/* Tutorframe. Layout: Frame Green rail on the left, warm paper workspace on the right;
   on phones the rail becomes a top bar with sideways tabs.
   Colours come from the Tutorframe brand system. The tutor app and sign-in screen
   swap the brand colour for the client's own (see client.js, .client-scope).
   White label: every screen, admin included, uses .client-scope, so the client's colour
   drives light mode brand bits and the whole dark mode. These :root values are the fallback. */
:root {
  --bg: #faf7f1;            /* paper */
  --surface: #ffffff;       /* surface-raised */
  --surface-2: #f5f1e8;
  --sand: #eee8dc;
  --border: #e2ddd2;        /* line: decorative only */
  --border-strong: #848b85; /* line-strong: control borders */
  --text: #18221f;          /* ink */
  --text-2: #34403b;
  --muted: #56615c;         /* ink-muted */
  --faint: #7d8782;
  --primary: #1e4d42;       /* brand: Frame Green */
  --primary-hover: #163a32;
  --primary-soft: #dcebe4;  /* brand-tint */
  --primary-text: #1e4d42;
  --on-primary: #ffffff;    /* on-brand */
  --accent: #f0a531;        /* Marigold: one highlight per screen, fills only */
  --on-accent: #18221f;
  --rail: #1e4d42;
  --rail-text: rgb(250 247 241 / .74);
  --rail-strong: #faf7f1;
  --rail-hover: rgb(250 247 241 / .08);
  --rail-active: rgb(250 247 241 / .14);
  --rail-line: rgb(250 247 241 / .14);
  --green: #1e4d42; --green-soft: #dcebe4;   /* confirmations use brand */
  --amber: #7a4f06; --amber-soft: #fcefd6;
  --red: #b23a2a; --red-soft: #fbe9e5;       /* danger */
  --toast-bg: #18221f; --toast-fg: #faf7f1;
  --backdrop: rgb(24 34 31 / .45);
  --focus-ring: rgb(30 77 66 / .22);
  --shadow-sm: none;
  --shadow-lg: 0 24px 60px -16px rgb(24 34 31 / .35);
  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --font-body: "Figtree", "Segoe UI", system-ui, sans-serif;
  --radius: 10px;     /* radius-md: cards, buttons */
  --radius-sm: 6px;   /* radius-sm: inputs, badges */
  --radius-lg: 16px;  /* radius-lg: modals */
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #101816; --surface: #17221f; --surface-2: #1b2824; --sand: #22302b;
    --border: #2a3732; --border-strong: #6e7e77;
    --text: #edf1ee; --text-2: #cfd8d3; --muted: #a7b3ad; --faint: #7f8d86;
    --primary: #6cc2a6; --primary-hover: #8dd3bb; --primary-soft: #1d3830; --primary-text: #8dd3bb; --on-primary: #0c1f19;
    --accent: #f2b451; --on-accent: #18221f;
    --rail: #0c1512; --rail-text: rgb(237 241 238 / .68); --rail-strong: #edf1ee;
    --rail-hover: rgb(237 241 238 / .06); --rail-active: rgb(108 194 166 / .16); --rail-line: rgb(237 241 238 / .1);
    --green: #6cc2a6; --green-soft: #1d3830; --amber: #f2b451; --amber-soft: #33270f; --red: #f08c7a; --red-soft: #3a1a15;
    --toast-bg: #edf1ee; --toast-fg: #101816; --backdrop: rgb(0 0 0 / .6); --focus-ring: rgb(108 194 166 / .28);
    --shadow-lg: 0 24px 60px rgb(0 0 0 / .6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #101816; --surface: #17221f; --surface-2: #1b2824; --sand: #22302b;
  --border: #2a3732; --border-strong: #6e7e77;
  --text: #edf1ee; --text-2: #cfd8d3; --muted: #a7b3ad; --faint: #7f8d86;
  --primary: #6cc2a6; --primary-hover: #8dd3bb; --primary-soft: #1d3830; --primary-text: #8dd3bb; --on-primary: #0c1f19;
  --accent: #f2b451; --on-accent: #18221f;
  --rail: #0c1512; --rail-text: rgb(237 241 238 / .68); --rail-strong: #edf1ee;
  --rail-hover: rgb(237 241 238 / .06); --rail-active: rgb(108 194 166 / .16); --rail-line: rgb(237 241 238 / .1);
  --green: #6cc2a6; --green-soft: #1d3830; --amber: #f2b451; --amber-soft: #33270f; --red: #f08c7a; --red-soft: #3a1a15;
  --toast-bg: #edf1ee; --toast-fg: #101816; --backdrop: rgb(0 0 0 / .6); --focus-ring: rgb(108 194 166 / .28);
  --shadow-lg: 0 24px 60px rgb(0 0 0 / .6);
  color-scheme: dark;
}

* { box-sizing: border-box; }
body {
  margin: 0; font: 400 14px/1.55 var(--font-body); -webkit-font-smoothing: antialiased;
  background: var(--bg); color: var(--text); display: flex; min-height: 100vh;
}
svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
button { font-family: inherit; }
a { color: var(--primary-text); }
/* Focus ring: 2px brand with a 2px gap. */
button:focus-visible, a:focus-visible, [tabindex]:focus-visible { outline: 2px solid var(--primary-text); outline-offset: 2px; }
.sidebar :focus-visible, #login :focus-visible { outline-color: currentColor; }
#login .login-card :focus-visible { outline-color: var(--primary-text); }

/* ---------- brand rail ---------- */
.sidebar {
  width: 248px; flex-shrink: 0; background: var(--rail); color: var(--rail-text);
  padding: 28px 16px 18px; position: sticky; top: env(safe-area-inset-top, 0px); height: 100vh;
  display: flex; flex-direction: column;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px 28px; }
.brand-logo { display: block; width: 112px; height: auto; }
.brand-text { min-width: 0; }
.brand-name { font: 600 16px/1.25 var(--font-body); color: var(--rail-strong); }
.brand-sub { font-size: 12px; color: var(--rail-text); margin-top: 3px; }
.brand-stack { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.brand-stack .brand-sub { margin: 0; }
.client-badge { width: 36px; height: 36px; border-radius: var(--radius); display: grid; place-items: center; flex-shrink: 0; font: 600 17px/1 var(--font-body); background: var(--rail-strong); color: var(--rail); }
.client-logo { height: 36px; width: auto; max-width: 140px; border-radius: var(--radius-sm); background: #fff; padding: 4px 6px; flex-shrink: 0; }
nav { flex: 1; display: flex; flex-direction: column; gap: 2px; }
nav a {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--radius);
  color: var(--rail-text); text-decoration: none; font-weight: 400; font-size: 14px; cursor: pointer;
  transition: background .15s, color .15s;
}
nav a svg { width: 18px; height: 18px; opacity: .8; }
nav a:hover { background: var(--rail-hover); color: var(--rail-strong); }
nav a.active { background: var(--rail-active); color: var(--rail-strong); font-weight: 600; }
nav a.active svg { opacity: 1; }
.sidebar-foot { font-size: 12px; padding: 14px 12px 0; display: flex; align-items: center; gap: 9px; border-top: 1px solid var(--rail-line); }
.sync-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--rail-text); opacity: .5; flex-shrink: 0; }
.sync-dot.on { background: var(--accent); opacity: 1; }
.sync-dot.off { background: #f08c7a; opacity: 1; }
.client-scope .sync-dot.on { background: var(--rail-strong); } /* Marigold stays a Tutorframe-only accent */
.powered { font-size: 12px; line-height: 16px; color: var(--rail-text); padding: 8px 12px 0; }
.powered b { font-weight: 600; color: var(--rail-strong); }

/* ---------- workspace ---------- */
main { flex: 1; min-width: 0; padding: 40px 40px 72px; display: flex; flex-direction: column; }
main > * { width: 100%; max-width: 1120px; margin-left: auto; margin-right: auto; }
.crumb { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-size: 13px; font-weight: 600; margin-bottom: 16px; cursor: pointer; background: none; border: 0; padding: 0; width: auto; margin-left: 0; }
.crumb:hover { color: var(--primary-text); }
.crumb svg { width: 14px; height: 14px; }
.page-head { display: flex; align-items: flex-end; gap: 16px 24px; margin-bottom: 24px; flex-wrap: wrap; }
.page-head > :first-child { flex: 1; min-width: 240px; }
.page-head h1 { margin: 0; font: 600 28px/34px var(--font-body); letter-spacing: -.01em; display: flex; align-items: center; gap: 14px; text-wrap: balance; color: var(--text); }
.page-head .sub { margin: 8px 0 0; color: var(--muted); max-width: 68ch; font-size: 14px; line-height: 20px; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.profile-head { display: flex; align-items: center; gap: 16px; }
.profile-head .avatar { width: 52px; height: 52px; font-size: 17px; border-radius: var(--radius); }
.app-foot { margin-top: auto; padding-top: 40px; display: flex; align-items: center; gap: 8px; justify-content: center; font-size: 12px; line-height: 16px; color: var(--muted); }
.app-foot img { width: 96px; height: auto; display: block; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 16px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  border-radius: var(--radius); font: 600 14px/1 var(--font-body); cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s; text-decoration: none;
}
.btn:hover { border-color: var(--primary); color: var(--primary-text); }
.btn svg { width: 16px; height: 16px; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); color: var(--on-primary); }
.btn[hidden] { display: none; } /* .btn's display would otherwise override the hidden attribute (e.g. Delete on new forms) */
.btn.wrap { height: auto; min-height: 36px; padding-top: 8px; padding-bottom: 8px; white-space: normal; text-align: left; line-height: 1.35; }
.btn.danger { color: var(--red); }
.btn.danger:hover, .btn.danger.armed { background: var(--red-soft); border-color: var(--red); color: var(--red); }
.btn.small { height: 32px; padding: 0 12px; font-size: 13px; border-radius: var(--radius-sm); }
.btn.ghost { border-color: transparent; background: none; color: var(--muted); }
.btn.ghost:hover { background: var(--sand); color: var(--text); border-color: transparent; }
.btn[disabled] { opacity: .6; cursor: default; }
.icon-btn { border: 0; background: none; color: var(--muted); cursor: pointer; width: 36px; height: 36px; border-radius: var(--radius); display: grid; place-items: center; }
.icon-btn:hover { background: var(--sand); color: var(--text); }
.icon-btn svg { width: 18px; height: 18px; }

/* ---------- KPI strip ---------- */
.stats {
  display: flex; flex-wrap: wrap; gap: 1px;
  background: var(--border); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; margin-bottom: 24px;
}
/* Stats grow to fill their row, so a short last row never leaves a grey gap. */
.stat { background: var(--surface); padding: 20px 24px; min-width: 0; flex: 1 1 190px; }
.stat-label { font-size: 12px; line-height: 16px; font-weight: 600; color: var(--muted); }
.stat-value { font: 600 28px/34px var(--font-body); letter-spacing: -.01em; margin-top: 8px; color: var(--text); font-variant-numeric: tabular-nums; white-space: nowrap; }
.stat-sub { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ---------- panels ---------- */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 24px; overflow: hidden; }
.panel-head { display: flex; align-items: center; gap: 8px; padding: 16px 24px; min-height: 60px; border-bottom: 1px solid var(--border); }
.panel-head h2 { margin: 0; font-size: 16px; line-height: 24px; font-weight: 600; flex: 1; color: var(--text); }
.panel-head .hint { color: var(--muted); font-size: 13px; }
.panel-body { padding: 24px; }
.panel-body.flush { padding: 0; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-bottom: 24px; align-items: start; }
.grid-2 > .panel { margin-bottom: 0; min-width: 0; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 14px 24px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: 12px; line-height: 16px; color: var(--muted); font-weight: 600; white-space: nowrap; padding-top: 12px; padding-bottom: 12px; background: var(--surface-2); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr.clickable { cursor: pointer; transition: background .12s; }
tbody tr.clickable:hover { background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.right, th.right { text-align: right; }
.toolbar { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; padding: 16px 24px; border-bottom: 1px solid var(--border); }
.toolbar .grow { flex: 1; }
.person { display: flex; align-items: center; gap: 12px; min-width: 0; }
.person .name { font-weight: 600; color: var(--text); }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0; font-size: 12px; font-weight: 600; letter-spacing: .02em; }
.small { font-size: 12px; }
.muted { color: var(--muted); }
.strong { font-weight: 600; }
.amount-owed { color: var(--amber); font-weight: 600; font-variant-numeric: tabular-nums; }
.tag { display: inline-block; padding: 2px 10px; border-radius: var(--radius-sm); font-size: 12px; font-weight: 600; background: var(--sand); color: var(--text-2); margin: 2px 4px 2px 0; }
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px 3px 9px; border-radius: var(--radius-sm); font-size: 12px; line-height: 16px; font-weight: 600; white-space: nowrap; background: var(--sand); color: var(--muted); }
.badge i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.green { background: var(--green-soft); color: var(--green); }
.badge.amber { background: var(--amber-soft); color: var(--amber); }
.badge.red { background: var(--red-soft); color: var(--red); }
.badge.accent { background: var(--primary-soft); color: var(--primary-text); }
.empty { text-align: center; color: var(--muted); padding: 40px 24px; }
.empty-icon { width: 44px; height: 44px; border-radius: var(--radius); background: var(--primary-soft); display: grid; place-items: center; margin: 0 auto 12px; color: var(--primary-text); }
.empty-icon svg { width: 20px; height: 20px; }

/* ---------- to-do list (dashboard) ---------- */
.todo { list-style: none; margin: 0; padding: 0; }
.todo li { display: flex; align-items: center; gap: 16px; padding: 14px 24px; border-bottom: 1px solid var(--border); cursor: pointer; transition: background .12s; }
.todo li:last-child { border-bottom: 0; }
.todo li:hover { background: var(--surface-2); }
.todo .grow { flex: 1; min-width: 0; }
.todo .what { font-size: 12px; color: var(--muted); }

/* ---------- inputs ---------- */
input, select, textarea {
  font: 400 14px/1.4 var(--font-body); color: var(--text); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 8px 12px; width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
input, select { height: 40px; }
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--focus-ring); }
input::placeholder, textarea::placeholder { color: var(--faint); }
.search { position: relative; }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search input { padding-left: 36px; width: 280px; background: var(--surface); }
.toolbar select, .toolbar input[type=date] { width: auto; min-width: 150px; }
.toolbar label { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); font-weight: 600; }

