/* ==========================================================================
   Daftar components. Every radius, border, shadow and height reads a token.
   ========================================================================== */

/* ---------- Buttons ---------- */
.btn {
  --b-bg: var(--bg); --b-fg: var(--ink); --b-ring: var(--line-strong);
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  min-height: var(--h-ctl); padding: 0 var(--s-4); border-radius: var(--r-ctl);
  background: var(--b-bg); color: var(--b-fg); box-shadow: inset 0 0 0 var(--bw) var(--b-ring);
  font: var(--wt-strong) var(--t-15)/1 var(--font-body); white-space: nowrap; text-decoration: none; cursor: pointer;
  transition: background var(--dur-1) var(--ease), box-shadow var(--dur-1) var(--ease), color var(--dur-1) var(--ease);
}
.btn:hover, .btn.is-hover { --b-bg: var(--surface); --b-ring: var(--muted-2); color: var(--b-fg); }
.btn.is-focus { outline: 2px solid var(--primary); outline-offset: 2px; }
.btn:active { --b-bg: var(--surface-2); }
.btn-primary { --b-bg: var(--primary); --b-fg: var(--on-primary); --b-ring: transparent; }
.btn-primary:hover, .btn-primary.is-hover { --b-bg: var(--primary-strong); --b-ring: transparent; }
.btn-primary:active { --b-bg: oklch(0.36 0.08 214); }
.btn-ink { --b-bg: var(--ink); --b-fg: var(--on-primary); --b-ring: transparent; }
.btn-ink:hover, .btn-ink.is-hover { --b-bg: var(--ink-2); --b-ring: transparent; }
.btn-ghost { --b-ring: transparent; --b-bg: transparent; }
.btn-ghost:hover, .btn-ghost.is-hover { --b-bg: var(--surface-2); --b-ring: transparent; }
.btn-danger { --b-fg: var(--danger-ink); --b-ring: oklch(0.85 0.06 25); }
.btn-danger:hover, .btn-danger.is-hover { --b-bg: var(--danger-soft); --b-ring: var(--danger); }
.btn-danger.solid { --b-bg: var(--danger); --b-fg: var(--on-primary); --b-ring: transparent; }
.btn-on-drench { --b-bg: oklch(1 0 0 / .08); --b-fg: var(--on-drench); --b-ring: var(--drench-line); }
.btn-on-drench:hover { --b-bg: oklch(1 0 0 / .14); --b-ring: oklch(1 0 0 / .4); color: var(--on-drench); }
.btn-sm { min-height: var(--h-ctl-sm); padding: 0 var(--s-3); font-size: var(--t-14); }
.btn-lg { min-height: var(--h-ctl-lg); padding: 0 var(--s-5); font-size: var(--t-16); }
.btn-icon { width: var(--h-ctl); padding: 0; }
.btn-icon.btn-sm { width: var(--h-ctl-sm); }
.btn-block { width: 100%; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .42; cursor: not-allowed; pointer-events: none; }
/* Loading: three pulli dots land in turn. No spinner anywhere. */
.btn.is-loading { color: transparent !important; pointer-events: none; }
.btn.is-loading::after {
  content: ''; position: absolute; left: 50%; top: 50%; width: 30px; height: 6px; translate: -50% -50%;
  background: radial-gradient(circle, var(--b-fg) 2.6px, transparent 3px) 0 0 / 12px 6px repeat-x;
  -webkit-mask: linear-gradient(90deg, #000 0 0) 0 0 / 0% 100% no-repeat; mask: linear-gradient(90deg, #000 0 0) 0 0 / 0% 100% no-repeat;
  animation: pulli 1.1s steps(4) infinite;
}
@keyframes pulli { to { -webkit-mask-size: 133% 100%; mask-size: 133% 100%; } }

/* ---------- Fields ---------- */
.field { display: grid; gap: 6px; align-content: start; }
.label { font-size: var(--t-14); font-weight: var(--wt-strong); color: var(--ink); }
.label .hint { font-weight: var(--wt-body); color: var(--muted); }
.help { font-size: var(--t-13); color: var(--muted); line-height: 1.45; }
.input, .select, .textarea {
  width: 100%; min-height: var(--h-ctl); padding: 0 var(--s-3); border-radius: var(--r-ctl);
  background: var(--bg); color: var(--ink); border: 0; box-shadow: inset 0 0 0 var(--bw) var(--line-strong);
  font-size: var(--t-15); transition: box-shadow var(--dur-1) var(--ease);
}
.textarea { min-height: 96px; padding: var(--s-3); line-height: 1.5; resize: vertical; }
.input:hover, .select:hover, .textarea:hover { box-shadow: inset 0 0 0 var(--bw) var(--muted-2); }
.input:focus, .select:focus, .textarea:focus, .input.is-focus { outline: none; box-shadow: inset 0 0 0 var(--bw-strong) var(--primary), 0 0 0 4px var(--primary-soft); }
.input:disabled, .select:disabled { background: var(--surface-2); color: var(--muted); cursor: not-allowed; }
.select { appearance: none; padding-right: 36px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' fill='none' stroke='%23365560' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9.5 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 8px center; background-size: 20px; }
.field.has-error .input, .field.has-error .select, .field.has-error .textarea { box-shadow: inset 0 0 0 var(--bw-strong) var(--danger); }
.field .err { display: flex; gap: 6px; align-items: flex-start; font-size: var(--t-13); color: var(--danger-ink); line-height: 1.4; }
.field .err .ico { flex: none; margin-top: 1px; }
.field.is-ok .input { box-shadow: inset 0 0 0 var(--bw-strong) var(--success); }
.input-wrap { position: relative; }
.input-wrap > .ico { position: absolute; left: 12px; top: 50%; translate: 0 -50%; color: var(--muted); pointer-events: none; }
.input-wrap > .input { padding-left: 40px; }
.input-wrap .kbd { position: absolute; right: 8px; top: 50%; translate: 0 -50%; font-size: 11px; padding: 2px 6px; border-radius: 6px; box-shadow: inset 0 0 0 1px var(--line-strong); color: var(--muted); }
.file-drop { display: grid; justify-items: center; gap: var(--s-2); padding: var(--s-6) var(--s-5); border-radius: var(--r-card); text-align: center;
  background: var(--surface); border: var(--bw-strong) dashed var(--line-strong); color: var(--ink-2); cursor: pointer; transition: border-color var(--dur-1), background var(--dur-1); }
.file-drop:hover, .file-drop.is-over { border-color: var(--primary); background: var(--primary-soft); }
.file-drop .ico { color: var(--primary); }

/* ---------- Choice controls ---------- */
.check, .radio { display: inline-flex; align-items: center; gap: var(--s-3); min-height: 44px; cursor: pointer; font-size: var(--t-15); }
.check input, .radio input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.check .box, .radio .box { width: 22px; height: 22px; flex: none; display: grid; place-items: center; background: var(--bg);
  box-shadow: inset 0 0 0 var(--bw-strong) var(--line-strong); transition: background var(--dur-1), box-shadow var(--dur-1); color: transparent; }
.check .box { border-radius: 7px; }
.radio .box { border-radius: 50%; }
.check .box .ico { opacity: 0; scale: .6; transition: opacity var(--dur-1), scale var(--dur-2) var(--ease-out); }
.check input:checked + .box { background: var(--primary); box-shadow: none; color: var(--on-primary); }
.check input:checked + .box .ico { opacity: 1; scale: 1; }
.check input:indeterminate + .box { background: var(--primary); box-shadow: none; }
.check input:indeterminate + .box::after { content: ''; width: 10px; height: 2px; border-radius: 2px; background: var(--on-primary); }
.radio .box::after { content: ''; width: 10px; height: 10px; border-radius: 50%; background: var(--primary); scale: 0; transition: scale var(--dur-2) var(--ease-out); }
.radio input:checked + .box { box-shadow: inset 0 0 0 var(--bw-strong) var(--primary); }
.radio input:checked + .box::after { scale: 1; }
.check input:focus-visible + .box, .radio input:focus-visible + .box { outline: 2px solid var(--primary); outline-offset: 2px; }
.check input:disabled + .box, .radio input:disabled + .box { background: var(--surface-2); opacity: .6; }
.switch { display: inline-flex; align-items: center; gap: var(--s-3); min-height: 44px; cursor: pointer; font-size: var(--t-15); }
.switch .knob { position: relative; width: 44px; height: 26px; flex: none; border-radius: var(--r-full); background: var(--line-strong); transition: background var(--dur-2) var(--ease); }
.switch .knob::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--bg); box-shadow: var(--e-1); transition: translate var(--dur-2) var(--ease-out); }
.switch[aria-checked="true"] .knob, .switch input:checked + .knob { background: var(--primary); }
.switch[aria-checked="true"] .knob::after, .switch input:checked + .knob::after { translate: 18px 0; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch input:focus-visible + .knob { outline: 2px solid var(--primary); outline-offset: 2px; }
.seg { width: fit-content; display: inline-flex; padding: 3px; border-radius: var(--r-ctl); background: var(--surface-2); gap: 2px; }
.seg button { min-height: calc(var(--h-ctl) - 6px); padding: 0 var(--s-3); border-radius: calc(var(--r-ctl) - 3px); font-size: var(--t-14); font-weight: var(--wt-strong); color: var(--ink-2); transition: background var(--dur-1), color var(--dur-1); }
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed="true"] { background: var(--bg); color: var(--ink); box-shadow: var(--e-1), 0 0 0 1px var(--line); }

