/*
 * EduLink Central - one stylesheet.
 * Styled like EduLink Academy: Inter, black pill buttons, orange + green accents,
 * soft rounded panels. Light and dark mode share every rule below; dark mode
 * only changes the colour variables (see "Dark mode" at the end).
 */

/* Colours ----------------------------------------------------------------- */
:root {
    --bg: #ffffff; --card: #ffffff; --text: #0f1412; --muted: #6b7470; --line: #ececea;
    --soft: #f4f6f5; --warm: #f8f3ee; --ink: #0b0b0b; --on-ink: #ffffff;
    --brand: #168a40; --orange: #f26b1d; --forest: #0b3320;
    --side: #ffffff; --side-text: #3b4340; --side-icon: #8a938f;
    --link: #168a40; --row-line: #f0f1f0; --hover: #fafbfa;
    --input-bg: #ffffff; --input-line: #e2e4e3; --btn-bg: #ffffff; --btn-line: #dcdedd;
    --ok: #168a40; --info: #2a6fd6; --warn: #c97a00; --danger: #d23b3b;
    --ok-bg: #e8f5ec; --info-bg: #eaf1fc; --warn-bg: #fdf3e2; --danger-bg: #fcecec;
    --ok-text: #0f5a2a; --warn-text: #7a4d00; --danger-text: #8a1f1f;
    --flash-live: #fff1b8;
}

