/* Admin-panel inspired shell (Figma community: Admin Panel Dashboard)
   Light content + dark sidebar, blue primary, clean tables/lists. */

:root {
  --sidebar: #1b2430;
  --sidebar-2: #232d3b;
  --sidebar-text: #c9d2de;
  --sidebar-muted: #8b97a8;
  --sidebar-active: #2f6fed;
  --bg: #f4f6fa;
  --surface: #ffffff;
  --ink: #1a2332;
  --muted: #6b778c;
  --line: #e6ebf2;
  --line-strong: #d5deea;
  --primary: #2f6fed;
  --primary-hover: #255fd1;
  --primary-soft: #eaf1ff;
  --success: #1f9d63;
  --success-soft: #e8f7ef;
  --danger: #e14b4b;
  --danger-soft: #fdecec;
  --warning: #d97706;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 8px 24px rgba(16, 24, 40, 0.04);
  --font: "Vazirmatn", "Tahoma", sans-serif;
  --sidebar-w: 248px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.6;
}

a { color: var(--primary); }

/* ---------- App shell ---------- */
.app-shell {
  min-height: 100vh;
}

.sidebar {
  background: linear-gradient(180deg, var(--sidebar) 0%, #151c26 100%);
  color: var(--sidebar-text);
  padding: 1.25rem 1rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  position: fixed;
  top: 0;
  bottom: 0;
  inset-inline-start: 0;
  width: var(--sidebar-w);
  height: 100vh;
  overflow-y: auto;
  z-index: 40;
}

.shell-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  margin-inline-start: var(--sidebar-w);
  transition: margin-inline-start 0.2s ease;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  text-decoration: none;
  color: #fff;
  font-weight: 700;
  font-size: 1.05rem;
  padding: 0.35rem 0.5rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  margin-bottom: 0.75rem;
}

.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: linear-gradient(135deg, #4d8bff, #2f6fed 55%, #1f4fb8);
  box-shadow: 0 0 0 3px rgba(47, 111, 237, 0.25);
}

.sidebar-label {
  margin: 0.85rem 0.65rem 0.35rem;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--sidebar-muted);
}

.sidebar-nav {
  display: grid;
  gap: 0.25rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.7rem 0.8rem;
  border-radius: 10px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 500;
  transition: background 0.15s ease, color 0.15s ease;
}

.nav-item:hover {
  background: rgba(255,255,255,0.06);
  color: #fff;
}

.nav-item.active {
  background: rgba(47, 111, 237, 0.22);
  color: #fff;
  box-shadow: inset 3px 0 0 var(--sidebar-active);
}

.nav-ico {
  width: 1.1rem;
  text-align: center;
  opacity: 0.85;
  font-size: 0.75rem;
}

.sidebar-foot {
  margin-top: auto;
  padding-top: 1rem;
  border-top: 1px solid rgba(255,255,255,0.08);
}

.nav-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.65rem;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}

.nav-toggle:hover {
  background: var(--primary-soft);
  border-color: #c5d6f7;
}

.nav-toggle-label { color: var(--muted); }

body.nav-collapsed .sidebar {
  width: 0;
  padding: 0;
  overflow: hidden;
  border: 0;
  pointer-events: none;
}

body.nav-collapsed .shell-main {
  margin-inline-start: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 1.5rem;
  background: rgba(255,255,255,0.9);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar-start {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  color: var(--muted);
  font-size: 0.88rem;
}

.breadcrumb .sep { opacity: 0.5; }

.user-chip {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.25rem 0.7rem 0.25rem 0.25rem;
  font-size: 0.85rem;
  color: var(--ink);
}

.avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 0.75rem;
  font-weight: 700;
}

.content {
  padding: 1.35rem 1.5rem 2.5rem;
  max-width: 1100px;
  width: 100%;
}

.content.content-wide {
  max-width: none;
}

/* ---------- Auth ---------- */
.auth-shell {
  min-height: 100vh;
  background:
    radial-gradient(900px 420px at 85% -10%, #dce8ff 0%, transparent 55%),
    radial-gradient(700px 360px at 0% 100%, #e7eefc 0%, transparent 50%),
    var(--bg);
}

.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; }
.auth-main { width: 100%; max-width: 420px; }

.login {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1.75rem;
  box-shadow: var(--shadow);
}

.login h1 {
  margin: 0 0 0.35rem;
  font-size: 1.45rem;
}

.login-form { display: grid; gap: 0.65rem; margin-top: 1rem; }

/* ---------- Typography / helpers ---------- */
.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.15rem;
}

.page-head h1 {
  margin: 0;
  font-size: 1.55rem;
  letter-spacing: -0.02em;
}

.page-head .muted { margin: 0.35rem 0 0; }

.muted { color: var(--muted); }
.error {
  color: var(--danger);
  background: var(--danger-soft);
  border: 1px solid #f4c7c7;
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.8rem;
}
.ok {
  color: var(--success);
  background: var(--success-soft);
  border: 1px solid #bfe5cf;
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.8rem;
}

.link {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
}
.link:hover { text-decoration: underline; }

