/* Inter (SIL Open Font License, see ../fonts/inter/LICENSE.txt), self-hosted variable font. */
@font-face { font-family: "Inter"; font-style: normal; font-weight: 100 900; font-display: swap; src: url("../fonts/inter/InterVariable.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-style: italic; font-weight: 100 900; font-display: swap; src: url("../fonts/inter/InterVariable-Italic.woff2") format("woff2"); }

:root {
    /* Theme colors - every value can be overridden under School Settings > Theme
       (App\Services\ThemeService prints the overrides after this file). */
    --color-nav-bg: #262c31;
    --color-nav-text: #c4ccd2;
    --color-nav-heading: #8a959e;
    --color-nav-active-bg: #244662;
    --color-nav-active-text: #ffffff;
    --color-nav-border: #3e474e;
    --color-bg: #f3f5f7;
    --color-surface: #ffffff;
    --color-border: #dce1e5;
    --color-text: #262c31;
    --color-muted: #5c6670;
    --color-primary: #244662;
    --color-primary-dark: #1a3349;
    --color-button-text: #ffffff;
    --color-secondary: #6b757e;
    --color-table-head: #edf0f3;
    --color-table-hover: #f9fafb;
    --color-table-sort: #e2e7eb;
    --color-table-sorted: #d8e1ea;
    --color-tag-bg: #e3e8ed;
    --color-success-bg: #e7f3ea;
    --color-success-text: #2c5c37;
    --color-warning-bg: #fdf3dc;
    --color-warning-text: #7a5a12;
    --color-danger-bg: #fbe9e5;
    --color-danger: #b3432b;
    --color-code-bg: #262c31;
    --color-code-text: #c4ccd2;
    --radius: 6px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "Inter", -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    font-size: 14px;
}

a { color: var(--color-primary-dark); }

.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: 220px;
    flex-shrink: 0;
    background: var(--color-nav-bg);
    color: var(--color-nav-text);
    padding: 16px 0;
}
/* Brand with the collapse button beside it at the top right. */
.sidebar-top { display: flex; align-items: flex-start; gap: 6px; padding: 0 8px 16px 16px; }
.sidebar-brand { flex: 1 1 auto; min-width: 0; font-weight: 700; font-size: 16px; }
.sidebar-brand a { color: var(--color-nav-active-text); text-decoration: none; }
.sidebar-collapse {
    flex: 0 0 auto; display: flex; align-items: center; justify-content: center;
    margin: 0; padding: 4px; background: none; border: none; border-radius: 4px;
    color: var(--color-nav-heading); line-height: 0; cursor: pointer;
}
.sidebar-collapse:hover { background: var(--color-nav-active-bg); color: var(--color-nav-active-text); }
.sidebar-collapse .nav-icon { transition: transform .15s ease; }
.nav-icon { flex: 0 0 18px; width: 18px; height: 18px; }
.nav-section { margin-bottom: 6px; }
.nav-section-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
    margin: 0;
    padding: 8px 16px;
    background: none;
    border: none;
    font: inherit;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--color-nav-heading);
    cursor: pointer;
    text-align: left;
}
.nav-section-title:hover { color: var(--color-nav-text); }
/* A section that is a single link (Media Library): a heading you click straight through. */
.nav-section-link { text-decoration: none; }
.nav-section-link.active { background: var(--color-nav-active-bg); color: var(--color-nav-active-text); }
/* The label grows to fill the row and stays left-aligned even when it wraps to two
   lines; the arrow indicator keeps a fixed size at the end instead of also stretching. */
.nav-section-title > .nav-label { flex: 1 1 auto; text-align: left; }
.nav-section-indicator { flex: 0 0 auto; font-size: 20px; transition: transform .15s ease; line-height: 15px; }
.nav-section-indicator::before { content: '\25B8'; }
/* Direct-child combinators here so a nested subsection's own open/closed state
   isn't overridden by its parent section merely being open. */
.nav-section.open > .nav-section-title .nav-section-indicator { transform: rotate(90deg); }
.nav-section-links { display: none; padding-bottom: 12px; }
.nav-section.open > .nav-section-links { display: block; }
.nav-link {
    display: block;
    padding: 6px 16px 6px 24px;
    color: var(--color-nav-text);
    text-decoration: none;
}
.nav-link:hover, .nav-link.active { background: var(--color-nav-active-bg); color: var(--color-nav-active-text); }
/* Top-level links (Admin Guide, Account Settings) align with the Log out button, not the indented section links. */
.nav-link-top { display: flex; align-items: center; gap: 10px; padding-left: 16px; }
.nav-logout { display: flex; align-items: center; gap: 10px; }
/* Live contact search under Dashboard (contact-search.js); results list below the box, in the sidebar. */
.contact-search { padding: 6px 16px 8px; }
.contact-search-icon { display: none; }
.contact-search input { width: 100%; margin: 0; padding: 6px 8px; font-size: 13px; background: var(--color-nav-active-bg); color: var(--color-nav-active-text); border: 1px solid var(--color-nav-border); border-radius: var(--radius); }
.contact-search input::placeholder { color: var(--color-nav-heading); }
.contact-search-results { list-style: none; margin: 6px 0 0; padding: 0; max-height: 60vh; overflow-y: auto; border: 1px solid var(--color-nav-border); border-radius: var(--radius); }
.contact-search-results a { display: flex; justify-content: space-between; gap: 6px; padding: 6px 8px; font-size: 13px; color: var(--color-nav-text); text-decoration: none; }
.contact-search-results a:hover, .contact-search-results a.is-active { background: var(--color-nav-active-bg); color: var(--color-nav-active-text); }
.contact-search-status { flex-shrink: 0; font-size: 11px; color: var(--color-nav-heading); }
.contact-search-empty { padding: 6px 8px; font-size: 12px; color: var(--color-nav-heading); }
.nav-subsection { margin: 2px 0; }
/* A sub-category heading reads as one of the links, not a distinct all-caps label —
   same font size/weight/color and left position as .nav-link. The arrow indicator has
   no color of its own, so it inherits this and matches automatically. */
