/* TutorHub — interface styles. Mobile first; drawer navigation on every screen size, docked on desktop. */
:root {
    /* --brand: accent as text and lines; --brand-fill: accent as a solid background, with --brand-ink on it */
    --brand: #b45410; --brand-fill: #f97316; --brand-ink: #111111; --brand-soft: #feeee3; --brand-strong: #8f420c;
    --bg: #f3f5f9; --surface: #ffffff; --surface-2: #f7f9fc; --line: #e2e7ef; --line-strong: #cbd3df;
    --text: #0f172a; --muted: #475569; --faint: #7c889b;
    --green: #0f7a55; --green-bg: #e2f5ec; --amber: #a55a05; --amber-bg: #fdf0d9; --red: #c22f2f; --red-bg: #fde7e7;
    --blue: #1d4ed8; --blue-bg: #dbeafe; --gray-bg: #e9edf3;
    --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 4px 16px rgba(15, 23, 42, .05);
    --radius: 12px; --drawer-w: 264px; --rail-w: 68px; --topbar-h: 58px;
    --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: ui-monospace, "Cascadia Mono", Consolas, "Courier New", monospace;
    --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100; --s5: #e87ba4; --s6: #008300; --s7: #6250d6; --s0: #9aa5a2; --grid: #e6ebe9;
    --brand-print: #b45410;
    color-scheme: light;
}
[data-theme="dark"] {
    --brand: #f97316; --brand-fill: #f97316; --brand-ink: #111111; --brand-soft: #40281a; --brand-strong: #fa8431;
    --bg: #0e0e10; --surface: #18181b; --surface-2: #202024; --line: #2e2e34; --line-strong: #3f3f46;
    --text: #ececef; --muted: #b8b8c0; --faint: #8a8a94;
    --green: #3fc28f; --green-bg: #12322a; --amber: #f0b23f; --amber-bg: #3a2c10; --red: #f07a7a; --red-bg: #3c1b1e;
    --blue: #7ab0ff; --blue-bg: #14274a; --gray-bg: #26262b;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #2f9a2f; --s7: #9085e9; --s0: #5d6b68; --grid: #26312f;
    color-scheme: dark;
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.5 var(--font); color: var(--text); background: var(--bg); }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; text-wrap: balance; }
h2 { font-size: 1.35rem; } h3 { font-size: 1.05rem; } h4 { font-size: .95rem; }
p { margin: 0 0 .8em; }
small { font-size: .85em; }
code, .mono { font-family: var(--mono); font-size: .9em; }
hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }
.ic { flex: none; vertical-align: -3px; }
.muted { color: var(--muted); } .faint { color: var(--faint); }
.right { text-align: right; } .center { text-align: center; } .nowrap { white-space: nowrap; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.mb-0, .mb0 { margin-bottom: 0; } .mb-1 { margin-bottom: 8px; } .mb-2, .mb { margin-bottom: 16px; } .mt-1 { margin-top: 8px; } .mt-2, .mt { margin-top: 16px; }
.small { font-size: .88rem; } .tiny { font-size: .78rem; color: var(--faint); }
.hide { display: none !important; }

/* ---------- Shell ---------- */
.shell { min-height: 100vh; min-height: 100dvh; }
.drawer {
    position: fixed; inset: 0 auto 0 0; z-index: 40; width: min(var(--drawer-w), 86vw); display: flex; flex-direction: column;
    background: var(--surface); border-right: 1px solid var(--line); transform: translateX(-102%); transition: transform .22s ease, width .18s ease;
    padding-left: env(safe-area-inset-left);
}
.drawer-open .drawer { transform: none; box-shadow: var(--shadow); }
.backdrop { position: fixed; inset: 0; z-index: 35; background: rgba(8, 14, 13, .5); opacity: 0; pointer-events: none; transition: opacity .2s; }
.drawer-open .backdrop { opacity: 1; pointer-events: auto; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; height: var(--topbar-h); padding: 0 12px 0 16px; border-bottom: 1px solid var(--line); flex: none; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 700; font-size: 1.05rem; min-width: 0; }
.brand:hover { text-decoration: none; }
.app-logo { flex: none; border-radius: 22%; }
.brand-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav { flex: 1; overflow-y: auto; padding: 10px 10px 16px; overscroll-behavior: contain; }
.nav-group { margin: 14px 10px 4px; font-size: .72rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); display: flex; align-items: center; gap: 8px; }
.nav-group::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.nav-link { --g: var(--brand); display: flex; align-items: center; gap: 10px; padding: 5px 8px; border-radius: 9px; color: var(--muted); font-weight: 550; min-height: 40px; }
.nav-link span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.nav-link:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-link.active { background: var(--brand-soft); color: var(--brand-strong); box-shadow: inset 3px 0 0 var(--g, var(--brand)); }
[data-theme="dark"] .nav-link.active { color: var(--brand); }
.nav-link .ic { width: 30px; height: 30px; padding: 6px; border-radius: 9px; color: var(--g, var(--muted)); background: color-mix(in srgb, var(--g, var(--muted)) 14%, transparent); }
.nav-link:hover .ic { background: color-mix(in srgb, var(--g, var(--muted)) 24%, transparent); }
.nav-link.active .ic { color: #fff; background: var(--g, var(--brand)); }
.nav-link[data-g="scheduling"] { --g: var(--s1); } .nav-link[data-g="learning"] { --g: var(--s3); } .nav-link[data-g="billing"] { --g: var(--s2); }
.nav-link[data-g="communication"] { --g: var(--s7); } .nav-link[data-g="setup"] { --g: var(--s4); } .nav-link[data-g="system"] { --g: #64748b; }
[data-theme="dark"] .nav-link[data-g="system"] { --g: #94a3b8; }
.nav-count { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--red); color: #fff; font-size: .72rem; line-height: 20px; text-align: center; }
.drawer-foot { display: flex; align-items: center; gap: 6px; padding: 10px 12px; border-top: 1px solid var(--line); flex: none; padding-bottom: max(10px, env(safe-area-inset-bottom)); }
.me { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; color: var(--text); }
.me:hover { text-decoration: none; }
.me-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.me-text strong, .me-text small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-text small { color: var(--muted); }
.avatar { flex: none; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--brand-fill); color: var(--brand-ink); font-weight: 700; font-size: .85rem; }
.main { display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; min-width: 0; }
.topbar {
    position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 10px; height: var(--topbar-h); padding: 0 12px;
    background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
    padding-left: max(12px, env(safe-area-inset-left)); padding-right: max(12px, env(safe-area-inset-right));
}
.topbar-title { font-size: 1.05rem; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; min-width: 0; }
.topbar-actions { display: flex; align-items: center; gap: 6px; flex: none; }
select option, select optgroup { background: var(--surface); color: var(--text); }
.icon-btn { display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 9px; border: 0; background: transparent; color: var(--muted); cursor: pointer; flex: none; position: relative; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
[data-theme="dark"] .t-dark, [data-theme="light"] .t-light, html:not([data-theme]) .t-light { display: none; }
@media (max-width: 719px) { #installBtn span { display: none; } #installBtn { padding: 4px 9px; } }
.content { flex: 1; width: 100%; max-width: 1360px; margin: 0 auto; padding: 16px 12px 28px; padding-left: max(12px, env(safe-area-inset-left)); padding-right: max(12px, env(safe-area-inset-right)); }
.foot { padding: 14px 16px 18px; text-align: center; color: var(--muted); font-size: .85rem; border-top: 1px solid var(--line); }
.foot-ver { display: block; color: var(--faint); margin-top: 2px; }

/* Desktop and landscape tablets: the drawer is docked; the menu button folds it to an icon rail */
@media (min-width: 1024px) {
    .drawer { transform: none; }
    .backdrop, .drawer-close { display: none; }
    .main { margin-left: var(--drawer-w); transition: margin-left .18s ease; }
    .rail .drawer { width: var(--rail-w); }
    .rail .main { margin-left: var(--rail-w); }
    .rail .brand-text, .rail .nav-link span, .rail .me-text, .rail .drawer-foot .icon-btn, .rail .nav-count { display: none; }
    .rail .nav-group { height: 1px; margin: 10px 8px; background: var(--line); overflow: hidden; color: transparent; display: block; }
    .rail .nav-link { justify-content: center; padding: 5px 0; }
    .rail .drawer-head { padding: 0; justify-content: center; }
    .rail .drawer-foot { justify-content: center; }
    .rail .me { flex: none; }
    .content { padding: 22px 26px 36px; }
}

/* ---------- Page pieces ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.page-head p { margin: 4px 0 0; color: var(--muted); max-width: 70ch; }
.actions, .btn-group, .btn-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
/* A card holds its content with 16px padding. A .card-head becomes a full-width title strip; .card-body, .list and
   .table-wrap placed directly in a card run edge to edge, so both simple and sectioned cards look the same. */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 16px; min-width: 0; padding: 16px; }
.card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; padding: 13px 16px; border-bottom: 1px solid var(--line); }
.card > .card-head { margin: -16px -16px 16px; }
.card-head h2, .card-head h3 { display: flex; align-items: center; gap: 8px; font-size: 1.05rem; margin: 0; }
.card > h2:first-child, .card > h3:first-child { display: flex; align-items: center; gap: 8px; margin: -16px -16px 16px; padding: 13px 16px; border-bottom: 1px solid var(--line); font-size: 1.05rem; }
.card-body { padding: 16px; }
.card > .card-body { margin: -16px; }
.card > .card-head + .card-body { margin-top: -16px; }
.card > .card-body + * { margin-top: 32px; }
.card > .list { margin-left: -16px; margin-right: -16px; }
.card > .card-head + .list, .card > h2:first-child + .list, .card > h3:first-child + .list { margin-top: -16px; }
.card > .list:last-child { margin-bottom: -16px; }
.card > .table-wrap { margin-left: -16px; margin-right: -16px; }
.card > .card-head + .table-wrap, .card > .tabs + .table-wrap { margin-top: -16px; }
.card > .table-wrap:last-child { margin-bottom: -16px; }
.card > .empty:last-child { margin-bottom: -8px; }
.grid { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
.grid > * { min-width: 0; }
.grid .card, .grid > .stat { margin-bottom: 0; }
.grid + .grid, .grid + .card, .card + .grid { margin-top: 16px; }
@media (min-width: 640px) { .cols-2, .cols-4, .grid-2, .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .cols-3, .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1100px) { .cols-3, .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .cols-4, .grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); } .grid-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); } }
.stack > * + * { margin-top: 16px; }
.stack > .card { margin-bottom: 0; }
.grid-main > div > .card:last-child { margin-bottom: 0; }

