/* TESPAM Eğitim Akademisi — Yönetim Paneli
   Design tokens: SPEC §9. Dark --night sidebar, light content area. */

:root {
  --night: #050F16; --night-2: #0A1A24; --night-3: #10283A;
  --cyan: #1FB8E6; --cyan-strong: #0C8DB8; --cyan-ink: #086A8C; --cyan-tint: #E3F5FB;
  --red: #E0242B; --red-strong: #B81A20; --red-tint: #FCE7E8;
  --bg: #EEF2F4; --surface: #FFFFFF; --surface-2: #F4F7F8; --line: #CFD8DC; --line-soft: #E0E7EA;
  --ink: #0F1B22; --ink-soft: #43545E; --ink-faint: #6C7E88;
  --ok: #1E7F4F; --warn: #A86A00; --danger: #B81A20;
  --st-new: #0C8DB8; --st-review: #6B5BD6; --st-approved: #1E7F4F; --st-waitlist: #A86A00;
  --st-rejected: #B81A20; --st-cancelled: #6C7E88; --st-attended: #0F5E7A;
  --r: 6px; --r-lg: 10px;
  --sans: 'IBM Plex Sans', 'Noto Sans Arabic', system-ui, -apple-system, 'Segoe UI', Roboto, 'PingFang SC', 'Microsoft YaHei', 'Noto Sans SC', sans-serif;
  --serif: 'IBM Plex Serif', Georgia, 'Times New Roman', serif;
  --mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sidebar-w: 244px;
  --topbar-h: 56px;
  --shadow: 0 1px 2px rgba(15, 27, 34, .06), 0 2px 8px rgba(15, 27, 34, .05);
  --shadow-lg: 0 12px 40px rgba(5, 15, 22, .22);
  --focus: 0 0 0 3px rgba(31, 184, 230, .45);
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--sans); font-size: 14px; line-height: 1.5;
  color: var(--ink); background: var(--bg);
}
img { max-width: 100%; }
a { color: var(--cyan-ink); }
a:hover { color: var(--cyan-strong); }
h1, h2, h3, h4 { font-family: var(--serif); font-weight: 600; margin: 0; line-height: 1.25; color: var(--ink); }
h1 { font-size: 22px; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }
p { margin: 0 0 .6em; }
code, .mono { font-family: var(--mono); }
[hidden] { display: none !important; }
:focus { outline: none; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--r); }
.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: 8px; top: -60px; z-index: 1000; background: var(--surface);
  padding: 8px 12px; border-radius: var(--r); box-shadow: var(--shadow-lg);
}
.skip-link:focus { top: 8px; }

/* ---------- Boot / auth screens ---------- */
.boot {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  color: #9fb3bf; background: var(--night); font-family: var(--mono); font-size: 13px; gap: 10px;
}
.auth {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px;
  background:
    radial-gradient(900px 500px at 15% -10%, rgba(31, 184, 230, .16), transparent 60%),
    radial-gradient(700px 400px at 110% 110%, rgba(224, 36, 43, .10), transparent 60%),
    var(--night);
}
.auth-card {
  width: 100%; max-width: 420px; background: var(--surface); border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg); padding: 28px 28px 24px;
}
.auth-card.wide { max-width: 480px; }
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.auth-brand img { height: 40px; width: auto; }
.auth-brand .t1 { font-family: var(--serif); font-weight: 600; font-size: 17px; }
.auth-brand .t2 { font-family: var(--mono); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-faint); }
.auth-card h1 { font-size: 20px; margin-bottom: 6px; }
.auth-card .lead { color: var(--ink-soft); margin-bottom: 18px; }
.auth-card .btn-block { margin-top: 8px; }
.auth-foot { margin-top: 16px; font-size: 12px; color: var(--ink-faint); text-align: center; }

