:root {
  --green: #0aad4d;
  --green-dark: #088a3e;
  --green-soft: #e8f8ef;
  --green-mid: #b7ebc9;
  --ink: #152033;
  --ink-soft: #3a465c;
  --muted: #7a869c;
  --line: #e4eaf2;
  --line-strong: #d5dee9;
  --bg: #eef3f0;
  --bg-accent: #f7fbf8;
  --panel: #ffffff;
  --danger: #e5484d;
  --danger-soft: #fdecec;
  --shadow-sm: 0 1px 2px rgba(21, 32, 51, 0.04);
  --shadow-md: 0 10px 30px rgba(21, 32, 51, 0.06);
  --shadow-lg: 0 24px 60px rgba(21, 32, 51, 0.1);
  --radius: 14px;
  --radius-sm: 10px;
  --sidebar-w: 248px;
  --font-sans: "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  --font-display: "Avenir Next", "Segoe UI", "PingFang SC", "Hiragino Sans GB", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-sans);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 0% -10%, rgba(10, 173, 77, 0.12), transparent 55%),
    radial-gradient(900px 500px at 100% 0%, rgba(72, 140, 180, 0.08), transparent 50%),
    linear-gradient(180deg, #f4f8f5 0%, var(--bg) 40%, #e9efec 100%);
  background-attachment: fixed;
}

button, input, select {
  font: inherit;
}

button {
  border: 0;
  background: linear-gradient(180deg, #12b858 0%, var(--green) 100%);
  color: #fff;
  border-radius: 999px;
  padding: 10px 18px;
  cursor: pointer;
  font-weight: 600;
  letter-spacing: 0.01em;
  box-shadow: 0 8px 18px rgba(10, 173, 77, 0.22);
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease, color 0.15s ease;
}

button:hover {
  background: linear-gradient(180deg, #10a84f 0%, var(--green-dark) 100%);
  box-shadow: 0 10px 22px rgba(8, 138, 62, 0.28);
  transform: translateY(-1px);
}

button:active { transform: translateY(0); }

button.secondary,
button.ghost {
  background: #fff;
  color: var(--ink-soft);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-sm);
}

button.secondary:hover,
button.ghost:hover {
  background: var(--bg-accent);
  border-color: var(--green-mid);
  color: var(--green-dark);
  box-shadow: var(--shadow-sm);
}

button.danger {
  background: linear-gradient(180deg, #ef6a6e 0%, var(--danger) 100%);
  box-shadow: 0 8px 16px rgba(229, 72, 77, 0.2);
}

button.danger:hover {
  background: #d63d42;
}

input, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  background: #fff;
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus, select:focus {
  border-color: #79d4a0;
  box-shadow: 0 0 0 4px rgba(10, 173, 77, 0.12);
}

input::placeholder { color: #a3aec0; }

label {
  display: grid;
  gap: 8px;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 500;
}

.hidden { display: none !important; }

/* Login */
.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  position: relative;
  overflow: hidden;
}

.login-shell::before {
  content: "";
  position: absolute;
  inset: auto -10% -20% auto;
  width: 420px;
  height: 420px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(10, 173, 77, 0.18), transparent 70%);
  pointer-events: none;
}

.login-panel {
  width: min(420px, 100%);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 22px;
  padding: 36px 32px;
  display: grid;
  gap: 16px;
  box-shadow: var(--shadow-lg);
  position: relative;
  z-index: 1;
}

.login-panel h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 28px;
  letter-spacing: -0.02em;
}

.login-panel p {
  margin: -4px 0 4px;
  color: var(--muted);
  line-height: 1.5;
}

.login-panel button[type="submit"] {
  margin-top: 4px;
  width: 100%;
  padding: 12px 18px;
  border-radius: 12px;
}

.brand-mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: linear-gradient(145deg, #18c460, var(--green-dark));
  color: white;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 24px;
  box-shadow: 0 10px 24px rgba(10, 173, 77, 0.28);
}

/* Layout */
.layout {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(16px);
  border-right: 1px solid rgba(228, 234, 242, 0.9);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.brand-row {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 4px 8px 8px;
}

.brand-row strong {
  display: block;
  font-family: var(--font-display);
  font-size: 18px;
  letter-spacing: -0.02em;
}

.brand-row span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

nav { display: grid; gap: 6px; }

.nav {
  text-align: left;
  background: transparent;
  color: var(--ink-soft);
  border-radius: 12px;
  box-shadow: none;
  padding: 12px 14px;
  font-weight: 500;
}

.nav:hover {
  background: rgba(232, 248, 239, 0.7);
  color: var(--green-dark);
  transform: none;
  box-shadow: none;
}

.nav.active {
  background: var(--green-soft);
  color: var(--green-dark);
  box-shadow: inset 3px 0 0 var(--green);
}

.ghost {
  margin-top: auto;
  border-radius: 12px;
}

main {
  padding: 28px 32px 40px;
  overflow: auto;
  min-width: 0;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 22px;
}

.topbar h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 30px;
  letter-spacing: -0.03em;
  line-height: 1.15;
}

.topbar p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.profile {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid var(--line);
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-sm);
  white-space: nowrap;
}

