/* SchoolPay Finance Portal - Design System */

:root {
  /* Neutrals - cool warm-leaning */
  --bg: #F4F6F8;
  --bg-soft: #EDF0F4;
  --surface: #FFFFFF;
  --surface-2: #FAFBFC;
  --border: #E4E7EB;
  --border-strong: #CBD2DA;
  --text: #0F1A2C;
  --text-2: #2A3849;
  --muted: #5C6878;
  --muted-2: #8A95A3;

  /* Brand */
  --navy: #0E2A47;
  --navy-2: #143862;
  --navy-soft: #E8EDF3;
  --navy-deep: #081A2E;

  --emerald: #0F7B5E;
  --emerald-2: #0B6149;
  --emerald-soft: #E2F1EC;

  --gold: #B8893B;
  --gold-2: #95701F;
  --gold-soft: #FAF1DE;

  --amber: #B86D00;
  --amber-soft: #FBEEDA;

  --danger: #BE3A2E;
  --danger-soft: #FBEAE7;

  --info: #1E5BA6;
  --info-soft: #E5EEF8;

  /* Shadow */
  --shadow-sm: 0 1px 2px rgba(15, 26, 44, 0.04), 0 1px 1px rgba(15, 26, 44, 0.03);
  --shadow-md: 0 4px 14px rgba(15, 26, 44, 0.06), 0 2px 4px rgba(15, 26, 44, 0.04);
  --shadow-lg: 0 12px 32px rgba(15, 26, 44, 0.10), 0 4px 10px rgba(15, 26, 44, 0.04);

  /* Type scale */
  --thai: "Sarabun", "Noto Sans Thai", -apple-system, sans-serif;
  --latin: "IBM Plex Sans", "Sarabun", -apple-system, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", monospace;

  /* Radii */
  --r-sm: 4px;
  --r-md: 6px;
  --r-lg: 10px;
  --r-pill: 999px;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--thai);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

input, select, textarea {
  font-family: inherit;
  font-size: 14px;
}

a { color: inherit; }

.num, .mono { font-family: var(--mono); font-feature-settings: "tnum" 1; }
.latin { font-family: var(--latin); }

/* ===== App shell ===== */
.app {
  display: grid;
  grid-template-columns: 244px 1fr;
  min-height: 100vh;
  min-width: 1280px;
}

.sidebar {
  background: var(--navy-deep);
  color: #C8D2E0;
  padding: 18px 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 20px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  margin-bottom: 8px;
}
.brand-mark {
  width: 32px; height: 32px;
  border-radius: 6px;
  background: linear-gradient(135deg, #1E5BA6, #0F7B5E);
  display: grid; place-items: center;
  color: #fff;
  font-weight: 700;
  font-family: var(--latin);
  font-size: 14px;
  letter-spacing: -0.02em;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.15), 0 0 0 1px rgba(0,0,0,0.2);
}
.brand-name {
  color: #FFFFFF;
  font-weight: 600;
  font-family: var(--latin);
  letter-spacing: -0.01em;
  font-size: 15px;
  line-height: 1.1;
}
.brand-sub {
  color: #8A98AE;
  font-size: 11px;
  margin-top: 2px;
}

