/* ===========================================================
   Shop Hisaab — Design System
   Sober, professional palette: deep navy + muted gold accent.
   =========================================================== */

:root{
  --navy: #0f2b46;
  --navy-2: #123a58;
  --navy-3: #163c5e;
  --gold: #c9a227;
  --gold-light: #e0bd4a;
  --bg: #f4f6f8;
  --card: #ffffff;
  --text: #16232f;
  --muted: #647480;
  --border: #e3e7ec;
  --success: #1f9d55;
  --success-bg: #e7f6ec;
  --danger: #c0392b;
  --danger-bg: #fbebe9;
  --shadow: 0 1px 3px rgba(15,43,70,.06), 0 1px 2px rgba(15,43,70,.08);
  --shadow-lg: 0 10px 30px rgba(15,43,70,.12);
  --radius: 14px;
  --radius-sm: 9px;
  --font-en: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-ur: 'Noto Nastaliq Urdu', serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

[data-theme="dark"]{
  --bg: #0b1620;
  --card: #12212f;
  --text: #e7edf3;
  --muted: #8ea0b3;
  --border: #223245;
  --success: #35c073;
  --success-bg: #113626;
  --danger: #e2685a;
  --danger-bg: #3a1b18;
  --shadow: 0 1px 3px rgba(0,0,0,.35);
  --shadow-lg: 0 10px 30px rgba(0,0,0,.45);
}

*{box-sizing:border-box; -webkit-tap-highlight-color: transparent;}
html,body{height:100%;}
body{
  margin:0;
  background:var(--bg);
  color:var(--text);
  font-family: var(--font-en);
  -webkit-font-smoothing:antialiased;
  transition: background .25s ease, color .25s ease;
  overscroll-behavior-y: none;
}
body[dir="rtl"]{ font-family: var(--font-ur); }
body[dir="rtl"] .lang-en-only{ display:none !important; }
body[dir="ltr"] .lang-ur-only{ display:none !important; }

.num, .money, input[type="number"]{ font-family:'Inter', sans-serif; }

img{max-width:100%;}
button{font-family:inherit;}
input, select, textarea{font-family:inherit;}

a{color:inherit;}

::selection{ background: var(--gold-light); color:#1a1a1a; }

/* ---------- Layout shells ---------- */
#app-root{
  min-height:100vh;
  min-height:100dvh;
  display:flex;
  flex-direction:column;
}

.screen{ display:none; flex:1; flex-direction:column; }
.screen.active{ display:flex; }

/* ---------- Top bar ---------- */
.topbar{
  position:sticky; top:0; z-index:40;
  padding-top: calc(12px + var(--safe-top));
  padding-bottom:12px;
  background: linear-gradient(180deg, var(--navy) 0%, var(--navy-2) 100%);
  color:#fff;
  display:flex; align-items:center; gap:12px;
  padding-inline:16px;
  box-shadow: var(--shadow);
}
.topbar .brand{
  display:flex; align-items:center; gap:10px;
  font-weight:700; font-size:17px; letter-spacing:.2px;
}
.topbar .brand .coin{
  width:30px; height:30px; border-radius:50%;
  background: var(--gold);
  color:var(--navy);
  display:flex; align-items:center; justify-content:center;
  font-weight:800; font-size:13px; font-family:'Inter',sans-serif;
  flex-shrink:0;
}
.topbar-spacer{flex:1;}
.icon-btn{
  width:38px; height:38px; border-radius:10px;
  border:1px solid rgba(255,255,255,.18);
  background: rgba(255,255,255,.08);
  color:#fff;
  display:flex; align-items:center; justify-content:center;
  cursor:pointer;
  font-size:17px;
  transition: background .15s;
}
.icon-btn:hover{ background: rgba(255,255,255,.18); }
.icon-btn:active{ transform: scale(.94); }

/* ---------- Bottom nav ---------- */
.bottom-nav{
  position:sticky; bottom:0; z-index:40;
  display:flex;
  background: var(--card);
  border-top:1px solid var(--border);
  padding-bottom: calc(6px + var(--safe-bottom));
  padding-top:6px;
  box-shadow: 0 -2px 12px rgba(15,43,70,.06);
}
.nav-item{
  flex:1; display:flex; flex-direction:column; align-items:center; gap:3px;
  padding:6px 4px 4px;
  color:var(--muted);
  cursor:pointer;
  font-size:11px;
  border:none; background:none;
  font-family:inherit;
}
.nav-item .ic{ font-size:19px; line-height:1; }
.nav-item.active{ color:var(--navy); }
[data-theme="dark"] .nav-item.active{ color:var(--gold-light); }
.nav-item.active .ic{ transform: translateY(-1px); }

/* ---------- Content ---------- */
.content{ flex:1; padding:16px; padding-bottom:28px; max-width:720px; margin:0 auto; width:100%; }

/* ---------- Cards ---------- */
.card{
  background:var(--card);
  border:1px solid var(--border);
  border-radius: var(--radius);
  padding:16px;
  box-shadow: var(--shadow);
  margin-bottom:14px;
}
.card h3{ margin:0 0 12px; font-size:14px; color:var(--muted); font-weight:600; }

/* ---------- Stat grid ---------- */
.stat-grid{ display:grid; grid-template-columns:1fr 1fr; gap:12px; margin-bottom:14px; }
.stat-card{
  background: var(--card);
  border:1px solid var(--border);
  border-radius: var(--radius);
  padding:14px 16px;
  box-shadow: var(--shadow);
  position:relative;
  overflow:hidden;
}
.stat-card.hero{
  grid-column: 1 / -1;
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-3) 100%);
  color:#fff;
  border:none;
}
.stat-card.hero .stat-label{ color: rgba(255,255,255,.72); }
.stat-card.hero .stat-value{ color:#fff; }
.stat-card .stat-label{ font-size:12px; color:var(--muted); margin-bottom:6px; }
.stat-card .stat-value{ font-size:21px; font-weight:800; font-family:'Inter',sans-serif; letter-spacing:-.2px; }
.stat-card .stat-sub{ font-size:11px; color:var(--muted); margin-top:4px; }
.stat-card .accent-bar{ position:absolute; inset-inline-start:0; top:0; bottom:0; width:4px; background:var(--gold); }

/* ---------- Buttons ---------- */
.btn{
  display:inline-flex; align-items:center; justify-content:center; gap:8px;
  padding:12px 18px;
  border-radius: 11px;
  border:none;
  font-size:14.5px; font-weight:600;
  cursor:pointer;
  transition: transform .1s, opacity .15s, background .15s;
}
.btn:active{ transform: scale(.97); }
.btn-primary{ background: var(--navy); color:#fff; }
.btn-primary:hover{ background: var(--navy-3); }
.btn-gold{ background: var(--gold); color:#1a1a1a; }
.btn-gold:hover{ background: var(--gold-light); }
.btn-outline{ background:transparent; border:1.5px solid var(--border); color:var(--text); }
.btn-outline:hover{ border-color: var(--navy); }
.btn-danger{ background: var(--danger-bg); color:var(--danger); }
.btn-block{ width:100%; }
.btn-sm{ padding:8px 12px; font-size:13px; border-radius:9px; }
.btn:disabled{ opacity:.55; cursor:not-allowed; }
.btn-icon-only{ padding:10px; }

.fab{
  position:fixed;
  bottom: calc(78px + var(--safe-bottom));
  inset-inline-end:20px;
  width:56px; height:56px; border-radius:50%;
  background: var(--gold);
  color:#1a1a1a;
  display:flex; align-items:center; justify-content:center;
  font-size:26px;
  box-shadow: var(--shadow-lg);
  border:none; cursor:pointer;
  z-index:45;
}
.fab:active{ transform: scale(.94); }

/* ---------- Forms ---------- */
.field{ margin-bottom:14px; }
.field label{ display:block; font-size:12.5px; color:var(--muted); margin-bottom:6px; font-weight:600; }
.field input, .field select, .field textarea{
  width:100%;
  padding:12px 13px;
  border-radius:10px;
  border:1.5px solid var(--border);
  background: var(--bg);
  color:var(--text);
  font-size:15px;
  outline:none;
  transition: border-color .15s;
}
.field input:focus, .field select:focus, .field textarea:focus{ border-color: var(--navy); }
[data-theme="dark"] .field input:focus, [data-theme="dark"] .field select:focus{ border-color: var(--gold); }
.field-row{ display:grid; grid-template-columns:1fr 1fr; gap:12px; }
.field .hint{ font-size:11.5px; color:var(--muted); margin-top:5px; }
.field .error-text{ font-size:12px; color:var(--danger); margin-top:5px; display:none; }

/* ---------- Auth screen ---------- */
.auth-wrap{
  min-height:100vh; min-height:100dvh;
  display:flex; flex-direction:column; align-items:center; justify-content:center;
  padding:28px 20px calc(28px + var(--safe-bottom));
  background: radial-gradient(circle at 30% 0%, var(--navy-3), var(--navy) 60%);
}
.auth-logo{
  width:74px; height:74px; border-radius:50%;
  background: var(--gold);
  color:var(--navy);
  display:flex; align-items:center; justify-content:center;
  font-weight:800; font-size:26px; font-family:'Inter',sans-serif;
  margin-bottom:16px;
  box-shadow: var(--shadow-lg);
}
.auth-title{ color:#fff; font-size:22px; font-weight:800; margin-bottom:2px; text-align:center;}
.auth-sub{ color: rgba(255,255,255,.65); font-size:13.5px; margin-bottom:26px; text-align:center; }
.auth-card{
  width:100%; max-width:380px;
  background: var(--card);
  border-radius: 18px;
  padding:24px 20px;
  box-shadow: var(--shadow-lg);
}
.auth-tabs{ display:flex; background:var(--bg); border-radius:11px; padding:4px; margin-bottom:18px; }
.auth-tab{ flex:1; text-align:center; padding:9px; border-radius:8px; font-size:13.5px; font-weight:600; color:var(--muted); cursor:pointer; }
.auth-tab.active{ background:var(--card); color:var(--navy); box-shadow:var(--shadow); }
[data-theme="dark"] .auth-tab.active{ color: var(--gold-light); }
.auth-form{ display:none; }
.auth-form.active{ display:block; }
.auth-msg{ font-size:12.5px; padding:10px 12px; border-radius:9px; margin-bottom:14px; display:none; }
.auth-msg.show{ display:block; }
.auth-msg.error{ background:var(--danger-bg); color:var(--danger); }
.auth-msg.info{ background:var(--success-bg); color:var(--success); }
.config-warning{
  max-width:380px; width:100%;
  background:#3a2a12; color:#f4d58a;
  border:1px solid #5c4419;
  border-radius:12px; padding:14px 16px; font-size:12.5px; line-height:1.6;
  margin-top:16px;
}

/* ---------- Entry list ---------- */
.entry-item{
  display:flex; align-items:center; gap:12px;
  padding:13px 14px;
  background:var(--card);
  border:1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom:9px;
  cursor:pointer;
}
.entry-avatar{
  width:40px; height:40px; border-radius:50%;
  background: var(--navy);
  color:#fff;
  display:flex; align-items:center; justify-content:center;
  font-weight:700; font-size:15px; flex-shrink:0;
}
.entry-main{ flex:1; min-width:0; }
.entry-name{ font-weight:700; font-size:14.5px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.entry-desc{ font-size:12.5px; color:var(--muted); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; margin-top:2px; }
.entry-date{ font-size:11px; color:var(--muted); margin-top:2px; }
.entry-amounts{ text-align:end; flex-shrink:0; }
.entry-bill{ font-weight:700; font-size:14.5px; font-family:'Inter',sans-serif; }
.entry-profit{ font-size:11.5px; color:var(--success); font-weight:600; font-family:'Inter',sans-serif; }

.section-title{ font-size:13px; font-weight:700; color:var(--muted); text-transform:uppercase; letter-spacing:.5px; margin:18px 0 10px; }
.empty-state{ text-align:center; padding:40px 20px; color:var(--muted); }
.empty-state .ic{ font-size:40px; margin-bottom:10px; opacity:.5; }

/* ---------- Filters ---------- */
.filter-row{ display:flex; gap:8px; margin-bottom:14px; overflow-x:auto; padding-bottom:2px; }
.chip{
  padding:8px 14px; border-radius:20px; background:var(--card); border:1.5px solid var(--border);
  font-size:12.5px; font-weight:600; color:var(--muted); white-space:nowrap; cursor:pointer; flex-shrink:0;
}
.chip.active{ background:var(--navy); color:#fff; border-color:var(--navy); }
.search-box{ position:relative; margin-bottom:12px; }
.search-box input{ padding-inline-start:38px; }
.search-box .ic{ position:absolute; inset-inline-start:12px; top:50%; transform:translateY(-50%); color:var(--muted); }

/* ---------- Modal / Sheet ---------- */
.overlay{
  position:fixed; inset:0; background:rgba(10,18,28,.5);
  display:none; align-items:flex-end; justify-content:center;
  z-index:100; backdrop-filter: blur(2px);
}
.overlay.show{ display:flex; }
.sheet{
  width:100%; max-width:520px;
  background:var(--card);
  border-radius: 20px 20px 0 0;
  padding:18px 18px calc(18px + var(--safe-bottom));
  max-height:88vh; overflow-y:auto;
  animation: slideUp .25s ease;
}
@keyframes slideUp{ from{ transform: translateY(24px); opacity:0; } to{ transform:none; opacity:1; } }
.sheet-handle{ width:40px; height:4px; background:var(--border); border-radius:3px; margin:0 auto 14px; }
.sheet-title{ font-size:17px; font-weight:800; margin-bottom:16px; display:flex; align-items:center; justify-content:space-between; }
.sheet-actions{ display:flex; gap:10px; margin-top:6px; }

.overlay.center{ align-items:center; padding:20px; }
.overlay.center .sheet{ border-radius:18px; max-width:400px; }

/* ---------- Toast ---------- */
.toast{
  position:fixed; bottom: calc(90px + var(--safe-bottom)); left:50%; transform:translateX(-50%) translateY(20px);
  background: var(--navy); color:#fff;
  padding:11px 20px; border-radius:30px; font-size:13.5px;
  box-shadow: var(--shadow-lg);
  z-index:200; opacity:0; pointer-events:none; transition: all .25s ease;
}
.toast.show{ opacity:1; transform:translateX(-50%) translateY(0); }

/* ---------- Loader ---------- */
.loader-screen{ display:flex; align-items:center; justify-content:center; min-height:100vh; min-height:100dvh; background:var(--navy); }
.spinner{ width:40px; height:40px; border-radius:50%; border:3.5px solid rgba(255,255,255,.25); border-top-color: var(--gold); animation: spin .8s linear infinite; }
@keyframes spin{ to{ transform:rotate(360deg); } }

/* ---------- Charts ---------- */
.chart-wrap{ position:relative; height:220px; }
.legend-row{ display:flex; flex-wrap:wrap; gap:10px; margin-top:10px; font-size:12px; color:var(--muted); }
.legend-dot{ display:inline-block; width:9px; height:9px; border-radius:50%; margin-inline-end:5px; }

/* ---------- Receipt ---------- */
.receipt{ background:#fff; color:#1a1a1a; border-radius:12px; padding:20px; font-family:'Inter',sans-serif; }
.receipt-header{ text-align:center; border-bottom:2px dashed #ddd; padding-bottom:14px; margin-bottom:14px; }
.receipt-shop{ font-weight:800; font-size:18px; color:var(--navy); }
.receipt-row{ display:flex; justify-content:space-between; padding:6px 0; font-size:13.5px; border-bottom:1px solid #f0f0f0; }
.receipt-row.total{ font-weight:800; font-size:15px; border-bottom:none; border-top:2px dashed #ddd; margin-top:6px; padding-top:12px; }
.receipt-footer{ text-align:center; margin-top:16px; font-size:11.5px; color:#888; }

/* ---------- Customer card ---------- */
.customer-item{
  display:flex; align-items:center; gap:12px; padding:13px 14px;
  background:var(--card); border:1px solid var(--border); border-radius:var(--radius-sm); margin-bottom:9px; cursor:pointer;
}
.customer-item .entry-main{ flex:1; }
.customer-count{ font-size:11.5px; color:var(--muted); }

/* ---------- Settings ---------- */
.settings-row{
  display:flex; align-items:center; justify-content:space-between;
  padding:14px 4px; border-bottom:1px solid var(--border);
}
.settings-row:last-child{ border-bottom:none; }
.settings-label{ font-size:14.5px; font-weight:600; }
.settings-desc{ font-size:12px; color:var(--muted); margin-top:2px; }

.switch{ position:relative; width:46px; height:26px; }
.switch input{ opacity:0; width:0; height:0; }
.switch .slider{
  position:absolute; inset:0; background:var(--border); border-radius:20px; cursor:pointer; transition:.2s;
}
.switch .slider:before{
  content:""; position:absolute; height:20px; width:20px; left:3px; top:3px; background:#fff; border-radius:50%; transition:.2s;
  box-shadow:0 1px 3px rgba(0,0,0,.3);
}
.switch input:checked + .slider{ background: var(--navy); }
body[dir="rtl"] .switch input:checked + .slider:before{ transform: translateX(-20px); }
body[dir="ltr"] .switch input:checked + .slider:before{ transform: translateX(20px); }

.category-badge{
  display:inline-block; font-size:10.5px; font-weight:700; padding:2px 8px; border-radius:20px;
  background: var(--bg); color:var(--muted); border:1px solid var(--border); margin-top:4px;
}

/* Print styles for receipts / reports.
   #print-area is a hidden (display:none) element at the end of <body>;
   we fill it with the printable HTML and call window.print(). */
#print-area{ display:none; }
.print-report table{ width:100%; border-collapse:collapse; font-size:12px; }
.print-report th, .print-report td{ padding:6px 8px; border-bottom:1px solid #ddd; text-align:start; }
.print-report th{ background:#f4f6f8; }
.print-report .rpt-header{ text-align:center; margin-bottom:16px; }
.print-report .rpt-shop{ font-size:19px; font-weight:800; color:#0f2b46; }
.print-report .rpt-meta{ font-size:11.5px; color:#666; margin-top:4px; }
.print-report .rpt-summary{ display:flex; gap:14px; justify-content:center; margin:16px 0; flex-wrap:wrap; }
.print-report .rpt-summary div{ text-align:center; }
.print-report .rpt-summary .lbl{ font-size:10.5px; color:#888; }
.print-report .rpt-summary .val{ font-size:15px; font-weight:800; color:#0f2b46; }

@media print{
  body *{ visibility:hidden; }
  #print-area, #print-area *{ visibility:visible; }
  #print-area{ display:block !important; position:absolute; inset-inline-start:0; top:0; width:100%; background:#fff; color:#1a1a1a; }
  .bottom-nav, .topbar, .fab, .overlay{ display:none !important; }
}

@media (min-width:640px){
  .stat-grid{ grid-template-columns:1fr 1fr 1fr; }
  .stat-card.hero{ grid-column: span 1; }
}