dl.info { display: grid; grid-template-columns: 130px 1fr; gap: 12px 16px; margin: 0; }
dl.info dt { color: var(--muted); font-size: 13px; }
dl.info dd { margin: 0; white-space: pre-wrap; min-width: 0; overflow-wrap: anywhere; }

/* ---------- weekly updates ---------- */
.update { padding: 24px; border-bottom: 1px solid var(--border); }
.update:last-child { border-bottom: 0; }
.update-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.update-head .who { flex: 1; min-width: 200px; }
.update-body { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px 24px; padding-left: 44px; }
.update-body .label { font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
.update-body p { margin: 0; white-space: pre-wrap; color: var(--text-2); overflow-wrap: anywhere; }

/* ---------- notices & loading ---------- */
.notice { display: flex; gap: 16px; align-items: flex-start; padding: 20px 24px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); margin-bottom: 24px; }
.notice-mark { width: 40px; height: 40px; border-radius: var(--radius); background: var(--primary-soft); color: var(--primary-text); display: grid; place-items: center; flex-shrink: 0; }
.notice.warn { background: var(--amber-soft); border-color: transparent; color: var(--amber); }
.notice p { margin: 0; }
.notice .title { font-weight: 600; color: var(--text); margin-bottom: 2px; }
.notice.warn .title { color: inherit; }
.notice.danger { background: var(--red-soft); border-color: transparent; color: var(--red); }
.notice.danger .title { color: inherit; }
.skeleton { height: 14px; border-radius: var(--radius-sm); background: var(--sand); margin: 16px 24px; }
.skeleton.w60 { width: 60%; } .skeleton.w40 { width: 40%; } .skeleton.w75 { width: 75%; }

