:root {
  color-scheme: light;
  --ink: #111827;
  --muted: #667085;
  --line: #e5e7eb;
  --surface: #ffffff;
  --canvas: #f5f7fb;
  --accent: #5b4bdb;
  --accent-soft: #eeecff;
  --warning: #9a5b08;
  --warning-soft: #fff7e6;
  --success: #0f766e;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--canvas); }
button, input, select, textarea { font: inherit; }
a { color: inherit; text-decoration: none; }
.skip-link { position: fixed; left: 16px; top: -80px; z-index: 20; padding: 10px 14px; background: #111827; color: #fff; border-radius: 10px; }
.skip-link:focus { top: 12px; }
.layout { min-height: 100vh; display: grid; grid-template-columns: 244px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 24px 18px; background: #111827; color: #fff; display: flex; flex-direction: column; }
.brand { display: flex; gap: 12px; align-items: center; padding: 4px 8px 24px; }
.brand-mark { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 13px; background: linear-gradient(135deg, #8b7cf6, #5b4bdb); font-weight: 800; }
.brand strong, .brand small { display: block; }
.brand small { color: #98a2b3; margin-top: 3px; }
.sidebar nav { display: grid; gap: 5px; }
.nav-item { border: 0; width: 100%; padding: 11px 12px; border-radius: 10px; text-align: left; background: transparent; color: #cbd5e1; cursor: pointer; }
.nav-item:hover, .nav-item:focus-visible { background: #1f2937; color: #fff; outline: none; }
.nav-item.is-active { background: #312e81; color: #fff; font-weight: 700; }
.nav-link { display: block; margin-top: 8px; border: 1px solid #374151; }
.sidebar-note { margin-top: auto; display: flex; gap: 10px; align-items: center; padding: 13px; border: 1px solid #374151; border-radius: 12px; background: #161f2d; }
.sidebar-note strong, .sidebar-note small { display: block; }
.sidebar-note small { color: #98a2b3; margin-top: 2px; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: #f59e0b; box-shadow: 0 0 0 5px rgba(245, 158, 11, .12); }
.sidebar-note .status-dot { background: #34d399; box-shadow: 0 0 0 5px rgba(52, 211, 153, .12); }
.workspace { min-width: 0; }
.topbar { min-height: 88px; padding: 18px clamp(20px, 4vw, 48px); display: flex; justify-content: space-between; align-items: center; background: rgba(255,255,255,.9); border-bottom: 1px solid var(--line); backdrop-filter: blur(14px); }
.topbar h1 { margin: 2px 0 0; font-size: 24px; }
.eyebrow { margin: 0; color: var(--accent); font-size: 11px; font-weight: 800; letter-spacing: .14em; }
.topbar-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.user-badge { font-size: 13px; color: var(--muted); }
.button { display: inline-flex; align-items: center; justify-content: center; min-height: 38px; padding: 0 14px; border-radius: 9px; border: 1px solid transparent; cursor: pointer; font-weight: 700; }
.button.primary { background: var(--accent); color: #fff; }
.button.secondary { background: #fff; color: var(--ink); border-color: var(--line); }
.shadow-banner { margin: 22px clamp(20px, 4vw, 48px) 0; padding: 15px 18px; display: flex; justify-content: space-between; align-items: center; gap: 18px; border: 1px solid #f4d18b; border-radius: 14px; background: var(--warning-soft); color: #71430a; }
.shadow-banner strong, .shadow-banner span { display: block; }
.shadow-banner span { margin-top: 3px; font-size: 13px; }
.mode-badge { flex: 0 0 auto; padding: 6px 9px; border-radius: 999px; background: #f59e0b; color: #3b2405; font-size: 11px !important; font-weight: 900; letter-spacing: .08em; }
.shadow-banner.authoritative { border-color: #a7f3d0; background: #ecfdf3; color: #065f46; }
.shadow-banner.authoritative .mode-badge { background: #047857; color: #fff; }
main { padding: 24px clamp(20px, 4vw, 48px) 48px; }
.view { display: none; }
.view.is-active { display: block; }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.metric-grid.compact { margin-bottom: 18px; }
.metric { min-height: 132px; padding: 20px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 8px 30px rgba(15,23,42,.04); }
.metric span, .metric small { display: block; color: var(--muted); }
.metric strong { display: block; margin: 9px 0 6px; font-size: 31px; }
.metric small { font-size: 12px; }
.skeleton { animation: pulse 1.5s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .58; } }
.overview-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(280px, .65fr); gap: 16px; margin-top: 16px; }
.panel { padding: 22px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 8px 30px rgba(15,23,42,.04); }
.panel h2 { margin: 4px 0 5px; font-size: 19px; }
.panel p { color: var(--muted); }
.panel-head { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 18px; }
.panel-head p { margin: 4px 0 0; }
.panel-actions { display: flex; gap: 8px; align-items: end; justify-content: flex-end; }
.panel-actions.wrap { flex-wrap: wrap; max-width: 620px; }
.boundary-list { display: grid; gap: 12px; padding: 0; margin: 18px 0 0; list-style: none; }
.boundary-list li { display: flex; gap: 12px; align-items: flex-start; padding: 12px; background: #f8fafc; border-radius: 12px; }
.boundary-list li > span { flex: 0 0 28px; height: 28px; display: grid; place-items: center; border-radius: 8px; background: var(--accent-soft); color: var(--accent); font-weight: 800; }
.boundary-list strong, .boundary-list small { display: block; }
.boundary-list small { margin-top: 4px; color: var(--muted); line-height: 1.45; }
.action-panel { display: flex; flex-direction: column; justify-content: space-between; gap: 24px; background: linear-gradient(145deg, #17152e, #312e81); color: #fff; }
.action-panel .eyebrow, .action-panel p { color: #c7d2fe; }
.search { display: grid; gap: 5px; min-width: min(280px, 42vw); color: var(--muted); font-size: 12px; }
.search input { width: 100%; height: 40px; padding: 0 12px; border: 1px solid var(--line); border-radius: 9px; color: var(--ink); background: #fff; }
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { padding: 12px 13px; text-align: left; border-bottom: 1px solid var(--line); font-size: 13px; vertical-align: top; }
th { position: sticky; top: 0; background: #f8fafc; color: #475467; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafafa; }
.cell-main { display: block; font-weight: 700; }
.cell-sub { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; }
.tag { display: inline-flex; padding: 4px 7px; border-radius: 999px; background: #f2f4f7; color: #475467; font-size: 11px; }
.tag.active { background: #ecfdf3; color: #027a48; }
.table-foot { min-height: 18px; margin: 11px 2px 0; color: var(--muted); font-size: 12px; }
.empty-row td { padding: 34px; text-align: center; color: var(--muted); }
.row-actions { display: flex; gap: 6px; white-space: nowrap; }
.row-button { border: 1px solid var(--line); border-radius: 8px; padding: 6px 9px; background: #fff; color: var(--ink); cursor: pointer; font-weight: 700; font-size: 12px; }
.row-button.danger { color: #b42318; }
.directory-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 0 0 18px; }
.directory-card { border: 1px solid var(--line); border-radius: 12px; padding: 14px; background: #fafafa; }
.directory-card h3 { margin: 0 0 10px; font-size: 14px; }
.directory-list { display: grid; gap: 7px; }
.directory-item { display: flex; justify-content: space-between; gap: 8px; align-items: center; padding: 8px; border-radius: 8px; background: #fff; }
.directory-item span { min-width: 0; }
.directory-item strong, .directory-item small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.directory-item small { color: var(--muted); margin-top: 2px; }
.editor-dialog { width: min(760px, calc(100vw - 28px)); max-height: min(860px, calc(100vh - 28px)); padding: 0; border: 0; border-radius: 18px; box-shadow: 0 30px 90px rgba(15,23,42,.28); }
.editor-dialog::backdrop { background: rgba(15,23,42,.48); backdrop-filter: blur(3px); }
.editor-dialog form { display: flex; flex-direction: column; max-height: inherit; }
.editor-dialog header, .editor-dialog footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 22px; }
.editor-dialog header { border-bottom: 1px solid var(--line); }
.editor-dialog footer { border-top: 1px solid var(--line); justify-content: flex-end; }
.editor-dialog h2 { margin: 3px 0 0; font-size: 20px; }
.dialog-close { width: 38px; height: 38px; border: 0; border-radius: 10px; background: #f2f4f7; cursor: pointer; font-size: 24px; }
.editor-fields { overflow: auto; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; padding: 22px; }
.editor-fields label { display: grid; gap: 6px; color: #475467; font-size: 12px; font-weight: 700; }
.editor-fields label.wide, .editor-fields .wide { grid-column: 1 / -1; }
.editor-fields input, .editor-fields select, .editor-fields textarea { width: 100%; border: 1px solid #d0d5dd; border-radius: 9px; padding: 10px 11px; color: var(--ink); background: #fff; font-weight: 500; }
.editor-fields textarea { min-height: 88px; resize: vertical; }
.dialog-error { margin: 0 22px 4px; padding: 11px 12px; border-radius: 9px; background: #fff1f0; color: #b42318; font-size: 13px; }
.toast { position: fixed; right: 22px; bottom: 22px; z-index: 30; max-width: min(420px, calc(100vw - 44px)); padding: 13px 16px; border-radius: 11px; background: #111827; color: #fff; box-shadow: 0 16px 50px rgba(15,23,42,.25); font-size: 13px; }
.error-panel { margin-top: 16px; padding: 16px; border: 1px solid #fda29b; background: #fff1f0; border-radius: 12px; color: #912018; }
.error-panel strong, .error-panel span { display: block; }
.error-panel span { margin: 4px 0 12px; }

@media (max-width: 1050px) {
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .overview-grid { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .layout { display: block; }
  .sidebar { position: static; width: 100%; height: auto; padding: 14px; }
  .brand { padding-bottom: 12px; }
  .sidebar nav { display: flex; overflow-x: auto; }
  .nav-item { width: auto; flex: 0 0 auto; white-space: nowrap; }
  .sidebar-note { display: none; }
  .topbar { align-items: flex-start; gap: 12px; }
  .user-badge { width: 100%; text-align: right; }
  .shadow-banner { align-items: flex-start; }
  .metric-grid { grid-template-columns: 1fr 1fr; }
  .metric { min-height: 112px; padding: 16px; }
  .metric strong { font-size: 25px; }
  .panel { padding: 16px; }
  .panel-head { display: block; }
  .panel-actions { justify-content: flex-start; flex-wrap: wrap; margin-top: 14px; }
  .search { margin-top: 14px; min-width: 0; }
  .directory-grid { grid-template-columns: 1fr; }
  .editor-fields { grid-template-columns: 1fr; }
  .editor-fields label.wide, .editor-fields .wide { grid-column: 1; }
}
@media (max-width: 470px) {
  .metric-grid { grid-template-columns: 1fr; }
  .topbar { display: block; }
  .topbar-actions { margin-top: 12px; justify-content: flex-start; }
  .user-badge { width: 100%; text-align: left; }
}
