/* Shared UI kit: clean, calm, professional. One accent colour (set --accent), status colours only for meaning. */
:root {
  --accent: #1d4ed8;
  --accent-600: color-mix(in srgb, var(--accent) 88%, black);
  --accent-50: color-mix(in srgb, var(--accent) 7%, white);
  --accent-100: color-mix(in srgb, var(--accent) 14%, white);
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --border: #e5e7eb;
  --border-strong: #d1d5db;
  --text: #111827;
  --text-2: #4b5563;
  --text-3: #6b7280;
  --ok: #15803d;
  --ok-bg: #ecfdf3;
  --warn: #b45309;
  --warn-bg: #fff7ed;
  --err: #b91c1c;
  --err-bg: #fef2f2;
  --info-bg: #eff6ff;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06);
  --shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 4px 16px rgba(16, 24, 40, .06);
  --shadow-lg: 0 12px 40px rgba(16, 24, 40, .16);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", Arial, sans-serif;
  --font-ur: "Noto Nastaliq Urdu", "Noto Naskh Arabic", var(--font);
  --topbar-h: 60px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font); font-size: 15px; line-height: 1.5; color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
body.lang-ur .i18n { font-family: var(--font-ur); }
#app { overflow-x: clip; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; letter-spacing: -0.01em; }
h1 { font-size: 26px; font-weight: 700; }
h2 { font-size: 19px; font-weight: 650; }
h3 { font-size: 16px; font-weight: 600; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; }
svg[aria-hidden] { width: 18px; height: 18px; flex: none; vertical-align: middle; }
.stat .label svg { width: 15px; height: 15px; }
.muted { color: var(--text-3); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.num { font-variant-numeric: tabular-nums; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }
.row { display: flex; align-items: center; gap: 12px; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.grow { flex: 1; min-width: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- layout ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40; height: var(--topbar-h); background: var(--surface);
  border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 28px; padding: 0 24px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; color: var(--text); white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 9px; background: var(--accent); color: #fff; display: grid; place-items: center;
  font-weight: 800; font-size: 15px; flex: none;
}
.brand img { height: 32px; width: auto; max-width: 140px; object-fit: contain; }
.nav { display: flex; gap: 4px; flex: 1; }
.nav a {
  color: var(--text-2); padding: 8px 12px; border-radius: 8px; font-weight: 500; font-size: 14.5px; display: flex; align-items: center; gap: 7px;
}
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a.active { color: var(--accent); background: var(--accent-50); }
.nav a svg { width: 17px; height: 17px; }
.profile { position: relative; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; background: var(--accent-100); color: var(--accent-600);
  display: grid; place-items: center; font-weight: 700; font-size: 13px; border: 0; cursor: pointer;
}
.menu {
  position: absolute; right: 0; top: 44px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: var(--shadow-lg); min-width: 220px; padding: 6px; z-index: 50;
}
.menu .menu-head { padding: 8px 10px 10px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.menu button, .menu a {
  display: flex; width: 100%; gap: 8px; align-items: center; padding: 8px 10px; border: 0; background: none; border-radius: 6px;
  cursor: pointer; color: var(--text); font-size: 14px; text-align: left;
}
.menu button:hover, .menu a:hover { background: var(--surface-2); text-decoration: none; }
.page { max-width: 1180px; margin: 0 auto; padding: 28px 24px 64px; }
.page.wide { max-width: 1440px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head p { color: var(--text-2); margin-top: 6px; }
.demo-banner {
  height: 32px; line-height: 20px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
  background: #fffbeb; border-bottom: 1px solid #fde68a; color: #92400e; font-size: 13px; text-align: center; padding: 6px 12px;
}

/* ---------- cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-pad { padding: 20px; }
.card-head { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card-body { padding: 20px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat { padding: 18px 20px; }
.stat .label { color: var(--text-3); font-size: 13px; font-weight: 500; display: flex; align-items: center; gap: 6px; }
.stat .value { font-size: 30px; font-weight: 700; letter-spacing: -0.02em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat .sub { color: var(--text-3); font-size: 12.5px; margin-top: 2px; }
.stat.attention .value { color: var(--warn); }
.stat.good .value { color: var(--ok); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 16px; border-radius: 9px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font-weight: 600; font-size: 14.5px;
  cursor: pointer; white-space: nowrap; transition: background .12s, border-color .12s, box-shadow .12s; text-decoration: none !important;
}
.btn:hover { background: var(--surface-2); }
.btn:focus-visible, .chip:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid var(--accent-100); outline-offset: 1px;
}
.btn svg { width: 17px; height: 17px; flex: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.btn-primary:hover { background: var(--accent-600); border-color: var(--accent-600); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-danger { color: var(--err); }
.btn-danger:hover { background: var(--err-bg); border-color: #fecaca; }
.btn-sm { height: 32px; padding: 0 11px; font-size: 13.5px; border-radius: 7px; }
.btn-lg { height: 48px; padding: 0 22px; font-size: 15.5px; border-radius: 11px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.icon-btn { width: 36px; padding: 0; }
.icon-btn.btn-sm { width: 32px; }
kbd {
  font-family: ui-monospace, monospace; font-size: 11px; border: 1px solid var(--border-strong); border-bottom-width: 2px;
  border-radius: 4px; padding: 0 5px; background: var(--surface); color: var(--text-2);
}
.btn-primary kbd { background: rgba(255,255,255,.15); border-color: rgba(255,255,255,.35); color: #fff; }

/* ---------- forms ---------- */
label.field { display: flex; flex-direction: column; gap: 6px; font-size: 13.5px; font-weight: 550; color: var(--text-2); }
.input, select.input, textarea.input {
  height: 40px; padding: 0 12px; border: 1px solid var(--border-strong); border-radius: 9px; background: var(--surface);
  font-size: 14.5px; color: var(--text); width: 100%; transition: border-color .12s, box-shadow .12s;
}
textarea.input { height: auto; padding: 10px 12px; min-height: 90px; resize: vertical; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-100); outline: none; }
.input::placeholder { color: #9ca3af; }
.input-icon { position: relative; }
.input-icon svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 17px; height: 17px; color: var(--text-3); }
.input-icon .input { padding-left: 36px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--border-strong); background: var(--surface); padding: 7px 14px; border-radius: 999px; cursor: pointer;
  font-size: 14px; font-weight: 500; color: var(--text-2); display: inline-flex; align-items: center; gap: 6px;
}
.chip:hover { border-color: var(--accent); color: var(--text); }
.chip.active { background: var(--accent-50); border-color: var(--accent); color: var(--accent-600); font-weight: 600; }
.switch { position: relative; width: 40px; height: 23px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: #d1d5db; border-radius: 999px; transition: .15s; cursor: pointer; }
.switch span::before { content: ""; position: absolute; width: 17px; height: 17px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::before { transform: translateX(17px); }
.radio-card {
  display: flex; gap: 12px; padding: 14px 16px; border: 1px solid var(--border-strong); border-radius: 10px; cursor: pointer; align-items: flex-start;
}
.radio-card:has(input:checked) { border-color: var(--accent); background: var(--accent-50); }
.radio-card input { margin-top: 3px; accent-color: var(--accent); }

/* ---------- badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 12.5px; font-weight: 600;
  background: #f3f4f6; color: var(--text-2); white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85; }
.badge.plain::before { display: none; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.err { background: var(--err-bg); color: var(--err); }
.badge.info { background: var(--accent-50); color: var(--accent-600); }
.badge.neutral { background: #f3f4f6; color: var(--text-3); }
.badge.pulse::before { animation: pulse 1.1s infinite; }
@keyframes pulse { 50% { opacity: .25; } }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  text-align: left; font-weight: 600; color: var(--text-3); font-size: 12.5px; text-transform: uppercase; letter-spacing: .04em;
  padding: 10px 14px; border-bottom: 1px solid var(--border); background: var(--surface-2); position: sticky; top: 0; white-space: nowrap;
}
.table td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover td { background: var(--surface-2); }
.table.zebra tbody tr:nth-child(even) td { background: #fbfbfc; }

/* ---------- alerts / tips ---------- */
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 11px 14px; border-radius: 10px; font-size: 14px; border: 1px solid; }
.alert svg { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.alert.warn { background: var(--warn-bg); border-color: #fed7aa; color: #9a3412; }
.alert.err { background: var(--err-bg); border-color: #fecaca; color: #991b1b; }
.alert.ok { background: var(--ok-bg); border-color: #bbf7d0; color: #166534; }
.alert.info { background: var(--accent-50); border-color: var(--accent-100); color: var(--accent-600); }
.tip { display: flex; gap: 8px; align-items: center; color: var(--text-3); font-size: 13px; }
.tip svg { width: 15px; height: 15px; color: var(--accent); flex: none; }

/* ---------- progress / skeleton ---------- */
.progress { height: 10px; background: #eef0f3; border-radius: 999px; overflow: hidden; }
.progress > div { height: 100%; background: var(--accent); border-radius: 999px; transition: width .4s ease; }
.progress.ok > div { background: var(--ok); }
.skeleton { background: linear-gradient(90deg, #eef0f3 25%, #f6f7f9 37%, #eef0f3 63%); background-size: 400% 100%; animation: shimmer 1.3s infinite; border-radius: 8px; }
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
.spinner { width: 18px; height: 18px; border: 2.5px solid var(--accent-100); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- empty state ---------- */
.empty { text-align: center; padding: 48px 20px; color: var(--text-2); }
.empty .empty-icon { width: 52px; height: 52px; border-radius: 14px; background: var(--accent-50); color: var(--accent); display: grid; place-items: center; margin: 0 auto 14px; }
.empty .empty-icon svg { width: 26px; height: 26px; }
.empty h3 { color: var(--text); margin-bottom: 6px; }
.empty p { max-width: 420px; margin: 0 auto 16px; }

/* ---------- toast / modal ---------- */
.toasts { position: fixed; bottom: 20px; right: 20px; z-index: 100; display: flex; flex-direction: column; gap: 10px; }
.toast {
  background: #111827; color: #fff; padding: 12px 16px; border-radius: 10px; box-shadow: var(--shadow-lg); font-size: 14px;
  display: flex; gap: 10px; align-items: center; max-width: 380px; animation: toastIn .2s ease;
}
.toast svg { width: 18px; height: 18px; flex: none; }
.toast.ok svg { color: #4ade80; } .toast.err svg { color: #f87171; } .toast.warn svg { color: #fbbf24; }
@keyframes toastIn { from { transform: translateY(10px); opacity: 0; } }
.modal-bg { position: fixed; inset: 0; background: rgba(17, 24, 39, .45); z-index: 90; display: grid; place-items: center; padding: 16px; animation: fade .15s; }
.modal { background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-lg); width: 100%; max-width: 460px; max-height: 90vh; overflow: auto; }
.modal-head { padding: 18px 20px 0; }
.modal-body { padding: 14px 20px; }
.modal-foot { padding: 12px 20px 18px; display: flex; justify-content: flex-end; gap: 10px; }
@keyframes fade { from { opacity: 0; } }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; overflow-x: auto; }
.tabs button {
  border: 0; background: none; padding: 10px 14px; font-weight: 550; color: var(--text-3); cursor: pointer; border-bottom: 2px solid transparent;
  margin-bottom: -1px; white-space: nowrap; font-size: 14.5px;
}
.tabs button.active { color: var(--accent); border-bottom-color: var(--accent); }
.seg { display: inline-flex; background: #eef0f3; border-radius: 9px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: none; padding: 6px 12px; border-radius: 7px; font-size: 13.5px; font-weight: 550; color: var(--text-2); cursor: pointer; }
.seg button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

/* ---------- auth ---------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: var(--bg); }
.auth-card { width: 100%; max-width: 410px; padding: 32px 28px; }
.auth-card .brand { justify-content: center; font-size: 20px; margin-bottom: 22px; }
.auth-card h1 { font-size: 22px; text-align: center; }
.auth-card .lead { text-align: center; color: var(--text-2); margin: 6px 0 22px; }
.divider { display: flex; align-items: center; gap: 12px; color: var(--text-3); font-size: 13px; margin: 18px 0; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.privacy-line { display: flex; gap: 7px; align-items: center; justify-content: center; color: var(--text-3); font-size: 13px; margin-top: 18px; text-align: center; }
.privacy-line svg { width: 15px; height: 15px; color: var(--ok); flex: none; }

/* ---------- mobile ---------- */
.bottom-nav { display: none; }
@media (max-width: 900px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  body { font-size: 15px; }
  .topbar { padding: 0 16px; gap: 12px; }
  .topbar .nav { display: none; }
  .topbar .spacer { flex: 1; }
  .page { padding: 18px 16px 96px; }
  h1 { font-size: 22px; }
  .grid-2 { grid-template-columns: 1fr; }
  .stat .value { font-size: 24px; }
  .bottom-nav {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 40; background: var(--surface);
    border-top: 1px solid var(--border); padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .bottom-nav a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; color: var(--text-3); padding: 4px 0; }
  .bottom-nav a svg { width: 21px; height: 21px; }
  .bottom-nav a.active { color: var(--accent); }
  .bottom-nav a:hover { text-decoration: none; }
  .toasts { left: 16px; right: 16px; bottom: 80px; }
  .hide-sm { display: none !important; }
  .table td, .table th { padding: 10px; }
}
