/* ==========================================================================
   Digital School Control — design system « Encre & Ambre »
   ========================================================================== */
:root {
  --ink: #0E1726;
  --ink-2: #16223A;
  --ink-3: #22304D;
  --paper: #F4F1EA;
  --paper-2: #FAF8F3;
  --surface: #FFFFFF;
  --line: #E7E1D4;
  --line-2: #EFEADF;
  --text: #14213D;
  --text-2: #3A4560;
  --muted: #6B7287;
  --amber: #F2A33A;
  --amber-soft: #FDF0DB;
  --cobalt: #2742F5;
  --cobalt-dark: #1B31C9;
  --cobalt-soft: #E8EBFE;
  --green: #0E9F6E; --green-soft: #E3F5EE;
  --amberx: #B76E00; --amberx-soft: #FCF1DC;
  --orange: #D4570B; --orange-soft: #FDEADF;
  --red: #D02F2F; --red-soft: #FCE7E7;
  --blue: #2563EB; --blue-soft: #E5EDFD;
  --gray: #6B7287; --gray-soft: #EEEDE8;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(14,23,38,.04), 0 6px 24px -12px rgba(14,23,38,.14);
  --shadow-lg: 0 24px 60px -20px rgba(14,23,38,.35);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --display: "Bricolage Grotesque", "Inter", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sidebar: 264px;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 14.5px/1.55 var(--font); color: var(--text); background: var(--paper); font-feature-settings: "cv11", "ss01"; }