/* ---------- Pills, tags, avatars ---------- */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px 5px 8px; border-radius: var(--r-full);
  font: var(--wt-strong) var(--t-13)/1.1 var(--font-body); white-space: nowrap; background: var(--surface-2); color: var(--ink-2); }
.pill .ico { width: 15px; height: 15px; }
.pill .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill-ok { background: var(--success-soft); color: var(--success-ink); }
.pill-warn { background: var(--warning-soft); color: var(--warning-ink); }
.pill-bad { background: var(--danger-soft); color: var(--danger-ink); }
.pill-info { background: var(--info-soft); color: var(--info-ink); }
.pill-off { background: var(--offline-soft); color: var(--offline-ink); }
.pill-brand { background: var(--primary-soft); color: var(--primary-strong); }
.pill-sync { background: var(--accent-soft); color: var(--on-accent); }
.tag { display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px; border-radius: 7px; font-size: var(--t-12); font-weight: var(--wt-strong); box-shadow: inset 0 0 0 1px var(--line-strong); color: var(--ink-2); white-space: nowrap; }
.count { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: var(--r-full); background: var(--primary); color: var(--on-primary); font-size: 11px; font-weight: 600; }
.avatar { --av: 36px; width: var(--av); height: var(--av); flex: none; border-radius: 50%; display: grid; place-items: center;
  background: var(--primary-soft-2); color: var(--primary-strong); font: 600 calc(var(--av) * .38)/1 var(--font-display); font-stretch: 112%; overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.sm { --av: 28px; } .avatar.lg { --av: 52px; }

/* ---------- Cards, panels, key-values, rows ---------- */
.card { background: var(--bg); border-radius: var(--r-card); box-shadow: var(--elev-card); padding: var(--pad-card); }
.card.flat { box-shadow: 0 0 0 1px var(--line); }
.card.tint { background: var(--surface); box-shadow: none; }
.card.is-link { cursor: pointer; transition: box-shadow var(--dur-2) var(--ease); }
.card.is-link:hover { box-shadow: var(--elev-pop); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); margin-bottom: var(--s-4); }
.card-head h2, .card-head h3 { font-size: var(--t-18); font-stretch: var(--stretch-head); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: var(--s-2) var(--s-5); font-size: var(--t-14); }
.kv dt { color: var(--muted); }
.kv dd { color: var(--ink); font-weight: var(--wt-strong); }
.row-item { display: flex; align-items: center; gap: var(--s-3); min-height: var(--h-row); padding: var(--s-2) 0; border-bottom: var(--row-rule); }
.row-item:last-child { border-bottom: 0; }
.row-item .main { flex: 1; min-width: 0; }
.row-item .main b { display: block; font-size: var(--t-15); }
.row-item .main small { display: block; font-size: var(--t-13); color: var(--muted); }
.stat { display: grid; gap: 2px; }
.stat .v { font: 600 var(--t-28)/1.1 var(--font-display); font-stretch: 108%; letter-spacing: -.01em; }
.stat .k { font-size: var(--t-13); color: var(--muted); }
.stat .trend { font-size: var(--t-13); display: inline-flex; gap: 4px; align-items: center; }
.stat .trend.up { color: var(--success-ink); } .stat .trend.down { color: var(--danger-ink); }

