/* OfficeCore. Visual language borrowed from the company's own product: printed ID cards.
   Ink-navy rail, process-cyan accent, department colour bands like the header strip on a school ID card. */

@font-face { font-family: "Plex"; src: url("../fonts/plex-sans-400.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Plex"; src: url("../fonts/plex-sans-500.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Plex"; src: url("../fonts/plex-sans-600.woff2") format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Plex"; src: url("../fonts/plex-sans-700.woff2") format("woff2"); font-weight: 700; font-display: swap; }

:root {
    --paper: #f3f5f9;
    --surface: #ffffff;
    --surface-2: #f7f9fc;
    --ink: #16213a;
    --ink-2: #56637b;
    --ink-3: #8592a8;
    --line: #dde2eb;
    --line-strong: #c9d0dc;
    --rail: #14203a;
    --rail-ink: #c8d3e6;
    --rail-ink-strong: #ffffff;
    --rail-hover: #1e2c4b;
    --cyan: #0b7fa6;
    --cyan-strong: #086a8b;
    --cyan-weak: #e2f2f8;
    --ok: #237a55;
    --ok-weak: #e3f3eb;
    --warn: #9a5f0b;
    --warn-weak: #fbf0dc;
    --danger: #b3362f;
    --danger-weak: #fbe7e5;

    --d-lead: #3d4e9e;
    --d-sales: #c9821a;
    --d-idcard: #0b7fa6;
    --d-support: #2e8c69;
    --d-admin: #6b7689;
    --d-none: #a3abb9;

    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 14px;
    --shadow-card: 0 1px 0 rgba(22, 33, 58, .04), 0 6px 18px -10px rgba(22, 33, 58, .18);

    --font: "Plex", "Segoe UI", system-ui, sans-serif;
    --rail-w: 232px;
    --bottom-nav-h: 64px;
    color-scheme: light;
}

[data-theme="dark"] {
    --paper: #0d1424;
    --surface: #142036;
    --surface-2: #18263f;
    --ink: #e3e9f3;
    --ink-2: #9fadc4;
    --ink-3: #6f7f99;
    --line: #24324d;
    --line-strong: #31415f;
    --rail: #0a1120;
    --rail-ink: #a9b6cc;
    --rail-hover: #16223a;
    --cyan: #47bee0;
    --cyan-strong: #6fd0ec;
    --cyan-weak: #0f3147;
    --ok: #56c491;
    --ok-weak: #123528;
    --warn: #f0b456;
    --warn-weak: #3a2c13;
    --danger: #ff8a7d;
    --danger-weak: #3d1a18;
    --d-lead: #7f8fe0;
    --d-sales: #e8a443;
    --d-idcard: #47bee0;
    --d-support: #5cc79c;
    --d-admin: #96a1b5;
    --d-none: #5b6578;
    --shadow-card: 0 1px 0 rgba(0, 0, 0, .25), 0 8px 20px -12px rgba(0, 0, 0, .6);
    color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0; background: var(--paper); color: var(--ink);
    font-family: var(--font); font-size: 15px; line-height: 1.55;
    font-feature-settings: "tnum" 1;
}
a { color: var(--cyan); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; border-radius: 4px; }
h1, h2, h3 { margin: 0; line-height: 1.25; letter-spacing: -0.01em; }
h1 { font-size: 26px; font-weight: 600; }
h2 { font-size: 17px; font-weight: 600; }
h3 { font-size: 15px; font-weight: 600; }
p { margin: 0; }
.muted { color: var(--ink-2); }
.small { font-size: 13px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------------------------------------------------------------- app shell */
.shell { min-height: 100vh; }
.rail {
    position: fixed; inset: 0 auto 0 0; width: var(--rail-w); background: var(--rail); color: var(--rail-ink);
    display: flex; flex-direction: column; padding: 20px 14px; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--rail-ink-strong); font-weight: 600; font-size: 17px; padding: 4px 8px 22px; }
.brand:hover { text-decoration: none; }
.brand svg { flex: none; }
.rail nav { display: flex; flex-direction: column; gap: 2px; flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
            margin: 0 -6px; padding: 0 6px 8px; scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
.rail nav a {
    display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: var(--radius-sm);
    color: var(--rail-ink); font-weight: 500;
}
.rail nav a:hover { background: var(--rail-hover); color: var(--rail-ink-strong); text-decoration: none; }
.rail nav a[aria-current="page"] { background: var(--rail-hover); color: var(--rail-ink-strong); box-shadow: inset 3px 0 0 var(--cyan); }
.rail nav > * { flex: none; }   /* items keep their height; the list scrolls instead */
.rail nav a svg { width: 18px; height: 18px; flex: none; }
.rail-foot { margin-top: auto; border-top: 1px solid rgba(255, 255, 255, .08); padding-top: 14px; display: flex; flex-direction: column; gap: 10px; }
.rail-user { display: flex; align-items: center; gap: 10px; padding: 0 8px; }
.rail-user .who { line-height: 1.3; min-width: 0; }
.rail-user .who strong { color: var(--rail-ink-strong); font-weight: 500; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail-user .who span { font-size: 12px; }
.rail-actions { display: flex; gap: 6px; padding: 0 4px; }
.rail-actions .btn-ghost { color: var(--rail-ink); border-color: rgba(255, 255, 255, .12); flex: 1; justify-content: center; }
.rail-actions .btn-ghost:hover { background: var(--rail-hover); color: var(--rail-ink-strong); }

.content { margin-left: var(--rail-w); min-width: 0; }
.topbar { display: none; }
.bottom-nav { display: none; }
.page { max-width: 1180px; margin: 0 auto; padding: 28px 32px 48px; }

.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.page-head p { margin-top: 4px; color: var(--ink-2); max-width: 70ch; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------------------------------------------------------------- avatar (photo frame, like the photo on an ID card) */
.avatar {
    --c: var(--d-none);
    width: 36px; height: 36px; border-radius: 8px; display: grid; place-items: center; flex: none;
    background: color-mix(in srgb, var(--c) 16%, var(--surface)); color: var(--c);
    font-weight: 600; font-size: 13px; letter-spacing: .02em; border: 1px solid color-mix(in srgb, var(--c) 30%, transparent);
}
.rail .avatar { --c: var(--cyan); background: rgba(71, 190, 224, .14); color: #8fdcf2; border-color: rgba(71, 190, 224, .3); }
.avatar.lg { width: 56px; height: 64px; font-size: 18px; border-radius: 8px; }

/* department colours */
.d-LEAD { --c: var(--d-lead); }
.d-SALES { --c: var(--d-sales); }
.d-IDCARD { --c: var(--d-idcard); }
.d-SUPPORT { --c: var(--d-support); }
.d-ADMIN { --c: var(--d-admin); }

/* ---------------------------------------------------------------- panels */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 18px 20px 0; }
.panel-head p { color: var(--ink-2); font-size: 13px; }
.panel-body { padding: 16px 20px 20px; }
.stack { display: grid; gap: 20px; }
.two-col { display: grid; gap: 20px; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); }

/* ---------------------------------------------------------------- dashboard */
.today { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.today .greet { color: var(--ink-2); font-size: 15px; }
.today h1 { font-size: 30px; margin-top: 2px; }
.today .ad { color: var(--ink-2); font-size: 14px; margin-top: 2px; }

/* season strip: the BS year as 12 months, peak months shaded. */
.season { padding: 20px; }
.season-top { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.season-top .state { font-size: 18px; font-weight: 600; }
.season-top .count { color: var(--ink-2); }
.season-top .count strong { color: var(--ink); font-size: 22px; font-weight: 600; margin-right: 4px; }
.months { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 4px; list-style: none; margin: 0; padding: 0; }
.months li {
    position: relative; padding: 26px 4px 8px; border-radius: 6px; text-align: center; font-size: 12px;
    background: var(--surface-2); color: var(--ink-3); border: 1px solid var(--line);
}
.months li.peak { background: color-mix(in srgb, var(--cyan) 14%, var(--surface)); color: var(--ink-2); border-color: color-mix(in srgb, var(--cyan) 28%, transparent); }
.months li.now { background: var(--ink); color: var(--surface); border-color: var(--ink); font-weight: 600; }
.months li.now::before {
    content: ""; position: absolute; top: 9px; left: 50%; width: 8px; height: 8px; margin-left: -4px; border-radius: 50%; background: var(--cyan);
}
.months li.peak::after { content: ""; position: absolute; top: 12px; left: 8px; right: 8px; height: 2px; border-radius: 2px; background: var(--cyan); opacity: .6; }
.months li.now.peak::after { display: none; }
.season-legend { display: flex; gap: 18px; margin-top: 12px; font-size: 12px; color: var(--ink-2); flex-wrap: wrap; }
.season-legend span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.season-legend .l-peak::before { background: color-mix(in srgb, var(--cyan) 40%, var(--surface)); }
.season-legend .l-off::before { background: var(--surface-2); border: 1px solid var(--line-strong); }
.season-legend .l-now::before { background: var(--ink); }

.figures { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin: 20px 0; }
.figure { padding: 16px 20px; border-right: 1px solid var(--line); }
.figure:last-child { border-right: 0; }
.figure .k { font-size: 13px; color: var(--ink-2); }
.figure .v { font-size: 28px; font-weight: 600; letter-spacing: -0.02em; margin-top: 2px; }
.figure .v.pending { color: var(--ink-3); font-weight: 400; font-size: 15px; padding: 10px 0 7px; }
.figure .s { font-size: 12px; color: var(--ink-3); }

.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-top: 1px solid var(--line); }
.list li:first-child { border-top: 0; }
.list .grow { flex: 1; min-width: 0; }
.list .grow small { display: block; color: var(--ink-2); font-size: 13px; }
.band-dot { width: 10px; height: 28px; border-radius: 3px; background: var(--c, var(--d-none)); flex: none; }
.count-bar { width: 72px; height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; border: 1px solid var(--line); }
.count-bar i { display: block; height: 100%; background: var(--c, var(--cyan)); }
.num { font-weight: 600; min-width: 2ch; text-align: right; }

/* ---------------------------------------------------------------- chips / status */
.chip {
    display: inline-flex; align-items: center; gap: 5px; font-size: 12px; line-height: 1; padding: 5px 8px; border-radius: 999px;
    background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); white-space: nowrap; font-weight: 500;
}
.chip.ok { background: var(--ok-weak); color: var(--ok); border-color: transparent; }
.chip.warn { background: var(--warn-weak); color: var(--warn); border-color: transparent; }
.chip.accent { background: var(--cyan-weak); color: var(--cyan-strong); border-color: transparent; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------------------------------------------------------------- staff ID cards */
.dept-section + .dept-section { margin-top: 28px; }
.dept-title { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.dept-title .band-dot { height: 18px; width: 6px; }
.dept-title .muted { font-size: 13px; }
.id-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.id-card {
    display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
    overflow: hidden; color: var(--ink); box-shadow: var(--shadow-card); transition: border-color .15s, transform .15s;
}
.id-card:hover { text-decoration: none; border-color: color-mix(in srgb, var(--c, var(--d-none)) 55%, var(--line)); transform: translateY(-1px); }
.id-band { position: relative; height: 30px; background: var(--c, var(--d-none)); color: #fff; font-size: 12px; font-weight: 500; display: flex; align-items: center; padding: 0 12px; }
.id-band::after { /* lanyard slot */
    content: ""; position: absolute; top: 9px; left: 50%; width: 34px; height: 8px; margin-left: -17px; border-radius: 4px;
    background: var(--surface); opacity: .9;
}
.id-band .role { margin-left: auto; opacity: .9; }
.id-body { display: flex; gap: 12px; padding: 14px 14px 12px; }
.id-body .who { min-width: 0; }
.id-body .name { font-weight: 600; line-height: 1.3; }
.id-body .title { color: var(--ink-2); font-size: 13px; margin-top: 1px; }
.id-body .rep { color: var(--ink-3); font-size: 12px; margin-top: 6px; }
.id-foot { margin-top: auto; padding: 10px 14px 12px; border-top: 1px dashed var(--line); }
.id-card.inactive { opacity: .6; }

/* ---------------------------------------------------------------- tables (become stacked rows on mobile) */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12.5px; color: var(--ink-2); font-weight: 600; background: var(--surface-2); }
tbody tr:last-child td { border-bottom: 0; }

/* ---------------------------------------------------------------- forms */
.form-section { padding: 20px; }
.form-section + .form-section { border-top: 1px solid var(--line); }
.form-section > h2 { margin-bottom: 4px; }
.form-section > .hint { color: var(--ink-2); font-size: 13px; margin-bottom: 16px; max-width: 70ch; }
.fields { display: grid; gap: 16px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.fields .span-2 { grid-column: span 2; }
.fields .span-all { grid-column: 1 / -1; }
.field label, .label { display: block; font-weight: 500; font-size: 13px; margin-bottom: 6px; color: var(--ink); }
input[type=text], input[type=time], input[type=search], input[type=tel], input[type=password], input[type=email], input[type=number], input[type=file], select, textarea {
    width: 100%; min-height: 42px; padding: 9px 12px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
    background: var(--surface); color: var(--ink); font: inherit; font-size: 15px;
}
textarea { min-height: 72px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--cyan); box-shadow: 0 0 0 3px color-mix(in srgb, var(--cyan) 22%, transparent); }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--ink-2) 50%), linear-gradient(135deg, var(--ink-2) 50%, transparent 50%);
         background-position: calc(100% - 17px) 50%, calc(100% - 12px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 32px; }
.check { display: flex; align-items: center; gap: 10px; font-weight: 400; font-size: 14px; cursor: pointer; min-height: 42px; }
.check input { width: 18px; height: 18px; accent-color: var(--cyan); }
.split-row { display: grid; gap: 10px; grid-template-columns: 1fr 1.4fr 110px; margin-bottom: 10px; }
.account-row { display: grid; gap: 10px; grid-template-columns: 170px 1fr 1fr; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.account-row:first-of-type { border-top: 0; }
.account-row .sys { font-weight: 500; }
.form-actions { display: flex; gap: 10px; padding: 16px 20px; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }

/* ---------------------------------------------------------------- buttons */
.btn {
    display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 8px 16px; border-radius: var(--radius-sm);
    border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); font: inherit; font-size: 14px; font-weight: 500; cursor: pointer;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.primary { background: var(--cyan); border-color: var(--cyan); color: #fff; }
[data-theme="dark"] .btn.primary { color: #06202b; }
.btn.primary:hover { background: var(--cyan-strong); border-color: var(--cyan-strong); }
.btn svg { width: 16px; height: 16px; }
.btn-ghost { display: inline-flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: transparent; color: inherit; font: inherit; font-size: 13px; cursor: pointer; }
.btn-ghost svg { width: 16px; height: 16px; }
.icon-btn { display: grid; place-items: center; width: 40px; height: 40px; border-radius: var(--radius-sm); border: 0; background: transparent; color: var(--ink-2); cursor: pointer; }
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn svg { width: 20px; height: 20px; }
.theme-toggle .moon { display: none; }
[data-theme="dark"] .theme-toggle .sun { display: none; }
[data-theme="dark"] .theme-toggle .moon { display: inline; }

/* ---------------------------------------------------------------- messages */
.flash { display: flex; gap: 10px; align-items: flex-start; background: var(--cyan-weak); color: var(--ink); border: 1px solid color-mix(in srgb, var(--cyan) 35%, transparent); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 20px; }
.alert { background: var(--danger-weak); color: var(--danger); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 16px; font-weight: 500; }
.notice { background: var(--warn-weak); color: var(--warn); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 20px; }
.notice ul { margin: 6px 0 0; padding-left: 18px; }
.empty { text-align: center; padding: 48px 20px; color: var(--ink-2); }
.empty h2 { color: var(--ink); margin-bottom: 6px; }
.empty .btn { margin-top: 16px; }

/* ---------------------------------------------------------------- sign-in (an ID card on a lanyard) */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: var(--paper);
        background-image: radial-gradient(circle at 50% -20%, color-mix(in srgb, var(--cyan) 14%, transparent), transparent 55%); }
.auth-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 20px 50px -24px rgba(22, 33, 58, .45); overflow: hidden; }
.auth-band { position: relative; background: var(--rail); color: #fff; padding: 34px 24px 20px; display: flex; align-items: center; gap: 12px; }
.auth-band::before { content: ""; position: absolute; top: 12px; left: 50%; width: 54px; height: 10px; margin-left: -27px; border-radius: 5px; background: var(--paper); }
[data-theme="dark"] .auth-band::before { background: #2a3b5e; }
.auth-band strong { font-size: 19px; font-weight: 600; display: block; }
.auth-band span { font-size: 13px; color: var(--rail-ink); }
.auth-body { padding: 22px 24px 26px; }
.auth-body h1 { font-size: 20px; margin-bottom: 4px; }
.auth-body > p { color: var(--ink-2); margin-bottom: 18px; font-size: 14px; }
.auth-body .field { margin-bottom: 14px; }
.auth-body .btn { width: 100%; justify-content: center; min-height: 44px; margin-top: 4px; }
.auth-foot { position: fixed; top: 14px; right: 14px; }

/* ---------------------------------------------------------------- responsive */
@media (max-width: 1100px) {
    .two-col { grid-template-columns: 1fr; }
    .figures { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .figure:nth-child(2) { border-right: 0; }
    .figure:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
}

@media (max-width: 900px) {
    .rail { display: none; }
    .content { margin-left: 0; padding-bottom: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom)); }
    .topbar {
        display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 20; height: 56px; padding: 0 8px 0 14px;
        background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
    }
    .topbar .brand { color: var(--ink); padding: 0; font-size: 16px; }
    .topbar .spacer { flex: 1; }
    .bottom-nav {
        display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
        height: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
        background: var(--surface); border-top: 1px solid var(--line);
    }
    .bottom-nav a, .bottom-nav button {
        display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--ink-3);
        font: inherit; font-size: 11.5px; font-weight: 500; background: none; border: 0; cursor: pointer;
    }
    .bottom-nav a:hover { text-decoration: none; }
    .bottom-nav svg { width: 22px; height: 22px; }
    .bottom-nav [aria-current="page"] { color: var(--cyan); }
    .bottom-nav form { display: contents; }
    .page { padding: 20px 16px 32px; }
    h1 { font-size: 22px; }
    .today h1 { font-size: 24px; }
    .fields { grid-template-columns: 1fr 1fr; }
    .fields .span-2 { grid-column: 1 / -1; }
}

@media (max-width: 600px) {
    body { font-size: 15px; }
    .page-head { align-items: stretch; }
    .page-head .actions { width: 100%; }
    .page-head .actions .btn { flex: 1; justify-content: center; }
    .months { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .months li { font-size: 12.5px; }
    .figures { grid-template-columns: 1fr 1fr; }
    .figure { padding: 14px 16px; }
    .figure .v { font-size: 24px; }
    .fields { grid-template-columns: 1fr; }
    .split-row { grid-template-columns: 1fr 90px; }
    .split-row > :nth-child(2) { grid-column: 1 / -1; grid-row: 2; }
    .account-row { grid-template-columns: 1fr; gap: 6px; }
    .form-actions { position: sticky; bottom: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom)); border-radius: 0; }
    .form-actions .btn { flex: 1; justify-content: center; }
    .id-grid { grid-template-columns: 1fr; }
    .panel { border-radius: var(--radius); }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; }
}

/* ================================================================ CRM, access, widgets (added with CRM phase 1) */
.rail-group { font-size: 12px; color: var(--rail-ink); opacity: .6; padding: 16px 10px 4px; font-weight: 500; }
.page--wide { max-width: none; }

/* toolbar + filters */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.toolbar .search { position: relative; flex: 1 1 260px; max-width: 420px; }
.toolbar .search svg { position: absolute; left: 11px; top: 50%; width: 18px; height: 18px; margin-top: -9px; color: var(--ink-3); pointer-events: none; }
.toolbar .search input { padding-left: 36px; }
.toolbar select { width: auto; min-width: 140px; flex: 0 1 auto; }
.segmented { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface); }
.segmented a, .segmented button { display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px; color: var(--ink-2); font: inherit; font-size: 14px; background: none; border: 0; cursor: pointer; }
.segmented a + a, .segmented button + button { border-left: 1px solid var(--line-strong); }
.segmented a:hover { text-decoration: none; background: var(--surface-2); }
.segmented [aria-current="page"], .segmented .on { background: var(--cyan-weak); color: var(--cyan-strong); font-weight: 500; }
.segmented svg { width: 16px; height: 16px; }

/* stage pill + priority */
.stage { --sc: var(--ink-3); display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 500; white-space: nowrap; }
.stage::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--sc); }
.prio { font-size: 12px; font-weight: 500; }
.prio.Hot { color: var(--danger); }
.prio.Warm { color: var(--warn); }
.prio.Cold { color: var(--cyan-strong); }
.due { font-size: 13px; color: var(--ink-2); white-space: nowrap; }
.due.overdue { color: var(--danger); font-weight: 500; }
.due.today { color: var(--warn); font-weight: 500; }

/* data table with clickable rows */
.data-table td a.row-link { color: var(--ink); font-weight: 500; }
.data-table tbody tr:hover { background: var(--surface-2); }
.data-table .sub { display: block; color: var(--ink-3); font-size: 12.5px; font-weight: 400; }
.pager { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--line); color: var(--ink-2); font-size: 13px; flex-wrap: wrap; }
.pager .actions .btn { min-height: 34px; padding: 6px 12px; }