.nav-subsection > .nav-section-title {
    padding: 6px 16px 6px 24px;
    font-size: 14px;
    text-transform: none;
    letter-spacing: normal;
    color: var(--color-nav-text);
}
/* Links under a sub-heading sit one level deeper than the sub-heading itself. */
.nav-subsection .nav-link { padding-left: 32px; }
.nav-subsection > .nav-section-title:hover { color: var(--color-nav-active-text); }
.nav-subsection > .nav-section-links { padding-bottom: 4px; }
/* App version, last thing in the sidebar. */
.sidebar-version { padding: 12px 16px 0; font-size: 11px; color: var(--color-nav-heading); }
/* School # from config.local.php ('school_number'), just above the version. */
.sidebar-school-number { padding: 12px 16px 0; font-size: 11px; color: var(--color-nav-heading); opacity: .75; }
.sidebar-school-number + .sidebar-version { padding-top: 2px; }
/* Settings fixed in config.local.php (config_lock()). */
.config-locked { background: var(--color-table-head); cursor: not-allowed; }
/* Config/release version mismatch (Super Admins): a warning icon that opens the message. */
.version-warning { display: inline; }
.version-warning > summary { display: inline-flex; vertical-align: middle; margin-left: 4px; cursor: pointer; list-style: none; color: #f0b429; }
.version-warning > summary::-webkit-details-marker { display: none; }
.version-warning > summary .nav-icon { width: 14px; height: 14px; }
.sidebar-version { position: relative; }
/* Opens above the version line (it's at the bottom of the menu). */
.version-warning-message { position: absolute; left: 12px; right: 12px; bottom: calc(100% + 6px); z-index: 50; box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2); padding: 8px 10px; border-radius: 6px; background: var(--color-warning-bg); color: var(--color-warning-text); font-size: 12px; line-height: 1.4; }

/* Collapsed sidebar (desktop only; .nav-collapsed on .app-shell, toggled by the button at the
   top): a 60px column of icons. Labels stay readable to screen readers; each section's links,
   the contact search and the top links' names open as fly-outs to the right. */
@media (min-width: 861px) {
    .app-shell.nav-collapsed .sidebar { width: 60px; }
    .nav-collapsed .sidebar-top { justify-content: center; padding: 0 0 12px; }
    .nav-collapsed .sidebar-brand { display: none; }
    .nav-collapsed .sidebar-version { padding: 12px 0 0; text-align: center; font-size: 10px; }
    .nav-collapsed .sidebar-school-number { padding: 12px 0 0; text-align: center; font-size: 10px; }
    .nav-collapsed .version-warning > summary { margin: 4px 0 0; }
    /* Out of the 60px column, beside the sidebar. */
    .nav-collapsed .version-warning-message { position: fixed; left: 68px; right: auto; bottom: 16px; width: 300px; text-align: left; }
    .nav-collapsed .sidebar-collapse .nav-icon { transform: rotate(180deg); }
    .nav-collapsed .sidebar > .nav-section { position: relative; }
    .nav-collapsed .sidebar > .nav-section > .nav-section-title,
    .nav-collapsed .nav-link-top,
    .nav-collapsed .nav-logout { justify-content: center; padding: 10px 0; }
    .nav-collapsed .sidebar > .nav-section > .nav-section-title > .nav-label,
    .nav-collapsed .nav-link-top > .nav-label,
    .nav-collapsed .nav-logout > .nav-label {
        position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
    }
    .nav-collapsed .sidebar > .nav-section > .nav-section-title > .nav-section-indicator { display: none; }
    .nav-collapsed .sidebar > .nav-section > .nav-section-title { color: var(--color-nav-text); }
    .nav-collapsed .sidebar > .nav-section.has-active > .nav-section-title,
    .nav-collapsed .sidebar > .nav-section:hover > .nav-section-title,
    .nav-collapsed .sidebar > .nav-section.flyout-open > .nav-section-title { background: var(--color-nav-active-bg); color: var(--color-nav-active-text); }

    /* Section fly-outs, headed by the section name. */
    .nav-collapsed .sidebar > .nav-section > .nav-section-links {
        display: none; position: absolute; left: 100%; top: 0; z-index: 1000;
        min-width: 220px; max-width: 280px; padding: 0 0 8px;
        background: var(--color-nav-bg); border: 1px solid var(--color-nav-border); border-left: none;
        border-radius: 0 var(--radius) var(--radius) 0; box-shadow: 4px 4px 16px rgba(0,0,0,.3);
    }
    .nav-collapsed .sidebar > .nav-section:hover > .nav-section-links,
    .nav-collapsed .sidebar > .nav-section:focus-within > .nav-section-links,
    .nav-collapsed .sidebar > .nav-section.flyout-open > .nav-section-links { display: block; }
    .nav-collapsed .sidebar > .nav-section > .nav-section-links::before {
        content: attr(data-label); display: block; padding: 10px 16px 6px;
        font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--color-nav-heading);
    }
    .nav-collapsed .sidebar > .nav-section > .nav-section-links .nav-link { padding-left: 16px; }
    .nav-collapsed .sidebar > .nav-section > .nav-section-links .nav-subsection > .nav-section-title { padding-left: 16px; }
    .nav-collapsed .sidebar > .nav-section > .nav-section-links .nav-subsection .nav-link { padding-left: 28px; }

    /* Top links and Log out: just the name beside the icon. */
    .nav-collapsed .nav-link-top, .nav-collapsed .nav-logout { position: relative; }
    .nav-collapsed .nav-section-link:hover::after, .nav-collapsed .nav-section-link:focus-visible::after,
    .nav-collapsed .nav-link-top:hover::after, .nav-collapsed .nav-link-top:focus-visible::after,
    .nav-collapsed .nav-logout:hover::after, .nav-collapsed .nav-logout:focus-visible::after {
        content: attr(data-label); position: absolute; left: 100%; top: 50%; transform: translateY(-50%); z-index: 1000;
        padding: 6px 12px; white-space: nowrap; font-size: 13px;
        background: var(--color-nav-active-bg); color: var(--color-nav-active-text);
        border-radius: 0 var(--radius) var(--radius) 0; box-shadow: 4px 4px 16px rgba(0,0,0,.3);
    }
    .nav-collapsed .nav-logout:hover { text-decoration: none; background: var(--color-nav-active-bg); color: var(--color-nav-active-text); }

    /* Contact search: a search icon; the box and its results open beside it. */
    .nav-collapsed .contact-search { position: relative; padding: 0; }
    .nav-collapsed .contact-search-icon { display: flex; justify-content: center; padding: 10px 0; color: var(--color-nav-text); cursor: pointer; }
    .nav-collapsed .contact-search:hover > .contact-search-icon,
    .nav-collapsed .contact-search:focus-within > .contact-search-icon { background: var(--color-nav-active-bg); color: var(--color-nav-active-text); }
    .nav-collapsed .contact-search-panel {
        display: none; position: absolute; left: 100%; top: 0; z-index: 1000; width: 280px; padding: 8px;
        background: var(--color-nav-bg); border: 1px solid var(--color-nav-border); border-left: none;
        border-radius: 0 var(--radius) var(--radius) 0; box-shadow: 4px 4px 16px rgba(0,0,0,.3);
    }
    .nav-collapsed .contact-search:hover > .contact-search-panel,
    .nav-collapsed .contact-search:focus-within > .contact-search-panel { display: block; }
}
@media (max-width: 860px) {
    .sidebar-collapse { display: none; }
}