/* ---------- modal ---------- */
dialog { border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 0; width: min(640px, calc(100vw - 32px)); background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); }
dialog[open] { animation: pop .18s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.985); } }
dialog::backdrop { background: var(--backdrop); backdrop-filter: blur(3px); }
dialog header, dialog footer { display: flex; align-items: center; gap: 8px; padding: 16px 24px; }
dialog header { justify-content: space-between; border-bottom: 1px solid var(--border); }
dialog header h2 { margin: 0; font: 600 20px/28px var(--font-body); }
dialog footer { border-top: 1px solid var(--border); background: var(--surface-2); flex-wrap: wrap; }
dialog footer .spacer { flex: 1; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; padding: 24px; max-height: 64vh; overflow-y: auto; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid label { display: flex; flex-direction: column; gap: 8px; font-size: 13px; font-weight: 600; color: var(--text-2); min-width: 0; }
.form-grid label.check { flex-direction: row; align-items: center; gap: 8px; cursor: pointer; }
.form-grid label.check input { width: 18px; height: 18px; accent-color: var(--primary); }
.form-grid .help { font-weight: 400; color: var(--muted); }
.form-grid .req { color: var(--red); }
.form-grid .section { grid-column: 1 / -1; font-size: 12px; font-weight: 600; color: var(--primary-text); padding-top: 4px; }
.form-grid .section:not(:first-child) { border-top: 1px solid var(--border); padding-top: 20px; margin-top: 4px; }
.form-error { grid-column: 1 / -1; background: var(--red-soft); color: var(--red); border-radius: var(--radius-sm); padding: 10px 14px; font-size: 13px; }

/* tutor matcher */
.suggest { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.suggest .help { display: block; margin-bottom: 12px; font-size: 12px; font-weight: 600; color: var(--primary-text); }
.suggest-list { display: flex; flex-direction: column; gap: 8px; }
.suggest-item { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 12px 16px; border: 1px solid var(--border-strong); background: var(--surface); border-radius: var(--radius); cursor: pointer; font: inherit; color: var(--text); transition: border-color .15s, background .15s, box-shadow .15s; }
.suggest-item:hover { border-color: var(--primary); }
.suggest-item.picked { border-color: var(--primary); background: var(--primary-soft); box-shadow: 0 0 0 3px var(--focus-ring); }
.suggest-item .grow { flex: 1; min-width: 0; }
.copy-box { width: 100%; min-height: 220px; font-size: 13px; }

#toast { position: fixed; bottom: calc(28px + env(safe-area-inset-bottom, 0px)); left: 50%; background: var(--toast-bg); color: var(--toast-fg); padding: 12px 20px; border-radius: var(--radius); font-weight: 600; font-size: 14px; box-shadow: var(--shadow-lg); opacity: 0; transform: translate(-50%, 10px); transition: .2s; pointer-events: none; max-width: calc(100vw - 32px); }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) { *, dialog[open] { animation: none !important; transition: none !important; } }

@media (max-width: 1000px) { .grid-2 { grid-template-columns: 1fr; } }
@media (max-width: 860px) {
  body { flex-direction: column; }
  .sidebar { width: auto; height: auto; position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; padding: 14px 0 0; }
  .brand { padding: 0 16px 12px; }
  .brand-logo { width: 112px; }
  .brand-stack { flex-direction: row; align-items: center; gap: 12px; }
  .brand-stack .brand-sub { display: none; }
  .client-badge { width: 32px; height: 32px; font-size: 15px; }
  .brand-name { font-size: 15px; }
  nav { flex-direction: row; gap: 4px; overflow-x: auto; padding: 0 12px 12px; scrollbar-width: none; }
  nav::-webkit-scrollbar { display: none; }
  nav a { flex-shrink: 0; padding: 8px 12px; }
  .sidebar-foot, .foot-user, .powered { display: none; }
  main { padding: 24px 16px 40px; }
  .page-head { margin-bottom: 20px; }
  .page-head h1 { font-size: 24px; line-height: 30px; }
  .page-head .actions { width: 100%; }
  .stats { margin-bottom: 16px; }
  .stat { padding: 16px; flex-basis: 40%; }
  .stat-value { font-size: clamp(18px, 5.2vw, 22px); line-height: 1.2; }
  .todo .btn { display: none; }
  .todo li::after { content: "\203A"; font-size: 22px; line-height: 1; color: var(--muted); }
  .grid-2 { gap: 16px; margin-bottom: 16px; }
  .panel { margin-bottom: 16px; }
  .panel-head, .toolbar { padding-left: 16px; padding-right: 16px; }
  .todo li { padding: 12px 16px; }
  .form-grid { grid-template-columns: 1fr; padding: 16px; }
  dialog { width: calc(100vw - 16px); max-height: 92vh; }
  dialog header, dialog footer { padding: 14px 16px; }
  input, select, textarea { font-size: 16px; }
  .search, .search input { width: 100%; }
  .toolbar label { width: 100%; justify-content: space-between; }
  .toolbar select, .toolbar input[type=date] { flex: 1; min-width: 0; }
  .update { padding: 16px; }
  .update-body { padding-left: 0; }
  dl.info { grid-template-columns: 110px 1fr; }
  th, td { padding-left: 16px; padding-right: 16px; white-space: nowrap; }
}

/* ---------- sign in (client-branded, "Powered by Tutorframe") ---------- */
body.locked > .sidebar, body.locked > main { visibility: hidden; }
#login { position: fixed; inset: 0; z-index: 50; display: flex; flex-direction: column; align-items: center; gap: 24px; padding: 40px 16px; background: var(--bg); overflow-y: auto; }
#login > :first-child { margin-top: auto; }
#login > :last-child { margin-bottom: auto; }
.login-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 32px; display: flex; flex-direction: column; gap: 8px; position: relative; }
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.login-brand .client-badge { background: var(--primary); color: var(--on-primary); }
.login-brand .client-logo { padding: 0; height: 40px; }
.login-brand-name { font-weight: 600; font-size: 16px; line-height: 20px; color: var(--text); }
.login-card h1 { margin: 0; font: 600 20px/28px var(--font-body); color: var(--text); }
.login-sub { margin: 0 0 8px; font-size: 14px; line-height: 20px; color: var(--muted); }
.login-card label { font-size: 12px; line-height: 16px; font-weight: 600; color: var(--text); margin-top: 8px; }
.login-card input, .login-card select { height: 44px; font-size: 16px; }
.login-card .btn.login-alt { width: 100%; margin: 4px 0 16px; }
.login-card .btn { height: 44px; justify-content: center; margin-top: 16px; font-size: 16px; }
.login-error { background: var(--red-soft); color: var(--red); border-radius: var(--radius-sm); padding: 10px 12px; font-size: 13px; margin-top: 8px; }
.login-error.info { background: var(--primary-soft); color: var(--text); }
.login-check { display: flex !important; gap: 10px; align-items: flex-start; margin-top: 16px !important; font-weight: 400 !important; font-size: 13px !important; line-height: 19px !important; color: var(--text-2) !important; cursor: pointer; }
.login-check input { width: 20px; height: 20px !important; flex-shrink: 0; margin: 0; accent-color: var(--primary); }
.login-check a, .login-privacy { color: var(--primary-text); }
.login-privacy { font-size: 12px; }
.link-btn { display: block; border: 0; background: none; padding: 4px 0; margin: 0 auto; color: var(--primary-text); font: 600 13px/1.4 var(--font-body); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.login-note { margin: 8px 0 0; font-size: 13px; line-height: 18px; color: var(--muted); }
.login-close { position: absolute; top: 12px; right: 12px; width: 36px; height: 36px; border: 0; background: none; border-radius: var(--radius); font-size: 22px; color: var(--muted); cursor: pointer; }
.login-close:hover { background: var(--sand); color: var(--text); }
.login-powered { display: flex; align-items: center; gap: 8px; font-size: 12px; line-height: 16px; color: var(--muted); }
.login-powered img { width: 96px; height: auto; display: block; }
/* Dark theme swaps the Frame Green logo for the paper (reversed) version. */
.logo-dark { display: none !important; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .logo-light { display: none !important; } :root:not([data-theme="light"]) .logo-dark { display: block !important; } }
:root[data-theme="dark"] .logo-light { display: none !important; }
:root[data-theme="dark"] .logo-dark { display: block !important; }
.signout { margin-left: auto; border: 0; background: none; color: var(--rail-text); width: 32px; height: 32px; border-radius: var(--radius); display: grid; place-items: center; cursor: pointer; }
.signout:hover { background: var(--rail-hover); color: var(--rail-strong); }

/* ---------- accounts ---------- */
.acct-btn { margin-left: auto; width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--rail-line); background: var(--rail-hover); color: var(--rail-strong); font: 600 12px/1 var(--font-body); cursor: pointer; flex-shrink: 0; }
.acct-btn:hover { background: var(--rail-active); }
.theme-btn { display: grid; place-items: center; padding: 0; }
.theme-btn svg { width: 16px; height: 16px; }
.theme-btn + .acct-btn { margin-left: 6px; }
/* Admin rail: the logo keeps its clear space; the two round buttons sit to its right. */
.brand:has(.brand-stack) { gap: 0; }
.brand:has(.brand-stack) .brand-stack { flex: none; width: 112px; margin-right: 16px; }
/* Password boxes: a Show / Hide button inside the box. */
.pw-wrap { position: relative; }
.pw-wrap input { width: 100%; padding-right: 72px; }
.pw-toggle { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); height: 32px; padding: 0 10px; border: 0; background: none; border-radius: var(--radius-sm); color: var(--primary-text); font: 600 13px/1 var(--font-body); cursor: pointer; }
.pw-toggle:hover { background: var(--primary-soft); }
.foot-user { font-size: 12px; padding: 6px 12px 0 28px; color: var(--rail-text); }
.row-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; min-width: 150px; }
.link-box { display: flex; gap: 8px; }
.link-box input { flex: 1; min-width: 0; font-size: 13px; background: var(--surface-2); }