/* ---------- Navigation bits ---------- */
.tabs { display: flex; gap: var(--s-1); border-bottom: var(--rule); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a, .tabs button { position: relative; display: inline-flex; align-items: center; gap: 6px; min-height: var(--h-ctl); padding: 0 var(--s-3); white-space: nowrap;
  font-size: var(--t-15); font-weight: var(--wt-strong); color: var(--muted); text-decoration: none; }
.tabs a:hover, .tabs button:hover { color: var(--ink); }
.tabs [aria-selected="true"], .tabs [aria-current="page"] { color: var(--ink); }
.tabs [aria-selected="true"]::after, .tabs [aria-current="page"]::after { content: ''; position: absolute; left: var(--s-3); right: var(--s-3); bottom: -1px; height: 2px; border-radius: 2px; background: var(--primary); }
.crumbs { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: var(--t-13); color: var(--muted); }
.crumbs a { color: var(--muted); text-decoration: none; } .crumbs a:hover { color: var(--ink); }
.crumbs .ico { width: 14px; height: 14px; }
.pager { display: flex; align-items: center; gap: var(--s-2); font-size: var(--t-14); color: var(--muted); }

/* ---------- Data table ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--r-card); box-shadow: var(--elev-card); background: var(--bg); }
.table { width: 100%; font-size: var(--t-14); }
.table th { position: sticky; top: 0; z-index: 1; text-align: left; font-weight: var(--wt-strong); font-size: var(--t-13); color: var(--muted); background: var(--surface); padding: 0 var(--s-4); height: 42px; border-bottom: var(--rule); white-space: nowrap; }
.table th button.sort { display: inline-flex; align-items: center; gap: 4px; color: inherit; font: inherit; }
.table th button.sort:hover, .table th[aria-sort] { color: var(--ink); }
.table th[aria-sort="descending"] .ico { rotate: 180deg; }
.table td { padding: 0 var(--s-4); height: var(--h-row); border-bottom: var(--row-rule); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background var(--dur-1); }
.table tbody tr:hover { background: var(--surface); }
.table tbody tr.is-selected { background: var(--primary-soft); }
.table tbody tr[data-href] { cursor: pointer; }
.table .num, .table td.r { text-align: right; }
.table td b { font-weight: var(--wt-strong); }
.table td small { display: block; color: var(--muted); font-size: var(--t-13); }
.table td a, .table td.nowrap, .table td b { white-space: nowrap; }
.table .cell-user { display: flex; align-items: center; gap: var(--s-3); }
.bulkbar { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-2) var(--s-2) var(--s-2) var(--s-4); border-radius: var(--r-ctl);
  background: var(--ink); color: var(--on-primary); font-size: var(--t-14); }
.bulkbar .btn { --b-bg: oklch(1 0 0 / .08); --b-fg: var(--on-primary); --b-ring: oklch(1 0 0 / .18); min-height: var(--h-ctl-sm); font-size: var(--t-14); }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); margin-bottom: var(--s-4); }
.toolbar .grow { flex: 1 1 240px; }

/* ---------- Feedback ---------- */
.banner { display: flex; gap: var(--s-3); align-items: flex-start; padding: var(--s-3) var(--s-4); border-radius: var(--r-ctl); font-size: var(--t-14); line-height: 1.5;
  background: var(--surface); box-shadow: inset 0 0 0 1px var(--line-strong); color: var(--ink-2); }
.banner .ico { flex: none; margin-top: 1px; }
.banner b { color: var(--ink); }
.banner .actions { margin-left: auto; display: flex; gap: var(--s-2); flex: none; }
.banner.ok { background: var(--success-soft); box-shadow: inset 0 0 0 1px oklch(0.85 0.06 155); } .banner.ok .ico { color: var(--success); }
.banner.warn { background: var(--warning-soft); box-shadow: inset 0 0 0 1px oklch(0.86 0.07 75); } .banner.warn .ico { color: var(--warning-ink); }
.banner.bad { background: var(--danger-soft); box-shadow: inset 0 0 0 1px oklch(0.86 0.06 25); } .banner.bad .ico { color: var(--danger); }
.banner.off { background: var(--offline-soft); box-shadow: inset 0 0 0 1px var(--line-strong); } .banner.off .ico { color: var(--offline); }
.banner.info { background: var(--primary-soft); box-shadow: inset 0 0 0 1px var(--primary-soft-2); } .banner.info .ico { color: var(--primary); }
.empty { display: grid; justify-items: center; gap: var(--s-2); padding: var(--s-7) var(--s-5); text-align: center; color: var(--ink-2); }
.empty .crest { width: 72px; color: var(--line-strong); margin-bottom: var(--s-2); }
.empty h3 { font-size: var(--t-18); color: var(--ink); }
.empty p { font-size: var(--t-14); color: var(--muted); max-width: 44ch; }
.empty .cluster { margin-top: var(--s-2); justify-content: center; }
/* Loading placeholders: a row of pulli dots settling into place, no shimmer. */
.skel { border-radius: 8px; background: var(--surface-2); position: relative; overflow: hidden; }
.skel::after { content: ''; position: absolute; inset: 0; background: radial-gradient(circle, var(--line-strong) 1.5px, transparent 2px) 0 50% / 14px 14px repeat-x; opacity: .9; animation: skel 1.4s var(--ease) infinite; }
@keyframes skel { from { translate: -14px 0; opacity: .3; } 50% { opacity: .9; } to { translate: 0 0; opacity: .3; } }
.skel.line { height: 12px; } .skel.block { height: 64px; border-radius: var(--r-ctl); }
.toaster { position: fixed; right: var(--s-4); bottom: calc(var(--pocbar-h) + var(--s-4)); z-index: var(--z-toast); display: flex; flex-direction: column-reverse; gap: var(--s-2); pointer-events: none; }
body:not(.has-pocbar) .toaster { bottom: var(--s-4); }
.toast { max-width: 44ch; display: flex; gap: var(--s-3); align-items: flex-start; padding: var(--s-3) var(--s-4); border-radius: var(--r-ctl);
  background: var(--drench); color: var(--on-drench); box-shadow: var(--e-3); font-size: var(--t-14); line-height: 1.45; animation: toast-in var(--dur-3) var(--ease-out); transition: opacity var(--dur-3); }
.toast.ok { background: var(--success-ink); } .toast.warn { background: var(--warning-soft); color: var(--warning-ink); box-shadow: var(--e-3), inset 0 0 0 1px oklch(0.86 0.07 75); } .toast.err { background: var(--danger-ink); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
.scrim { position: fixed; inset: 0; z-index: var(--z-layer); background: oklch(0.21 0.03 215 / .42); opacity: 0; pointer-events: none; transition: opacity var(--dur-2) var(--ease); }
.dialog { position: fixed; z-index: calc(var(--z-layer) + 1); left: 50%; top: 50%; width: min(520px, calc(100vw - 32px)); max-height: calc(100vh - 64px); overflow: auto;
  translate: -50% -46%; opacity: 0; pointer-events: none; background: var(--bg); border-radius: var(--r-lg); box-shadow: var(--elev-modal); padding: var(--s-6);
  transition: opacity var(--dur-2) var(--ease), translate var(--dur-3) var(--ease-out); }
.dialog h2 { font-size: var(--t-22); margin-bottom: var(--s-2); }
.dialog .foot { display: flex; justify-content: flex-end; gap: var(--s-2); margin-top: var(--s-5); }
.drawer { position: fixed; z-index: calc(var(--z-layer) + 1); top: 0; right: 0; bottom: 0; width: min(440px, 100vw); background: var(--bg); box-shadow: var(--elev-modal);
  translate: 100% 0; transition: translate var(--dur-3) var(--ease-out); display: flex; flex-direction: column; }
.drawer .d-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); padding: var(--s-4) var(--s-5); border-bottom: var(--rule); }
.drawer .d-body { flex: 1; overflow: auto; padding: var(--s-5); }
.drawer .d-foot { padding: var(--s-4) var(--s-5); border-top: var(--rule); display: flex; gap: var(--s-2); justify-content: flex-end; }
body.layer-open .scrim, body.dialog-open .scrim, body.drawer-open .scrim { opacity: 1; pointer-events: auto; }
body.dialog-open .dialog.is-open { opacity: 1; pointer-events: auto; translate: -50% -50%; }
body.drawer-open .drawer.is-open { translate: 0 0; }
.tip { position: relative; }
.tip[data-tip]::after { content: attr(data-tip); position: absolute; left: 50%; bottom: calc(100% + 8px); translate: -50% 4px; opacity: 0; pointer-events: none; z-index: 5;
  white-space: nowrap; padding: 6px 9px; border-radius: 7px; background: var(--ink); color: var(--on-primary); font: var(--wt-body) var(--t-12)/1.2 var(--font-body); transition: opacity var(--dur-1), translate var(--dur-2) var(--ease-out); }