/* ---------- Buttons ---------- */
button,
.btn {
  appearance: none;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: #fff;
  padding: 0.65rem 1rem;
  font: inherit;
  font-weight: 600;
  font-size: 0.92rem;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  transition: background 0.15s ease, box-shadow 0.15s ease;
}

button:hover,
.btn:hover { background: #255fd1; }

.btn-ghost,
.logout button,
button.danger {
  background: transparent;
  color: var(--sidebar-text);
  border: 1px solid rgba(255,255,255,0.14);
  font-weight: 500;
}

.btn-ghost:hover,
.logout button:hover {
  background: rgba(255,255,255,0.06);
  color: #fff;
}

.btn-block { width: 100%; }

button.danger {
  color: var(--danger);
  border: 1px solid #f0b4b4;
  background: var(--danger-soft);
  margin-top: 0.5rem;
}

button.danger:hover { filter: brightness(0.98); }

.btn-secondary {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line-strong);
}

.btn-secondary:hover { background: var(--bg); }

/* ---------- Forms ---------- */
label { font-size: 0.88rem; color: var(--muted); font-weight: 500; }

input[type="password"],
input[type="search"],
input[type="text"],
input[type="number"],
input[type="email"],
select,
textarea {
  width: 100%;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 0.95rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: #9db8f5;
  box-shadow: 0 0 0 3px rgba(47, 111, 237, 0.15);
}

/* ---------- Toolbar / search ---------- */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.85rem;
  box-shadow: var(--shadow);
}

.search {
  display: flex;
  gap: 0.5rem;
  flex: 1;
  min-width: 240px;
}

.search input[type="search"] {
  background: var(--bg);
}

/* ---------- Document list as table-like cards ---------- */
.doc-list {
  list-style: none;
  padding: 0;
  margin: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.doc-list > li {
  border-bottom: 1px solid var(--line);
}

.doc-list > li:last-child { border-bottom: 0; }

.doc-list li a {
  display: grid;
  gap: 0.35rem;
  text-decoration: none;
  color: inherit;
  padding: 0.95rem 1.1rem;
  transition: background 0.12s ease;
}

.doc-list li a:hover { background: #f8faff; }

.doc-list li a:hover .preview { color: var(--ink); }

.meta {
  font-size: 0.78rem;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.65rem;
  align-items: center;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.12rem 0.5rem;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
}

.badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.badge-success { background: var(--success-soft); color: var(--success); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-muted { background: #eef1f6; color: var(--muted); }

.preview {
  line-height: 1.75;
  font-size: 0.95rem;
  color: #334155;
}

.empty {
  padding: 2rem 1.25rem;
  text-align: center;
  color: var(--muted);
}

.pager {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  margin: 1rem 0 0;
}

.pager a {
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.95rem;
  text-decoration: none;
  color: var(--ink);
  font-weight: 500;
  box-shadow: var(--shadow);
}

.pager a:hover { border-color: #9db8f5; color: var(--primary); }

/* ---------- Detail ---------- */
.detail-head h1 {
  margin: 0 0 0.25rem;
  font-size: 1.4rem;
}

.judgment-frame {
  width: 100%;
  min-height: 70vh;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow);
}

/* Unity detail: vote on top, model metadata compared below */
.unity-layout {
  display: grid;
  gap: 1.25rem;
}

.unity-section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem 1rem;
  margin-bottom: 0.65rem;
}

.unity-pane-title {
  margin: 0;
  font-size: 1.05rem;
  color: var(--ink);
}

.unity-vote-block {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0.85rem 1rem 1rem;
}

.unity-vote-frame {
  min-height: 42vh;
  max-height: 52vh;
  box-shadow: none;
}

.unity-model-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.model-chip {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  background: #eef3fb;
  color: #1e3a5f;
  font-size: 0.78rem;
  font-weight: 600;
  border: 1px solid #d7e2f4;
}

.unity-meta-grid {
  display: grid;
  grid-template-columns: repeat(var(--meta-cols, 1), minmax(360px, 1fr));
  gap: 1rem;
  align-items: stretch;
  overflow-x: auto;
}

.unity-meta-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0.75rem 0.85rem 0.95rem;
  min-width: 360px;
  max-height: none;
  overflow: visible;
}

.unity-meta-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
  padding-bottom: 0.65rem;
  margin-bottom: 0.65rem;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 1;
}

.model-name {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 700;
  color: #16335c;
  word-break: break-word;
}

.meta-stats {
  margin: 0.2rem 0 0;
  font-size: 0.75rem;
}

.status-pill {
  flex: 0 0 auto;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.18rem 0.5rem;
  border-radius: 999px;
}

.status-ok {
  background: #e8f7ee;
  color: #146c3b;
  border: 1px solid #b9e4c9;
}

.status-err {
  background: #fdecec;
  color: #9b1c1c;
  border: 1px solid #f0c2c2;
}

.unity-meta-empty {
  padding: 1rem;
  background: #fff;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}

.unity-meta-body {
  font-size: 0.86rem;
}

.unity-meta-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  line-height: 1.55;
}

.unity-meta-table th,
.unity-meta-table td {
  border: 1px solid #e5eaf2;
  padding: 0.38rem 0.45rem;
  vertical-align: top;
}

.unity-meta-table thead th {
  background: #f3f6fb;
  color: #1e3a5f;
  font-weight: 700;
  position: sticky;
  top: 3.1rem;
  z-index: 1;
}

.unity-meta-table tbody th {
  width: 28%;
  text-align: right;
  background: #fafbfd;
  font-weight: 600;
  color: #334155;
  white-space: nowrap;
}

.unity-meta-table .meta-val {
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--ink);
}

