/* ============================================================
   دفتر فروش — Design system (Material 3, RTL, Vazirmatn)
   Colors/typography/components mirror docs/UI KIT.
   ============================================================ */

:root {
  --primary: #16A34A;
  --primary-teal: #14B8A6;
  --primary-700: #0F766E;
  --accent: #F59E0B;
  --bg: #F8FAFC;
  --surface: #FFFFFF;
  --text: #0F172A;
  --muted: #64748B;
  --faint: #94A3B8;
  --line: #E2E8F0;
  --line-soft: #F1F5F9;
  --text-2: #334155;
  --overlay: #0F172A;
  --danger-soft: #FEF2F2;
  --danger-text: #DC2626;
  --gradient: linear-gradient(135deg, #16A34A, #14B8A6);
  --splash-gradient: linear-gradient(180deg, #0F766E 0%, #16A34A 55%, #0EA5A0 100%);
  --success: #22C55E;
  --error: #EF4444;
  --tonal-green: #DCFCE7;
  --tonal-teal: #CCFBF1;
  --tonal-amber: #FEF3C7;

  --r-lg: 24px;
  --r-md: 18px;
  --r-sm: 16px;
  --shadow-card: 0 4px 16px rgba(15, 23, 42, 0.08);
  --shadow-soft: 0 3px 10px rgba(15, 23, 42, 0.05);
  --shadow-primary: 0 6px 18px rgba(22, 163, 74, 0.3);

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --nav-height: 66px;
  --app-height: 100dvh;
  --ease-ui: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-standard: cubic-bezier(0.2, 0, 0, 1);
}

/* Dark theme — applied via data-theme="dark" on <html> */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0B1120;
  --surface: #16202F;
  --text: #E8EEF6;
  --text-2: #CBD5E1;
  --muted: #94A3B8;
  --faint: #6B7A90;
  --line: #2A3648;
  --line-soft: #1C2636;
  --overlay: #243044;
  --danger-soft: #2A1618;
  --danger-text: #FCA5A5;
  --tonal-green: #16351F;
  --tonal-teal: #113436;
  --tonal-amber: #362A12;
  --shadow-card: 0 6px 18px rgba(0, 0, 0, 0.45);
  --shadow-soft: 0 3px 12px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  height: var(--app-height);
  background: var(--bg);
  color: var(--text);
  font-family: 'Vazirmatn', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
  overflow: hidden;
}

body { direction: rtl; }

/* Match the native PWA launch colour before deferred JavaScript paints the
   custom splash. This prevents a one-frame light/dark flash on cold launch. */
:root.pwa-standalone.splash-active,
:root.pwa-standalone.splash-active body {
  background-color: #0EA5A0;
  background-image: var(--splash-gradient);
  background-repeat: no-repeat;
  background-size: 100% 100%;
}
:root.pwa-standalone.splash-active #app {
  background: var(--splash-gradient);
}

/* Edge-to-edge status bar: keep the white iOS status text legible on light
   backgrounds with a faint scrim over just the notch area (none on dark or on
   devices without a notch, where --safe-top is 0). */
body::before {
  content: ''; position: fixed; top: 0; left: 0; right: 0; height: var(--safe-top);
  background: linear-gradient(to bottom, rgba(2, 6, 23, 0.3), rgba(2, 6, 23, 0));
  z-index: 250; pointer-events: none; display: none;
}
@media (display-mode: standalone) {
  :root:not([data-theme="dark"]) body::before { display: block; }
}

#app {
  max-width: 480px;
  margin: 0 auto;
  height: var(--app-height);
  background: var(--bg);
  position: relative;
}

button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, textarea, select { font-family: inherit; }
a { color: inherit; text-decoration: none; }

/* Numbers read best in a Latin face */
.num { font-family: 'Roboto', 'Vazirmatn', sans-serif; font-feature-settings: 'tnum'; }
.unit { font-size: 0.72em; font-weight: 600; opacity: 0.7; margin-inline-start: 1px; white-space: nowrap; }

/* ---------- Icons ---------- */
.icon { display: inline-flex; width: 1em; height: 1em; vertical-align: -0.125em; }
.icon svg { width: 100%; height: 100%; fill: currentColor; }

/* ---------- Screen scaffold ---------- */
.screen {
  position: relative;
  width: 100%;
  max-width: 480px;
  height: var(--app-height);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  padding-top: var(--safe-top);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  background: var(--bg); /* keep content opaque over the per-page body colour */
}
.screen.flush-top { padding-top: 0; } /* colored header fills the notch itself */
/* Pages with a bottom nav scroll only their content area, keeping the in-flow
   navigation as the final flex child at the physical bottom. */
