html:has(body.admin-shell),
html:has(body.admin-shell) body {
  height: 100%;
  max-height: 100%;
  overflow: hidden;
}
body.admin-shell {
  display: block;
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  color-scheme: light;
}
html[data-theme="dark"] body.admin-shell { color-scheme: dark; }
@media (prefers-color-scheme: dark) {
  html[data-theme="system"] body.admin-shell { color-scheme: dark; }
}
body.admin-shell .ad-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 260px;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--nav);
  border-right: 1px solid var(--line);
  padding: 12px 10px 16px;
  overflow-x: hidden;
  overflow-y: auto;
  z-index: 20;
}
body.admin-shell.nav-compact .ad-sidebar { width: 76px; }
body.admin-shell .admin-frame { margin-left: 260px; }
body.admin-shell.nav-compact .admin-frame { margin-left: 76px; }
body.admin-shell.nav-compact .ad-nav-text,
body.admin-shell.nav-compact .ad-nav-group,
body.admin-shell.nav-compact .ad-logo,
body.admin-shell.nav-compact .admin-theme,
body.admin-shell.nav-compact .ad-side-foot .ad-nav-group { display: none; }
body.admin-shell.nav-compact .ad-nav { justify-content: center; padding: 12px 8px; }
body.admin-shell.nav-compact .ad-nav-mark { display: inline; }
.ad-nav-mark { display: none; font-weight: 800; }
body.admin-shell.nav-compact .ad-nav-mark { display: inline; }
.ad-side-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
body.admin-shell .ad-logo { margin: 0; padding: 8px; font-size: 18px; }
.ad-compact {
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  border-radius: 10px;
  width: 36px; height: 36px;
  cursor: pointer;
  font-weight: 800;
}
.ad-side-nav { flex: 1; }
.ad-side-foot { padding-top: 8px; }

.admin-frame {
  min-width: 0;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
}
.admin-topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 20px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.admin-topbar .grow { flex: 1; }

.theme-seg.top-theme { display: flex; flex-direction: row; gap: 6px; }
.theme-seg.top-theme button {
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}
.theme-seg.top-theme button.on {
  background: var(--cyan);
  color: #fff;
  border-color: transparent;
}
.theme-seg.admin-theme { display: flex; flex-direction: column; gap: 6px; padding: 0 8px 12px; }
.theme-seg.admin-theme button {
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}
.theme-seg.admin-theme button.on {
  background: var(--cyan);
  color: #fff;
  border-color: transparent;
}