/* ---------- App shell ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  background: var(--night); color: #C9D6DD; position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; overflow-y: auto; z-index: 40;
  border-right: 1px solid #0d2130;
}
.sb-brand {
  display: flex; align-items: center; gap: 10px; padding: 16px 16px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, .06); text-decoration: none; color: #fff;
}
.sb-brand img { height: 34px; width: auto; flex: none; }
.sb-brand .t1 { font-family: var(--serif); font-weight: 600; font-size: 15px; line-height: 1.15; color: #fff; }
.sb-brand .t2 { font-size: 12px; color: #9fb3bf; line-height: 1.3; }
.sb-brand .t3 { font-family: var(--mono); font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: var(--cyan); margin-top: 1px; }
.sb-nav { padding: 10px 8px 16px; display: flex; flex-direction: column; gap: 1px; flex: 1; }
.sb-group {
  font-family: var(--mono); font-size: 10px; letter-spacing: .12em; text-transform: uppercase;
  color: #5f7885; padding: 14px 10px 6px;
}
.sb-link {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--r);
  color: #C9D6DD; text-decoration: none; font-weight: 500; font-size: 13.5px; position: relative;
}
.sb-link svg { width: 18px; height: 18px; flex: none; opacity: .8; }
.sb-link:hover { background: var(--night-2); color: #fff; }
.sb-link.active { background: var(--night-3); color: #fff; }
.sb-link.active::before {
  content: ""; position: absolute; left: -8px; top: 6px; bottom: 6px; width: 3px; border-radius: 0 3px 3px 0; background: var(--cyan);
}
.sb-link.active svg { opacity: 1; color: var(--cyan); }
.sb-link .badge { margin-left: auto; }
.sb-foot { padding: 12px 16px; border-top: 1px solid rgba(255, 255, 255, .06); font-size: 11px; color: #5f7885; font-family: var(--mono); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: var(--topbar-h); background: var(--surface); border-bottom: 1px solid var(--line-soft);
  display: flex; align-items: center; gap: 12px; padding: 0 20px; position: sticky; top: 0; z-index: 30;
}
.topbar .menu-btn { display: none; }
.topbar .crumb { font-family: var(--serif); font-weight: 600; font-size: 15px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .spacer { flex: 1; }
.user-chip { display: flex; align-items: center; gap: 8px; min-width: 0; flex: none; }
.user-chip .avatar {
  width: 30px; height: 30px; border-radius: 50%; background: var(--night-3); color: #fff; flex: none;
  display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 12px;
}
.user-chip .who { line-height: 1.2; min-width: 0; }
.user-chip .who b { display: block; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 180px; }
.user-chip .who span { font-size: 11px; color: var(--ink-faint); font-family: var(--mono); text-transform: uppercase; letter-spacing: .06em; }
.content { padding: 22px 24px 48px; max-width: 1400px; width: 100%; }
.scrim { display: none; }

/* ---------- Page header ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head .sub { color: var(--ink-faint); font-size: 13px; margin-top: 2px; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.back-link { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; text-decoration: none; margin-bottom: 6px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 500; font-size: 13.5px; line-height: 1.2;
  padding: 8px 14px; border-radius: var(--r); border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); cursor: pointer; text-decoration: none; white-space: nowrap;
  min-height: 36px;
}
.btn:hover { background: var(--surface-2); color: var(--ink); border-color: #b8c5cb; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; flex: none; }
.btn-primary { background: var(--cyan-strong); border-color: var(--cyan-strong); color: #fff; }
.btn-primary:hover { background: var(--cyan-ink); border-color: var(--cyan-ink); color: #fff; }
.btn-danger { background: var(--red-strong); border-color: var(--red-strong); color: #fff; }
.btn-danger:hover { background: #9c151a; border-color: #9c151a; color: #fff; }
.btn-danger-ghost { color: var(--danger); border-color: #e7c2c4; background: var(--surface); }
.btn-danger-ghost:hover { background: var(--red-tint); color: var(--danger); border-color: #dca5a8; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--surface-2); border-color: var(--line-soft); }
.btn-sm { padding: 5px 10px; font-size: 12.5px; min-height: 30px; }
.btn-xs { padding: 3px 7px; font-size: 12px; min-height: 26px; }
.btn-block { width: 100%; }
.btn-icon { padding: 6px; min-width: 32px; min-height: 32px; }
.btn.is-loading { position: relative; color: transparent !important; }
.btn.is-loading::after {
  content: ""; position: absolute; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid currentColor; border-color: var(--ink-faint) transparent var(--ink-faint) transparent; animation: spin .8s linear infinite;
}
.btn-primary.is-loading::after, .btn-danger.is-loading::after { border-color: #fff transparent #fff transparent; }
.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; margin-left: -1px; }
.btn-group .btn:first-child { border-radius: var(--r) 0 0 var(--r); margin-left: 0; }
.btn-group .btn:last-child { border-radius: 0 var(--r) var(--r) 0; }
.btn-group .btn[aria-pressed="true"] { background: var(--night-3); border-color: var(--night-3); color: #fff; z-index: 1; }

/* ---------- Cards / KPIs ---------- */
.card { background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--r-lg); box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 14px 16px 10px; border-bottom: 1px solid var(--line-soft); flex-wrap: wrap; }
.card-head h2 { font-size: 15px; }
.card-body { padding: 14px 16px; }
.card-body.flush { padding: 0; }
.card + .card { margin-top: 16px; }
.res-grid > .card, .grid > .card, .kpis > .card { margin-top: 0; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.dash-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 16px; margin-top: 16px; }
.dash-grid > .col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.dash-grid > .col > .card + .card { margin-top: 0; }

.kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.kpi {
  display: block; text-decoration: none; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line-soft); border-radius: var(--r-lg); padding: 14px 16px; box-shadow: var(--shadow);
  position: relative; overflow: hidden;
}
.kpi::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--kpi-c, var(--cyan)); }
.kpi:hover { border-color: var(--line); color: var(--ink); }
.kpi .k-label { font-size: 12px; color: var(--ink-soft); font-weight: 500; }
.kpi .k-value { font-family: var(--serif); font-size: 28px; font-weight: 600; line-height: 1.15; margin-top: 4px; }
.kpi .k-sub { font-size: 11.5px; color: var(--ink-faint); font-family: var(--mono); }

/* ---------- Lists ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list > li { border-top: 1px solid var(--line-soft); }
.list > li:first-child { border-top: 0; }
.list-item {
  display: flex; gap: 12px; align-items: center; padding: 11px 16px; text-decoration: none; color: var(--ink);
}
a.list-item:hover { background: var(--surface-2); color: var(--ink); }
.list-item .li-main { flex: 1; min-width: 0; }
.list-item .li-title { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item .li-meta { font-size: 12px; color: var(--ink-faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item .li-side { flex: none; text-align: right; font-size: 12px; color: var(--ink-soft); }
.date-badge {
  flex: none; width: 46px; text-align: center; border: 1px solid var(--line-soft); border-radius: var(--r); overflow: hidden; background: var(--surface);
}
.date-badge .m { background: var(--night-3); color: #fff; font-family: var(--mono); font-size: 10px; letter-spacing: .06em; text-transform: uppercase; padding: 1px 0; }
.date-badge .d { font-family: var(--serif); font-weight: 600; font-size: 17px; line-height: 1.5; }

/* ---------- Pills / badges ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 600; line-height: 1;
  padding: 4px 8px; border-radius: 999px; white-space: nowrap; color: var(--pc, var(--ink-soft));
  background: color-mix(in srgb, var(--pc, var(--ink-faint)) 12%, #fff);
  border: 1px solid color-mix(in srgb, var(--pc, var(--ink-faint)) 30%, #fff);
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.no-dot::before { display: none; }
.st-new { --pc: var(--st-new); } .st-review { --pc: var(--st-review); } .st-approved { --pc: var(--st-approved); }
.st-waitlist { --pc: var(--st-waitlist); } .st-rejected { --pc: var(--st-rejected); } .st-cancelled { --pc: var(--st-cancelled); }
.st-attended { --pc: var(--st-attended); }
.av-open { --pc: var(--ok); } .av-limited { --pc: var(--warn); } .av-full { --pc: var(--danger); }
.av-planned { --pc: var(--st-review); } .av-closed { --pc: var(--ink-faint); } .av-cancelled { --pc: var(--ink-faint); }
.sv-draft { --pc: var(--ink-faint); } .sv-open { --pc: var(--ok); } .sv-closed { --pc: var(--st-attended); }
.vis-public { --pc: var(--ok); } .vis-participants { --pc: var(--cyan-strong); } .vis-private { --pc: var(--ink-faint); }
.pill-on { --pc: var(--ok); } .pill-off { --pc: var(--ink-faint); } .pill-warn { --pc: var(--warn); } .pill-admin { --pc: var(--red-strong); } .pill-editor { --pc: var(--cyan-strong); }
.badge {
  display: inline-block; min-width: 20px; padding: 2px 6px; border-radius: 999px; font-size: 11px; font-weight: 600;
  text-align: center; background: var(--line-soft); color: var(--ink-soft); font-family: var(--mono); line-height: 1.3;
}
.sb-link .badge { background: var(--cyan-strong); color: #fff; }
.tag {
  display: inline-block; font-family: var(--mono); font-size: 11.5px; font-weight: 500; padding: 2px 6px; border-radius: 4px;
  background: var(--surface-2); border: 1px solid var(--line-soft); color: var(--ink-soft); white-space: nowrap;
}
.code-chip {
  font-family: var(--mono); font-weight: 600; letter-spacing: .08em; background: var(--night-2); color: var(--cyan);
  padding: 3px 8px; border-radius: 4px; font-size: 12.5px; white-space: nowrap;
}
.star { color: #C7921A; }
.muted { color: var(--ink-faint); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.pre { white-space: pre-wrap; word-break: break-word; }
.text-right { text-align: right; }
.danger-text { color: var(--danger); }

/* ---------- Capacity bar ---------- */
.cap { display: flex; align-items: center; gap: 8px; min-width: 140px; }
.cap-bar { flex: 1; height: 7px; background: var(--line-soft); border-radius: 99px; overflow: hidden; min-width: 60px; }
.cap-bar > span { display: block; height: 100%; background: var(--ok); border-radius: 99px; }
.cap-bar.is-limited > span { background: var(--warn); }
.cap-bar.is-full > span { background: var(--danger); }
.cap-bar.is-none > span { background: var(--cyan-strong); opacity: .35; }
.cap-text { font-family: var(--mono); font-size: 12px; color: var(--ink-soft); white-space: nowrap; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: thin; margin-bottom: 14px; }
.tab {
  font: inherit; font-weight: 500; font-size: 13px; background: none; border: 0; border-bottom: 2px solid transparent;
  padding: 9px 12px 8px; color: var(--ink-soft); cursor: pointer; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px;
  margin-bottom: -1px; border-radius: var(--r) var(--r) 0 0;
}
.tab:hover { color: var(--ink); background: rgba(255, 255, 255, .6); }
.tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--cyan-strong); }
.tab[aria-selected="true"] .badge { background: var(--cyan-strong); color: #fff; }
.tab .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--line); }
.tab .dot.full { background: var(--ok); }
.tab .dot.part { background: var(--warn); }
.lang-tabs { margin-bottom: 12px; }

