/* ==========================================================================
   FLMS — Facility, Laboratory & Meeting Management System
   Design System / Prototype Stylesheet
   ========================================================================== */

/* ---------- Tokens ---------- */
:root {
  --brand-50:  #eef4ff;
  --brand-100: #dbe6ff;
  --brand-200: #bcd0ff;
  --brand-300: #8fb0ff;
  --brand-400: #5c86fb;
  --brand-500: #3563e9;
  --brand-600: #1b4bd6;
  --brand-700: #163bad;
  --brand-800: #16338a;
  --brand-900: #172e6e;

  --teal-100: #d3f4f2;
  --teal-500: #0fa3a3;
  --teal-600: #0b8484;

  --violet-100: #ece6ff;
  --violet-500: #7c3aed;
  --violet-600: #6b28dc;

  --amber-100: #fdf0d5;
  --amber-500: #d97706;
  --green-100: #d9f5e3;
  --green-500: #16a34a;
  --red-100:   #fde3e3;
  --red-500:   #dc2626;
  --slate-100: #eef1f6;
  --slate-500: #64748b;

  --bg:            #f5f7fb;
  --bg-elevated:   #ffffff;
  --surface:       #ffffff;
  --surface-2:     #f8fafc;
  --surface-3:     #f1f5f9;
  --sidebar-bg:    #101a2e;
  --sidebar-fg:    #a9b6cd;
  --sidebar-fg-hi: #ffffff;
  --sidebar-hover: rgba(255,255,255,.07);
  --sidebar-active:#1b4bd6;

  --border:        #e3e8f0;
  --border-strong: #cfd7e4;
  --text:          #101a2e;
  --text-muted:    #5b6b85;
  --text-faint:    #8a99b0;

  --radius-xs: 6px;
  --radius-sm: 8px;
  --radius:    12px;
  --radius-lg: 16px;
  --radius-xl: 22px;

  --shadow-xs: 0 1px 2px rgba(16,26,46,.06);
  --shadow-sm: 0 1px 3px rgba(16,26,46,.08), 0 1px 2px rgba(16,26,46,.04);
  --shadow:    0 4px 16px rgba(16,26,46,.08), 0 1px 3px rgba(16,26,46,.05);
  --shadow-lg: 0 18px 48px rgba(16,26,46,.16), 0 4px 12px rgba(16,26,46,.08);

  --sidebar-w: 264px;
  --topbar-h: 62px;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI Variable Text", "Segoe UI",
          system-ui, "Inter", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

html[data-theme="dark"] {
  --bg:            #0b1120;
  --bg-elevated:   #121b2d;
  --surface:       #121b2d;
  --surface-2:     #172236;
  --surface-3:     #1d2942;
  --sidebar-bg:    #080e1b;
  --border:        #24314c;
  --border-strong: #33425f;
  --text:          #e8edf7;
  --text-muted:    #9aa8c0;
  --text-faint:    #6f7f99;
  --brand-50:      #17233d;
  --brand-100:     #1c2a49;
  --teal-100:      #0e2f30;
  --violet-100:    #241a45;
  --amber-100:     #38270c;
  --green-100:     #0e2e1c;
  --red-100:       #3a1518;
  --slate-100:     #1d2942;
  --shadow-xs: 0 1px 2px rgba(0,0,0,.4);
  --shadow-sm: 0 1px 3px rgba(0,0,0,.45);
  --shadow:    0 4px 18px rgba(0,0,0,.45);
  --shadow-lg: 0 20px 50px rgba(0,0,0,.6);
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1,h2,h3,h4,h5 { margin: 0; font-weight: 650; letter-spacing: -.015em; line-height: 1.25; }
h1 { font-size: 22px; } h2 { font-size: 18px; } h3 { font-size: 15px; } h4 { font-size: 13px; }
p { margin: 0 0 10px; }
a { color: var(--brand-600); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; display: block; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 8px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: var(--text-faint); background-clip: content-box; }

/* ---------- Utilities ---------- */
.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.mono  { font-family: var(--mono); font-size: .92em; }
.small { font-size: 12px; }
.tiny  { font-size: 11px; }
.bold  { font-weight: 650; }
.center{ text-align: center; }
.right { text-align: right; }
.nowrap{ white-space: nowrap; }
.trunc { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hide  { display: none !important; }
.row   { display: flex; align-items: center; gap: 10px; }
.row-t { display: flex; align-items: flex-start; gap: 10px; }
.col   { display: flex; flex-direction: column; gap: 10px; }
.wrap  { flex-wrap: wrap; }
.spacer{ flex: 1 1 auto; }
.gap-4 { gap: 4px; } .gap-6 { gap: 6px; } .gap-8 { gap: 8px; }
.gap-16{ gap: 16px; } .gap-20 { gap: 20px; } .gap-24 { gap: 24px; }
.mt-4{margin-top:4px}.mt-8{margin-top:8px}.mt-12{margin-top:12px}.mt-16{margin-top:16px}.mt-24{margin-top:24px}
.mb-4{margin-bottom:4px}.mb-8{margin-bottom:8px}.mb-12{margin-bottom:12px}.mb-16{margin-bottom:16px}.mb-24{margin-bottom:24px}
.grid { display: grid; gap: 16px; }
.grid > * { min-width: 0; }
.g2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.g5 { grid-template-columns: repeat(5, minmax(0,1fr)); }
.g6 { grid-template-columns: repeat(6, minmax(0,1fr)); }
.g-2-1 { grid-template-columns: 2fr 1fr; }
.g-1-2 { grid-template-columns: 1fr 2fr; }
.g-3-2 { grid-template-columns: 3fr 2fr; }

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

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--sidebar-bg);
  color: var(--sidebar-fg);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
  z-index: 60;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 11px;
  padding: 0 18px; height: var(--topbar-h); flex: 0 0 var(--topbar-h);
  border-bottom: 1px solid rgba(255,255,255,.07);
}
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px; flex: 0 0 34px;
  background: linear-gradient(140deg, var(--brand-400), var(--teal-500));
  display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 13px;
  letter-spacing: -.04em; box-shadow: 0 4px 14px rgba(53,99,233,.45);
}
.brand-text { line-height: 1.15; }
.brand-text b { color: #fff; font-size: 14px; display: block; letter-spacing: -.02em; }
.brand-text span { font-size: 10.5px; color: var(--sidebar-fg); letter-spacing: .04em; text-transform: uppercase; }

.sidebar-scroll { flex: 1 1 auto; overflow-y: auto; padding: 12px 10px 20px; }
.sidebar-scroll::-webkit-scrollbar-thumb { background: rgba(255,255,255,.14); background-clip: content-box; }

.nav-group { margin-bottom: 2px; }
.nav-group-label {
  font-size: 10px; text-transform: uppercase; letter-spacing: .1em;
  color: #61708d; padding: 14px 10px 6px; font-weight: 700;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius-sm);
  color: var(--sidebar-fg); cursor: pointer; font-size: 13px; font-weight: 500;
  user-select: none; transition: background .12s, color .12s;
}
.nav-item:hover { background: var(--sidebar-hover); color: #fff; text-decoration: none; }
.nav-item.active { background: var(--sidebar-active); color: #fff; font-weight: 600; box-shadow: 0 4px 14px rgba(27,75,214,.4); }
.nav-item .ico { width: 17px; height: 17px; flex: 0 0 17px; opacity: .9; }
.nav-item .chev { margin-left: auto; transition: transform .18s; opacity: .6; }
.nav-item.open .chev { transform: rotate(90deg); }
.nav-item .pill {
  margin-left: auto; background: var(--red-500); color: #fff; font-size: 10px;
  font-weight: 700; padding: 1px 6px; border-radius: 20px;
}
.nav-sub { overflow: hidden; max-height: 0; transition: max-height .22s ease; }
.nav-sub.open { max-height: 700px; }
.nav-sub .nav-item { padding-left: 38px; font-size: 12.5px; font-weight: 450; }
.nav-sub .nav-item.active { background: rgba(27,75,214,.22); color: #fff; box-shadow: none; }
.nav-sub .nav-item.active::before {
  content: ""; position: absolute; margin-left: -18px; width: 3px; height: 15px;
  border-radius: 4px; background: var(--brand-400);
}

.sidebar-foot { padding: 12px; border-top: 1px solid rgba(255,255,255,.07); }
.ai-cta {
  background: linear-gradient(135deg, rgba(124,58,237,.28), rgba(53,99,233,.22));
  border: 1px solid rgba(255,255,255,.1);
  border-radius: var(--radius); padding: 12px; cursor: pointer;
}
.ai-cta:hover { border-color: rgba(255,255,255,.24); }
.ai-cta b { color: #fff; font-size: 12.5px; display: block; }
.ai-cta span { font-size: 11px; color: var(--sidebar-fg); }

.main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: var(--topbar-h); flex: 0 0 var(--topbar-h);
  background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 14px; padding: 0 20px;
  position: sticky; top: 0; z-index: 50;
}
.hamburger { display: none; }
.crumbs { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--text-muted); }
.crumbs b { color: var(--text); font-weight: 600; }

.searchbox {
  display: flex; align-items: center; gap: 8px; width: 320px; max-width: 34vw;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 10px; padding: 7px 11px; color: var(--text-faint); cursor: pointer;
}
.searchbox:hover { border-color: var(--border-strong); }
.searchbox input { border: 0; background: transparent; outline: none; width: 100%; font-size: 13px; }
.searchbox kbd {
  font-family: var(--font); font-size: 10.5px; border: 1px solid var(--border-strong);
  border-radius: 5px; padding: 1px 5px; color: var(--text-faint); background: var(--surface);
}

.icon-btn {
  width: 34px; height: 34px; border-radius: 9px; border: 1px solid transparent;
  background: transparent; display: grid; place-items: center; cursor: pointer;
  color: var(--text-muted); position: relative;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn .dot {
  position: absolute; top: 6px; right: 6px; width: 7px; height: 7px;
  border-radius: 50%; background: var(--red-500); border: 2px solid var(--surface);
}

.avatar {
  width: 32px; height: 32px; border-radius: 50%; flex: 0 0 32px;
  background: linear-gradient(140deg, var(--brand-500), var(--violet-500));
  color: #fff; display: grid; place-items: center; font-size: 12px; font-weight: 700;
}
.avatar.sm { width: 26px; height: 26px; flex-basis: 26px; font-size: 10px; }
.avatar.lg { width: 46px; height: 46px; flex-basis: 46px; font-size: 16px; }
.userchip { display: flex; align-items: center; gap: 9px; padding: 4px 8px 4px 4px; border-radius: 30px; cursor: pointer; }
.userchip:hover { background: var(--surface-3); }
.userchip .nm { line-height: 1.2; }
.userchip .nm b { font-size: 12.5px; display: block; }
.userchip .nm span { font-size: 11px; color: var(--text-muted); }

.content { flex: 1 1 auto; padding: 22px 24px 48px; min-width: 0; }
.page-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head .ttl h1 { margin-bottom: 3px; }
.page-head .ttl p { color: var(--text-muted); font-size: 13px; margin: 0; max-width: 720px; }
.page-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 8px 14px; border-radius: 9px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font-size: 13px; font-weight: 550;
  cursor: pointer; white-space: nowrap; transition: background .12s, border-color .12s, transform .06s;
  box-shadow: var(--shadow-xs); text-decoration: none;
}
.btn:hover { background: var(--surface-3); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn svg { width: 15px; height: 15px; }
.btn-primary { background: var(--brand-600); border-color: var(--brand-600); color: #fff; box-shadow: 0 2px 10px rgba(27,75,214,.28); }
.btn-primary:hover { background: var(--brand-700); border-color: var(--brand-700); }
.btn-ai { background: var(--violet-600); border-color: var(--violet-600); color: #fff; }
.btn-ai:hover { background: var(--violet-500); border-color: var(--violet-500); }
.btn-danger { background: var(--red-500); border-color: var(--red-500); color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; box-shadow: none; }
.btn-ghost:hover { background: var(--surface-3); }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 8px; }
.btn-sm svg { width: 13px; height: 13px; }
.btn-lg { padding: 11px 20px; font-size: 14px; border-radius: 10px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-block { width: 100%; }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 12px; font-weight: 600; color: var(--text-muted); }
.field label .req { color: var(--red-500); }
.input, .select, .textarea {
  width: 100%; padding: 8px 11px; border: 1px solid var(--border-strong);
  border-radius: 9px; background: var(--surface); outline: none; font-size: 13px;
  transition: border-color .12s, box-shadow .12s;
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--brand-500); box-shadow: 0 0 0 3px var(--brand-50);
}
.textarea { min-height: 80px; resize: vertical; }
.select { appearance: none; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%235b6b85' stroke-width='2' stroke-linecap='round'><path d='M4 6l4 4 4-4'/></svg>"); background-repeat: no-repeat; background-position: right 9px center; padding-right: 30px; }
.hint { font-size: 11.5px; color: var(--text-faint); }
.check { display: flex; align-items: flex-start; gap: 9px; cursor: pointer; font-size: 13px; }
.check input { margin-top: 2px; accent-color: var(--brand-600); width: 15px; height: 15px; }

.switch { position: relative; width: 38px; height: 21px; flex: 0 0 38px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: var(--border-strong); border-radius: 20px; transition: .18s; cursor: pointer; }
.switch span::before { content: ""; position: absolute; width: 15px; height: 15px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .18s; }
.switch input:checked + span { background: var(--brand-600); }
.switch input:checked + span::before { transform: translateX(17px); }

.seg { display: inline-flex; background: var(--surface-3); border-radius: 9px; padding: 3px; gap: 2px; }
.seg button {
  border: 0; background: transparent; padding: 5px 12px; border-radius: 7px;
  font-size: 12.5px; font-weight: 550; color: var(--text-muted); cursor: pointer;
}
.seg button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-xs); }

/* ---------- Card ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-xs);
}
.card-head {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
}
.card-head h3 { font-size: 14px; }
.card-head .sub { font-size: 12px; color: var(--text-muted); }
.card-head .card-tools { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.card-body { padding: 16px; }
.card-body.tight { padding: 12px; }
.card-body.flush { padding: 0; }
.card-foot { padding: 12px 16px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); }

/* ---------- KPI ---------- */
.kpi { position: relative; overflow: hidden; padding: 15px 16px; }
.kpi .kpi-top { display: flex; align-items: center; gap: 9px; margin-bottom: 8px; }
.kpi .kpi-ico { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; flex: 0 0 32px; }
.kpi .kpi-label { font-size: 12px; color: var(--text-muted); font-weight: 550; }
.kpi .kpi-val { font-size: 26px; font-weight: 700; letter-spacing: -.03em; line-height: 1.1; }
.kpi .kpi-val small { font-size: 13px; font-weight: 550; color: var(--text-muted); letter-spacing: 0; }
.kpi .kpi-foot { display: flex; align-items: center; gap: 6px; margin-top: 7px; font-size: 11.5px; }
.delta { display: inline-flex; align-items: center; gap: 3px; font-weight: 650; padding: 1px 6px; border-radius: 20px; font-size: 11px; }
.delta.up { background: var(--green-100); color: var(--green-500); }
.delta.down { background: var(--red-100); color: var(--red-500); }
.delta.flat { background: var(--slate-100); color: var(--slate-500); }

.tint-brand  { background: var(--brand-50);   color: var(--brand-600); }
.tint-teal   { background: var(--teal-100);   color: var(--teal-600); }
.tint-violet { background: var(--violet-100); color: var(--violet-500); }
.tint-amber  { background: var(--amber-100);  color: var(--amber-500); }
.tint-green  { background: var(--green-100);  color: var(--green-500); }
.tint-red    { background: var(--red-100);    color: var(--red-500); }
.tint-slate  { background: var(--slate-100);  color: var(--slate-500); }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px;
  border-radius: 20px; font-size: 11.5px; font-weight: 600; white-space: nowrap;
  background: var(--slate-100); color: var(--slate-500); line-height: 1.6;
}
.badge .bdot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.green  { background: var(--green-100);  color: var(--green-500); }
.badge.red    { background: var(--red-100);    color: var(--red-500); }
.badge.amber  { background: var(--amber-100);  color: var(--amber-500); }
.badge.brand  { background: var(--brand-50);   color: var(--brand-600); }
.badge.teal   { background: var(--teal-100);   color: var(--teal-600); }
.badge.violet { background: var(--violet-100); color: var(--violet-500); }
.badge.outline { background: transparent; border: 1px solid var(--border-strong); color: var(--text-muted); }

.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px;
  border: 1px solid var(--border-strong); border-radius: 20px; font-size: 12px;
  background: var(--surface); cursor: pointer; color: var(--text-muted);
}
.chip:hover { border-color: var(--brand-400); color: var(--brand-600); }
.chip.on { background: var(--brand-50); border-color: var(--brand-300); color: var(--brand-700); font-weight: 600; }
.chip .x { opacity: .5; }

/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
table.tbl th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-faint); font-weight: 700; padding: 10px 14px;
  background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap;
  position: sticky; top: 0; z-index: 2;
}
table.tbl td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.tbl tbody tr:hover td { background: var(--surface-2); }
table.tbl tbody tr:last-child td { border-bottom: 0; }
table.tbl td.actions { text-align: right; white-space: nowrap; }
table.tbl .lnk { font-weight: 600; color: var(--brand-600); cursor: pointer; }
table.tbl .lnk:hover { text-decoration: underline; }
.tbl-toolbar { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.tbl-search { display: flex; align-items: center; gap: 7px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px; padding: 6px 10px; min-width: 210px; }
.tbl-search input { border: 0; background: transparent; outline: none; width: 100%; font-size: 13px; }
.pager { display: flex; align-items: center; gap: 8px; padding: 11px 14px; border-top: 1px solid var(--border); font-size: 12.5px; color: var(--text-muted); }
.pager .pbtn { border: 1px solid var(--border-strong); background: var(--surface); border-radius: 7px; padding: 3px 9px; cursor: pointer; font-size: 12px; }
.pager .pbtn.on { background: var(--brand-600); border-color: var(--brand-600); color: #fff; font-weight: 650; }

/* ---------- Calendar ---------- */
.cal { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.cal-head { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); background: var(--surface-2); border-bottom: 1px solid var(--border); }
.cal-head div { padding: 8px 10px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-faint); text-align: center; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal-cell { min-height: 116px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); padding: 6px 7px; position: relative; }
.cal-cell:nth-child(7n) { border-right: 0; }
.cal-cell.out { background: var(--surface-2); }
.cal-cell.today .cal-date { background: var(--brand-600); color: #fff; }
.cal-date { font-size: 11.5px; font-weight: 650; width: 22px; height: 22px; display: grid; place-items: center; border-radius: 50%; color: var(--text-muted); }
.cal-ev {
  font-size: 11px; padding: 2px 6px; border-radius: 5px; margin-top: 3px;
  cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  border-left: 3px solid currentColor; font-weight: 550;
}
.cal-ev:hover { filter: brightness(.97); }
.cal-more { font-size: 10.5px; color: var(--text-faint); margin-top: 3px; cursor: pointer; font-weight: 600; }

/* Timeline availability */
.tl { overflow-x: auto; }
.tl-inner { min-width: 940px; }
.tl-row { display: grid; grid-template-columns: 190px 1fr; border-bottom: 1px solid var(--border); }
.tl-row:last-child { border-bottom: 0; }
.tl-head { background: var(--surface-2); position: sticky; top: 0; z-index: 3; }
.tl-label { padding: 9px 12px; border-right: 1px solid var(--border); display: flex; align-items: center; gap: 9px; }
.tl-label .rname { font-size: 12.5px; font-weight: 600; line-height: 1.25; }
.tl-label .rmeta { font-size: 11px; color: var(--text-faint); }
.tl-slots { display: grid; position: relative; }
.tl-hour { border-right: 1px dashed var(--border); font-size: 10.5px; color: var(--text-faint); text-align: center; padding: 7px 0; }
.tl-track { position: relative; height: 46px; border-right: 0; }
.tl-track .gridline { position: absolute; top: 0; bottom: 0; border-right: 1px dashed var(--border); }
.tl-block {
  position: absolute; top: 6px; bottom: 6px; border-radius: 7px; padding: 4px 8px;
  font-size: 11px; font-weight: 600; overflow: hidden; white-space: nowrap;
  text-overflow: ellipsis; cursor: pointer; border-left: 3px solid currentColor;
}
.tl-block:hover { box-shadow: var(--shadow-sm); z-index: 2; }

.ev-blue   { background: var(--brand-50);   color: var(--brand-700); }
.ev-teal   { background: var(--teal-100);   color: var(--teal-600); }
.ev-violet { background: var(--violet-100); color: var(--violet-500); }
.ev-amber  { background: var(--amber-100);  color: var(--amber-500); }
.ev-green  { background: var(--green-100);  color: var(--green-500); }
.ev-red    { background: var(--red-100);    color: var(--red-500); }
.ev-slate  { background: var(--slate-100);  color: var(--slate-500); }

/* ---------- Stepper ---------- */
.stepper { display: flex; align-items: center; gap: 0; flex-wrap: wrap; }
.step { display: flex; align-items: center; gap: 9px; padding-right: 8px; }
.step .sn {
  width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center;
  font-size: 12px; font-weight: 700; background: var(--surface-3); color: var(--text-faint);
  border: 1px solid var(--border-strong); flex: 0 0 26px;
}
.step .st { font-size: 12.5px; color: var(--text-muted); font-weight: 550; }
.step.done .sn { background: var(--green-500); border-color: var(--green-500); color: #fff; }
.step.done .st { color: var(--text); }
.step.now .sn { background: var(--brand-600); border-color: var(--brand-600); color: #fff; box-shadow: 0 0 0 4px var(--brand-50); }
.step.now .st { color: var(--text); font-weight: 650; }
.step-line { flex: 1 1 20px; min-width: 18px; height: 2px; background: var(--border-strong); margin-right: 8px; border-radius: 2px; }
.step-line.done { background: var(--green-500); }

/* ---------- Timeline / activity ---------- */
.tline { position: relative; padding-left: 26px; }
.tline::before { content: ""; position: absolute; left: 8px; top: 6px; bottom: 6px; width: 2px; background: var(--border); border-radius: 2px; }
.tline-item { position: relative; padding-bottom: 16px; }
.tline-item:last-child { padding-bottom: 0; }
.tline-item::before {
  content: ""; position: absolute; left: -22px; top: 4px; width: 10px; height: 10px;
  border-radius: 50%; background: var(--surface); border: 2px solid var(--border-strong);
}
.tline-item.ok::before   { border-color: var(--green-500); background: var(--green-500); }
.tline-item.now::before  { border-color: var(--brand-600); background: var(--brand-600); box-shadow: 0 0 0 3px var(--brand-50); }
.tline-item.warn::before { border-color: var(--amber-500); background: var(--amber-500); }
.tline-item .tt { font-size: 13px; font-weight: 600; }
.tline-item .tm { font-size: 11.5px; color: var(--text-faint); }

/* ---------- Progress ---------- */
.bar { height: 7px; background: var(--surface-3); border-radius: 20px; overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 20px; background: var(--brand-500); }
.bar.thin { height: 5px; }

.meter-row { display: grid; grid-template-columns: 1fr 62px; gap: 12px; align-items: center; }
.meter-row + .meter-row { margin-top: 11px; }
.meter-row .mlabel { font-size: 12.5px; margin-bottom: 5px; display: flex; gap: 8px; align-items: center; }
.meter-row .mval { font-size: 12.5px; font-weight: 650; text-align: right; }

/* ---------- Modal / Drawer ---------- */
.overlay {
  position: fixed; inset: 0; background: rgba(11,17,32,.5); backdrop-filter: blur(3px);
  z-index: 200; display: flex; align-items: center; justify-content: center; padding: 24px;
  animation: fade .16s ease;
}
@keyframes fade { from { opacity: 0 } }
@keyframes slideUp { from { opacity: 0; transform: translateY(14px) } }
@keyframes slideIn { from { transform: translateX(24px); opacity: 0 } }
.modal {
  background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  width: 560px; max-width: 100%; max-height: 88vh; display: flex; flex-direction: column;
  animation: slideUp .2s ease; border: 1px solid var(--border);
}
.modal.wide { width: 860px; }
.modal.xwide { width: 1080px; }
.modal-head { display: flex; align-items: flex-start; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.modal-head h3 { font-size: 15px; }
.modal-head .sub { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }
.modal-body { padding: 18px; overflow-y: auto; }
.modal-foot { padding: 13px 18px; border-top: 1px solid var(--border); display: flex; gap: 9px; justify-content: flex-end; background: var(--surface-2); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }

.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: 420px; max-width: 94vw;
  background: var(--surface); border-left: 1px solid var(--border); z-index: 210;
  box-shadow: var(--shadow-lg); display: flex; flex-direction: column; animation: slideIn .2s ease;
}
.drawer.wide { width: 620px; }
.drawer-head { padding: 15px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 12px; }
.drawer-body { flex: 1 1 auto; overflow-y: auto; padding: 18px; }
.drawer-foot { padding: 13px 18px; border-top: 1px solid var(--border); display: flex; gap: 9px; background: var(--surface-2); }

/* ---------- Toast ---------- */
.toasts { position: fixed; bottom: 22px; right: 22px; z-index: 400; display: flex; flex-direction: column; gap: 10px; }
.toast {
  background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--brand-500);
  border-radius: var(--radius-sm); box-shadow: var(--shadow); padding: 12px 15px;
  display: flex; gap: 11px; align-items: flex-start; width: 330px; animation: slideIn .2s ease;
}
.toast.ok   { border-left-color: var(--green-500); }
.toast.warn { border-left-color: var(--amber-500); }
.toast.err  { border-left-color: var(--red-500); }
.toast b { font-size: 13px; display: block; }
.toast span { font-size: 12px; color: var(--text-muted); }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 3px; border-bottom: 1px solid var(--border); overflow-x: auto; }
.tabs button {
  border: 0; background: transparent; padding: 9px 14px; font-size: 13px; font-weight: 550;
  color: var(--text-muted); cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap;
}
.tabs button:hover { color: var(--text); }
.tabs button.active { color: var(--brand-600); border-bottom-color: var(--brand-600); font-weight: 650; }

/* ---------- Misc components ---------- */
.dl { display: grid; grid-template-columns: 150px 1fr; gap: 9px 14px; font-size: 13px; }
.dl dt { color: var(--text-muted); font-size: 12.5px; }
.dl dd { margin: 0; font-weight: 550; }

.empty { text-align: center; padding: 44px 20px; color: var(--text-muted); }
.empty .eico { width: 52px; height: 52px; border-radius: 50%; background: var(--surface-3); display: grid; place-items: center; margin: 0 auto 14px; color: var(--text-faint); }
.empty b { display: block; font-size: 14px; color: var(--text); margin-bottom: 4px; }

.thumb { width: 100%; aspect-ratio: 16/9; border-radius: 10px; overflow: hidden; position: relative; background: linear-gradient(135deg, var(--brand-100), var(--teal-100)); display: grid; place-items: center; }
.thumb .pat { position: absolute; inset: 0; opacity: .5; }
.thumb .lbl { position: relative; font-size: 12px; font-weight: 700; color: var(--brand-700); letter-spacing: .06em; text-transform: uppercase; }

.res-card { overflow: hidden; cursor: pointer; transition: transform .12s, box-shadow .12s; }
.res-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.res-card .rc-body { padding: 13px 14px; }
.res-card .rc-title { font-size: 14px; font-weight: 650; margin-bottom: 2px; }
.res-card .rc-meta { font-size: 12px; color: var(--text-muted); }
.res-card .rc-facs { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 9px; }
.fac { font-size: 10.5px; padding: 2px 7px; border-radius: 5px; background: var(--surface-3); color: var(--text-muted); font-weight: 550; }

.qr { width: 96px; height: 96px; border-radius: 10px; background: var(--surface); border: 1px solid var(--border); padding: 6px; }

.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 11.5px; color: var(--text-muted); }
.legend i { width: 9px; height: 9px; border-radius: 3px; display: inline-block; margin-right: 5px; }

.alert { display: flex; gap: 11px; padding: 12px 14px; border-radius: var(--radius-sm); font-size: 13px; align-items: flex-start; }
.alert.info  { background: var(--brand-50);  color: var(--brand-700); }
.alert.warn  { background: var(--amber-100); color: var(--amber-500); }
.alert.err   { background: var(--red-100);   color: var(--red-500); }
.alert.ok    { background: var(--green-100); color: var(--green-500); }
.alert.ai    { background: var(--violet-100);color: var(--violet-500); }
.alert b:first-child { display: block; margin-bottom: 2px; }

/* AI assistant */
.ai-wrap { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; align-items: start; }
.chat { display: flex; flex-direction: column; height: calc(100vh - 210px); min-height: 460px; }
.chat-log { flex: 1 1 auto; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 16px; }
.msg { display: flex; gap: 11px; max-width: 86%; }
.msg .bub { padding: 11px 14px; border-radius: 14px; font-size: 13.5px; line-height: 1.55; }
.msg.bot .bub { background: var(--surface-2); border: 1px solid var(--border); border-top-left-radius: 4px; }
.msg.me { margin-left: auto; flex-direction: row-reverse; }
.msg.me .bub { background: var(--brand-600); color: #fff; border-top-right-radius: 4px; }
.msg .aiav { width: 30px; height: 30px; border-radius: 9px; flex: 0 0 30px; background: linear-gradient(140deg, var(--violet-500), var(--brand-500)); display: grid; place-items: center; color: #fff; }
.chat-input { border-top: 1px solid var(--border); padding: 12px 14px; display: flex; gap: 9px; align-items: flex-end; }
.chat-input textarea { flex: 1; border: 1px solid var(--border-strong); border-radius: 11px; padding: 9px 12px; resize: none; min-height: 42px; max-height: 130px; outline: none; background: var(--surface); font-size: 13.5px; }
.chat-input textarea:focus { border-color: var(--brand-500); box-shadow: 0 0 0 3px var(--brand-50); }
.suggest { padding: 9px 12px; border: 1px solid var(--border); border-radius: 9px; font-size: 12.5px; cursor: pointer; background: var(--surface); }
.suggest:hover { border-color: var(--brand-400); background: var(--brand-50); color: var(--brand-700); }

/* Layout picker */
.layout-opt { border: 2px solid var(--border); border-radius: 11px; padding: 11px; cursor: pointer; text-align: center; background: var(--surface); }
.layout-opt:hover { border-color: var(--brand-300); }
.layout-opt.on { border-color: var(--brand-600); background: var(--brand-50); }
.layout-opt .ln { font-size: 12px; font-weight: 650; margin-top: 7px; }
.layout-opt .lc { font-size: 11px; color: var(--text-muted); }

/* Seat map */
.seatmap { display: grid; gap: 3px; }
.seat { width: 100%; aspect-ratio: 1; border-radius: 3px; background: var(--brand-200); }
.seat.vip { background: var(--violet-500); }
.seat.sold { background: var(--border-strong); }

/* Login */
.auth {
  min-height: 100vh; display: grid; grid-template-columns: 1.05fr .95fr;
  background: var(--bg);
}
.auth-art {
  background: linear-gradient(150deg, #0d1a35 0%, #142a5c 45%, #0d3c48 100%);
  color: #fff; padding: 46px 52px; display: flex; flex-direction: column; position: relative; overflow: hidden;
}
.auth-art .glow { position: absolute; border-radius: 50%; filter: blur(70px); opacity: .5; }
.auth-art .g1 { width: 330px; height: 330px; background: #3563e9; top: -70px; right: -60px; }
.auth-art .g2 { width: 290px; height: 290px; background: #0fa3a3; bottom: -70px; left: -50px; }
.auth-art > * { position: relative; z-index: 1; }
.auth-form { display: flex; align-items: center; justify-content: center; padding: 40px 26px; }
.auth-card { width: 400px; max-width: 100%; }
.auth-feat { display: flex; gap: 12px; align-items: flex-start; margin-top: 18px; }
.auth-feat .fi { width: 34px; height: 34px; border-radius: 10px; background: rgba(255,255,255,.11); display: grid; place-items: center; flex: 0 0 34px; }
.auth-feat b { font-size: 13.5px; display: block; }
.auth-feat span { font-size: 12.5px; color: rgba(255,255,255,.66); }
.role-pick { display: grid; grid-template-columns: repeat(2,1fr); gap: 8px; }
.role-opt { border: 1px solid var(--border-strong); border-radius: 9px; padding: 9px 11px; cursor: pointer; font-size: 12.5px; background: var(--surface); }
.role-opt:hover { border-color: var(--brand-400); }
.role-opt.on { border-color: var(--brand-600); background: var(--brand-50); color: var(--brand-700); font-weight: 600; }

/* ---------- Layout halaman khusus ---------- */
.cal-page, .perm-page { display: grid; gap: 16px; align-items: start; }
.cal-page  { grid-template-columns: minmax(0, 1fr) 300px; }
.perm-page { grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); }
@media (max-width: 1100px) {
  .cal-page, .perm-page { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- Responsive ---------- */
@media (max-width: 1400px) { .g6 { grid-template-columns: repeat(3, minmax(0,1fr)); } }
@media (max-width: 1200px) {
  .g5, .g4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .g-2-1, .g-1-2, .g-3-2 { grid-template-columns: minmax(0, 1fr); }
  .ai-wrap { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 900px) {
  .sidebar {
    position: fixed; left: 0; top: 0; transform: translateX(-100%);
    transition: transform .22s ease; box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }
  .hamburger { display: grid; }
  .content { padding: 16px 14px 44px; }
  .g2, .g3, .g4, .g5, .g6 { grid-template-columns: minmax(0, 1fr); }
  .searchbox { display: none; }
  .auth { grid-template-columns: minmax(0, 1fr); }
  .auth-art { display: none; }
  .dl { grid-template-columns: minmax(0, 1fr); gap: 2px 0; }
  .dl dd { margin-bottom: 8px; }
  .cal-cell { min-height: 78px; }
  .topbar { padding: 0 12px; }
}
@media (max-width: 760px) {
  .crumbs { display: none; }
  .userchip .nm, .userchip > svg { display: none; }
  .userchip { padding: 4px; }
  .card-head { flex-wrap: wrap; }
  .card-head .card-tools { margin-left: 0; width: 100%; }
  .page-actions { width: 100%; }
  .stepper { row-gap: 8px; }
  .step-line { display: none; }
  .modal-foot, .drawer-foot { flex-wrap: wrap; }
  .modal-foot .btn, .drawer-foot .btn { flex: 1 1 auto; }
  .seg { width: 100%; }
  .seg button { flex: 1 1 auto; }
}
@media (max-width: 460px) {
  .toasts { left: 12px; right: 12px; bottom: 12px; }
  .toast { width: auto; }
  h1 { font-size: 19px; }
  .kpi .kpi-val { font-size: 23px; }
}

.scrim { position: fixed; inset: 0; background: rgba(11,17,32,.45); z-index: 55; }
@media (min-width: 901px) { .scrim { display: none; } }

@media print {
  .sidebar, .topbar, .page-actions { display: none !important; }
  .content { padding: 0; }
}

/* ---------- Penyesuaian kontras mode gelap ----------
   Token *-500/600 dirancang untuk latar terang. Di mode gelap, teks di atas
   permukaan tint perlu dinaikkan luminansinya agar tetap terbaca.            */
html[data-theme="dark"] {
  --brand-500:  #6f97ff;   /* garis chart & isian bar */
  --violet-500: #a98bff;
  --teal-500:   #2fd4cf;
}
html[data-theme="dark"] a,
html[data-theme="dark"] table.tbl .lnk { color: #8fb0ff; }
html[data-theme="dark"] .tabs button.active { color: #8fb0ff; border-bottom-color: #8fb0ff; }

html[data-theme="dark"] .badge,
html[data-theme="dark"] .tint-slate,
html[data-theme="dark"] .ev-slate,
html[data-theme="dark"] .delta.flat  { color: #a5b2c8; }
html[data-theme="dark"] .tint-brand,
html[data-theme="dark"] .badge.brand,
html[data-theme="dark"] .chip.on,
html[data-theme="dark"] .alert.info,
html[data-theme="dark"] .ev-blue     { color: #a3c0ff; }
html[data-theme="dark"] .tint-teal,
html[data-theme="dark"] .badge.teal,
html[data-theme="dark"] .ev-teal     { color: #3fe0da; }
html[data-theme="dark"] .tint-violet,
html[data-theme="dark"] .badge.violet,
html[data-theme="dark"] .alert.ai,
html[data-theme="dark"] .ev-violet   { color: #bfa6ff; }
html[data-theme="dark"] .tint-amber,
html[data-theme="dark"] .badge.amber,
html[data-theme="dark"] .alert.warn,
html[data-theme="dark"] .ev-amber,
html[data-theme="dark"] .delta.down  { color: #f6b95c; }
html[data-theme="dark"] .tint-green,
html[data-theme="dark"] .badge.green,
html[data-theme="dark"] .alert.ok,
html[data-theme="dark"] .ev-green,
html[data-theme="dark"] .delta.up    { color: #4ade80; }
html[data-theme="dark"] .tint-red,
html[data-theme="dark"] .badge.red,
html[data-theme="dark"] .alert.err,
html[data-theme="dark"] .ev-red      { color: #ff8b8b; }
html[data-theme="dark"] .badge.outline { color: var(--text-muted); }
