/* Lowest-priority layer for generic element rules, so the calendar library's own (layered) styles are not overridden. */
@layer app-base, theme, base, df-theme, components, utilities;

@font-face{font-family:'Manrope';font-style:normal;font-weight:400 800;font-display:swap;src:url(vendor/fonts/manrope-vietnamese.woff2) format('woff2');unicode-range:U+0102-0103,U+0110-0111,U+0128-0129,U+0168-0169,U+01A0-01A1,U+01AF-01B0,U+0300-0301,U+0303-0304,U+0308-0309,U+0323,U+0329,U+1EA0-1EF9,U+20AB}
@font-face{font-family:'Manrope';font-style:normal;font-weight:400 800;font-display:swap;src:url(vendor/fonts/manrope-latin-ext.woff2) format('woff2');unicode-range:U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C4,U+2113,U+2C60-2C7F,U+A720-A7FF}
@font-face{font-family:'Manrope';font-style:normal;font-weight:400 800;font-display:swap;src:url(vendor/fonts/manrope-latin.woff2) format('woff2');unicode-range:U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD}

:root {
  /* Bytewise design system (site/assets/css/site.*.css; .claude/skills/bytewise-design): warm paper, ink-navy text,
     mint accent (fill only), coral highlight, pill controls, soft cards, hard offset shadows on things that pop. */
  --brand-ink: #1f2633;
  --brand-accent: #3dd9a0;
  --brand-secondary: #ff6b4a;
  --accent-ink: #0b7a52;
  --accent-soft: #c9f5e3;
  --accent-wash: #eefcf6;
  --coral-ink: #c4391a;
  --coral-soft: #ffe6df;
  --sun-soft: #fff3d6;
  --sun-ink: #7a5200;
  --info-soft: #e7efff;
  --info-ink: #1d4ed8;
  --primary: #0b7a52;          /* text/icon accent on light (mint itself is a fill only) */
  --primary-active: #075c3d;
  --secondary: #1f2633;        /* the one dark island (hero) is ink */
  --canvas: #ffffff;
  --paper: #f2f1eb;
  --surface-muted: #f8f7f2;
  --ink: #1f2633;
  --ink-2: #121722;
  --muted: #5f6672;
  --faint: #6e7581;
  --hairline: #e2e0d8;
  --input-border: #b4b6b8;
  --green: #0b7a52;
  --orange: #c4391a;
  --r-xs: 8px; --r-sm: 10px; --r-md: 12px; --r-lg: 18px; --r-xl: 24px; --r-full: 9999px;
  --shadow-1: 0 1px 2px rgba(18,23,34,.04), 0 4px 14px rgba(18,23,34,.05);
  --shadow-2: 0 12px 32px rgba(18,23,34,.12);
  --pop: 3px 3px 0 var(--brand-ink);
  --ease-brand: cubic-bezier(.22,1,.36,1);
  --font-sans: Manrope, -apple-system, system-ui, "Segoe UI", Helvetica, Arial, sans-serif;
}

@layer app-base {
  * { box-sizing: border-box; }
  button, input, select, textarea { font: inherit; color: inherit; }
  h1, h2, h3, h4 { margin: 0; }
}
body {
  margin: 0;
  font: 15px/1.5 var(--font-sans);
  font-feature-settings: "lnum", "locl";
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}
/* ---------- nav ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 8px 28px;
  padding: 0 24px; min-height: 60px;
  background: rgba(255,255,255,.86); backdrop-filter: saturate(1.4) blur(12px); -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--hairline);
}
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; flex: none; }
.brand-mark { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; color: #fff; background: linear-gradient(145deg, #2f45b5, var(--secondary)); box-shadow: 0 1px 2px rgba(33,49,131,.35), inset 0 1px 0 rgba(255,255,255,.18); }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text b { font-size: 15px; font-weight: 700; letter-spacing: -.2px; }
.brand-text small { font-size: 12px; color: var(--muted); }

.tabs { display: flex; align-self: stretch; gap: 2px; }
.tab {
  position: relative; display: inline-flex; align-items: center; gap: 8px;
  padding: 0 14px; border: 0; background: none; cursor: pointer;
  font-size: 14px; font-weight: 500; color: var(--muted); white-space: nowrap;
  transition: color .15s;
}
.tab svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.tab:hover { color: var(--ink); }
.tab.is-active { color: var(--ink); font-weight: 600; }
.tab.is-active svg { color: var(--primary); }
.tab::after { content: ''; position: absolute; left: 12px; right: 12px; bottom: -1px; height: 2px; border-radius: 2px 2px 0 0; background: var(--primary); transform: scaleX(0); transition: transform .18s ease; }
.tab.is-active::after { transform: scaleX(1); }
.tab:focus-visible { outline: 2px solid var(--primary); outline-offset: -4px; border-radius: var(--r-md); }

.topbar-end { margin-left: auto; display: flex; align-items: center; gap: 8px 16px; padding: 8px 0; }
.month-nav, .actions { display: flex; gap: 6px; align-items: center; }
.month-nav input[type=month] { padding: 5px 10px; border: 1px solid var(--input-border); border-radius: var(--r-md); background: var(--canvas); }
.ico { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.btn .ico { margin-right: 2px; }
.btn.icon-btn { width: 32px; padding: 0; }
.btn.icon-btn .ico { margin: 0; }
.menu-pop hr { border: 0; border-top: 1px solid var(--hairline); margin: 4px 2px; }

@media (max-width: 1500px) {
  .topbar { flex-wrap: wrap; padding-top: 8px; row-gap: 0; }
  .tabs { order: 3; width: 100%; overflow-x: auto; margin: 0 -8px; padding: 0 8px; min-height: 44px; scrollbar-width: none; }
  .topbar-end { padding: 0; }
}
@media (max-width: 760px) {
  .topbar { padding: 8px 12px 0; }
  .brand-text small { display: none; }
  .topbar-end { margin-left: auto; flex-wrap: wrap; justify-content: flex-end; }
  .actions .btn:not(.icon-btn):not(.primary) { font-size: 0; gap: 0; padding: 0 10px; }
  .actions .btn:not(.icon-btn):not(.primary) .ico { margin: 0; }
}

/* ---------- buttons ---------- */
.btn {
  border: 1px solid var(--hairline); background: var(--canvas); color: var(--ink);
  border-radius: var(--r-md); padding: 4px 14px; min-height: 32px;
  font-weight: 500; cursor: pointer; list-style: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  transition: background .15s, transform .1s;
}
.btn:hover { background: var(--paper); }
.btn:active { transform: scale(.96); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; border-radius: var(--r-full); padding: 6px 18px; }
.btn.primary:hover, .btn.primary:active { background: var(--primary-active); border-color: var(--primary-active); }
.btn.secondary { border-radius: var(--r-full); box-shadow: var(--shadow-1); }
.btn.ghost { border-color: transparent; color: var(--primary); }
.btn.ghost:hover { background: var(--accent-wash); }
.btn.icon { width: 32px; padding: 0; font-size: 18px; border-radius: var(--r-full); background: rgba(0,0,0,.05); border-color: transparent; }
.btn.icon:hover { background: rgba(0,0,0,.09); }
.btn.danger { color: var(--coral-ink); }
.btn.small { min-height: 28px; padding: 2px 12px; font-size: 13px; }
.btn.primary.small { padding: 2px 14px; }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }

.menu { position: relative; }
.menu summary::-webkit-details-marker { display: none; }
.menu-pop {
  position: absolute; right: 0; top: 40px; min-width: 250px; z-index: 20;
  background: var(--canvas); border: 1px solid var(--hairline); border-radius: var(--r-lg);
  box-shadow: var(--shadow-2); padding: 6px; display: flex; flex-direction: column;
}
.menu-pop button { text-align: left; border: 0; background: none; padding: 8px 10px; border-radius: var(--r-sm); cursor: pointer; }
.menu-pop button:hover { background: var(--paper); }
.danger-text { color: var(--coral-ink); }

/* ---------- layout ---------- */
main { max-width: 1240px; margin: 0 auto; padding: 32px 24px 64px; }
.eyebrow { font-size: 12px; font-weight: 600; letter-spacing: .125px; text-transform: uppercase; }

/* hero "night" band: the single dark island on the page */
.hero {
  display: grid; grid-template-columns: 1fr minmax(240px, 320px); gap: 32px; align-items: end;
  background: var(--secondary); color: #fff; border-radius: var(--r-xl); padding: 32px 36px; margin-bottom: 16px;
}
.hero .eyebrow { color: rgba(255,255,255,.7); }
.hero-title { font-size: 20px; font-weight: 600; letter-spacing: -.125px; margin-top: 8px; color: rgba(255,255,255,.9); }
.hero-value { font-size: clamp(36px, 6vw, 64px); font-weight: 700; line-height: 1; letter-spacing: -2.125px; margin: 8px 0 12px; font-variant-numeric: tabular-nums; }
.hero-hint { color: rgba(255,255,255,.75); font-size: 14px; }
.hero .up { color: var(--brand-accent); font-weight: 600; }
.hero .down { color: #ffb3a1; font-weight: 600; }
.hero-side { display: flex; flex-direction: column; gap: 10px; }
.hero-stat { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; color: rgba(255,255,255,.75); }
.hero-stat b { color: #fff; font-weight: 600; font-variant-numeric: tabular-nums; }
.progress { height: 6px; border-radius: var(--r-full); background: rgba(255,255,255,.18); overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--brand-accent); border-radius: var(--r-full); }

.daily { display: grid; grid-template-columns: 3fr 2fr; gap: 16px; margin-bottom: 16px; }
.day-card { position: relative; overflow: hidden; background: var(--canvas); border: 1px solid var(--hairline); border-radius: var(--r-xl); padding: 22px 26px; }
.day-card::before { content: ''; position: absolute; inset: 0 0 auto 0; height: 4px; background: var(--faint); opacity: .5; }
.day-card.today::before { background: linear-gradient(90deg, var(--accent-ink), var(--brand-accent) 55%, var(--primary)); opacity: 1; }
.day-card .eyebrow { color: var(--muted); }
.day-top { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.day-value { font-size: clamp(28px, 4vw, 40px); font-weight: 700; letter-spacing: -1.25px; line-height: 1.1; margin: 6px 0 4px; font-variant-numeric: tabular-nums; }
.today .day-value { color: var(--accent-ink); }
.yesterday .day-value { color: var(--ink-2); }
.day-hint { font-size: 14px; color: var(--muted); }
.day-hint b { color: var(--ink); }
.day-ring { position: relative; width: 84px; height: 84px; flex: none; }
.day-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.day-ring circle { fill: none; stroke-width: 8; }
.ring-bg { stroke: var(--paper); }
.ring-fg { stroke: var(--accent-ink); stroke-linecap: round; transition: stroke-dashoffset .6s ease; }
.day-ring span { position: absolute; inset: 0; display: grid; place-items: center; font-weight: 700; font-size: 16px; font-variant-numeric: tabular-nums; }
.day-list { list-style: none; margin: 14px 0 0; padding: 12px 0 0; border-top: 1px solid var(--hairline); display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.day-list li { display: grid; grid-template-columns: auto 1fr auto auto; align-items: center; gap: 4px 10px; }
.day-list .dot { width: 9px; height: 9px; border-radius: var(--r-full); }
.day-list .dn { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.day-list .dt { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.day-list b { font-weight: 600; min-width: 92px; text-align: right; font-variant-numeric: tabular-nums; }
.day-list .is-soon { color: var(--muted); }
.day-list .is-soon b { font-weight: 500; }
.day-list .is-soon .dn::after { content: ' · sắp tới'; font-size: 12px; }
.day-list .is-done .dn::before { content: '✓ '; color: var(--accent-ink); font-weight: 700; }
.day-list .more { display: block; color: var(--muted); font-size: 13px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-bottom: 16px; }
.kpi, .panel, .card { background: var(--canvas); border: 1px solid var(--hairline); border-radius: var(--r-lg); }
.kpi { padding: 20px 24px; }
.kpi .label { color: var(--muted); font-size: 12px; font-weight: 600; letter-spacing: .125px; text-transform: uppercase; }
.kpi .value { font-size: 26px; font-weight: 700; letter-spacing: -.625px; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .hint { font-size: 14px; color: var(--muted); margin-top: 2px; }

.panels { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 40px; }
.panel { padding: 24px; }
.panel h3 { font-size: 20px; font-weight: 600; letter-spacing: -.125px; margin-bottom: 16px; }

.bars { display: flex; flex-direction: column; gap: 12px; }
.bar-row { width: 100%; padding: 4px 6px; margin: -4px -6px; border: 0; border-radius: var(--r-md); background: none; font: inherit; color: inherit; text-align: left; cursor: pointer; display: grid; grid-template-columns: 130px 1fr 150px; gap: 12px; align-items: center; font-size: 14px; }
.bar-row:hover { background: var(--paper); }
.bar-row .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { background: var(--paper); border-radius: var(--r-full); height: 10px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: var(--r-full); }
.bar-row .amt { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.muted { color: var(--muted); }

.panel.wide { grid-column: 1 / -1; }

.trend svg { width: 100%; height: 180px; display: block; }
.trend text { font-size: 10px; fill: var(--muted); }
.trend .cur { font-weight: 700; fill: var(--ink); }

/* ---------- class cards (sheet style) ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(400px, 1fr)); gap: 24px; align-items: start; }
.card { overflow: hidden; break-inside: avoid; }
.card:hover { box-shadow: var(--shadow-1); }
.card-band { height: 6px; }
.card-head { display: flex; align-items: center; gap: 10px; padding: 16px 24px 12px; }
.card-head .title { font-size: 20px; font-weight: 700; letter-spacing: -.25px; flex: 1; min-width: 0; line-height: 1.2; }
.card-head .title small { display: block; font-size: 14px; font-weight: 400; color: var(--muted); letter-spacing: 0; margin-top: 2px; }
.badge { font-size: 12px; font-weight: 600; letter-spacing: .125px; padding: 4px 10px; border-radius: var(--r-full); background: var(--sun-soft); color: var(--sun-ink); white-space: nowrap; }
.badge.paid { background: var(--accent-soft); color: var(--accent-ink); }

table.sheet { width: 100%; border-collapse: collapse; }
table.sheet th {
  background: var(--paper); color: var(--muted); font-size: 12px; font-weight: 600; letter-spacing: .125px; text-transform: uppercase;
  padding: 8px 12px; text-align: center; border-top: 1px solid var(--hairline); border-bottom: 1px solid var(--hairline);
}
table.sheet td { padding: 9px 12px; text-align: center; border-bottom: 1px solid var(--hairline); font-variant-numeric: tabular-nums; }
table.sheet tr:last-child td { border-bottom: 0; }
table.sheet td:first-child { color: var(--faint); width: 44px; }
table.sheet td.day { font-weight: 500; }
table.sheet td.note { text-align: left; color: var(--muted); }
table.sheet td.money { text-align: right; font-weight: 500; }
tr.unpaid td { color: var(--faint); text-decoration: line-through; }
tr.unpaid td.note { text-decoration: none; }
.tag { display: inline-block; font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: var(--r-full); background: var(--paper); color: var(--muted); text-decoration: none; }
.tag.makeup { background: var(--accent-wash); color: var(--primary); }
.tag.absent { background: var(--sun-soft); color: var(--sun-ink); }
.tag.absentPaid { background: var(--info-soft); color: var(--info-ink); }
.empty-row td { color: var(--muted); padding: 24px 12px; }

.card-foot { padding: 16px 24px; display: grid; grid-template-columns: auto 1fr; gap: 4px 16px; align-items: baseline; border-top: 1px solid var(--hairline); background: var(--paper); }
.card-foot .cnt { grid-column: 1 / -1; color: var(--muted); font-size: 13px; margin-bottom: 4px; }
.card-foot .v { text-align: right; font-variant-numeric: tabular-nums; }
.card-foot .total-label { font-weight: 600; }
.card-foot .total-value { font-size: 26px; font-weight: 700; letter-spacing: -.625px; }
.adj { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 12px 24px; border-top: 1px solid var(--hairline); font-size: 14px; color: var(--muted); }
.adj input[type=number], .adj input[type=text] { padding: 4px 8px; border: 1px solid var(--input-border); border-radius: var(--r-xs); background: var(--canvas); color: var(--ink); width: 120px; }
.adj input[type=text] { flex: 1; min-width: 100px; }
.adj input[type=checkbox] { accent-color: var(--primary); }
.card-actions { display: flex; gap: 8px; padding: 12px 24px 16px; }

.empty { text-align: center; padding: 64px 24px; background: var(--paper); border: 1px solid var(--hairline); border-radius: var(--r-xl); }
.empty h2 { font-size: 26px; font-weight: 700; letter-spacing: -.625px; margin-bottom: 8px; }
.empty .btns { display: flex; gap: 8px; justify-content: center; margin-top: 20px; flex-wrap: wrap; }

.idle { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 24px; font-size: 14px; }
.idle .dot { width: 10px; height: 10px; border-radius: var(--r-full); display: inline-block; margin-right: 6px; }
table.history { border: 1px solid var(--hairline); border-radius: var(--r-md); overflow: hidden; }
table.history td { text-align: left; }
table.history td:first-child { color: var(--ink); width: auto; }
table.history td.money { text-align: right; font-weight: 600; }
table.history .up { color: var(--accent-ink); font-weight: 600; }
table.history .down { color: var(--coral-ink); font-weight: 600; }

/* ---------- dialog ---------- */
dialog#dialog, dialog#course-dialog { border: 0; border-radius: var(--r-xl); padding: 0; width: min(1040px, 96vw); max-height: 90vh; box-shadow: var(--shadow-2); background: var(--canvas); color: var(--ink); }
dialog::backdrop { background: rgba(0, 0, 0, .35); }
.dlg-head { display: flex; justify-content: space-between; align-items: center; padding: 20px 24px; border-bottom: 1px solid var(--hairline); position: sticky; top: 0; background: var(--canvas); z-index: 1; }
.dlg-head h2 { font-size: 22px; font-weight: 700; letter-spacing: -.25px; }
.dlg-body { padding: 24px; overflow: auto; max-height: calc(90vh - 150px); }
.dlg-foot { padding: 16px 24px; border-top: 1px solid var(--hairline); display: flex; gap: 8px; justify-content: flex-end; align-items: center; background: var(--paper); border-radius: 0 0 var(--r-xl) var(--r-xl); }
.dlg-foot .grow { flex: 1; color: var(--muted); }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 12px; font-weight: 600; color: var(--muted); }
.field input, .field select, .field textarea, table.edit input, table.edit select {
  padding: 6px; border: 1px solid var(--input-border); border-radius: var(--r-xs); background: var(--canvas); width: 100%;
}
.field input:focus, .field select:focus, .field textarea:focus, table.edit input:focus, table.edit select:focus { box-shadow: var(--shadow-1); }
.field input[type=color] { padding: 2px; height: 34px; }
.field.wide { grid-column: 1 / -1; }
.bill-fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 8px 16px; }
.bill-field { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 400; color: var(--ink, inherit); cursor: pointer; }
.bill-field input { width: auto; accent-color: var(--primary); }
.field.check { flex-direction: row; align-items: center; gap: 8px; }
.field.check input { width: auto; accent-color: var(--primary); }
dialog#dialog h4, dialog#course-dialog h4 { margin: 28px 0 8px; font-size: 16px; font-weight: 600; }

table.edit { width: 100%; border-collapse: collapse; }
table.edit th { font-size: 12px; text-align: left; color: var(--muted); font-weight: 600; letter-spacing: .125px; text-transform: uppercase; padding: 4px; }
table.edit td { padding: 3px; }
table.edit input[data-f=rate] { min-width: 96px; }
table.edit select[data-f=status] { min-width: 150px; }
table.edit input[data-f=note] { min-width: 160px; }
table.edit input[type=date] { min-width: 130px; }
table.edit td.no { width: 36px; text-align: center; color: var(--faint); }
table.edit td.del { width: 40px; }

.class-list { display: flex; flex-direction: column; gap: 8px; }
.class-item { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border: 1px solid var(--hairline); border-radius: var(--r-md); }
.class-item .dot, .card-head .dot { width: 12px; height: 12px; border-radius: var(--r-full); flex: none; }
.class-item .grow { flex: 1; }
.class-item.inactive { opacity: .55; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px);
  background: var(--canvas); color: var(--ink); border: 1px solid var(--hairline); box-shadow: var(--shadow-2);
  padding: 12px 16px; border-radius: var(--r-xl); font-size: 14px;
  opacity: 0; pointer-events: none; transition: .25s; z-index: 100;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 840px) {
  .topbar { position: static; }
  .hero { grid-template-columns: 1fr; padding: 24px; gap: 20px; }
  .daily { grid-template-columns: 1fr; }
  .panels { grid-template-columns: 1fr; }
  .cards { grid-template-columns: 1fr; }
  .bar-row { grid-template-columns: 90px 1fr 120px; }
  main { padding: 20px 16px 48px; }
}

/* ---------- calendar view ---------- */
.seg { display: inline-flex; background: var(--paper); border: 1px solid var(--hairline); border-radius: var(--r-full); padding: 2px; }
.seg button { border: 0; background: none; padding: 4px 14px; border-radius: var(--r-full); cursor: pointer; font-weight: 500; color: var(--muted); }
.seg button.is-active { background: var(--canvas); color: var(--ink); box-shadow: var(--shadow-1); }
body[data-mode="calendar"] .month-nav, body[data-mode="calendar"] .report-only,
body[data-mode="forecast"] .month-nav, body[data-mode="forecast"] .report-only,
body[data-mode="courses"] .month-nav, body[data-mode="courses"] .report-only,
body[data-mode="learning"] .month-nav, body[data-mode="learning"] .report-only { display: none; }
.cal-wrap { max-width: 1240px; margin: 0 auto; padding: 24px 24px 48px; }
.cal-bar { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.cal-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.cal-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.btn[hidden] { display: none; }
.cal-summary { font-size: 15px; }
.snack { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); z-index: 100; display: flex; align-items: center; gap: 12px;
  background: var(--canvas); border: 1px solid var(--hairline); box-shadow: var(--shadow-2); padding: 10px 14px; border-radius: var(--r-xl); font-size: 14px;
  opacity: 0; pointer-events: none; transition: .25s; max-width: min(640px, calc(100vw - 32px)); }
.snack.show { opacity: 1; pointer-events: auto; transform: translate(-50%, 0); }
.cal-filter { display: flex; flex-wrap: wrap; gap: 6px; }
.cal-chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--hairline); background: var(--canvas); border-radius: var(--r-full); padding: 2px 10px; font-size: 13px; cursor: pointer; }
.cal-chip .dot { width: 10px; height: 10px; border-radius: var(--r-full); }
.cal-chip.is-off { opacity: .45; }
.cal-chip.is-off .dot { background: var(--faint) !important; }
.cal-chip-all { color: var(--primary); }
.cal-host { height: calc(100vh - 260px); min-height: 600px; background: var(--canvas); border: 1px solid var(--hairline); border-radius: var(--r-lg); overflow: hidden; }
/* The library hard-codes a calendar height of 800px (550px on small screens); without this the part that does not
   fit in the host is clipped and the last hours of the day can never be scrolled into view. */
.cal-host .df-calendar-container { --df-calendar-height: 100%; height: 100%; border: 0; border-radius: 0; box-shadow: none; }
.cal-filter { max-height: 76px; overflow-y: auto; }
@media (max-width: 840px) { .cal-wrap { padding: 16px 12px 40px; } .seg button { padding: 4px 10px; } }

/* ---------- forecast ---------- */
.fc-wrap { max-width: 1240px; margin: 0 auto; padding: 32px 24px 64px; }
.fc-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; margin-bottom: 16px; }
.fc-head h2 { font-size: 26px; font-weight: 700; letter-spacing: -.625px; }
.fc-wrap .panel { margin-bottom: 16px; }
.fc-chart svg { width: 100%; height: auto; display: block; }
.fc-chart text { font-size: 11px; fill: var(--muted); }
.fc-chart text.cur { font-weight: 700; fill: var(--ink); }
.fc-legend { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 8px; font-size: 13px; color: var(--muted); }
.fc-legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.fc-legend i.dash { background: none; border: 1px dashed var(--brand-ink); }
.fc-scroll { overflow-x: auto; }
table.fc-table th, table.fc-table td { white-space: nowrap; }
table.fc-table th.left, table.fc-table td.left { text-align: left; }
table.fc-table td:first-child { color: var(--ink); width: auto; }
table.fc-table tfoot td { border-top: 2px solid var(--hairline); background: var(--paper); }
table.fc-table .dot { display: inline-block; width: 10px; height: 10px; border-radius: var(--r-full); margin-right: 8px; }
.fc-row { cursor: pointer; }
.fc-row:hover td { background: var(--paper); }
.fc-row.is-selected td { background: var(--accent-wash); }
.fc-wrap .up { color: var(--accent-ink); font-weight: 600; }
.fc-wrap .down { color: var(--coral-ink); font-weight: 600; }
.fc-explain summary { cursor: pointer; font-weight: 600; }
.fc-explain ul { margin: 12px 0 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; color: var(--ink-2); }
@media (max-width: 840px) { .fc-wrap { padding: 16px 12px 40px; } }

/* ---------- invoices ---------- */
.bill-layout { display: grid; grid-template-columns: minmax(280px, 340px) 1fr; gap: 20px; align-items: start; }
.bill-side { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.bill-tools { display: flex; flex-wrap: wrap; gap: 6px; }
.bill-list { display: flex; flex-direction: column; border: 1px solid var(--hairline); border-radius: var(--r-md); max-height: 52vh; overflow-y: auto; }
.bill-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--hairline); cursor: pointer; }
.bill-row:last-child { border-bottom: 0; }
.bill-row:hover { background: var(--paper); }
.bill-row.is-focus { background: var(--accent-wash); }
.bill-row input[type=checkbox] { accent-color: var(--primary); }
.bill-row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.bill-row-main strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bill-row-main small { color: var(--muted); }
.bill-warn { background: var(--sun-soft); color: var(--sun-ink); border-radius: var(--r-md); padding: 8px 12px; font-size: 13px; }
.bill-preview { border: 1px solid var(--hairline); border-radius: var(--r-md); background: var(--paper); padding: 12px; max-height: 62vh; overflow: auto; }
.bill-preview img { display: block; width: 100%; height: auto; border-radius: var(--r-sm); box-shadow: var(--shadow-1); background: #fff; }
.dlg-foot .btn:disabled { opacity: .45; cursor: not-allowed; }
@media (max-width: 840px) { .bill-layout { grid-template-columns: 1fr; } .bill-preview { max-height: none; } }

/* ---------- chat assistant ---------- */
#chat-fab {
  position: fixed; right: 24px; bottom: 24px; z-index: 40; width: 56px; height: 56px; border-radius: var(--r-full);
  border: 0; background: var(--primary); color: #fff; font-size: 24px; cursor: pointer; box-shadow: var(--shadow-2);
  transition: transform .1s, background .15s;
}
#chat-fab:hover { background: var(--primary-active); }
#chat-fab:active { transform: scale(.92); }
#chat-fab[hidden], #chat-panel[hidden] { display: none; }
#chat-panel {
  position: fixed; right: 24px; bottom: 24px; z-index: 40; width: min(420px, calc(100vw - 32px)); height: min(640px, calc(100vh - 48px));
  display: flex; flex-direction: column; background: var(--canvas); border: 1px solid var(--hairline); border-radius: var(--r-xl); box-shadow: var(--shadow-2); overflow: hidden;
}
.chat-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--hairline); }
.chat-log { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; background: var(--paper); }
.chat-msg { max-width: 92%; padding: 10px 14px; border-radius: var(--r-lg); font-size: 14px; line-height: 1.45; word-break: break-word; }
.chat-msg.user { align-self: flex-end; background: var(--primary); color: #fff; border-bottom-right-radius: var(--r-xs); }
.chat-msg.bot { align-self: flex-start; background: var(--canvas); border: 1px solid var(--hairline); border-bottom-left-radius: var(--r-xs); }
.chat-msg.bot > div + div { margin-top: 4px; }
.chat-msg ul { margin: 8px 0; padding-left: 18px; }
.chat-msg code { background: var(--paper); border-radius: var(--r-xs); padding: 1px 5px; font-size: 12.5px; }
.chat-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chat-undo { margin-top: 8px; }
.chat-head-actions { display: flex; gap: 6px; }
.chat-note { align-self: center; font-size: 12px; color: var(--muted); text-align: center; }
.chat-form { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--hairline); align-items: flex-end; }
.chat-form textarea { flex: 1; resize: none; padding: 8px; border: 1px solid var(--input-border); border-radius: var(--r-md); background: var(--canvas); }