/* ---------- Toolbar / filters ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; margin-bottom: 12px; }
.toolbar .field { margin: 0; }
.toolbar .grow { flex: 1 1 220px; }
.toolbar .field > label { font-size: 11.5px; }
.bulkbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 12px; margin-bottom: 12px;
  background: var(--night-3); color: #fff; border-radius: var(--r-lg);
}
.bulkbar .count { font-weight: 600; margin-right: 4px; }
.bulkbar .input, .bulkbar select { min-height: 32px; padding: 5px 8px; }
.bulkbar .btn:not(.btn-primary) { background: transparent; color: #fff; border-color: rgba(255, 255, 255, .3); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th, .tbl td { padding: 9px 12px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line-soft); }
.tbl thead th {
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-faint);
  background: var(--surface-2); border-bottom: 1px solid var(--line); white-space: nowrap; position: sticky; top: 0;
}
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr.clickable { cursor: pointer; }
.tbl tbody tr.clickable:hover td { background: #F7FAFB; }
.tbl tbody tr.selected td { background: var(--cyan-tint); }
.tbl tbody tr.is-open td { background: #E9F6FB; }
.tbl tbody tr:focus-visible { outline: 2px solid var(--cyan); outline-offset: -2px; box-shadow: none; }
.tbl .col-check { width: 36px; padding-right: 0; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl .cell-title { font-weight: 500; color: var(--ink); }
.tbl .cell-sub { font-size: 12px; color: var(--ink-faint); }
.tbl .cell-actions { white-space: nowrap; text-align: right; }
.tbl .cell-actions .btn + .btn { margin-left: 4px; }
.sort-btn {
  font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; display: inline-flex; align-items: center; gap: 4px;
  text-transform: inherit; letter-spacing: inherit;
}
.sort-btn .arrow { font-size: 10px; opacity: .35; }
.sort-btn[data-active="1"] { color: var(--ink); }
.sort-btn[data-active="1"] .arrow { opacity: 1; color: var(--cyan-strong); }
.table-foot { padding: 10px 12px; display: flex; justify-content: space-between; align-items: center; gap: 8px; border-top: 1px solid var(--line-soft); font-size: 12.5px; color: var(--ink-faint); flex-wrap: wrap; }
.ellipsis { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 14px 16px; }
.form-grid > * { grid-column: span 12; }
.span-6 { grid-column: span 6 !important; } .span-4 { grid-column: span 4 !important; }
.span-3 { grid-column: span 3 !important; } .span-8 { grid-column: span 8 !important; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > label, .field-label { font-size: 12.5px; font-weight: 600; color: var(--ink-soft); }
.field .req { color: var(--danger); margin-left: 2px; }
.field .hint { font-size: 12px; color: var(--ink-faint); }
.field .err { font-size: 12px; color: var(--danger); font-weight: 500; }
.field.has-error .input, .field.has-error select, .field.has-error textarea { border-color: var(--danger); background: #FFF8F8; }
.input, select.input, textarea.input {
  font: inherit; font-size: 14px; color: var(--ink); background: var(--surface); width: 100%;
  border: 1px solid var(--line); border-radius: var(--r); padding: 8px 10px; min-height: 36px;
}
textarea.input { resize: vertical; min-height: 80px; line-height: 1.5; }
.input:hover { border-color: #b3c1c7; }
.input:focus { border-color: var(--cyan-strong); box-shadow: var(--focus); outline: none; }
.input[readonly] { background: var(--surface-2); }
select.input { padding-right: 28px; appearance: none; -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-soft) 50%), linear-gradient(135deg, var(--ink-soft) 50%, transparent 50%);
  background-position: calc(100% - 15px) 55%, calc(100% - 10px) 55%; background-size: 5px 5px; background-repeat: no-repeat; }
.input.input-sm { min-height: 34px; padding: 6px 9px; font-size: 13px; }
select.input.input-sm { padding-right: 26px; }
.input-mono { font-family: var(--mono); }
.check { display: inline-flex; align-items: flex-start; gap: 8px; cursor: pointer; font-size: 13.5px; line-height: 1.35; }
.check input { width: 16px; height: 16px; margin: 1px 0 0; accent-color: var(--cyan-strong); flex: none; }
.checks { display: flex; flex-wrap: wrap; gap: 8px 16px; padding: 6px 0; }
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 13.5px; position: relative; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { width: 36px; height: 20px; border-radius: 99px; background: var(--line); position: relative; transition: background .15s; flex: none; }
.switch .track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .15s; }
.switch input:checked + .track { background: var(--cyan-strong); }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch input:focus-visible + .track { box-shadow: var(--focus); }
.form-section { border-top: 1px solid var(--line-soft); padding-top: 16px; margin-top: 4px; }
.form-section > h3 { margin-bottom: 10px; }
.form-actions {
  display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; padding: 12px 16px; border-top: 1px solid var(--line-soft);
  background: var(--surface-2); border-radius: 0 0 var(--r-lg) var(--r-lg);
}
.form-actions .left { margin-right: auto; display: flex; gap: 8px; }
.sticky-actions { position: sticky; bottom: 0; z-index: 5; }
.form-alert { border-radius: var(--r); padding: 10px 12px; font-size: 13px; margin-bottom: 12px; }
.form-alert.error { background: var(--red-tint); color: #7d1216; border: 1px solid #f3c3c5; }
.form-alert.info { background: var(--cyan-tint); color: #064c63; border: 1px solid #bfe6f3; }
.form-alert.warn { background: #FDF3E1; color: #6b4400; border: 1px solid #F0D9AC; }
details.more { border: 1px dashed var(--line); border-radius: var(--r); padding: 0 12px; }
details.more > summary { cursor: pointer; padding: 8px 0; font-size: 12.5px; font-weight: 600; color: var(--cyan-ink); }
details.more[open] { padding-bottom: 12px; }
details.more .form-grid { gap: 10px 12px; }
[dir="rtl"].input { text-align: right; font-family: 'Noto Sans Arabic', var(--sans); }
.progress { height: 8px; border-radius: 99px; background: var(--line-soft); overflow: hidden; }
.progress > span { display: block; height: 100%; width: 0; background: var(--cyan-strong); transition: width .15s; }

/* ---------- Combobox ---------- */
.combo { position: relative; }
.combo-list {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 60; max-height: 280px; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow-lg); margin: 0; padding: 4px; list-style: none;
}
.combo-list li { padding: 7px 9px; border-radius: 4px; cursor: pointer; font-size: 13px; }
.combo-list li .c { font-family: var(--mono); font-size: 12px; color: var(--cyan-ink); margin-right: 6px; }
.combo-list li[aria-selected="true"] { background: var(--cyan-tint); }
.combo-list li.empty { color: var(--ink-faint); cursor: default; }
.combo-clear { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); }
.combo .input { padding-right: 36px; }