.tip[data-tip]:hover::after, .tip[data-tip]:focus-visible::after { opacity: 1; translate: -50% 0; }
.menu { min-width: 220px; padding: 6px; border-radius: var(--r-ctl); background: var(--bg); box-shadow: var(--elev-pop); }
.menu button, .menu a { display: flex; align-items: center; gap: var(--s-3); width: 100%; min-height: 40px; padding: 0 10px; border-radius: 7px; font-size: var(--t-14); color: var(--ink); text-decoration: none; text-align: left; }
.menu button:hover, .menu a:hover { background: var(--surface-2); }
.menu .danger { color: var(--danger-ink); }
.menu hr { margin: 6px 0; }

/* ==========================================================================
   Domain components
   ========================================================================== */

/* Kolam: the crest, drawn by components.js. Colour comes from currentColor. */
.kolam { overflow: visible; }
.kolam .kl { fill: none; stroke: currentColor; stroke-width: var(--kw, 2.3); stroke-linecap: round; stroke-linejoin: round; }
.kolam .kd { fill: currentColor; }
.crest { --size: 48px; width: var(--size); height: var(--size); flex: none; display: grid; place-items: center; color: var(--school, var(--primary)); }
.crest .kolam { width: 70.7%; rotate: 45deg; }
.crest.framed { border-radius: 50%; background: var(--bg); box-shadow: inset 0 0 0 1px var(--line); }
.crest.on-drench { color: var(--on-drench); }
.crest.sm { --size: 32px; --kw: 3.4; } .crest.md { --size: 40px; --kw: 3; } .crest.lg { --size: 96px; } .crest.xl { --size: 240px; }
.crest.sealed { position: relative; }
.crest.sealed::after { content: ''; position: absolute; inset: 0; border-radius: 50%; box-shadow: inset 0 0 0 3px currentColor; }

