/* ===== Dojo Stock Manager — white professional theme ===== */
:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --border: #e4e7ec;
  --border-strong: #d0d5dd;
  --text: #101828;
  --text-2: #475467;
  --muted: #98a2b3;
  --primary: #2447d6;
  --primary-hover: #1c39b0;
  --primary-soft: #eef2ff;
  --brand: #c8102e;
  --good: #067647;
  --good-bg: #ecfdf3;
  --warn: #b54708;
  --warn-bg: #fffaeb;
  --bad: #b42318;
  --bad-bg: #fef3f2;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .16);
  --sidebar-w: 248px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: Inter, "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--text-2); }
.small { font-size: 12px; }
svg.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Layout ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); flex: none;
  background: var(--surface); border-right: 1px solid var(--border);
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 20px 20px 16px; border-bottom: 1px solid var(--border); }
.brand-mark {
  width: 38px; height: 38px; border-radius: 9px; background: var(--brand); color: #fff;
  display: grid; place-items: center; font-size: 20px; font-weight: 700;
}
.brand-name { font-weight: 700; font-size: 15px; max-width: 160px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-sub { font-size: 12px; color: var(--muted); }
.nav { padding: 8px 12px 24px; }
.nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 16px 10px 6px; font-weight: 600; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px;
  color: var(--text-2); font-weight: 500; margin-bottom: 2px;
}
.nav a:hover { background: var(--bg); color: var(--text); }
.nav a.active { background: var(--primary-soft); color: var(--primary); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 14px;
  background: rgba(255,255,255,.92); backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--border);
  padding: 14px 28px; min-height: 68px;
}
.topbar h1 { font-size: 19px; }
.page-sub { font-size: 12.5px; color: var(--text-2); margin-top: 2px; }
.topbar-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.content { padding: 24px 28px 48px; max-width: 1480px; width: 100%; }
.icon-btn.menu-btn { display: none; }
.backdrop { display: none; }

