/* Food Safety Agent - modern operations workspace */
:root {
  --page: #f4f7fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #eef2f7;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;
  --text: #0f172a;
  --muted: #64748b;
  --nav: #08111f;
  --nav-2: #0f1c30;
  --primary: #2563eb;
  --primary-strong: #1d4ed8;
  --primary-soft: #eff6ff;
  --ok: #047857;
  --ok-bg: #ecfdf5;
  --warn: #b45309;
  --warn-bg: #fffbeb;
  --bad: #be123c;
  --bad-bg: #fff1f2;
  --info: #0369a1;
  --info-bg: #f0f9ff;
  --radius: 8px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05);
  --shadow-md: 0 12px 32px rgba(15, 23, 42, .09);
}
html[data-theme="dark"] {
  --page: #0b1220;
  --surface: #111827;
  --surface-2: #0f172a;
  --surface-3: #1e293b;
  --line: #263244;
  --line-strong: #475569;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --primary-soft: rgba(37, 99, 235, .16);
  --ok-bg: rgba(4, 120, 87, .16);
  --warn-bg: rgba(180, 83, 9, .16);
  --bad-bg: rgba(190, 18, 60, .16);
  --info-bg: rgba(3, 105, 161, .16);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .2);
  --shadow-md: 0 16px 40px rgba(0, 0, 0, .28);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { background: var(--page); }