.nav-section {
  padding: 8px 12px 4px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #6A7689;
  font-family: var(--latin);
  font-weight: 500;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  margin: 0 8px;
  border-radius: 6px;
  color: #C8D2E0;
  font-size: 13.5px;
  cursor: pointer;
  user-select: none;
  position: relative;
}
.nav-item:hover { background: rgba(255,255,255,0.04); color: #fff; }
.nav-item.active {
  background: rgba(255,255,255,0.08);
  color: #fff;
}
.nav-item.active::before {
  content: "";
  position: absolute;
  left: -8px; top: 8px; bottom: 8px;
  width: 3px;
  background: var(--gold);
  border-radius: 2px;
}
.nav-icon {
  width: 16px; height: 16px;
  display: inline-grid;
  place-items: center;
  color: #8A98AE;
}
.nav-item.active .nav-icon { color: #fff; }
.nav-children {
  margin-left: 34px;
  border-left: 1px solid rgba(255,255,255,0.08);
}
.nav-child {
  padding: 6px 12px;
  font-size: 12.5px;
  color: #98A4B8;
  cursor: pointer;
  border-radius: 4px;
  margin: 1px 8px 1px 0;
}
.nav-child:hover { color: #fff; }
.nav-child.active { color: #fff; font-weight: 500; }

.sidebar-foot {
  margin-top: auto;
  padding: 14px 16px;
  border-top: 1px solid rgba(255,255,255,0.06);
  display: flex;
  align-items: center;
  gap: 10px;
}
.avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: #1E5BA6;
  color: #fff;
  display: grid; place-items: center;
  font-size: 12px; font-weight: 600;
  font-family: var(--latin);
}
.user-name { color: #fff; font-size: 13px; line-height: 1.2; }
.user-role { color: #8A98AE; font-size: 11px; font-family: var(--latin); }

/* ===== Main ===== */
.main { background: var(--bg); min-width: 0; }
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky; top: 0; z-index: 10;
}
.breadcrumb {
  font-size: 12.5px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
}
.breadcrumb b { color: var(--text); font-weight: 500; }
.breadcrumb .sep { color: var(--border-strong); }

.top-actions { display: flex; align-items: center; gap: 10px; }
.search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 6px 10px;
  border-radius: 6px;
  width: 280px;
  color: var(--muted);
  font-size: 13px;
}
.search input { border: none; background: none; outline: none; width: 100%; }
.kbd {
  font-family: var(--mono);
  font-size: 10.5px;
  padding: 1px 5px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--muted);
}
.icon-btn {
  width: 32px; height: 32px;
  border-radius: 6px;
  display: grid; place-items: center;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
}
.icon-btn:hover { background: var(--bg); color: var(--text); }
.dot-red { width: 6px; height: 6px; background: var(--danger); border-radius: 50%; position: absolute; top: 6px; right: 6px; }

.content {
  padding: 24px 28px 60px;
  max-width: 1440px;
}

/* ===== Typography ===== */
.page-h1 {
  font-size: 22px;
  font-weight: 600;
  margin: 0 0 4px;
  letter-spacing: -0.01em;
}
.page-sub { color: var(--muted); font-size: 13.5px; margin: 0 0 20px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }

.section-h {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 12px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}
.section-h .link { font-size: 12.5px; color: var(--info); font-weight: 500; cursor: pointer; }

/* ===== Cards ===== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
}
.card-pad { padding: 16px 18px; }
.card-pad-lg { padding: 20px 22px; }
.card-head {
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.card-head h3 { margin: 0; font-size: 14px; font-weight: 600; }

/* ===== KPI cards ===== */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  position: relative;
  overflow: hidden;
}
.kpi-label { color: var(--muted); font-size: 12.5px; margin-bottom: 6px; display: flex; align-items: center; gap: 6px; }
.kpi-value { font-size: 24px; font-weight: 600; font-family: var(--latin); letter-spacing: -0.02em; font-feature-settings: "tnum" 1; }
.kpi-value .suffix { font-size: 13px; color: var(--muted); font-weight: 400; margin-left: 4px; }
.kpi-delta { margin-top: 6px; font-size: 11.5px; font-family: var(--latin); color: var(--muted); display: flex; align-items: center; gap: 4px; }
.kpi-delta.up { color: var(--emerald); }
.kpi-delta.down { color: var(--danger); }
.kpi.accent-emerald { border-left: 3px solid var(--emerald); }
.kpi.accent-navy { border-left: 3px solid var(--navy); }
.kpi.accent-gold { border-left: 3px solid var(--gold); }
.kpi.accent-danger { border-left: 3px solid var(--danger); }

.kpi-bar {
  height: 4px;
  background: var(--bg-soft);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 10px;
}
.kpi-bar .fill { height: 100%; background: var(--emerald); }

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  font-size: 13px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-weight: 500;
  white-space: nowrap;
  transition: all .12s;
}
.btn:hover { background: var(--bg-soft); }
.btn.primary { background: var(--navy); color: #fff; border-color: var(--navy); }
.btn.primary:hover { background: var(--navy-2); }
.btn.emerald { background: var(--emerald); color: #fff; border-color: var(--emerald); }
.btn.emerald:hover { background: var(--emerald-2); }
.btn.danger { color: var(--danger); border-color: #E8C8C3; background: #FDF6F4; }
.btn.danger:hover { background: var(--danger-soft); }
.btn.ghost { border: none; }
.btn.sm { padding: 4px 10px; font-size: 12px; }
.btn.lg { padding: 10px 16px; font-size: 14px; }
.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; }
.btn-group .btn:first-child { border-radius: 6px 0 0 6px; }
.btn-group .btn:last-child { border-radius: 0 6px 6px 0; border-left: none; }

/* ===== Badges ===== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: var(--r-pill);
  font-size: 11.5px;
  font-weight: 500;
  background: var(--bg-soft);
  color: var(--text-2);
  border: 1px solid transparent;
  white-space: nowrap;
  line-height: 1.5;
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.paid { background: var(--emerald-soft); color: var(--emerald-2); }
.badge.pending { background: var(--info-soft); color: var(--info); }
.badge.review { background: var(--amber-soft); color: var(--amber); }
.badge.issued { background: var(--navy-soft); color: var(--navy); }
.badge.draft { background: var(--bg-soft); color: var(--muted); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.gold { background: var(--gold-soft); color: var(--gold-2); }
.badge.expired { background: #F2EEEE; color: #74675F; }
.badge.cancelled { background: #F2EEEE; color: #74675F; text-decoration: line-through; }
.badge.refunded { background: var(--info-soft); color: var(--info); }
.badge.partial { background: var(--gold-soft); color: var(--gold-2); }
.badge.overpaid { background: var(--danger-soft); color: var(--danger); }
.badge.receipt-issued { background: var(--emerald-soft); color: var(--emerald-2); }
.badge.solid { background: var(--navy); color: #fff; }

/* ===== Tables ===== */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td {
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  vertical-align: middle;
}
.table th {
  background: var(--surface-2);
  font-weight: 500;
  color: var(--muted);
  font-size: 11.5px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-family: var(--latin);
  border-top: 1px solid var(--border);
}
.table tr:hover td { background: var(--surface-2); }
.table tr:last-child td { border-bottom: none; }
.table td.r, .table th.r { text-align: right; font-family: var(--mono); font-feature-settings: "tnum" 1; }
.table td .stack { display: flex; flex-direction: column; gap: 1px; }
.table td .stack .sub { font-size: 11.5px; color: var(--muted); }
.table td .stack .sub.mono { font-size: 11px; }
.thai-name { font-weight: 500; }

.row-check { width: 18px; }
.checkbox {
  width: 16px; height: 16px;
  border: 1.5px solid var(--border-strong);
  border-radius: 3px;
  display: inline-block;
  vertical-align: middle;
  position: relative;
  background: var(--surface);
}
.checkbox.checked { background: var(--navy); border-color: var(--navy); }
.checkbox.checked::after {
  content: "";
  position: absolute;
  left: 4px; top: 1px;
  width: 5px; height: 9px;
  border: 2px solid #fff;
  border-top: none; border-left: none;
  transform: rotate(45deg);
}

/* ===== Filters ===== */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 12px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
.filter {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12.5px;
  cursor: pointer;
  color: var(--text-2);
}
.filter:hover { border-color: var(--border-strong); }
.filter b { color: var(--text); font-weight: 500; }
.filter .x { color: var(--muted-2); margin-left: 2px; }

.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--border); }
.tab {
  padding: 10px 16px;
  font-size: 13px;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  cursor: pointer;
  font-weight: 500;
  display: inline-flex; align-items: center; gap: 6px;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--navy); border-color: var(--gold); }