/* mobile: tables become stacked cards */
@media (max-width: 700px) {
    .data-table thead { display: none; }
    .data-table, .data-table tbody, .data-table tr, .data-table td { display: block; width: 100%; }
    .data-table tr { padding: 12px 14px; border-bottom: 1px solid var(--line); }
    .data-table td { border: 0; padding: 2px 0; }
    .data-table td[data-label]::before { content: attr(data-label) ": "; color: var(--ink-3); font-size: 12.5px; }
    .data-table td.first::before { display: none; }
}

/* ---------------------------------------------------------------- kanban board */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(270px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 12px;
         align-items: start; scroll-snap-type: x proximity; }
.col { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); display: flex; flex-direction: column;
       max-height: calc(100vh - 200px); scroll-snap-align: start; }
.col-head { display: flex; align-items: center; gap: 8px; padding: 12px 12px 10px; border-bottom: 1px solid var(--line); position: relative; }
.col-head::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 3px; border-radius: var(--radius) var(--radius) 0 0; background: var(--sc, var(--ink-3)); }
.col-head h2 { font-size: 14px; flex: 1; }
.col-head .count { font-size: 12px; color: var(--ink-2); background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px; }
.col-body { padding: 8px; display: flex; flex-direction: column; gap: 8px; overflow-y: auto; min-height: 80px; }
.col.drop-target { border-color: var(--cyan); box-shadow: 0 0 0 3px color-mix(in srgb, var(--cyan) 20%, transparent); }
.col-more { font-size: 12.5px; color: var(--ink-2); text-align: center; padding: 6px 4px 10px; }
.kcard { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 10px 11px; cursor: grab; box-shadow: var(--shadow-card); }
.kcard:active { cursor: grabbing; }
.kcard.dragging { opacity: .45; }
.kcard.saving { opacity: .6; pointer-events: none; }
.kcard .k-name { font-weight: 500; color: var(--ink); display: block; line-height: 1.35; }
.kcard .k-name:hover { text-decoration: underline; }
.kcard .k-meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 6px; font-size: 12.5px; color: var(--ink-2); }
.kcard .k-meta .avatar { width: 22px; height: 22px; font-size: 10px; border-radius: 6px; margin-left: auto; }
.kcard .k-move { margin-top: 8px; display: none; }
.kcard .k-move select { min-height: 34px; font-size: 13px; padding: 5px 30px 5px 8px; }
.kcard.review { border-left: 3px solid var(--warn); }
@media (hover: none), (max-width: 900px) { .kcard .k-move { display: block; } .kcard { cursor: default; } }
@media (max-width: 600px) { .board { grid-auto-columns: 86%; } .col { max-height: none; } }