/* Class dot grid: one dot per learner. Present fills, absent rings in dashed red. */
.dotgrid { position: relative; display: grid; place-items: center; }
.dotgrid svg { width: 100%; height: auto; overflow: visible; }
.dotgrid .kl { fill: none; stroke: var(--primary); stroke-width: 2.6; stroke-linecap: round; opacity: 0; }
.dotgrid.closed .kl, .dotgrid.drawing .kl { opacity: 1; }
.dotgrid.drawing .kl { transition: stroke-dashoffset var(--dur-draw) cubic-bezier(.45,0,.15,1); }
.dotgrid.offline .kl { stroke: var(--offline); stroke-dasharray: 1 6 !important; }
.dotgrid .bead { fill: none; stroke: var(--accent-strong); stroke-width: 5; stroke-linecap: round; opacity: 0; }
.dotgrid.syncing .bead { opacity: 1; animation: bead 1.7s linear; }
@keyframes bead { from { stroke-dashoffset: var(--L); } to { stroke-dashoffset: 0; } }
.dotgrid .dot { fill: var(--bg); stroke: var(--line-strong); stroke-width: 1.5; transition: fill var(--dur-2), stroke var(--dur-2); }
.dotgrid .dot.on { fill: var(--primary); stroke: var(--primary); }
.dotgrid .dot.abs { fill: var(--bg); stroke: var(--danger); stroke-dasharray: 2 2.5; }
.dotgrid text { font: 500 10.5px/1 var(--font-body); fill: var(--muted); text-anchor: middle; pointer-events: none; }
.dotgrid text.on { fill: var(--on-primary); }

/* Sync status: the one pill every tablet screen carries. */
.net { display: inline-flex; align-items: center; gap: 7px; min-height: 32px; padding: 0 12px 0 10px; border-radius: var(--r-full);
  font: var(--wt-strong) var(--t-13)/1 var(--font-body); background: var(--primary-soft); color: var(--primary-strong); white-space: nowrap; }
.net .ico { width: 16px; height: 16px; }
.net.offline { background: var(--offline-soft); color: var(--offline-ink); }
.net.syncing { background: var(--accent-soft); color: var(--on-accent); }
.net.syncing .ico { animation: breathe 1.2s var(--ease) infinite; }
.net.failed { background: var(--warning-soft); color: var(--warning-ink); }
.net.locked { background: var(--danger-soft); color: var(--danger-ink); }
@keyframes breathe { 50% { opacity: .35; } }
/* Waiting-for-signal line: a dotted line that joins up once synced. */
.waitline { height: 2px; background: radial-gradient(circle, var(--offline) 1px, transparent 1.4px) 0 50% / 7px 2px repeat-x; }
.waitline.done { background: var(--primary); }

/* Seven days as seven dots: check-ins (sized) and lease (filled). */
.beats { display: inline-flex; gap: 4px; align-items: center; height: 18px; }
.beats i { border-radius: 50%; background: var(--ink); }
.beats i.zero { width: 5px; height: 5px; background: none; box-shadow: inset 0 0 0 1.2px var(--danger); }
.lease { display: inline-flex; gap: 3px; align-items: center; }
.lease i { width: 7px; height: 7px; border-radius: 50%; box-shadow: inset 0 0 0 1.2px var(--line-strong); }
.lease i.on { background: var(--primary); box-shadow: none; }
.lease.low i.on { background: var(--warning); }
.lease.out i { box-shadow: inset 0 0 0 1.2px var(--danger); }