/* Stat tiles: a tinted icon chip and a coloured top edge per topic */
.kpi, .stat { position: relative; overflow: hidden; padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.kpi .label, .stat .label { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: .85rem; font-weight: 600; margin: 0; }
.kpi .value, .stat .value { font-size: 1.5rem; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.kpi .sub, .stat .sub { color: var(--muted); font-size: .85rem; }
.stat::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 3px; background: var(--tone, var(--brand-fill)); }
.grid > .stat:nth-child(4n+1) { --tone: var(--s1); } .grid > .stat:nth-child(4n+2) { --tone: var(--s3); } .grid > .stat:nth-child(4n+3) { --tone: var(--s2); } .grid > .stat:nth-child(4n+4) { --tone: var(--s7); }

/* ---------- Buttons and forms ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 40px; padding: 8px 14px; border-radius: 9px;
    border: 1px solid var(--line-strong); background: var(--surface); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn-primary { background: var(--brand-fill); border-color: var(--brand-fill); color: var(--brand-ink); }
.btn-primary:hover { background: var(--brand-strong); border-color: var(--brand-strong); }
.btn-danger { background: var(--red); border-color: var(--red); color: #fff; }
[data-theme="dark"] .btn-danger { color: #1b0606; }
.btn-danger:hover { filter: brightness(.92); background: var(--red); }
.btn-good { background: var(--green); border-color: var(--green); color: #fff; }
[data-theme="dark"] .btn-good { color: #06180f; }
.btn-good:hover { filter: brightness(.95); background: var(--green); }
.btn-sm { min-height: 32px; padding: 4px 10px; font-size: .88rem; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.link-btn { background: none; border: 0; color: var(--brand); cursor: pointer; font: inherit; padding: 0; }
.link-btn.danger { color: var(--red); }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.inline { display: inline; }
label, .label { display: block; font-weight: 600; font-size: .88rem; color: var(--muted); margin-bottom: 4px; }
input[type=text], input[type=password], input[type=email], input[type=number], input[type=date], input[type=time], input[type=url], input[type=search], input[type=tel], input[type=datetime-local], select, textarea {
    width: 100%; min-height: 40px; padding: 8px 11px; border: 1px solid var(--line-strong); border-radius: 9px; background: var(--surface); color: var(--text); font: inherit; font-size: 16px;
}
@media (min-width: 1024px) { input, select, textarea { font-size: 15px !important; } }
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 22%, transparent); }
input[readonly] { background: var(--surface-2); }
input[type=file] { width: 100%; padding: 7px; border: 1px dashed var(--line-strong); border-radius: 9px; background: var(--surface-2); color: var(--text); font: inherit; }
input[type=checkbox], input[type=radio] { width: 18px; height: 18px; accent-color: var(--brand); flex: none; }
input[type=color] { width: 64px; height: 40px; padding: 2px; border: 1px solid var(--line-strong); border-radius: 9px; background: var(--surface); }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; color: var(--text); font-size: .95rem; margin: 0; cursor: pointer; }
.field { margin-bottom: 14px; min-width: 0; }
.field small { display: block; color: var(--muted); margin-top: 3px; }
.form-grid { display: grid; gap: 0 16px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 640px) { .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } .span-2 { grid-column: span 2; } .span-all { grid-column: 1 / -1; } }
.form-row { display: grid; gap: 0 14px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.form-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.toolbar, .filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; margin-bottom: 14px; }
.toolbar .field, .filters .field { margin: 0; flex: 1 1 140px; min-width: 0; max-width: 260px; }
.card.filters { padding: 12px 16px; }
.join { display: flex; gap: 6px; }
.join > input, .join > select { flex: 1; min-width: 0; }
fieldset { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px 4px; margin: 0 0 14px; min-width: 0; }
legend { font-weight: 700; padding: 0 6px; font-size: .92rem; }

/* Drop-down menu on a button */
.menu { position: relative; display: inline-block; }
.menu > summary { list-style: none; }
.menu > summary::-webkit-details-marker { display: none; }
.menu[open] > summary { background: var(--surface-2); }
.menu-list { position: absolute; right: 0; top: calc(100% + 6px); z-index: 25; min-width: 190px; padding: 6px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 10px; box-shadow: var(--shadow); }
.menu-list a { display: flex; align-items: center; gap: 9px; padding: 9px 10px; border-radius: 7px; color: var(--text); font-weight: 600; white-space: nowrap; }
.menu-list a:hover, .menu-list a:focus-visible { background: var(--brand-soft); text-decoration: none; }

/* Notifications bell */
.bell > summary { position: relative; }
.bell-n { position: absolute; top: 3px; right: 2px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 999px; background: var(--red); color: #fff; font-size: .68rem; font-weight: 800; line-height: 17px; text-align: center; }
[data-theme="dark"] .bell-n { color: #1b0606; }
.bell-list { width: min(360px, calc(100vw - 20px)); padding: 0; max-height: min(70vh, 520px); overflow: auto; }
.bell-head { padding: 12px 14px 8px; font-weight: 700; border-bottom: 1px solid var(--line); }
.bell-empty { padding: 22px 14px; color: var(--muted); text-align: center; }
.menu-list a.bell-item { display: flex; align-items: flex-start; gap: 12px; padding: 12px 14px; border-radius: 0; border-bottom: 1px solid var(--line); white-space: normal; font-weight: 400; }
.bell-item strong { display: block; } .bell-item small { display: block; color: var(--muted); }
.bell-ic { flex: none; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; }
.bt-red .bell-ic { background: var(--red-bg); color: var(--red); } .bt-amber .bell-ic { background: var(--amber-bg); color: var(--amber); } .bt-blue .bell-ic { background: var(--blue-bg); color: var(--blue); }
.menu-list a.bell-all { justify-content: center; border-radius: 0; color: var(--brand); padding: 11px; }
@media (max-width: 479px) { .bell-list { position: fixed; right: 10px; top: calc(var(--topbar-h) + 4px); } }

/* Account menu (top bar) */
.avatar-sm { width: 30px; height: 30px; font-size: .8rem; }
.account-list { width: min(280px, calc(100vw - 20px)); padding: 6px; }
.account-head { display: flex; align-items: center; gap: 10px; padding: 8px 8px 10px; }
.account-head .me-text small { color: var(--muted); }
.account-role { padding: 0 8px 10px; margin-bottom: 6px; border-bottom: 1px solid var(--line); }
.account-role .badge { display: inline-flex; align-items: center; gap: 5px; }
.menu-list a.account-out { color: var(--red); border-top: 1px solid var(--line); border-radius: 0 0 7px 7px; margin-top: 6px; }
@media (max-width: 479px) { .account-list { position: fixed; right: 10px; top: calc(var(--topbar-h) + 4px); } }

/* Loading: spinner overlay for forms, progress bar for page changes, spinner inside busy buttons */
.spin-wrap { position: relative; width: 64px; height: 64px; display: grid; place-items: center; }
.spin-wrap .spinner { position: absolute; inset: 0; width: 64px; height: 64px; }
.loader-pct { position: relative; font-size: .92rem; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text); }
.spinner { width: 46px; height: 46px; border-radius: 50%; border: 4px solid color-mix(in srgb, var(--brand) 22%, transparent); border-top-color: var(--brand); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loader { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; padding: 20px; background: color-mix(in srgb, var(--bg) 72%, transparent); backdrop-filter: blur(2px); opacity: 0; pointer-events: none; transition: opacity .18s; }
.loader.on { opacity: 1; pointer-events: auto; }
.loader-box { display: flex; flex-direction: column; align-items: center; gap: 10px; min-width: min(280px, 100%); max-width: 360px; padding: 26px 28px; text-align: center; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); }
.loader-title { font-size: 1.08rem; }
.loader-detail { color: var(--muted); font-size: .9rem; }
.loadbar { position: fixed; left: 0; top: 0; z-index: 95; height: 3px; width: 0; background: var(--brand-fill); opacity: 0; box-shadow: 0 0 8px var(--brand-fill); }
.loadbar.on { opacity: 1; animation: loadbar 8s cubic-bezier(.1, .7, .2, 1) forwards; }
@keyframes loadbar { 0% { width: 0; } 20% { width: 45%; } 60% { width: 80%; } 100% { width: 96%; } }
.btn.is-busy { position: relative; color: transparent !important; pointer-events: none; }
.btn.is-busy::after { content: ""; position: absolute; left: 50%; top: 50%; width: 18px; height: 18px; margin: -9px 0 0 -9px; border-radius: 50%; border: 2.5px solid currentColor; border-top-color: transparent; color: var(--text); animation: spin .7s linear infinite; }
.btn-primary.is-busy::after, .btn-danger.is-busy::after, .btn-good.is-busy::after { color: #fff; }
@media (prefers-reduced-motion: reduce) { .spinner, .btn.is-busy::after { animation-duration: 2.4s !important; } .loadbar.on { animation: none; width: 70%; } }

/* ---------- Tabs, badges, alerts ---------- */
.tabs { display: flex; gap: 4px; overflow-x: auto; margin-bottom: 16px; border-bottom: 1px solid var(--line); scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab, .tabs > a { padding: 9px 14px; border-bottom: 2px solid transparent; color: var(--muted); font-weight: 600; white-space: nowrap; margin-bottom: -1px; }
.tab:hover, .tabs > a:hover { color: var(--text); text-decoration: none; }
.tab.active, .tabs > a.active { color: var(--brand); border-bottom-color: var(--brand); }
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .78rem; font-weight: 700; white-space: nowrap; vertical-align: 1px; }
.b-green, .badge-good { background: var(--green-bg); color: var(--green); } .b-amber, .badge-warn { background: var(--amber-bg); color: var(--amber); }
.b-red, .badge-bad { background: var(--red-bg); color: var(--red); } .b-blue, .badge-info { background: var(--blue-bg); color: var(--blue); } .b-gray, .badge-muted { background: var(--gray-bg); color: var(--muted); }
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 11px 14px; border-radius: 10px; margin-bottom: 14px; border: 1px solid transparent; }
.alert .ic { margin-top: 2px; }
.alert ul { margin: 0; padding-left: 18px; }
.alert-success { background: var(--green-bg); color: var(--green); } .alert-error { background: var(--red-bg); color: var(--red); }
.alert-info { background: var(--blue-bg); color: var(--blue); } .alert-warn { background: var(--amber-bg); color: var(--amber); }
.empty { padding: 28px 16px; text-align: center; color: var(--muted); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); background: var(--surface-2); white-space: nowrap; font-weight: 700; }
th.num, td.num { text-align: right; }
tbody tr:hover { background: var(--surface-2); }
tbody tr:last-child td, tfoot tr:last-child td, tfoot tr:last-child th { border-bottom: 0; }
tfoot td, tfoot th { font-weight: 700; background: var(--surface-2); }
/* Phones: list tables become stacked cards (labels are added by app.js) */
@media (max-width: 719px) {
    table.stack thead, table.stackable thead { display: none; }
    table.stack, table.stack tbody, table.stack tr, table.stack td { display: block; width: 100%; }
    table.stack tr { padding: 10px 14px; border-bottom: 1px solid var(--line); }
    table.stack tbody tr:last-child { border-bottom: 0; }
    table.stack td { display: block; overflow: hidden; padding: 3px 0; border: 0; text-align: right; white-space: normal; overflow-wrap: anywhere; }
    table.stack td::before { content: attr(data-label); float: left; margin-right: 14px; font-weight: 600; color: var(--muted); font-size: .82rem; text-align: left; max-width: 45%; }
    table.stack td:first-child { font-weight: 700; font-size: 1rem; }
    table.stack td[data-label=""]::before { display: none; }
    table.stack td:empty { display: none; }
}

.list { list-style: none; margin: 0; padding: 0; }
.list > li, .list-item { display: flex; align-items: center; gap: 12px; padding: 11px 16px; border-bottom: 1px solid var(--line); }
.list > li:last-child { border-bottom: 0; }
.list .grow { flex: 1; min-width: 0; }
.list .title { font-weight: 600; overflow-wrap: anywhere; }
.list .sub { color: var(--muted); font-size: .88rem; overflow-wrap: anywhere; }
.list > li.empty { justify-content: center; }
.swatch { width: 5px; align-self: stretch; border-radius: 3px; flex-shrink: 0; }
.dl, .kv { display: grid; grid-template-columns: minmax(110px, auto) minmax(0, 1fr); gap: 6px 16px; margin: 0; }
.dl dt, .kv dt { color: var(--muted); font-weight: 600; font-size: .88rem; } .dl dd, .kv dd { margin: 0; overflow-wrap: anywhere; }

/* ---------- Charts: single-series meters ---------- */
.bar-row { display: grid; grid-template-columns: minmax(90px, 170px) 1fr 74px; gap: 10px; align-items: center; padding: 5px 0; font-size: .88rem; }
.bar-track { height: 12px; background: var(--gray-bg); border-radius: 4px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--s1); border-radius: 0 4px 4px 0; min-width: 2px; }
.bar-row .v { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }
.meter { height: 8px; background: var(--gray-bg); border-radius: 4px; overflow: hidden; }
.meter > span { display: block; height: 100%; background: var(--s1); border-radius: 0 4px 4px 0; }
.tip { position: fixed; z-index: 80; pointer-events: none; max-width: 240px; padding: 7px 10px; border-radius: 8px; background: #111a19; color: #f1f6f5; font-size: .82rem; line-height: 1.4; white-space: pre-line; box-shadow: var(--shadow); }
[data-theme="dark"] .tip { background: #eef3f2; color: #101716; }

/* ---------- Week calendar ---------- */
.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }
.day { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; min-height: 140px; padding: 8px; }
.day.today { border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); }
.day-head { font-size: .8rem; font-weight: 700; color: var(--muted); margin-bottom: 6px; display: flex; justify-content: space-between; }
.ev { display: block; border-left: 4px solid var(--s1); background: var(--surface-2); border-radius: 6px; padding: 6px 8px; margin-bottom: 6px; font-size: .78rem; color: var(--text); }
.ev:hover { background: var(--brand-soft); text-decoration: none; }
.ev.cancelled { opacity: .5; text-decoration: line-through; }
.ev b { display: block; font-size: .8rem; }
@media (max-width: 1099px) { .week { grid-template-columns: minmax(0, 1fr); } .day { min-height: 0; } .day.empty-day { display: none; } }