.main-content { flex: 1; padding: 24px 32px; max-width: 1280px; }

h1, h2, h3 { margin-top: 0; }

.alert { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 16px; }
.alert-success { background: var(--color-success-bg); color: var(--color-success-text); }
.alert-error { background: var(--color-danger-bg); color: var(--color-danger); }
.alert-warning { background: var(--color-warning-bg); color: var(--color-warning-text); }
.alert ul { margin: 0; padding-left: 18px; }
.alert[hidden] { display: none; }

.contact-map { height: 620px; border: 1px solid var(--color-border); border-radius: var(--radius); margin-bottom: 8px; }
/* The site-wide button style mustn't leak into Google's map controls (zoom, fullscreen, info window close). */
.contact-map .gm-style button { padding: 0; border-radius: 0; font-size: inherit; }
.contact-map-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12px; color: var(--color-muted); margin-bottom: 16px; }
.contact-map-legend span { display: inline-flex; align-items: center; gap: 6px; }
.contact-map-legend i { width: 12px; height: 12px; border-radius: 50%; border: 1px solid rgba(0, 0, 0, 0.35); }
.contact-map-info { font-size: 13px; line-height: 1.45; color: #262c31; max-width: 260px; }
.contact-map-info strong { font-size: 14px; }
.contact-map-info ul { margin: 4px 0 0; padding-left: 16px; }
.appt-follow-up summary { cursor: pointer; color: var(--color-primary); font-size: 12px; }
.appt-follow-up form { margin-top: 6px; min-width: 220px; }
.appt-follow-up label { font-size: 12px; }

/* Drag-to-reorder rows (row-reorder.js) */
button.drag-handle, button.drag-handle:hover {
    background: none;
    color: var(--color-muted);
    padding: 2px 6px;
    margin-right: 4px;
    font-size: 16px;
    line-height: 1;
    cursor: grab;
    touch-action: none;
    vertical-align: middle;
}
button.drag-handle:hover, button.drag-handle:focus-visible { color: var(--color-primary-dark); }
/* Keep the handle and checkbox side by side instead of stacking. */
table.data-table td.row-select-cell { white-space: nowrap; }
table.data-table tr.is-dragging { opacity: 0.6; outline: 2px dashed var(--color-primary); }
table.data-table tr.is-dragging button.drag-handle { cursor: grabbing; }

/* Click-to-change division status (division-status.js) */
button.status-edit, button.status-edit:hover {
    background: none;
    color: inherit;
    padding: 0;
    font: inherit;
    border-bottom: 1px dotted var(--color-muted);
    border-radius: 0;
    cursor: pointer;
}
button.status-edit:hover, button.status-edit:focus-visible { color: var(--color-primary-dark); border-bottom-color: currentColor; }
/* The global button { display:inline-block } would otherwise override [hidden] while the editor is open. */
button.status-edit[hidden] { display: none; }
.status-editor { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.status-editor select { width: auto; margin: 0; padding: 3px 6px; }
.status-editor button { padding: 3px 9px; font-size: 14px; line-height: 1.2; }
.status-editor button.status-save, .status-editor button.status-save:hover { background: var(--color-success-text); }
.status-editor button.status-cancel, .status-editor button.status-cancel:hover { background: var(--color-danger); }
.status-editor button:disabled { opacity: .6; cursor: wait; }
.status-message { font-size: 12px; color: var(--color-muted); }
.status-message.is-error { color: var(--color-danger); white-space: normal; }

.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 20px;
}

/* "How to set this up" box at the top of an integration settings page. */
.setup-guide > summary { cursor: pointer; font-weight: 600; }
.setup-guide[open] > summary { margin-bottom: 12px; }
.setup-guide p, .setup-guide li { font-size: 14px; line-height: 1.5; }
.setup-guide ol { margin: 8px 0 12px; padding-left: 22px; }
.setup-guide li { margin-bottom: 6px; }
.setup-guide h3 { font-size: 15px; margin: 16px 0 4px; }
.setup-guide code { background: var(--color-table-head); padding: 1px 4px; border-radius: 3px; }
.provider-note:empty { display: none; }

/* Automations > AI Assistant: the conversation, then the plan of reviewable actions. */
.assistant-chat { display: flex; flex-direction: column; gap: 10px; margin-bottom: 20px; }
.assistant-msg { max-width: 760px; padding: 10px 14px; border-radius: var(--radius); border: 1px solid var(--color-border); background: var(--color-surface); }
.assistant-msg p { margin: 0 0 8px; }
.assistant-msg > :last-child { margin-bottom: 0; }
.assistant-msg-user { align-self: flex-end; background: var(--color-tag-bg); }
.assistant-who { display: block; font-size: 12px; font-weight: 600; color: var(--color-muted); margin-bottom: 4px; }
.assistant-plan h2 { margin-top: 0; }
.assistant-action { padding: 10px 0; border-top: 1px solid var(--color-border); }
.assistant-action .checkbox-row { margin-bottom: 0; align-items: flex-start; }
.assistant-action .checkbox-row input { margin-top: 3px; }
.assistant-action p { margin: 6px 0 0; }
.assistant-action-skipped, .assistant-action-done { opacity: .8; }
.assistant-details { margin: 4px 0 0; padding-left: 46px; font-size: 14px; color: var(--color-muted); }
.assistant-preview { margin: 6px 0 0 26px; font-size: 14px; }
.assistant-preview summary { cursor: pointer; color: var(--color-primary); }
.assistant-email { border: 1px solid var(--color-border); border-radius: var(--radius); padding: 8px 12px; background: var(--color-bg); overflow-wrap: anywhere; }
.assistant-error { color: var(--color-danger); }

/* Check-in QR code beside a short explanation (contact page, portal). */
.qr-card { display: flex; gap: 16px; align-items: center; }
.qr-card [data-qr] { flex: 0 0 auto; line-height: 0; }
.qr-card h2 { margin-top: 0; }
/* Contact page: Style student IDs at the top of Programs & ranks. */
.detail-list.style-id-list { margin-bottom: 16px; }
.detail-list.style-id-list dt { color: var(--color-text); }
@media (max-width: 600px) { .qr-card { flex-direction: column; text-align: center; } }

/* Administration > Student QR Codes: one section per program; each prints on its own page. */
.qr-program { margin-bottom: 28px; }
.qr-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.qr-tile {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 12px 8px;
    text-align: center;
    break-inside: avoid;
    page-break-inside: avoid;
}
.qr-tile [data-qr] { display: flex; justify-content: center; line-height: 0; }
.qr-tile-name { display: block; margin-top: 6px; font-weight: 600; font-size: 13px; color: var(--color-text); text-decoration: none; }
@media print {
    .qr-program + .qr-program { break-before: page; page-break-before: always; }
    .qr-grid { grid-template-columns: repeat(4, 1fr); }
}

table { border-collapse: collapse; width: 100%; background: var(--color-surface); }
table.data-table th, table.data-table td {
    padding: 8px 10px;
    border-bottom: 1px solid var(--color-border);
    text-align: left;
    font-size: 13px;
}
table.data-table th { background: var(--color-table-head); font-weight: 600; }
table.data-table th a { color: inherit; text-decoration: none; }
table.data-table tbody tr:hover { background: var(--color-table-hover); }
/* nowrap keeps the sort arrow on the same line as a short heading like "Amount". */
table.data-table th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
/* A header that sorts on the server (a link that reloads the list); looks like th.sortable. */
table.data-table th.server-sort { white-space: nowrap; padding: 0; }
table.data-table th.server-sort a { display: block; padding: 8px 10px; color: inherit; text-decoration: none; }
table.data-table th.server-sort a:hover { background: var(--color-table-sort); }
table.data-table th.server-sort.sort-asc,
table.data-table th.server-sort.sort-desc { background: var(--color-table-sorted); color: var(--color-primary-dark); }
table.data-table th.server-sort.sort-asc a::after { content: '\25B2'; font-size: 9px; margin-left: 6px; vertical-align: 0.15em; }
table.data-table th.server-sort.sort-desc a::after { content: '\25BC'; font-size: 9px; margin-left: 6px; vertical-align: 0.15em; }
table.data-table th.sortable:hover { background: var(--color-table-sort); }
table.data-table th.sortable::after { content: ''; display: inline-block; margin-left: 6px; width: 0; height: 0; }
table.data-table th.sortable.sort-asc,
table.data-table th.sortable.sort-desc { background: var(--color-table-sorted); color: var(--color-primary-dark); }
/* A real (not 0x0) box with line-height 1, nudged up so the arrow centres on the heading text. */
table.data-table th.sortable.sort-asc::after,
table.data-table th.sortable.sort-desc::after { width: auto; height: auto; font-size: 9px; line-height: 1; vertical-align: 0.15em; }
table.data-table th.sortable.sort-asc::after { content: '\25B2'; }
table.data-table th.sortable.sort-desc::after { content: '\25BC'; }

.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }

.tsd-filter-form {
    display: flex;
    gap: 12px;
    /* Fields line up along the top, so a tall one (a multi-select) doesn't push the rest down. */
    align-items: flex-start;
    flex-wrap: wrap;
    margin-bottom: 16px;
    padding: 12px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
}
.tsd-filter-form label { display: flex; flex-direction: column; font-size: 12px; color: var(--color-muted); gap: 4px; }
/* A row of checkboxes in a filter (Outgoing Email Queue types). */
.tsd-filter-form .filter-checks { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 0; padding: 0; border: 0; min-width: 0; }
.tsd-filter-form .filter-checks legend { font-size: 12px; color: var(--color-muted); padding: 0; margin-bottom: 4px; }
.tsd-filter-form .filter-checks .checkbox-row { flex-direction: row; margin-bottom: 0; font-size: 13px; color: inherit; }
/* Items without a caption above them (buttons, links, a lone checkbox) start level with the fields. */
.tsd-filter-form > button, .tsd-filter-form > a, .tsd-filter-form > noscript > button, .tsd-filter-form > label.checkbox-row { margin-top: 20px; }
.tsd-filter-form > a { padding: 8px 0; }

label { display: block; margin-bottom: 12px; font-size: 13px; }
label[hidden] { display: none; }
/* A fieldset is as wide as its widest child by default (min-width: min-content), so a wide
   table inside one pushed the page sideways instead of scrolling. */