.unity-meta-table .meta-ev {
  width: 5.5rem;
  text-align: center;
}

.ev-pill {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.12rem 0.4rem;
  border-radius: 999px;
  background: #eef2f7;
  color: #475569;
}

.ev-pill.ev-explicit {
  background: #e7f1ff;
  color: #1d4f91;
}

.ev-pill.ev-inferred {
  background: #fff6e8;
  color: #9a5b00;
}

.ev-pill.ev-absent,
.ev-pill.ev-missing,
.ev-pill.ev-na {
  background: #f1f5f9;
  color: #64748b;
}

.unity-meta-raw {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.78rem;
  line-height: 1.5;
  background: #f8fafc;
  border: 1px solid #e5eaf2;
  border-radius: 6px;
  padding: 0.55rem;
}

@media (max-width: 1200px) {
  .unity-meta-grid {
    grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  }
}

@media (max-width: 820px) {
  .unity-meta-grid {
    grid-template-columns: 1fr;
  }
  .unity-vote-frame {
    min-height: 36vh;
    max-height: none;
  }
  .unity-meta-card {
    max-height: none;
  }
}

.compare-charts {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0.85rem 1rem 1.1rem;
}

.compare-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
}

.compare-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.7rem 0.75rem 0.85rem;
  background: #fafbfd;
  min-width: 0;
}

.compare-card h3 {
  margin: 0 0 0.55rem;
  font-size: 0.88rem;
  color: #16335c;
}

.compare-card-wide { grid-column: 1 / -1; }

.chart-box {
  position: relative;
  height: 220px;
}

.chart-box-tall { height: 320px; }

@media (max-width: 900px) {
  .compare-grid { grid-template-columns: 1fr; }
  .compare-card-wide { grid-column: auto; }
}

.advisory-qa .qa-block { margin: 0.75rem 0 1rem; }
.advisory-qa .qa-frame { min-height: 22vh; }

.qa-block { margin: 1.25rem 0 1.5rem; }

.qa-block h2 {
  margin: 0 0 0.55rem;
  font-size: 1rem;
  color: var(--ink);
}

.qa-frame { min-height: 28vh; }

/* ---------- Laws / regulations tree browser ---------- */
.law-layout {
  display: grid;
  grid-template-columns: minmax(220px, 280px) 1fr;
  gap: 1rem;
  align-items: start;
}