/* ---------- Drawer ---------- */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(5, 15, 22, .35); z-index: 80; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(620px, 100vw); background: var(--surface); z-index: 81;
  box-shadow: var(--shadow-lg); display: flex; flex-direction: column; animation: slidein .18s ease-out;
}
@keyframes slidein { from { transform: translateX(24px); opacity: .6; } to { transform: none; opacity: 1; } }
.drawer-head { display: flex; align-items: flex-start; gap: 10px; padding: 16px 18px 12px; border-bottom: 1px solid var(--line-soft); }
.drawer-head .dh-main { flex: 1; min-width: 0; }
.drawer-head h2 { font-size: 18px; word-break: break-word; }
.drawer-head .dh-sub { font-size: 12.5px; color: var(--ink-faint); margin-top: 2px; }
.drawer-body { flex: 1; overflow-y: auto; padding: 14px 18px 24px; }
.drawer-section { margin-top: 18px; }
.drawer-section:first-child { margin-top: 0; }
.drawer-section > h3 {
  font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--ink-faint); font-weight: 600;
  margin-bottom: 8px;
}
dl.kv { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 6px 12px; margin: 0; font-size: 13.5px; }
dl.kv dt { color: var(--ink-faint); font-size: 12.5px; padding-top: 1px; }
dl.kv dd { margin: 0; word-break: break-word; }
.status-box { background: var(--surface-2); border: 1px solid var(--line-soft); border-radius: var(--r-lg); padding: 12px; }
.status-box .row { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; }
.status-box .row .field { flex: 1 1 180px; }