/* Command journey: three dots joined by a line that draws as the command travels. */
.journey { display: grid; gap: var(--s-2); }
.journey .jtrack { position: relative; height: 28px; margin: 0 10px; }
.journey svg { position: absolute; left: 0; right: 0; top: 12px; width: 100%; height: 4px; overflow: visible; }
.journey .track { fill: none; stroke: var(--line-strong); stroke-width: 2; stroke-dasharray: 2 5; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.journey .prog { fill: none; stroke: var(--primary); stroke-width: 2.5; stroke-linecap: round; transition: stroke-dashoffset 900ms var(--ease-out); }
.journey .jd { position: absolute; top: 14px; width: 18px; height: 18px; translate: -50% -50%; border-radius: 50%; background: var(--bg); box-shadow: inset 0 0 0 1.5px var(--line-strong); transition: background var(--dur-3), box-shadow var(--dur-3); }
.journey .jd.on { background: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }
.journey ol { display: grid; grid-template-columns: repeat(3, 1fr); font-size: var(--t-13); color: var(--muted); line-height: 1.35; }
.journey li:nth-child(2) { text-align: center; } .journey li:nth-child(3) { text-align: right; }
.journey li b { display: block; color: var(--ink); font-size: var(--t-14); }

/* Fee receipt: the counterfoil book, kept from the register idea. */
.receipt { position: relative; display: grid; grid-template-columns: 132px 1fr; background: var(--bg); border-radius: var(--r-ctl); box-shadow: var(--elev-card); font-size: var(--t-13); overflow: hidden; }
.receipt .foil { padding: var(--s-4); background: var(--surface); border-right: 2px dashed var(--line-strong); display: grid; gap: 6px; align-content: start; color: var(--ink-2); }
.receipt .foil b { font: 600 var(--t-15)/1.1 var(--font-display); color: var(--ink); }
.receipt .body { padding: var(--s-4) var(--s-5); display: grid; gap: var(--s-3); }
.receipt .rhead { display: flex; justify-content: space-between; gap: var(--s-3); align-items: flex-start; }
.receipt .rhead h4 { font-size: var(--t-16); }
.receipt .rno { font: 600 var(--t-15)/1 var(--font-display); font-stretch: 112%; color: var(--primary-strong); white-space: nowrap; }
.receipt table { width: 100%; }
.receipt td { padding: 4px 0; border-bottom: 1px dotted var(--line-strong); }
.receipt td:last-child { text-align: right; }
.receipt tr.total td { border-bottom: 0; padding-top: 8px; font: 600 var(--t-16)/1.2 var(--font-display); }
.receipt .words { font-style: italic; color: var(--ink-2); }
.receipt .stamp { position: absolute; right: 22px; bottom: 18px; rotate: -12deg; padding: 6px 12px; border-radius: 8px; border: 3px solid currentColor; color: var(--success); font: 700 18px/1 var(--font-display); font-stretch: 120%; letter-spacing: .08em; opacity: .85; }
.receipt .stamp.pending { color: var(--offline); }
.receipt .stamp.void { color: var(--danger); }
.receipt.landed .stamp { animation: stamp var(--dur-3) var(--ease-out); }
@keyframes stamp { from { scale: 1.6; opacity: 0; } 60% { opacity: .9; } }

/* Exam terminal: OMR-style answer bubbles, large enough for a ten-year-old. */
.opts { display: grid; gap: var(--s-3); }
.opt { display: flex; align-items: center; gap: var(--s-4); min-height: 64px; padding: var(--s-3) var(--s-4); border-radius: var(--r-card); text-align: left;
  background: var(--bg); box-shadow: inset 0 0 0 var(--bw-strong) var(--line); font-size: var(--t-18); transition: box-shadow var(--dur-1), background var(--dur-1); }
.opt:hover { box-shadow: inset 0 0 0 var(--bw-strong) var(--primary-soft-2); }
.opt .bub { width: 40px; height: 40px; flex: none; border-radius: 50%; display: grid; place-items: center; box-shadow: inset 0 0 0 2px var(--primary); color: var(--primary-strong); font: 600 var(--t-16)/1 var(--font-display); transition: background var(--dur-2), color var(--dur-2); }
.opt[aria-checked="true"] { background: var(--primary-soft); box-shadow: inset 0 0 0 2px var(--primary); }
.opt[aria-checked="true"] .bub { background: var(--primary); color: var(--on-primary); }
.opt.right { box-shadow: inset 0 0 0 2px var(--success); } .opt.right .bub { background: var(--success); color: var(--on-primary); box-shadow: none; }
.opt.wrong { box-shadow: inset 0 0 0 2px var(--danger); } .opt.wrong .bub { background: var(--danger); color: var(--on-primary); box-shadow: none; }
.rollbox { display: flex; gap: 8px; }
.rollbox input { width: 52px; height: 64px; text-align: center; border: 0; border-radius: var(--r-ctl); box-shadow: inset 0 0 0 var(--bw-strong) var(--line-strong); font: 600 28px/1 var(--font-display); background: var(--bg); }
.rollbox input:focus { outline: none; box-shadow: inset 0 0 0 2px var(--primary), 0 0 0 4px var(--primary-soft); }
.qnav { display: flex; flex-wrap: wrap; gap: 6px; }
.qnav button { width: 36px; height: 36px; border-radius: 50%; font-size: var(--t-13); font-weight: 600; box-shadow: inset 0 0 0 1.5px var(--line-strong); color: var(--ink-2); }
.qnav button.done { background: var(--primary); color: var(--on-primary); box-shadow: none; }
.qnav button.now { box-shadow: inset 0 0 0 2px var(--ink); color: var(--ink); }
.qnav button.flag { box-shadow: inset 0 0 0 2px var(--warning); }

/* Period strip: the school day as eight beads on a thread. */
.periods { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 6px; }
.periods .p { display: grid; gap: 3px; padding: var(--s-2); border-radius: var(--r-ctl); background: var(--surface); font-size: var(--t-12); color: var(--muted); min-width: 0; }
.periods .p span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.periods .p b { font-size: var(--t-14); color: var(--ink); }
.periods .p.done { background: var(--primary-soft); }
.periods .p.now { background: var(--primary); color: var(--on-primary); }
.periods .p.now b { color: var(--on-primary); }
.periods .p.due { box-shadow: inset 0 0 0 var(--bw-strong) var(--warning); }

/* Small trend bars drawn from data. */
.spark { display: flex; align-items: flex-end; gap: 3px; height: 32px; }
.spark i { flex: 1; border-radius: 3px 3px 0 0; background: var(--c-3); min-height: 2px; }
.spark i.hi { background: var(--primary-strong); }

/* Who is signed in: avatar, name and role, opens a switcher. */
.userchip { display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 4px 10px 4px 4px; border-radius: var(--r-full); text-align: left; transition: background var(--dur-1); }
.userchip:hover { background: var(--surface-2); }
.userchip b { display: block; font-size: var(--t-14); line-height: 1.1; }
.userchip small { display: block; font-size: var(--t-12); color: var(--muted); }


/* ==========================================================================
   App shells
   ========================================================================== */

/* Web hub: sidebar + topbar. The sidebar carries the school's own crest. */
.hub { display: grid; grid-template-columns: 256px minmax(0, 1fr); min-height: 100vh; background: var(--surface); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: var(--s-1); padding: var(--s-4) var(--s-3); background: var(--bg); border-right: var(--rule); overflow-y: auto; }
.sidebar .school { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-2) var(--s-2) var(--s-4); margin-bottom: var(--s-2); border-bottom: var(--rule); }
.sidebar .school b { display: block; font: 600 var(--t-15)/1.2 var(--font-display); font-stretch: var(--stretch-head); }
.sidebar .school small { display: block; font-size: var(--t-12); color: var(--muted); }
.sidebar .grp { margin: var(--s-3) var(--s-2) var(--s-1); font-size: var(--t-12); color: var(--muted); }
.sidebar a { display: flex; align-items: center; gap: var(--s-3); min-height: 40px; padding: 0 var(--s-3); border-radius: var(--r-ctl); color: var(--ink-2); text-decoration: none; font-size: var(--t-15); }
.sidebar a:hover { background: var(--surface); color: var(--ink); }
.sidebar a[aria-current="page"] { background: var(--primary-soft); color: var(--primary-strong); font-weight: var(--wt-strong); }
.sidebar a .count { margin-left: auto; }
.has-pocbar .sidebar { height: calc(100vh - var(--pocbar-h)); }
.sidebar .me { margin-top: auto; display: flex; align-items: center; gap: var(--s-3); padding: var(--s-3) var(--s-2) 0; border-top: var(--rule); font-size: var(--t-13); }
.sidebar .me b { display: block; font-size: var(--t-14); }
.topbar { position: sticky; top: 0; z-index: var(--z-sticky); display: flex; align-items: center; gap: var(--s-3); min-height: 64px; padding: 0 var(--gutter); background: oklch(0.976 0.006 210 / .92); backdrop-filter: blur(8px); border-bottom: var(--rule); }
.topbar .grow { flex: 1; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--s-4); padding: var(--s-6) var(--gutter) var(--s-5); }
.page-head h1 { font-size: var(--t-32); line-height: 1.1; }
.page-head p { color: var(--muted); font-size: var(--t-15); margin-top: 4px; }
.content { padding: 0 var(--gutter) var(--s-8); display: grid; gap: var(--s-5); align-content: start; }
.menu-btn { display: none; }
@media (max-width: 980px) {
  .hub { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: var(--z-layer); left: 0; width: 280px; translate: -100% 0; transition: translate var(--dur-3) var(--ease-out); box-shadow: var(--elev-modal); }
  body.nav-open .sidebar { translate: 0 0; }
  .menu-btn { display: inline-flex; }
}