/* ---------- Messages ---------- */
.card.chat { display: grid; grid-template-columns: 290px minmax(0, 1fr); height: calc(100vh - var(--topbar-h) - 120px); min-height: 440px; padding: 0; overflow: hidden; }
.chat-list { border-right: 1px solid var(--line); overflow-y: auto; }
.chat-list a { display: flex; gap: 10px; padding: 11px 14px; border-bottom: 1px solid var(--line); color: var(--text); align-items: center; }
.chat-list a.active, .chat-list a:hover { background: var(--brand-soft); text-decoration: none; }
.chat-main { display: flex; flex-direction: column; min-width: 0; }
.chat-head { padding: 10px 14px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.chat-back { display: none; }
.chat-msgs { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 6px; background: var(--surface-2); }
.msg { max-width: 78%; padding: 8px 12px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); align-self: flex-start; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.mine { align-self: flex-end; background: var(--brand-fill); color: var(--brand-ink); border-color: var(--brand-fill); }
.msg .t { display: block; font-size: .68rem; opacity: .7; margin-top: 2px; }
.chat-form { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--line); }
.chat-form textarea { min-height: 42px; height: 42px; }
.pill { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--red); color: #fff; font-size: .72rem; line-height: 20px; text-align: center; font-weight: 700; }
@media (max-width: 719px) {
    .card.chat { grid-template-columns: minmax(0, 1fr); height: calc(100vh - var(--topbar-h) - 90px); }
    .card.chat.has-thread .chat-list { display: none; }
    .card.chat:not(.has-thread) .chat-main { display: none; }
    .chat-back { display: inline-grid; }
}