/* ---------- week calendar ---------- */
.cal-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 16px 24px; border-bottom: 1px solid var(--border); }
.cal-bar .range { font-weight: 600; font-size: 16px; min-width: 190px; font-variant-numeric: tabular-nums; }
.cal-bar .grow { flex: 1; }
.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 1px; background: var(--border); }
.day { background: var(--surface); min-height: 190px; display: flex; flex-direction: column; min-width: 0; }
.day.past { background: var(--surface-2); }
.day-head { display: flex; align-items: baseline; gap: 8px; padding: 12px 12px 8px; }
.dow { font-size: 12px; font-weight: 600; color: var(--muted); }
.dnum { font-size: 16px; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
.day.today .dnum { background: var(--primary); color: var(--on-primary); border-radius: var(--radius-sm); padding: 0 8px; }
.day-body { display: flex; flex-direction: column; gap: 8px; padding: 4px 8px 12px; }
.day-empty { font-size: 12px; color: var(--muted); padding: 2px 4px; }
.chip { border-radius: var(--radius-sm); padding: 8px 10px; background: var(--primary-soft); border: 1px solid transparent; cursor: pointer; min-width: 0; transition: border-color .15s; }
.chip:hover { border-color: var(--primary); }
.chip.s-completed { background: var(--surface-2); border-color: var(--border); }
.chip.s-no-show { background: var(--amber-soft); }
.chip.s-cancelled { background: var(--sand); opacity: .75; }
.chip.s-cancelled .chip-who { text-decoration: line-through; }
.chip.overdue { background: var(--amber-soft); }
.chip-top { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 2px 6px; }
.chip-time { font-size: 12px; font-weight: 600; color: var(--text-2); font-variant-numeric: tabular-nums; }
.chip-status { font-size: 11px; font-weight: 600; color: var(--muted); }
.chip.s-completed .chip-status { color: var(--green); }
.chip.overdue .chip-status, .chip.s-no-show .chip-status { color: var(--amber); }
.chip-who { font-size: 13px; font-weight: 600; color: var(--text); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip-what { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Time clash: a tutor has two lessons that overlap. Always a word and an icon, never colour alone. */
.chip.clash { border-color: var(--red); }
.clash-word { color: var(--red); font-weight: 600; }
.chip-clash { display: flex; align-items: center; gap: 4px; margin-top: 4px; font-size: 11px; font-weight: 600; color: var(--red); }
.chip-clash svg { width: 13px; height: 13px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tick { width: 28px; height: 28px; border-radius: 50%; border: 1.5px solid var(--primary); background: var(--surface); color: var(--primary-text); display: grid; place-items: center; cursor: pointer; padding: 0; }
.tick svg { width: 14px; height: 14px; stroke-width: 2.5; }
.tick:hover { background: var(--primary); color: var(--on-primary); }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; border: 1px solid var(--border-strong); }

/* ---------- timesheet ---------- */
.status-line { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.review-sum { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--border); border-radius: var(--radius); overflow: hidden; }
.review-sum div { background: var(--surface-2); padding: 12px 16px; }
.review-sum b { display: block; font-size: 18px; color: var(--text); font-variant-numeric: tabular-nums; }
.review-sum span { font-size: 12px; font-weight: 600; color: var(--muted); }
.history { font-size: 12px; color: var(--muted); margin: 4px 0 0; padding-left: 16px; }

@media (max-width: 860px) {
  .week { grid-template-columns: 1fr; }
  .day { min-height: 0; flex-direction: row; }
  .day-head { flex-direction: column; align-items: center; width: 58px; flex-shrink: 0; padding: 12px 6px; gap: 2px; }
  .day-body { flex: 1; padding: 10px 12px 10px 0; }
  .day-empty { padding-top: 8px; }
  .cal-bar { padding: 12px 16px; }
  .cal-bar .range { min-width: 0; }
  .acct-btn { margin-left: auto; }
}
.app-foot .foot-link { margin-left: 8px; padding-left: 10px; border-left: 1px solid var(--border); color: var(--muted); text-decoration: underline; text-underline-offset: 2px; }
.app-foot .foot-link:hover { color: var(--text); }

/* ---------- loading screen ---------- */
.splash { position: fixed; inset: 0; z-index: 60; display: flex; flex-direction: column; align-items: center; padding: 40px 24px calc(32px + env(safe-area-inset-bottom, 0px)); background: var(--rail); color: var(--rail-strong); transition: opacity .35s ease; }
.splash.done { opacity: 0; pointer-events: none; }
.splash-mid { margin: auto 0; display: flex; flex-direction: column; align-items: center; gap: 16px; text-align: center; }
.splash .client-badge.splash-badge { width: 72px; height: 72px; border-radius: 20px; font-size: 32px; background: var(--rail-strong); color: var(--rail); }
.splash .client-logo.splash-badge { height: 72px; max-width: 220px; padding: 10px 14px; border-radius: 16px; }
.splash-name { font: 600 20px/28px var(--font-body); }
.splash-logo { width: 168px; height: auto; display: block; }
.splash-bar { width: 96px; height: 3px; border-radius: 3px; overflow: hidden; background: color-mix(in srgb, currentColor 22%, transparent); margin-top: 8px; }
.splash-bar i { display: block; width: 40%; height: 100%; border-radius: inherit; background: currentColor; animation: tf-load 1.1s ease-in-out infinite; }
.splash-foot { font-size: 12px; line-height: 16px; opacity: .72; }
@keyframes tf-load { from { transform: translateX(-100%); } to { transform: translateX(250%); } }

/* ---------- menu labels: full in the side menu, short in the phone bar ---------- */
nav .ns, .nav-more { display: none; }
.more-sheet[hidden] { display: none; }

/* ---------- phone: menu bar along the bottom ---------- */
@media (max-width: 860px) {
  .sidebar { padding-bottom: 0; }
  #nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; flex: none; flex-direction: row; gap: 2px; overflow: visible; padding: 6px 6px calc(6px + env(safe-area-inset-bottom, 0px)); background: var(--surface); border-top: 1px solid var(--border); box-shadow: 0 -4px 16px rgb(0 0 0 / .06); }
  #nav a { flex: 1 1 0; min-width: 0; flex-direction: column; gap: 4px; padding: 6px 2px 5px; border-radius: var(--radius); color: var(--muted); font-size: 11px; line-height: 14px; font-weight: 600; text-align: center; }
  #nav a svg { width: 22px; height: 22px; opacity: 1; flex-shrink: 0; }
  #nav a:hover { background: none; color: var(--text); }
  #nav a.active, #nav a.open { background: var(--primary-soft); color: var(--primary-text); }
  #nav .nl, #nav a.nav-extra { display: none; }
  #nav .ns { display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  #nav .nav-more { display: flex; }
  main { padding-bottom: calc(96px + env(safe-area-inset-bottom, 0px)); }
  #toast { bottom: calc(88px + env(safe-area-inset-bottom, 0px)); }
  .more-sheet { position: fixed; inset: 0; z-index: 29; }
  .more-back { position: absolute; inset: 0; background: rgb(0 0 0 / .32); }
  .more-panel { position: absolute; left: 8px; right: 8px; bottom: calc(76px + env(safe-area-inset-bottom, 0px)); flex: none; display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 8px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); }
  .more-panel a { gap: 10px; padding: 12px; color: var(--text); font-size: 14px; font-weight: 600; }
  .more-panel a svg { width: 20px; height: 20px; opacity: 1; color: var(--muted); }
  .more-panel a:hover { background: var(--surface-2); color: var(--text); }
  .more-panel a.active { background: var(--primary-soft); color: var(--primary-text); }
  .more-panel a.active svg { color: currentColor; }
}
@media (min-width: 861px) { .more-sheet { display: none !important; } }

/* ---------- round client logos (a circular badge, already on white) ---------- */
.client-logo.round { padding: 0; background: none; border-radius: 50%; aspect-ratio: 1; object-fit: contain; }
.login-brand .client-logo.round { height: 48px; }
.splash .client-logo.round.splash-badge { height: 128px; padding: 0; border-radius: 50%; background: none; box-shadow: 0 8px 28px rgb(0 0 0 / .28); }