.law-toc {
  position: sticky;
  top: 0.75rem;
  max-height: calc(100vh - 6rem);
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.law-toc-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.75rem 0.9rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.toc-actions {
  display: inline-flex;
  gap: 0.45rem;
  font-weight: 500;
}

.btn-linkish {
  border: 0;
  background: transparent;
  color: var(--primary);
  cursor: pointer;
  font: inherit;
  font-size: 0.75rem;
  padding: 0;
}

.btn-linkish:hover { text-decoration: underline; }

.law-toc-tree {
  padding: 0.35rem 0 0.75rem;
}

.toc-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.toc-list .toc-list {
  padding-inline-start: 0.7rem;
  border-inline-start: 1px dashed #d7deea;
  margin-inline-start: 0.35rem;
}

.toc-node { margin: 0; }

.toc-branch {
  margin: 0;
}

.toc-summary {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.15rem;
  cursor: pointer;
}

.toc-summary::-webkit-details-marker { display: none; }

.toc-summary::before {
  content: "▸";
  color: var(--muted);
  font-size: 0.7rem;
  width: 0.9rem;
  flex: 0 0 auto;
}

details.toc-branch[open] > .toc-summary::before {
  content: "▾";
}

.law-toc-item {
  display: block;
  flex: 1;
  min-width: 0;
  text-align: right;
  text-decoration: none;
  color: var(--ink);
  font-size: 0.82rem;
  line-height: 1.45;
  padding: 0.28rem 0.55rem;
  border-radius: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.law-toc-item.leaf {
  padding-inline-start: 1.35rem;
}

.law-toc-item:hover {
  background: #f5f8ff;
  color: var(--primary);
}

.law-toc-item.active {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 600;
}

.empty-toc { padding: 1rem; margin: 0; }

.law-main {
  display: grid;
  gap: 1rem;
  min-width: 0;
}

.law-related {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0.85rem 1rem;
}

.law-related h2 {
  margin: 0 0 0.5rem;
  font-size: 0.92rem;
}

.law-related ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.35rem;
}

.law-related li {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.75rem;
  font-size: 0.88rem;
}

.law-related a {
  color: var(--primary);
  text-decoration: none;
}

.law-related a:hover { text-decoration: underline; }

.law-article {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem 1.25rem 2.5rem;
  min-width: 0;
  line-height: 1.95;
}

.law-sec {
  margin: 0.85rem 0;
  scroll-margin-top: 1rem;
}

.law-sec.toc-target {
  outline: 2px solid #2f6fed55;
  background: #f3f7ff;
  border-radius: 8px;
  padding: 0.35rem 0.55rem;
}

.law-sec-label {
  margin: 0 0 0.25rem;
  font-size: 1rem;
  font-weight: 700;
  color: #1e3a5f;
}

.law-sec-lvl-1 > .law-sec-label {
  font-size: 1.15rem;
  border-bottom: 1px solid var(--line);
  padding-bottom: 0.3rem;
  margin-top: 1rem;
}

.law-sec-lvl-2 > .law-sec-label { font-size: 1.05rem; }
.law-sec-lvl-3 > .law-sec-label { font-size: 1rem; }
.law-sec-body { font-size: 0.96rem; color: #243547; }

@media (max-width: 900px) {
  .law-layout {
    grid-template-columns: 1fr;
  }
  .law-toc {
    position: relative;
    top: 0;
    max-height: 280px;
  }
}

/* ---------- Lab ---------- */
.lab-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0 0 1.15rem;
  padding: 0.35rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.lab-tabs a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 500;
  padding: 0.55rem 0.85rem;
  border-radius: 8px;
}

.lab-tabs a:hover { background: var(--bg); color: var(--ink); }

.lab-tabs a.active {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 700;
}

.lab-panel { margin-bottom: 1.5rem; }

.lab-panel h2 {
  margin: 0 0 0.75rem;
  font-size: 1.1rem;
}

.lab-panel h3 {
  margin: 1.25rem 0 0.65rem;
  font-size: 0.98rem;
}

.lab-form {
  display: grid;
  gap: 0.65rem;
  margin: 0.75rem 0 1.1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  box-shadow: var(--shadow);
}

.lab-form.inline {
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  align-items: end;
}

.lab-form label {
  display: grid;
  gap: 0.3rem;
}

.lab-form label.check {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.lab-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  margin: 0.65rem 0;
  box-shadow: var(--shadow);
}

.lab-card summary {
  cursor: pointer;
  font-weight: 600;
}

.cost-box {
  background: linear-gradient(180deg, #f7faff 0%, #eef5ff 100%);
  border: 1px solid #d5e3ff;
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
  box-shadow: var(--shadow);
}

.cost-box strong { color: var(--primary); }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.75rem;
  margin: 1rem 0 1.25rem;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.95rem 1rem;
  box-shadow: var(--shadow);
}

.stat-card .label {
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 0.25rem;
}

.stat-card .value {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

pre.raw {
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  font-size: 0.85rem;
  max-height: 240px;
  overflow: auto;
}

.panel-note {
  background: var(--primary-soft);
  border: 1px solid #d5e3ff;
  color: #274a93;
  border-radius: var(--radius-sm);
  padding: 0.7rem 0.85rem;
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

/* ---------- Lab wizard ---------- */
.wizard-steps {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.4rem;
  margin: 0 0 1.25rem;
}

.wizard-step {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.65rem 0.7rem;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  text-decoration: none;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
  min-width: 0;
}

.wizard-step .step-num {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--bg);
  color: var(--muted);
  font-size: 0.72rem;
  flex: 0 0 auto;
}

.wizard-step .step-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wizard-step.active {
  border-color: #9db8f5;
  background: var(--primary-soft);
  color: var(--primary);
}

.wizard-step.active .step-num {
  background: var(--primary);
  color: #fff;
}

.wizard-step.done .step-num {
  background: var(--success-soft);
  color: var(--success);
}

.wizard-cta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-top: 1.25rem;
}

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.85rem;
}

.section-head h2 { margin: 0 0 0.25rem; font-size: 1.15rem; }

.data-table-wrap {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: auto;
  box-shadow: var(--shadow);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.data-table th,
.data-table td {
  padding: 0.75rem 0.9rem;
  border-bottom: 1px solid var(--line);
  text-align: right;
  vertical-align: middle;
}

.data-table th {
  background: #f8fafc;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.8rem;
}

.data-table tr:last-child td { border-bottom: 0; }

.data-table code {
  font-size: 0.8rem;
  background: var(--bg);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
}

.row-actions { white-space: nowrap; }

.linkish {
  cursor: pointer;
  color: var(--primary);
  font-weight: 600;
  list-style: none;
}

.linkish::-webkit-details-marker { display: none; }

.inline-edit > summary { margin-bottom: 0.5rem; }

.add-drawer {
  margin-top: 1rem;
  background: var(--surface);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
}

.add-drawer > summary.btn,
.add-drawer > summary.btn-secondary {
  display: inline-flex;
  width: fit-content;
  list-style: none;
  margin-bottom: 0.75rem;
}

.add-drawer > summary.btn::-webkit-details-marker,
.add-drawer > summary.btn-secondary::-webkit-details-marker { display: none; }

.add-drawer[open] > summary.btn { margin-bottom: 0.85rem; }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 0.75rem;
}

.soft-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.95rem 1rem;
  box-shadow: var(--shadow);
}

.soft-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}

.empty-state {
  padding: 1.5rem;
  text-align: center;
  color: var(--muted);
  background: var(--surface);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
}

