:root {
  --bg: #07101d;
  --bg-soft: #0b1626;
  --panel: rgba(16, 31, 51, .86);
  --panel-strong: #12243a;
  --line: rgba(144, 177, 218, .14);
  --line-strong: rgba(144, 177, 218, .24);
  --text: #eef6ff;
  --muted: #8da1b8;
  --teal: #42e8c5;
  --teal-soft: rgba(66, 232, 197, .12);
  --blue: #5b8cff;
  --violet: #8d6cff;
  --danger: #ff6b7a;
  --warning: #ffbd59;
  --radius: 18px;
  --shadow: 0 18px 50px rgba(0, 0, 0, .28);
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at 82% 10%, rgba(91, 140, 255, .12), transparent 30%),
    radial-gradient(circle at 18% 85%, rgba(66, 232, 197, .08), transparent 28%),
    var(--bg);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; }
button, select { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
}
a { color: inherit; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 250px minmax(0, 1fr); }
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px 18px;
  border-right: 1px solid var(--line);
  background: rgba(7, 16, 29, .92);
  backdrop-filter: blur(20px);
  z-index: 30;
  display: flex;
  flex-direction: column;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 28px; }
.brand-mark, .login-mark {
  width: 42px; height: 42px; display: grid; place-items: center;
  border-radius: 13px; color: #041511; font-weight: 900;
  background: linear-gradient(135deg, var(--teal), #77f2ee);
  box-shadow: 0 8px 30px rgba(66, 232, 197, .2);
}
.brand strong { display: block; font-size: 16px; letter-spacing: .02em; }
.brand span { display: block; margin-top: 4px; color: var(--muted); font-size: 10px; letter-spacing: .18em; }
.nav-list { display: grid; gap: 6px; }
.nav-item {
  width: 100%; padding: 12px 14px; display: flex; align-items: center; gap: 12px;
  border: 1px solid transparent; border-radius: 12px; color: var(--muted);
  background: transparent; text-align: left; transition: .18s ease;
}
.nav-item span { width: 22px; color: #aac2de; font-size: 18px; text-align: center; }
.nav-item:hover { color: var(--text); background: rgba(255,255,255,.035); }
.nav-item.active { color: var(--text); border-color: rgba(66,232,197,.17); background: var(--teal-soft); }
.nav-item.active span { color: var(--teal); }
.sidebar-foot { margin-top: auto; display: grid; gap: 14px; }
.system-state { padding: 12px; display: flex; gap: 10px; align-items: center; border: 1px solid var(--line); border-radius: 13px; background: rgba(255,255,255,.025); }
.system-state strong, .system-state small { display: block; }
.system-state strong { font-size: 13px; }
.system-state small { margin-top: 3px; color: var(--muted); font-size: 11px; }
.status-dot { width: 8px; height: 8px; flex: 0 0 auto; border-radius: 50%; background: var(--teal); box-shadow: 0 0 0 5px rgba(66,232,197,.1), 0 0 16px rgba(66,232,197,.55); }

.workspace { min-width: 0; }
.topbar {
  min-height: 88px; padding: 17px 30px; display: flex; align-items: center; gap: 18px;
  border-bottom: 1px solid var(--line); background: rgba(7,16,29,.72); backdrop-filter: blur(18px);
  position: sticky; top: 0; z-index: 20;
}
.topbar h1 { margin: 2px 0 0; font-size: 22px; }
.eyebrow { margin: 0; color: var(--teal); font-size: 10px; font-weight: 800; letter-spacing: .18em; text-transform: uppercase; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.group-picker-label { color: var(--muted); font-size: 12px; }
.group-picker, input, textarea, select {
  color: var(--text); border: 1px solid var(--line-strong); border-radius: 10px;
  background: rgba(8, 19, 33, .9); padding: 10px 12px;
}
.group-picker { width: min(280px, 28vw); }
textarea { width: 100%; resize: vertical; line-height: 1.6; }
input { width: 100%; }
input::placeholder, textarea::placeholder { color: #5f748c; }
.admin-chip { display: flex; align-items: center; gap: 8px; margin-left: 5px; color: var(--muted); font-size: 12px; }
.avatar { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; color: white; background: linear-gradient(135deg, var(--blue), var(--violet)); font-weight: 700; }
.menu-button { display: none; border: 0; color: var(--text); background: transparent; font-size: 24px; }

.content { max-width: 1480px; margin: 0 auto; padding: 30px; }
.view { display: none; animation: view-in .18s ease both; }
.view.active { display: block; }
@keyframes view-in { from { opacity: 0; transform: translateY(5px); } }
.hero-panel {
  min-height: 205px; padding: 34px; border: 1px solid rgba(91,140,255,.18); border-radius: 24px;
  display: flex; align-items: center; justify-content: space-between; gap: 28px;
  background:
    linear-gradient(120deg, rgba(18,36,58,.96), rgba(13,30,50,.8)),
    radial-gradient(circle at 80% 20%, rgba(66,232,197,.22), transparent 30%);
  box-shadow: var(--shadow); overflow: hidden; position: relative;
}
.hero-panel::after { content: ""; position: absolute; width: 330px; height: 330px; right: -130px; top: -170px; border: 1px solid rgba(66,232,197,.16); border-radius: 50%; box-shadow: 0 0 0 45px rgba(66,232,197,.025), 0 0 0 90px rgba(91,140,255,.018); }
.hero-panel h2 { max-width: 650px; margin: 12px 0 10px; font-size: clamp(25px, 3vw, 39px); line-height: 1.18; }
.hero-panel p:last-child { margin: 0; color: var(--muted); }
.hero-status { min-width: 150px; padding: 20px; position: relative; z-index: 1; text-align: center; border: 1px solid rgba(66,232,197,.18); border-radius: 18px; background: rgba(5,17,28,.54); }
.hero-status strong, .hero-status small { display: block; }
.hero-status strong { margin-top: 12px; }
.hero-status small { margin-top: 6px; color: var(--muted); }
.pulse { display: block; width: 15px; height: 15px; margin: auto; border-radius: 50%; background: var(--teal); box-shadow: 0 0 0 8px rgba(66,232,197,.08), 0 0 25px rgba(66,232,197,.5); }

.metric-grid { margin-top: 18px; display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 14px; }
.metric-card, .panel { border: 1px solid var(--line); background: var(--panel); box-shadow: 0 12px 38px rgba(0,0,0,.16); }
.metric-card { padding: 20px; border-radius: 16px; }
.metric-card span { color: var(--muted); font-size: 12px; }
.metric-card strong { display: block; margin-top: 10px; font-size: 26px; }
.metric-card small { display: block; margin-top: 8px; color: #6f849b; }
.split-grid { margin-top: 18px; display: grid; grid-template-columns: 1.25fr .75fr; gap: 18px; }
.panel { padding: 22px; border-radius: var(--radius); }
.panel-heading, .section-intro { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.panel-heading h3 { margin: 7px 0 0; font-size: 17px; }
.count-badge { min-width: 34px; height: 28px; padding: 0 9px; display: grid; place-items: center; border-radius: 20px; color: var(--teal); background: var(--teal-soft); font-weight: 800; }
.group-list, .record-list { margin-top: 18px; display: grid; gap: 9px; }
.group-row, .record-row { padding: 13px 14px; display: flex; align-items: center; gap: 12px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255,255,255,.022); }
.group-icon { width: 38px; height: 38px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 11px; color: var(--teal); background: var(--teal-soft); }
.group-main, .record-main { min-width: 0; flex: 1; }
.group-main strong, .record-main strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.group-main small, .record-main small { display: block; margin-top: 5px; color: var(--muted); overflow-wrap: anywhere; }
.tag { padding: 5px 8px; border-radius: 8px; color: var(--teal); background: var(--teal-soft); font-size: 10px; white-space: nowrap; }
.tag.muted { color: var(--muted); background: rgba(141,161,184,.1); }
.tag.danger { color: var(--danger); background: rgba(255,107,122,.1); }
.link-button, .delete-button { border: 0; background: transparent; text-decoration: none; }
.link-button { color: #8db2ff; font-size: 12px; }
.delete-button { color: var(--danger); padding: 7px 9px; border-radius: 8px; }
.delete-button:hover { background: rgba(255,107,122,.1); }
.today-stats { margin-top: 18px; display: grid; grid-template-columns: repeat(2,1fr); gap: 10px; }
.today-item { padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255,255,255,.02); }
.today-item strong { display: block; font-size: 22px; }
.today-item span { display: block; margin-top: 5px; color: var(--muted); font-size: 11px; }

.section-intro { margin-bottom: 20px; }
.section-intro h2 { margin: 7px 0 7px; font-size: 24px; }
.section-intro p:last-child { margin: 0; color: var(--muted); }
.primary-button, .secondary-button, .ghost-button {
  min-height: 40px; padding: 9px 16px; border-radius: 10px; font-weight: 700; transition: .18s ease;
}
.primary-button { border: 0; color: #061612; background: linear-gradient(135deg, var(--teal), #71eee1); box-shadow: 0 8px 24px rgba(66,232,197,.15); }
.primary-button:hover { filter: brightness(1.07); transform: translateY(-1px); }
.secondary-button { color: var(--text); border: 1px solid rgba(91,140,255,.28); background: rgba(91,140,255,.1); }
.ghost-button { width: 100%; color: var(--muted); border: 1px solid var(--line); background: transparent; }
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.setting-card { padding: 21px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
.setting-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.setting-head h3 { margin: 0; font-size: 16px; }
.setting-card > p { min-height: 38px; margin: 9px 0 18px; color: var(--muted); font-size: 12px; line-height: 1.55; }
.field-row { display: grid; grid-template-columns: repeat(2,1fr); gap: 10px; }
.field label { display: block; margin-bottom: 6px; color: var(--muted); font-size: 11px; }
.field select, .field input { width: 100%; }
.switch { width: 44px; height: 24px; position: relative; display: inline-block; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; border-radius: 20px; background: #314156; transition: .2s; }
.switch span::before { content: ""; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; border-radius: 50%; background: white; transition: .2s; }
.switch input:checked + span { background: var(--teal); }
.switch input:checked + span::before { transform: translateX(20px); }
.tabbar { display: flex; gap: 8px; margin-bottom: 14px; overflow-x: auto; }
.tab { padding: 10px 14px; flex: 0 0 auto; color: var(--muted); border: 1px solid var(--line); border-radius: 10px; background: rgba(255,255,255,.02); }
.tab.active { color: var(--text); border-color: rgba(66,232,197,.22); background: var(--teal-soft); }
.manager-panel { min-height: 340px; }
.add-row { display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 12px; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.inline-form { display: grid; grid-template-columns: minmax(160px,1fr) minmax(140px,.6fr) auto; gap: 10px; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.record-evidence { margin-top: 6px; color: #b8c7d8; font-size: 12px; white-space: pre-wrap; overflow-wrap: anywhere; }
.empty-state { grid-column: 1/-1; padding: 32px 12px; color: var(--muted); text-align: center; }
.chart { min-height: 260px; margin-top: 20px; display: flex; align-items: end; gap: 10px; padding: 20px 4px 0; border-top: 1px solid var(--line); overflow-x: auto; }
.bar-column { min-width: 44px; height: 210px; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 7px; }
.bar { width: 24px; min-height: 3px; border-radius: 7px 7px 2px 2px; background: linear-gradient(180deg, var(--teal), var(--blue)); box-shadow: 0 0 18px rgba(66,232,197,.14); }
.bar-column strong { font-size: 11px; }
.bar-column small { color: var(--muted); font-size: 9px; }
.toast { position: fixed; right: 24px; bottom: 24px; max-width: min(380px, calc(100vw - 40px)); padding: 13px 17px; z-index: 100; border: 1px solid rgba(66,232,197,.22); border-radius: 12px; color: var(--text); background: #13273c; box-shadow: var(--shadow); opacity: 0; transform: translateY(15px); pointer-events: none; transition: .2s; }
.toast.show { opacity: 1; transform: none; }
.toast.error { border-color: rgba(255,107,122,.3); }
.sidebar-backdrop { display: none; }

.login-page { min-height: 100vh; display: grid; place-items: center; padding: 22px; }
.login-card { width: min(440px, 100%); padding: 38px; border: 1px solid var(--line-strong); border-radius: 25px; background: rgba(15,31,50,.9); box-shadow: var(--shadow); text-align: center; }
.login-mark { width: 58px; height: 58px; margin: 0 auto 22px; border-radius: 18px; font-size: 20px; }
.login-card h1 { margin: 10px 0 14px; font-size: 30px; }
.login-copy { color: var(--muted); line-height: 1.75; }
.login-copy code { color: var(--teal); }
.security-note { margin: 22px 0; padding: 12px; display: flex; align-items: center; justify-content: center; gap: 10px; border: 1px solid var(--line); border-radius: 12px; color: #b9cce0; background: rgba(255,255,255,.025); font-size: 12px; }
.login-error { padding: 11px; border-radius: 10px; color: #ffb6be; background: rgba(255,107,122,.1); }
.login-action { display: flex; align-items: center; justify-content: center; margin-top: 20px; text-decoration: none; }
.login-footnote { margin: 18px 0 0; color: #64788e; font-size: 11px; }

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; transform: translateX(-105%); width: 260px; transition: .22s ease; }
  .sidebar.open { transform: none; }
  .sidebar-backdrop { position: fixed; inset: 0; z-index: 25; background: rgba(1,6,12,.6); backdrop-filter: blur(3px); }
  .sidebar-backdrop.show { display: block; }
  .menu-button { display: block; }
  .metric-grid { grid-template-columns: repeat(2,1fr); }
  .split-grid { grid-template-columns: 1fr; }
}

@media (max-width: 680px) {
  .topbar { min-height: 76px; padding: 13px 16px; align-items: center; }
  .topbar .eyebrow, .topbar h1, .group-picker-label, .admin-chip { display: none; }
  .topbar-actions { min-width: 0; flex: 1; }
  .group-picker { width: 100%; }
  .content { padding: 16px; }
  .hero-panel { min-height: 230px; padding: 24px; align-items: flex-start; flex-direction: column; }
  .hero-panel h2 { font-size: 27px; }
  .hero-status { width: 100%; display: flex; align-items: center; gap: 10px; text-align: left; }
  .hero-status .pulse { margin: 0; }
  .hero-status strong, .hero-status small { margin: 0; }
  .hero-status small { margin-left: auto; }
  .metric-grid { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; }
  .metric-card { padding: 16px; }
  .metric-card strong { font-size: 23px; }
  .panel { padding: 17px; }
  .section-intro { align-items: flex-start; flex-direction: column; }
  .section-intro .primary-button, .section-intro .secondary-button { width: 100%; }
  .settings-grid { grid-template-columns: 1fr; }
  .field-row, .inline-form { grid-template-columns: 1fr; }
  .add-row { grid-template-columns: 1fr; }
  .add-row .primary-button { width: 100%; }
  .record-row { align-items: flex-start; }
  .login-card { padding: 28px 21px; }
}