/* ===== Forms ===== */
.field { margin-bottom: 14px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.label {
  display: block;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-2);
  margin-bottom: 4px;
}
.label .req { color: var(--danger); }
.hint { font-size: 11.5px; color: var(--muted); margin-top: 4px; font-family: var(--latin); }
.input, .select, .textarea {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color .12s, box-shadow .12s;
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--navy); box-shadow: 0 0 0 3px rgba(14,42,71,0.08); }
.input.mono { font-family: var(--mono); }
.input.locked {
  background: var(--surface-2);
  color: var(--muted);
  font-family: var(--mono);
}
.input-group { display: flex; align-items: center; }
.input-group .input { border-radius: 6px 0 0 6px; }
.input-group .btn { border-radius: 0 6px 6px 0; border-left: none; }

.switch {
  width: 32px; height: 18px;
  background: var(--border-strong);
  border-radius: var(--r-pill);
  position: relative;
  cursor: pointer;
  transition: background .15s;
  flex-shrink: 0;
}
.switch::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: #fff;
  transition: left .15s;
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}
.switch.on { background: var(--emerald); }
.switch.on::after { left: 16px; }
.switch-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.switch-row:last-child { border-bottom: none; }
.switch-row .grow { flex: 1; }
.switch-row .switch-title { font-size: 13px; font-weight: 500; }
.switch-row .switch-desc { font-size: 12px; color: var(--muted); }