.inline-bind {
  display: flex;
  gap: 0.4rem;
  align-items: center;
}

.inline-bind select { min-width: 140px; }

.run-form .btn-lg,
button.btn-lg {
  padding: 0.85rem 1.25rem;
  font-size: 1rem;
}

button:disabled,
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.prompt-doc,
.prompt-doc-inner,
.edit-doc {
  background: #fffef9;
  border: 1px solid #e7e0d2;
  border-radius: 14px;
  padding: 1rem 1.1rem 1.15rem;
  box-shadow: var(--shadow);
  margin-top: 0.85rem;
}

.prompt-doc-head {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  align-items: end;
  justify-content: space-between;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid #ebe4d6;
  margin-bottom: 0.85rem;
}

.prompt-title-label {
  flex: 1;
  min-width: 220px;
  display: grid;
  gap: 0.3rem;
  font-weight: 600;
  color: var(--ink);
}

.prompt-section {
  padding: 0.85rem 0;
  border-bottom: 1px dashed #ebe4d6;
}

.prompt-section:last-of-type { border-bottom: 0; }

.prompt-section h3 {
  margin: 0 0 0.25rem;
  font-size: 1rem;
  color: var(--ink);
}

.prompt-section .hint {
  margin: 0 0 0.55rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.prompt-section textarea {
  background: #fff;
  min-height: 4.5rem;
  line-height: 1.8;
}

.insert-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.55rem;
}

.chip {
  background: var(--primary-soft);
  color: var(--primary);
  border: 1px solid #c9daf8;
  border-radius: 999px;
  padding: 0.35rem 0.7rem;
  font-size: 0.8rem;
  font-weight: 600;
}