.timeline { list-style: none; margin: 0; padding: 0 0 0 14px; border-left: 2px solid var(--line-soft); }
.timeline li { position: relative; padding: 0 0 12px 12px; font-size: 13px; }
.timeline li::before {
  content: ""; position: absolute; left: -21px; top: 4px; width: 10px; height: 10px; border-radius: 50%; background: var(--surface);
  border: 2px solid var(--pc, var(--line));
}
.timeline .t-meta { font-size: 11.5px; color: var(--ink-faint); font-family: var(--mono); }
.timeline .t-note { color: var(--ink-soft); margin-top: 2px; white-space: pre-wrap; word-break: break-word; }
.notes { list-style: none; margin: 0 0 10px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.notes li { background: #FFFBEF; border: 1px solid #F1E3B8; border-radius: var(--r); padding: 8px 10px; font-size: 13px; }
.notes .n-meta { font-size: 11.5px; color: var(--ink-faint); font-family: var(--mono); margin-bottom: 2px; }
.notes .n-text { white-space: pre-wrap; word-break: break-word; }

/* ---------- Menu (dropdown) ---------- */
.menu-wrap { position: relative; display: inline-block; }
.menu {
  position: absolute; right: 0; top: calc(100% + 4px); z-index: 70; min-width: 230px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow-lg); padding: 4px; display: flex; flex-direction: column;
}
.menu.left { right: auto; left: 0; }
.menu a, .menu button {
  font: inherit; font-size: 13px; text-align: left; background: none; border: 0; padding: 8px 10px; border-radius: 4px;
  color: var(--ink); text-decoration: none; cursor: pointer; display: block;
}
.menu a:hover, .menu button:hover, .menu a:focus-visible, .menu button:focus-visible { background: var(--cyan-tint); box-shadow: none; }
.menu .menu-note { font-size: 11.5px; color: var(--ink-faint); padding: 6px 10px 4px; border-top: 1px solid var(--line-soft); margin-top: 4px; }
.menu .m-sub { display: block; font-size: 11.5px; color: var(--ink-faint); }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(5, 15, 22, .5); z-index: 100; display: flex; align-items: center; justify-content: center; padding: 16px;
}
.modal {
  background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-lg); width: 100%; max-width: 460px;
  max-height: calc(100vh - 32px); display: flex; flex-direction: column; animation: pop .14s ease-out;
}
.modal.lg { max-width: 640px; }
@keyframes pop { from { transform: scale(.97); opacity: .5; } to { transform: none; opacity: 1; } }
.modal-head { padding: 16px 18px 6px; }
.modal-head h2 { font-size: 17px; }
.modal-body { padding: 8px 18px 16px; overflow-y: auto; color: var(--ink-soft); }
.modal-body .form-grid { color: var(--ink); }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line-soft); background: var(--surface-2); border-radius: 0 0 var(--r-lg) var(--r-lg); flex-wrap: wrap; }