@media (max-width: 840px) {
  #chat-panel { right: 8px; bottom: 8px; width: calc(100vw - 16px); height: calc(100vh - 16px); }
}

/* ---------- print ---------- */
@media print {
  body { background: #fff; font-size: 11px; }
  .no-print, .card-actions, .adj, .cal-wrap, .fc-wrap, .cs-wrap { display: none !important; }
  main { padding: 0; max-width: none; }
  .hero { padding: 20px; }
  .hero-value { font-size: 36px; }
  .cards { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .card:hover { box-shadow: none; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ---------- course classes (paid per course) ---------- */
#class-form[data-kind="course"] .when-session { display: none; }
.cs-wrap { max-width: 1240px; margin: 0 auto; padding: 32px 24px 64px; }
.cs-wrap .fc-head p { margin-top: 4px; max-width: 70ch; }
.cs-card { margin-bottom: 20px; }
.cs-card .card-head { flex-wrap: wrap; }
div.cs-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
td.cs-actions { white-space: nowrap; text-align: right; }
td.cs-actions .btn + .btn { margin-left: 6px; }
.cs-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px 24px; padding: 12px 24px 8px; }
.cs-stat span { display: block; font-size: 12px; font-weight: 600; letter-spacing: .125px; text-transform: uppercase; color: var(--muted); }
.cs-stat b { font-size: 22px; font-weight: 700; letter-spacing: -.5px; font-variant-numeric: tabular-nums; }
.cs-stat small { display: block; font-size: 13px; }
.cs-total { display: flex; align-items: center; gap: 12px; padding: 4px 24px 16px; font-size: 13px; color: var(--muted); }
.cs-total .cs-bar { flex: 1; }
.cs-bar { height: 8px; border-radius: var(--r-full); background: var(--paper); overflow: hidden; min-width: 80px; }
.cs-bar i { display: block; height: 100%; border-radius: var(--r-full); background: var(--brand-secondary); }
.cs-bar.paid i { background: var(--accent-ink); }
.cs-bar.owe i { background: var(--coral-ink); }
.ok-text { color: var(--accent-ink); }
.owe-text { color: var(--coral-ink); }
table.cs-table th.left, table.cs-table td.left { text-align: left; }
table.cs-table td:first-child { color: var(--ink); width: auto; }
table.cs-table td { vertical-align: middle; }
.cs-row { cursor: pointer; }
.cs-row:hover td { background: var(--paper); }
.cs-caret { color: var(--faint); display: inline-block; width: 14px; }
.cs-note { font-size: 12px; font-weight: 400; }
.cs-prog { min-width: 150px; }
.cs-prog .cs-bar { display: inline-block; width: 90px; vertical-align: middle; margin-right: 8px; }
.cs-badge.owe { background: var(--coral-soft); color: var(--coral-ink); }
.cs-badge.part { background: var(--sun-soft); color: var(--sun-ink); }
.cs-badge:not(.paid):not(.part):not(.owe) { background: var(--paper); color: var(--muted); }
tr.cs-pay td { background: var(--paper); text-align: left; padding: 8px 12px 12px 36px; }
.cs-pays { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; max-width: 560px; }
.cs-pays li { display: flex; gap: 16px; align-items: center; font-variant-numeric: tabular-nums; }
.cs-pays li > span:first-child { width: 90px; }
.cs-pays li b { min-width: 130px; }
.cs-pays li .muted { flex: 1; }
.cs-error { color: var(--coral-ink); font-size: 14px; margin-top: 12px; min-height: 1em; }
dialog#course-dialog { width: min(560px, 96vw); }
dialog#learning-dialog { border: 0; border-radius: var(--r-xl); padding: 0; width: min(640px, 96vw); max-height: 90vh; box-shadow: var(--shadow-2); background: var(--canvas); color: var(--ink); }
@media (max-width: 840px) { .cs-wrap { padding: 16px 12px 40px; } }
.cs-ms-cell { white-space: nowrap; text-align: left !important; }
.cs-ms { display: inline-block; min-width: 38px; text-align: center; font-size: 12px; font-weight: 600; padding: 2px 8px; margin: 1px 3px 1px 0; border-radius: var(--r-full); background: var(--paper); color: var(--faint); border: 1px solid var(--hairline); font-variant-numeric: tabular-nums; }
.cs-ms.paid { background: var(--accent-soft); color: var(--accent-ink); border-color: transparent; }
.cs-ms.overdue { background: var(--coral-soft); color: var(--coral-ink); border-color: transparent; }

/* ---------- personal learning expenses ---------- */
.learning-wrap { max-width: 1240px; margin: 0 auto; padding: 32px 24px 64px; }
.learning-head-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.learning-month { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.learning-month input { padding: 5px 8px; border: 1px solid var(--input-border); border-radius: var(--r-md); background: var(--canvas); }
.learning-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-bottom: 20px; }
.learning-kpi { background: var(--canvas); border: 1px solid var(--hairline); border-radius: var(--r-lg); padding: 16px 20px; }
.learning-kpi span { display: block; color: var(--muted); font-size: 12px; font-weight: 600; letter-spacing: .125px; text-transform: uppercase; }
.learning-kpi b { display: block; margin-top: 4px; font-size: 22px; font-variant-numeric: tabular-nums; }
.learning-card { margin-bottom: 16px; }
.learning-card .card-head { flex-wrap: wrap; }
.learning-body { padding: 0 24px 20px; }
.learning-meta { color: var(--muted); font-size: 14px; }
.learning-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px 24px; padding: 14px 0; }
.learning-stat span { display: block; color: var(--muted); font-size: 12px; font-weight: 600; letter-spacing: .125px; text-transform: uppercase; }
.learning-stat b { display: block; font-size: 18px; font-variant-numeric: tabular-nums; }
.learning-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-left: auto; }
.learning-payments { margin-top: 10px; }
.learning-payments td:first-child { color: var(--ink); width: auto; }
.learning-payments th:first-child, .learning-payments td:first-child { text-align: left; }
.learning-payments td:last-child { white-space: nowrap; }
.learning-empty { text-align: center; padding: 52px 24px; }
.learning-overpaid { color: var(--muted); font-size: 13px; }
@media (max-width: 840px) { .learning-wrap { padding: 16px 12px 40px; } .learning-body { padding: 0 16px 16px; } }

.dlg-month { display: flex; align-items: center; gap: 6px; }
.dlg-month input[type=month] { padding: 4px 8px; border: 1px solid var(--input-border); border-radius: var(--r-xs); background: var(--canvas); color: var(--ink); font: inherit; }
.cs-head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.cs-toggle { border: 0; background: none; width: 28px; height: 28px; border-radius: var(--r-full); display: inline-flex; align-items: center; justify-content: center; color: var(--muted); cursor: pointer; flex: none; }
.cs-toggle:hover { background: var(--paper); color: var(--ink); }
.cs-chevron { transition: transform .18s ease; }
.cs-card.is-collapsed .cs-chevron { transform: rotate(-90deg); }
.cs-title { cursor: pointer; }
.cs-body[hidden] { display: none; }
.cs-mini { display: flex; align-items: center; gap: 12px 18px; flex-wrap: wrap; padding: 0 24px 16px 62px; font-size: 14px; font-variant-numeric: tabular-nums; }
.cs-mini .cs-bar { width: 160px; flex: none; }
.cs-card.is-collapsed .card-head { padding-bottom: 8px; }

/* ---------- class history ---------- */
.hist-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px 16px; padding: 12px 16px; margin-bottom: 20px; background: var(--paper); border-radius: var(--r-lg); }
.hist-stat span { display: block; font-size: 12px; font-weight: 600; letter-spacing: .125px; text-transform: uppercase; color: var(--muted); }
.hist-stat b { font-size: 18px; font-variant-numeric: tabular-nums; }
.hist-month { margin-bottom: 20px; border: 1px solid var(--hairline); border-radius: var(--r-lg); overflow: hidden; }
.hist-month-head { display: flex; align-items: center; gap: 12px; padding: 10px 16px; }
.hist-month-head .muted { flex: 1; }
.hist-month tr.future td { color: var(--muted); }
.card-head .title small + small { margin-top: 0; }