.chip:hover { background: #dce8ff; }

.subhead {
  margin: 1.35rem 0 0.5rem;
  font-size: 1rem;
}

.edit-doc > summary {
  cursor: pointer;
  font-weight: 700;
  padding: 0.25rem 0;
}

/* —— Status strip —— */
.status-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem 1.25rem;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(180deg, #f7f9fc 0%, #eef3fa 100%);
  border: 1px solid #d9e2f0;
  border-radius: 14px;
  padding: 0.85rem 1.1rem;
  margin-bottom: 1rem;
}

.status-strip-title {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.status-lab-name {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--ink);
}

.status-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  text-decoration: none;
  color: inherit;
  background: #fff;
  border: 1px solid #d7e0ee;
  border-radius: 999px;
  padding: 0.35rem 0.7rem 0.35rem 0.45rem;
  font-size: 0.82rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.status-chip:hover {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.status-chip.active {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.status-chip.ok .chip-count { color: #157347; }
.status-chip.missing .chip-count { color: #b42318; }

.chip-count {
  font-weight: 700;
  min-width: 1.6rem;
  text-align: center;
  background: #f3f5f9;
  border-radius: 999px;
  padding: 0.1rem 0.35rem;
}

.chip-label { color: var(--muted); font-weight: 600; }

.page-head-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* —— Sheet drawer —— */
dialog.sheet {
  border: 0;
  padding: 0;
  margin: 0;
  max-width: none;
  width: min(420px, 100vw);
  height: 100vh;
  max-height: 100vh;
  position: fixed;
  inset-inline-end: 0;
  inset-block: 0;
  inset-inline-start: auto;
  border-radius: 16px 0 0 16px;
  box-shadow: -12px 0 40px rgba(15, 23, 42, 0.18);
  background: #fff;
}

dialog.sheet::backdrop {
  background: rgba(15, 23, 42, 0.35);
}

.sheet-body {
  padding: 1.1rem 1.2rem 1.4rem;
  display: grid;
  gap: 0.75rem;
  max-height: calc(100vh - 4rem);
  overflow: auto;
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.25rem;
}

.sheet-head h3 { margin: 0; font-size: 1.1rem; }

.sheet-close {
  border: 0;
  background: #f1f4f9;
  width: 2rem;
  height: 2rem;
  border-radius: 999px;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
}

.sheet-foot {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-top: 0.5rem;
}

.sheet-danger {
  padding: 0 1.2rem 1.2rem;
}

.empty-hero {
  text-align: center;
  padding: 2.5rem 1rem;
  background: #f8fafc;
  border: 1px dashed #d5dde8;
  border-radius: 14px;
}

.empty-hero p {
  margin: 0 0 1rem;
  color: var(--muted);
}

.desc-cell {
  max-width: 280px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.6;
}

/* —— Master / detail for extraction logic —— */
.master-detail {
  display: grid;
  grid-template-columns: minmax(200px, 260px) 1fr;
  gap: 1rem;
  align-items: start;
  margin-top: 0.75rem;
}

.master-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  background: #f7f9fc;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 0.55rem;
  max-height: 70vh;
  overflow: auto;
}

.master-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.15rem 0.5rem;
  text-decoration: none;
  color: inherit;
  padding: 0.65rem 0.7rem;
  border-radius: 10px;
  border: 1px solid transparent;
}

.master-item-title {
  font-weight: 700;
  grid-column: 1;
}

.master-item-meta {
  grid-column: 1;
  font-size: 0.78rem;
  color: var(--muted);
}

.master-item .badge {
  grid-column: 2;
  grid-row: 1 / span 2;
  align-self: center;
}

.master-item:hover { background: #fff; border-color: #d7e2f0; }
.master-item.active {
  background: #fff;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.detail-pane { min-width: 0; }

.recipe-editor {
  background: #fffef9;
  border: 1px solid #e7e0d2;
  border-radius: 14px;
  padding: 1rem 1.1rem 1.2rem;
  box-shadow: var(--shadow);
}

.recipe-head { margin-bottom: 0.85rem; }
.recipe-head h3 { margin: 0.15rem 0; }
.eyebrow {
  margin: 0;
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  color: var(--muted);
  font-weight: 700;
}

.field-picker {
  width: 100%;
  max-width: 420px;
}

.field-match-card {
  margin-top: 0.65rem;
  padding: 0.75rem 0.9rem;
  background: #f4f7fc;
  border: 1px solid #d7e2f4;
  border-radius: 10px;
}

.field-match-inner .meta-line { margin: 0.35rem 0; }
.field-match-inner .desc-line { margin: 0.4rem 0 0; line-height: 1.7; }

.field-match-inner .opt-list {
  margin: 0.45rem 0 0;
  padding-inline-start: 1.1rem;
  line-height: 1.7;
}

.format-preview,
.body-preview {
  margin: 0.55rem 0 0.75rem;
  background: #fbfbfd;
  border: 1px solid #e6e8ef;
  border-radius: 10px;
  padding: 0.7rem 0.85rem;
}

.format-preview .format-pre,
.body-preview .raw {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.86rem;
  line-height: 1.75;
  color: var(--ink);
}

.body-preview .preview-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 0.4rem;
}

.include-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem 1.1rem;
  margin: 0.55rem 0 0.35rem;
}

.soft-label {
  display: grid;
  gap: 0.3rem;
  margin-top: 0.45rem;
  font-weight: 600;
  color: var(--ink);
}

/* —— Metadata schema doc —— */
.doc-bullets {
  margin: 0.5rem 0 0;
  padding-inline-start: 1.2rem;
  line-height: 1.85;
}

.doc-bullets.out li { color: #8a3b32; }

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.75rem 0;
}

.schema-pre {
  background: #f7f9fc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 0.85rem 1rem;
  overflow: auto;
  font-size: 0.85rem;
}

.field-doc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 0.85rem;
}

.field-doc-card {
  background: #fff;
  border: 1px solid #e6e8ef;
  border-radius: 12px;
  padding: 0.9rem 1rem;
  box-shadow: var(--shadow);
}

.field-doc-card header {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.35rem;
}

.field-doc-card h3 {
  margin: 0.2rem 0;
  font-size: 1rem;
}

.field-doc-card .en-label {
  margin: 0 0 0.45rem;
  font-size: 0.82rem;
}

.opt-compact {
  margin: 0.4rem 0 0;
  padding-inline-start: 1rem;
  font-size: 0.85rem;
  line-height: 1.7;
  max-height: 160px;
  overflow: auto;
}

/* ---------- Vote Lab ---------- */
.stack-form {
  display: grid;
  gap: 0.85rem;
  max-width: 640px;
}

.stack-form .field-label {
  display: block;
  margin-bottom: 0.3rem;
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 600;
}

.stack-form select,
.stack-form input[type="text"],
.stack-form input[type="number"] {
  width: 100%;
}

.code-block {
  margin: 0;
  padding: 0.85rem 1rem;
  background: #f7f8fb;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.88rem;
  line-height: 1.7;
  max-height: 420px;
  overflow: auto;
}

.vote-summary { margin-bottom: 1.25rem; }
.vote-summary h2,
.vote-card h2,
.vote-pane h3 {
  margin: 0 0 0.55rem;
  font-size: 1rem;
}

.vote-chart td,
.vote-chart th {
  vertical-align: top;
}

.vote-preview-cell {
  max-width: 340px;
  line-height: 1.6;
  color: #334155;
  font-size: 0.88rem;
}

.vote-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem 1.15rem 1.25rem;
  margin-bottom: 1rem;
}

.vote-card-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  margin-bottom: 0.85rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--line);
}

.vote-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 1rem;
}

