:root {
  --blue: #0b83bd;
  --blue-dark: #075d8c;
  --ink: #082033;
  --muted: #5d7890;
  --line: #d8e7f0;
  --soft: #eef8fd;
  --green: #157a4d;
  --red: #a53333;
  --gold: #9a7422;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: #f5fbff; color: var(--ink); }
button, input, select { font: inherit; }
button { border: 0; cursor: pointer; }

.hidden { display: none !important; }
.login-view { min-height: 100vh; display: grid; align-content: start; gap: 1rem; padding: clamp(2rem, 10vh, 5rem) 1.25rem 1.25rem; }
.login-brand { text-align: center; }
.mark { width: 72px; height: 72px; margin: 0 auto 0.75rem; border-radius: 20px; display: grid; place-items: center; background: var(--blue); color: #fff; font-weight: 900; letter-spacing: 0.08em; box-shadow: 0 12px 30px rgba(11, 131, 189, 0.25); }
h1, h2, p { margin: 0; }
.login-brand h1 { font-size: 1.7rem; }
.login-brand p, #user-label, .muted { color: var(--muted); }

.panel { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 1rem; box-shadow: 0 8px 24px rgba(8, 32, 51, 0.06); }
label { display: grid; gap: 0.35rem; color: var(--muted); font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; }
input, select { width: 100%; min-height: 44px; border: 1px solid var(--line); border-radius: 10px; padding: 0.65rem 0.75rem; background: #fbfdff; color: var(--ink); }
input:focus, select:focus { outline: 2px solid rgba(11, 131, 189, 0.18); border-color: var(--blue); }
.password-field { position: relative; display: block; }
.password-field input { padding-right: 4.25rem; }
.password-toggle { position: absolute; right: 0.35rem; top: 50%; transform: translateY(-50%); min-height: 34px; border-radius: 8px; padding: 0 0.7rem; background: var(--soft); color: var(--blue-dark); font-size: 0.78rem; font-weight: 900; }

.primary, .ghost { min-height: 44px; border-radius: 10px; padding: 0.65rem 0.9rem; font-weight: 800; }
.primary { background: var(--green); color: #fff; }
.ghost { background: #eaf4fa; color: var(--blue-dark); }
.small { min-height: 34px; padding: 0.35rem 0.65rem; font-size: 0.8rem; }
.error { min-height: 1.2rem; color: var(--red); font-size: 0.85rem; }

.app-view { min-height: 100vh; padding-bottom: calc(74px + env(safe-area-inset-bottom)); }
.topbar { position: sticky; top: 0; z-index: 20; min-height: 62px; padding: env(safe-area-inset-top) 1rem 0.75rem; display: flex; align-items: end; justify-content: space-between; gap: 0.8rem; background: var(--blue); color: #fff; }
.topbar > div { display: grid; gap: 0.15rem; }
.topbar #user-label { color: rgba(255,255,255,0.82); font-size: 0.8rem; }
main { padding: 0.8rem; display: grid; gap: 0.8rem; }
.session-panel { display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 0.8rem; }
.today-pill { background: var(--soft); color: var(--blue-dark); border-radius: 999px; padding: 0.7rem 0.85rem; font-weight: 900; white-space: nowrap; }

.screen { display: none; }
.screen.active { display: grid; gap: 0.8rem; }
.screen-head { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; }
.screen-head h2 { font-size: 1.25rem; }
.search { background: #fff; }
.compact-filter { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 0.75rem; }
.form-stack { display: grid; gap: 0.75rem; }
.cash-form { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.cash-form button { grid-column: 1 / -1; }

.list { display: grid; gap: 0.65rem; }
.item { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 0.85rem; display: grid; gap: 0.45rem; }
.item-top { display: flex; align-items: start; justify-content: space-between; gap: 0.75rem; }
.item h3 { margin: 0; font-size: 0.98rem; overflow-wrap: anywhere; }
.meta { display: flex; gap: 0.45rem; flex-wrap: wrap; color: var(--muted); font-size: 0.82rem; }
.badge { display: inline-flex; align-items: center; border-radius: 999px; padding: 0.2rem 0.55rem; background: var(--soft); color: var(--blue-dark); font-weight: 800; }
button.badge { min-height: 30px; }
.badge.inactive { color: var(--red); background: #fff1f1; }
.amount { font-weight: 900; color: var(--green); white-space: nowrap; }
.danger { color: var(--red); }

.options { position: relative; }
.options:not(:empty) { margin-top: 0.35rem; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #fff; }
.option { padding: 0.75rem; border-bottom: 1px solid var(--line); text-transform: none; letter-spacing: 0; color: var(--ink); }
.option:last-child { border-bottom: 0; }

.summary-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.65rem; }
.summary { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 0.85rem; }
.summary span { color: var(--muted); font-size: 0.78rem; font-weight: 800; text-transform: uppercase; }
.summary strong { display: block; margin-top: 0.25rem; font-size: 1.25rem; }
#student-stats.admin { grid-template-columns: 1fr 1fr; }
#student-stats:not(.admin) { grid-template-columns: 1fr; }

.bottom-nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 25; display: grid; grid-template-columns: repeat(7, 1fr); padding: 0.35rem 0.35rem calc(0.35rem + env(safe-area-inset-bottom)); background: #fff; border-top: 1px solid var(--line); box-shadow: 0 -8px 24px rgba(8, 32, 51, 0.08); }
.bottom-nav button { min-height: 48px; border-radius: 10px; background: transparent; color: var(--muted); font-size: 0.72rem; font-weight: 900; }
.bottom-nav button.active { background: var(--blue); color: #fff; }

dialog { width: min(92vw, 420px); border: 0; border-radius: 14px; padding: 0; box-shadow: 0 18px 60px rgba(8, 32, 51, 0.25); }
dialog::backdrop { background: rgba(8, 32, 51, 0.45); }
.receipt { padding: 1rem; color: #111; background: #fff; font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; }
.receipt h2 { text-align: center; font-size: 1rem; margin-bottom: 0.3rem; }
.receipt-logo { display: block; width: 58px; height: 58px; object-fit: contain; margin: 0 auto 0.4rem; }
.receipt-seal-slot { height: 30px; display: flex; align-items: center; justify-content: center; }
.receipt-seal { display: block; width: 58px; height: 58px; object-fit: contain; opacity: 0.9; }
.receipt-row { display: flex; justify-content: space-between; gap: 0.8rem; padding: 0.3rem 0; border-bottom: 1px dashed #ddd; }
.receipt-total { margin-top: 0.35rem; padding-top: 0.35rem; border-top: 2px dashed #111; display: flex; justify-content: space-between; font-weight: 900; }
.dialog-actions { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0.5rem; padding: 0.75rem; background: #f6fbff; }
.toast { position: fixed; left: 0.8rem; right: 0.8rem; bottom: calc(82px + env(safe-area-inset-bottom)); z-index: 60; transform: translateY(140%); opacity: 0; pointer-events: none; transition: transform 0.2s ease, opacity 0.2s ease; background: var(--ink); color: #fff; border-radius: 12px; padding: 0.85rem; font-weight: 800; text-align: center; }
.toast.show { animation: toast-life 2.4s ease forwards; }
@keyframes toast-life {
  0% { transform: translateY(140%); opacity: 0; }
  12% { transform: translateY(0); opacity: 1; }
  82% { transform: translateY(0); opacity: 1; }
  100% { transform: translateY(140%); opacity: 0; }
}
#print-root { display: none; }

@media print {
  @page { size: 80mm auto; margin: 0; }
  html, body { width: 80mm; margin: 0 !important; padding: 0 !important; background: #fff !important; }
  body.print-mode > :not(#print-root) { display: none !important; }
  body.print-mode dialog,
  body.print-mode #receipt-dialog,
  body.print-mode #receipt-dialog * { display: none !important; visibility: hidden !important; }
  .dialog-actions { display: none !important; visibility: hidden !important; }
  #print-root { display: block !important; width: 80mm; margin: 0; padding: 0; }
  .receipt { width: 80mm; max-width: 80mm; padding: 3mm 2.5mm 4mm; box-shadow: none; break-after: auto; page-break-after: auto; font-size: 23px; line-height: 1.22; font-weight: 700; }
  .receipt h2 { font-size: 27px; margin: 0 0 3mm; }
  .receipt-logo { width: 27mm; height: 27mm; margin-bottom: 3mm; }
  .receipt-seal-slot { height: 25mm; margin: 1mm 0; }
  .receipt-seal { width: 32mm; height: 32mm; }
  .receipt-row { padding: 2.8mm 0; gap: 3mm; }
  .receipt-row strong { overflow-wrap: anywhere; }
  .receipt-total { margin-top: 3mm; padding-top: 3mm; font-size: 27px; }
}