/* ---------- detail view: student list on the left, their sessions on the right ---------- */
.dt-wrap { max-width: 1440px; margin: 0 auto; padding: 24px 24px 48px; display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 24px; align-items: start; }
.dt-wrap[hidden] { display: none; }
.dt-side { position: sticky; top: 16px; display: flex; flex-direction: column; gap: 10px; max-height: calc(100vh - 32px); background: var(--canvas); border: 1px solid var(--hairline); border-radius: var(--r-lg); padding: 14px; }
.dt-side h3 { font-size: 16px; font-weight: 600; }
.dt-side input[type="search"] { width: 100%; padding: 7px 12px; border: 1px solid var(--hairline); border-radius: var(--r-md); font: inherit; font-size: 14px; }
.dt-tools { display: flex; gap: 6px; flex-wrap: wrap; }
.dt-list { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; margin: 0 -6px; padding: 0 6px; }
.dt-item { display: grid; grid-template-columns: auto auto 1fr; gap: 8px; align-items: center; padding: 7px 8px; border-radius: var(--r-md); cursor: pointer; font-size: 14px; }
.dt-item:hover { background: var(--paper); }
.dt-item.is-on { background: var(--accent-wash); }
.dt-item.is-idle .dt-name { color: var(--muted); }
.dt-item .dot { width: 10px; height: 10px; border-radius: var(--r-full); }
.dt-name { min-width: 0; line-height: 1.25; }
.dt-name b { display: block; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dt-name small { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.dt-col { min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.dt-filter { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; background: var(--canvas); border: 1px solid var(--hairline); border-radius: var(--r-lg); padding: 10px 14px; }
.dt-filter [hidden] { display: none; }
.dt-dates, .dt-presets { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.dt-filter input[type="date"] { padding: 5px 10px; border: 1px solid var(--input-border); border-radius: var(--r-md); background: var(--canvas); font: inherit; font-size: 14px; }
body[data-mode="detail"][data-range] .month-nav { display: none; }
.dt-main { min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.dt-summary { display: flex; flex-wrap: wrap; gap: 8px 24px; align-items: baseline; background: var(--canvas); border: 1px solid var(--hairline); border-radius: var(--r-lg); padding: 14px 20px; font-size: 14px; color: var(--muted); }
.dt-summary b { color: var(--ink); font-size: 18px; font-variant-numeric: tabular-nums; }
@media (max-width: 840px) {
  .dt-wrap { grid-template-columns: 1fr; padding: 16px; }
  .dt-side { position: static; max-height: none; }
  .dt-list { max-height: 260px; }
}

/* ==========================================================================
   Bytewise theme (overrides the component rules above with the Bytewise design system)
   ========================================================================== */
h1, h2, h3, .hero-value, .day-value, .kpi .value, .card-head .title, .fc-head h2, .empty h2, .dlg-head h2, .panel h3 { font-weight: 800; letter-spacing: -.02em; color: var(--ink-2); }
.hero-value, .hero-title { color: #fff; }
:focus-visible { outline: 3px solid var(--brand-accent); outline-offset: 2px; }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid var(--brand-accent); outline-offset: 2px; }
::selection { background: var(--accent-soft); }

/* top bar */
.topbar { background: rgba(255,255,255,.92); border-bottom: .8px solid var(--hairline); }
.brand-mark { background: var(--brand-accent); color: var(--brand-ink); border: 1.6px solid var(--brand-ink); border-radius: 10px; box-shadow: 2px 2px 0 var(--brand-ink); }
.brand-text b { font-weight: 800; font-size: 16px; letter-spacing: -.01em; }
.tab { font-weight: 600; color: var(--muted); }
.tab:hover { color: var(--ink-2); }
.tab.is-active { color: var(--ink-2); font-weight: 800; }
.tab.is-active svg { color: var(--accent-ink); }
.tab::after { height: 3px; background: var(--brand-accent); border-radius: 3px 3px 0 0; }
.tab:focus-visible { outline: 3px solid var(--brand-accent); outline-offset: -4px; }
.month-nav input[type=month], .learning-month input, .dlg-month input[type=month], .dt-filter input[type="date"] {
  border: 1px solid var(--input-border); border-radius: var(--r-full); padding: 6px 14px; background: #fff; color: var(--ink);
}

/* buttons: pill, ink border, hard offset shadow that "presses" on hover */
.btn {
  border: 1.6px solid var(--brand-ink); border-radius: var(--r-full); background: #fff; color: var(--brand-ink);
  font-weight: 700; font-size: 14px; min-height: 36px; padding: 4px 16px; gap: 6px;
  box-shadow: 2px 2px 0 var(--brand-ink);
  transition: transform .15s var(--ease-brand), box-shadow .15s var(--ease-brand), background .15s var(--ease-brand);
}
.btn:hover { background: #fff; transform: translate(1px, 1px); box-shadow: 1px 1px 0 var(--brand-ink); }
.btn:active { transform: translate(2px, 2px); box-shadow: none; }
.btn.primary { background: var(--brand-ink); border-color: var(--brand-ink); color: #fff; padding: 4px 18px; box-shadow: 3px 3px 0 var(--brand-accent); }
.btn.primary:hover, .btn.primary:active { background: var(--brand-ink); border-color: var(--brand-ink); box-shadow: 1px 1px 0 var(--brand-accent); }
.btn.secondary { box-shadow: 2px 2px 0 var(--brand-ink); }
.btn.ghost { border-color: transparent; box-shadow: none; color: var(--accent-ink); }
.btn.ghost:hover { background: var(--accent-wash); transform: none; box-shadow: none; }
.btn.icon { width: 36px; font-size: 18px; border: .8px solid var(--hairline); background: var(--surface-muted); box-shadow: none; color: var(--ink); }
.btn.icon:hover { background: #fff; border-color: var(--brand-ink); transform: none; box-shadow: none; }
.btn.icon-btn { width: 36px; }
.btn.small { min-height: 30px; padding: 2px 12px; font-size: 13px; border-width: 1px; box-shadow: none; }
.btn.small:hover { border-color: var(--brand-ink); transform: none; box-shadow: 1px 1px 0 var(--brand-ink); }
.btn.primary.small { box-shadow: 2px 2px 0 var(--brand-accent); }
.btn.danger { color: var(--coral-ink); }
.btn:disabled, .btn[disabled] { opacity: .45; cursor: not-allowed; transform: none; }
.danger-text { color: var(--coral-ink); }
.menu-pop { border: .8px solid var(--hairline); border-radius: 14px; box-shadow: var(--shadow-2); top: 44px; }
.menu-pop button { border-radius: 10px; font-weight: 600; }
.menu-pop button:hover { background: var(--surface-muted); }

/* surfaces */
.kpi, .panel, .card, .learning-kpi, .dt-side, .dt-filter, .dt-summary, .day-card { border: .8px solid var(--hairline); border-radius: var(--r-lg); box-shadow: var(--shadow-1); }
.card:hover { box-shadow: 0 12px 32px rgba(18,23,34,.08); }
.eyebrow, .kpi .label, .cs-stat span, .learning-kpi span, .learning-stat span, .hist-stat span { font-weight: 700; letter-spacing: .08em; }
.day-card .eyebrow, .kpi .label { color: var(--accent-ink); }
.hero { background: var(--brand-ink); border-radius: var(--r-xl); box-shadow: 6px 6px 0 var(--brand-accent); }
.hero .eyebrow { color: var(--brand-accent); }
.hero .up { color: var(--brand-accent); }
.progress i { background: var(--brand-accent); }
.day-card::before { background: var(--hairline); opacity: 1; }
.day-card.today::before { background: linear-gradient(90deg, var(--brand-accent), var(--brand-secondary)); }
.ring-fg { stroke: var(--brand-accent); }
.ring-bg { stroke: var(--surface-muted); }
.bar-track, .cs-bar { background: var(--surface-muted); }
.bar-row:hover, .fc-row:hover td, .cs-row:hover td, .bill-row:hover, .dt-item:hover { background: var(--surface-muted); }
.card-foot, tr.cs-pay td, table.fc-table tfoot td { background: var(--surface-muted); }
.card-foot .total-value { font-weight: 800; }
table.sheet th { background: var(--surface-muted); font-weight: 700; letter-spacing: .06em; }
.badge, .tag, .cs-ms { font-weight: 700; }
.tag.makeup { background: var(--accent-wash); color: var(--accent-ink); }
.empty { background: #fff; border: .8px dashed var(--input-border); border-radius: var(--r-xl); }
.seg { background: var(--surface-muted); border: .8px solid var(--hairline); padding: 3px; }
.seg button { font-weight: 700; padding: 6px 14px; }
.seg button.is-active { background: #fff; color: var(--ink-2); box-shadow: var(--shadow-1); }
.cal-chip { border-color: var(--hairline); font-weight: 600; padding: 3px 12px; }
.cal-chip-all { color: var(--accent-ink); }
.cal-host { border-radius: var(--r-lg); box-shadow: var(--shadow-1); }
.dt-item.is-on { background: var(--accent-wash); box-shadow: inset 3px 0 0 var(--brand-accent); }
.bill-warn { border-radius: 14px; }

/* forms */
.field label { font-size: 13px; font-weight: 700; color: var(--ink-2); }
.field input, .field select, .field textarea, table.edit input, table.edit select, .adj input[type=number], .adj input[type=text],
.dt-side input[type="search"], .chat-form textarea {
  border: 1px solid var(--input-border); border-radius: var(--r-md); background: #fff; padding: 8px 12px; min-height: 38px;
  transition: border-color .15s var(--ease-brand), box-shadow .15s var(--ease-brand);
}
table.edit input, table.edit select { padding: 6px 10px; min-height: 34px; }
.field input:focus, .field select:focus, .field textarea:focus, table.edit input:focus, table.edit select:focus, .dt-side input[type="search"]:focus { border-color: var(--brand-ink); box-shadow: 0 0 0 3px var(--accent-soft); }
input[type=checkbox], input[type=radio] { accent-color: var(--accent-ink); }

/* dialogs, toasts, chat */
dialog#dialog, dialog#course-dialog, dialog#learning-dialog { border: 1.6px solid var(--brand-ink); border-radius: var(--r-xl); box-shadow: 6px 6px 0 var(--brand-ink); }
dialog::backdrop { background: rgba(18,23,34,.45); }
.dlg-foot { background: var(--surface-muted); }
.toast, .snack { border: 1.6px solid var(--brand-ink); border-radius: 14px; box-shadow: 3px 3px 0 var(--brand-ink); font-weight: 700; }
#chat-fab { background: var(--brand-ink); border: 1.6px solid var(--brand-ink); box-shadow: 3px 3px 0 var(--brand-accent); }
#chat-fab:hover { background: var(--brand-ink); transform: translate(1px, 1px); box-shadow: 1px 1px 0 var(--brand-accent); }
#chat-panel { border: 1.6px solid var(--brand-ink); border-radius: var(--r-xl); box-shadow: 6px 6px 0 var(--brand-ink); }
.chat-log { background: var(--paper); }
.chat-msg.user { background: var(--brand-ink); }

/* ---------- phones: compact top bar, tabs become a bottom tab bar, full-screen dialogs ---------- */
.tab-long { display: inline; }
@media (max-width: 760px) {
  body { padding-bottom: calc(68px + env(safe-area-inset-bottom)); }
  /* no backdrop-filter here: it would make the fixed bottom tab bar (a child) position against the top bar */
  .topbar { position: sticky; top: 0; flex-wrap: nowrap; gap: 8px; padding: 8px 12px; min-height: 56px; background: #fff; backdrop-filter: none; -webkit-backdrop-filter: none; }
  .brand-text { display: none; }
  .brand-mark { width: 34px; height: 34px; }
  .topbar-end { gap: 6px; flex-wrap: nowrap; min-width: 0; }
  .month-nav { gap: 4px; min-width: 0; }
  .month-nav input[type=month] { padding: 6px 8px; font-size: 14px; min-width: 0; width: 132px; }
  .month-nav .btn.ghost { display: none; }
  .btn.icon, .btn.icon-btn { width: 34px; min-height: 34px; }
  .actions { gap: 6px; }
  .actions .btn:not(.icon-btn) { font-size: 0; gap: 0; width: 36px; padding: 0; }
  .actions .btn .ico { width: 18px; height: 18px; margin: 0; }
  .menu-pop { position: fixed; top: 60px; right: 8px; left: 8px; min-width: 0; }
  .menu-pop button { padding: 12px; }
  .tabs {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 60; order: 0; width: auto; margin: 0; min-height: 0;
    display: grid; grid-template-columns: repeat(6, 1fr); gap: 0; overflow: visible;
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); background: #fff; border-top: .8px solid var(--hairline);
  }
  .tab { flex-direction: column; justify-content: center; gap: 3px; padding: 6px 2px; border-radius: 12px; font-size: 10.5px; line-height: 1.2; white-space: normal; text-align: center; min-height: 52px; }
  .tab svg { width: 20px; height: 20px; }
  .tab::after { display: none; }
  .tab.is-active { background: var(--accent-wash); }
  .tab.is-active svg { color: var(--accent-ink); }
  .tab-long { display: none; }
  #chat-fab { right: 14px; bottom: calc(80px + env(safe-area-inset-bottom)); width: 50px; height: 50px; z-index: 55; }
  #chat-panel { z-index: 80; }
  .topbar { z-index: 65; }
  #chat-panel { right: 0; bottom: 0; left: 0; top: 0; width: 100vw; height: 100dvh; border-radius: 0; border: 0; box-shadow: none; }
  .toast, .snack { bottom: calc(84px + env(safe-area-inset-bottom)); }
  main, .cal-wrap, .fc-wrap, .cs-wrap, .learning-wrap, .dt-wrap { padding: 14px 12px 32px; }
  .hero { padding: 22px 20px; box-shadow: 4px 4px 0 var(--brand-accent); }
  .hero-value { letter-spacing: -.03em; }
  .day-card { padding: 18px; }
  .day-list li { grid-template-columns: auto 1fr auto; }
  .day-list .dt { grid-column: 2; grid-row: 2; }
  .day-list b { min-width: 0; }
  .kpis { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi { padding: 14px 16px; }
  .kpi .value { font-size: 20px; }
  .kpi .hint { font-size: 12.5px; }
  .panel { padding: 18px 16px; }
  .bar-row { grid-template-columns: 88px 1fr auto; gap: 8px; font-size: 13px; }
  .bar-row .amt small, .bar-row .amt .muted { display: none; }
  .cards { gap: 14px; }
  .card { overflow-x: auto; }
  .card-head { padding: 14px 16px 10px; }
  .card-foot, .adj, .card-actions { padding-left: 16px; padding-right: 16px; }
  .card-actions { flex-wrap: wrap; }
  table.sheet th, table.sheet td { padding: 8px 8px; }
  /* 16px inputs: iOS doesn't zoom the page when they get focus */
  input, select, textarea { font-size: 16px; }
  .field input, .field select, .field textarea { min-height: 44px; }
  dialog#dialog, dialog#course-dialog, dialog#learning-dialog {
    width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0; border-radius: 0; border: 0; box-shadow: none;
  }
  dialog[open]#dialog, dialog[open]#course-dialog, dialog[open]#learning-dialog { display: flex; flex-direction: column; }
  .dlg-head { padding: 14px 16px; }
  .dlg-head h2 { font-size: 19px; }
  .dlg-body { padding: 16px; max-height: none; flex: 1; }
  .dlg-foot { padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); border-radius: 0; flex-wrap: wrap; position: sticky; bottom: 0; }
  .dlg-foot .grow { flex-basis: 100%; }
  .form-grid { grid-template-columns: 1fr; gap: 12px; }
  table.edit { display: block; overflow-x: auto; }
  .cal-host { height: calc(100dvh - 300px); min-height: 460px; }
  .cs-mini { padding-left: 16px; }
  .cs-summary, .cs-total { padding-left: 16px; padding-right: 16px; }
  .fc-head h2 { font-size: 22px; }
  .fc-wrap .panel, .cs-card, .learning-card { overflow-x: auto; }
  .fc-scroll { max-width: 100%; }
  .bill-list { max-height: 40vh; }
}
@media print { body { padding-bottom: 0; } .tabs { position: static; } }

/* ---------- access-key page (login.html) ---------- */
.login-page { min-height: 100dvh; display: grid; place-items: center; padding: 20px; }
.login-wrap { width: 100%; max-width: 400px; margin: 0; padding: 0; }
.login-card { background: #fff; border: 1.6px solid var(--brand-ink); border-radius: var(--r-xl); box-shadow: 6px 6px 0 var(--brand-ink); padding: 32px 28px; display: flex; flex-direction: column; gap: 10px; }
.login-mark { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; margin-bottom: 6px; }
.login-eyebrow { color: var(--accent-ink); margin: 0; }
.login-title { font-size: 34px; font-weight: 800; letter-spacing: -.03em; line-height: 1.1; color: var(--ink-2); }
.login-lead { margin: 0 0 8px; color: var(--muted); }
.login-card .field input { min-height: 48px; font-size: 18px; letter-spacing: .2em; border-radius: var(--r-full); padding: 10px 18px; }
.login-err { color: var(--coral-ink); font-weight: 700; font-size: 14px; margin: 0; min-height: 1.2em; }
.login-btn { min-height: 48px; font-size: 16px; margin-top: 4px; }

table.sheet td.money, table.cs-table td.money { white-space: nowrap; }