.vote-pane h3 {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.vote-output {
  background: #fbfcfe;
  border: 1px solid #e7ebf3;
  border-radius: 12px;
  padding: 0.95rem 1.05rem;
  line-height: 1.9;
  font-size: 0.98rem;
}

.vote-output p { margin: 0 0 0.65rem; }
.vote-output p:last-child { margin-bottom: 0; }

.vote-list {
  margin: 0;
  padding-inline-start: 1.25rem;
  display: grid;
  gap: 0.45rem;
}

.vote-kv {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.vote-kv th {
  text-align: right;
  width: 28%;
  padding: 0.45rem 0.55rem;
  background: #f3f6fb;
  border: 1px solid #e5eaf2;
  font-weight: 600;
  color: #1e3a5f;
}

.vote-kv td {
  padding: 0.45rem 0.55rem;
  border: 1px solid #e5eaf2;
  white-space: pre-wrap;
}

.vote-prose {
  white-space: pre-wrap;
  line-height: 1.9;
}

@media (max-width: 900px) {
  .two-col { grid-template-columns: 1fr; }
  .vote-grid { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  .master-detail {
    grid-template-columns: 1fr;
  }
  .master-list {
    flex-direction: row;
    overflow-x: auto;
    max-height: none;
  }
  .master-item {
    min-width: 160px;
  }
  dialog.sheet {
    width: 100vw;
    border-radius: 16px 16px 0 0;
    inset-block-start: auto;
    inset-block-end: 0;
    height: min(92vh, 100%);
    max-height: 92vh;
  }
}

@media (max-width: 900px) {
  .wizard-steps {
    grid-template-columns: 1fr 1fr;
  }
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: relative;
    inset: auto;
    width: 100%;
    height: auto;
    border-bottom: 1px solid rgba(255,255,255,0.08);
  }

  .shell-main {
    margin-inline-start: 0;
  }

  .sidebar-nav {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  }

  .content {
    padding: 1rem;
  }
}

/* ---------- Book OCR reader ---------- */
.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
}

.book-card {
  display: block;
  padding: 1rem 1.1rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.book-card:hover {
  border-color: #9db8f5;
  box-shadow: 0 6px 18px rgba(30, 58, 95, 0.08);
}

.book-card h2 {
  margin: 0 0 0.4rem;
  font-size: 1.05rem;
}

.book-pager {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.book-jump {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.book-jump input {
  width: 4.5rem;
  padding: 0.35rem 0.45rem;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.book-reader {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(280px, 0.95fr);
  gap: 1rem;
  align-items: start;
}

.book-page-image,
.book-page-text {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0.85rem 1rem 1rem;
  min-width: 0;
}

.book-page-image figcaption,
.book-text-head h2 {
  margin: 0 0 0.65rem;
  font-size: 0.95rem;
  color: var(--ink);
}

.book-text-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.55rem;
}

.book-page-image img {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid #e5eaf2;
  border-radius: 6px;
  background: #f8fafc;
}

.book-ocr-body {
  white-space: pre-wrap;
  line-height: 1.95;
  font-size: 0.98rem;
  color: var(--ink);
  max-height: min(72vh, 900px);
  overflow: auto;
  padding: 0.35rem 0.15rem;
}

@media (max-width: 960px) {
  .book-reader {
    grid-template-columns: 1fr;
  }
}

/* ---------- Live OCR dashboard ---------- */
.ocr-live-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}

.ocr-stat {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.7rem 0.85rem;
  box-shadow: var(--shadow);
}

.ocr-stat-label {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 0.25rem;
}

.ocr-progress-track {
  height: 10px;
  background: #e8eef8;
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 0.55rem;
}

.ocr-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #2f6fed, #5b8def);
  transition: width 0.35s ease;
}

.ocr-live-reader {
  margin-top: 1rem;
}

.ocr-live-log {
  margin-top: 1.25rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0.85rem 1rem;
}

.ocr-log-list {
  margin: 0;
  padding: 0;
  list-style: none;
  max-height: 280px;
  overflow: auto;
  display: grid;
  gap: 0.35rem;
  font-size: 0.85rem;
}

.ocr-log-list time {
  color: var(--muted);
  font-size: 0.75rem;
  margin-inline-end: 0.35rem;
}

.book-live-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

#live-img {
  display: none;
  width: 100%;
  height: auto;
  border: 1px solid #e5eaf2;
  border-radius: 6px;
}

@media (max-width: 960px) {
  .ocr-live-stats {
    grid-template-columns: 1fr 1fr;
  }
}

/* ---------- Dictionary OCR live ---------- */
.dict-ocr-stats {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.dict-ocr-stats .ocr-stat .status-pill {
  display: inline-block;
  margin-top: 0.35rem;
}

.dict-pull-form {
  display: inline;
  margin: 0;
}

.dict-parts {
  margin-top: 1rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0.85rem 1rem;
}

.dict-parts-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.45rem;
}

.dict-parts-list li {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: baseline;
  font-size: 0.88rem;
  padding: 0.35rem 0;
  border-bottom: 1px solid #eef2f8;
}

.dict-parts-list li:last-child {
  border-bottom: none;
}

.dict-part-id {
  font-weight: 700;
  min-width: 4.5rem;
}

.dict-part-meta {
  color: var(--muted);
}

.dict-feed {
  margin-top: 1.25rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0.85rem 1rem;
}

.dict-feed-list {
  list-style: none;
  margin: 0.5rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.75rem;
  max-height: 420px;
  overflow: auto;
}

.dict-feed-list li {
  padding-bottom: 0.65rem;
  border-bottom: 1px solid #eef2f8;
}

.dict-feed-list li:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.dict-feed-head {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 0.75rem;
  align-items: baseline;
  margin-bottom: 0.25rem;
}

.dict-feed-cat {
  font-size: 0.75rem;
  color: #2f4f8f;
  background: #eef4ff;
  border: 1px solid #c9d8f5;
  border-radius: 999px;
  padding: 0.1rem 0.45rem;
}

.dict-feed-page {
  margin-inline-start: auto;
  font-size: 0.75rem;
  color: var(--muted);
}

.dict-feed-def {
  margin: 0;
  font-size: 0.86rem;
  line-height: 1.55;
  color: #334;
}

@media (max-width: 960px) {
  .dict-ocr-stats {
    grid-template-columns: 1fr 1fr;
  }
}

/* —— Knowledge graph —— */
.kg-status-wrap {
  display: flex;
  align-items: center;
}

.kg-status-ready {
  background: #eef4ff;
  color: #2f4f8f;
  border: 1px solid #c9d8f5;
}

.kg-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.85rem;
  margin-bottom: 1.25rem;
}