/* ---------------------------------------------------------------- organisation detail */
.org-head { display: flex; gap: 16px; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; margin-bottom: 20px; }
.org-head h1 { font-size: 24px; }
.org-head .meta { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 6px; color: var(--ink-2); font-size: 14px; align-items: center; }
.detail { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 20px; align-items: start; }
.facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 20px; margin: 0; }
.facts dt { font-size: 12.5px; color: var(--ink-3); }
.facts dd { margin: 2px 0 0; overflow-wrap: anywhere; }
.facts .span-all { grid-column: 1 / -1; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 18px 22px; }
.timeline li::before { content: ""; position: absolute; left: 5px; top: 7px; bottom: -7px; width: 2px; background: var(--line); }
.timeline li:last-child::before { display: none; }
.timeline li::after { content: ""; position: absolute; left: 0; top: 4px; width: 12px; height: 12px; border-radius: 50%; background: var(--surface); border: 2px solid var(--cyan); }
.timeline li.legacy::after { border-color: var(--ink-3); }
.timeline .t-head { display: flex; gap: 8px; flex-wrap: wrap; align-items: baseline; font-size: 13px; color: var(--ink-2); }
.timeline .t-head strong { color: var(--ink); font-weight: 500; }
.timeline .t-body { margin-top: 4px; white-space: pre-line; overflow-wrap: anywhere; }
.timeline .t-next { margin-top: 4px; font-size: 13px; color: var(--ink-2); }
.contact { padding: 10px 0; border-top: 1px solid var(--line); }
.contact:first-child { border-top: 0; padding-top: 0; }
.contact .c-name { font-weight: 500; }
.contact .c-meta { font-size: 13px; color: var(--ink-2); display: flex; gap: 10px; flex-wrap: wrap; }
.review-banner { background: var(--warn-weak); color: var(--warn); border-radius: var(--radius); padding: 10px 14px; margin-bottom: 16px; }
details.inline-form > summary { list-style: none; cursor: pointer; }
details.inline-form > summary::-webkit-details-marker { display: none; }
details.inline-form[open] > summary { margin-bottom: 12px; }
@media (max-width: 1000px) { .detail { grid-template-columns: 1fr; } }
@media (max-width: 600px) { .facts { grid-template-columns: 1fr; } }

