/* ==========================================================================
   EduOrbia website portal (/portal/). Tokens match static/css/main.css.
   ========================================================================== */
:root {
    --teal-900: #05262d; --teal-800: #073842; --teal-700: #08434f; --teal-500: #147a8c; --teal-100: #d4e9ec; --teal-50: #edf6f7;
    --green-700: #146b36; --green-600: #1b8a46; --green-100: #d5f0df; --green-50: #eaf7ef;
    --sun: #f5b301; --sun-50: #fff6dc; --sun-ink: #7a5600;
    --red-700: #a1261b; --red-50: #fdeaea;
    --ink: #0b3038; --ink-2: #3e5c63; --ink-3: #68828a; --line: #dce9eb; --line-2: #c3d6d9;
    --bg: #ffffff; --bg-soft: #f3f8f8; --side-ink: #c4dde0; --side-muted: #8eb0b5;
    --font: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --radius: 16px; --radius-sm: 12px;
    --shadow: 0 10px 30px -12px rgba(6, 38, 45, .18);
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: 15px; line-height: 1.55; color: var(--ink); background: var(--bg-soft); }
a { color: var(--teal-700); }
a:hover { color: var(--teal-800); }
h1, h2, h3 { margin: 0; line-height: 1.2; }
:focus-visible { outline: 3px solid var(--teal-500); outline-offset: 2px; border-radius: 6px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: 12px; top: -60px; z-index: 300; background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; }
.skip:focus { top: 12px; color: #fff; }
.muted { color: var(--ink-3); font-size: 13px; }
.warn-text { color: var(--sun-ink); }
.nowrap { white-space: nowrap; }
.stack { display: flex; flex-direction: column; gap: 20px; }
.stack-sm { display: flex; flex-direction: column; gap: 14px; }

/* ── Buttons, fields ───────────────────────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px;
    border: 1px solid transparent; border-radius: var(--radius-sm); font: inherit; font-size: 15px; font-weight: 700;
    cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn--primary { background: var(--teal-700); color: #fff; }
.btn--primary:hover { background: var(--teal-800); color: #fff; }
.btn--ghost { background: #fff; border-color: var(--line-2); color: var(--ink); }
.btn--ghost:hover { border-color: var(--teal-700); color: var(--teal-700); }
.btn--danger { background: #fff; border-color: #f1b8b2; color: var(--red-700); }
.btn--sm { min-height: 36px; padding: 0 12px; font-size: 13px; border-radius: 10px; }
.btn--lg { min-height: 50px; font-size: 16px; }
.btn--block { width: 100%; }
.btn[disabled], .btn.is-busy { opacity: .6; cursor: progress; }
.linklike { background: none; border: 0; padding: 0; font: inherit; color: var(--side-ink); text-decoration: underline; cursor: pointer; }
.field { display: flex; flex-direction: column; gap: 8px; border: 0; padding: 0; margin: 0; min-width: 0; }
.field label, .field .label, .field legend { font-size: 14px; font-weight: 600; }
.field__row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.field__row a { font-size: 14px; font-weight: 600; }
.field input[type=text], .field input[type=email], .field input[type=password], .field input[type=search],
.field input[type=url], .field input[type=number], .field select, .field textarea {
    width: 100%; min-height: 48px; padding: 0 14px; border: 1px solid var(--line-2); border-radius: var(--radius-sm);
    font: inherit; font-size: 15px; background: #fff; color: var(--ink);
}
.field textarea { padding: 12px 14px; min-height: 110px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--teal-500); outline-offset: 1px; }
.field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--red-700); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.hint { color: var(--ink-3); font-size: 13px; }
.error { color: var(--red-700); font-size: 13px; font-weight: 600; }
.check { display: flex; gap: 10px; align-items: center; font-size: 14px; color: var(--ink-2); }
.check input { width: 18px; height: 18px; accent-color: var(--teal-700); }
.pw { position: relative; }
.pw input { padding-right: 52px !important; }
.pw__toggle {
    position: absolute; right: 4px; top: 4px; width: 44px; height: 40px; border: 0; border-radius: 10px;
    background: transparent; color: var(--ink-2); cursor: pointer; display: grid; place-items: center;
}
.pw__toggle[aria-pressed="true"] { color: var(--teal-700); background: var(--teal-50); }
.alert { margin: 0; padding: 12px 14px; border-radius: var(--radius-sm); font-size: 14px; font-weight: 600; }
.alert--error { background: var(--red-50); color: var(--red-700); }
.alert--info { background: var(--teal-50); color: var(--teal-700); }
.fine { margin: 0; font-size: 13px; color: var(--ink-3); text-align: center; line-height: 1.5; }
.flash { list-style: none; margin: 0 0 20px; padding: 0; display: grid; gap: 8px; }
.flash li { padding: 12px 16px; border-radius: var(--radius-sm); font-weight: 600; font-size: 14px; background: var(--teal-50); color: var(--teal-700); }
.flash .flash--success { background: var(--green-50); color: var(--green-700); }
.flash .flash--warning { background: var(--sun-50); color: var(--sun-ink); }
.flash .flash--error { background: var(--red-50); color: var(--red-700); }

/* ── Sign-in pages ─────────────────────────────────────────────────────── */
.auth { min-height: 100vh; display: flex; flex-wrap: wrap; }
.auth__brand {
    flex: 1 1 520px; background: var(--teal-900); color: #fff; padding: 56px 64px;
    display: flex; flex-direction: column; justify-content: space-between; gap: 48px;
}
.auth__logo { display: flex; align-items: center; gap: 12px; }
.auth__name { font-size: 22px; font-weight: 800; letter-spacing: -.01em; }
.auth__tag { font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px; background: rgba(255, 255, 255, .12); }
.auth__pitch { max-width: 480px; display: flex; flex-direction: column; gap: 20px; }
.auth__pitch h1 { font-size: 44px; line-height: 1.1; font-weight: 800; letter-spacing: -.02em; }
.auth__pitch p { margin: 0; font-size: 17px; line-height: 1.6; color: var(--side-ink); }
.auth__pitch ul { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 12px; color: #e3ecf8; }
.auth__pitch li { display: flex; gap: 12px; align-items: center; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.dot--green { background: #25a559; } .dot--sun { background: var(--sun); }
.auth__foot { margin: 0; font-size: 13px; color: var(--side-muted); }
.auth__main { flex: 1 1 480px; display: flex; align-items: center; justify-content: center; padding: 48px 24px; }
.auth-card {
    width: 100%; max-width: 420px; background: #fff; border: 1px solid var(--line); border-radius: 20px;
    padding: 40px; box-shadow: var(--shadow);
}
.card-head { display: flex; flex-direction: column; gap: 6px; }
.card-head h2 { font-size: 26px; font-weight: 800; }
.card-head p { margin: 0; color: var(--ink-2); }

/* ── Shell: sidebar + main ─────────────────────────────────────────────── */
.shell { display: grid; grid-template-columns: 264px minmax(0, 1fr); min-height: 100vh; }
.topbar { display: none; }
.sidebar {
    background: var(--teal-900); padding: 24px 16px; display: flex; flex-direction: column; gap: 20px;
    position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sidebar__brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; text-decoration: none; }
.sidebar__brand strong { display: block; color: #fff; font-size: 16px; font-weight: 800; }
.sidebar__brand small { display: block; color: var(--side-muted); font-size: 12px; }
.sidebar__group { display: flex; flex-direction: column; gap: 2px; }
.sidebar__label { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--side-muted); padding: 0 12px 6px; }
.sb-link {
    display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 40px; padding: 0 12px;
    border-radius: 10px; font-size: 14px; font-weight: 500; color: var(--side-ink); text-decoration: none;
}
.sb-link:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.sb-link.sb-on, .sb-link.sb-on:hover { background: #fff; color: var(--teal-900); font-weight: 700; }
.sb-badge { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--sun); color: var(--teal-900); }
.sidebar__me {
    margin-top: auto; border-top: 1px solid rgba(255, 255, 255, .12); padding: 16px 8px 0;
    display: flex; align-items: center; gap: 10px; color: #fff;
}
.sidebar__me strong { display: block; font-size: 14px; font-weight: 600; }
.sidebar__me small { font-size: 12px; color: var(--side-muted); }
.sidebar__me form { margin: 0; }
.avatar {
    width: 36px; height: 36px; border-radius: 50%; background: var(--green-600); color: #fff; flex: none;
    font-size: 13px; font-weight: 700; display: grid; place-items: center;
}
.main { min-width: 0; padding: 28px 32px 48px; display: flex; flex-direction: column; gap: 24px; }

/* ── Page parts ────────────────────────────────────────────────────────── */
.page-head { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; justify-content: space-between; }
.page-head h1 { font-size: 28px; font-weight: 800; }
.page-head p { margin: 4px 0 0; font-size: 14px; color: var(--ink-2); max-width: 720px; }
.page-head__actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.page-head__actions form { margin: 0; }
.crumbs { margin: 0 0 4px !important; font-size: 13px !important; }
.card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.card h2 { font-size: 17px; font-weight: 700; }
.card__head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.card__head a { font-size: 14px; font-weight: 600; }
.form-card { max-width: 720px; display: flex; flex-direction: column; gap: 18px; }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; padding-top: 6px; }
.two-col { display: flex; flex-wrap: wrap; gap: 24px; align-items: flex-start; }
.two-col > :first-child { flex: 1 1 320px; }
.two-col > :last-child { flex: 2 1 480px; min-width: 0; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; }
.stat { text-decoration: none; color: var(--ink); display: flex; flex-direction: column; gap: 4px; }
.stat:hover { border-color: var(--teal-100); color: var(--ink); box-shadow: var(--shadow); }
.stat__label { font-size: 13px; color: var(--ink-2); font-weight: 600; }
.stat__value { font-size: 32px; font-weight: 800; line-height: 1.1; }
.stat__note { font-size: 13px; color: var(--ink-3); }

.chip {
    display: inline-flex; gap: 8px; align-items: center; font-size: 14px; padding: 8px 14px; border-radius: 999px;
    border: 1px solid var(--line); background: #fff; color: var(--ink-2);
}
.chip .dot { background: var(--ink-3); }
.chip--ok { color: var(--green-700); background: var(--green-50); border-color: var(--green-100); }
.chip--ok .dot { background: var(--green-600); }
.chip--failing { color: var(--red-700); background: var(--red-50); border-color: #f6c9c4; }
.chip--failing .dot { background: var(--red-700); }
.chip--never, .chip--off { color: var(--sun-ink); background: var(--sun-50); border-color: #f7dc8c; }
.chip--never .dot, .chip--off .dot { background: var(--sun); }

.pill { display: inline-block; font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 999px; background: var(--bg-soft); color: var(--ink-2); white-space: nowrap; }
.pill--ok { background: var(--green-50); color: var(--green-700); }
.pill--bad { background: var(--red-50); color: var(--red-700); }
.pill--warn { background: var(--sun-50); color: var(--sun-ink); }
.pill--info { background: var(--teal-50); color: var(--teal-700); }
.pill--sun { background: var(--sun); color: var(--teal-900); }
.pill--teal { background: var(--teal-700); color: #fff; }

.need { display: flex; gap: 12px; align-items: flex-start; padding: 14px; border-radius: var(--radius-sm); background: var(--teal-50); }
.need--sun { background: var(--sun-50); }
.need--bad { background: var(--red-50); }
.need > div { display: flex; flex-direction: column; gap: 4px; font-size: 14px; }
.need span:not(.pill) { color: var(--ink-2); }
.need a { font-weight: 700; }

.table-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; font-size: 12px; font-weight: 700; color: var(--ink-3); text-transform: uppercase; letter-spacing: .05em; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 12px; border-bottom: 1px solid #eef2f7; vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr.is-highlight td { background: var(--sun-50); }
.tbl td.actions { text-align: right; white-space: nowrap; }
.tbl td.actions > * { display: inline-block; vertical-align: middle; margin: 2px 0 2px 4px; }
.tbl td.actions form { margin: 2px 0 2px 4px; }

.roles { gap: 10px; }
.role-option { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius-sm); cursor: pointer; }
.role-option:has(input:checked) { border-color: var(--teal-700); background: var(--teal-50); }
.role-option input { margin-top: 4px; accent-color: var(--teal-700); }
.role-option small { display: block; color: var(--ink-2); font-size: 13px; }
fieldset[disabled] .role-option { opacity: .6; cursor: not-allowed; }

.notice { display: flex; gap: 10px; align-items: center; padding: 12px 16px; border-radius: var(--radius-sm); background: var(--teal-50); color: var(--teal-700); font-size: 14px; font-weight: 600; }

/* ── Tabs, search, inline forms, logos ─────────────────────────────────── */
.tabs { display: flex; flex-wrap: wrap; gap: 6px; border-bottom: 1px solid var(--line); }
.tab {
    display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 14px; margin-bottom: -1px;
    border-bottom: 3px solid transparent; color: var(--ink-2); font-weight: 600; text-decoration: none;
}
.tab:hover { color: var(--ink); }
.tab.is-on { color: var(--teal-700); border-bottom-color: var(--teal-700); }
.tab__count { font-size: 12px; font-weight: 700; padding: 1px 8px; border-radius: 999px; background: var(--bg-soft); color: var(--ink-2); }
.search { display: flex; gap: 8px; margin: 0; }
.search input { min-height: 44px; padding: 0 14px; border: 1px solid var(--line-2); border-radius: var(--radius-sm); font: inherit; min-width: 240px; }
.inline-form { display: flex; gap: 8px; align-items: center; margin: 0; }
.inline-form select { min-height: 36px; padding: 0 10px; border: 1px solid var(--line-2); border-radius: 10px; font: inherit; font-size: 14px; background: #fff; }
.name-cell { display: inline-flex; gap: 10px; align-items: center; }
.pager { display: flex; justify-content: center; align-items: center; gap: 12px; margin-top: 16px; }
code { font-size: 12.5px; background: var(--bg-soft); padding: 2px 6px; border-radius: 6px; }
.logo-tile {
    position: relative; flex: none; display: inline-grid; place-items: center; overflow: hidden;
    width: 36px; height: 36px; border-radius: 10px; background: var(--tile-bg, var(--teal-50)); color: var(--tile-ink, var(--teal-700));
    font-weight: 800; font-size: 13px;
}
.logo-tile img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #fff; padding: 3px; }
.logo-tile img:not([src]), .logo-tile img[src=""] { display: none; }
.tint-0 { --tile-bg: #d4e9ec; --tile-ink: #073842; } .tint-1 { --tile-bg: #d5f0df; --tile-ink: #146b36; }
.tint-2 { --tile-bg: #fff6dc; --tile-ink: #7a5800; } .tint-3 { --tile-bg: #ede4fb; --tile-ink: #4b2a86; }
.tint-4 { --tile-bg: #fde4e1; --tile-ink: #8a2a1d; } .tint-5 { --tile-bg: #dff3f4; --tile-ink: #0f5d62; }

/* ── Settings, messages ────────────────────────────────────────────────── */
.settings-group { border: 0; padding: 0; margin: 0 0 8px; display: flex; flex-direction: column; gap: 16px; }
.settings-group legend { font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); margin-bottom: 4px; }
.facts { display: grid; gap: 12px; margin: 0; }
.facts dt { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); }
.facts dd { margin: 2px 0 0; }
.message-body { font-size: 15px; line-height: 1.65; overflow-wrap: anywhere; }

/* ── Legal pages: the Terms Hub's editor screens inside the portal shell ──
   portal/portal.css (the hub's own stylesheet) loads first; these rules recolour it with the portal's tokens and keep
   it light (the hub follows the OS dark mode on its own, which would clash with the light shell). */
body.hub {
    --surface: #ffffff; --text: var(--ink); --muted: var(--ink-3); --line: #dce9eb;
    --brand: var(--teal-700); --brand-text: #ffffff; --danger: var(--red-700); --ok: var(--green-700); --warn: var(--sun-ink);
    --radius: var(--radius); --shadow: none;
    background: var(--bg-soft); color: var(--ink); font-family: var(--font); font-size: 15px;
}
body.hub .main > .head h1, body.hub .main h1 { font-size: 28px; font-weight: 800; }
body.hub .head { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; justify-content: space-between; margin: 0; }
body.hub .card { border-radius: var(--radius); margin-bottom: 0; }
body.hub .btn:not([class*="btn--"]) {
    display: inline-flex; align-items: center; min-height: 40px; padding: 0 16px; border-radius: var(--radius-sm);
    font-size: 14px; font-weight: 700; border: 1px solid var(--line-2); background: #fff; color: var(--ink);
}
body.hub .btn.primary { background: var(--teal-700); border-color: var(--teal-700); color: #fff; }
body.hub .btn.primary:hover { background: var(--teal-800); color: #fff; }
body.hub .btn.danger { color: var(--red-700); border-color: #f1b8b2; }
body.hub .btn.link { border: 0; background: none; min-height: 0; padding: 4px; color: var(--teal-700); }
body.hub table.list { background: #fff; border-radius: var(--radius); font-size: 14px; }
body.hub table.list th { font-size: 12px; font-weight: 700; color: var(--ink-3); letter-spacing: .05em; }
body.hub .badge.published { background: var(--green-50); border-color: var(--green-100); color: var(--green-700); }
body.hub .badge.draft { background: var(--sun-50); border-color: #f7dc8c; color: var(--sun-ink); }
body.hub input[type=text], body.hub input[type=email], body.hub input[type=number], body.hub input[type=url],
body.hub input[type=date], body.hub select, body.hub textarea {
    background: #fff; border-color: var(--line-2); border-radius: var(--radius-sm); min-height: 44px;
}

/* ── Phone: the sidebar becomes a drawer ───────────────────────────────── */
@media (max-width: 900px) {
    .shell { display: block; }
    .topbar {
        display: flex; align-items: center; gap: 12px; position: sticky; top: 0; z-index: 50;
        background: var(--teal-900); color: #fff; padding: 10px 16px; font-weight: 800;
    }
    .topbar__menu { width: 44px; height: 44px; border-radius: 10px; border: 1px solid rgba(255, 255, 255, .2); background: transparent; color: #fff; display: grid; place-items: center; }
    .topbar__brand { display: flex; align-items: center; gap: 8px; }
    .topbar__brand .mark { width: 26px; height: 26px; }
    .sidebar { position: fixed; inset: 0 auto 0 0; width: min(86vw, 300px); z-index: 120; transform: translateX(-100%); transition: transform .25s ease; }
    .sidebar.is-open { transform: none; }
    .sidebar-backdrop { position: fixed; inset: 0; background: rgba(6, 38, 45, .45); z-index: 110; }
    .main { padding: 20px 16px 40px; }
    .page-head h1 { font-size: 24px; }
    .auth__brand { padding: 32px 24px; gap: 28px; flex-basis: 100%; }
    .auth__pitch h1 { font-size: 30px; }
    .auth-card { padding: 28px 22px; }
    .field-row { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* Until a linked logo has loaded, keep it invisible so the initials show (JS marks it .is-loaded) */
.js .logo-tile img:not(.is-loaded) { opacity: 0; }
