/* ============================================================
   ECRB — Employment Clearance Reference Bureau
   Design system. Linked by layouts/main.php and layouts/dashboard.php.
   Page-specific rules remain in individual view <style> blocks.

   Principles
   - An official register: flat panels, hairline rules, no shadows
     except floating layers (menus, modals).
   - One typeface (Public Sans). Mono only for reference numbers.
   - Colour carries status. Brass is rationed to the brand mark.
   - Sentence case everywhere; no tracked-out capitals.
   ============================================================ */

:root {
  /* Brand + surfaces (legacy variable names kept so view styles follow) */
  --navy:     #16273E;   /* ink */
  --navy2:    #223A58;
  --gold:     #A8741A;   /* brass */
  --gold2:    #C58E2A;
  --clear:    #17724A;
  --flagged:  #B3261E;
  --pending:  #8A5A00;
  --info:     #1D5FA8;
  --bg:       #F2F4F6;
  --white:    #FFFFFF;
  --text:     #1E2733;
  --muted:    #5B6675;
  --border:   #D9DEE4;
  --input-bg: #FFFFFF;
  --rule-soft:#E8EBEF;

  --sidebar-w: 236px;
  --radius:    6px;
  --radius-sm: 5px;
  --shadow:    0 1px 2px rgba(22,39,62,.06);
  --shadow-lg: 0 10px 30px rgba(22,39,62,.16);

  --font: 'Public Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, Consolas, monospace;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body { font-family: var(--font); font-size: 14px; background: var(--bg); color: var(--text); line-height: 1.55; -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4 { font-family: var(--font); font-weight: 600; letter-spacing: -0.01em; line-height: 1.25; color: var(--navy); }
a { text-decoration: none; color: inherit; }
img { max-width: 100%; }
ul { list-style: none; }
.icon { flex-shrink: 0; vertical-align: -0.2em; }
:focus-visible { outline: 2px solid var(--info); outline-offset: 2px; }
::selection { background: rgba(29,95,168,.2); }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; scroll-behavior: auto !important; } }