/* ---------- Kiosk & check-in ---------- */
.kiosk { max-width: 520px; margin: 0 auto; text-align: center; }
.pin-input { font-size: 2.2rem !important; letter-spacing: .5em; text-align: center; font-variant-numeric: tabular-nums; min-height: 64px !important; }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 16px 0 0; }
.keypad button { font-size: 1.5rem; padding: 14px 0; border-radius: 12px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--text); cursor: pointer; font-family: inherit; }
.keypad button:active { background: var(--brand-soft); }
.keypad .go { background: var(--brand-fill); border-color: var(--brand-fill); color: var(--brand-ink); }
.qr-box { display: inline-block; padding: 12px; background: #fff; border-radius: 12px; }
.big-result { font-size: 1.2rem; font-weight: 700; padding: 14px; border-radius: 12px; justify-content: center; }

/* ---------- System pages ---------- */
.log-box { font-family: var(--mono); font-size: .85rem; white-space: pre-wrap; overflow-wrap: anywhere; background: #0b1211; color: #cfe6e1; border-radius: 10px; padding: 12px 14px; max-height: 320px; overflow: auto; }
.diff-list { list-style: none; margin: 0; padding: 0; max-height: 280px; overflow: auto; border: 1px solid var(--line); border-radius: 10px; font-family: var(--mono); font-size: .84rem; }
.diff-list li { padding: 5px 10px; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.diff-list li:last-child { border: 0; }
.tag { display: inline-block; min-width: 68px; margin-right: 8px; padding: 0 6px; border-radius: 5px; font-size: .72rem; font-weight: 700; text-align: center; }
.tag-new { background: var(--green-bg); color: var(--green); } .tag-changed { background: var(--amber-bg); color: var(--amber); } .tag-deleted { background: var(--red-bg); color: var(--red); }
.dialog { border: 1px solid var(--line); border-radius: 14px; padding: 20px; width: min(460px, calc(100vw - 28px)); background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.dialog::backdrop { background: rgba(8, 14, 13, .55); }
.dialog h3 { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; }
.doc { line-height: 1.65; }
.doc ol, .doc ul { padding-left: 22px; margin: 0 0 12px; } .doc li { margin-bottom: 5px; }
.doc code { overflow-wrap: anywhere; }
.doc pre { background: #0b1211; color: #cfe6e1; border-radius: 10px; padding: 12px 14px; overflow-x: auto; font-size: .84rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatches label { display: flex; align-items: center; gap: 6px; margin: 0; padding: 5px 10px 5px 6px; border: 1px solid var(--line-strong); border-radius: 999px; font-weight: 600; color: var(--text); cursor: pointer; }
.swatches i { width: 18px; height: 18px; border-radius: 50%; display: inline-block; }

/* ---------- Help, manual, about ---------- */
.nav-link[data-g="support"] { --g: var(--s6); }
@media (min-width: 1100px) { .grid-manual { grid-template-columns: 260px minmax(0, 1fr); align-items: start; } }
.grid-manual .manual-sec { margin-bottom: 16px; }
.toc { list-style: none; padding: 0; margin: 0; } .toc li { margin: 0; }
.toc a { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 8px; color: var(--muted); font-weight: 550; }
.toc a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
@media (min-width: 1100px) { .sticky { position: sticky; top: calc(var(--topbar-h) + 16px); max-height: calc(100vh - var(--topbar-h) - 32px); overflow: auto; } }
.doc h3 { margin: 22px 0 8px; display: flex; align-items: center; gap: 8px; } .doc h3:first-child { margin-top: 0; }
.doc h4 { margin: 16px 0 6px; }
.manual-sec { scroll-margin-top: calc(var(--topbar-h) + 12px); }
.who { display: inline-flex; gap: 4px; flex-wrap: wrap; margin-left: 4px; vertical-align: 2px; }
.who .badge { font-size: .7rem; padding: 1px 7px; }
details.faq { border-bottom: 1px solid var(--line); margin: 0 -16px; } details.faq:last-child { border: 0; margin-bottom: -16px; }
details.faq summary { cursor: pointer; padding: 13px 16px; font-weight: 600; list-style-position: outside; margin-left: 18px; }
details.faq summary:hover { color: var(--brand); }
details.faq > div { padding: 0 16px 14px 34px; color: var(--muted); }
.card > .card-head + details.faq { margin-top: -16px; }
a.card.tile { color: inherit; display: block; } a.card.tile:hover { text-decoration: none; border-color: var(--brand); }
a.card.tile h3 { color: var(--brand); display: flex; gap: 8px; align-items: center; }
/* The vendor logo has a white background: show it on a white plate in both themes */
.vendor-logo { display: inline-block; background: #fff; border-radius: 12px; padding: 10px 14px; border: 1px solid var(--line); line-height: 0; }
.vendor-logo img { width: 100%; max-width: 260px; height: auto; }
.vendor-logo.sm img { max-width: 150px; }
.foot a { color: var(--muted); font-weight: 600; }

/* ---------- Sign-in / installer ---------- */
.auth { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; align-content: center; padding: 20px 14px; }
.auth > .alert { width: min(100%, 420px); }
.auth-card { width: min(100%, 420px); background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); padding: 26px 24px; }
.auth-card.wide { width: min(100%, 640px); }
.auth-brand { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; margin-bottom: 18px; }
.auth-brand h1, .auth-brand h2 { font-size: 1.4rem; }
.auth-foot { text-align: center; color: var(--muted); font-size: .85rem; margin-top: 14px; }

@media print {
    :root, [data-theme="dark"] { --bg: #fff; --surface: #fff; --surface-2: #f5f7f6; --line: #d5dbd9; --line-strong: #9aa5a2; --text: #111; --muted: #555f5c; --faint: #7b8794; --brand: var(--brand-print); color-scheme: light; }
    * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    html, body { background: #fff; color: #111; }
    .drawer, .backdrop, .topbar, .foot, .no-print, .alert, .tabs, .filters, .btn, dialog, .loader, .loadbar { display: none !important; }
    .main { margin: 0 !important; } .content { padding: 0; max-width: none; }
    .card { border: 0; box-shadow: none; border-radius: 0; margin: 0 0 10px; }
}