/* Base -------------------------------------------------------------------- */
* { box-sizing: border-box; }
body {
    margin: 0; display: flex; min-height: 100vh; background: var(--bg); color: var(--text);
    font: 14.5px/1.55 "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; -webkit-font-smoothing: antialiased;
}
body.bare { justify-content: center; align-items: flex-start; background: var(--soft); }
a { color: var(--link); text-decoration: none; font-weight: 500; }
a:hover { text-decoration: underline; }
h1 { font-size: 30px; line-height: 1.15; margin: 0 0 6px; font-weight: 800; letter-spacing: -.04em; }
h2 { font-size: 18px; margin: 0 0 14px; font-weight: 700; letter-spacing: -.02em; }
h3 { font-size: 14.5px; margin: 18px 0 6px; font-weight: 700; }
code, pre.code, textarea.code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }
pre.code, textarea.code { width: 100%; padding: 12px; background: var(--soft); border: 1px solid var(--line); border-radius: 12px; white-space: pre-wrap; word-break: break-all; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.nowrap, td.nowrap { white-space: nowrap; }
.txt-warn { color: var(--warn); }

/* Brand: EDU + orange LINK, a small spaced word under it ------------------ */
.brand { display: flex; align-items: center; gap: 10px; padding: 22px 20px 18px; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand img { width: 38px; height: 38px; border-radius: 11px; box-shadow: 0 8px 18px -8px rgba(22, 138, 64, .55); }
.brand span { font-weight: 800; font-size: 19px; letter-spacing: -.02em; line-height: 1; }
.brand em { font-style: normal; color: var(--orange); }
.brand small { display: block; margin-top: 4px; font-size: 9.5px; font-weight: 700; letter-spacing: .32em; text-transform: uppercase; color: var(--muted); }

/* Sidebar: line icons, the open page as a pill ----------------------------- */
.side { position: sticky; top: 0; display: flex; flex-direction: column; flex-shrink: 0; width: 248px; height: 100vh; background: var(--side); color: var(--side-text); border-right: 1px solid var(--line); }
.side nav { flex: 1; padding: 8px 14px; }
.side nav a { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; padding: 10px 14px; border-radius: 999px; color: var(--side-text); font-weight: 500; }
.side nav a .ni { display: flex; align-items: center; gap: 12px; }
.side nav a svg { width: 19px; height: 19px; flex: none; color: var(--side-icon); }
.side nav a:hover { background: var(--soft); text-decoration: none; }
.side nav a.on { background: var(--ink); color: var(--on-ink); }
.side nav a.on svg { color: var(--on-ink); }
.pill { margin-left: 6px; padding: 1px 8px; border-radius: 999px; background: var(--orange); color: #fff; font-size: 11px; font-weight: 700; }

/* Top bar: light/dark switch and the account menu ------------------------- */
.topbar { display: flex; justify-content: flex-end; align-items: center; gap: 10px; margin: -14px 0 18px; }
.tb-icon { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--line); background: var(--card); color: var(--text); cursor: pointer; }
.tb-icon:hover { background: var(--soft); }
.tb-icon svg { width: 19px; height: 19px; }
.tb-icon .moon, .theme-btn .moon, [data-theme="dark"] .tb-icon .sun, [data-theme="dark"] .theme-btn .sun { display: none; }
[data-theme="dark"] .tb-icon .moon, [data-theme="dark"] .theme-btn .moon { display: block; }
.acct { position: relative; }
.acct > summary { display: flex; align-items: center; gap: 10px; padding: 4px 12px 4px 4px; border: 1px solid var(--line); border-radius: 999px; background: var(--card); font-weight: 600; cursor: pointer; list-style: none; }
.acct > summary::-webkit-details-marker { display: none; }
.acct > summary:hover, .acct[open] > summary { background: var(--soft); }
.acct .dn { width: 16px; height: 16px; color: var(--muted); transition: transform .15s; }
.acct[open] .dn { transform: rotate(180deg); }
.av { flex: none; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--orange); color: #fff; font-weight: 800; font-size: 14px; }
.av.big { width: 44px; height: 44px; font-size: 18px; }
.acct-menu {
    position: absolute; right: 0; top: calc(100% + 10px); z-index: 30; width: 280px; padding: 10px;
    background: var(--card); border: 1px solid var(--line); border-radius: 20px; box-shadow: 0 20px 44px -18px rgba(10, 20, 15, .35);
}
.acct-menu form { margin: 0; }
.am-who { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; padding: 10px 10px 14px; border-bottom: 1px solid var(--line); }
.am-who b { display: block; font-size: 14.5px; }
.am-who small { color: var(--muted); font-size: 12.5px; word-break: break-all; }
.am-link, .am-out { display: flex; align-items: center; gap: 10px; width: 100%; padding: 11px 12px; border-radius: 12px; font-weight: 600; }
.am-link { color: var(--text); }
.am-link:hover, .am-link.on { background: var(--soft); text-decoration: none; }
.am-link svg { width: 18px; height: 18px; color: var(--muted); }
.am-out { border: 0; background: none; color: var(--danger); font: inherit; font-weight: 600; text-align: left; cursor: pointer; }
.am-out:hover { background: var(--danger-bg); }
.am-out svg { width: 18px; height: 18px; }

/* Page frame ---------------------------------------------------------------- */
.main { flex: 1; min-width: 0; max-width: 1440px; padding: 34px 40px; }
body.bare .main { max-width: 620px; padding-top: 6vh; }
.head { display: flex; justify-content: space-between; align-items: flex-end; flex-wrap: wrap; gap: 12px; margin-bottom: 26px; }
.head-actions { display: flex; align-items: flex-start; flex-wrap: wrap; gap: 10px; }
.head-actions form.toggle { margin: 0; }
.head-actions form.toggle input { width: 280px; margin: 0; }
.crumb { margin: -6px 0 6px; font-size: 13px; }
.card { margin-bottom: 20px; padding: 30px 32px; background: var(--card); border: 1px solid var(--line); border-radius: 26px; }
.card > h2:first-child { margin-bottom: 18px; }
.card.narrow { max-width: 560px; margin: 0 auto; }
.card .logo { height: 44px; margin-bottom: 14px; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.cols > .card { margin-bottom: 20px; }
details.fold { padding: 0; }
details.fold > summary { padding: 14px 20px; font-weight: 600; list-style: none; cursor: pointer; }
details.fold > summary::before { content: "▸ "; color: var(--muted); }
details.fold[open] > summary::before { content: "▾ "; }
details.fold > :not(summary) { margin-left: 20px; margin-right: 20px; }
details.fold[open] { padding-bottom: 14px; }

/* Number tiles: soft panels, big tight numbers, a coloured dot ------------- */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(232px, 1fr)); gap: 16px; margin-bottom: 26px; }
.stats.wide { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.stat { position: relative; padding: 18px 20px 16px; background: var(--soft); border-radius: 22px; }
.stat:nth-child(even) { background: var(--warm); }
.stat::before { content: ""; position: absolute; right: 18px; top: 20px; width: 10px; height: 10px; border-radius: 50%; background: var(--line); }
.stat .n { padding-right: 16px; font-size: 27px; font-weight: 800; letter-spacing: -.04em; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat .l { color: var(--muted); font-size: 13px; font-weight: 500; }
.stat-ok::before { background: var(--ok); }
.stat-info::before { background: var(--info); }
.stat-warn::before { background: var(--orange); }
.stat-danger::before { background: var(--danger); }

/* Tables: a soft rounded header bar, roomy rows ------------------------------ */
.table-wrap { overflow-x: auto; margin: 0 -6px; padding: 0 6px; }
table { width: 100%; border-collapse: separate; border-spacing: 0; }
th, td { text-align: left; vertical-align: middle; }
th { padding: 13px 18px; background: var(--soft); color: var(--muted); font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; white-space: nowrap; }
th:first-child { border-radius: 14px 0 0 14px; }
th:last-child { border-radius: 0 14px 14px 0; }
td { padding: 17px 18px; border-bottom: 1px solid var(--row-line); }
td small, td .muted { line-height: 1.45; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--hover); }
tbody tr:hover td:first-child { border-radius: 12px 0 0 12px; }
tbody tr:hover td:last-child { border-radius: 0 12px 12px 0; }
tfoot th, tfoot td { padding: 15px 18px; background: var(--warm); border: 0; color: var(--text); font-size: 14.5px; font-weight: 800; }
.r { text-align: right; }
/* The schools list: short cells on one line, the school column gets room */
table.list th, table.list td { padding-left: 12px; padding-right: 12px; }
table.list th:first-child, table.list td:first-child { padding-left: 18px; }
table.list td:first-child { min-width: 230px; }
table.list td:not(:first-child) { white-space: nowrap; }

/* Badges, alerts, messages ---------------------------------------------------- */
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; vertical-align: middle; white-space: nowrap; }
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-muted { background: var(--soft); color: var(--muted); }
.alert { margin-bottom: 10px; padding: 12px 16px; border-radius: 16px; }
.alert-danger { background: var(--danger-bg); }
.alert-warning { background: var(--warn-bg); }
.alert-info { background: var(--info-bg); }
.alert.resolved { opacity: .55; background: var(--soft); }
.flash { margin-bottom: 18px; padding: 12px 18px; border-radius: 16px; font-weight: 500; }
.flash-ok { background: var(--ok-bg); color: var(--ok-text); }
.flash-danger { background: var(--danger-bg); color: var(--danger-text); }
.flash-warn { background: var(--warn-bg); color: var(--warn-text); }
.act { padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.namediff { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 8px; padding: 6px 10px; border-radius: 10px; background: var(--warn-bg); color: var(--warn-text); }
.live-dot { display: inline-block; width: 7px; height: 7px; margin-left: 4px; border-radius: 50%; background: var(--ok); vertical-align: middle; animation: livepulse 2s ease-in-out infinite; }
@keyframes livepulse { 0%, 100% { opacity: .35; } 50% { opacity: 1; } }
.flash-live { border-radius: 4px; animation: flashlive 1.6s ease-out; }
@keyframes flashlive { 0% { background: var(--flash-live); } 100% { background: transparent; } }

/* Forms ------------------------------------------------------------------------- */
label { display: block; margin-bottom: 14px; color: var(--text); font-size: 13.5px; font-weight: 600; }
label small { color: var(--muted); font-weight: 500; }
input, select, textarea {
    display: block; width: 100%; margin-top: 6px; padding: 11px 14px; border: 1px solid var(--input-line); border-radius: 12px;
    background: var(--input-bg); color: var(--text); font: inherit; font-weight: 400;
}
input:focus, textarea:focus, select:focus { outline: 3px solid rgba(242, 107, 29, .16); border-color: var(--orange); }
label.check { display: flex; align-items: center; gap: 8px; margin: 0; color: var(--text); font-weight: 500; }
label.check input { width: auto; margin: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 14px; }
.inline { display: flex; align-items: flex-end; flex-wrap: wrap; gap: 10px; margin-bottom: 8px; }
.inline label { flex: 1 1 160px; margin-bottom: 0; }
.stack .inline { padding: 10px 0; border-top: 1px solid var(--line); }
.filters { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-bottom: 22px; }
.filters input { max-width: 360px; margin: 0; }
.pair { display: flex; gap: 6px; margin-top: 4px; }
.pair input, .pair select { margin-top: 0; }
.pair select { flex-shrink: 0; width: 120px; }

/* Buttons: pills - black primary, outlined default, orange accent -------------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 20px;
    border: 1px solid var(--btn-line); border-radius: 999px; background: var(--btn-bg); color: var(--text);
    font: inherit; font-weight: 600; white-space: nowrap; cursor: pointer; transition: background .15s, border-color .15s, transform .1s;
}
.btn:hover { background: var(--soft); text-decoration: none; }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--ink); border-color: var(--ink); color: var(--on-ink); }
.btn.primary:hover { opacity: .88; }
.btn.accent, .btn.warn { background: var(--orange); border-color: var(--orange); color: #fff; }
.btn.accent:hover, .btn.warn:hover { background: #dd5c12; }
.btn.danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn.small { padding: 5px 13px; font-size: 12.5px; }
.btn.big { padding: 12px 26px; font-size: 16px; }
.btn.wide { width: 100%; margin-top: 8px; }

/* Product key, key/value lists --------------------------------------------------- */
.keybox { border: 2px solid var(--brand); }
.key { display: inline-block; margin: 10px 0; padding: 12px 16px; border-radius: 14px; background: var(--ok-bg); font: 700 22px/1.4 ui-monospace, Menlo, Consolas, monospace; letter-spacing: .06em; user-select: all; }
dl.kv { display: grid; grid-template-columns: 150px 1fr; gap: 8px 14px; margin: 0 0 12px; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; font-weight: 500; }

/* School page: deactivate form, renewals ------------------------------------------ */
details.deact { position: relative; }
details.deact > summary { list-style: none; cursor: pointer; }
details.deact > summary::-webkit-details-marker { display: none; }
.deact-panel {
    position: absolute; right: 0; top: calc(100% + 8px); z-index: 20; width: 440px; max-width: 90vw; padding: 16px;
    background: var(--card); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 18px 40px -16px rgba(15, 31, 51, .35); color: var(--text); text-align: left;
}
details.deact.inline-edit { margin-top: 8px; }
details.deact.inline-edit > summary { display: inline; color: var(--danger-text); font-size: 13px; text-decoration: underline; }
details.deact.inline-edit .deact-panel { position: static; width: auto; max-width: 560px; margin-top: 10px; box-shadow: none; }
.renew { margin: 6px 0 12px; padding: 4px 16px 16px; background: var(--soft); border: 1px solid var(--line); border-radius: 14px; }
.renew-sum { padding: 9px 12px; background: var(--card); border: 1px dashed var(--line); border-radius: 10px; color: var(--text); }

/* Payments ---------------------------------------------------------------------- */
table.money td.paid, table.money th.paid { color: var(--ok); font-weight: 700; }
table.money td.owes, table.money th.owes { color: var(--danger); font-weight: 700; }
table.payform th { padding: 4px 6px; }
table.payform td { padding: 4px 6px; border: 0; vertical-align: middle; }
table.payform input, table.payform select { min-width: 90px; margin: 0; }
table.payform tr:hover td { background: none; }
.paycalc { margin: 8px 6px 0; font-size: 13px; }
form.rest { display: inline-flex; align-items: center; gap: 6px; margin: 0 6px 0 0; }
form.rest input { width: 110px; padding: 5px 8px; text-align: right; }
.paidok { display: flex; justify-content: space-between; align-items: center; gap: 12px; color: var(--ok); font-size: 16px; }

/* EduLink Pay page ---------------------------------------------------------------- */
.pay-status { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 20px; }
.pay-status h2 { margin-top: 0; }
.pay-pics { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.pay-pic { display: flex; align-items: center; gap: 14px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 14px; }
.pp-img { flex: none; display: grid; place-items: center; width: 56px; height: 56px; overflow: hidden; background: var(--soft); border: 1px solid var(--line); border-radius: 14px; }
.pp-img img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.pp-img span { color: var(--brand); font-weight: 800; font-size: 20px; }
.pp-t { flex: 1; min-width: 0; }
.pp-t b { display: block; }
.pp-form { margin: 0; }

/* Sign in: split screen like the academy - form left, dark green panel right ------ */
body.bare.auth { display: block; background: var(--bg); }
body.bare.auth .main { max-width: none; padding: 0; }
.auth { display: grid; grid-template-columns: 1fr 1fr; min-height: 100vh; }
.auth-form { display: flex; flex-direction: column; padding: 28px 40px; background: var(--bg); }
.auth-form .brand { padding: 0; }
.auth-box { width: 100%; max-width: 420px; margin: auto; padding: 40px 0; }
.auth-box h1 { font-size: 38px; }
.auth-box .muted { margin: 0 0 28px; font-size: 15px; }
.auth-box .btn.wide { margin-top: 10px; padding: 14px 20px; font-size: 15.5px; }
.auth-foot { margin: 0; color: var(--muted); font-size: 12.5px; text-align: center; }
.auth-art { position: relative; display: flex; align-items: flex-end; overflow: hidden; padding: 56px; background: var(--forest); color: #fff; }
.auth-art::before { content: ""; position: absolute; left: -120px; bottom: -160px; width: 420px; height: 420px; border-radius: 50%; background: rgba(255, 255, 255, .04); }
.auth-art .sun { position: absolute; right: -90px; top: -110px; width: 420px; height: 420px; border-radius: 50%; background: #e86a12; }
.auth-art .ghost { position: absolute; left: 30px; bottom: -40px; color: rgba(255, 255, 255, .05); font-size: 190px; font-weight: 800; letter-spacing: -.05em; line-height: 1; white-space: nowrap; }
.auth-copy { position: relative; z-index: 1; max-width: 460px; }
.auth-copy h2 { margin: 0 0 18px; font-size: 44px; line-height: 1.08; font-weight: 800; letter-spacing: -.045em; }
.auth-copy h2 em { display: block; font-style: normal; color: #ff8a3d; }
.auth-copy p { margin: 0; color: rgba(255, 255, 255, .72); font-size: 15.5px; line-height: 1.6; }
/* The light/dark button in the corner of the sign-in page */
.theme-btn {
    position: fixed; top: 22px; right: 24px; z-index: 5; display: flex; align-items: center; gap: 10px; padding: 9px 14px;
    border: 1px solid var(--line); border-radius: 999px; background: var(--card); color: var(--side-text); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
}
.theme-btn:hover { background: var(--soft); }
.theme-btn svg { width: 18px; height: 18px; }
.theme-btn .t-dark, [data-theme="dark"] .theme-btn .t-light { display: none; }
[data-theme="dark"] .theme-btn .t-dark { display: inline; }

/* Phones and small windows ---------------------------------------------------------- */
@media (max-width: 900px) {
    body { flex-direction: column; }
    .side { position: static; width: 100%; height: auto; border-right: 0; border-bottom: 1px solid var(--line); }
    .side nav { display: flex; flex-wrap: wrap; gap: 4px; }
    .main { padding: 18px 16px; }
    .topbar { margin: 0 0 14px; }
    .acct .an { display: none; }
    .cols, .grid2, .grid3 { grid-template-columns: 1fr; }
    .auth { grid-template-columns: 1fr; }
    .auth-art { display: none; }
    .auth-form { padding: 22px 18px; }
    .theme-btn { top: 14px; right: 14px; }
}

/* Dark mode: deep green-black, soft dark panels, a white pill for the open page -- */
[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0c110f; --card: #131a17; --text: #e8eeeb; --muted: #8f9a95; --line: #222c28;
    --soft: #18211d; --warm: #1e1d19; --ink: #f2f5f3; --on-ink: #0c110f;
    --brand: #3fbf6f; --forest: #082618;
    --side: #0f1512; --side-text: #c9d2ce; --side-icon: #7d8984;
    --link: #5fd08a; --row-line: #1d2622; --hover: #17201c;
    --input-bg: #0f1512; --input-line: #2a3530; --btn-bg: #131a17; --btn-line: #2c3732;
    --ok: #3fbf6f; --info: #6ea3f0; --warn: #f0a640; --danger: #f07070;
    --ok-bg: #143322; --info-bg: #15243a; --warn-bg: #33270f; --danger-bg: #3a1616;
    --ok-text: #9fe3b7; --warn-text: #ffd38a; --danger-text: #ffb3b3;
    --flash-live: #4a3d0d;
}
[data-theme="dark"] .brand { color: #fff; }
[data-theme="dark"] .stat::before { background: #36423d; }