/* ===== Banners ===== */
.banner {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 6px;
  border: 1px solid;
  font-size: 13px;
  line-height: 1.5;
}
.banner.warn { background: var(--gold-soft); border-color: #E8D2A0; color: var(--gold-2); }
.banner.danger { background: var(--danger-soft); border-color: #E8C8C3; color: var(--danger); }
.banner.info { background: var(--info-soft); border-color: #C9D9EE; color: var(--info); }
.banner.success { background: var(--emerald-soft); border-color: #BCDDD0; color: var(--emerald-2); }
.banner b { font-weight: 600; }
.banner-icon { flex-shrink: 0; }

/* ===== Misc ===== */
.divider { height: 1px; background: var(--border); margin: 12px 0; }
.spacer-12 { height: 12px; }
.spacer-20 { height: 20px; }
.grid-2 { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }
.grid-2-equal { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.flex { display: flex; gap: 10px; align-items: center; }
.flex-col { display: flex; flex-direction: column; gap: 8px; }
.between { justify-content: space-between; }
.grow { flex: 1; }
.muted { color: var(--muted); }
.tiny { font-size: 11.5px; }
.right { text-align: right; }

/* Chart placeholders */
.chart-area {
  position: relative;
  height: 200px;
  padding: 14px;
}
.bars { display: flex; align-items: flex-end; gap: 10px; height: 100%; }
.bars .bar-group { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; }
.bars .bar-stack { display: flex; flex-direction: column-reverse; width: 100%; height: 90%; gap: 1px; }
.bars .bar { width: 100%; }
.bars .bar.paid { background: var(--emerald); }
.bars .bar.pending { background: var(--info-soft); border: 1px dashed var(--info); }
.bars .label { font-size: 11px; color: var(--muted); font-family: var(--latin); }

.donut {
  width: 140px; height: 140px;
  border-radius: 50%;
  background: conic-gradient(var(--emerald) 0% 72%, var(--info-soft) 72% 88%, var(--gold-soft) 88% 96%, var(--danger-soft) 96% 100%);
  position: relative;
}
.donut::after {
  content: "";
  position: absolute;
  inset: 22px;
  background: var(--surface);
  border-radius: 50%;
}
.donut-center {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  text-align: center;
  z-index: 1;
}
.donut-pct { font-size: 22px; font-weight: 600; font-family: var(--latin); }
.donut-label { font-size: 11px; color: var(--muted); }
.legend { display: flex; flex-direction: column; gap: 8px; font-size: 12.5px; }
.legend-item { display: flex; align-items: center; gap: 8px; }
.legend-sw { width: 10px; height: 10px; border-radius: 2px; }

/* Progress */
.progress {
  height: 8px;
  background: var(--bg-soft);
  border-radius: 4px;
  overflow: hidden;
  display: flex;
}
.progress .seg-paid { background: var(--emerald); }
.progress .seg-pending { background: var(--info); opacity: 0.4; }
.progress .seg-review { background: var(--gold); opacity: 0.6; }

/* Phone frame styling for parent flow */
.phone-stage {
  background: linear-gradient(180deg, #E8EDF3 0%, #DCE3EC 100%);
  min-height: calc(100vh - 60px);
  display: grid;
  place-items: start center;
  padding: 32px 20px;
}
.phone-multi {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  justify-content: center;
}
.phone {
  width: 380px;
  background: #fff;
  border-radius: 36px;
  border: 1px solid #C3CBD7;
  box-shadow: 0 20px 60px rgba(15, 26, 44, 0.18), 0 6px 20px rgba(15, 26, 44, 0.08);
  overflow: hidden;
  padding: 8px;
}
.phone-screen {
  background: var(--bg);
  border-radius: 28px;
  overflow: hidden;
  position: relative;
  min-height: 720px;
  display: flex;
  flex-direction: column;
}
.phone-status {
  display: flex;
  justify-content: space-between;
  padding: 10px 22px 4px;
  font-size: 12px;
  font-weight: 600;
  font-family: var(--latin);
}
.phone-screen-label {
  font-size: 11px;
  color: var(--muted);
  text-align: center;
  padding: 6px 0 0;
  font-family: var(--latin);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.phone-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 8px 16px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.phone-header .school-mark {
  width: 32px; height: 32px;
  border-radius: 6px;
  background: linear-gradient(135deg, #1E5BA6, #0F7B5E);
  display: grid; place-items: center;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  font-family: var(--latin);
}
.phone-title { font-size: 13.5px; font-weight: 600; line-height: 1.2; }
.phone-subtitle { font-size: 11.5px; color: var(--muted); }

.phone-body {
  padding: 16px;
  flex: 1;
  overflow-y: auto;
}

/* Receipt styles */
.receipt {
  background: #fff;
  width: 100%;
  max-width: 820px;
  border: 1px solid var(--border);
  padding: 48px 56px;
  position: relative;
  font-family: var(--thai);
  box-shadow: var(--shadow-md);
}
.receipt-watermark {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%) rotate(-30deg);
  font-size: 110px;
  color: rgba(14, 42, 71, 0.04);
  font-weight: 700;
  letter-spacing: 0.1em;
  pointer-events: none;
  font-family: var(--latin);
}
.receipt-head {
  display: flex;
  align-items: flex-start;
  gap: 18px;
  border-bottom: 2px solid var(--navy);
  padding-bottom: 16px;
  margin-bottom: 18px;
}
.school-crest {
  width: 64px; height: 64px;
  border-radius: 50%;
  background: var(--navy-soft);
  border: 2px solid var(--navy);
  display: grid; place-items: center;
  color: var(--navy);
  font-family: var(--latin);
  font-size: 9px;
  text-align: center;
  font-weight: 600;
  letter-spacing: 0.05em;
}
.receipt-school-name { font-size: 18px; font-weight: 700; color: var(--navy); margin: 0; }
.receipt-school-sub { font-size: 12px; color: var(--text-2); margin-top: 2px; line-height: 1.5; }
.receipt-title-block { text-align: right; margin-left: auto; }
.receipt-doc-title { font-size: 16px; font-weight: 700; color: var(--navy); }
.receipt-doc-sub { font-size: 11px; color: var(--muted); font-family: var(--latin); }

.receipt-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 18px;
  font-size: 12.5px;
  margin-bottom: 16px;
}
.receipt-meta div { display: flex; gap: 6px; }
.receipt-meta .k { color: var(--muted); min-width: 96px; }
.receipt-meta .v { color: var(--text); font-weight: 500; }

.receipt-table { width: 100%; border-collapse: collapse; margin: 16px 0; }
.receipt-table th, .receipt-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  font-size: 12.5px;
  text-align: left;
}
.receipt-table th {
  background: var(--bg-soft);
  font-weight: 600;
  border-bottom: 2px solid var(--border-strong);
}
.receipt-table td.r, .receipt-table th.r { text-align: right; font-family: var(--mono); }
.receipt-table tr.total td { border-top: 2px solid var(--navy); font-weight: 700; padding-top: 10px; }
.amount-thai { font-style: italic; color: var(--text-2); font-size: 12px; padding-top: 6px; }

.receipt-foot {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 20px;
  margin-top: 32px;
  font-size: 11.5px;
}
.sig-block {
  text-align: center;
  padding-top: 50px;
  border-top: 1px solid var(--text);
  margin-top: 24px;
}
.school-seal {
  width: 90px; height: 90px;
  border-radius: 50%;
  border: 2px dashed var(--gold);
  color: var(--gold-2);
  display: grid; place-items: center;
  font-size: 10px;
  margin: 0 auto;
  font-family: var(--latin);
  text-align: center;
  line-height: 1.2;
}

.qr-verify {
  display: flex; align-items: center; gap: 10px;
  border-top: 1px dashed var(--border);
  padding-top: 14px;
  margin-top: 18px;
  font-size: 11px;
  color: var(--muted);
}
.qr-mini {
  width: 56px; height: 56px;
  background:
    linear-gradient(45deg, #0F1A2C 25%, transparent 25%, transparent 75%, #0F1A2C 75%),
    linear-gradient(45deg, #0F1A2C 25%, transparent 25%, transparent 75%, #0F1A2C 75%);
  background-size: 8px 8px;
  background-position: 0 0, 4px 4px;
  background-color: #fff;
  border: 4px solid #fff;
  box-shadow: 0 0 0 1px #0F1A2C;
}

/* QR display (parent payment) */
.qr-display {
  width: 220px;
  height: 220px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  margin: 0 auto;
  position: relative;
}
.qr-grid {
  width: 100%; height: 100%;
  display: grid;
  grid-template-columns: repeat(25, 1fr);
  grid-template-rows: repeat(25, 1fr);
  gap: 0;
}
.qr-cell { background: #0F1A2C; }
.qr-cell.off { background: transparent; }
.qr-corner {
  width: 24%; height: 24%;
  border: 14% solid #0F1A2C;
  position: absolute;
}

/* Barcode */
.barcode {
  display: flex;
  align-items: flex-end;
  height: 60px;
  gap: 0;
  background: #fff;
  padding: 8px 0;
}
.barcode > div {
  background: #0F1A2C;
  height: 100%;
}

/* Stepper */
.stepper {
  display: flex;
  align-items: center;
  gap: 0;
  margin-bottom: 24px;
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}
.step {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}
.step-num {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--bg-soft);
  display: grid; place-items: center;
  font-size: 12px;
  font-weight: 600;
  font-family: var(--latin);
  color: var(--muted);
}
.step.done .step-num { background: var(--emerald); color: #fff; }
.step.active .step-num { background: var(--navy); color: #fff; }
.step.active { color: var(--text); font-weight: 500; }
.step.done { color: var(--text-2); }
.step-line { flex: 1; height: 1px; background: var(--border); margin: 0 14px; }
.step.done + .step-line { background: var(--emerald); }

/* Code block */
.code {
  background: var(--navy-deep);
  color: #C8D2E0;
  padding: 12px 16px;
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-all;
  line-height: 1.6;
}
.code .k { color: #8AB4FF; }
.code .s { color: #B3E394; }
.code .n { color: #F0B97D; }

/* Reconciliation 3-panel */
.recon-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
}
.recon-panel { min-width: 0; }

/* Toggle row */
.method-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  transition: all .15s;
  position: relative;
}
.method-card:hover { border-color: var(--border-strong); }
.method-card.selected { border-color: var(--navy); background: var(--navy-soft); }
.method-card.selected::after {
  content: "✓";
  position: absolute;
  top: 12px; right: 12px;
  width: 18px; height: 18px;
  background: var(--navy);
  color: #fff;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 11px;
}
.brand-logo {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.school-crest, .school-mark {
  background: var(--navy-soft);
  color: var(--navy);
  border-radius: 8px;
  display: grid;
  place-items: center;
  text-align: center;
  font-weight: 700;
  overflow: hidden;
}

.school-crest img, .school-mark img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.method-icon {
  width: 44px; height: 44px;
  border-radius: 8px;
  background: var(--bg-soft);
  display: grid; place-items: center;
  flex-shrink: 0;
  color: var(--navy);
}
.method-card.qr .method-icon { background: var(--navy-soft); color: var(--navy); }
.method-card.cs .method-icon { background: var(--emerald-soft); color: var(--emerald); }
.method-card.bank .method-icon { background: var(--gold-soft); color: var(--gold-2); }
.method-title { font-size: 14px; font-weight: 600; }
.method-desc { font-size: 12px; color: var(--muted); }

/* Misc helpers */
.copy-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 12.5px;
}
.copy-row .copy { color: var(--info); cursor: pointer; font-size: 11.5px; font-family: var(--latin); }

.list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}
.list-row:last-child { border-bottom: none; }
.list-row .avatar-sm {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--navy-soft);
  color: var(--navy);
  display: grid; place-items: center;
  font-size: 11px;
  font-weight: 600;
  font-family: var(--latin);
  flex-shrink: 0;
}

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 12.5px;
  color: var(--muted);
}
.page-btns { display: flex; gap: 4px; }
.page-btn {
  width: 28px; height: 28px;
  display: grid; place-items: center;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  color: var(--text-2);
  font-family: var(--latin);
}
.page-btn:hover { background: var(--bg-soft); }
.page-btn.active { background: var(--navy); color: #fff; }

/* Secret reveal */
.secret-row {
  display: flex;
  align-items: center;
  gap: 0;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0;
  overflow: hidden;
}
.secret-row .secret-val {
  flex: 1;
  padding: 8px 12px;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text);
}
.secret-row .secret-act {
  padding: 8px 12px;
  border-left: 1px solid var(--border);
  background: var(--surface);
  color: var(--info);
  font-size: 12px;
  cursor: pointer;
  font-family: var(--latin);
}
.secret-row .secret-act:hover { background: var(--info-soft); }

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 26, 44, 0.4);
  display: grid;
  place-items: center;
  z-index: 100;
  padding: 20px;
}
.modal {
  background: var(--surface);
  border-radius: 10px;
  max-width: 460px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.modal-body { padding: 24px; }
.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 24px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
}

/* Section header for parent flow */
.parent-amount {
  text-align: center;
  padding: 24px 16px;
}
.parent-amount .label { font-size: 12px; color: var(--muted); font-weight: 400; margin-bottom: 6px; }
.parent-amount .value {
  font-family: var(--latin);
  font-size: 36px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--navy);
}
.parent-amount .value .cur { font-size: 18px; color: var(--muted); margin-right: 6px; }
.parent-amount .sub { font-size: 12px; color: var(--muted); margin-top: 4px; }

.dot-sep {
  display: inline-block;
  width: 3px; height: 3px;
  border-radius: 50%;
  background: var(--muted-2);
  margin: 0 7px;
  vertical-align: middle;
}

/* Status pill (large for parent flow) */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: var(--r-pill);
  font-size: 13px;
  font-weight: 500;
}
.status-pill .dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: currentColor;
}
.status-pill.pending {
  background: var(--info-soft);
  color: var(--info);
}
.status-pill.confirmed {
  background: var(--emerald-soft);
  color: var(--emerald-2);
}
.status-pill .dot.pulse {
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.85); }
}