fieldset { min-width: 0; }
input[type=text], input[type=password], input[type=number], input[type=date],
input[type=email], input[type=tel], input[type=url], select, textarea {
    width: 100%;
    padding: 7px 9px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 13px;
    font-family: inherit;
    margin-top: 4px;
}
textarea { min-height: 70px; }

/* WYSIWYG email editor (assets/js/wysiwyg.js). The editing surface itself stays white:
   it previews the email, not this app's theme. */
.wysiwyg { margin: 4px 0 12px; border: 1px solid var(--color-border); border-radius: var(--radius); background: var(--color-surface); overflow: hidden; }
.wysiwyg-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; padding: 6px; background: var(--color-table-head); border-bottom: 1px solid var(--color-border); }
.wysiwyg-toolbar button {
    min-width: 30px; padding: 4px 8px; margin: 0; font-size: 12px; line-height: 1.4;
    background: var(--color-surface); color: var(--color-text); border: 1px solid var(--color-border); border-radius: 4px; cursor: pointer;
}
.wysiwyg-toolbar button:hover:not(:disabled) { border-color: var(--color-primary); }
.wysiwyg-toolbar button.is-active { background: var(--color-tag-bg); border-color: var(--color-primary); }
.wysiwyg-toolbar button:disabled { opacity: .45; cursor: default; }
.wysiwyg-toolbar select { width: auto; margin: 0; padding: 4px 6px; font-size: 12px; }
.wysiwyg-toolbar .wysiwyg-insert { max-width: 220px; }
.wysiwyg-toolbar input[type=color] { width: 30px; height: 26px; padding: 1px; margin: 0; border: 1px solid var(--color-border); border-radius: 4px; background: var(--color-surface); cursor: pointer; }
.wysiwyg-toolbar .wysiwyg-source { margin-left: auto; }
.wysiwyg-sep { width: 1px; align-self: stretch; margin: 2px 2px; background: var(--color-border); }
.wysiwyg-frame { display: block; width: 100%; border: 0; background: #ffffff; }
.wysiwyg-frame[hidden] { display: none; }
.wysiwyg .wysiwyg-source-area {
    display: block; margin: 0; border: 0; border-radius: 0; min-height: 260px; resize: vertical;
    font-family: Consolas, Menlo, monospace; font-size: 12px; line-height: 1.5;
}
.wysiwyg .wysiwyg-source-area[hidden] { display: none; }
.template-preview { display: block; width: 100%; height: 480px; border: 1px solid var(--color-border); border-radius: var(--radius); background: #ffffff; }
.placeholder-table code { white-space: nowrap; }

.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px 20px; }
.form-grid .full { grid-column: 1 / -1; }
.checkbox-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.checkbox-row input { width: auto; margin: 0; }
.checkbox-group { display: flex; flex-wrap: wrap; gap: 14px; margin-bottom: 12px; }

.checkbox-group-fieldset { border: none; padding: 0; margin: 0 0 16px; }
.checkbox-group-fieldset legend { font-size: 13px; font-weight: 600; padding: 0; margin-bottom: 4px; }

form h3 { font-size: 14px; margin: 24px 0 12px; padding-top: 16px; border-top: 1px solid var(--color-border); }
form h3:first-child { margin-top: 0; padding-top: 0; border-top: none; }

.diagnostic-log {
    background: var(--color-code-bg);
    color: var(--color-code-text);
    padding: 14px 16px;
    border-radius: var(--radius);
    font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace;
    font-size: 12px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
    overflow-x: auto;
}

button, .button {
    display: inline-block;
    background: var(--color-primary);
    color: var(--color-button-text);
    border: none;
    padding: 8px 16px;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 13px;
    text-decoration: none;
}
button:hover, .button:hover { background: var(--color-primary-dark); }
.button-secondary { background: var(--color-secondary); }
.button-danger { background: var(--color-danger); }
.link-button { background: none; border: none; color: var(--color-nav-text); padding: 6px 16px; cursor: pointer; font-size: 13px; text-align: left; width: 100%; }
.link-button:hover { text-decoration: underline; background: none; }

.login-wrap { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-form { background: var(--color-surface); padding: 32px; border-radius: var(--radius); width: 320px; border: 1px solid var(--color-border); }
.login-form h1 { font-size: 18px; margin-bottom: 20px; }
.login-form button { width: 100%; margin-top: 8px; }
.login-form p { text-align: center; margin: 16px 0; font-size: 13px; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; background: var(--color-table-head); }
.badge-success { background: var(--color-success-bg); color: var(--color-success-text); }
.badge-danger { background: var(--color-danger-bg); color: var(--color-danger); }
/* System Upgrade log */
.upgrade-log { border-top: 1px solid var(--color-border); padding: 10px 0; }
.upgrade-log > summary { cursor: pointer; }
.upgrade-log h3 { margin: 12px 0 4px; font-size: 14px; }
.upgrade-steps { margin: 8px 0; padding-left: 22px; font-size: 13px; }
.upgrade-steps time { color: var(--color-muted); font-variant-numeric: tabular-nums; margin-right: 6px; }
.upgrade-step-error { color: var(--color-danger); }
/* E/W after a judge's name: incomplete practical/written testing on file in Judge Management (Ring Judges, Ring Assignments). */
.name-flag { font-size: 11px; font-weight: 700; color: var(--color-warning-text); }
.text-muted { color: var(--color-muted); }

/* Student Portal Invitations: a student's family, listed under their name. */
.invite-family { list-style: none; margin: 6px 0 0; padding: 0 0 0 14px; border-left: 2px solid var(--color-border); font-size: 13px; }
.invite-family li { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 10px; padding: 3px 0; min-width: 0; overflow-wrap: anywhere; }
.invite-family-name { display: inline-flex; align-items: center; gap: 6px; min-width: 0; }
.invite-family input[type=checkbox] { margin: 0; }
.pagination { display: flex; gap: 6px; margin-top: 12px; }
.actions-col { white-space: nowrap; }
/* Contacts list: a small photo column, and the row's buttons in up to four per line (two lines). */
.photo-col { width: 52px; }
.contact-thumb { display: block; width: 44px; height: 44px; object-fit: cover; border-radius: 50%; border: 1px solid var(--color-border); }
.contact-actions { display: grid; grid-template-columns: repeat(4, auto); gap: 4px; justify-content: start; }
.contact-actions .button { text-align: center; }

.ring-card { width: 275px; flex: 0 0 275px; }

/* ── Mobile ───────────────────────────────────────────────────────────────── */

.mobile-topbar { display: none; }
.nav-backdrop { display: none; }
.mobile-select-all { display: none; }

@media (max-width: 860px) {
    .mobile-topbar {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 10px 16px;
        background: var(--color-nav-bg);
        color: var(--color-nav-active-text);
        position: sticky;
        top: 0;
        z-index: 1002;
    }
    .mobile-topbar-brand { flex: 1; font-weight: 700; font-size: 15px; }
    .mobile-topbar-brand a { color: var(--color-nav-active-text); text-decoration: none; }
    .mobile-nav-toggle {
        background: none;
        border: 1px solid var(--color-nav-border);
        border-radius: 4px;
        color: var(--color-nav-active-text);
        font-size: 18px;
        line-height: 1;
        padding: 8px 12px;
        cursor: pointer;
    }

    /* The sidebar becomes an off-canvas drawer, toggled by .nav-open on .app-shell,
       instead of a permanent flex column — freeing the full viewport width for content. */
    .app-shell { display: block; min-height: auto; }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 260px;
        max-width: 82vw;
        z-index: 1003;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        transform: translateX(-100%);
        transition: transform .2s ease;
    }
    .app-shell.nav-open .sidebar { transform: translateX(0); box-shadow: 2px 0 16px rgba(0,0,0,.35); }

    .nav-backdrop {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,.4);
        z-index: 1002;
    }
    .app-shell.nav-open .nav-backdrop { display: block; }

    /* min-width: 0 lets the content column shrink to the screen instead of to its widest child;
       long words, URLs and emails break rather than push the page sideways. */
    .main-content { padding: 16px; max-width: 100%; min-width: 0; overflow-wrap: break-word; }
    img, video, canvas, iframe { max-width: 100%; }
    img, video { height: auto; }
    /* Fixed-width fields (style="width:260px" and the like) never run past their box. */
    input, select, textarea { max-width: 100%; }

    /* Grid and flex children default to min-width: auto (as wide as their content), which is
       what pushes a page sideways: every column here may shrink, and its own content wraps or
       scrolls instead. */
    .two-col, .dash-grid, .media-admin, .tag-admin { grid-template-columns: minmax(0, 1fr); }
    .form-grid > *, .two-col > *, .dash-grid > *, .media-admin > *, .tag-admin > *, .stat-grid > * { min-width: 0; }
    .stat-value { overflow-wrap: anywhere; }
    .page-header > *, .card-header-row > *, .toolbar > * { min-width: 0; }
    .page-header h1 { overflow-wrap: anywhere; }
    .checkbox-columns { columns: 1; }
    .diagnostic-log, .url-box, pre { max-width: 100%; overflow-x: auto; }

    /* Bigger tap targets. */
    .nav-link, .nav-section-title, .link-button { padding-top: 11px; padding-bottom: 11px; }
    button, .button { padding: 10px 16px; font-size: 14px; }
    .actions-col .button, .actions-col button { padding: 8px 12px; }

    /* 16px prevents iOS Safari from auto-zooming the page on focus. */
    input[type=text], input[type=password], input[type=number], input[type=date],
    input[type=email], input[type=tel], input[type=url], select, textarea { font-size: 16px; }

    .toolbar { flex-direction: column; align-items: stretch; }
    .tsd-filter-form { flex-direction: column; align-items: stretch; }
    .tsd-filter-form > button, .tsd-filter-form > a, .tsd-filter-form > noscript > button, .tsd-filter-form > label.checkbox-row { margin-top: 0; }
    .contact-map { height: 70vh; }
    .form-grid { grid-template-columns: 1fr; }

    .ring-card { width: 100%; flex: 1 1 100%; }

    /* A table keeps its internal row/column layout but the <table> box itself
       becomes a horizontally-scrollable block, so wide tables (score entry,
       judge lists) stay usable without redesigning them for a phone. Tables
       opted into card mode are handled separately below instead. */
    table.data-table:not(.table-cards-mobile) { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }

    .mobile-select-all { display: block; margin-bottom: 10px; }
    .mobile-select-all label { display: flex; align-items: center; gap: 8px; font-size: 14px; }

    /* Card mode: each row becomes a stacked card of label/value pairs instead
       of a wide table, so columns like the Assign action don't require
       scrolling sideways to reach. Selectors use child combinators (>) so a
       plain (non-card) table nested inside a card's detail cell — e.g. the
       judges list's expandable testing/experience tables — keeps its normal
       table layout instead of inheriting the card styling. */
    table.data-table.table-cards-mobile { display: block; background: none; }
    table.data-table.table-cards-mobile > thead {
        position: absolute;
        width: 1px; height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
    }
    table.data-table.table-cards-mobile > tbody { display: block; }
    table.data-table.table-cards-mobile > tbody > tr {
        display: block;
        background: var(--color-surface);
        border: 1px solid var(--color-border);
        border-radius: var(--radius);
        margin-bottom: 12px;
        padding: 2px 12px;
    }
    /* display:block above would otherwise override the [hidden] attribute
       used by expandable detail rows (e.g. judges list), forcing them open. */
    table.data-table.table-cards-mobile > tbody > tr[hidden] { display: none; }
    table.data-table.table-cards-mobile > tbody > tr > td {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        justify-content: space-between;
        gap: 6px 12px;
        padding: 9px 0;
        border-bottom: 1px solid var(--color-border);
        text-align: right;
        overflow-wrap: anywhere;
    }
    /* A value wider than what's left beside its label drops onto its own line instead of overflowing. */
    table.data-table.table-cards-mobile > tbody > tr > td > * { min-width: 0; max-width: 100%; }
    /* Several buttons/forms in one cell (Edit, Message, Enroll...) wrap onto more rows. */
    table.data-table.table-cards-mobile > tbody > tr > td.actions-col,
    table.data-table.table-cards-mobile > tbody > tr > td.actions {
        white-space: normal;
        justify-content: flex-end;
    }
    table.data-table.table-cards-mobile > tbody > tr > td.actions-col::before,
    table.data-table.table-cards-mobile > tbody > tr > td.actions::before { flex-basis: 100%; }
    table.data-table.table-cards-mobile > tbody > tr > td.photo-col { width: auto; }
    table.data-table.table-cards-mobile > tbody > tr > td.photo-col.is-empty { display: none; }
    .contact-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; }
    table.data-table.table-cards-mobile .inline-form { display: inline-flex; flex-wrap: wrap; gap: 4px; align-items: center; }
    table.data-table.table-cards-mobile .inline-form input[type=number],
    table.data-table.table-cards-mobile .inline-form input[type=text] { width: 90px; flex: 1 1 90px; }
    table.data-table.table-cards-mobile > tbody > tr > td:last-child { border-bottom: none; }
    table.data-table.table-cards-mobile > tbody > tr > td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--color-muted);
        text-align: left;
        margin-right: 12px;
    }
    table.data-table.table-cards-mobile > tbody > tr > td.row-select-cell {
        justify-content: flex-start;
    }
    table.data-table.table-cards-mobile > tbody > tr > td.row-select-cell::before { content: none; }
    table.data-table.table-cards-mobile > tbody > tr > td.cell-actions {
        justify-content: center;
        padding: 10px 0 4px;
    }
    table.data-table.table-cards-mobile > tbody > tr > td.cell-actions::before { content: none; }
    table.data-table.table-cards-mobile > tbody > tr > td.cell-actions a {
        display: block;
        width: 100%;
        text-align: center;
        background: var(--color-primary);
        color: var(--color-button-text);
        padding: 10px 16px;
        border-radius: var(--radius);
        text-decoration: none;
        font-size: 14px;
    }
    /* Some action cells submit a form (e.g. "Assign") rather than linking. */
    table.data-table.table-cards-mobile > tbody > tr > td.cell-actions form { width: 100%; }
    table.data-table.table-cards-mobile > tbody > tr > td.cell-actions button {
        display: block;
        width: 100%;
        padding: 10px 16px;
        font-size: 14px;
    }

    /* A row's colspan cell (an expandable detail panel, an empty-state message)
       holds its own layout rather than a single label/value pair, so it drops
       the flex/label treatment and just stacks as a full-width block. */
    table.data-table.table-cards-mobile > tbody > tr > td[colspan] {
        display: block;
        text-align: left;
    }
    table.data-table.table-cards-mobile > tbody > tr > td[colspan]::before { content: none; }
}

