/* =========================================================
   RisitiPro — styles.css
   Navy #0F2557 + Gold #F4B942 · mobile-first · print-perfect A4
   ========================================================= */

:root {
  --navy: #0F2557;
  --navy-dark: #0A1A3E;
  --navy-light: #1E3A7B;
  --gold: #F4B942;
  --gold-dark: #D99E1E;
  --bg: #F4F6FA;
  --card: #FFFFFF;
  --text: #1A2233;
  --muted: #6B7488;
  --border: #E2E7F0;
  --danger: #C0392B;
  --danger-bg: #FBEAE8;
  --success: #1E8449;
  --success-bg: #E8F6EE;
  --warn: #B9770E;
  --warn-bg: #FCF3DE;
  --info-bg: #EAF0FB;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(15, 37, 87, 0.08), 0 4px 14px rgba(15, 37, 87, 0.06);
  --header-h: 56px;
  --nav-h: 62px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.45;
}

[hidden] { display: none !important; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.tiny { font-size: 0.78rem; }
.center { text-align: center; }

/* ============ HEADER ============ */
.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--navy);
  color: #fff;
  box-shadow: 0 2px 8px rgba(10, 26, 62, 0.35);
}
.header-inner {
  max-width: 860px;
  margin: 0 auto;
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
}
.brand { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.brand-mark { width: 32px; height: 32px; }
.brand-name { font-weight: 800; font-size: 1.15rem; letter-spacing: 0.2px; }
.brand-accent { color: var(--gold); }
.header-actions { display: flex; align-items: center; gap: 8px; }
.icon-btn {
  background: rgba(255, 255, 255, 0.12);
  border: none;
  color: #fff;
  min-width: 42px;
  min-height: 42px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 700;
}
.icon-btn:active { background: rgba(255, 255, 255, 0.25); }
.lang-btn { letter-spacing: 1px; }
.premium-badge {
  background: var(--gold);
  color: var(--navy);
  font-size: 0.72rem;
  font-weight: 800;
  padding: 4px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

/* ============ MAIN LAYOUT ============ */
.app-main {
  max-width: 860px;
  margin: 0 auto;
  padding: 16px 14px calc(var(--nav-h) + 28px);
  min-height: calc(100vh - var(--header-h));
}
.view-title { margin: 0 0 6px; font-size: 1.35rem; color: var(--navy); }
.view-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.view-head .view-title { margin: 0; }
.greeting { margin: 0 0 14px; }
.section-title { font-size: 1rem; color: var(--navy); margin: 18px 0 8px; }

/* ============ BUTTONS ============ */
.btn {
  font: inherit;
  font-weight: 700;
  border: none;
  border-radius: var(--radius);
  padding: 12px 18px;
  min-height: 46px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: filter 0.15s, transform 0.05s;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--navy); color: #fff; }
.btn-primary:hover { filter: brightness(1.15); }
.btn-gold { background: var(--gold); color: var(--navy); }
.btn-gold:hover { filter: brightness(1.05); }
.btn-outline { background: #fff; color: var(--navy); border: 2px solid var(--navy); }
.btn-ghost { background: transparent; color: var(--navy); }
.btn-ghost:hover { background: var(--info-bg); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger-outline { background: #fff; color: var(--danger); border: 2px solid var(--danger); }
.btn-block { display: flex; width: 100%; }
.btn-lg { font-size: 1.05rem; min-height: 54px; }
.btn-sm { padding: 8px 14px; min-height: 40px; font-size: 0.9rem; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-row .btn { flex: 1; min-width: 130px; }

/* ============ STAT CARDS ============ */
.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}
.stat-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  border-top: 4px solid var(--navy);
}
.stat-card:first-child { grid-column: 1 / -1; border-top-color: var(--gold); }
.stat-danger { border-top-color: var(--danger); }
.stat-danger .stat-value { color: var(--danger); }
.stat-success { border-top-color: var(--success); }
.stat-success .stat-value { color: var(--success); }
.stat-label { font-size: 0.8rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px; }
.stat-value { font-size: 1.35rem; font-weight: 800; color: var(--navy); }

.free-counter {
  margin: 10px 0 4px;
  text-align: center;
  font-size: 0.85rem;
  color: var(--muted);
}
.free-counter .up-link { color: var(--gold-dark); font-weight: 700; cursor: pointer; text-decoration: underline; }

/* ============ CARD LISTS ============ */
.card-list { display: flex; flex-direction: column; gap: 10px; }
.list-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 13px 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid transparent;
}
.list-card:hover { border-color: var(--border); }
.list-card .lc-main { flex: 1; min-width: 0; }
.lc-title { font-weight: 700; color: var(--navy); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lc-sub { font-size: 0.82rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lc-right { text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.lc-amount { font-weight: 800; color: var(--navy); font-size: 0.95rem; white-space: nowrap; }
.avatar {
  width: 42px; height: 42px;
  border-radius: 50%;
  background: var(--info-bg);
  color: var(--navy);
  font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.empty-state {
  text-align: center;
  color: var(--muted);
  padding: 34px 16px;
  background: var(--card);
  border-radius: var(--radius);
  border: 2px dashed var(--border);
}

/* ============ STATUS BADGES ============ */
.badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 800;
  padding: 3px 9px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  white-space: nowrap;
}
.badge-draft { background: #EDEFF3; color: #5A6270; }
.badge-sent { background: var(--info-bg); color: var(--navy-light); }
.badge-paid { background: var(--success-bg); color: var(--success); }
.badge-overdue { background: var(--danger-bg); color: var(--danger); }
.badge-partial { background: var(--warn-bg); color: var(--warn); }

/* ============ FILTER CHIPS ============ */
.filter-row { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 8px; margin-bottom: 8px; -webkit-overflow-scrolling: touch; }
.chip {
  font: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  border: 1.5px solid var(--border);
  background: #fff;
  color: var(--muted);
  border-radius: 999px;
  padding: 7px 15px;
  min-height: 38px;
  cursor: pointer;
  white-space: nowrap;
}
.chip-active { background: var(--navy); border-color: var(--navy); color: #fff; }

/* ============ FORMS ============ */
.field-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 14px;
  margin-bottom: 14px;
}
label { display: block; font-size: 0.85rem; font-weight: 700; color: var(--navy); margin-bottom: 12px; }
input, select, textarea {
  font: inherit;
  width: 100%;
  margin-top: 5px;
  padding: 11px 12px;
  min-height: 46px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
}
textarea { min-height: 0; resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--navy);
  box-shadow: 0 0 0 3px rgba(15, 37, 87, 0.12);
}
input[readonly] { background: var(--bg); color: var(--muted); }
input[type="file"] { padding: 9px; min-height: 0; }
input[type="checkbox"] {
  width: 22px; height: 22px; min-height: 0;
  margin: 0; accent-color: var(--navy); flex-shrink: 0;
}
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.check-row { display: flex; align-items: center; gap: 10px; font-size: 0.95rem; }
.search-input { margin-bottom: 12px; }
.pay-group { border-top: 1px solid var(--border); padding-top: 12px; margin-top: 12px; }
.pay-group:first-of-type { border-top: none; padding-top: 0; margin-top: 4px; }
.pay-group strong { display: block; margin-bottom: 8px; color: var(--navy); font-size: 0.9rem; }
.logo-preview img { max-height: 64px; max-width: 160px; border-radius: 8px; border: 1px solid var(--border); padding: 4px; background: #fff; }

/* ============ INVOICE EDITOR ITEMS ============ */
.item-row {
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  margin-bottom: 10px;
  position: relative;
}
.item-row .item-desc { margin-top: 0; }
.item-grid { display: grid; grid-template-columns: 1fr 1.4fr; gap: 8px; margin-top: 8px; align-items: end; }
.item-line-total { font-weight: 800; color: var(--navy); font-size: 0.92rem; text-align: right; padding-bottom: 12px; }
.item-remove {
  position: absolute;
  top: 6px; right: 6px;
  background: var(--danger-bg);
  color: var(--danger);
  border: none;
  width: 34px; height: 34px;
  border-radius: 8px;
  font-size: 1.05rem;
  font-weight: 800;
  cursor: pointer;
  line-height: 1;
}
.item-row .field-mini { font-size: 0.72rem; margin-bottom: 0; }
.totals-preview {
  background: var(--navy);
  color: #fff;
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 14px;
}
.totals-preview .tp-row { display: flex; justify-content: space-between; font-size: 0.9rem; padding: 3px 0; }
.totals-preview .tp-total { font-size: 1.15rem; font-weight: 800; border-top: 1px solid rgba(255,255,255,0.25); margin-top: 6px; padding-top: 8px; color: var(--gold); }

/* ============ DETAIL VIEWS ============ */
.detail-summary {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 14px;
  margin-bottom: 14px;
}
.detail-summary .ds-amount { font-size: 1.6rem; font-weight: 800; color: var(--navy); }
.detail-rows { margin-top: 10px; }
.detail-row { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; border-bottom: 1px dashed var(--border); font-size: 0.92rem; }
.detail-row:last-child { border-bottom: none; }
.detail-row .dr-label { color: var(--muted); }
.detail-row .dr-value { font-weight: 700; text-align: right; }
.action-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.action-grid .btn-span { grid-column: 1 / -1; }
.pay-list-item {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  background: var(--success-bg);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 8px;
  font-size: 0.9rem;
}
.pay-list-item .btn { min-height: 38px; padding: 6px 12px; font-size: 0.82rem; }
.mini-stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0; }
.mini-stat { background: var(--bg); border-radius: 10px; padding: 10px 8px; text-align: center; }
.mini-stat .ms-label { display: block; font-size: 0.68rem; color: var(--muted); text-transform: uppercase; font-weight: 700; letter-spacing: 0.3px; }
.mini-stat .ms-value { display: block; font-weight: 800; font-size: 0.88rem; color: var(--navy); margin-top: 3px; }
.ms-danger .ms-value { color: var(--danger); }
.ms-success .ms-value { color: var(--success); }

/* ============ REPORTS ============ */
.report-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 14px;
  margin-bottom: 14px;
}
.report-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.report-table th { text-align: left; color: var(--muted); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.4px; padding: 6px 4px; border-bottom: 2px solid var(--border); }
.report-table td { padding: 8px 4px; border-bottom: 1px solid var(--border); }
.report-table td.num, .report-table th.num { text-align: right; white-space: nowrap; }
.chart-wrap { overflow-x: auto; }
.chart-legend { display: flex; gap: 16px; font-size: 0.8rem; color: var(--muted); margin-top: 6px; }
.chart-legend .lg { display: flex; align-items: center; gap: 5px; }
.chart-legend .sw { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.premium-lock { position: relative; }
.premium-lock .lock-content { filter: blur(5px); pointer-events: none; user-select: none; }
.premium-lock .lock-overlay {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  text-align: center; padding: 16px;
  background: rgba(255, 255, 255, 0.55);
  border-radius: var(--radius);
}
.lock-overlay .lock-icon { font-size: 1.8rem; }

/* ============ UPGRADE ============ */
.up-hero {
  background: linear-gradient(145deg, var(--navy) 0%, var(--navy-light) 100%);
  color: #fff;
  border-radius: var(--radius);
  padding: 22px 18px;
  text-align: center;
  margin-bottom: 14px;
}
.up-hero .up-price { font-size: 2rem; font-weight: 800; color: var(--gold); margin: 6px 0 2px; }
.up-benefits { list-style: none; margin: 0 0 4px; padding: 0; }
.up-benefits li { padding: 9px 0 9px 30px; border-bottom: 1px dashed var(--border); position: relative; font-size: 0.94rem; }
.up-benefits li:last-child { border-bottom: none; }
.up-benefits li::before { content: "✓"; position: absolute; left: 4px; color: var(--success); font-weight: 800; }
.up-paybox {
  background: var(--warn-bg);
  border: 2px solid var(--gold);
  border-radius: var(--radius);
  padding: 14px;
  margin: 14px 0;
  font-size: 0.94rem;
}
.up-paybox .lipa-number { font-size: 1.5rem; font-weight: 800; color: var(--navy); letter-spacing: 1px; }
.code-row { display: flex; gap: 8px; margin-top: 6px; }
.code-row input { text-transform: uppercase; letter-spacing: 2px; font-weight: 700; margin-top: 0; }

/* ============ WIZARD ============ */
.wizard-card {
  background: var(--card);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 26px 20px;
  max-width: 460px;
  margin: 10px auto;
  text-align: center;
}
.wizard-logo { width: 72px; height: 72px; margin-bottom: 8px; }
.wizard-card h1 { margin: 0 0 6px; color: var(--navy); font-size: 1.45rem; }
.wizard-card form { text-align: left; margin-top: 18px; }
.wizard-card .btn-block { margin-top: 6px; }

/* ============ BOTTOM NAV ============ */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 50;
  background: #fff;
  border-top: 1px solid var(--border);
  display: flex;
  height: var(--nav-h);
  padding-bottom: env(safe-area-inset-bottom, 0);
  box-shadow: 0 -2px 10px rgba(15, 37, 87, 0.06);
}
.nav-btn {
  flex: 1;
  background: none;
  border: none;
  color: var(--muted);
  font: inherit;
  font-size: 0.68rem;
  font-weight: 700;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  cursor: pointer;
  min-height: 100%;
}
.nav-btn.nav-active { color: var(--navy); }
.nav-btn.nav-active svg { stroke: var(--gold-dark); }

/* ============ MODAL ============ */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(10, 26, 62, 0.55);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}
.modal-card {
  background: #fff;
  border-radius: 18px 18px 0 0;
  width: 100%;
  max-width: 560px;
  max-height: 88vh;
  overflow-y: auto;
  padding: 20px 16px calc(20px + env(safe-area-inset-bottom, 0));
  animation: slideUp 0.22s ease-out;
}
@keyframes slideUp { from { transform: translateY(40px); opacity: 0.4; } to { transform: none; opacity: 1; } }
.modal-card h3 { margin: 0 0 14px; color: var(--navy); }
.modal-actions { display: flex; gap: 10px; margin-top: 16px; }
.modal-actions .btn { flex: 1; }

/* ============ TOAST ============ */
.toast {
  position: fixed;
  bottom: calc(var(--nav-h) + 16px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  background: var(--navy-dark);
  color: #fff;
  padding: 12px 20px;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 600;
  box-shadow: 0 6px 20px rgba(10, 26, 62, 0.4);
  max-width: 90vw;
  text-align: center;
}

/* =========================================================
   DOCUMENT (A4 SHEET) — screen preview
   ========================================================= */
.view-doc { padding-bottom: 20px; }
.doc-topbar { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.doc-share { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.doc-share .btn { flex: 1; min-width: 120px; min-height: 42px; font-size: 0.85rem; }
.btn-wa { background: #E7F8EC; color: #128C4A; }
.btn-sms { background: var(--info-bg); color: var(--navy); }
.doc-sheet-wrap { overflow-x: auto; }
.doc-sheet {
  background: #fff;
  width: 100%;
  max-width: 794px; /* A4 @96dpi */
  min-width: 560px; /* keeps the document proportional; wrapper scrolls on phones */
  min-height: 500px;
  margin: 0 auto;
  padding: 34px 30px;
  box-shadow: 0 4px 24px rgba(15, 37, 87, 0.18);
  color: #1A2233;
  font-size: 13px;
  position: relative;
}

.doc-head { display: flex; justify-content: space-between; gap: 16px; border-bottom: 4px solid var(--navy); padding-bottom: 16px; }
.doc-biz { max-width: 55%; }
.doc-biz-logo img { max-height: 60px; max-width: 150px; margin-bottom: 8px; display: block; }
.doc-biz-name { font-size: 19px; font-weight: 800; color: var(--navy); }
.doc-biz-line { color: #555; font-size: 12px; }
.doc-title-block { text-align: right; }
.doc-type-title { font-size: 25px; font-weight: 800; color: var(--navy); letter-spacing: 1px; line-height: 1.15; }
.doc-type-sub { color: var(--gold-dark); font-weight: 700; font-size: 13px; letter-spacing: 2px; }
.doc-number { font-size: 14px; font-weight: 800; margin-top: 6px; }
.doc-dates { font-size: 12px; color: #555; margin-top: 4px; }
.doc-dates strong { color: #1A2233; }

.doc-meta-row { display: flex; justify-content: space-between; gap: 18px; margin: 18px 0; flex-wrap: wrap; }
.doc-billto { flex: 1; min-width: 200px; }
.doc-block-label { font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: 1.2px; color: var(--gold-dark); margin-bottom: 4px; }
.doc-billto-name { font-weight: 800; font-size: 15px; color: var(--navy); }
.doc-billto-line { font-size: 12px; color: #555; }
.doc-status-tag { align-self: flex-start; }

.doc-items { width: 100%; border-collapse: collapse; margin: 6px 0 14px; }
.doc-items th {
  background: var(--navy);
  color: #fff;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  padding: 9px 10px;
  text-align: left;
}
.doc-items th.num, .doc-items td.num { text-align: right; white-space: nowrap; }
.doc-items td { padding: 9px 10px; border-bottom: 1px solid #E8EBF2; font-size: 12.5px; vertical-align: top; }
.doc-items tbody tr:nth-child(even) td { background: #F7F9FC; }

.doc-totals { margin-left: auto; width: 270px; max-width: 100%; }
.doc-totals .dt-row { display: flex; justify-content: space-between; padding: 5px 10px; font-size: 12.5px; }
.doc-totals .dt-row.dt-grand {
  background: var(--navy);
  color: #fff;
  font-weight: 800;
  font-size: 15px;
  padding: 10px;
  border-radius: 6px;
  margin-top: 5px;
}
.doc-totals .dt-grand .dt-val { color: var(--gold); }
.doc-balance { color: var(--danger); font-weight: 800; }

.doc-paybox {
  border: 2.5px solid var(--gold);
  background: #FFFBEF;
  border-radius: 10px;
  padding: 14px 16px;
  margin: 18px 0;
  page-break-inside: avoid;
}
.doc-paybox-title { font-size: 14px; font-weight: 800; color: var(--navy); margin-bottom: 8px; }
.doc-pay-line { font-size: 12.5px; padding: 2.5px 0; }
.doc-pay-line strong { color: var(--navy); }
.doc-pay-num { font-weight: 800; letter-spacing: 0.5px; }

.doc-notes { margin: 14px 0; font-size: 12px; color: #444; }
.doc-notes .doc-block-label { margin-bottom: 3px; }

.doc-foot { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; margin-top: 34px; page-break-inside: avoid; }
.doc-sign { width: 220px; }
.doc-sign-line { border-top: 1.5px solid #999; padding-top: 5px; font-size: 11px; color: #666; }
.doc-thanks { font-size: 12px; color: var(--navy); font-weight: 700; text-align: right; }

.doc-watermark {
  margin-top: 22px;
  padding-top: 10px;
  border-top: 1px solid #E8EBF2;
  text-align: center;
  font-size: 10.5px;
  color: #9AA3B5;
}
.doc-watermark strong { color: var(--navy); }

/* PAID stamp on receipts / paid invoices */
.doc-stamp {
  position: absolute;
  top: 130px;
  right: 40px;
  transform: rotate(-14deg);
  border: 4px solid var(--success);
  color: var(--success);
  font-size: 26px;
  font-weight: 800;
  letter-spacing: 3px;
  padding: 6px 18px;
  border-radius: 8px;
  opacity: 0.82;
  text-transform: uppercase;
  pointer-events: none;
}
.doc-stamp.stamp-partial { border-color: var(--warn); color: var(--warn); }

.doc-receipt-ref {
  background: var(--info-bg);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 12.5px;
  margin: 14px 0;
}

/* =========================================================
   TAPPABLE STATS — "every number is a door"
   ========================================================= */
.door { cursor: pointer; }
.door:focus-visible { outline: 3px solid rgba(15, 37, 87, 0.35); outline-offset: 2px; }

.stat-card { position: relative; }
.stat-card .stat-chev {
  display: none;
  position: absolute;
  top: 50%;
  right: 10px;
  transform: translateY(-50%);
  color: var(--muted);
}
.stat-card.door { padding-right: 32px; }
.stat-card.door .stat-chev { display: block; }
.stat-card.door:active { transform: scale(0.985); }

.mini-stat { position: relative; border: 1.5px solid transparent; }
.mini-stat .ms-chev {
  display: none;
  position: absolute;
  top: 5px;
  right: 5px;
  color: var(--muted);
}
.mini-stat .ms-chev svg { width: 14px; height: 14px; display: block; }
.mini-stat.door .ms-chev { display: flex; }
.mini-stat.door:active { background: var(--info-bg); }
.mini-stat.ms-active { border-color: var(--navy); background: var(--info-bg); }

.detail-row.door:active { background: var(--info-bg); }
.detail-row .dr-chev {
  color: var(--muted);
  display: inline-flex;
  vertical-align: middle;
  margin-left: 4px;
}
.detail-row .dr-chev svg { width: 14px; height: 14px; display: block; }

.report-table tr.row-door { cursor: pointer; }
.report-table tr.row-door:active td { background: var(--info-bg); }

.rp-bar { cursor: pointer; }
.rp-bar:focus-visible { outline: 2px solid var(--navy); }

.badge[role="button"] { cursor: pointer; }
.badge[role="button"]:active { filter: brightness(0.92); }

#inv-count { margin: 0 0 10px; }

/* =========================================================
   DESKTOP
   ========================================================= */
@media (min-width: 700px) {
  .stat-grid { grid-template-columns: repeat(3, 1fr); }
  .stat-card:first-child { grid-column: auto; }
  .modal-overlay { align-items: center; padding: 20px; }
  .modal-card { border-radius: 18px; }
  .action-grid { grid-template-columns: repeat(3, 1fr); }
  .doc-sheet { padding: 48px 46px; font-size: 13.5px; }
}

/* =========================================================
   PRINT — only the A4 document
   ========================================================= */
@media print {
  @page { size: A4; margin: 12mm; }
  body { background: #fff; }
  body * { visibility: hidden; }
  #view-doc, #view-doc * { visibility: visible; }
  #view-doc .app-chrome, #view-doc .app-chrome * { visibility: hidden; display: none !important; }
  .app-header, .bottom-nav, .toast, .modal-overlay { display: none !important; }
  #view-doc {
    position: absolute;
    left: 0; top: 0;
    width: 100%;
    margin: 0; padding: 0;
  }
  .app-main { padding: 0; max-width: none; }
  .doc-sheet-wrap { overflow: visible; }
  .doc-sheet {
    box-shadow: none;
    max-width: 100%;
    width: 100%;
    min-width: 0;
    padding: 0;
    min-height: 0;
    font-size: 12.5pt;
  }
  .doc-items th { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .doc-totals .dt-grand, .doc-paybox, .doc-stamp, .doc-receipt-ref, .doc-head {
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
  }
}