/* Doc card for downloads */
.doc-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}
.doc-icon {
  width: 36px; height: 44px;
  background: var(--danger-soft);
  border: 1px solid #E8C8C3;
  border-radius: 4px;
  color: var(--danger);
  font-size: 9px;
  font-weight: 700;
  font-family: var(--latin);
  display: grid; place-items: center;
  flex-shrink: 0;
  position: relative;
}
.doc-icon::before {
  content: "";
  position: absolute;
  top: 0; right: 0;
  width: 8px; height: 8px;
  background: var(--surface);
  border-bottom-left-radius: 3px;
}
.doc-title { font-size: 13px; font-weight: 500; }
.doc-meta { font-size: 11.5px; color: var(--muted); font-family: var(--latin); }

/* Audit diff */
.diff {
  display: grid;
  grid-template-columns: 1fr 16px 1fr;
  gap: 8px;
  align-items: center;
  font-family: var(--mono);
  font-size: 12px;
}
.diff .before { background: var(--danger-soft); padding: 4px 8px; border-radius: 4px; }
.diff .after { background: var(--emerald-soft); padding: 4px 8px; border-radius: 4px; }
.diff .arr { color: var(--muted); text-align: center; }

/* Empty state */
.empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--navy);
  color: #fff;
  padding: 10px 16px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  z-index: 9999;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  animation: toastIn 0.3s ease-out;
}
.toast.success { background: var(--emerald); }
.toast.danger { background: var(--danger); }