.screen.has-nav { overflow: hidden; -webkit-overflow-scrolling: auto; }

/* Smooth cross-fade between screens (View Transitions API) */
::view-transition-old(root) { animation: pageOut 0.16s var(--ease-standard) both; }
::view-transition-new(root) { animation: pageIn 0.26s var(--ease-ui) both; }
@keyframes pageOut { to { opacity: 0; transform: translateY(-3px) scale(0.995); } }
@keyframes pageIn { from { opacity: 0; transform: translateY(6px) scale(0.995); } }
@media (prefers-reduced-motion: reduce) {
  ::view-transition-old(root),
  ::view-transition-new(root) { animation: none; }
}

/* The inner scroller needs min-height:0 so it can shrink and scroll smoothly with momentum. */
.screen-scroll { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; scroll-behavior: smooth; }
.screen,
.screen-scroll,
.chips-row {
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.screen::-webkit-scrollbar,
.screen-scroll::-webkit-scrollbar,
.chips-row::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}
.pad { padding: 20px; }

/* ---------- Typography ---------- */
.t-display { font-size: 28px; font-weight: 800; color: var(--text); }
.t-headline { font-size: 22px; font-weight: 800; color: var(--text); }
.t-title { font-size: 18px; font-weight: 700; color: var(--text); }
.t-body { font-size: 15px; font-weight: 400; color: var(--text-2); }
.t-muted { font-size: 14px; color: var(--muted); }
.t-label { font-size: 12px; font-weight: 600; color: var(--muted); }