/* ---------- Buttons & inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 38px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font: inherit; font-weight: 600; cursor: pointer;
  box-shadow: var(--shadow); white-space: nowrap;
}
.btn:hover { background: var(--bg); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-hover); }
.btn.danger { color: var(--bad); }
.btn.danger:hover { background: var(--bad-bg); border-color: #fda29b; }
.btn.sm { height: 32px; padding: 0 10px; font-size: 13px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.icon-btn {
  display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 8px;
  border: 1px solid transparent; background: transparent; color: var(--text-2); cursor: pointer;
}
.icon-btn:hover { background: var(--bg); color: var(--text); }
.icon-btn.danger:hover { background: var(--bad-bg); color: var(--bad); }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; font-weight: 600; color: var(--text); }
.field label .req { color: var(--bad); }
.field .hint { font-size: 12px; color: var(--muted); }
.input, select.input, textarea.input {
  height: 38px; width: 100%; padding: 0 12px; border: 1px solid var(--border-strong); border-radius: 8px;
  font: inherit; color: var(--text); background: #fff; box-shadow: var(--shadow);
}
textarea.input { height: auto; min-height: 76px; padding: 10px 12px; resize: vertical; }
.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(36,71,214,.15); }
.input.invalid { border-color: var(--bad); }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, 1fr); }
.g3 { grid-template-columns: repeat(3, 1fr); }
.g4 { grid-template-columns: repeat(4, 1fr); }
.span2 { grid-column: span 2; }
.span-all { grid-column: 1 / -1; }

.search { position: relative; }
.search svg { position: absolute; left: 11px; top: 10px; color: var(--muted); }
.search .input { padding-left: 36px; }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.card-head h3 { font-size: 15px; }
.card-head .sub { font-size: 12.5px; color: var(--text-2); }
.card-head .right { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.card-body { padding: 20px; }
.stack { display: flex; flex-direction: column; gap: 20px; }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; padding: 14px 20px; border-bottom: 1px solid var(--border); }
.toolbar .search { flex: 1; min-width: 200px; max-width: 360px; }
.toolbar select.input { width: auto; min-width: 150px; }

/* ---------- KPIs ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.kpi { padding: 18px 20px; }
.kpi .k-label { font-size: 13px; color: var(--text-2); font-weight: 500; display: flex; align-items: center; gap: 8px; }
.kpi .k-icon { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); }
.kpi .k-icon svg { width: 16px; height: 16px; }
.kpi .k-value { font-size: 26px; font-weight: 700; margin-top: 12px; letter-spacing: -.01em; }
.kpi .k-foot { font-size: 12.5px; color: var(--text-2); margin-top: 4px; }

.dash-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 20px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-size: 12px; font-weight: 600; color: var(--text-2); text-transform: uppercase; letter-spacing: .03em;
  background: #f9fafb; padding: 11px 16px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.table td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: #fafbfc; }
.table .r { text-align: right; }
.table .c { text-align: center; }
.table .actions { text-align: right; white-space: nowrap; }
.cell-title { font-weight: 600; }
.cell-sub { font-size: 12px; color: var(--text-2); margin-top: 2px; }
.empty { text-align: center; color: var(--text-2); padding: 40px 20px !important; }
.empty svg { width: 32px; height: 32px; color: var(--muted); display: block; margin: 0 auto 8px; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 999px;
  font-size: 12px; font-weight: 600; background: var(--bg); color: var(--text-2); border: 1px solid var(--border); white-space: nowrap;
}
.badge svg { width: 12px; height: 12px; stroke-width: 2.4; }
.badge.good { background: var(--good-bg); color: var(--good); border-color: #abefc6; }
.badge.warn { background: var(--warn-bg); color: var(--warn); border-color: #fedf89; }
.badge.bad { background: var(--bad-bg); color: var(--bad); border-color: #fecdca; }
.badge.info { background: var(--primary-soft); color: var(--primary); border-color: #c7d2fe; }

/* ---------- Bar chart (single series) ---------- */
.bars { display: flex; flex-direction: column; gap: 14px; }
.bar-row { display: grid; grid-template-columns: 130px 1fr 110px; gap: 12px; align-items: center; position: relative; }
.bar-row .b-label { font-size: 13px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-row .b-track { height: 12px; position: relative; }
.bar-row .b-fill { height: 100%; background: #3b5bdb; border-radius: 0 4px 4px 0; min-width: 2px; }
.bar-row .b-val { font-size: 13px; color: var(--text-2); text-align: right; font-variant-numeric: tabular-nums; }
.bar-row:hover .b-fill { background: #2447d6; }
.bar-row:hover .b-label { font-weight: 600; }
.chart-tip {
  position: fixed; z-index: 90; pointer-events: none; background: #101828; color: #fff; font-size: 12px;
  padding: 8px 10px; border-radius: 6px; box-shadow: var(--shadow-lg); line-height: 1.5; display: none;
}

/* ---------- Tabs ---------- */
.seg { display: inline-flex; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 3px; }
.seg button { border: 0; background: transparent; font: inherit; font-size: 13px; font-weight: 600; color: var(--text-2); padding: 6px 12px; border-radius: 6px; cursor: pointer; }
.seg button.on { background: #fff; color: var(--text); box-shadow: var(--shadow); }

/* ---------- POS / Sales ---------- */
.pos { display: grid; grid-template-columns: 1fr 430px; gap: 20px; align-items: start; }
.pos-right { position: sticky; top: 92px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--border-strong); background: #fff; font: inherit; font-size: 12.5px; font-weight: 600;
  color: var(--text-2); padding: 5px 11px; border-radius: 999px; cursor: pointer;
}
.chip.on { background: var(--primary); border-color: var(--primary); color: #fff; }
.prod-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; padding: 20px; }
.prod {
  border: 1px solid var(--border); border-radius: 10px; padding: 14px; background: #fff; cursor: pointer; text-align: left;
  font: inherit; color: inherit; display: flex; flex-direction: column; gap: 6px; transition: border-color .12s, box-shadow .12s;
}
.prod:hover { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(36,71,214,.1); }
.prod:disabled { opacity: .55; cursor: not-allowed; box-shadow: none; border-color: var(--border); }
.prod .p-type { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; }
.prod .p-name { font-weight: 600; line-height: 1.3; }
.prod .p-meta { font-size: 12px; color: var(--text-2); }
.prod .p-foot { display: flex; justify-content: space-between; align-items: center; margin-top: auto; padding-top: 6px; }
.prod .p-price { font-weight: 700; font-size: 15px; }

.cart-items { max-height: 300px; overflow-y: auto; }
.cart-line { display: grid; grid-template-columns: 1fr auto auto 28px; gap: 10px; align-items: center; padding: 12px 20px; border-bottom: 1px solid var(--border); }
.cart-line .cl-name { font-weight: 600; font-size: 13.5px; }
.cart-line .cl-sub { font-size: 12px; color: var(--text-2); }
.qty { display: inline-flex; align-items: center; border: 1px solid var(--border-strong); border-radius: 8px; overflow: hidden; }
.qty button { width: 28px; height: 30px; border: 0; background: #fff; cursor: pointer; font-size: 16px; color: var(--text-2); }
.qty button:hover { background: var(--bg); }
.qty input { width: 38px; height: 30px; border: 0; border-left: 1px solid var(--border); border-right: 1px solid var(--border); text-align: center; font: inherit; }
.qty input:focus { outline: none; }
.cart-empty { padding: 28px 20px; text-align: center; color: var(--text-2); font-size: 13px; border-bottom: 1px solid var(--border); }
.totals { padding: 14px 20px; display: flex; flex-direction: column; gap: 8px; }
.totals .row { display: flex; justify-content: space-between; align-items: center; font-size: 13.5px; }
.totals .grand { font-size: 18px; font-weight: 700; padding-top: 10px; border-top: 1px dashed var(--border-strong); }
.totals .input { height: 32px; width: 110px; text-align: right; }
.section-title { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; font-weight: 700; color: var(--text-2); margin-bottom: 12px; }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; z-index: 50; background: rgba(16,24,40,.45); display: none; align-items: flex-start; justify-content: center; padding: 6vh 16px; overflow-y: auto; }
.modal.open { display: flex; }
.modal-dialog { background: #fff; border-radius: 12px; width: 100%; max-width: 560px; box-shadow: var(--shadow-lg); animation: pop .14s ease-out; }
.modal-dialog.wide { max-width: 760px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.modal-head h3 { font-size: 16px; }
.modal-body { padding: 22px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 22px; border-top: 1px solid var(--border); background: #fcfcfd; border-radius: 0 0 12px 12px; }
.modal-foot:empty { display: none; }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- Toast ---------- */
.toast-wrap { position: fixed; right: 20px; bottom: 20px; z-index: 100; display: flex; flex-direction: column; gap: 8px; }
.toast { background: #101828; color: #fff; padding: 11px 16px; border-radius: 8px; box-shadow: var(--shadow-lg); font-size: 13.5px; display: flex; gap: 8px; align-items: center; animation: pop .15s ease-out; }
.toast.bad { background: var(--bad); }

/* ---------- Receipt ---------- */
.receipt { font-size: 13px; color: #111; background: #fff; }
.receipt .r-head { display: flex; justify-content: space-between; gap: 16px; border-bottom: 2px solid #111; padding-bottom: 14px; }
.receipt .r-dojo { font-size: 20px; font-weight: 800; }
.receipt .r-addr { color: #444; font-size: 12px; margin-top: 4px; line-height: 1.5; white-space: pre-line; }
.receipt .r-title { text-align: right; }
.receipt .r-title .t { font-size: 13px; font-weight: 800; letter-spacing: .12em; color: var(--brand); }
.receipt .r-title .no { font-size: 16px; font-weight: 700; margin-top: 4px; }
.receipt .r-info { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; padding: 14px 0; border-bottom: 1px solid #ddd; }
.receipt .r-info .lbl { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: #666; font-weight: 700; margin-bottom: 4px; }
.receipt .r-info .val { line-height: 1.6; }
.receipt table { width: 100%; border-collapse: collapse; margin-top: 14px; }
.receipt th { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; text-align: left; border-bottom: 1px solid #111; padding: 8px 6px; }
.receipt td { padding: 8px 6px; border-bottom: 1px solid #eee; }
.receipt .r { text-align: right; }
.receipt .r-sum { margin-left: auto; width: 260px; margin-top: 12px; }
.receipt .r-sum div { display: flex; justify-content: space-between; padding: 4px 6px; }
.receipt .r-sum .g { font-size: 16px; font-weight: 800; border-top: 2px solid #111; margin-top: 4px; padding-top: 8px; }
.receipt .r-foot { display: flex; justify-content: space-between; align-items: flex-end; margin-top: 36px; gap: 16px; }
.receipt .r-sign { border-top: 1px solid #111; padding-top: 6px; width: 180px; text-align: center; font-size: 12px; }
.receipt .r-note { font-size: 12px; color: #444; }
.paid-stamp { display: inline-block; border: 2px solid var(--good); color: var(--good); font-weight: 800; letter-spacing: .1em; padding: 2px 10px; border-radius: 4px; transform: rotate(-4deg); font-size: 13px; }

#printArea { display: none; }
@media print {
  @page { size: A5; margin: 10mm; }
  body { background: #fff; }
  body.printing .app, body.printing .modal, body.printing .toast-wrap { display: none !important; }
  body.printing #printArea { display: block; }
}

/* ---------- Responsive (desktop first) ---------- */
@media (max-width: 1280px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .pos { grid-template-columns: 1fr 380px; }
}
@media (max-width: 1080px) {
  .dash-grid { grid-template-columns: 1fr; }
  .pos { grid-template-columns: 1fr; }
  .pos-right { position: static; }
}
@media (max-width: 900px) {
  .sidebar { position: fixed; left: 0; top: 0; z-index: 60; transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: none; }
  .backdrop.open { display: block; position: fixed; inset: 0; background: rgba(16,24,40,.4); z-index: 55; }
  .icon-btn.menu-btn { display: inline-grid; }
  .topbar { padding: 12px 16px; }
  .content { padding: 16px 16px 40px; }
}
@media (max-width: 640px) {
  .kpis { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi { padding: 14px; }
  .kpi .k-value { font-size: 20px; }
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
  .span2 { grid-column: auto; }
  .topbar h1 { font-size: 17px; }
  .topbar-actions .btn span.lbl { display: none; }
  .page-sub { display: none; }
  .toolbar .search { max-width: none; }
  .toolbar select.input { flex: 1; }
  .bar-row { grid-template-columns: 90px 1fr 84px; }
  .prod-grid { grid-template-columns: 1fr 1fr; padding: 12px; gap: 10px; }
  .receipt .r-head, .receipt .r-info { grid-template-columns: 1fr; flex-direction: column; }
  .receipt .r-title { text-align: left; }
  .receipt .r-sum { width: 100%; }
  .modal { padding: 0; }
  .modal-dialog { border-radius: 0; min-height: 100vh; }
  .card-head, .toolbar { padding: 12px 14px; }
  .table th, .table td { padding: 10px 12px; }
}

/* ===================== Student module ===================== */
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; }
.input.sm { height: 32px; padding: 0 10px; font-size: 13px; }
select.input.sm { padding-right: 4px; }
tr.click { cursor: pointer; }
.who { display: flex; align-items: center; gap: 10px; }
.avatar { width: 56px; height: 56px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; font-weight: 700; font-size: 20px; flex: none; }
.avatar.sm { width: 34px; height: 34px; font-size: 13px; }

.belt { display: inline-flex; align-items: center; gap: 7px; font-weight: 600; font-size: 13px; white-space: nowrap; }
.belt i { width: 22px; height: 8px; border-radius: 2px; border: 1px solid rgba(16, 24, 40, .3); flex: none; }

.profile { display: grid; grid-template-columns: 340px 1fr; gap: 20px; align-items: start; }
.profile > *, .pos > *, .dash-grid > * { min-width: 0; }
.dl { display: grid; grid-template-columns: 118px 1fr; gap: 9px 12px; font-size: 13px; margin: 0; }
.dl dt { color: var(--text-2); }
.dl dd { margin: 0; word-break: break-word; }
.alert-box { display: flex; gap: 10px; align-items: flex-start; margin-top: 16px; padding: 12px 14px; border-radius: 8px; background: var(--warn-bg); border: 1px solid #fedf89; color: #7a2e0e; font-size: 13px; line-height: 1.5; }
.alert-box svg { color: var(--warn); margin-top: 1px; }

.li { display: flex; gap: 14px; align-items: center; padding: 12px 20px; border-bottom: 1px solid var(--border); color: inherit; }
.li:last-child { border-bottom: 0; }
.li:hover { background: #fafbfc; }
.date-box { width: 46px; flex: none; text-align: center; border: 1px solid var(--border); border-radius: 8px; padding: 4px 0; background: #fff; }
.date-box .mo { font-size: 10.5px; text-transform: uppercase; color: var(--brand); font-weight: 700; letter-spacing: .04em; }
.date-box .d { font-size: 17px; font-weight: 700; line-height: 1.2; }

/* attendance marking */
.att { display: inline-flex; gap: 6px; }
.att button { width: 38px; height: 34px; border: 1px solid var(--border-strong); background: #fff; border-radius: 8px; font: inherit; font-weight: 700; cursor: pointer; color: var(--text-2); }
.att button:hover { background: var(--bg); }
.att button.on[data-v=P] { background: var(--good-bg); border-color: #75e0a7; color: var(--good); }
.att button.on[data-v=L] { background: var(--warn-bg); border-color: #fec84b; color: var(--warn); }
.att button.on[data-v=A] { background: var(--bad-bg); border-color: #fda29b; color: var(--bad); }
.att-sum { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.save-bar { position: sticky; bottom: 0; display: flex; gap: 10px; align-items: center; padding: 14px 20px; border-top: 1px solid var(--border); background: rgba(255,255,255,.96); border-radius: 0 0 var(--radius) var(--radius); flex-wrap: wrap; }

/* monthly register */
.table.reg th, .table.reg td { padding: 8px 6px; }
.table.reg th:first-child, .table.reg td:first-child { position: sticky; left: 0; background: #fff; z-index: 1; padding-left: 16px; min-width: 170px; box-shadow: 1px 0 0 var(--border); }
.table.reg thead th:first-child { background: #f9fafb; }
.table.reg td.m { text-align: center; font-weight: 700; font-size: 12px; color: var(--muted); min-width: 30px; }
.table.reg td.m-P { color: var(--good); background: var(--good-bg); }
.table.reg td.m-L { color: var(--warn); background: var(--warn-bg); }
.table.reg td.m-A { color: var(--bad); background: var(--bad-bg); }

/* grading result select */
select.res-Pass { border-color: #75e0a7; background: var(--good-bg); color: var(--good); font-weight: 600; }
select.res-Fail { border-color: #fda29b; background: var(--bad-bg); color: var(--bad); font-weight: 600; }

/* student picker */
.check-all { display: flex; gap: 8px; align-items: center; font-weight: 600; font-size: 13px; margin-bottom: 8px; cursor: pointer; }
.checklist { border: 1px solid var(--border); border-radius: 8px; max-height: 46vh; overflow-y: auto; }
.check-row { display: grid; grid-template-columns: 20px 1fr auto; gap: 12px; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--border); cursor: pointer; }
.check-row:last-child { border-bottom: 0; }
.check-row:hover { background: #fafbfc; }
.check-row[hidden] { display: none; }
.check-row .cell-sub { display: block; }
.collect-total { display: flex; justify-content: space-between; font-size: 18px; font-weight: 700; margin-top: 18px; padding-top: 14px; border-top: 1px dashed var(--border-strong); }

@media (max-width: 1080px) {
  .profile { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .dl { grid-template-columns: 105px 1fr; }
  .topbar h1 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .topbar > div:nth-child(2) { min-width: 0; flex: 1; }
  .topbar-actions { flex-wrap: nowrap; gap: 6px; }
  .topbar-actions .btn { width: 40px; height: 40px; padding: 0; border-radius: 12px; flex: none; }
  .topbar-actions .btn svg { width: 19px; height: 19px; }
  .seg { flex-wrap: wrap; }
  .att button { width: 40px; height: 38px; }
}

/* ===================== Cloud: auth, account, sync status ===================== */
body.auth-mode .app { display: none; }
#auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: var(--bg); }
.auth-card { width: 100%; max-width: 420px; padding: 28px; }
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.auth-card h2 { font-size: 20px; }
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-error { background: var(--bad-bg); color: var(--bad); border: 1px solid #fecdca; border-radius: 8px; padding: 10px 12px; font-size: 13px; }
.auth-note { background: var(--warn-bg); color: #7a2e0e; border: 1px solid #fedf89; border-radius: 8px; padding: 10px 12px; font-size: 13px; margin-bottom: 14px; line-height: 1.5; }

.side-foot { margin-top: auto; border-top: 1px solid var(--border); padding: 14px 16px 18px; display: flex; flex-direction: column; gap: 12px; background: #fcfcfd; }
.sync-status { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-2); flex-wrap: wrap; }
.sync-status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.sync-status .dot.ok { background: #17b26a; }
.sync-status .dot.busy { background: var(--primary); animation: pulse 1s infinite alternate; }
.sync-status .dot.warn { background: #f79009; }
.sync-status .dot.bad { background: var(--bad); }
@keyframes pulse { to { opacity: .35; } }
.link-btn { border: 0; background: none; padding: 0; font: inherit; font-size: 12.5px; color: var(--primary); font-weight: 600; cursor: pointer; }
.me { display: flex; align-items: center; gap: 10px; }
.avatar.xs { width: 32px; height: 32px; font-size: 12px; }
.me-name { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-sub { font-size: 11.5px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-actions { display: flex; gap: 6px; }
.me-actions .btn { flex: 1; padding: 0 8px; font-size: 12px; }
.sidebar { padding-bottom: env(safe-area-inset-bottom); }
.topbar { padding-top: max(14px, env(safe-area-inset-top)); }

/* ===================== Phone app experience ===================== */
:root {
  /* Capacitor sets --safe-area-inset-* on Android; browsers use env() */
  --sat: var(--safe-area-inset-top, env(safe-area-inset-top, 0px));
  --sab: var(--safe-area-inset-bottom, env(safe-area-inset-bottom, 0px));
  --sal: var(--safe-area-inset-left, env(safe-area-inset-left, 0px));
  --sar: var(--safe-area-inset-right, env(safe-area-inset-right, 0px));
}
html.native, html.native body { -webkit-tap-highlight-color: transparent; overscroll-behavior-y: none; }
html.native .nav a, html.native .tabbar, html.native .btn, html.native .chip, html.native .seg button { -webkit-user-select: none; user-select: none; }

.tabbar { display: none; }

@media (max-width: 900px) {
  body { -webkit-tap-highlight-color: transparent; }
  .topbar { padding: calc(10px + var(--sat)) calc(16px + var(--sar)) 10px calc(16px + var(--sal)); min-height: 0; }
  .icon-btn.menu-btn { display: none; }          /* "More" tab opens the menu */
  .content { padding-bottom: calc(88px + var(--sab)); }
  .sidebar { padding-top: var(--sat); width: min(84vw, 300px); }
  .side-foot { padding-bottom: calc(18px + var(--sab)); }

  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr);
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 45;
    background: rgba(255, 255, 255, .96); backdrop-filter: saturate(1.6) blur(10px);
    border-top: 1px solid var(--border);
    padding: 0 var(--sar) var(--sab) var(--sal);
  }
  .tabbar a, .tabbar button {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    min-height: 58px; padding: 6px 0; border: 0; background: none; font: inherit;
    font-size: 11px; font-weight: 600; color: var(--text-2); cursor: pointer; position: relative;
  }
  .tabbar svg { width: 23px; height: 23px; }
  .tabbar .on { color: var(--primary); }
  .tabbar .on::before { content: ""; position: absolute; top: 0; left: 30%; right: 30%; height: 3px; border-radius: 0 0 3px 3px; background: var(--primary); }
  .tabbar a:active, .tabbar button:active { background: var(--bg); }

  .toast-wrap { left: 16px; right: 16px; bottom: calc(74px + var(--sab)); align-items: center; }
  .toast { max-width: 100%; }

  .pos-right { padding-bottom: 8px; }
  .save-bar { bottom: calc(58px + var(--sab)); }
}

@media (max-width: 640px) {
  .content { padding-left: calc(12px + var(--sal)); padding-right: calc(12px + var(--sar)); padding-top: 14px; }
  .stack { gap: 14px; }
  .card { border-radius: 14px; }
  .kpi .k-icon { width: 28px; height: 28px; }
  .btn { height: 42px; border-radius: 10px; }
  .btn.sm { height: 34px; }
  .input, select.input { height: 44px; font-size: 16px; border-radius: 10px; }
  textarea.input { font-size: 16px; }
  .input.sm, select.input.sm { height: 36px; font-size: 14px; }
  .icon-btn { width: 40px; height: 40px; }
  .table td, .table th { white-space: nowrap; }
  .table td .cell-sub { white-space: normal; }
  .table-wrap { -webkit-overflow-scrolling: touch; }

  /* full-screen dialogs with a pinned header and action bar */
  .modal { padding: 0; align-items: stretch; }
  .modal-dialog { display: flex; flex-direction: column; min-height: 100%; border-radius: 0; animation: sheet .2s ease-out; }
  .modal-head { position: sticky; top: 0; z-index: 2; background: #fff; padding-top: calc(14px + var(--sat)); }
  .modal-body { flex: 1; padding: 18px 16px; }
  .modal-foot { position: sticky; bottom: 0; z-index: 2; padding: 12px 16px calc(12px + var(--sab)); border-radius: 0; box-shadow: 0 -4px 16px rgba(16, 24, 40, .06); }
  .modal-foot .btn { flex: 1; }
  #auth { padding: calc(24px + var(--sat)) 16px calc(24px + var(--sab)); }
  .auth-card { border-radius: 18px; }
}
@keyframes sheet { from { transform: translateY(24px); opacity: .6; } to { transform: none; opacity: 1; } }

/* attendance marking: keep student + P/L/A visible on phones */
@media (max-width: 640px) {
  .att-table th:nth-child(1), .att-table td:nth-child(1),
  .att-table th:nth-child(3), .att-table td:nth-child(3),
  .att-table th:nth-child(5), .att-table td:nth-child(5) { display: none; }
  .att-table td:nth-child(2) { white-space: normal; }
  .att { gap: 8px; }
  .att button { width: 44px; height: 42px; border-radius: 10px; }
}

/* floating "view cart" bar on the sale screen (phones/tablets) */
.cart-fab { display: none; }
@media (max-width: 1080px) {
  .cart-fab.show {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    position: fixed; left: 12px; right: 12px; bottom: 16px; z-index: 44;
    height: 52px; padding: 0 18px; border: 0; border-radius: 14px;
    background: var(--primary); color: #fff; font: inherit; font-weight: 700; font-size: 15px;
    box-shadow: 0 8px 24px rgba(36, 71, 214, .35); cursor: pointer;
  }
}
@media (max-width: 900px) { .cart-fab.show { bottom: calc(68px + var(--sab)); } }