@keyframes toastIn {
  from { bottom: 0; opacity: 0; }
  to { bottom: 24px; opacity: 1; }
}

/* ===== Print Styles ===== */
@media print {
  /* Hide all UI elements */
  .sidebar, 
  .topbar, 
  .page-head, 
  .kpis, 
  .tabs, 
  .card-head,
  .filters,
  .pagination,
  .btn,
  .avatar,
  .banner,
  .modal-backdrop,
  .sidebar-brand,
  .card:not(.print-container),
  .flex-col:not(.print-container) {
    display: none !important;
  }

  /* Reset layout for print */
  body, html {
    background: #fff !important;
    padding: 0 !important;
    margin: 0 !important;
    height: auto !important;
  }
  
  .app {
    display: block !important;
    min-width: auto !important;
    background: #fff !important;
  }

  .main {
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
  }

  .content {
    padding: 0 !important;
    margin: 0 !important;
    max-width: 100% !important;
    display: block !important;
    background: #fff !important;
  }

  .grid-2 {
    display: block !important;
  }

  /* Target the receipt specifically */
  .receipt {
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 auto !important;
    background: #fff !important;
  }

  /* Force colors and backgrounds for watermarks and badges */
  * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  /* Ensure page breaks if multiple receipts are printed */
  .receipt {
    page-break-after: always;
  }

  /* Hide print container background/borders if any */
  .card.print-container {
    border: none !important;
    box-shadow: none !important;
    background: transparent !important;
    padding: 0 !important;
  }
}