/* ── Typography helpers ── */
.text-navy   { color: var(--navy); }
.text-gold   { color: var(--gold); }
.text-muted  { color: var(--muted); }
.text-clear  { color: var(--clear); }
.text-red    { color: var(--flagged); }
.text-sm     { font-size: 13px; }
.text-xs     { font-size: 12px; }
.font-serif  { font-family: var(--font); }
.fw-500      { font-weight: 500; }
.mono, .ref  { font-family: var(--mono); font-size: .92em; letter-spacing: 0; font-variant-numeric: tabular-nums; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 16px; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 500; line-height: 1.3; border: 1px solid transparent;
  cursor: pointer; font-family: var(--font);
  transition: background .12s, border-color .12s, color .12s;
  text-decoration: none; white-space: nowrap;
}
.btn-primary   { background: var(--navy); color: #fff; }
.btn-primary:hover { background: var(--navy2); }
.btn-gold      { background: var(--navy); color: #fff; }           /* retired accent button → primary */
.btn-gold:hover { background: var(--navy2); }
.btn-outline   { background: var(--white); color: var(--navy); border-color: #B9C1CC; }
.btn-outline:hover { border-color: var(--navy); background: #F7F9FB; }
.btn-danger    { background: var(--flagged); color: #fff; }
.btn-danger:hover { background: #9A1F18; }
.btn-sm        { padding: 5px 11px; font-size: 13px; }
.btn-lg        { padding: 12px 22px; font-size: 15px; }
.btn-full      { width: 100%; }
.btn:disabled, .btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ── Status badges: small, square-ish, with a dot ── */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 500; line-height: 1.4;
  padding: 2px 8px; border-radius: 4px; white-space: nowrap;
  background: #EEF0F3; color: var(--muted);
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.badge-clear, .badge-success, .badge-approved, .badge-active { background: #E4F2EA; color: #14633F; }
.badge-pending, .badge-premium { background: #FBF0D9; color: #7A5000; }
.badge-flagged, .badge-failed, .badge-rejected { background: #FBE6E4; color: #9A1F18; }
.badge-inactive { background: #EEF0F3; color: var(--muted); }
.badge-info     { background: #E3EEF9; color: #174F8C; }
.badge-navy     { background: #E4E9F0; color: var(--navy); }

/* ── Flash messages ── */
.flash-wrap { padding: 0 2rem; margin-top: 1rem; }
.flash-wrap-public { max-width: 960px; margin: 1.25rem auto 0; padding: 0 1.5rem; }
.flash { padding: 10px 14px; border-radius: var(--radius-sm); font-size: 14px; display: flex; align-items: flex-start; gap: 10px; margin-bottom: 6px; border: 1px solid; border-left-width: 4px; }
.flash .icon { margin-top: 2px; }
.flash-success { background: #F1F8F4; color: #14543A; border-color: #BFDECC; border-left-color: var(--clear); }
.flash-error   { background: #FDF3F2; color: #8E1D17; border-color: #F0C5C2; border-left-color: var(--flagged); }
.flash-info    { background: #F2F7FC; color: #174F8C; border-color: #C3D9EF; border-left-color: var(--info); }
.flash-warning { background: #FDF8EC; color: #6B4700; border-color: #EBD9A8; border-left-color: #B7791F; }

/* ── Panels (cards) ── */
.card { background: var(--white); border: 1px solid var(--border); border-radius: var(--radius); }
.card-header { padding: .85rem 1.25rem; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card-title  { font-size: 14px; font-weight: 600; color: var(--navy); }
.card-body   { padding: 1.25rem; }
.card-footer { padding: .85rem 1.25rem; border-top: 1px solid var(--border); background: #F8F9FB; border-radius: 0 0 var(--radius) var(--radius); }

/* ── Summary strip (stat cards share one frame, split by hairlines) ── */
.stats-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 1px; background: var(--border);
  border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; margin-bottom: 1.5rem;
}
.stat-card  { background: var(--white); padding: 1rem 1.25rem; border: 0; border-radius: 0; }
.stat-label { font-size: 13px; color: var(--muted); margin-bottom: 4px; text-transform: none; letter-spacing: 0; }
.stat-value { font-family: var(--font); font-size: 1.65rem; font-weight: 600; color: var(--navy); font-variant-numeric: tabular-nums; letter-spacing: -0.02em; line-height: 1.2; }
.stat-sub   { font-size: 12px; color: var(--muted); margin-top: 2px; }
.stat-trend-up   { color: var(--clear); font-size: 12px; }
.stat-trend-down { color: var(--flagged); font-size: 12px; }

/* ── Tables ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th { padding: 9px 14px; text-align: left; font-size: 12.5px; text-transform: none; letter-spacing: 0; color: var(--muted); font-weight: 600; background: #F8F9FB; border-bottom: 1px solid var(--border); white-space: nowrap; }
tbody td { padding: 11px 14px; border-bottom: 1px solid var(--rule-soft); color: var(--text); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #F8FAFC; }

/* ── Forms ── */
.field { margin-bottom: 1.1rem; }
.field label { display: block; font-size: 13.5px; font-weight: 500; color: var(--text); margin-bottom: 5px; }
.field label .req { color: var(--flagged); margin-left: 2px; }
.field input, .field select, .field textarea {
  width: 100%; background: var(--input-bg);
  border: 1px solid #B9C1CC; border-radius: var(--radius-sm);
  padding: 9px 12px; font-size: 14px; color: var(--text);
  font-family: var(--font); transition: border-color .12s, box-shadow .12s; outline: none;
}
.field input::placeholder, .field textarea::placeholder { color: #8A94A3; }
.field input:hover, .field select:hover, .field textarea:hover { border-color: #8E99A8; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--info); box-shadow: 0 0 0 3px rgba(29,95,168,.16); }
.field-error input, .field-error select, .field input.is-error, .field select.is-error { border-color: var(--flagged) !important; }
.field .error-msg { font-size: 13px; color: var(--flagged); margin-top: 4px; }
.field-hint { font-size: 13px; color: var(--muted); margin-top: 4px; }
.form-divider { border: none; border-top: 1px solid var(--border); margin: 1.25rem 0; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 560px) { .form-row { grid-template-columns: 1fr; } }

/* ── Key / value rows ── */
.info-row { display: flex; justify-content: space-between; padding: 9px 0; border-bottom: 1px solid var(--rule-soft); font-size: 14px; gap: 16px; }
.info-row:last-child { border-bottom: none; }
.info-label { color: var(--muted); flex-shrink: 0; }
.info-value { font-weight: 500; color: var(--text); text-align: right; }

.doc-row { display: flex; align-items: center; justify-content: space-between; padding: 11px 1.25rem; border-bottom: 1px solid var(--rule-soft); font-size: 14px; gap: 12px; }
.doc-row:last-child { border-bottom: none; }

/* ── Empty states ── */
.empty-state { text-align: center; padding: 2.5rem 1rem; color: var(--muted); }
.empty-state-icon { font-size: 0; margin-bottom: .6rem; color: #98A2B0; }
.empty-state-icon .icon { width: 32px; height: 32px; }
.empty-state-text { font-size: 14px; }

/* ── Inline alerts ── */
.alert { padding: 10px 14px; border-radius: var(--radius-sm); font-size: 14px; display: flex; align-items: flex-start; gap: 10px; margin-bottom: 1rem; border: 1px solid; border-left-width: 4px; }
.alert-success { background: #F1F8F4; color: #14543A; border-color: #BFDECC; border-left-color: var(--clear); }
.alert-error   { background: #FDF3F2; color: #8E1D17; border-color: #F0C5C2; border-left-color: var(--flagged); }
.alert-info    { background: #F2F7FC; color: #174F8C; border-color: #C3D9EF; border-left-color: var(--info); }
.alert-warning { background: #FDF8EC; color: #6B4700; border-color: #EBD9A8; border-left-color: #B7791F; }

/* ── Spinner ── */
.spinner { width: 24px; height: 24px; border: 3px solid var(--border); border-top-color: var(--navy); border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Upload zones ── */
.upload-zone { border: 1.5px dashed #9FAAB8; border-radius: var(--radius); padding: 1.5rem; text-align: center; cursor: pointer; transition: border-color .12s, background .12s; background: #FAFBFC; position: relative; }
.upload-zone:hover, .upload-zone.dragover { border-color: var(--navy); background: #F3F6F9; }
.upload-zone input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.upload-zone-icon  { font-size: 1.6rem; margin-bottom: .4rem; color: var(--muted); }
.upload-zone-title { font-size: 14px; font-weight: 500; color: var(--navy); margin-bottom: 2px; }
.upload-zone-sub   { font-size: 13px; color: var(--muted); }
.upload-zone.has-file { border-style: solid; border-color: var(--clear); background: #F4FAF6; }
.upload-zone.has-file .upload-zone-icon { color: var(--clear); }

/* ── Pagination ── */
.pagination { display: flex; align-items: center; gap: 4px; justify-content: center; padding: 1rem 0; }
.page-btn { padding: 5px 11px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--white); font-size: 13px; color: var(--navy); cursor: pointer; }
.page-btn:hover  { border-color: var(--navy); }
.page-btn.active { background: var(--navy); color: #fff; border-color: var(--navy); }
.page-btn:disabled { opacity: .4; cursor: not-allowed; }

/* ── Progress ── */
.progress-wrap { background: #E3E7EC; border-radius: 3px; height: 6px; overflow: hidden; }
.progress-bar  { height: 6px; border-radius: 3px; background: var(--navy); transition: width .3s; }
.progress-bar.is-clear { background: var(--clear); }

/* ── Tooltips ── */
[data-tip] { position: relative; cursor: help; }
[data-tip]::after { content: attr(data-tip); position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%); background: var(--navy); color: #fff; font-size: 12px; padding: 4px 9px; border-radius: 4px; white-space: nowrap; pointer-events: none; opacity: 0; transition: opacity .12s; }
[data-tip]:hover::after { opacity: 1; }

/* ── Back link / page header ── */
.back-link { font-size: 13.5px; color: var(--muted); margin-bottom: 1rem; display: inline-flex; align-items: center; gap: 6px; }
.back-link:hover { color: var(--navy); text-decoration: underline; }
.page-body { padding: 1.75rem 2rem 2.5rem; flex: 1; max-width: 1280px; width: 100%; }
.page-header { margin-bottom: 1.5rem; }
.page-header h1 { font-size: 1.4rem; color: var(--navy); }
.page-header p  { font-size: 14px; color: var(--muted); margin-top: 3px; font-weight: 400; max-width: 68ch; }

.section-label { font-size: 13px; letter-spacing: 0; text-transform: none; color: var(--muted); font-weight: 600; margin-bottom: .75rem; }

/* ── Plan cards (payments / update tiers) ── */
.plan-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-bottom: 1.5rem; }
.plan-card { border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; background: var(--white); position: relative; transition: border-color .12s; cursor: pointer; }
.plan-card:hover { border-color: var(--navy); }
.plan-card.featured { border-color: var(--navy); box-shadow: inset 0 0 0 1px var(--navy); }
.plan-card.featured::before { content: 'Most chosen'; position: absolute; top: 10px; right: 10px; background: #E4E9F0; color: var(--navy); font-size: 12px; font-weight: 500; padding: 1px 8px; border-radius: 4px; }
.plan-name  { font-size: 14px; font-weight: 600; color: var(--navy); margin-bottom: 2px; text-transform: none; letter-spacing: 0; }
.plan-price { font-size: 1.6rem; color: var(--navy); font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.plan-price span { font-size: 13px; font-weight: 400; color: var(--muted); }
.plan-desc  { font-size: 13px; color: var(--muted); margin-top: 6px; line-height: 1.5; }
.plan-features { margin-top: 10px; list-style: none; }
.plan-features li { font-size: 13px; color: var(--text); padding: 3px 0; display: flex; align-items: center; gap: 8px; }
.plan-features li::before { content: ''; width: 10px; height: 6px; border-left: 2px solid var(--clear); border-bottom: 2px solid var(--clear); transform: rotate(-45deg) translateY(-2px); flex-shrink: 0; }

/* ============================================================
   PUBLIC LAYOUT — header, footer
   ============================================================ */
.navbar {
  background: var(--white); border-bottom: 1px solid var(--border);
  padding: 0 2rem; display: flex; align-items: center; justify-content: space-between;
  height: 60px; position: sticky; top: 0; z-index: 100;
}
.navbar-brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { display: block; flex-shrink: 0; }
.brand-icon { display: none; }
.brand-logo { display: block; object-fit: contain; flex-shrink: 0; }
.sidebar .brand-logo { background: #fff; border-radius: 6px; padding: 3px 6px; }
.brand-name { font-size: 16px; font-weight: 700; color: var(--navy); letter-spacing: .02em; line-height: 1.1; }
.brand-sub  { font-size: 12px; color: var(--muted); letter-spacing: 0; text-transform: none; display: block; line-height: 1.2; margin-top: 1px; }
.navbar-links { display: flex; align-items: center; gap: 6px; }
.navbar-links a { color: var(--text); font-size: 14px; font-weight: 500; padding: 7px 12px; border-radius: var(--radius-sm); transition: background .12s; }
.navbar-links a:hover { background: #EEF1F4; }
.btn-nav-login    { border: 1px solid #B9C1CC !important; color: var(--navy) !important; }
.btn-nav-register { background: var(--navy) !important; color: #fff !important; }
.btn-nav-register:hover { background: var(--navy2) !important; }

.footer { background: var(--white); border-top: 1px solid var(--border); color: var(--muted); text-align: center; padding: 1.25rem; font-size: 13px; margin-top: 3rem; }
.footer span { color: var(--navy); font-weight: 600; }
.footer a { color: var(--muted); text-decoration: underline; }
.footer a:hover { color: var(--navy); }

/* ============================================================
   DASHBOARD LAYOUT — sidebar, topbar, notifications
   ============================================================ */
body.dashboard-body { display: flex; min-height: 100vh; }

.sidebar { width: var(--sidebar-w); background: var(--navy); min-height: 100vh; display: flex; flex-direction: column; position: fixed; top: 0; left: 0; bottom: 0; z-index: 50; transition: transform .2s; }
.sidebar-brand { padding: 1rem 1.1rem; border-bottom: 1px solid rgba(255,255,255,.1); display: flex; align-items: center; gap: 10px; height: 60px; }
.brand-text { font-size: 15px; color: #fff; font-weight: 700; letter-spacing: .02em; line-height: 1.1; }
.sidebar .brand-sub { color: rgba(255,255,255,.6); font-size: 12px; }

.sidebar-nav { flex: 1; padding: .6rem .6rem; overflow-y: auto; }
.nav-section-label { font-size: 12px; letter-spacing: 0; text-transform: none; color: rgba(255,255,255,.5); font-weight: 500; padding: .9rem .6rem .3rem; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 7px .6rem; margin-bottom: 1px; border-radius: var(--radius-sm); font-size: 14px; color: rgba(255,255,255,.78); transition: background .12s, color .12s; cursor: pointer; }
.nav-item:hover  { color: #fff; background: rgba(255,255,255,.07); }
.nav-item.active { color: #fff; background: rgba(255,255,255,.13); font-weight: 500; }
.nav-icon  { width: 18px; height: 18px; display: inline-flex; align-items: center; justify-content: center; font-size: 14px; flex-shrink: 0; opacity: .9; }
.nav-icon .icon { display: block; }
.nav-badge { margin-left: auto; background: #fff; color: var(--navy); font-size: 12px; font-weight: 600; padding: 0 7px; border-radius: 10px; line-height: 1.5; font-variant-numeric: tabular-nums; }
.nav-sub   { font-size: 13px; color: rgba(255,255,255,.6); padding: 3px .6rem 3px 2.4rem; display: block; }
.nav-sub:hover { color: #fff; }

.sidebar-bottom { padding: .6rem; border-top: 1px solid rgba(255,255,255,.1); }
.btn-logout { display: flex; align-items: center; gap: 10px; font-size: 14px; color: rgba(255,255,255,.78); padding: 7px .6rem; border-radius: var(--radius-sm); background: none; border: none; cursor: pointer; font-family: var(--font); width: 100%; }
.btn-logout:hover { color: #fff; background: rgba(255,255,255,.07); }

.main { margin-left: var(--sidebar-w); flex: 1; display: flex; flex-direction: column; min-height: 100vh; min-width: 0; }

.topbar { background: var(--white); border-bottom: 1px solid var(--border); padding: 0 2rem; height: 60px; display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 40; }
.topbar-left { display: flex; align-items: center; gap: 12px; }
.topbar-title { font-size: 15px; font-weight: 600; color: var(--navy); }
.topbar-right { display: flex; align-items: center; gap: 12px; position: relative; }
.topbar-user { display: flex; align-items: center; gap: 10px; }
.topbar-avatar { width: 30px; height: 30px; border-radius: 50%; background: #E4E9F0; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; color: var(--navy); flex-shrink: 0; }
.topbar-user-name { font-size: 13.5px; font-weight: 500; color: var(--text); line-height: 1.2; }
.topbar-user-role { font-size: 12px; color: var(--muted); text-transform: capitalize; }
.topbar-divider   { width: 1px; height: 26px; background: var(--border); }

.notif-bell { position: relative; width: 34px; height: 34px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--white); display: flex; align-items: center; justify-content: center; color: var(--navy); cursor: pointer; transition: background .12s; flex-shrink: 0; }
.notif-bell:hover { background: #F3F5F7; }
.notif-dot { position: absolute; top: -6px; right: -6px; min-width: 17px; height: 17px; background: var(--flagged); border-radius: 9px; border: 2px solid #fff; font-size: 10px; font-weight: 700; color: #fff; display: none; align-items: center; justify-content: center; padding: 0 3px; }
.notif-dot.visible { display: flex; }

.notif-dropdown { position: absolute; top: 44px; right: 0; width: 340px; background: var(--white); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); z-index: 200; display: none; overflow: hidden; }
.notif-dropdown.open { display: block; }
.notif-dropdown-header { padding: .7rem 1rem; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.notif-dropdown-title { font-size: 14px; font-weight: 600; color: var(--navy); }
.notif-mark-read { font-size: 13px; color: var(--info); cursor: pointer; background: none; border: none; font-family: var(--font); }
.notif-mark-read:hover { text-decoration: underline; }
.notif-list { max-height: 340px; overflow-y: auto; }
.notif-item { padding: .7rem 1rem; border-bottom: 1px solid var(--rule-soft); cursor: pointer; }
.notif-item:last-child { border-bottom: none; }
.notif-item:hover  { background: #F8FAFC; }
.notif-item.unread { background: #F2F7FC; box-shadow: inset 3px 0 0 var(--info); }
.notif-item-title { font-size: 14px; font-weight: 500; color: var(--text); margin-bottom: 1px; }
.notif-item-msg   { font-size: 13px; color: var(--muted); line-height: 1.4; }
.notif-item-time  { font-size: 12px; color: var(--muted); margin-top: 3px; }
.notif-empty  { padding: 2rem; text-align: center; color: var(--muted); font-size: 14px; }
.notif-footer { padding: .65rem; border-top: 1px solid var(--border); text-align: center; background: #F8F9FB; }
.notif-footer a { font-size: 13.5px; color: var(--info); font-weight: 500; }
.notif-footer a:hover { text-decoration: underline; }

.sidebar-toggle { display: none; background: none; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 5px 8px; cursor: pointer; color: var(--navy); align-items: center; }

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .main { margin-left: 0; }
  .sidebar-toggle { display: flex; }
  .topbar { padding: 0 1rem; }
  .flash-wrap { padding: 0 1rem; }
  .page-body { padding: 1.25rem 1rem 2rem; }
  .topbar-user-name, .topbar-user-role, .topbar-divider { display: none; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .plan-grid { grid-template-columns: 1fr; }
  .notif-dropdown { position: fixed; top: 64px; left: 12px; right: 12px; width: auto; }
}
@media (max-width: 480px) { .stats-grid { grid-template-columns: 1fr; } .navbar { padding: 0 1rem; } }

/* ── Payment / checkout ── */
.checkout-card { max-width: 480px; margin: 2.5rem auto; background: var(--white); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.checkout-header { background: #F8F9FB; border-bottom: 1px solid var(--border); padding: 1.25rem 1.75rem; text-align: left; }
.checkout-header h2 { color: var(--navy); font-size: 1.15rem; }
.checkout-header p  { color: var(--muted); font-size: 14px; margin-top: 3px; }
.checkout-body { padding: 1.75rem; }
.checkout-amount { text-align: left; margin-bottom: 1.25rem; font-size: 2.1rem; font-weight: 600; color: var(--navy); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.checkout-amount small { font-size: 1rem; color: var(--muted); font-weight: 400; }
.checkout-status-icon { font-size: 0; text-align: center; margin-bottom: .75rem; }
.checkout-status-icon .icon { width: 44px; height: 44px; }
.checkout-msg { text-align: center; font-size: 15px; color: var(--navy); margin-bottom: 1.25rem; }

/* ── ID card upload ── */
.id-upload-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 1rem; }
@media (max-width: 480px) { .id-upload-grid { grid-template-columns: 1fr; } }
.id-upload-side { font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 5px; text-transform: none; letter-spacing: 0; }
.id-preview-wrap { position: relative; border-radius: var(--radius-sm); overflow: hidden; border: 1px solid var(--border); }
.id-preview-wrap img { width: 100%; display: block; }
.id-preview-remove { position: absolute; top: 6px; right: 6px; background: rgba(22,39,62,.8); color: #fff; border: none; border-radius: 50%; width: 26px; height: 26px; font-size: 13px; cursor: pointer; display: flex; align-items: center; justify-content: center; }

/* Top bar search (admin) */
.topbar-search { display: flex; align-items: center; gap: 8px; flex: 1; max-width: 420px; margin: 0 1.25rem; padding: 0 10px; height: 36px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: #F8F9FB; color: var(--muted); }
.topbar-search:focus-within { background: #fff; border-color: var(--info); box-shadow: 0 0 0 3px rgba(29,95,168,.16); }
.topbar-search input { border: 0; background: transparent; outline: none; font: inherit; font-size: 14px; width: 100%; color: var(--text); }
.topbar-search-link { display: none; color: var(--navy); }

/* ============================================================
   RESPONSIVE LAYER
   Phones first-class: stacked tables, single-column forms,
   full-width modals, bottom navigation, 44px tap targets.
   Attribute selectors catch the inline grids used by older views.
   ============================================================ */
img, video, svg { max-width: 100%; }
.card, .info-value, td { overflow-wrap: anywhere; }
pre, code { overflow-x: auto; }

.drawer-backdrop { display: none; position: fixed; inset: 0; background: rgba(22,39,62,.45); z-index: 45; }
body.drawer-open { overflow: hidden; }

/* Bottom navigation (phones, signed-in layouts only) */
.bottom-nav { display: none; }

@media (max-width: 900px) {
  /* Two-column page layouts fall to one column */
  [style*="grid-template-columns:1fr 340px"], [style*="grid-template-columns: 1fr 340px"],
  [style*="grid-template-columns:1fr 320px"], [style*="grid-template-columns: 1fr 320px"],
  [style*="grid-template-columns:1fr 300px"], [style*="grid-template-columns:220px 1fr"],
  [style*="grid-template-columns:1.5fr 1fr"], [style*="grid-template-columns:1.2fr 1fr"] { grid-template-columns: 1fr !important; }
}

@media (max-width: 768px) {
  .topbar-search { display: none; }
  .topbar-search-link { display: flex; margin-left: auto; margin-right: 4px; }
  body.dashboard-body { padding-bottom: 64px; }
  .topbar-title { max-width: 46vw; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .page-header h1 { font-size: 1.25rem; }

  /* Forms: no iOS zoom on focus, comfortable targets */
  input, select, textarea, .field input, .field select, .field textarea { font-size: 16px !important; }
  .btn, .page-btn { min-height: 40px; }
  .btn-sm { min-height: 36px; }
  .nav-item, .btn-logout { min-height: 44px; }
  .form-row, [style*="grid-template-columns:1fr 1fr"], [style*="grid-template-columns: 1fr 1fr"],
  [style*="grid-template-columns:1fr 1fr 1fr"], [style*="grid-template-columns: 1fr 1fr 1fr"],
  [style*="grid-template-columns:repeat(3,1fr)"] { grid-template-columns: 1fr !important; }
  [style*="grid-template-columns:repeat(4,1fr)"], [style*="grid-template-columns: repeat(4, 1fr)"],
  [style*="grid-template-columns:repeat(2,1fr)"] { grid-template-columns: 1fr 1fr !important; }

  /* Header rows with actions wrap instead of overflowing */
  [style*="justify-content:space-between"], .card-header, .page-header-inner, .section-header { flex-wrap: wrap; gap: 8px; }
  .card-body { padding: 1rem; }

  /* Tables become stacked records */
  table.stack-table, table.stack-table tbody, table.stack-table tr, table.stack-table td { display: block; width: 100%; }
  table.stack-table thead { position: absolute; left: -9999px; }
  table.stack-table tbody tr { border-bottom: 1px solid var(--border); padding: .6rem 1rem; }
  table.stack-table tbody tr:last-child { border-bottom: none; }
  table.stack-table tbody tr:hover { background: transparent; }
  table.stack-table tbody td { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; padding: 5px 0; border: none; text-align: right; }
  table.stack-table tbody td::before { content: attr(data-label); flex: 0 0 38%; max-width: 38%; text-align: left; font-size: 13px; font-weight: 600; color: var(--muted); }
  table.stack-table tbody td:not([data-label])::before { content: none; }
  table.stack-table tbody td.mono::before, table.stack-table tbody td.ref::before { font-family: var(--font); }
  table.stack-table tbody td.cell-empty { display: none; }
  table.stack-table tbody td > * { max-width: 100%; }
  .table-wrap { overflow-x: visible; }

  /* Modals fit the screen */
  .modal-box { width: calc(100vw - 24px) !important; max-width: none !important; max-height: 88vh; overflow-y: auto; margin: 12px; }

  /* Bottom navigation */
  .bottom-nav { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 44; background: #fff; border-top: 1px solid var(--border); padding-bottom: env(safe-area-inset-bottom); }
  .bottom-nav a, .bottom-nav button { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 56px; font-size: 11.5px; font-weight: 500; color: var(--muted); background: none; border: none; font-family: var(--font); cursor: pointer; position: relative; }
  .bottom-nav a.active { color: var(--navy); }
  .bottom-nav a.active::before { content: ''; position: absolute; top: 0; left: 25%; right: 25%; height: 2px; background: var(--navy); }
  .bottom-nav .bn-badge { position: absolute; top: 6px; left: calc(50% + 6px); min-width: 16px; height: 16px; border-radius: 8px; background: var(--flagged); color: #fff; font-size: 10px; display: flex; align-items: center; justify-content: center; padding: 0 3px; }
}

@media (max-width: 480px) {
  .btn-lg { padding: 11px 18px; }
  .checkout-card { margin: 1rem 12px; }
  .checkout-body, .checkout-header { padding: 1.25rem; }
  .plan-grid { grid-template-columns: 1fr; }
  .flash, .alert { font-size: 14px; }
  .info-row { flex-direction: column; gap: 2px; }
  .info-value { text-align: left; }
}

/* ── Print: reports and records print as clean documents ── */
.print-head { display: none; }
.print-only { display: none; }
@media print {
  body { background: #fff; font-size: 12px; }
  .sidebar, .topbar, .bottom-nav, .no-print, .flash-wrap, .drawer-backdrop, .notif-dropdown { display: none !important; }
  .main { margin-left: 0 !important; }
  .page-body { padding: 0 !important; max-width: none; }
  .print-head { display: flex; justify-content: space-between; align-items: flex-end; border-bottom: 2px solid var(--navy); padding-bottom: 10px; margin-bottom: 14px; }
  .print-only { display: block; }
  .card, .report-section { break-inside: avoid; box-shadow: none !important; }
  a { color: inherit !important; text-decoration: none !important; }
}