/* ---------- Toasts ---------- */
.toasts { position: fixed; right: 16px; top: calc(var(--topbar-h) + 10px); z-index: 200; display: flex; flex-direction: column; gap: 8px; max-width: min(380px, calc(100vw - 32px)); }
.toast {
  background: var(--night-2); color: #fff; border-radius: var(--r); padding: 10px 14px 10px 12px; box-shadow: var(--shadow-lg);
  font-size: 13.5px; display: flex; gap: 10px; align-items: flex-start; border-left: 4px solid var(--cyan); animation: pop .15s ease-out;
}
.toast.success { border-left-color: #3FBF7F; }
.toast.error { border-left-color: var(--red); }
.toast.warn { border-left-color: #E3A21A; }
.toast .t-msg { flex: 1; word-break: break-word; }
.toast button { background: none; border: 0; color: #9fb3bf; cursor: pointer; font-size: 16px; line-height: 1; padding: 0 2px; }

/* ---------- States ---------- */
.loading { display: flex; align-items: center; gap: 10px; color: var(--ink-faint); padding: 32px 8px; justify-content: center; }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--cyan-strong); animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty { text-align: center; color: var(--ink-faint); padding: 28px 16px; font-size: 13.5px; }
.empty b { display: block; color: var(--ink-soft); font-weight: 600; margin-bottom: 4px; }
.error-state { padding: 24px; text-align: center; }

/* ---------- Session cards ---------- */
.sess-list { display: flex; flex-direction: column; gap: 10px; }
.sess {
  background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--r-lg); box-shadow: var(--shadow);
  display: grid; grid-template-columns: 64px minmax(0, 1fr) 290px; gap: 14px; padding: 14px 16px; align-items: start;
}
.sess.is-cancelled { opacity: .72; }
.sess .date-badge { width: 56px; }
.sess .s-title { font-weight: 600; font-size: 14.5px; }
.sess .s-title .tag { margin-right: 6px; vertical-align: 1px; }
.sess .s-meta { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12.5px; color: var(--ink-soft); margin-top: 4px; }
.sess .s-meta span { display: inline-flex; gap: 4px; align-items: center; }
.sess .s-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.sess .s-side { display: flex; flex-direction: column; gap: 8px; }
.sess .s-code { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.sess .s-counts { font-size: 12px; color: var(--ink-soft); }
.sess .s-counts b { color: var(--ink); }

/* ---------- Survey builder ---------- */
.q-list { display: flex; flex-direction: column; gap: 10px; }
.q-card { border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); }
.q-card-head { display: flex; align-items: center; gap: 8px; padding: 8px 10px 8px 12px; background: var(--surface-2); border-bottom: 1px solid var(--line-soft); border-radius: var(--r-lg) var(--r-lg) 0 0; flex-wrap: wrap; }
.q-num { font-family: var(--mono); font-weight: 600; font-size: 12px; color: var(--ink-faint); }
.q-type { font-size: 12px; font-weight: 600; color: var(--cyan-ink); background: var(--cyan-tint); padding: 2px 8px; border-radius: 99px; }
.q-card-head .spacer { flex: 1; }
.q-tools { display: inline-flex; gap: 2px; margin-left: auto; }
.q-card-body { padding: 12px; }
.q-add { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 12px; border: 1px dashed var(--line); border-radius: var(--r-lg); background: var(--surface-2); }
.q-add .lbl { font-size: 12.5px; font-weight: 600; color: var(--ink-soft); margin-right: 4px; }
.share-box { display: flex; gap: 6px; align-items: center; }
.share-box .input { font-family: var(--mono); font-size: 12.5px; }
.builder-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
.builder-side { position: sticky; top: calc(var(--topbar-h) + 16px); display: flex; flex-direction: column; gap: 16px; }
.builder-side .card + .card { margin-top: 0; }

/* ---------- Survey results ---------- */
.res-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.res-card .big { font-family: var(--serif); font-size: 30px; font-weight: 600; line-height: 1.1; }
.res-card .big small { font-size: 14px; color: var(--ink-faint); font-family: var(--sans); font-weight: 400; margin-left: 4px; }
.res-card .res-q { font-weight: 600; font-size: 14px; }
.res-card .res-meta { font-size: 12px; color: var(--ink-faint); margin: 2px 0 10px; }
.hbars { display: flex; flex-direction: column; gap: 5px; margin-top: 10px; }
.hbar { display: grid; grid-template-columns: minmax(40px, 30%) minmax(0, 1fr) 72px; gap: 8px; align-items: center; font-size: 12.5px; }
.hbar .hb-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-soft); }
.hbar .hb-track { height: 14px; background: var(--surface-2); border-radius: 3px; overflow: hidden; border: 1px solid var(--line-soft); }
.hbar .hb-fill { height: 100%; background: var(--cyan-strong); border-radius: 2px 0 0 2px; min-width: 0; }
.hbar .hb-val { font-family: var(--mono); font-size: 11.5px; color: var(--ink-soft); text-align: right; white-space: nowrap; }
.hbar.nps-det .hb-fill { background: var(--danger); }
.hbar.nps-pas .hb-fill { background: #C7921A; }
.hbar.nps-pro .hb-fill { background: var(--ok); }
.hbars.compact .hbar { grid-template-columns: 28px minmax(0, 1fr) 72px; }
.nps-split { display: flex; gap: 12px; font-size: 12px; color: var(--ink-soft); margin-top: 4px; flex-wrap: wrap; }
.nps-split b { font-family: var(--mono); }
.answers { max-height: 260px; overflow-y: auto; list-style: none; margin: 8px 0 0; padding: 0; border: 1px solid var(--line-soft); border-radius: var(--r); }
.answers li { padding: 8px 10px; border-top: 1px solid var(--line-soft); font-size: 13px; white-space: pre-wrap; word-break: break-word; }
.answers li:first-child { border-top: 0; }
.stat-row { display: flex; gap: 24px; flex-wrap: wrap; }
.stat-row .stat .v { font-family: var(--serif); font-size: 24px; font-weight: 600; }
.stat-row .stat .l { font-size: 12px; color: var(--ink-faint); }
.stat-row .stat .v.sm { font-size: 16px; padding-top: 7px; padding-bottom: 3px; }

.filter-toggle { display: none; }
.card-head .ch-title { display: flex; align-items: baseline; gap: 10px; }

/* ---------- Mobile / responsive ---------- */
@media (max-width: 1200px) {
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .builder-grid { grid-template-columns: minmax(0, 1fr); }
  .builder-side { position: static; }
}
@media (max-width: 1000px) {
  .dash-grid { grid-template-columns: minmax(0, 1fr); }
  .sess { grid-template-columns: 56px minmax(0, 1fr); }
  .sess .s-side { grid-column: 1 / -1; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 10px 16px; }
  .sess .s-side .cap { flex: 1 1 200px; }
  .res-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; width: min(280px, 86vw); transform: translateX(-100%);
    transition: transform .2s ease; box-shadow: var(--shadow-lg);
  }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(5, 15, 22, .45); z-index: 35; }
  .topbar { padding: 0 12px; gap: 8px; }
  .topbar .menu-btn { display: inline-flex; }
  .content { padding: 16px 16px 40px; }
  .span-6, .span-4, .span-3, .span-8 { grid-column: span 12 !important; }
  .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
  h1 { font-size: 19px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .kpi { padding: 10px 12px; }
  .kpi .k-value { font-size: 23px; }
  .user-chip .who { display: none; }
  .topbar .hide-sm { display: none; }
  .drawer-head { padding: 12px 14px 10px; }
  .drawer-body { padding: 12px 14px 20px; }
  dl.kv { grid-template-columns: minmax(0, 1fr); gap: 0 0; }
  dl.kv dt { margin-top: 8px; }
  .toolbar > .field, .toolbar > .grow { flex: 1 1 100%; }
  .toolbar > .field.half { flex: 1 1 calc(50% - 4px); }
  .page-head { align-items: flex-start; }
  .hbar { grid-template-columns: minmax(40px, 34%) minmax(0, 1fr) 64px; }
  .modal-foot .btn { flex: 1; }
  .hide-xs { display: none; }
  .filter-toggle { display: inline-flex; }
  .toolbar.collapsible:not(.open) > .adv { display: none; }
  .kpis > .kpi:last-child:nth-child(odd) { grid-column: span 2; }
  .list-item.up-item { flex-wrap: wrap; }
  .list-item.up-item .li-side { width: auto !important; flex: 1 1 100%; margin-left: 58px; display: flex; align-items: center; gap: 10px; text-align: left; }
  .list-item.up-item .li-side .cap { flex: 1; min-width: 0; }
  .list-item.up-item .li-side > div { margin-top: 0 !important; }
  .list-item .li-title { white-space: normal; }
  .sticky-actions { position: static; }
  .toasts { left: 16px; right: 16px; max-width: none; }
  .q-card-head { padding: 8px; }
  .stat-row { gap: 12px 24px; }
  .stat-row .stat .v.sm { font-size: 14px; }
  .form-actions .left { margin-right: 0; width: 100%; }
  .form-actions .btn { flex: 1; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
