:root {
  --brand: #1f4e79;
  --brand-dark: #163a5b;
  --brand-light: #e8f0f8;
  --accent: #e07b22;
  --surface: #ffffff;
  --muted: #6c757d;
  --bg: #f4f6f9;
  --sidebar-w: 250px;
}

html, body { height: 100%; }
body {
  font-family: "Tajawal", "Segoe UI", Tahoma, sans-serif;
  background: var(--bg);
  color: #212529;
  font-size: 15px;
}
h1, h2, h3, h4, h5 { font-weight: 700; }
a { color: var(--brand); }
a:hover { color: var(--brand-dark); }

.btn-brand { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-brand:hover { background: var(--brand-dark); border-color: var(--brand-dark); color: #fff; }
.text-brand { color: var(--brand) !important; }
.bg-brand { background: var(--brand) !important; color: #fff; }
.bg-brand-light { background: var(--brand-light) !important; }

/* ---------- app shell */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w);
  background: var(--brand-dark);
  color: #fff;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}
.sidebar .brand {
  padding: 1.25rem 1.25rem 1rem;
  font-size: 1.15rem;
  font-weight: 700;
  border-bottom: 1px solid rgba(255,255,255,.12);
}
.sidebar .brand small { display: block; font-size: .75rem; font-weight: 400; opacity: .7; }
.sidebar .nav-link {
  color: rgba(255,255,255,.85);
  padding: .65rem 1.25rem;
  display: flex; align-items: center; gap: .65rem;
  border-inline-start: 3px solid transparent;
}
.sidebar .nav-link i { font-size: 1.1rem; width: 1.4rem; text-align: center; }
.sidebar .nav-link:hover { background: rgba(255,255,255,.07); color: #fff; }
.sidebar .nav-link.active { background: rgba(255,255,255,.12); color: #fff; border-inline-start-color: var(--accent); }
.sidebar .nav-section { padding: 1rem 1.25rem .35rem; font-size: .72rem; letter-spacing: .04em; opacity: .55; text-transform: uppercase; }
.sidebar .sidebar-footer { margin-top: auto; padding: 1rem 1.25rem; border-top: 1px solid rgba(255,255,255,.12); font-size: .85rem; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  background: var(--surface);
  border-bottom: 1px solid #e3e6ea;
  padding: .75rem 1.5rem;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
}
.topbar .page-title { font-size: 1.25rem; font-weight: 700; margin: 0; }
.content { padding: 1.5rem; flex: 1; }

@media (max-width: 991px) {
  .sidebar { position: fixed; inset-inline-start: -260px; top: 0; bottom: 0; z-index: 1040; transition: inset-inline-start .2s; }
  .sidebar.open { inset-inline-start: 0; }
  .sidebar-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 1035; display: none; }
  .sidebar-backdrop.show { display: block; }
}

/* ---------- cards & tables */
.card { border: 0; box-shadow: 0 1px 3px rgba(0,0,0,.06); border-radius: .6rem; }
.card-header { background: transparent; border-bottom: 1px solid #eef0f3; font-weight: 700; }
.stat-card .stat-value { font-size: 1.9rem; font-weight: 700; line-height: 1.1; }
.stat-card .stat-label { color: var(--muted); font-size: .85rem; }
.stat-card .stat-icon { font-size: 2rem; opacity: .25; }
.table > :not(caption) > * > * { padding: .6rem .75rem; vertical-align: middle; }
.table thead th { font-size: .8rem; color: var(--muted); font-weight: 700; white-space: nowrap; background: #fafbfc; }
.table-hover tbody tr:hover { background: var(--brand-light); }
.table td.actions { white-space: nowrap; width: 1%; }

/* ---------- details */
.kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: .75rem 1.25rem; }
.kv .k { font-size: .78rem; color: var(--muted); }
.kv .v { font-weight: 600; word-break: break-word; }
.kv .v.empty { color: #adb5bd; font-weight: 400; }

.record-card { border-inline-start: 4px solid var(--brand); }
.record-card.insurance { border-inline-start-color: #2a9d8f; }
.record-card.gazette { border-inline-start-color: #e9c46a; }
.record-card.seizure { border-inline-start-color: #e76f51; }
.record-card.court { border-inline-start-color: #6a4c93; }
.record-card.membership { border-inline-start-color: #1982c4; }
.record-card.agency { border-inline-start-color: #8ac926; }

.badge-cat { font-weight: 600; font-size: .75rem; }
.badge-cat.insurance { background: #2a9d8f; }
.badge-cat.gazette { background: #c9a227; }
.badge-cat.seizure { background: #e76f51; }
.badge-cat.court { background: #6a4c93; }
.badge-cat.membership { background: #1982c4; }
.badge-cat.agency { background: #6aa11b; }

.search-hero { background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%); color: #fff; border-radius: .75rem; padding: 2rem; }
.search-hero .form-control { font-size: 1.1rem; padding: .8rem 1rem; }

.result-item { transition: box-shadow .15s; }
.result-item:hover { box-shadow: 0 4px 14px rgba(0,0,0,.08); }

/* ---------- auth */
.auth-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #163a5b 0%, #1f4e79 60%, #2b6ca3 100%); }
.auth-card { width: 100%; max-width: 420px; border-radius: 1rem; }

/* ---------- misc */
.required::after { content: " *"; color: #dc3545; }
.text-ltr { direction: ltr; unicode-bidi: embed; display: inline-block; }
.import-preview { font-size: .8rem; }
.import-preview th select { min-width: 150px; font-size: .78rem; }
.sticky-actions { position: sticky; bottom: 0; background: var(--surface); padding: .75rem 0; border-top: 1px solid #e3e6ea; }
.nowrap { white-space: nowrap; }
.pagination { margin: 0; }
.print-only { display: none; }
@media print {
  .sidebar, .topbar, .no-print, .sticky-actions { display: none !important; }
  .content { padding: 0; }
  .print-only { display: block; }
  body { background: #fff; font-size: 12px; }
  .card { box-shadow: none; border: 1px solid #ddd; break-inside: avoid; }
}