/* Owner console: deep-peacock top bar, wide content. */
.ownerbar { position: sticky; top: 0; z-index: var(--z-sticky); display: flex; align-items: center; gap: var(--s-5); min-height: 64px; padding: 0 var(--gutter); background: var(--drench); color: var(--on-drench); }
.ownerbar .brand:hover { color: var(--on-drench); }
.ownerbar .brand { display: flex; align-items: center; gap: 10px; font: 650 var(--t-22)/1 var(--font-display); font-stretch: 118%; color: var(--on-drench); text-decoration: none; }
.ownerbar nav { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; }
.ownerbar nav a { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 var(--s-3); border-radius: var(--r-ctl); color: var(--on-drench-muted); text-decoration: none; font-size: var(--t-15); white-space: nowrap; }
.ownerbar nav a:hover { background: oklch(1 0 0 / .08); color: var(--on-drench); }
.ownerbar nav a[aria-current="page"] { background: oklch(1 0 0 / .12); color: var(--on-drench); }
.ownerbar .grow { flex: 1; }
.owner-main { background: var(--surface); min-height: calc(100vh - 64px); }

/* Tablet app: Android navigation rail + app bar inside a 1280x800 canvas. */
.t-app { position: relative; width: 100%; height: 100%; display: grid; grid-template-columns: 92px minmax(0, 1fr); grid-template-rows: 28px 72px minmax(0, 1fr); background: var(--bg); color: var(--ink); overflow: hidden; }
.t-status { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; padding: 0 18px; font: 500 13px/1 var(--font-body); color: var(--ink-2); background: var(--surface); }
.t-status span { display: flex; align-items: center; gap: 6px; }
.t-rail { grid-row: 2 / 4; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: var(--s-3) 0; background: var(--surface); border-right: var(--rule); }
.t-rail a { display: grid; justify-items: center; gap: 4px; width: 76px; padding: 8px 0; border-radius: var(--r-card); color: var(--ink-2); text-decoration: none; font-size: 12px; font-weight: var(--wt-strong); }
.t-rail a .pip { display: grid; place-items: center; width: 56px; height: 32px; border-radius: var(--r-full); transition: background var(--dur-2); }
.t-rail a:hover .pip { background: var(--surface-3); }
.t-rail a[aria-current="page"] { color: var(--ink); }
.t-rail a[aria-current="page"] .pip { background: var(--primary-soft-2); color: var(--primary-strong); }
.t-rail .bottom { margin-top: auto; }
.t-bar { display: flex; align-items: center; gap: var(--s-4); padding: 0 var(--s-5); border-bottom: var(--rule); }
.t-bar h1, .t-bar h2 { font-size: var(--t-28); line-height: 1; }
.t-bar p { font-size: var(--t-13); color: var(--muted); margin-top: 4px; }
.t-bar .grow { flex: 1; }
.t-main { position: relative; overflow-y: auto; overscroll-behavior: contain; }

/* ==========================================================================
   Prototype chrome
   ========================================================================== */