/* duplicate warning */
.dupes { border: 1px solid color-mix(in srgb, var(--warn) 40%, transparent); background: var(--warn-weak); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 16px; }
.dupes strong { color: var(--warn); }
.dupes ul { margin: 8px 0 0; padding-left: 18px; }
.dupes li { margin: 3px 0; }

/* BS date field */
.bs-hint { display: block; min-height: 18px; margin-top: 4px; font-size: 12.5px; color: var(--ink-2); }
.bs-hint.bad { color: var(--danger); }
.quick { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.chip-btn { font: inherit; font-size: 12.5px; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink-2); cursor: pointer; }
.chip-btn:hover { border-color: var(--cyan); color: var(--cyan-strong); }

/* ---------------------------------------------------------------- permission matrix */
.matrix th, .matrix td { text-align: center; }
.matrix th:first-child, .matrix td:first-child { text-align: left; }
.matrix td.module { background: var(--surface-2); font-weight: 600; font-size: 12.5px; color: var(--ink-2); text-align: left; }
.matrix input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--cyan); }
@media (max-width: 600px) { .matrix th, .matrix td { padding: 8px 6px; } }

/* ---------------------------------------------------------------- dashboard widgets */
.widgets { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.widget.wide { grid-column: 1 / -1; }
.widget .w-actions { display: none; gap: 2px; margin-left: auto; }
.widgets.editing .widget { outline: 2px dashed var(--line-strong); outline-offset: 3px; }
.widgets.editing .widget .w-actions { display: inline-flex; }
.widgets.editing .widget.season .w-actions { position: absolute; top: 10px; right: 10px; }
.widget.season { position: relative; }
.w-actions .icon-btn { width: 32px; height: 32px; }
.w-actions .icon-btn svg { width: 16px; height: 16px; }
.w-empty { color: var(--ink-2); padding: 4px 0; }
.mini-list { list-style: none; margin: 0; padding: 0; }
.mini-list li { display: flex; gap: 10px; align-items: center; padding: 9px 0; border-top: 1px solid var(--line); }
.mini-list li:first-child { border-top: 0; }
.mini-list .grow { flex: 1; min-width: 0; }
.mini-list .grow a { color: var(--ink); font-weight: 500; }
.mini-list .grow small { display: block; color: var(--ink-2); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bars { display: grid; gap: 8px; }
.bar-row { display: grid; grid-template-columns: 130px 1fr 52px; gap: 10px; align-items: center; font-size: 13px; }
.bar-row a { color: var(--ink); }
.bar-row .track { height: 10px; background: var(--surface-2); border-radius: 5px; overflow: hidden; border: 1px solid var(--line); }
.bar-row .track i { display: block; height: 100%; background: var(--sc, var(--cyan)); border-radius: 5px; }
.bar-row .n { text-align: right; font-weight: 600; }
.customise { margin-bottom: 20px; }
.customise .add-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
.customise .add-item { display: flex; gap: 10px; align-items: flex-start; justify-content: space-between; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-2); }
.customise .add-item p { font-size: 12.5px; color: var(--ink-2); }
@media (max-width: 1000px) { .widgets { grid-template-columns: 1fr; } }

/* ---------------------------------------------------------------- mobile "More" menu */
.menu-user { display: flex; gap: 14px; align-items: center; padding: 16px; margin-bottom: 20px; }
.menu-group { margin-bottom: 18px; }
.menu-group h2 { font-size: 13px; color: var(--ink-2); font-weight: 500; margin: 0 0 8px 4px; }
.menu-list a, .menu-list button { display: flex; align-items: center; gap: 14px; width: 100%; padding: 14px 16px; color: var(--ink); background: none; border: 0;
    border-top: 1px solid var(--line); font: inherit; font-size: 15px; text-align: left; cursor: pointer; }
.menu-list > :first-child, .menu-list > form:first-child button { border-top: 0; }
.menu-list form { margin: 0; }
.menu-list a:hover, .menu-list button:hover { text-decoration: none; background: var(--surface-2); }
.menu-list svg { width: 20px; height: 20px; color: var(--ink-2); }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: var(--surface); padding: 10px 16px; border-radius: 8px;
         font-size: 14px; z-index: 50; box-shadow: 0 10px 30px -10px rgba(0,0,0,.5); max-width: calc(100vw - 32px); }