body {
  margin: 0;
  background: var(--page);
  color: var(--text);
  font: 15px/1.6 "MiSans", "Noto Sans SC", "PingFang SC", "Microsoft YaHei UI", sans-serif;
  font-optical-sizing: auto;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
h1, h2, h3, p { letter-spacing: 0; }
h1 { font-size: 26px; line-height: 1.2; margin: 0; font-weight: 720; }
h2 { font-size: 30px; line-height: 1.22; margin: 0; font-weight: 750; }
h3 { font-size: 15px; line-height: 1.35; margin: 0; font-weight: 700; }
.card h3 .ui-icon { display: inline-block; vertical-align: -3px; }
b { font-weight: 650; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.clickable { cursor: pointer; }
.warnText { color: var(--warn); }
.badText { color: var(--bad); font-weight: 650; }
.eyebrow {
  display: inline-flex;
  color: var(--primary);
  font-size: 12px;
  font-weight: 750;
  text-transform: uppercase;
}

/* App shell */
.shell { min-height: 100vh; background: var(--page); }
.global-progress {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 100;
  height: 3px;
  width: 32%;
  background: linear-gradient(90deg, #2563eb, #60a5fa, #2563eb);
  box-shadow: 0 0 10px rgba(96, 165, 250, .7);
  animation: loadingBar 1.1s ease-in-out infinite;
}
.app-main { min-width: 0; }
.sidebar { display: none; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 35;
  min-height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, .9);
  border-bottom: 1px solid rgba(226, 232, 240, .9);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}
.mobile-brand { display: flex; align-items: center; gap: 9px; min-width: 0; }
.mobile-brand b { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-title { display: none; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 7px; }
.icon-btn {
  width: 40px;
  height: 40px;
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #475569;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  transition: color .18s ease, border-color .18s ease, background .18s ease;
}
.icon-btn:hover { color: var(--primary); border-color: var(--line-strong); background: var(--surface-2); }
.top-action { min-height: 38px; padding: 8px 11px; gap: 6px; font-size: 13px; }
.content {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 16px 14px 112px;
}
.brand-mark {
  width: 36px;
  height: 36px;
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: var(--primary);
  border-radius: var(--radius);
  box-shadow: 0 6px 16px rgba(37, 99, 235, .24);
}
.brand-mark-lg { width: 44px; height: 44px; border-radius: 10px; }
.ui-icon { display: block; flex: none; }

/* Cards and rows */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
}
.card-list { display: flex; flex-direction: column; gap: 10px; }
.card-list .card { margin-bottom: 0; }
.row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
  transition: background .18s ease;
}
.row:last-child { border-bottom: none; }
.row.clickable:hover { background: var(--surface-2); }
.row b, .row small { display: block; }
.row small { line-height: 1.45; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.text-link {
  appearance: none;
  border: 0;
  background: transparent;
  padding: 3px 0;
  color: var(--primary);
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
}
.entry {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  color: var(--text);
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;
}
.entry:hover { border-color: var(--line-strong); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.entry:active { transform: translateY(0); }
.entry.dim { opacity: .55; }
.entry b, .entry small { display: block; }
.entry small { margin-top: 2px; color: var(--muted); line-height: 1.4; }
.entry-icon {
  width: 40px;
  height: 40px;
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  background: var(--primary-soft);
  border-radius: var(--radius);
}
.entry-emoji { font-size: 22px; width: 32px; text-align: center; }
.grade-badge {
  width: 38px;
  height: 38px;
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #475569;
  background: var(--surface-3);
  border-radius: 50%;
}
.grade-badge.ok { color: var(--ok); background: var(--ok-bg); }
.grade-badge.warn { color: var(--warn); background: var(--warn-bg); }
.grade-badge.bad { color: var(--bad); background: var(--bad-bg); }
.grade-badge.gray { color: #475569; background: var(--surface-3); }
.chev { color: #94a3b8; font-size: 24px; line-height: 1; }
.col-right { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; }
.kv { display: flex; justify-content: space-between; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.kv:last-child { border-bottom: none; }
.kv span { color: var(--muted); flex: none; }
.kv b { max-width: 68%; text-align: right; overflow-wrap: anywhere; }

/* Dashboard */
.hero {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 176px;
  margin-bottom: 14px;
  padding: 24px;
  color: #fff;
  background: linear-gradient(135deg, #08111f 0%, #12294a 70%, #173b6d 100%);
  border: 1px solid rgba(148, 163, 184, .2);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 44px rgba(15, 23, 42, .18);
}
.hero-wave-canvas {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  opacity: .98;
}
.hero-copy { position: relative; z-index: 1; max-width: 620px; }
.hero-kicker {
  display: inline-flex;
  margin-bottom: 10px;
  padding: 4px 9px;
  color: #bfdbfe;
  background: rgba(59, 130, 246, .16);
  border: 1px solid rgba(147, 197, 253, .2);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}
.hero h1 { color: #fff; font-size: 30px; }
.hero p { margin: 9px 0 0; color: #cbd5e1; font-size: 14px; max-width: 520px; }
.page-home .hero::after {
  content: "";
  position: absolute;
  inset: -60% -45%;
  pointer-events: none;
  background: linear-gradient(105deg, transparent 38%, rgba(191, 219, 254, .13) 50%, transparent 62%);
  transform: translateX(-42%);
  animation: heroSheen 7.5s ease-in-out 1.2s infinite;
}
.page-home .hero-copy,
.page-home .hero-mark,
.page-home > .cta,
.page-home .stat,
.page-home .entry,
.page-home > .card { animation: riseIn .72s cubic-bezier(.22, 1, .36, 1) both; }
.page-home .hero-copy { animation-delay: .06s; }
.page-home .hero-mark { animation-delay: .2s, 1.1s; }
.page-home > .cta { animation-delay: .24s; }
.page-home .stat:nth-child(1) { animation-delay: .32s; }
.page-home .stat:nth-child(2) { animation-delay: .39s; }
.page-home .stat:nth-child(3) { animation-delay: .46s; }
.page-home .entry { animation-delay: var(--entry-delay, .5s); }
.page-home > .card { animation-delay: .8s; }
.page-home .hero h1,
.login-brand-copy h2 {
  color: transparent;
  background: linear-gradient(105deg, #fff 0%, #fff 34%, #bfdbfe 48%, #fff 62%, #fff 100%);
  background-size: 230% auto;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: textFlow 7s ease-in-out 1s infinite;
}
.hero-mark {
  position: relative;
  z-index: 1;
  width: 82px;
  height: 82px;
  flex: none;
  display: none;
  align-items: center;
  justify-content: center;
  color: #93c5fd;
  background: rgba(255, 255, 255, .08);
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 18px;
}
.page-home .hero-mark { animation: riseIn .72s cubic-bezier(.22, 1, .36, 1) .2s both, heroFloat 5.5s ease-in-out 1.1s infinite; }
.cta {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 13px;
  margin-bottom: 14px;
  padding: 16px;
  color: var(--text);
  text-align: left;
  background: var(--surface);
  border: 1px solid #bfdbfe;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;
}
.cta:hover { border-color: #60a5fa; box-shadow: var(--shadow-md); transform: translateY(-1px); }
.cta:active { transform: translateY(0); }
.cta-icon {
  width: 44px;
  height: 44px;
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: var(--primary);
  border-radius: var(--radius);
}
.cta b { display: block; font-size: 16px; }
.cta small { color: var(--muted); }
.cta-arrow { margin-left: auto; color: #94a3b8; }
.stat-row { display: grid; grid-template-columns: 1fr; gap: 10px; margin-bottom: 14px; }
.stat {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 78px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.stat-icon {
  width: 38px;
  height: 38px;
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  background: var(--primary-soft);
  border-radius: var(--radius);
}
.stat-icon-safe { color: var(--ok); background: var(--ok-bg); }
.stat-icon-danger { color: var(--bad); background: var(--bad-bg); }
.stat b { display: block; font-size: 22px; line-height: 1.1; }
.stat span:not(.stat-icon) { color: var(--muted); font-size: 12px; }
.stat.warn b { color: var(--bad); }

/* Buttons */
.btn {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 14px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  cursor: pointer;
  white-space: nowrap;
  transition: background .18s ease, border-color .18s ease, color .18s ease, box-shadow .18s ease, transform .18s ease;
}
.btn:hover:not(:disabled) { background: var(--surface-2); border-color: #94a3b8; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn.primary { color: #fff; background: var(--primary); border-color: var(--primary); box-shadow: 0 6px 16px rgba(37, 99, 235, .18); }
.btn.primary:hover:not(:disabled) { background: var(--primary-strong); border-color: var(--primary-strong); }
.btn.danger { color: var(--bad); border-color: #fecdd3; background: #fff; }
.btn.danger:hover:not(:disabled) { background: var(--bad-bg); border-color: #fda4af; }
.btn.small { min-height: 34px; padding: 6px 10px; font-size: 13px; }
.btn.block { width: 100%; margin-top: 10px; }
.btn.grow { flex: 1; }
.btn:disabled { opacity: .5; cursor: not-allowed; box-shadow: none; }
.btn-row { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.page-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.page-title h1 { font-size: 24px; }
.page-title select { width: auto; min-height: 38px; padding: 7px 9px; }

/* Forms */
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; color: #475569; font-size: 13px; font-weight: 600; }
.field small { color: var(--muted); font-size: 11px; font-weight: 400; }
.field-row { display: grid; grid-template-columns: 1fr; gap: 10px; }
input, select, textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  outline: none;
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}
textarea { min-height: 92px; resize: vertical; }
input:hover, select:hover, textarea:hover { border-color: #94a3b8; }
input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .14);
}
.edit-box { border-top: 1px dashed var(--line); margin-top: 10px; padding-top: 12px; }

/* Combo box */
.combo { position: relative; }
.combo input { width: 100%; }
.combo-list {
  position: absolute;
  top: calc(100% + 5px);
  left: 0;
  right: 0;
  z-index: 50;
  max-height: 240px;
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
}
.combo-item {
  display: block;
  width: 100%;
  padding: 11px 12px;
  color: var(--text);
  text-align: left;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.combo-item:last-child { border-bottom: 0; }
.combo-item:hover { background: var(--surface-2); }
.combo-item.create { display: flex; align-items: center; gap: 6px; color: var(--primary); font-weight: 700; }
.combo-empty { padding: 11px 12px; color: var(--muted); font-size: 13px; }

/* Alerts and status */
.alert {
  padding: 11px 12px;
  margin-bottom: 12px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-size: 13px;
}
.alert.info { color: var(--info); background: var(--info-bg); border-color: #bae6fd; }
.alert.warn { color: var(--warn); background: var(--warn-bg); border-color: #fde68a; }
.alert.bad { color: var(--bad); background: var(--bad-bg); border-color: #fecdd3; }
.alert.ok { color: var(--ok); background: var(--ok-bg); border-color: #a7f3d0; }
.chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 26px;
  padding: 3px 9px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}
.chip.ok { color: var(--ok); background: var(--ok-bg); border-color: #a7f3d0; }
.chip.warn { color: var(--warn); background: var(--warn-bg); border-color: #fde68a; }
.chip.bad { color: var(--bad); background: var(--bad-bg); border-color: #fecdd3; }
.chip.gray { color: #475569; background: var(--surface-3); border-color: var(--line); }
.chips { display: flex; gap: 8px; margin-bottom: 14px; padding-bottom: 2px; overflow-x: auto; scrollbar-width: thin; }
.chip-btn {
  min-height: 36px;
  flex: none;
  padding: 6px 13px;
  color: #334155;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 13px;
  cursor: pointer;
  transition: border-color .18s ease, background .18s ease, color .18s ease;
}
.chip-btn:hover { border-color: var(--line-strong); }
.chip-btn.on { color: #fff; background: var(--nav-2); border-color: var(--nav-2); }

/* Verdict */
.verdict {
  position: relative;
  overflow: hidden;
  padding: 26px 18px;
  margin-bottom: 12px;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-top: 5px solid var(--line-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.verdict.ok { border-top-color: var(--ok); background: linear-gradient(180deg, var(--ok-bg), #fff 74%); }
.verdict.warn { border-top-color: var(--warn); background: linear-gradient(180deg, var(--warn-bg), #fff 74%); }
.verdict.bad { border-top-color: var(--bad); background: linear-gradient(180deg, var(--bad-bg), #fff 74%); }
.verdict.gray { border-top-color: #94a3b8; background: linear-gradient(180deg, var(--surface-3), #fff 74%); }
.verdict-icon { display: flex; justify-content: center; }
.verdict-grade { margin: 6px 0; font-size: 34px; font-weight: 800; }
.verdict.ok .verdict-grade { color: var(--ok); }
.verdict.warn .verdict-grade { color: var(--warn); }
.verdict.bad .verdict-grade { color: var(--bad); }
.verdict-sub { margin: 0; color: var(--muted); font-size: 13px; }
.verdict p { margin: 7px 0 0; }

/* Steps */
.steps { display: flex; align-items: center; gap: 7px; margin-bottom: 14px; padding: 7px; background: var(--surface-3); border-radius: 999px; }
.step {
  flex: none;
  min-height: 36px;
  padding: 7px 13px;
  color: #475569;
  background: transparent;
  border: 0;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 650;
}
.step.link { cursor: pointer; }
.step.on { color: #fff; background: var(--nav-2); box-shadow: 0 5px 14px rgba(15, 23, 42, .16); }
.step-line { flex: 1; height: 1px; background: #cbd5e1; }

/* Detection grid */
.grid-wrap {
  max-height: 440px;
  overflow: auto;
  padding: 8px;
  margin-bottom: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.grid-table { width: 100%; min-width: 560px; border-collapse: separate; border-spacing: 0; }
.grid-table th, .grid-table td { padding: 8px 6px; text-align: center; border-bottom: 1px solid var(--line); }
.grid-table th { position: sticky; top: 0; z-index: 1; color: #475569; background: var(--surface-2); font-size: 12px; }
.grid-table .gname { min-width: 130px; text-align: left; font-size: 12px; }
.grid-table .th-sub { display: block; color: var(--muted); font-size: 10px; font-weight: 400; }
.cell { padding: 5px 8px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 6px; font-size: 12px; cursor: pointer; }
.cell.hit { color: var(--bad); background: var(--bad-bg); border-color: #fecdd3; font-weight: 700; }
.cell-input { width: 100%; min-height: 30px; padding: 4px; margin-top: 3px; font-size: 12px; }
.switch-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; }
.switch-row.big { padding: 13px; margin-bottom: 10px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); }
.switch-row.big span b { display: block; }
.switch-row input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--primary); }

/* Navigation */
.tabbar {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(8px + env(safe-area-inset-bottom));
  z-index: 45;
  height: 66px;
  display: flex;
  align-items: stretch;
  padding: 6px 4px;
  background: rgba(255, 255, 255, .94);
  border: 1px solid rgba(203, 213, 225, .9);
  border-radius: 18px;
  box-shadow: 0 16px 44px rgba(15, 23, 42, .18);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}
.tabbar a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border: 1px solid transparent;
  border-radius: 12px;
  color: #64748b;
  font-size: 11px;
  cursor: pointer;
  user-select: none;
  transition: color .18s ease, background .18s ease, border-color .18s ease, box-shadow .18s ease, transform .18s ease;
}
.tabbar a:not(.tab-cta):hover {
  color: var(--primary);
  background: rgba(37, 99, 235, .08);
  border-color: rgba(37, 99, 235, .12);
  box-shadow: 0 8px 18px rgba(15, 23, 42, .12);
  transform: translateY(-2px);
}
.tabbar a:not(.tab-cta):active { transform: translateY(0); }
.tabbar a.on {
  color: var(--primary);
  background: var(--primary-soft);
  border-color: #bfdbfe;
  box-shadow: 0 6px 14px rgba(37, 99, 235, .12);
  font-weight: 750;
}
.tabbar .ticon { display: inline-flex; }
.tab-cta {
  flex: 0 0 58px !important;
  align-self: center;
  width: 54px;
  height: 54px;
  margin: -22px 7px 0;
  color: #fff !important;
  background: var(--primary);
  border: 5px solid var(--page);
  border-radius: 50%;
  box-shadow: 0 9px 24px rgba(37, 99, 235, .34);
}

/* Commercial capability shells */
.page-kicker { display: block; margin-bottom: 3px; color: var(--primary); font-size: 11px; font-weight: 750; text-transform: uppercase; }
.entry-status {
  flex: none;
  padding: 3px 8px;
  color: var(--warn);
  background: var(--warn-bg);
  border: 1px solid #fde68a;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}
.capability-layout { display: grid; gap: 14px; }
.capability-nav { display: flex; flex-direction: column; gap: 7px; }
.capability-nav button {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  color: var(--text);
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color .18s ease, background .18s ease, box-shadow .18s ease;
}
.capability-nav button:hover { border-color: var(--line-strong); background: var(--surface-2); }
.capability-nav button.on { background: var(--primary-soft); border-color: #bfdbfe; box-shadow: 0 6px 14px rgba(37, 99, 235, .09); }
.capability-nav b, .capability-nav small { display: block; }
.capability-nav small { margin-top: 2px; color: var(--muted); font-size: 11px; }
.capability-code {
  width: 32px;
  height: 32px;
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  background: var(--primary-soft);
  border-radius: var(--radius);
  font-weight: 800;
}
.capability-detail {
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.capability-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.capability-heading h2 { font-size: 24px; }
.status-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  padding: 4px 9px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 750;
  white-space: nowrap;
}
.status-badge.planned { color: var(--warn); background: var(--warn-bg); border-color: #fde68a; }
.status-badge.partial { color: var(--primary); background: var(--primary-soft); border-color: #bfdbfe; }
.capability-summary { margin: 16px 0 18px; color: #475569; line-height: 1.7; }
.capability-columns { display: grid; gap: 18px; }
.capability-columns h3 { margin-bottom: 8px; }
.capability-columns ul { margin: 0; padding-left: 19px; color: #475569; }
.capability-columns li { margin-bottom: 6px; }
.planned-grid { display: grid; gap: 10px; margin-bottom: 14px; }
.planned-card {
  position: relative;
  min-height: 128px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.planned-card b, .planned-card small { display: block; }
.planned-card b { margin-top: 11px; }
.planned-card small { margin-top: 5px; color: var(--muted); line-height: 1.5; }
.planned-card .status-badge { position: absolute; top: 12px; right: 12px; }
.planned-icon {
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  background: var(--primary-soft);
  border-radius: var(--radius);
}
.channel-options { display: grid; gap: 9px; }
.channel-option {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 12px;
  color: var(--text);
  text-align: left;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
}
.channel-option.on { background: var(--primary-soft); border-color: #bfdbfe; }
.channel-option b, .channel-option small { display: block; }
.channel-option small { margin-top: 2px; color: var(--muted); }
.channel-icon {
  width: 38px;
  height: 38px;
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

/* Global search, exception pages and pagination */
.command-overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 12vh 16px 24px;
  background: rgba(8, 17, 31, .52);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.command-palette {
  width: min(620px, 100%);
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 28px 80px rgba(0, 0, 0, .32);
}
.command-input { display: flex; align-items: center; gap: 10px; padding: 13px 14px; border-bottom: 1px solid var(--line); color: var(--muted); }
.command-input input { flex: 1; min-height: 36px; padding: 4px 0; background: transparent; border: 0; box-shadow: none; }
.command-input input:focus { box-shadow: none; }
.command-list { max-height: min(54vh, 460px); overflow: auto; padding: 6px; }
.command-list > button {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  color: var(--text);
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: var(--radius);
  cursor: pointer;
}
.command-list > button:hover { background: var(--surface-2); }
.command-list b, .command-list small { display: block; }
.command-list small { color: var(--muted); }
.command-hint { padding: 9px 14px; color: var(--muted); background: var(--surface-2); border-top: 1px solid var(--line); font-size: 11px; }
.exception-page {
  max-width: 620px;
  margin: 7vh auto 0;
  padding: 34px;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
}
.exception-code { display: block; color: var(--primary); font-size: 56px; font-weight: 850; line-height: 1; }
.exception-page h1 { margin: 12px 0 8px; }
.exception-page p { margin: 0 auto 18px; color: var(--muted); max-width: 460px; }
.exception-page .btn-row { justify-content: center; }
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 12px;
}
.system-notice-stack {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 96;
  width: min(430px, calc(100vw - 28px));
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.system-notice {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 11px;
  color: #fff;
  background: rgba(8, 17, 31, .96);
  border: 1px solid rgba(148, 163, 184, .28);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
}
.system-notice.update { border-color: rgba(96, 165, 250, .5); }
.ops-grid { display: grid; gap: 12px; margin-bottom: 12px; }
.ops-panel {
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.ops-list { margin-top: 10px; }
.ops-list > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}
.ops-list > div:last-child { border-bottom: 0; }
.remember-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  color: #334155;
  font-size: 12px;
  font-weight: 550;
  cursor: pointer;
}
.remember-row input { width: 17px; height: 17px; min-height: 0; margin: 0; accent-color: var(--primary); }

/* Login */
.login-page {
  position: relative;
  overflow: hidden;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 22px 16px;
  background: var(--page);
}
.login-wave-canvas {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  opacity: .98;
}
.login-page > .login-brand,
.login-page > .login-panel { position: relative; z-index: 1; }
.login-brand { display: none; }
.login-panel { width: 100%; max-width: 430px; animation: panelIn .9s cubic-bezier(.22, 1, .36, 1) .16s both; }
.login-mobile-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 28px; }
.login-panel h1 { margin: 7px 0 6px; font-size: 28px; }
.login-panel .sub { margin: 0 0 20px; color: var(--muted); }
.login-panel > .card { padding: 18px; box-shadow: var(--shadow-md); }
.login-panel > .tiny { margin-top: 12px; text-align: center; }
.captcha-field { margin-bottom: 12px; }
.captcha-label { display: block; margin-bottom: 6px; color: #475569; font-size: 13px; font-weight: 600; }
.captcha-field altcha-widget {
  display: block;
  width: 100%;
  --altcha-max-width: 100%;
  --altcha-border-radius: var(--radius);
  --altcha-padding: 10px 12px;
}
.captcha-error { display: block; margin-top: 6px; color: var(--bad); font-size: 12px; }

/* Empty / toast */
.empty { padding: 34px 14px; color: var(--muted); text-align: center; background: var(--surface); border: 1px dashed var(--line-strong); border-radius: var(--radius); }
.empty-icon { display: flex; justify-content: center; margin-bottom: 8px; color: #94a3b8; }
.empty p { margin: 0 0 12px; }
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(90px + env(safe-area-inset-bottom));
  z-index: 70;
  max-width: min(90vw, 480px);
  padding: 11px 15px;
  color: #fff;
  text-align: center;
  background: rgba(8, 17, 31, .94);
  border: 1px solid rgba(148, 163, 184, .25);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  transform: translateX(-50%);
}

/* Rules */
.rule-card .row { align-items: flex-start; padding: 0; border-bottom: 0; }

/* Focus and motion */
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid rgba(37, 99, 235, .28);
  outline-offset: 2px;
}

html[data-theme="dark"] .topbar {
  background: rgba(11, 18, 32, .9);
  border-bottom-color: rgba(71, 85, 105, .65);
}
html[data-theme="dark"] .tabbar {
  background: rgba(17, 24, 39, .95);
  border-color: rgba(71, 85, 105, .8);
}
html[data-theme="dark"] .fields,
html[data-theme="dark"] .field,
html[data-theme="dark"] .remember-row,
html[data-theme="dark"] .captcha-label,
html[data-theme="dark"] .chip-btn,
html[data-theme="dark"] .step,
html[data-theme="dark"] .tabbar a { color: #cbd5e1; }
html[data-theme="dark"] .verdict.ok { background: linear-gradient(180deg, var(--ok-bg), var(--surface) 74%); }
html[data-theme="dark"] .verdict.warn { background: linear-gradient(180deg, var(--warn-bg), var(--surface) 74%); }
html[data-theme="dark"] .verdict.bad { background: linear-gradient(180deg, var(--bad-bg), var(--surface) 74%); }
html[data-theme="dark"] .verdict.gray { background: linear-gradient(180deg, var(--surface-3), var(--surface) 74%); }
html[data-theme="dark"] .login-panel .sub,
html[data-theme="dark"] .tiny,
html[data-theme="dark"] .small.muted,
html[data-theme="dark"] .muted { color: var(--muted); }

@media (min-width: 620px) {
  .hero-mark { display: inline-flex; }
  .stat-row { grid-template-columns: repeat(3, 1fr); }
  .field-row { grid-template-columns: 1fr 1fr; }
  .planned-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .ops-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .capability-columns { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .channel-options { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .channel-option { align-items: flex-start; }
}

@media (min-width: 960px) {
  .shell { display: flex; }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 50;
    width: 248px;
    display: flex;
    flex-direction: column;
    padding: 20px 14px;
    color: #cbd5e1;
    background:
      linear-gradient(rgba(255, 255, 255, .035) 1px, transparent 1px),
      linear-gradient(90deg, rgba(255, 255, 255, .035) 1px, transparent 1px),
      var(--nav);
    background-size: 28px 28px;
    border-right: 1px solid rgba(148, 163, 184, .13);
  }
  .sidebar-brand { display: flex; align-items: center; gap: 11px; min-height: 48px; padding: 0 8px; color: #fff; }
  .sidebar-brand b, .sidebar-brand small { display: block; }
  .sidebar-brand b { font-size: 14px; }
  .sidebar-brand small { margin-top: 2px; color: #7f8ea3; font-size: 10px; letter-spacing: .04em; text-transform: uppercase; }
  .side-nav { display: flex; flex-direction: column; gap: 4px; margin-top: 24px; }
  .side-nav-label { padding: 14px 10px 6px; color: #64748b; font-size: 10px; font-weight: 750; letter-spacing: .1em; text-transform: uppercase; }
  .side-nav a {
    min-height: 44px;
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 9px 10px;
    color: #aab6c6;
    border: 1px solid transparent;
    border-radius: var(--radius);
    cursor: pointer;
    transition: color .18s ease, background .18s ease, border-color .18s ease;
  }
  .side-nav a:hover { color: #fff; background: rgba(255, 255, 255, .05); }
  .side-nav a.on { color: #fff; background: rgba(37, 99, 235, .18); border-color: rgba(96, 165, 250, .25); }
  .sidebar-footer { margin-top: auto; }
  .sidebar-user { display: flex; align-items: center; gap: 10px; padding: 12px 9px; border-top: 1px solid rgba(148, 163, 184, .13); }
  .sidebar-user b, .sidebar-user small { display: block; }
  .sidebar-user b { color: #fff; font-size: 13px; }
  .sidebar-user small { color: #738398; font-size: 11px; text-transform: uppercase; }
  .user-avatar {
    width: 36px;
    height: 36px;
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    background: #1d4ed8;
    border-radius: 50%;
    font-weight: 750;
  }
  .side-logout {
    width: 100%;
    min-height: 40px;
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 8px 10px;
    color: #94a3b8;
    background: transparent;
    border: 0;
    border-radius: var(--radius);
    cursor: pointer;
  }
  .side-logout:hover { color: #fff; background: rgba(255, 255, 255, .05); }
  .app-main { width: calc(100% - 248px); margin-left: 248px; }
  .topbar {
    min-height: 72px;
    padding: 12px 30px;
    background: rgba(244, 247, 251, .88);
    border-bottom-color: rgba(203, 213, 225, .75);
  }
  .mobile-brand { display: none; }
  .topbar-title { display: block; min-width: 0; }
  .topbar-title span, .topbar-title b { display: block; }
  .topbar-title span { color: var(--muted); font-size: 11px; }
  .topbar-title b { margin-top: 1px; font-size: 18px; }
  .content { max-width: 1180px; padding: 28px 30px 56px; }
  .capability-layout { grid-template-columns: 280px minmax(0, 1fr); align-items: start; }
  .tabbar { display: none; }
  .toast { bottom: 30px; }
  .hero { min-height: 208px; padding: 32px; }
  .hero h1 { font-size: 38px; }
  .card-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .card-list .entry { min-height: 82px; }
  .stat { min-height: 92px; padding: 18px; }
  .stat b { font-size: 26px; }
  .login-page {
    grid-template-columns: minmax(0, 1.25fr) minmax(440px, .75fr);
    place-items: stretch;
    padding: 0;
    background: linear-gradient(145deg, #07101d, #102647 68%, #173c6d);
  }
  .login-brand {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 34px clamp(32px, 6vw, 88px) 44px;
    color: #fff;
    background: transparent;
  }
  .login-brand-top {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 700;
    animation: riseIn .72s cubic-bezier(.22, 1, .36, 1) .08s both;
  }
  .login-brand-copy { max-width: 640px; animation: riseIn .82s cubic-bezier(.22, 1, .36, 1) .2s both; }
  .login-brand-copy .eyebrow { margin-bottom: 16px; color: #93c5fd; }
  .login-brand-copy h2 { font-size: clamp(34px, 4vw, 54px); }
  .login-brand-copy p { max-width: 560px; margin: 18px 0 0; color: #cbd5e1; font-size: 16px; line-height: 1.7; }
  .login-signal {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    animation: riseIn .82s cubic-bezier(.22, 1, .36, 1) .38s both;
  }
  .login-signal span {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 11px;
    color: #dbeafe;
    background: rgba(255, 255, 255, .07);
    border: 1px solid rgba(255, 255, 255, .1);
    border-radius: 999px;
    font-size: 13px;
  }
  .login-panel {
    align-self: center;
    justify-self: center;
    width: min(100%, 430px);
    max-width: 430px;
    padding: 40px;
    color: #fff;
  }
  .login-mobile-brand { display: none; }
  .login-panel h1 {
    color: transparent;
    background: linear-gradient(105deg, #fff 0%, #fff 34%, #bfdbfe 48%, #fff 62%, #fff 100%);
    background-size: 230% auto;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: textFlow 7s ease-in-out 1s infinite;
  }
  .login-panel .eyebrow { color: #93c5fd; }
  .login-panel .sub { color: #cbd5e1; }
  .login-panel > .card {
    padding: 22px;
    color: #e2e8f0;
    background: rgba(255, 255, 255, .075);
    border-color: rgba(255, 255, 255, .14);
    box-shadow: 0 24px 60px rgba(0, 0, 0, .28);
    backdrop-filter: blur(20px) saturate(135%);
    -webkit-backdrop-filter: blur(20px) saturate(135%);
  }
  .login-panel .field { color: #dbeafe; }
  .login-panel .captcha-label { color: #dbeafe; }
  .login-panel .remember-row { color: #dbeafe; }
  .login-panel altcha-widget {
    --altcha-color-base: rgba(8, 17, 31, .58);
    --altcha-color-base-content: #f8fafc;
    --altcha-color-neutral: rgba(148, 163, 184, .16);
    --altcha-color-neutral-content: #cbd5e1;
    --altcha-border-color: rgba(148, 163, 184, .34);
    --altcha-color-primary: var(--primary);
    --altcha-color-primary-content: #fff;
    --altcha-input-background-color: rgba(8, 17, 31, .58);
    --altcha-input-color: #fff;
  }
  .login-panel input {
    color: #fff;
    background: rgba(8, 17, 31, .58);
    border-color: rgba(148, 163, 184, .34);
  }
  .login-panel input::placeholder { color: #94a3b8; }
  .login-panel input:hover { border-color: rgba(191, 219, 254, .55); }
  .login-panel input:focus {
    border-color: #60a5fa;
    box-shadow: 0 0 0 3px rgba(96, 165, 250, .18);
  }
  .login-panel > .tiny { color: #94a3b8; }
}

@media (max-width: 420px) {
  .hero { min-height: 156px; padding: 20px; }
  .hero h1 { font-size: 27px; }
  .page-title h1 { font-size: 22px; }
  .topbar { padding-left: 12px; padding-right: 12px; }
  .top-action { padding: 8px 10px; font-size: 0; }
  .top-action .ui-icon { width: 20px; height: 20px; }
  .content { padding-left: 12px; padding-right: 12px; }
}

@keyframes riseIn {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes loadingBar {
  0% { transform: translateX(-110%); }
  55% { transform: translateX(150%); }
  100% { transform: translateX(330%); }
}

@keyframes panelIn {
  from { opacity: 0; transform: translate(22px, 10px) scale(.98); }
  to { opacity: 1; transform: translate(0, 0) scale(1); }
}

@keyframes textFlow {
  0% { background-position: 0% 50%; }
  100% { background-position: 200% 50%; }
}

@keyframes heroSheen {
  0%, 18% { opacity: 0; transform: translateX(-42%); }
  38% { opacity: .75; }
  62% { opacity: .75; }
  82%, 100% { opacity: 0; transform: translateX(42%); }
}

@keyframes heroFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
  }
}