.tablet-stage { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: var(--s-6); align-items: center; padding: var(--s-6) var(--gutter) calc(var(--pocbar-h) + var(--s-6)); background: var(--surface-3); }
.device { --fit: 1; position: relative; width: 100%; padding: 1.8%; border-radius: clamp(14px, 2.6vw, 34px); background: linear-gradient(160deg, oklch(0.27 0.008 230), oklch(0.17 0.008 230));
  box-shadow: 0 40px 80px -40px oklch(0.15 0.03 215 / .6), inset 0 0 0 1px oklch(1 0 0 / .06); }
.device::before { content: ''; position: absolute; top: 50%; left: .7%; width: 6px; height: 6px; border-radius: 50%; translate: 0 -50%; background: oklch(0.34 0.01 230); }
.device .vp { position: relative; aspect-ratio: 1280 / 800; overflow: hidden; border-radius: clamp(4px, .9vw, 12px); background: var(--bg); }
.device .canvas { position: absolute; left: 0; top: 0; width: 1280px; height: 800px; transform: scale(var(--fit)); transform-origin: 0 0; }
.stage-cap { align-self: center; display: grid; gap: var(--s-3); font-size: var(--t-14); color: var(--ink-2); }
.stage-cap h2 { font-size: var(--t-22); color: var(--ink); }
.stage-cap .tag { justify-self: start; }
@media (max-width: 1180px) { .tablet-stage { grid-template-columns: 1fr; } }
/* On a real tablet the frame drops away and the app is the page. */
@media (pointer: coarse) and (min-width: 900px) {
  .tablet-stage { padding: 0 0 var(--pocbar-h); display: block; background: var(--bg); }
  .tablet-stage .device { padding: 0; border-radius: 0; box-shadow: none; background: none; }
  .tablet-stage .device::before, .tablet-stage .stage-cap { display: none; }
  .tablet-stage .device .vp { border-radius: 0; height: calc(100vh - var(--pocbar-h)); aspect-ratio: auto; }
}

.pocbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: var(--z-pocbar); height: var(--pocbar-h); display: flex; align-items: center; gap: var(--s-3);
  padding: 0 var(--s-4); font-size: var(--t-13); background: oklch(0.2 0.03 215); color: var(--on-drench); box-shadow: 0 -6px 24px oklch(0.1 0.02 215 / .25); }
.pocbar .tagword { font-size: 11px; letter-spacing: .08em; color: var(--accent); font-weight: 600; }
.pocbar .roles { display: flex; gap: 2px; }
.pocbar .roles a { padding: 6px 10px; border-radius: var(--r-full); color: var(--on-drench-muted); text-decoration: none; white-space: nowrap; }
.pocbar .roles a:hover { color: var(--on-drench); background: oklch(1 0 0 / .08); }
.pocbar .roles a[aria-current="true"] { background: var(--on-drench); color: var(--drench); }
.pocbar .mods { display: flex; gap: 4px; }
.pocbar .tag-module { font-size: 11px; padding: 2px 7px; border: 1px solid var(--drench-line); border-radius: var(--r-full); color: var(--on-drench-muted); text-decoration: none; }
.pocbar .spacer { flex: 1; }
.pocbar button.link { color: var(--on-drench-muted); padding: 6px 8px; border-radius: 8px; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }
.pocbar button.link:hover { color: var(--on-drench); background: oklch(1 0 0 / .08); }
.pocbar .netsw[aria-checked="false"] { color: var(--accent); }
@media (max-width: 760px) {
  .pocbar .hide-sm { display: none; }
  .pocbar { overflow-x: auto; scrollbar-width: none; }
  .pocbar::-webkit-scrollbar { display: none; }
  .pocbar > * { flex: none; }
}
body.show-sow [data-module] { outline: 1px dashed var(--accent-strong); outline-offset: 2px; position: relative; }
body.show-sow [data-module]::after { content: attr(data-module); position: absolute; top: -8px; right: -6px; z-index: 2; font-size: 10px; line-height: 1; padding: 3px 6px; border-radius: var(--r-full); background: var(--accent); color: var(--on-accent); }

.tour-hole { position: fixed; z-index: calc(var(--z-tour) + 1); border-radius: var(--r-card); box-shadow: 0 0 0 9999px oklch(0.15 0.03 215 / .55), 0 0 0 3px var(--accent); pointer-events: none; transition: all var(--dur-3) var(--ease-out); }
.tour-pop { position: fixed; z-index: calc(var(--z-tour) + 2); max-width: 36ch; padding: var(--s-4); background: var(--bg); color: var(--ink); border-radius: var(--r-card); box-shadow: var(--e-3); }
.tour-pop .step { font-size: var(--t-12); color: var(--muted); }
.tour-pop h3 { font-size: var(--t-18); margin: var(--s-1) 0 var(--s-2); }
.tour-pop p { font-size: var(--t-14); line-height: 1.5; color: var(--ink-2); }
.tour-pop .row { display: flex; gap: var(--s-2); justify-content: flex-end; margin-top: var(--s-4); }

.rv.pre { opacity: 0; transform: translateY(16px); }
.rv.in { opacity: 1; transform: none; transition: opacity 700ms var(--ease-out), transform 900ms var(--ease-out); }

.skip-link { position: absolute; left: -9999px; top: 0; z-index: 999; padding: var(--s-3) var(--s-4); background: var(--ink); color: var(--on-primary); border-radius: 0 0 var(--r-ctl) 0; }
.skip-link:focus { left: 0; }
.skip-link:hover { color: var(--on-primary); }

/* A tablet embedded in another page (the owner console shows TAB-03 live). */
.embed { background: transparent; padding: 0 !important; }
.embed .tablet-stage { display: block; min-height: 0; padding: 0; background: none; }
.embed .tablet-stage .device { max-width: none; padding: 0; border-radius: 0; background: none; box-shadow: none; }
.embed .device::before { display: none; }
.embed .device .vp { border-radius: 0; }
.embed .stage-cap, .embed .toaster { display: none; }