.panel {
  background: var(--panel);
  border: 1px solid rgba(228, 234, 242, 0.95);
  border-radius: var(--radius);
  padding: 18px;
  display: grid;
  gap: 14px;
  box-shadow: var(--shadow-md);
}

.panel.narrow { max-width: 460px; }
.panel h3 {
  margin: 0;
  font-size: 18px;
  font-family: var(--font-display);
  letter-spacing: -0.02em;
}

.form-panel {
  max-width: 860px;
  padding: 24px;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(228, 234, 242, 0.95);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  flex-wrap: nowrap;
}

.toolbar-hint {
  margin: 0;
  color: var(--muted, #6b7280);
  font-size: 13px;
  white-space: nowrap;
  flex: 0 0 auto;
}

.filters {
  display: flex;
  gap: 10px;
  align-items: center;
  flex: 1 1 auto;
  min-width: 0;
}

.filters input,
.filters select {
  width: 220px;
  min-width: 0;
  max-width: 220px;
  flex: 0 0 220px;
  background: #fbfcfd;
}

.filters button {
  flex: 0 0 auto;
  white-space: nowrap;
}

.toolbar > button {
  flex: 0 0 auto;
  white-space: nowrap;
}

.subpage-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.subpage-header h3 {
  margin: 0;
  font-size: 20px;
  font-family: var(--font-display);
  letter-spacing: -0.02em;
}

.subpage-header .secondary {
  border-radius: 999px;
  padding: 8px 14px;
}

.detail-tabs {
  display: inline-flex;
  gap: 4px;
  margin-bottom: 16px;
  padding: 4px;
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: var(--shadow-sm);
}

.detail-tabs .tab {
  background: transparent;
  color: var(--muted);
  box-shadow: none;
  border-radius: 999px;
  padding: 8px 16px;
  font-weight: 500;
}

.detail-tabs .tab:hover {
  background: var(--green-soft);
  color: var(--green-dark);
  transform: none;
  box-shadow: none;
}

.detail-tabs .tab.active {
  background: var(--green);
  color: #fff;
  box-shadow: 0 6px 14px rgba(10, 173, 77, 0.22);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.form-grid .span-2 { grid-column: 1 / -1; }
.upload-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.upload-row input[type="file"] {
  width: auto;
  max-width: 260px;
  padding: 8px 10px;
}
.icon-preview {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
}

.actions {
  display: flex;
  gap: 10px;
  align-items: center;
  padding-top: 6px;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 13.5px;
}

th, td {
  border-bottom: 1px solid var(--line);
  padding: 13px 14px;
  text-align: left;
  vertical-align: middle;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

th {
  background: linear-gradient(180deg, #f8fbf9 0%, #f3f7f5 100%);
  color: var(--muted);
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.02em;
}

tbody tr:last-child td { border-bottom: 0; }

tr:hover td { background: #f7fbf8; }

td .row-actions {
  display: flex;
  gap: 6px;
  flex-wrap: nowrap;
  justify-content: flex-start;
}

td.col-actions {
  overflow: visible;
  white-space: nowrap;
}

td button {
  padding: 6px 11px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  box-shadow: none;
}

td button.secondary {
  background: #f4f7fa;
  border-color: transparent;
}

td button:hover { transform: none; }

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.2;
  vertical-align: middle;
}

.status-pill::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex: 0 0 auto;
}

.status-pill.on {
  background: var(--green-soft);
  color: var(--green-dark);
}

.status-pill.off {
  background: #f1f4f8;
  color: #8a95a8;
}

.cell-strong {
  font-weight: 600;
  color: var(--ink);
}

.cell-muted {
  color: var(--muted);
}

.cell-mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  letter-spacing: 0.02em;
}

.empty-cell {
  text-align: center !important;
  color: var(--muted);
  padding: 48px 12px !important;
  background:
    radial-gradient(circle at 50% 30%, rgba(10, 173, 77, 0.05), transparent 55%);
}

.error {
  color: var(--danger);
  min-height: 18px;
  font-size: 13px;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  background: rgba(21, 32, 51, 0.94);
  color: white;
  padding: 12px 16px;
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  z-index: 50;
  backdrop-filter: blur(8px);
}

@media (max-width: 960px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  main { padding: 20px 16px 32px; }
  .topbar h2 { font-size: 24px; }
  .filters {
    flex-wrap: wrap;
  }
  .filters input,
  .filters select {
    width: 180px;
    flex: 0 1 180px;
    max-width: 100%;
  }
  .toolbar {
    flex-wrap: wrap;
  }
  .form-grid { grid-template-columns: 1fr; }
}