body.admin-shell .admin-page { display: contents; }
body.admin-shell .ad-nav {
  color: var(--muted);
  background: transparent;
  text-decoration: none;
  font-size: 14px;
}
body.admin-shell .ad-nav:hover { background: var(--line); color: var(--ink); }
body.admin-shell .ad-nav.active {
  background: color-mix(in srgb, var(--cyan) 18%, var(--card));
  color: var(--ink);
  border: 1px solid var(--cyan);
  font-weight: 800;
}
body.admin-shell .ad-main {
  flex: 1;
  min-width: 0;
  min-height: 0;
  padding: 24px 24px 48px;
  background: var(--bg);
  overflow-y: auto;
}
body.admin-shell .ad-header { gap: 12px; flex-wrap: wrap; }
body.admin-shell .ad-header h1 { color: var(--ink); }
body.admin-shell .chart-card,
body.admin-shell .kpi,
body.admin-shell .prod-card,
body.admin-shell .kb-col,
body.admin-shell .dyn-card {
  background: var(--card);
  color: var(--ink);
  border-color: var(--line);
}
body.admin-shell .chart-card h3 { color: var(--cyan); }
body.admin-shell .ad-table tr:hover td { background: color-mix(in srgb, var(--cyan) 12%, var(--card)); }
body.admin-shell .pts-badge { background: var(--chip); color: var(--green); }
body.admin-shell input,
body.admin-shell select,
body.admin-shell textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--ink);
  border-radius: 12px;
  padding: 10px 12px;
}
body.admin-shell .btn-primary, body.admin-shell .btn {
  background: var(--grad);
  color: #0B3A6E;
  border: 0;
  font-weight: 800;
}
html[data-theme="dark"] body.admin-shell .btn-primary,
html[data-theme="dark"] body.admin-shell .btn { color: #072033; }
body.admin-shell .btn-outline, body.admin-shell .btn.ghost {
  background: var(--card);
  color: var(--ink);
  border: 1px solid var(--line);
}
body.admin-shell .toast {
  background: var(--card);
  color: var(--ink);
  border: 1px solid var(--line);
  bottom: 24px;
}

.job-bar {
  height: 36px; display: flex; align-items: center; justify-content: center;
  background: var(--cyan); color: #072033; font-size: 12px; font-weight: 700; position: relative;
}
.job-bar[hidden] { display: none; }
.job-bar-fill {
  position: absolute; left: 0; top: 0; bottom: 0; width: 0;
  background: rgba(255,255,255,.35); transition: width 0.25s ease;
}
.job-bar span { position: relative; z-index: 1; }
.ad-nav-group { font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); padding: 14px 12px 6px; font-weight: 800; }
.sk { background: linear-gradient(90deg, var(--line) 0%, var(--card) 50%, var(--line) 100%); background-size: 200% 100%; animation: sk 1.1s linear infinite; border-radius: 14px; }
.sk-line { height: 14px; margin: 10px 0; }
.sk-card { height: 92px; margin-bottom: 12px; }
@keyframes sk { to { background-position: -200% 0; } }
.stepper { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0 12px; }
.step {
  flex: 1; min-width: 90px; border-radius: 12px; padding: 8px; text-align: center;
  font-size: 11px; font-weight: 800; background: var(--line); color: var(--muted);
}
.step.on { background: var(--chip); color: var(--green); }
.step.now { background: color-mix(in srgb, var(--cyan) 25%, var(--card)); color: var(--ink); }
.kanban { display: grid; grid-template-columns: repeat(5, minmax(180px, 1fr)); gap: 12px; overflow-x: auto; }
.kb-col { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 10px; min-height: 180px; }
.kb-col h3 { font-size: 13px; margin: 0 0 8px; color: var(--ink); }
.kb-card { border: 1px solid var(--line); border-radius: 12px; padding: 10px; margin-bottom: 8px; background: var(--bg); font-size: 13px; color: var(--ink); cursor: pointer; }
.kb-card:hover { border-color: var(--cyan); }
.kb-card strong { display: block; }
.prod-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.prod-card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.prod-card img { width: 100%; height: 140px; object-fit: cover; background: var(--line); }
.prod-card .pad { padding: 12px; }
.load-note { font-size: 14px; color: var(--muted); margin: 0 0 16px; }
.ad-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.rk-cal-nav { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.rk-cal { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.rk-cal-cell {
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  border-radius: 12px;
  padding: 14px 8px;
  font-weight: 800;
  cursor: pointer;
}
.rk-cal-cell.has { box-shadow: inset 0 -3px 0 var(--green); }
.rk-cal-cell.on { background: var(--cyan); color: #fff; border-color: transparent; }

.tag-editor {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--bg);
}
body.admin-shell .tag-editor input {
  flex: 1;
  min-width: 160px;
  width: auto;
  border: 0;
  background: transparent;
  padding: 8px 4px;
  box-shadow: none;
}
.hash-chip.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  border: 1px solid var(--line);
}
.hash-chip.tag:hover { background: var(--cyan); color: #fff; }
.hash-chip .tag-x {
  font-size: 16px;
  line-height: 1;
  font-weight: 900;
}

.ad-modal {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(11, 58, 110, 0.45);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 40px 16px; overflow-y: auto;
}
.ad-modal.hidden { display: none !important; }
.ad-modal-card {
  width: min(720px, 100%);
  background: var(--card);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 20px;
  box-shadow: 0 20px 50px var(--shadow);
}
.ad-modal-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; }
.ad-modal-head h2 { font-size: 18px; }

.staff-gate {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg);
}
.staff-gate.hidden { display: none; }
body.staff-locked { overflow: auto; }
body.staff-locked .ad-sidebar,
body.staff-locked .admin-frame { display: none !important; }
.staff-card {
  width: min(420px, 100%);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 28px 24px;
  box-shadow: 0 18px 50px var(--shadow);
}
.staff-card h1 { margin: 0 0 8px; font-size: 26px; }
.staff-card input[type="email"],
.staff-card input[type="password"] {
  width: 100%;
  margin: 8px 0;
  box-sizing: border-box;
}
.staff-card .btn { width: 100%; margin-top: 10px; }
.staff-alt { margin-top: 16px; text-align: center; }

@media (max-width: 900px) {
  body.admin-shell .ad-sidebar {
    width: 72px;
    flex-direction: column;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 12px 8px;
  }
  body.admin-shell .admin-frame,
  body.admin-shell.nav-compact .admin-frame { margin-left: 72px; }
  body.admin-shell .ad-nav-text,
  body.admin-shell .ad-nav-group,
  body.admin-shell .ad-logo,
  body.admin-shell .admin-theme { display: none; }
  body.admin-shell .ad-nav { justify-content: center; }
  body.admin-shell .ad-nav-mark { display: inline; }
  .kanban { grid-template-columns: repeat(2, minmax(160px, 1fr)); }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
}