/* Expense documents (receipts/invoices) */
.document-list { list-style: none; padding: 0; margin: 0 0 12px; }
.document-list li { padding: 4px 0; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.document-list:empty { display: none; }

/* A titled group of fields inside a settings card. */
.settings-subsection { border-top: 1px solid var(--color-border); padding-top: 14px; margin-top: 16px; }
.settings-subsection h3 { margin: 0 0 8px; font-size: 15px; }
.settings-subsection > .help:first-of-type { margin-top: 0; }

/* Inventory item photos (Online Store). */
.item-photo-thumb { display: block; width: 64px; height: 64px; object-fit: cover; border-radius: var(--radius); }
.item-list-thumb { display: block; width: 40px; height: 40px; object-fit: cover; border-radius: var(--radius); }
.option-photo { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.option-photo img { width: 40px; height: 40px; object-fit: cover; border-radius: var(--radius); }
.option-photo .checkbox-row { margin: 0; font-size: 13px; }

/* Messages badge */
.nav-link-top { position: relative; }
.nav-badge { margin-left: auto; min-width: 18px; padding: 1px 5px; border-radius: 9px; background: var(--color-danger); color: #fff; font-size: 11px; font-weight: 700; line-height: 16px; text-align: center; }
.nav-collapsed .nav-badge { position: absolute; top: 2px; right: 4px; margin: 0; }
/* A section link with a count (Online Store Orders to prepare), and its closed section's heading. */
.nav-link.has-badge { display: flex; align-items: center; gap: 8px; }
.nav-section-title > .nav-badge { margin-left: 0; text-transform: none; letter-spacing: 0; }
.new-messages .plain-list { margin-top: 4px; }

/* Promotion Test: Students & results (Edit Event). */
.promo-add { margin-top: 8px; }
.promo-add > summary { cursor: pointer; }
.promo-add-form { margin-top: 10px; }
.promo-candidates { max-height: 280px; overflow-y: auto; border: 1px solid var(--color-border); border-radius: 6px; padding: 6px 10px; margin: 6px 0 12px; }
.promo-candidates .checkbox-row { margin: 3px 0; }
.promo-table .promo-line { min-height: 34px; display: flex; flex-direction: column; justify-content: center; }
.promo-table .promo-line + .promo-line { margin-top: 6px; }
.promo-table select[data-promo-rank]:disabled { opacity: .5; }
.promo-table tr.promo-passed td { background: var(--color-success-bg, rgba(46, 160, 67, .08)); }
.promo-scores { display: flex; flex-direction: column; gap: 4px; }
.promo-scores label { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin: 0; font-size: .85em; white-space: nowrap; }
.promo-scores input { width: 72px; }
.data-table tr.is-editing td { background: var(--color-warning-bg, rgba(212, 167, 44, .12)); }

/* SmsLinkCheck / sms-check.js: a text message with a phone number or an outside link. */
.sms-check { margin: 6px 0 12px; padding: 8px 12px; border-radius: 6px; background: var(--color-warning-bg); color: var(--color-warning-text); }
.sms-check[hidden] { display: none; }
.sms-check p { margin: 0 0 6px; }
.sms-check .checkbox-row { margin: 0; }

/* Marketing > QR Codes */
.text-break { overflow-wrap: anywhere; }
.qr-preview { display: flex; justify-content: center; line-height: 0; margin: 8px 0 16px; }
.qr-preview svg { background: #fff; border-radius: 4px; max-width: 100%; height: auto; }
.qr-description { white-space: normal; max-width: 70ch; }

/* Rich text editor: the Image window (ImagePicker in assets/js/wysiwyg.js) */
.image-picker {
    width: min(760px, calc(100vw - 32px)); max-height: calc(100vh - 32px); padding: 0;
    border: 1px solid var(--color-border); border-radius: var(--radius); background: var(--color-surface); color: var(--color-text);
    box-shadow: 0 12px 40px rgba(0, 0, 0, .25);
}
.image-picker[open] { display: flex; flex-direction: column; }
.image-picker::backdrop { background: rgba(0, 0, 0, .45); }
.image-picker-head, .image-picker-foot { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--color-border); }
.image-picker-foot { justify-content: flex-end; border-bottom: 0; border-top: 1px solid var(--color-border); }
.image-picker-head h2 { margin: 0; font-size: 17px; flex: 1; }
.image-picker-close { background: none; border: 0; color: var(--color-text); font-size: 24px; line-height: 1; padding: 0 4px; cursor: pointer; }
.image-picker-body { padding: 16px; overflow-y: auto; }
.image-picker-drop { border: 2px dashed var(--color-border); border-radius: var(--radius); padding: 12px 16px; text-align: center; margin-bottom: 16px; }
.image-picker-drop p { margin: 4px 0; }
.image-picker-drop.is-over { border-color: var(--color-primary); background: var(--color-tag-bg); }
.image-picker-choose { display: inline-block; cursor: pointer; }
.image-picker-status:empty { display: none; }
.image-picker-status.is-error { color: var(--color-danger, #b42318); }
.image-picker-library-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.image-picker-library-head h3 { margin: 0 0 8px; font-size: 14px; border: 0; padding: 0; }
.image-picker-library-head input { max-width: 220px; margin: 0 0 8px; }
.image-picker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; max-height: 320px; overflow-y: auto; padding: 2px; }
.image-picker-tile { position: relative; min-width: 0; }
.image-picker-pick {
    display: flex; flex-direction: column; width: 100%; padding: 4px; margin: 0; gap: 2px; text-align: left; cursor: pointer;
    background: var(--color-surface); color: var(--color-text); border: 2px solid var(--color-border); border-radius: var(--radius);
}
.image-picker-pick:hover { border-color: var(--color-primary); }
.image-picker-pick[aria-selected="true"] { border-color: var(--color-primary); box-shadow: 0 0 0 2px var(--color-primary); }
.image-picker-pick img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 3px; background: repeating-conic-gradient(#e6e6e6 0 25%, #fff 0 50%) 0 0 / 16px 16px; }
.image-picker-name { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.image-picker-size { font-size: 11px; color: var(--color-muted, #777); }
.image-picker-delete { position: absolute; top: 8px; right: 8px; padding: 2px 6px; margin: 0; font-size: 11px; opacity: 0; background: var(--color-surface); color: var(--color-text); border: 1px solid var(--color-border); border-radius: 4px; cursor: pointer; }
.image-picker-tile:hover .image-picker-delete, .image-picker-delete:focus { opacity: 1; }
.image-picker-url { margin: 16px 0 0; }
.image-picker-url summary { cursor: pointer; font-size: 13px; }
.image-picker-chosen { display: flex; gap: 14px; align-items: flex-start; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--color-border); }
.image-picker-chosen img { width: 120px; max-height: 120px; object-fit: contain; flex: none; border: 1px solid var(--color-border); border-radius: 3px; }
.image-picker-alt { flex: 1; min-width: 0; }
.image-picker-alt label { display: block; }
.image-picker-alt .help { margin: 4px 0 0; }
@media (max-width: 600px) {
    .image-picker-chosen { flex-direction: column; }
    .image-picker-grid { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
}
@media (hover: none) { .image-picker-delete { opacity: 1; } }
.image-picker [hidden] { display: none !important; }
.image-picker-foot button:disabled { opacity: .5; cursor: default; }