.kg-stat {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0.85rem 1rem;
}

.kg-stat-label {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.kg-stat-value {
  font-size: 1.45rem;
  font-weight: 700;
}

.kg-stat-engine {
  font-size: 0.95rem;
  font-weight: 600;
  word-break: break-word;
}

.kg-browser {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem 1.1rem 1.15rem;
  margin-bottom: 1rem;
}

.kg-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.85rem;
  border-bottom: 1px solid var(--line);
  padding-bottom: 0.65rem;
}

.kg-tab {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  padding: 0.4rem 0.85rem;
  border-radius: 8px;
  cursor: pointer;
}

.kg-tab:hover {
  color: var(--ink);
  background: #f4f7fc;
}

.kg-tab.active {
  color: var(--primary);
  background: #eef4ff;
  border-color: #c9d8f5;
}

.kg-toolbar {
  margin-bottom: 0.75rem;
  align-items: center;
}

.kg-page-meta {
  margin: 0;
  font-size: 0.85rem;
  white-space: nowrap;
}

.kg-rel-item {
  padding: 0.85rem 1.1rem;
}

.kg-rel-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem 0.7rem;
  margin-bottom: 0.35rem;
}

.kg-rel-link {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
}

.kg-rel-link:hover {
  text-decoration: underline;
}

.kg-rel-arrow {
  font-size: 0.8rem;
  color: var(--muted);
  background: #f1f4f9;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.15rem 0.45rem;
}

.kg-canvas-panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem 1.1rem 1.15rem;
  margin-bottom: 1rem;
}

.kg-canvas-head h2 {
  margin: 0 0 0.35rem;
  font-size: 1.05rem;
}

.kg-canvas {
  margin-top: 0.85rem;
  min-height: 280px;
  border: 1px dashed #c5d0e3;
  border-radius: 10px;
  background:
    radial-gradient(circle at 20% 30%, rgba(47, 111, 237, 0.06), transparent 45%),
    radial-gradient(circle at 80% 70%, rgba(47, 111, 237, 0.05), transparent 40%),
    linear-gradient(180deg, #f8fafc 0%, #eef3fa 100%);
  display: grid;
  place-items: center;
}

.kg-canvas-empty {
  text-align: center;
  color: var(--ink);
}

.kg-canvas-empty p {
  margin: 0.2rem 0;
}

.kg-note {
  margin-top: 0.5rem;
}

.kg-note code {
  font-size: 0.82em;
}

.kg-view-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0 0 1rem;
  padding: 0.35rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.kg-view-tabs a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 500;
  padding: 0.55rem 0.85rem;
  border-radius: 8px;
}

.kg-view-tabs a:hover {
  background: var(--bg);
  color: var(--ink);
}

.kg-view-tabs a.active {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 700;
}

.kg-visual-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem 1.1rem 1.15rem;
}

.kg-visual-search {
  display: grid;
  grid-template-columns: 140px minmax(220px, 1fr) auto auto;
  gap: 0.65rem;
  align-items: end;
  margin-bottom: 0.85rem;
}

.kg-visual-search label {
  display: grid;
  gap: 0.3rem;
}

.kg-visual-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem 1rem;
  margin-bottom: 0.65rem;
}

.kg-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  font-size: 0.82rem;
  color: var(--muted);
}

.kg-dot {
  display: inline-block;
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 50%;
  margin-inline-end: 0.3rem;
  vertical-align: middle;
}

.kg-dot-law {
  background: #2f6fed;
}

.kg-dot-regulation {
  background: #1f9d63;
  border-radius: 3px;
}

.kg-visual-canvas {
  height: min(68vh, 720px);
  min-height: 360px;
  border: 1px solid #d7e2f4;
  border-radius: 10px;
  background:
    radial-gradient(circle at 18% 22%, rgba(47, 111, 237, 0.08), transparent 42%),
    radial-gradient(circle at 82% 78%, rgba(31, 157, 99, 0.08), transparent 40%),
    linear-gradient(180deg, #f8fafc 0%, #eef3fa 100%);
}

.kg-visual-help {
  margin: 0.65rem 0 0;
  font-size: 0.85rem;
}

.structure-note {
  margin: 0.55rem 0 0;
  font-size: 0.86rem;
  line-height: 1.7;
}

@media (max-width: 900px) {
  .kg-stats {
    grid-template-columns: 1fr 1fr;
  }

  .kg-visual-search {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 800px) {
  .kg-stats {
    grid-template-columns: 1fr;
  }
}