/* ---------- Buttons ---------- */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  font-size: 16px; font-weight: 700; padding: 16px; border-radius: var(--r-sm);
  width: 100%; text-align: center; transition: transform 0.18s var(--ease-ui), opacity 0.18s ease, filter 0.18s ease;
}
.btn:active { transform: scale(0.975); filter: brightness(0.97); }
.btn-primary { background: var(--primary); color: #fff; box-shadow: var(--shadow-primary); }
.btn-primary:disabled { opacity: 0.55; box-shadow: none; }
.btn-tonal { background: var(--tonal-green); color: #166534; box-shadow: none; }
.btn-outline { background: transparent; color: var(--primary); border: 1.5px solid var(--primary); }
.btn-pill { border-radius: 100px; width: auto; padding: 14px 32px; }
.btn-danger { background: var(--danger-soft); color: var(--error); box-shadow: none; }

/* ---------- Inputs ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.field-label.active { color: var(--primary); }
.input {
  height: 54px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-sm); display: flex; align-items: center; gap: 10px;
  padding: 0 16px; font-size: 15px; color: var(--text); width: 100%;
  transition: border-color 0.15s;
}
.input:focus-within { border-color: var(--primary); border-width: 1.5px; }
.input input, .input textarea {
  flex: 1; border: none; outline: none; background: transparent;
  font-size: 16px; color: var(--text); width: 100%; min-width: 0;
}
.input .suffix { font-size: 13px; color: var(--faint); font-weight: 600; }
textarea.input { height: 84px; align-items: flex-start; padding: 14px 16px; resize: none; line-height: 1.6; }

/* ---------- Chips ---------- */
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  padding: 9px 16px; border-radius: 100px; font-size: 13px; font-weight: 600;
  background: var(--surface); border: 1px solid var(--line); color: var(--text-2);
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  transition: color 0.2s ease, background-color 0.2s ease, border-color 0.2s ease, transform 0.18s var(--ease-ui);
}
.chip:active { transform: scale(0.96); }
.chip.active { background: var(--primary); color: #fff; border-color: var(--primary); }
/* Single-line horizontally-scrollable chips (e.g. categories) — saves vertical space */
.chips-row { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain; padding-bottom: 2px; scrollbar-width: none; }
.chips-row::-webkit-scrollbar { display: none; }
.chips-row .chip { flex: 0 0 auto; }

/* ---------- Cards ---------- */
.card { background: var(--surface); border-radius: var(--r-md); box-shadow: var(--shadow-soft); }
.card-lg { border-radius: var(--r-lg); box-shadow: var(--shadow-card); }

/* ---------- App bar ---------- */
.appbar {
  display: flex; align-items: center; gap: 10px; padding: 16px 20px;
}
.appbar .title { flex: 1; font-size: 18px; font-weight: 800; }
.iconbtn {
  width: 42px; height: 42px; border-radius: 14px; background: var(--surface);
  display: flex; align-items: center; justify-content: center; color: var(--text-2);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.06); font-size: 22px; position: relative;
  transition: transform 0.18s var(--ease-ui), background-color 0.2s ease;
}
.iconbtn:active { transform: scale(0.92); }
.iconbtn.plain { background: transparent; box-shadow: none; }
.badge-dot { position: absolute; top: 9px; right: 9px; width: 8px; height: 8px; border-radius: 50%; background: var(--error); }

/* ---------- Bottom navigation ---------- */
/* In-flow (not position:fixed) — it's the last flex child of the screen, so it
   always sits flush at the bottom. Avoids the iOS fixed-in-scroll-container bug. */
.bottom-nav {
  position: relative; z-index: 40; flex-shrink: 0;
  width: 100%;
  box-sizing: border-box;
  height: calc(var(--nav-height) + var(--safe-bottom));
  padding: 6px 0 calc(8px + var(--safe-bottom));
  background: var(--surface); box-shadow: 0 -4px 20px rgba(15, 23, 42, 0.08);
  border-radius: 24px 24px 0 0;
  display: flex; align-items: center; justify-content: space-around;
  view-transition-name: bottomnav;
}
.nav-item { display: flex; flex-direction: column; align-items: center; gap: 2px; color: var(--faint); font-size: 10px; transition: color 0.2s ease, transform 0.18s var(--ease-ui); }
.nav-item:active { transform: translateY(1px) scale(0.96); }
.nav-item .icon { font-size: 24px; }
.nav-item.active { color: var(--primary); font-weight: 700; }
.nav-fab {
  width: 54px; height: 54px; border-radius: 19px; background: var(--primary);
  display: flex; align-items: center; justify-content: center; color: #fff;
  margin-top: -27px; box-shadow: 0 8px 20px rgba(22, 163, 74, 0.4); font-size: 27px;
  transition: transform 0.2s var(--ease-ui), box-shadow 0.2s ease;
}
.nav-fab:active { transform: scale(0.92); box-shadow: 0 4px 12px rgba(22, 163, 74, 0.32); }

/* ---------- Dashboard ---------- */
.greet-avatar {
  width: 46px; height: 46px; border-radius: 14px; color: #fff; font-size: 15px; font-weight: 700;
  background: linear-gradient(135deg, var(--primary), var(--primary-teal));
  display: flex; align-items: center; justify-content: center;
}
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stat {
  background: var(--surface); border-radius: 20px; padding: 16px;
  box-shadow: var(--shadow-card); display: flex; flex-direction: column; gap: 6px;
}
.stat.primary { background: var(--gradient); color: #fff; box-shadow: 0 8px 20px rgba(22, 163, 74, 0.28); }
.stat .icon { font-size: 20px; }
.stat .k { font-size: 12px; color: var(--muted); }
.stat.primary .k { color: rgba(255, 255, 255, 0.85); }
.stat .v { font-size: 19px; font-weight: 800; }

.quick-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.quick { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.quick .bubble {
  width: 56px; height: 56px; border-radius: 18px; display: flex; align-items: center; justify-content: center; font-size: 24px;
  transition: transform 0.2s var(--ease-ui), filter 0.2s ease;
}
.quick:active .bubble { transform: translateY(1px) scale(0.94); filter: brightness(0.97); }
.quick .lbl { font-size: 11px; color: var(--text-2); font-weight: 600; }

.section-head { display: flex; align-items: center; justify-content: space-between; }
.link { font-size: 13px; color: var(--primary); font-weight: 600; }

.sale-row {
  background: var(--surface); border-radius: var(--r-md); padding: 12px 14px;
  display: flex; align-items: center; gap: 12px; box-shadow: var(--shadow-soft);
}
.sale-accordion {
  background: var(--surface); border: 1px solid transparent; border-radius: var(--r-md);
  box-shadow: var(--shadow-soft); overflow: hidden;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.sale-accordion > summary { list-style: none; user-select: none; }
.sale-accordion > summary::-webkit-details-marker { display: none; }
.sale-accordion .sale-row { border-radius: 0; box-shadow: none; }
.sale-accordion[open] { border-color: color-mix(in srgb, var(--primary) 24%, var(--line)); box-shadow: var(--shadow-card); }
.sale-accordion[open] .sale-row { background: var(--line-soft); }
.sale-ico { width: 42px; height: 42px; border-radius: 14px; display: flex; align-items: center; justify-content: center; font-size: 20px; background: var(--tonal-green); color: var(--primary); }
.sale-row > .grow { min-width: 0; }
.sale-row .name {
  display: block; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 14px; font-weight: 600;
}
.sale-row .time { font-size: 12px; color: var(--faint); }
.sale-subline { display: flex; align-items: center; flex-wrap: nowrap; gap: 4px; overflow: hidden; white-space: nowrap; }
.sale-subline > span { flex: 0 0 auto; }
.sale-subline .num { direction: ltr; unicode-bidi: isolate; }
.sale-row .amt { font-size: 14px; font-weight: 700; white-space: nowrap; }
.sale-row-link {
  width: 100%; color: inherit; text-align: start; cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.2s var(--ease-ui), background-color 0.2s ease, border-color 0.2s ease;
}
.sale-row-trailing { flex: 0 0 auto; text-align: left; }
.sale-expand { flex: 0 0 auto; display: flex; color: var(--faint); transition: transform 0.25s ease, color 0.2s; }
.sale-accordion[open] .sale-expand { color: var(--primary); transform: rotate(180deg); }
.sale-accordion:not([open]) .sale-collapse { display: none; }
.sale-collapse-inner { min-height: 0; overflow: hidden; }
.sale-items-title { padding: 13px 14px 7px; border-top: 1px solid var(--line-soft); color: var(--muted); font-size: 10px; font-weight: 700; }
.sale-items-list { margin: 0 14px; border: 1px solid var(--line-soft); border-bottom: 0; }
.sale-item-line { min-height: 38px; padding: 8px 9px; display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--line-soft); }
.sale-item-line:last-child { border-bottom: none; }
.sale-item-number { width: 20px; height: 20px; flex: 0 0 20px; display: flex; align-items: center; justify-content: center; color: var(--primary); font-size: 9px; font-weight: 700; }
.sale-item-name { min-width: 0; flex: 1; color: var(--text-2); font-size: 11px; overflow-wrap: anywhere; }
.sale-item-price { flex: 0 0 auto; color: var(--text); font-size: 11px; font-weight: 700; }
.sale-collapse-meta {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px;
  margin-top: 10px; padding: 13px 14px 10px; border-top: 1px solid var(--line-soft);
}
.sale-collapse-item { min-width: 0; display: flex; align-items: flex-start; gap: 6px; color: var(--primary); }
.sale-collapse-item > div { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.sale-collapse-item small { color: var(--faint); font-size: 9px; }
.sale-collapse-item b { color: var(--text-2); font-size: 10px; font-weight: 650; overflow-wrap: anywhere; }
.sale-collapse-note {
  margin: 0 14px 8px; padding: 7px 9px; border-inline-start: 2px solid var(--primary);
  background: var(--line-soft); color: var(--text-2); font-size: 10px; line-height: 1.55;
  display: flex; align-items: flex-start; gap: 5px; white-space: pre-wrap; overflow-wrap: anywhere;
}
.sale-collapse-note.empty { color: var(--faint); border-inline-start-color: var(--line); }
.sale-collapse-note-title { flex: 0 0 auto; color: var(--muted); font-size: 9px; font-weight: 700; }
.sale-collapse-actions { padding: 0 14px 12px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.invoice-edit-link {
  min-height: 34px; padding: 7px 10px; border-radius: 10px; color: var(--primary);
  background: var(--tonal-green); display: inline-flex; align-items: center; gap: 5px;
  font-size: 10px; font-weight: 700;
}
.invoice-delete-button {
  min-height: 34px; padding: 7px 9px; border-radius: 10px; color: var(--danger-text);
  display: inline-flex; align-items: center; gap: 4px; font-size: 10px; font-weight: 700;
  transition: background-color 0.18s ease, transform 0.18s var(--ease-ui);
}
.invoice-delete-button:active { background: var(--danger-soft); transform: scale(0.96); }

/* Destructive confirmation dialog */
.confirm-overlay {
  position: fixed; inset: 0; z-index: 500; padding: 20px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(2, 6, 23, 0.58); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  opacity: 0; transition: opacity 0.18s ease;
}
.confirm-overlay.visible { opacity: 1; }
.confirm-dialog {
  width: min(100%, 360px); padding: 22px; border: 1px solid var(--line); border-radius: 20px;
  background: var(--surface); color: var(--text); box-shadow: 0 24px 60px rgba(2, 6, 23, 0.32);
  text-align: center; transform: translateY(10px) scale(0.97); transition: transform 0.24s var(--ease-ui);
}
.confirm-overlay.visible .confirm-dialog { transform: none; }
.confirm-icon {
  width: 58px; height: 58px; margin: 0 auto 13px; border-radius: 18px;
  display: flex; align-items: center; justify-content: center; color: var(--danger-text); background: var(--danger-soft);
}
.confirm-title { font-size: 17px; font-weight: 800; }
.confirm-message { margin-top: 7px; color: var(--muted); font-size: 12px; line-height: 1.75; }
.confirm-actions { margin-top: 20px; display: grid; grid-template-columns: 1fr 1.35fr; gap: 9px; }
.confirm-actions .btn { min-height: 46px; padding: 11px 8px; font-size: 12px; box-shadow: none; }
.confirm-cancel { color: var(--text-2); background: var(--line-soft); }
.confirm-delete { color: #fff; background: var(--error); }
.confirm-delete:disabled { opacity: 0.65; }
.confirm-spinner { width: 17px; height: 17px; border-width: 2px; border-color: rgba(255,255,255,.35); border-top-color: #fff; }

/* ---------- Invoice items ---------- */
.invoice-items-heading { margin-top: 2px; }
.invoice-items-count { color: var(--primary); font-size: 11px; font-weight: 700; }
.invoice-items { display: flex; flex-direction: column; gap: 10px; }
.invoice-item { padding: 12px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); display: grid; gap: 11px; animation: itemReveal 0.24s var(--ease-ui) both; }
@keyframes itemReveal { from { opacity: 0; transform: translateY(5px); } }
.invoice-item-head { min-height: 24px; display: flex; align-items: center; justify-content: space-between; }
.invoice-item-label { color: var(--text-2); font-size: 12px; font-weight: 750; }
.invoice-remove-item { width: 30px; height: 30px; display: flex; align-items: center; justify-content: center; color: var(--danger-text); border-radius: 10px; }
.invoice-remove-item:active { background: var(--danger-soft); }
.invoice-add-item { padding: 12px; font-size: 13px; }
.invoice-add-item:disabled { opacity: 0.45; }
.sale-row-link:active { transform: scale(0.992); background: var(--line-soft); }
@media (hover: hover) {
  .sale-row-link:hover { background: var(--line-soft); }
}
@media (prefers-reduced-motion: reduce) {
  .sale-accordion, .sale-expand, .sale-collapse { transition: none; animation: none; }
  .invoice-item { animation: none; }
  .screen-scroll { scroll-behavior: auto; }
}

/* ---------- Notifications ---------- */
.notification-page { padding-top: 8px; }
.notification-unread-count {
  flex: 0 0 auto; color: var(--primary); font-size: 10px; font-weight: 700; white-space: nowrap;
}
.notification-row {
  width: 100%; min-height: 88px; padding: 13px 14px; color: inherit; text-align: start;
  border: 1px solid var(--line-soft); border-radius: var(--r-md); background: var(--surface);
  box-shadow: var(--shadow-soft); display: flex; align-items: flex-start; gap: 11px;
  transition: background 0.12s, border-color 0.12s, opacity 0.12s;
}
.notification-row.unread { border-inline-start: 3px solid var(--primary); background: var(--tonal-green); }
.notification-row:active { opacity: 0.78; }
.notification-icon {
  width: 40px; height: 40px; flex: 0 0 40px; border-radius: 13px;
  display: flex; align-items: center; justify-content: center; color: var(--primary); background: var(--line-soft);
}
.notification-row.unread .notification-icon { background: var(--surface); }
.notification-content { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.notification-title { color: var(--text); font-size: 13px; font-weight: 750; }
.notification-message { color: var(--text-2); font-size: 12px; line-height: 1.75; white-space: normal; }
.notification-time { color: var(--faint); font-size: 10px; margin-top: 2px; }
.notification-dot { width: 8px; height: 8px; flex: 0 0 8px; margin-top: 6px; border-radius: 50%; background: var(--primary); }
.notification-chevron { flex: 0 0 auto; align-self: center; color: var(--faint); }
.notification-empty {
  min-height: 58vh; padding: 32px 20px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 9px; text-align: center;
}
.notification-empty-icon {
  width: 104px; height: 104px; margin-bottom: 8px; border-radius: 30px;
  display: flex; align-items: center; justify-content: center; color: var(--primary); background: var(--tonal-green);
}
.notification-more { margin: 16px auto 4px; }

/* ---------- OTP ---------- */
.otp-inputs { display: flex; gap: 8px; direction: ltr; justify-content: center; }
.otp-box {
  width: 46px; height: 56px; border-radius: 14px; border: 1.5px solid var(--line);
  text-align: center; font-size: 22px; font-weight: 700; color: var(--text);
  font-family: 'Roboto', sans-serif; background: var(--surface); outline: none;
}
.otp-box:focus, .otp-box.filled { border-color: var(--primary); }

/* ---------- Reports chart ---------- */
.bars { display: flex; align-items: flex-end; gap: 10px; height: 96px; position: relative; }
.bar-col { flex: 1; height: 100%; display: flex; align-items: flex-end; cursor: pointer; }
.bar { width: 100%; background: var(--tonal-green); border-radius: 8px 8px 0 0; min-height: 4px; transition: height 0.4s, background 0.15s; }
.bar.peak { background: var(--primary); }
.bar.sel { background: var(--primary); }
.bar-labels { display: flex; gap: 10px; padding-top: 8px; font-size: 10px; color: var(--faint); }
.bar-labels span { flex: 1; text-align: center; }
/* chart tooltip */
.bar-tip {
  position: absolute; transform: translateX(-50%); z-index: 5; pointer-events: none;
  background: var(--overlay); color: #fff; padding: 6px 10px; border-radius: 10px; text-align: center;
  white-space: nowrap; box-shadow: 0 6px 16px rgba(15, 23, 42, 0.25); opacity: 0; transition: opacity 0.12s;
}
.bar-tip.show { opacity: 1; }
.bar-tip b { display: block; font-size: 11px; font-weight: 600; opacity: 0.85; }
.bar-tip .num { font-size: 13px; font-weight: 800; }
.kv { display: flex; justify-content: space-between; font-size: 13px; }
.kv .k { color: var(--muted); }
.kv .v { font-weight: 700; }

/* report hero + mini stats */
.report-hero {
  background: linear-gradient(135deg, var(--primary), var(--primary-teal)); color: #fff;
  border-radius: 20px; padding: 18px; box-shadow: 0 10px 24px rgba(22, 163, 74, 0.28);
  display: flex; flex-direction: column; gap: 12px;
}
.report-hero .rh-label { font-size: 13px; opacity: 0.9; }
.report-hero .rh-value { font-size: 27px; font-weight: 800; margin-top: 3px; }
.report-hero .rh-unit { font-size: 14px; font-weight: 600; opacity: 0.85; }
.report-hero .rh-icon { font-size: 24px; opacity: 0.9; }
.report-hero .rh-meta { font-size: 12px; opacity: 0.9; border-top: 1px solid rgba(255, 255, 255, 0.2); padding-top: 10px; }
.mini { padding: 14px; display: flex; flex-direction: column; gap: 4px; }
.mini-label { font-size: 12px; color: var(--muted); line-height: 1.6; }
.mini-val { font-size: 17px; font-weight: 800; margin-top: auto; }
.export-btn {
  box-shadow: none; background: var(--line-soft); text-align: center; padding: 12px;
  font-weight: 700; font-size: 12px; color: var(--text-2); display: flex; flex-direction: column;
  align-items: center; gap: 5px; cursor: pointer; transition: background 0.12s;
}
.export-btn:active { background: var(--line); }
.report-empty { text-align: center; color: var(--muted); font-size: 13px; }

/* Public, read-only shared report */
.shared-report-head {
  padding: calc(22px + var(--safe-top)) 20px 22px; color: #fff;
  background: linear-gradient(135deg, #0F766E, #16A34A);
}
.shared-report-head-inner {
  width: 100%; display: flex; align-items: center; gap: 12px;
}
.shared-report-mark {
  width: 48px; height: 48px; flex: 0 0 48px; border-radius: 14px;
  background: rgba(255, 255, 255, 0.16); display: flex; align-items: center; justify-content: center;
}
.shared-report-store { margin-top: 2px; font-size: 13px; opacity: 0.82; }
.shared-report-badge {
  flex: 0 0 auto; padding: 5px 8px; border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 8px; font-size: 10px; font-weight: 700;
}
.shared-report-sales-head { margin: 22px 0 10px; }
.shared-report-range { display: none; margin-top: 3px; color: var(--faint); font-size: 12px; }
.shared-report-count {
  color: var(--faint); font-size: 12px; font-weight: 600;
}
.shared-report-footer { padding: 24px 0 10px; color: var(--faint); text-align: center; font-size: 11px; }

@media (min-width: 900px) {
  :root.shared-report-active #app { max-width: none; }
  :root.shared-report-active .screen { max-width: none; }
  :root.shared-report-active body { background: var(--bg); }

  .shared-report-head { padding: 0 32px; }
  .shared-report-head-inner { max-width: 1180px; min-height: 96px; margin: 0 auto; }
  .shared-report-mark { width: 52px; height: 52px; flex-basis: 52px; }
  .shared-report-head .t-headline { font-size: 20px; }
  .shared-report-badge { padding: 6px 10px; font-size: 11px; }

  .shared-report-main {
    width: 100%; max-width: 1180px; margin: 0 auto; padding: 32px;
    display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 28px; align-items: start;
  }
  .shared-report-summary { grid-column: 2; position: sticky; top: 32px; }
  .shared-report-summary .report-hero { padding: 22px; }
  .shared-report-summary .report-hero .rh-value { font-size: 30px; }
  .shared-report-sales {
    grid-column: 1; grid-row: 1; min-width: 0; padding: 20px;
    border: 1px solid var(--line); border-radius: 20px; background: var(--surface); box-shadow: var(--shadow-soft);
  }
  .shared-report-sales-head { margin: 0 0 16px; padding-bottom: 14px; border-bottom: 1px solid var(--line-soft); }
  .shared-report-range { display: block; }
  .shared-report-count {
    padding: 6px 10px; border-radius: 8px; background: var(--line-soft);
    color: var(--muted); font-size: 11px; font-weight: 700;
  }
  .shared-report-sales-list .sale-row {
    border: 1px solid var(--line-soft); border-radius: 12px; box-shadow: none; padding: 13px 14px;
  }
  .shared-report-sales-list .sale-row:hover { border-color: var(--line); background: var(--line-soft); }
  .shared-report-footer { grid-column: 1 / -1; padding: 4px 0 0; }
}

/* ---------- Profile ---------- */
.profile-head {
  background: linear-gradient(135deg, var(--primary), var(--primary-teal));
  padding: calc(28px + var(--safe-top)) 20px 40px;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  border-radius: 0 0 32px 32px; color: #fff;
}
.profile-avatar { width: 76px; height: 76px; border-radius: 24px; background: rgba(255, 255, 255, 0.2); display: flex; align-items: center; justify-content: center; font-size: 26px; font-weight: 800; }
.list-card { background: var(--surface); border-radius: var(--r-md); box-shadow: var(--shadow-card); overflow: hidden; }
.list-row { display: flex; align-items: center; gap: 14px; padding: 14px; transition: background-color 0.2s ease, transform 0.18s var(--ease-ui); }
.list-row:active { background: var(--line-soft); transform: scale(0.99); }
.list-row .icon { font-size: 22px; color: var(--primary); }
.list-row .icon.neutral { color: var(--text-2); }
.list-row .lbl { flex: 1; font-size: 14px; }
.list-row .val { font-size: 13px; color: var(--faint); }
.list-sep { height: 1px; background: var(--line-soft); margin: 0 14px; }

/* toggle */
.toggle { width: 44px; height: 26px; border-radius: 100px; background: var(--line); position: relative; transition: background 0.15s; }
.toggle .knob { position: absolute; top: 3px; right: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2); transition: right 0.15s; }
.toggle.on { background: var(--primary); }
.toggle.on .knob { right: 21px; }

/* ---------- States ---------- */
.state {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 16px; padding: 32px; text-align: center;
}
.state-badge { width: 132px; height: 132px; border-radius: 36px; display: flex; align-items: center; justify-content: center; font-size: 64px; }
.state-badge.green { background: var(--tonal-green); color: var(--primary); }
.state-badge.red { background: var(--danger-soft); color: var(--error); }
.state-badge.round { border-radius: 50%; }

/* skeleton */
.sk { background: var(--line); border-radius: 10px; position: relative; overflow: hidden; }
.sk::after { content: ''; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.55), transparent); animation: shimmer 1.2s infinite; }
@keyframes shimmer { from { transform: translateX(100%); } to { transform: translateX(-100%); } }

/* spinner */
.spinner { width: 40px; height: 40px; border: 3px solid rgba(22, 163, 74, 0.2); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.8s linear infinite; }
.spinner.light { border-color: rgba(255, 255, 255, 0.35); border-top-color: #fff; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Splash ---------- */
.splash {
  position: fixed; inset: 0;
  width: 100%; max-width: 480px; margin: 0 auto;
  box-sizing: border-box;
  background: var(--splash-gradient); color: #fff;
}
.splash-content {
  position: absolute; inset: 0;
  padding: var(--safe-top) 0 var(--safe-bottom);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 24px;
}
.splash-logo { width: 112px; height: 112px; border-radius: 32px; background: rgba(255, 255, 255, 0.16); display: flex; align-items: center; justify-content: center; font-size: 56px; box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18); }
.splash-title { font-size: 26px; font-weight: 800; }
.splash-sub { font-size: 13px; letter-spacing: 1px; opacity: 0.75; }

/* login hero */
.hero {
  width: 100%; height: 170px; border-radius: var(--r-lg);
  background: linear-gradient(135deg, var(--tonal-green), var(--tonal-teal));
  display: flex; align-items: center; justify-content: center; color: var(--primary); font-size: 84px;
}

/* ---------- Toast ---------- */
#toast-root { position: fixed; top: calc(12px + var(--safe-top)); left: 0; right: 0; z-index: 100; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast {
  background: var(--overlay); color: #fff; padding: 12px 18px; border-radius: 14px; font-size: 14px; font-weight: 600;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2); display: flex; align-items: center; gap: 8px; max-width: 90%;
  animation: toastIn 0.2s ease;
}
.toast.success { background: #166534; }
.toast.error { background: #B91C1C; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

/* ---------- Install hint (iOS) ---------- */
.install-hint {
  margin: 0 20px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
  padding: 12px 14px; display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--text-2); box-shadow: var(--shadow-soft);
}
.install-hint .icon { color: var(--primary); font-size: 22px; }

/* better contrast for tonal button text in dark mode */
:root[data-theme="dark"] .btn-tonal { color: #86EFAC; }
:root[data-theme="dark"] input::placeholder,
:root[data-theme="dark"] textarea::placeholder { color: var(--faint); }

/* ---------- Segmented control (theme switcher) ---------- */
.seg { display: flex; background: var(--line-soft); border-radius: 14px; padding: 4px; gap: 4px; }
.seg-opt {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 11px 6px; border-radius: 10px; font-size: 13px; font-weight: 600;
  color: var(--muted); cursor: pointer; transition: background 0.15s, color 0.15s;
}
.seg-opt .icon { font-size: 18px; }
.seg-opt.active { background: var(--surface); color: var(--primary); box-shadow: var(--shadow-soft); }

/* ---------- Top progress bar ---------- */
#progress {
  position: fixed; top: 0; inset-inline: 0 auto; height: 3px; width: 0;
  background: linear-gradient(90deg, var(--primary), var(--primary-teal));
  z-index: 200; opacity: 0; border-radius: 0 3px 3px 0;
  transition: width 0.25s ease, opacity 0.3s ease;
}
#progress.active { opacity: 1; }

/* ---------- Offline banner ---------- */
#offline-banner {
  position: fixed; top: 0; left: 0; right: 0; z-index: 300;
  background: var(--overlay); color: #fff; font-size: 13px; font-weight: 600;
  padding: calc(9px + var(--safe-top)) 14px 9px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  transform: translateY(-105%); transition: transform 0.28s ease;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}
#offline-banner .dot { width: 8px; height: 8px; border-radius: 50%; background: #F87171; flex: 0 0 auto; }
body.offline #offline-banner { transform: none; }

/* ---------- Logout row (readable in both themes) ---------- */
.logout-row {
  background: var(--danger-soft); border-radius: var(--r-md); box-shadow: var(--shadow-soft);
  display: flex; align-items: center; gap: 14px; padding: 15px 16px; cursor: pointer;
  transition: filter 0.12s;
}
.logout-row:active { filter: brightness(0.96); }
.logout-row .icon { font-size: 22px; color: var(--danger-text); }
.logout-row .lbl { font-size: 14px; font-weight: 700; color: var(--danger-text); }

.mt-auto { margin-top: auto; }
.center { text-align: center; }
.row { display: flex; align-items: center; }
.gap8 { gap: 8px; } .gap10 { gap: 10px; } .gap12 { gap: 12px; }
.col { display: flex; flex-direction: column; }
.grow { flex: 1; }
.hidden { display: none !important; }