a { color: var(--cobalt); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
h1, h2, h3, h4 { font-family: var(--display); letter-spacing: -.015em; margin: 0; color: var(--text); }
h1 { font-size: 26px; font-weight: 700; }
h2 { font-size: 17px; font-weight: 650; }
h3 { font-size: 15px; font-weight: 650; }
p { margin: 0 0 .6em; }
hr { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }
code, .mono { font-family: var(--mono); font-size: .92em; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
h1.mono { font-size: 24px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
[hidden] { display: none !important; }
svg { width: 1.15em; height: 1.15em; vertical-align: -0.2em; flex: none; }
[data-qr] svg { width: 100%; height: 100%; }
.chip svg { width: 14px; height: 14px; color: var(--green); }

/* ---------- Layout ---------- */
.app { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto; background: var(--ink); color: #C7CEDD;
  display: flex; flex-direction: column; padding: 20px 14px;
  background-image: radial-gradient(circle at 1px 1px, rgba(255,255,255,.045) 1px, transparent 0); background-size: 18px 18px;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 4px 10px 20px; color: #fff; text-decoration: none !important; }
.brand-mark { width: 36px; height: 36px; border-radius: 10px; background: var(--amber); display: grid; place-items: center; color: var(--ink); font: 800 15px var(--display); position: relative; flex: none; }
.brand-mark::after { content: ""; position: absolute; right: -3px; bottom: -3px; width: 12px; height: 12px; border-radius: 4px; background: var(--cobalt); border: 2px solid var(--ink); }
.brand-name { font: 700 16px/1.1 var(--display); letter-spacing: -.01em; }
.brand-name small { display: block; font: 500 11px var(--font); color: #8C97AE; letter-spacing: .08em; text-transform: uppercase; margin-top: 3px; }
.nav-group { margin: 14px 0 4px; padding: 0 12px; font-size: 10.5px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: #6E7A93; }
.nav a { display: flex; align-items: center; gap: 11px; padding: 8.5px 12px; margin: 1px 0; border-radius: 10px; color: #C7CEDD; font-weight: 500; text-decoration: none; position: relative; transition: background .15s, color .15s; }
.nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav a.active { background: rgba(255,255,255,.09); color: #fff; }
.nav a.active::before { content: ""; position: absolute; left: -14px; top: 9px; bottom: 9px; width: 4px; border-radius: 0 4px 4px 0; background: var(--amber); }
.nav a svg { width: 18px; height: 18px; flex: none; opacity: .85; }
.nav .count { margin-left: auto; background: var(--amber); color: var(--ink); font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 99px; }
.sidebar-foot { margin-top: auto; padding: 14px 10px 0; border-top: 1px solid rgba(255,255,255,.07); font-size: 12px; color: #7D88A0; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 14px; padding: 12px 28px; background: rgba(244,241,234,.86); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.topbar .search { flex: 1; max-width: 420px; position: relative; }
.topbar .search input { width: 100%; padding-left: 36px; background: var(--surface); }
.topbar .search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 16px; color: var(--muted); }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.icon-btn { position: relative; width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); display: grid; place-items: center; color: var(--text-2); cursor: pointer; }
.icon-btn:hover { border-color: #D6CDBA; }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn .dot { position: absolute; top: -4px; right: -4px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 99px; background: var(--red); color: #fff; font-size: 10.5px; font-weight: 700; display: grid; place-items: center; border: 2px solid var(--paper); }
.avatar { width: 38px; height: 38px; border-radius: 10px; background: var(--ink); color: #fff; display: grid; place-items: center; font: 700 13px var(--display); flex: none; }
.avatar.sm { width: 30px; height: 30px; border-radius: 8px; font-size: 11px; }
.avatar.lg { width: 64px; height: 64px; border-radius: 16px; font-size: 22px; }
.avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; }
.menu-toggle { display: none; }
.content { padding: 26px 28px 60px; max-width: 1440px; width: 100%; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head .eyebrow { font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
.page-head .sub { color: var(--muted); margin-top: 4px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- Cards & grid ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line-2); }
.card-head .hint { font-size: 12.5px; color: var(--muted); }
.card-body { padding: 18px 20px; }
.card-body.flush { padding: 0; }
.grid { display: grid; gap: 18px; }
.g-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-main { grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr); }
.stack > * + * { margin-top: 18px; }

/* KPI tiles */
.kpi { position: relative; padding: 16px 18px 15px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; text-decoration: none !important; color: inherit; display: block; transition: transform .15s, box-shadow .15s; }
a.kpi:hover { transform: translateY(-2px); box-shadow: 0 10px 30px -14px rgba(14,23,38,.3); }
.kpi::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 3px; background: var(--k, var(--cobalt)); }
.kpi .label { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); font-weight: 550; }
.kpi .label svg { width: 15px; height: 15px; color: var(--k, var(--cobalt)); }
.kpi .value { font: 700 27px/1.15 var(--display); letter-spacing: -.02em; margin-top: 8px; font-variant-numeric: tabular-nums; }
.kpi .meta { font-size: 12px; color: var(--muted); margin-top: 3px; }
.kpi.hero { background: var(--ink); color: #fff; border-color: var(--ink); background-image: radial-gradient(circle at 1px 1px, rgba(255,255,255,.06) 1px, transparent 0); background-size: 16px 16px; }
.kpi.hero .label, .kpi.hero .meta { color: #A7B1C6; }
.kpi.hero::before { background: var(--amber); }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px 3px 8px; border-radius: 99px; font-size: 12px; font-weight: 600; line-height: 1.4; white-space: nowrap; background: var(--gray-soft); color: var(--gray); }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.plain::before { display: none; }
.badge.green { background: var(--green-soft); color: var(--green); }
.badge.amber { background: var(--amberx-soft); color: var(--amberx); }
.badge.orange { background: var(--orange-soft); color: var(--orange); }
.badge.red { background: var(--red-soft); color: var(--red); }
.badge.blue { background: var(--blue-soft); color: var(--blue); }
.badge.gray { background: var(--gray-soft); color: var(--gray); }
.badge.ink { background: var(--ink); color: #fff; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border: 1px solid var(--line); border-radius: 7px; font-size: 12px; background: var(--paper-2); color: var(--text-2); }
.plan-dot { width: 9px; height: 9px; border-radius: 3px; display: inline-block; background: var(--c, var(--cobalt)); flex: none; }

/* License ticket */
.ticket { display: inline-flex; align-items: center; gap: 10px; padding: 7px 12px 7px 14px; background: var(--amber-soft); border: 1px dashed #E5B66D; border-radius: 10px; font: 600 13px var(--mono); color: #6A4300; letter-spacing: .04em; position: relative; }
.ticket::before, .ticket::after { content: ""; position: absolute; top: 50%; width: 10px; height: 10px; border-radius: 50%; background: var(--surface); transform: translateY(-50%); border: 1px dashed #E5B66D; }
.ticket::before { left: -6px; clip-path: inset(0 0 0 50%); }
.ticket::after { right: -6px; clip-path: inset(0 50% 0 0); }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 38px; padding: 0 15px; border-radius: 10px; border: 1px solid transparent; font: 600 13.5px var(--font); cursor: pointer; text-decoration: none !important; white-space: nowrap; transition: background .15s, border-color .15s, transform .05s; }
.btn:active { transform: translateY(1px); }
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--cobalt); color: #fff; box-shadow: 0 1px 0 rgba(255,255,255,.15) inset, 0 4px 14px -6px rgba(39,66,245,.6); }
.btn-primary:hover { background: var(--cobalt-dark); }
.btn-ink { background: var(--ink); color: #fff; }
.btn-ink:hover { background: var(--ink-3); }
.btn-amber { background: var(--amber); color: var(--ink); }
.btn-amber:hover { background: #E8952A; }
.btn-ghost { background: var(--surface); color: var(--text); border-color: var(--line); }
.btn-ghost:hover { border-color: #D3C9B5; background: var(--paper-2); }
.btn-danger { background: var(--red-soft); color: var(--red); border-color: #F5C9C9; }
.btn-danger:hover { background: #F9D9D9; }
.btn-success { background: var(--green-soft); color: var(--green); border-color: #BFE6D6; }
.btn-sm { height: 31px; padding: 0 11px; font-size: 12.5px; border-radius: 8px; }
.btn-link { background: none; border: 0; color: var(--cobalt); padding: 0; height: auto; font-weight: 600; }
.btn[disabled] { opacity: .5; pointer-events: none; }

/* ---------- Forms ---------- */
label, .label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=datetime-local], input[type=url], input[type=search], input[type=tel], select, textarea {
  width: 100%; height: 40px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--paper-2); font: 14px var(--font); color: var(--text); transition: border-color .15s, box-shadow .15s, background .15s;
}
textarea { height: auto; min-height: 96px; padding: 10px 12px; resize: vertical; line-height: 1.5; }
select { appearance: none; padding-right: 34px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='none' stroke='%236B7287' stroke-width='2' viewBox='0 0 24 24'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--cobalt); background: #fff; box-shadow: 0 0 0 4px rgba(39,66,245,.12); }
input[type=color] { width: 54px; height: 40px; padding: 3px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
input[type=file] { font-size: 13px; }
.field { margin-bottom: 16px; }
.field .help { font-size: 12px; color: var(--muted); margin-top: 5px; }
.field .error, .error-text { font-size: 12.5px; color: var(--red); margin-top: 5px; font-weight: 500; }
.field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--red); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 16px; }
.check { display: flex; align-items: flex-start; gap: 10px; font-size: 13.5px; font-weight: 500; color: var(--text); cursor: pointer; margin-bottom: 10px; }
.check input { width: 17px; height: 17px; margin: 2px 0 0; accent-color: var(--cobalt); flex: none; }
.check small { display: block; color: var(--muted); font-weight: 400; }
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 500; }
.switch input { appearance: none; width: 38px; height: 22px; border-radius: 99px; background: #D9D2C2; position: relative; cursor: pointer; transition: background .2s; flex: none; margin: 0; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked { background: var(--green); }
.switch input:checked::after { transform: translateX(16px); }
.segmented { display: inline-flex; padding: 3px; border-radius: 11px; background: var(--paper); border: 1px solid var(--line); gap: 2px; flex-wrap: wrap; }
.segmented label { margin: 0; }
.segmented input { display: none; }
.segmented span, .segmented a { display: inline-block; padding: 6px 12px; border-radius: 8px; font-size: 13px; font-weight: 600; color: var(--muted); cursor: pointer; text-decoration: none !important; }
.segmented input:checked + span, .segmented a.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(14,23,38,.12); }
.input-group { display: flex; }
.input-group input { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.input-group .btn { border-top-left-radius: 0; border-bottom-left-radius: 0; height: 40px; }

/* Filters bar */
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; padding: 14px 16px; border-bottom: 1px solid var(--line-2); background: var(--paper-2); border-radius: var(--radius) var(--radius) 0 0; }
.filters .f { min-width: 150px; }
.filters .f.grow { flex: 1; min-width: 200px; }
.filters label { font-size: 11.5px; margin-bottom: 4px; color: var(--muted); }
.filters input, .filters select { height: 36px; background: #fff; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th { text-align: left; font-size: 11.5px; font-weight: 650; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); padding: 11px 16px; border-bottom: 1px solid var(--line); background: var(--paper-2); white-space: nowrap; }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.table tbody tr { transition: background .12s; }
.table tbody tr:hover { background: #FBFAF6; }
.table tbody tr:last-child td { border-bottom: 0; }
.table .who { display: flex; align-items: center; gap: 11px; min-width: 200px; }
.table .who b { display: block; font-weight: 600; color: var(--text); }
.table .who small { color: var(--muted); font-size: 12px; }
.table a.row-link { color: inherit; }
.table .t-actions { display: flex; gap: 6px; justify-content: flex-end; }

/* ---------- Definition lists ---------- */
.dl { display: grid; grid-template-columns: minmax(130px, 38%) 1fr; gap: 9px 14px; margin: 0; font-size: 13.5px; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; font-weight: 500; min-width: 0; overflow-wrap: anywhere; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 20px; overflow-x: auto; }
.tabs a { padding: 10px 14px; font-weight: 600; font-size: 13.5px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; text-decoration: none !important; }
.tabs a:hover { color: var(--text); }
.tabs a.active { color: var(--text); border-bottom-color: var(--amber); }
.tabs a .n { font-size: 11px; background: var(--paper); border-radius: 99px; padding: 1px 6px; margin-left: 5px; color: var(--muted); }

/* ---------- Period timeline ---------- */
.period { margin-top: 6px; }
.period-bar { position: relative; height: 10px; border-radius: 99px; background: var(--paper); overflow: hidden; border: 1px solid var(--line); }
.period-bar span { position: absolute; inset: 0 auto 0 0; border-radius: 99px; background: linear-gradient(90deg, var(--cobalt), #5B6EFF); }
.period-bar.warn span { background: linear-gradient(90deg, #E9A23B, var(--amber)); }
.period-bar.bad span { background: repeating-linear-gradient(-45deg, var(--red), var(--red) 6px, #E25555 6px, #E25555 12px); }
.period-legend { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-top: 6px; }
.countdown { font: 700 44px/1 var(--display); letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.countdown small { font: 600 14px var(--font); color: var(--muted); letter-spacing: 0; margin-left: 6px; }

/* ---------- Timeline (events) ---------- */
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline li { position: relative; padding: 0 0 16px 28px; }
.timeline li::before { content: ""; position: absolute; left: 7px; top: 18px; bottom: -2px; width: 2px; background: var(--line-2); }
.timeline li:last-child::before { display: none; }
.timeline .tl-dot { position: absolute; left: 0; top: 4px; width: 16px; height: 16px; border-radius: 6px; background: var(--paper); border: 2px solid var(--t, var(--muted)); }
.timeline .tl-title { font-weight: 600; font-size: 13.5px; }
.timeline .tl-meta { font-size: 12px; color: var(--muted); }
.timeline .tl-body { font-size: 13px; color: var(--text-2); margin-top: 2px; }

/* ---------- Feed / list items ---------- */
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: flex; gap: 12px; padding: 12px 20px; border-bottom: 1px solid var(--line-2); align-items: flex-start; }
.feed li:last-child { border-bottom: 0; }
.feed .ic { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex: none; background: var(--paper); color: var(--text-2); }
.feed .ic svg { width: 17px; height: 17px; }
.feed .ic.danger { background: var(--red-soft); color: var(--red); }
.feed .ic.warning { background: var(--amberx-soft); color: var(--amberx); }
.feed .ic.success { background: var(--green-soft); color: var(--green); }
.feed .ic.info { background: var(--blue-soft); color: var(--blue); }
.feed .t { font-weight: 600; font-size: 13.5px; }
.feed .d { font-size: 12.5px; color: var(--muted); }
.feed .grow { flex: 1; min-width: 0; }
.feed li.unread { background: #FFFDF7; }
.feed li.unread .t::after { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--amber); margin-left: 7px; vertical-align: middle; }

/* ---------- Alerts ---------- */
.alert { display: flex; gap: 12px; align-items: flex-start; padding: 13px 16px; border-radius: 12px; border: 1px solid; margin-bottom: 18px; font-size: 13.5px; }
.alert svg { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.alert.success { background: var(--green-soft); border-color: #BFE6D6; color: #0A6C4B; }
.alert.warning { background: var(--amberx-soft); border-color: #F1D6A6; color: #7A4A00; }
.alert.danger { background: var(--red-soft); border-color: #F3C3C3; color: #9E1F1F; }
.alert.info { background: var(--blue-soft); border-color: #C6D6FB; color: #1C46B5; }
.alert ul { margin: 4px 0 0; padding-left: 18px; }
.secret-box { background: var(--ink); color: #E8ECF5; border-radius: 12px; padding: 16px 18px; margin-bottom: 18px; }
.secret-box h3 { color: #fff; display: flex; align-items: center; gap: 8px; }
.secret-box .row { display: flex; align-items: center; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
.secret-box code { background: rgba(255,255,255,.08); padding: 6px 10px; border-radius: 8px; color: var(--amber); font-size: 13px; word-break: break-all; }
.secret-box .muted { color: #9AA5BC; }

/* ---------- Empty state ---------- */
.empty { text-align: center; padding: 42px 20px; color: var(--muted); }
.empty .ill { width: 56px; height: 56px; border-radius: 16px; background: var(--paper); display: grid; place-items: center; margin: 0 auto 12px; color: var(--muted); }
.empty .ill svg { width: 26px; height: 26px; }
.empty h3 { color: var(--text); margin-bottom: 4px; }

/* ---------- Modal (dialog) ---------- */
dialog.modal { border: 0; padding: 0; border-radius: 18px; width: min(560px, calc(100vw - 24px)); box-shadow: var(--shadow-lg); color: var(--text); max-height: calc(100vh - 40px); }
dialog.modal.wide { width: min(780px, calc(100vw - 24px)); }
dialog.modal::backdrop { background: rgba(14,23,38,.5); backdrop-filter: blur(3px); }
dialog.modal[open] { animation: pop .18s ease-out; }
@keyframes pop { from { transform: translateY(8px) scale(.98); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--line-2); }
.modal-body { padding: 20px 22px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 22px; background: var(--paper-2); border-top: 1px solid var(--line-2); }
.modal-close { background: none; border: 0; cursor: pointer; color: var(--muted); padding: 4px; }
.modal-close svg { width: 20px; height: 20px; }

/* Notification dropdown */
.dropdown { position: relative; }
.dropdown-panel { position: absolute; right: 0; top: calc(100% + 8px); width: 380px; max-width: calc(100vw - 24px); background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-lg); z-index: 50; overflow: hidden; }
.dropdown-panel .feed li { padding: 11px 16px; }
.dropdown-panel .feed a { color: inherit; text-decoration: none; display: flex; gap: 12px; width: 100%; }
.user-menu .dropdown-panel { width: 240px; padding: 6px; }
.user-menu .dropdown-panel a, .user-menu .dropdown-panel button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border-radius: 8px; color: var(--text); background: none; border: 0; font: 500 13.5px var(--font); cursor: pointer; text-decoration: none; }
.user-menu .dropdown-panel a:hover, .user-menu .dropdown-panel button:hover { background: var(--paper); }
.user-menu .dropdown-panel svg { width: 16px; height: 16px; color: var(--muted); }

/* ---------- Pagination ---------- */
.pagination { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 16px; border-top: 1px solid var(--line-2); font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.pagination .pages { display: flex; gap: 4px; flex-wrap: wrap; }
.pagination a, .pagination span.p { min-width: 32px; height: 32px; padding: 0 9px; display: grid; place-items: center; border-radius: 8px; border: 1px solid var(--line); color: var(--text); background: var(--surface); text-decoration: none; font-weight: 600; }
.pagination span.p.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.pagination span.p.off { opacity: .45; }

/* ---------- Charts ---------- */
.chart-box { position: relative; height: 270px; }
.chart-box.sm { height: 200px; }
.legend { display: flex; flex-wrap: wrap; gap: 8px 16px; font-size: 12.5px; color: var(--text-2); margin-top: 12px; }
.legend span { display: inline-flex; align-items: center; gap: 7px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

/* ---------- Plans ---------- */
.plan-card { position: relative; padding: 20px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); overflow: hidden; }
.plan-card::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 4px; background: var(--c); }
.plan-card .price { font: 700 28px/1 var(--display); letter-spacing: -.02em; margin: 12px 0 2px; }
.plan-card ul { list-style: none; padding: 0; margin: 14px 0 0; font-size: 13px; }
.plan-card li { display: flex; gap: 8px; padding: 4px 0; color: var(--text-2); }
.plan-card li svg { width: 15px; height: 15px; color: var(--green); flex: none; margin-top: 2px; }
.plan-option { display: block; cursor: pointer; margin: 0; }
.plan-option input { display: none; }
.plan-option .plan-card { transition: border-color .15s, box-shadow .15s; height: 100%; }
.plan-option input:checked + .plan-card { border-color: var(--cobalt); box-shadow: 0 0 0 3px rgba(39,66,245,.15); }
.matrix th, .matrix td { text-align: center; }
.matrix td:first-child, .matrix th:first-child { text-align: left; }
.matrix input { width: 17px; height: 17px; accent-color: var(--cobalt); }

/* ---------- Chat (tickets) ---------- */
.thread { display: flex; flex-direction: column; gap: 14px; }
.msg { max-width: 80%; padding: 12px 15px; border-radius: 14px; background: var(--paper); font-size: 13.5px; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.me { align-self: flex-end; background: var(--cobalt-soft); }
.msg.note { align-self: flex-end; background: var(--amber-soft); border: 1px dashed #E5B66D; }
.msg .by { font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 4px; white-space: normal; }

/* ---------- Auth ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.05fr 1fr; }
.auth-art { background: var(--ink); color: #fff; padding: 48px; display: flex; flex-direction: column; position: relative; overflow: hidden; }
.auth-art::before { content: ""; position: absolute; inset: 0; background-image: radial-gradient(circle at 1px 1px, rgba(255,255,255,.07) 1px, transparent 0); background-size: 22px 22px; }
.auth-art > * { position: relative; }
.auth-art h1 { color: #fff; font-size: 40px; line-height: 1.08; max-width: 480px; margin-top: auto; }
.auth-art h1 em { font-style: normal; color: var(--amber); }
.auth-art p { color: #A7B1C6; max-width: 440px; margin-top: 14px; font-size: 15px; }
.auth-stats { display: flex; gap: 12px; margin-top: 34px; flex-wrap: wrap; }
.auth-stats div { padding: 12px 14px; border: 1px solid rgba(255,255,255,.1); border-radius: 12px; background: rgba(255,255,255,.03); font-size: 12.5px; color: #A7B1C6; }
.auth-stats b { display: block; color: #fff; font: 700 15px var(--display); }
.auth-form { display: grid; place-items: center; padding: 40px 24px; }
.auth-form .box { width: 100%; max-width: 380px; }
.auth-form h2 { font-size: 24px; margin-bottom: 6px; }
.otp-input { font: 700 24px var(--mono) !important; letter-spacing: .4em; text-align: center; height: 56px !important; }

/* ---------- Portal ---------- */
.portal-top { background: var(--ink); color: #fff; }
.portal-top .inner { max-width: 1180px; margin: 0 auto; padding: 14px 24px; display: flex; align-items: center; gap: 18px; }
.portal-nav { display: flex; gap: 2px; margin-left: 20px; overflow-x: auto; }
.portal-nav a { color: #B5BFD2; padding: 8px 12px; border-radius: 9px; font-weight: 500; white-space: nowrap; text-decoration: none; }
.portal-nav a.active, .portal-nav a:hover { color: #fff; background: rgba(255,255,255,.08); }
.portal-main { max-width: 1180px; margin: 0 auto; padding: 28px 24px 60px; }
.portal-hero { border-radius: 18px; padding: 26px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); display: grid; grid-template-columns: 1.3fr 1fr; gap: 26px; }

/* ---------- Code block ---------- */
pre.code { background: var(--ink); color: #D7DEEC; border-radius: 12px; padding: 14px 16px; font: 12.5px/1.6 var(--mono); overflow: auto; max-height: 360px; margin: 0; }

/* ---------- Responsive ---------- */
@media (max-width: 1200px) {
  .g-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g-main { grid-template-columns: 1fr; }
}
@media (max-width: 960px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 60; left: 0; top: 0; width: var(--sidebar); transform: translateX(-100%); transition: transform .25s; box-shadow: var(--shadow-lg); }
  body.nav-open .sidebar { transform: none; }
  body.nav-open::after { content: ""; position: fixed; inset: 0; background: rgba(14,23,38,.45); z-index: 55; }
  .menu-toggle { display: grid; }
  .topbar { padding: 10px 16px; }
  .content { padding: 20px 16px 50px; }
  .g-3, .g-2 { grid-template-columns: 1fr; }
  .auth { grid-template-columns: 1fr; }
  .auth-art { display: none; }
  .portal-hero { grid-template-columns: 1fr; }
  .portal-nav { margin-left: 0; }
  .portal-top .inner { flex-wrap: wrap; }
}
@media (max-width: 640px) {
  .g-4 { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi .value { font-size: 21px; }
  .form-grid, .form-grid-3 { grid-template-columns: 1fr; }
  .topbar .search { display: none; }
  h1 { font-size: 22px; }
  .dl { grid-template-columns: 1fr; gap: 2px 0; }
  .dl dd { margin-bottom: 8px; }
  .table th, .table td { padding: 10px 12px; }
  .msg { max-width: 95%; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
.g-7 { grid-template-columns: repeat(7, minmax(0, 1fr)); }
@media (max-width: 1300px) { .g-7 { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (max-width: 640px) { .g-7 { grid-template-columns: 1fr 1fr; gap: 10px; } }