.toast.bad { background: var(--danger); color: #fff; }
@media (max-width: 900px) { .toast { bottom: calc(var(--bottom-nav-h) + 16px); } }

/* inline icons inside links/text default to the text size (nav, buttons and widgets set their own sizes) */
a > svg, .small > svg { width: 1em; height: 1em; vertical-align: -2px; }
.brand svg { width: 28px; height: 28px; }

/* ================================================================ Sales-app look (matches the team's Lovable app)
   White sidebar, violet gradient for the active item and main buttons, colourful number cards. Overrides the tokens
   above; both themes keep working because everything reads these variables. */
:root {
    --paper: #f5f6fb;
    --surface-2: #f8f8fd;
    --line: #e7e8f0;
    --line-strong: #d6d8e4;
    --cyan: #6d4aff;          /* accent (name kept for compatibility) */
    --cyan-strong: #5634ea;
    --cyan-weak: #f0ecff;
    --grad: linear-gradient(90deg, #6d4aff 0%, #a43df5 100%);
    --rail: #ffffff;
    --rail-ink: #4b5563;
    --rail-ink-strong: #111827;
    --rail-hover: #f4f1ff;
    --radius: 12px;
    --radius-lg: 16px;
    --shadow-card: 0 1px 2px rgba(17, 24, 39, .04), 0 4px 14px -6px rgba(17, 24, 39, .10);
}
[data-theme="dark"] {
    --paper: #0f1020;
    --surface: #171a2e;
    --surface-2: #1d2036;
    --line: #2a2e48;
    --line-strong: #363b5c;
    --cyan: #9d85ff;
    --cyan-strong: #b6a4ff;
    --cyan-weak: #27214d;
    --grad: linear-gradient(90deg, #7b5cff 0%, #b14ef7 100%);
    --rail: #131628;
    --rail-ink: #a9adc8;
    --rail-ink-strong: #ffffff;
    --rail-hover: #1f2240;
}

/* sidebar */
.rail { border-right: 1px solid var(--line); padding: 18px 14px; }
.brand { color: var(--rail-ink-strong); }
.brand .logo-tile { width: 36px; height: 36px; border-radius: 10px; background: var(--grad); display: grid; place-items: center; box-shadow: 0 6px 14px -6px rgba(109, 74, 255, .7); flex: none; }
.brand .logo-tile svg { width: 22px; height: 22px; }
.brand .brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand .brand-text small { font-size: 12px; font-weight: 400; color: var(--rail-ink); }
.rail nav a { color: var(--rail-ink); padding: 10px 12px; border-radius: 10px; }
.rail nav a:hover { background: var(--rail-hover); color: var(--rail-ink-strong); }
.rail nav a[aria-current="page"] { background: var(--grad); color: #fff; box-shadow: 0 8px 18px -10px rgba(109, 74, 255, .9); }
.rail-group { color: var(--rail-ink); opacity: .7; }
.rail-foot { border-top-color: var(--line); }
.rail .avatar { --c: var(--cyan); background: var(--grad); color: #fff; border: 0; }
.rail-actions .btn-ghost { color: var(--rail-ink); border-color: var(--line); }
.rail-actions .btn-ghost:hover { background: var(--rail-hover); color: var(--rail-ink-strong); }

/* buttons */
.btn.primary { background: var(--grad); border: 0; color: #fff; box-shadow: 0 6px 16px -8px rgba(109, 74, 255, .8); }
.btn.primary:hover { background: var(--grad); filter: brightness(1.06); }
[data-theme="dark"] .btn.primary { color: #fff; }
.btn { border-radius: 10px; }

/* panels */
.panel { border-color: var(--line); box-shadow: var(--shadow-card); }

/* sign-in band */
.auth-band { background: var(--grad); }
.auth-band span { color: rgba(255, 255, 255, .85); }
.auth-band::before { background: rgba(255, 255, 255, .55); }
[data-theme="dark"] .auth-band::before { background: rgba(255, 255, 255, .35); }

/* topbar logo tile on phones */
.topbar .brand .logo-tile { width: 30px; height: 30px; border-radius: 8px; }
.topbar .brand .logo-tile svg { width: 18px; height: 18px; }

/* ---------------------------------------------------------------- number cards (sales summary) */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.kpi { position: relative; display: block; padding: 18px 18px 16px; border-radius: var(--radius-lg); background: var(--surface); border: 1px solid var(--line);
       box-shadow: var(--shadow-card); color: var(--ink); min-height: 120px; }
.kpi:hover { text-decoration: none; transform: translateY(-1px); }
.kpi .k-label { font-size: 13px; color: var(--ink-2); }
.kpi .k-value { font-size: 30px; font-weight: 700; letter-spacing: -.02em; margin-top: 6px; line-height: 1.1; }
.kpi .k-sub { font-size: 12.5px; color: var(--ink-2); margin-top: 6px; }
.kpi .k-icon { position: absolute; top: 16px; right: 16px; width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center;
               background: var(--cyan-weak); color: var(--cyan); }
.kpi .k-icon svg { width: 20px; height: 20px; }
.kpi.fill { border: 0; color: #fff; }
.kpi.fill .k-label, .kpi.fill .k-sub { color: rgba(255, 255, 255, .88); }
.kpi.fill .k-icon { background: rgba(255, 255, 255, .22); color: #fff; }
.kpi.hot { background: linear-gradient(135deg, #ff5b4d 0%, #f7883a 100%); }
.kpi.violet { background: linear-gradient(135deg, #6d4aff 0%, #b13df5 100%); }
.kpi.amber { background: linear-gradient(135deg, #f59e0b 0%, #f2c230 100%); }
.kpi.green { background: linear-gradient(135deg, #10b981 0%, #2fd39d 100%); }
.kpi.alert { border: 2px solid color-mix(in srgb, var(--danger) 45%, transparent); }
.kpi.alert .k-value { color: var(--danger); }
.kpi.alert .k-icon { background: var(--danger-weak); color: var(--danger); }
.attention { display: flex; align-items: center; gap: 14px; padding: 14px 18px; border-radius: var(--radius-lg); color: #fff; margin-bottom: 16px;
             background: linear-gradient(90deg, #ef4444 0%, #f0544f 100%); box-shadow: 0 8px 20px -12px rgba(239, 68, 68, .9); }
.attention svg { width: 22px; height: 22px; flex: none; }
.attention strong { display: block; }
.attention .btn { margin-left: auto; background: rgba(255, 255, 255, .2); color: #fff; border: 0; min-height: 34px; }
.attention .btn:hover { background: rgba(255, 255, 255, .3); }
@media (max-width: 1100px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 420px) { .kpis { gap: 10px; } .kpi { padding: 14px; min-height: 104px; } .kpi .k-value { font-size: 24px; } .kpi .k-icon { width: 32px; height: 32px; top: 12px; right: 12px; } }

/* ---------------------------------------------------------------- priority / status pills (sales-app style) */
.pill { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill.Hot { background: #ffe4e1; color: #c2341f; }
.pill.Warm { background: #fff1d6; color: #a2600a; }
.pill.Cold { background: #e3f0ff; color: #2b5fb8; }
[data-theme="dark"] .pill.Hot { background: #4a1f1c; color: #ff9d8f; }
[data-theme="dark"] .pill.Warm { background: #43321a; color: #f4c06a; }
[data-theme="dark"] .pill.Cold { background: #1d2c48; color: #8fb8ff; }
.status-pill { --sc: var(--ink-3); display: inline-flex; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap;
               background: color-mix(in srgb, var(--sc) 14%, var(--surface)); color: color-mix(in srgb, var(--sc) 80%, var(--ink)); }
.row-actions { display: flex; gap: 4px; justify-content: flex-end; }
.row-actions a { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 8px; color: var(--ink-2); }
.row-actions a:hover { background: var(--cyan-weak); color: var(--cyan); text-decoration: none; }
.row-actions svg { width: 18px !important; height: 18px !important; }
.students { display: inline-flex; gap: 6px; align-items: center; color: var(--ink-2); }

/* ---------------------------------------------------------------- follow-up cards */
.fu-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-bottom: 18px; }
.fu-stat { display: block; padding: 16px 18px; border-radius: var(--radius-lg); background: var(--surface); border: 1px solid var(--line); color: var(--ink); box-shadow: var(--shadow-card); }
.fu-stat:hover { text-decoration: none; border-color: var(--cyan); }
.fu-stat .n { font-size: 28px; font-weight: 700; margin-top: 8px; }
.fu-stat .s { font-size: 12.5px; color: var(--ink-2); }
.fu-stat.overdue { border: 2px solid color-mix(in srgb, var(--danger) 40%, transparent); }
.fu-stat.overdue .n { color: var(--danger); }
.fu-stat[aria-current="page"] { outline: 2px solid var(--cyan); outline-offset: 2px; }
.fu-tabs { display: inline-flex; gap: 4px; background: var(--surface-2); border: 1px solid var(--line); padding: 4px; border-radius: 12px; margin-bottom: 14px; }
.fu-tabs a { padding: 7px 14px; border-radius: 9px; color: var(--ink-2); font-weight: 500; font-size: 14px; }
.fu-tabs a:hover { text-decoration: none; color: var(--ink); }
.fu-tabs a[aria-current="page"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-card); }
.fu-tabs .badge { background: var(--danger); color: #fff; border-radius: 999px; font-size: 11px; padding: 1px 7px; margin-left: 6px; }
.fu-card { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 14px; padding: 16px 18px; border-radius: var(--radius-lg); background: var(--surface);
           border: 1px solid var(--line); box-shadow: var(--shadow-card); margin-bottom: 12px; }
.fu-card.is-overdue { background: color-mix(in srgb, var(--danger) 5%, var(--surface)); border-color: color-mix(in srgb, var(--danger) 30%, var(--line)); }
.fu-card .fu-title { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.fu-card .fu-title a { font-weight: 600; font-size: 16px; color: var(--ink); }
.fu-card .fu-meta { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 6px; font-size: 13px; color: var(--ink-2); align-items: center; }
.fu-card .fu-note { margin-top: 8px; font-size: 13.5px; color: var(--ink-2); background: var(--surface-2); border-radius: 8px; padding: 8px 10px; }
.fu-card .fu-actions { display: flex; flex-direction: column; gap: 6px; min-width: 132px; }
.fu-card .fu-actions .btn { justify-content: center; min-height: 36px; padding: 6px 12px; }
.btn.wa { color: #128c4b; border-color: color-mix(in srgb, #25d366 50%, var(--line)); }
[data-theme="dark"] .btn.wa { color: #4fe08f; }
.overdue-tag { background: var(--danger-weak); color: var(--danger); border-radius: 999px; font-size: 12px; font-weight: 600; padding: 2px 9px; }
.fu-card details summary { list-style: none; }
.fu-card details summary::-webkit-details-marker { display: none; }
.fu-card .fu-form { grid-column: 1 / -1; border-top: 1px dashed var(--line); padding-top: 12px; }
@media (max-width: 700px) {
    .fu-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
    .fu-stat { padding: 12px; } .fu-stat .n { font-size: 22px; }
    .fu-card { grid-template-columns: 1fr; }
    .fu-card .fu-actions { flex-direction: row; flex-wrap: wrap; min-width: 0; }
    .fu-card .fu-actions .btn { flex: 1 1 40%; }
}
/* inline icons inside text in tables, cards and chips */
.sub svg, .students svg, .fu-meta svg, .chip svg, .k-sub svg, .due svg { width: 1em; height: 1em; vertical-align: -2px; flex: none; }
/* agreement papers */
.paper-list { list-style: none; margin: 0 0 16px; padding: 0; display: grid; gap: 10px; }
.paper-list li { display: flex; gap: 12px; align-items: center; padding: 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); }
.paper-thumb { flex: none; width: 64px; height: 84px; border-radius: 6px; overflow: hidden; background: var(--surface); border: 1px solid var(--line); display: grid; place-items: center; }
.paper-thumb img { width: 100%; height: 100%; object-fit: cover; }
.paper-thumb .pdf { font-weight: 700; font-size: 13px; color: #c2341f; }
.paper-info { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.paper-info strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.paper-info small { color: var(--ink-2); font-size: 12.5px; }
.paper-actions { display: flex; gap: 12px; flex-wrap: wrap; font-size: 13px; margin-top: 4px; }
.paper-actions button.link { font-size: 13px; } .paper-actions button.link:disabled { color: var(--ink-3); cursor: default; }
button.link.danger { color: var(--danger); }
.upload-box { border: 2px dashed var(--line-strong); border-radius: 12px; padding: 14px; display: grid; gap: 8px; }
.upload-buttons { display: flex; gap: 8px; flex-wrap: wrap; }
.upload-buttons label.btn { cursor: pointer; }
@media (hover: hover) and (pointer: fine) { .camera-only { display: none; } }
/* utility fixes */
[hidden] { display: none !important; }
button.link { background: none; border: 0; padding: 0; color: var(--cyan); cursor: pointer; font: inherit; }
button.link:hover:not(:disabled) { text-decoration: underline; text-underline-offset: 3px; }
.rail-user .who a { display: block; margin-top: 2px; }

/* ---------- daily tasks ---------- */
.task-progress { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 14px 18px; margin-bottom: 14px; box-shadow: var(--shadow-card); }
.tp-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 8px; }
.tp-bar { display: block; height: 8px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); overflow: hidden; }
.tp-bar > span { display: block; height: 100%; background: var(--grad, var(--cyan)); border-radius: inherit; transition: width .3s ease; }
.tp-bar.small { height: 5px; margin-top: 5px; max-width: 160px; }
@media (prefers-reduced-motion: reduce) { .tp-bar > span { transition: none; } }
.task-card.prio-1 { border-left: 4px solid var(--danger); }
.task-card .t-title { font-weight: 600; font-size: 16px; color: var(--ink); }
.task-card .fu-actions .btn.primary svg { width: 16px; height: 16px; }
.task-card .chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.finished { margin-top: 18px; }
.finished > summary, details.panel > summary { cursor: pointer; list-style: none; }
details.panel > summary::-webkit-details-marker { display: none; }
.done-row { display: flex; gap: 10px; align-items: flex-start; }
.done-row > div { flex: 1; min-width: 0; }
.done-row .sub, .approve-list .sub { display: block; color: var(--ink-2); font-size: 13px; margin-top: 2px; }
.section-title { font-size: 17px; margin: 26px 0 12px; display: flex; align-items: center; gap: 8px; }
.section-title .badge, .approve-group .badge { background: var(--cyan-weak); color: var(--cyan-strong); border-radius: 999px; font-size: 12.5px; padding: 1px 9px; }
.approve-list > li { display: flex; gap: 12px; align-items: flex-start; }
.approve-list > li > input[type=checkbox] { width: 18px; height: 18px; margin-top: 3px; accent-color: var(--cyan); flex: none; }
.approve-list .a-body { flex: 1; min-width: 0; }
.approve-list .a-title { font-weight: 500; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.approve-list .a-title a { color: var(--ink); }
.bulk-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.bulk-actions input[type=text] { flex: 1 1 220px; min-width: 0; }
.progress-table .chip { margin-left: 6px; }
.edit-dialog { border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); color: var(--ink); padding: 20px; width: min(560px, calc(100vw - 32px)); box-shadow: var(--shadow-card); }
.edit-dialog::backdrop { background: rgba(10, 16, 30, .45); }
.edit-dialog h2 { margin-top: 0; }
.edit-dialog .actions { display: flex; gap: 8px; margin-top: 12px; }
.edit-dialog .reassign { border-top: 1px dashed var(--line); margin-top: 16px; padding-top: 14px; display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.edit-dialog .reassign .field { flex: 1 1 220px; margin: 0; }
.inline-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.inline-form strong { min-width: 96px; }
input.narrow { width: 96px; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
details.panel + details.panel, details.panel + section.panel, .approve-group + .approve-group { margin-top: 12px; }
input[type=time] { width: auto; }

/* AI plan panel */
.ai-panel .panel-head h2 { display: flex; align-items: center; gap: 8px; }
.ai-panel .panel-head h2 svg { width: 20px; height: 20px; color: var(--cyan); }
.ai-meta { color: var(--ink-2); font-size: 13.5px; margin: 0 0 8px; }
.ai-summary { background: var(--cyan-weak); color: var(--ink); border-radius: var(--radius); padding: 10px 12px; margin: 0 0 12px; }
.small-title { font-size: 14px; margin: 10px 0 6px; }
.ai-insights > li { display: flex; gap: 12px; justify-content: space-between; align-items: flex-start; }
.ai-insights > li.dim { opacity: .55; }
.ai-insights .row-actions { display: flex; gap: 10px; flex: none; }
.ai-reason { font-style: italic; }

/* Support widget */
.sup-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.sup-stats > div { background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.sup-stats .v { display: block; font-size: 22px; font-weight: 700; line-height: 1.2; }
.sup-stats .l { display: block; font-size: 12px; color: var(--ink-2); }
.sup-stats .warn { border-color: color-mix(in srgb, var(--warn) 45%, transparent); }
.sup-stats .warn .l { color: var(--warn); }
.w-sub { font-size: 13px; font-weight: 600; margin: 16px 0 8px; }
.w-sub .muted { font-weight: 400; }
.wk-chart { display: flex; align-items: flex-end; gap: 2px; height: 90px; border-bottom: 1px solid var(--line); }
.wk { position: relative; flex: 1; height: 100%; display: flex; align-items: flex-end; outline: none; }
.wk i { display: block; width: 100%; background: var(--cyan); border-radius: 4px 4px 0 0; opacity: .85; }
.wk:hover i, .wk:focus i { opacity: 1; }
.wk .tip { display: none; position: absolute; bottom: calc(100% + 4px); left: 50%; transform: translateX(-50%); z-index: 2;
           background: var(--ink); color: var(--surface); font-size: 12px; padding: 4px 8px; border-radius: 6px; white-space: nowrap; pointer-events: none; }
.wk:first-child .tip { left: 0; transform: none; }
.wk:last-child .tip { left: auto; right: 0; transform: none; }
.wk:hover .tip, .wk:focus .tip { display: block; }
.wk-axis { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--ink-2); margin-top: 4px; }
.bar-row a { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 520px) { .sup-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* Scorecards */
.vs { display: block; font-size: 11.5px; color: var(--ink-2); margin-top: 2px; font-weight: 400; }
.vs.up { color: var(--cyan-strong); font-weight: 500; }
.vs.up::before { content: "\25B2  "; font-size: 9px; }
.vs.down::before { content: "\25BC  "; font-size: 9px; }
.score-table .team-row td { background: var(--surface-2); font-weight: 500; }
.score-table .group-row td { color: var(--ink-2); font-size: 12.5px; padding-top: 18px; }
.score-table td .sub { display: block; }
.kpi .vs { margin-top: 6px; }
