/* =============================================
   QARZ DAFTAR — Otashenko design system
   Dark is the default; [data-theme="light"] overrides.
   Tokens mirror otashenko.uz so both sites read as one family.
   ============================================= */

/* ---- DEFAULT (Dark Mode) ---- */
:root {
  --bg:           #0D0D0D;
  --bg-2:         #161616;
  --bg-card:      #111111;
  --text:         #E8E8E8;
  --text-2:       #888888;
  --text-3:       #444444;
  --border:       #252525;
  --accent:       #E8E8E8;
  --accent-2:     #888888;
  --accent-hover: #FFFFFF;

  --shadow-sm:    0 2px 8px rgba(0,0,0,0.4);
  --shadow-md:    0 6px 24px rgba(0,0,0,0.5);
  --shadow-lg:    0 16px 48px rgba(0,0,0,0.6);

  --radius-sm:    10px;
  --radius-md:    16px;
  --radius-lg:    24px;
  --radius-xl:    100px;

  --font-display: 'Fraunces', Georgia, serif;
  --font-body:    'DM Sans', system-ui, sans-serif;
  --transition:   0.22s cubic-bezier(0.4,0,0.2,1);

  /* Money direction. The chrome stays monochrome like otashenko; colour is
     reserved for the one thing that must never be misread — which way the
     money moves. */
  --pos:       #10B981;
  --pos-soft:  rgba(16,185,129,0.12);
  --pos-line:  rgba(16,185,129,0.28);

  --neg:       #EF4444;
  --neg-soft:  rgba(239,68,68,0.12);
  --neg-line:  rgba(239,68,68,0.28);

  --warn:      #F59E0B;
  --warn-soft: rgba(245,158,11,0.12);
  --warn-line: rgba(245,158,11,0.28);

  --sidebar-w: 248px;
  --topbar-h:  64px;
}

/* ---- LIGHT MODE overrides (must come AFTER :root) ---- */
[data-theme="light"] {
  --bg:           #FFFFFF;
  --bg-2:         #F5F5F4;
  --bg-card:      #FFFFFF;
  --text:         #374151;
  --text-2:       #6B7280;
  --text-3:       #9CA3AF;
  --border:       #E5E7EB;
  --accent:       #374151;
  --accent-2:     #6B7280;
  --accent-hover: #111827;

  --shadow-sm:    0 2px 8px rgba(0,0,0,0.06);
  --shadow-md:    0 6px 24px rgba(0,0,0,0.08);
  --shadow-lg:    0 16px 48px rgba(0,0,0,0.10);

  --pos:       #059669;
  --pos-soft:  rgba(5,150,105,0.10);
  --pos-line:  rgba(5,150,105,0.25);

  --neg:       #DC2626;
  --neg-soft:  rgba(220,38,38,0.09);
  --neg-line:  rgba(220,38,38,0.24);

  --warn:      #D97706;
  --warn-soft: rgba(217,119,6,0.11);
  --warn-line: rgba(217,119,6,0.26);
}

/* --------------------------------------------------------------- base */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

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

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  font-size: 15px;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

a { text-decoration: none; color: inherit; }
ul { list-style: none; }

h1, h2, h3, h4 { font-weight: 600; line-height: 1.3; }
h1 { font-family: var(--font-display); font-size: 26px; letter-spacing: -0.01em; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }

p { margin: 0 0 0.8em; }
p:last-child { margin-bottom: 0; }

::selection { background: var(--text); color: var(--bg); }

.num { font-variant-numeric: tabular-nums; }

/* --------------------------------------------------------------- layout */

.shell { display: flex; min-height: 100vh; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 60;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  height: var(--topbar-h);
  padding: 0 22px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-brand-mark {
  width: 30px; height: 30px;
  border-radius: var(--radius-sm);
  background: var(--text);
  color: var(--bg);
  display: grid; place-items: center;
  font-weight: 800; font-size: 12px;
  letter-spacing: -0.5px;
  flex-shrink: 0;
  transition: background var(--transition);
}

.sidebar-brand-name {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 600;
  color: var(--text);
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-section {
  padding: 16px 10px 6px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-3);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: 13.5px;
  font-weight: 500;
  transition: all var(--transition);
}
.nav-item:hover { background: var(--bg-2); color: var(--text); }
.nav-item.active { background: var(--bg-2); color: var(--text); font-weight: 600; }
.nav-item svg { flex-shrink: 0; }

.nav-item-badge {
  margin-left: auto;
  min-width: 19px;
  height: 19px;
  padding: 0 6px;
  border-radius: var(--radius-xl);
  background: var(--neg);
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  display: grid;
  place-items: center;
}

.sidebar-foot {
  border-top: 1px solid var(--border);
  padding: 12px;
  flex-shrink: 0;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  transition: background var(--transition);
}
.sidebar-user:hover { background: var(--bg-2); }
.sidebar-user-meta { min-width: 0; }
.sidebar-user-name {
  display: block;
  font-size: 13px; font-weight: 600; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar-user-phone { display: block; font-size: 11.5px; color: var(--text-3); }

/* main column */

.main {
  flex: 1;
  min-width: 0;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 28px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.topbar-title { font-size: 14px; font-weight: 600; color: var(--text); }
.topbar-spacer { flex: 1; }

.icon-btn {
  position: relative;
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
  transition: all 0.15s;
}
.icon-btn:hover { background: var(--bg-2); color: var(--text); border-color: var(--text-3); }

.icon-btn-dot {
  position: absolute;
  top: -5px; right: -5px;
  min-width: 17px; height: 17px;
  padding: 0 4px;
  border-radius: var(--radius-xl);
  background: var(--neg);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: grid; place-items: center;
  border: 2px solid var(--bg);
}

.content {
  flex: 1;
  padding: 28px;
  max-width: 1180px;
  width: 100%;
}

.page-head {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}
.page-head-text { flex: 1; min-width: 200px; }
.page-sub { color: var(--text-2); font-size: 13.5px; margin-top: 4px; }

/* --------------------------------------------------------------- menu */

.menu { position: relative; }

.menu-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 176px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: 6px;
  z-index: 70;
}
.menu-panel[hidden] { display: none; }

.menu-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 9px 11px;
  border: 0;
  background: none;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font: inherit;
  font-size: 13.5px;
  text-align: left;
  cursor: pointer;
  transition: all 0.15s;
}
.menu-item:hover { background: var(--bg-2); color: var(--text); }
.menu-item.active { color: var(--text); font-weight: 600; }
.menu-sep { height: 1px; background: var(--border); margin: 6px 0; }

/* --------------------------------------------------------------- cards */

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  color: var(--text-2);
}
.card-head h2 { font-size: 14px; color: var(--text); }
.card-head-spacer { flex: 1; }

.card-body { padding: 20px; }
.card-body-tight { padding: 10px; }

.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-main { grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); }

/* --------------------------------------------------------------- stats */

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(205px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}

.stat {
  position: relative;
  overflow: hidden;
  padding: 18px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: border-color var(--transition);
}
.stat:hover { border-color: var(--text-3); }

.stat::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 2px;
  background: var(--border);
}
.stat-pos::before   { background: var(--pos); }
.stat-neg::before   { background: var(--neg); }
.stat-warn::before  { background: var(--warn); }
.stat-brand::before { background: var(--text-3); }

.stat-label {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 10px;
  font-weight: 700;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.stat-value {
  margin-top: 9px;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
  word-break: break-word;
}
.stat-value.pos { color: var(--pos); }
.stat-value.neg { color: var(--neg); }

.stat-foot { margin-top: 5px; font-size: 12px; color: var(--text-3); }

/* --------------------------------------------------------------- badges */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 11px;
  border-radius: var(--radius-xl);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.2px;
  white-space: nowrap;
  border: 1px solid transparent;
}
.badge-pos     { background: var(--pos-soft);  color: var(--pos);  border-color: var(--pos-line); }
.badge-neg     { background: var(--neg-soft);  color: var(--neg);  border-color: var(--neg-line); }
.badge-warn    { background: var(--warn-soft); color: var(--warn); border-color: var(--warn-line); }
.badge-brand   { background: var(--bg-2);      color: var(--text); border-color: var(--border); }
.badge-neutral { background: transparent;      color: var(--text-3); border-color: var(--border); }

.badge-dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; }

/* --------------------------------------------------------------- buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 22px;
  border: 1.5px solid transparent;
  border-radius: var(--radius-xl);
  background: var(--text);
  color: var(--bg);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition);
}
.btn:hover { background: var(--accent-hover); transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; box-shadow: none; }

.btn-ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}
.btn-ghost:hover { background: transparent; border-color: var(--text); box-shadow: none; }

.btn-pos { background: var(--pos); color: #fff; }
.btn-pos:hover { background: var(--pos); filter: brightness(1.1); }

.btn-neg { background: var(--neg); color: #fff; }
.btn-neg:hover { background: var(--neg); filter: brightness(1.1); }

.btn-danger-ghost {
  background: transparent;
  color: var(--neg);
  border-color: var(--neg-line);
}
.btn-danger-ghost:hover {
  background: var(--neg-soft);
  border-color: var(--neg);
  box-shadow: none;
  transform: none;
}

.btn-sm { padding: 8px 18px; font-size: 13px; }
.btn-block { width: 100%; }

.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }

/* --------------------------------------------------------------- forms */

.field { margin-bottom: 18px; }

.label {
  display: block;
  margin-bottom: 7px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.input, .select, .textarea {
  width: 100%;
  padding: 12px 15px;
  background: var(--bg-2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  transition: all var(--transition);
}

.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--text-3);
  background: var(--bg-card);
}
.input::placeholder, .textarea::placeholder { color: var(--text-3); }

.textarea { resize: vertical; min-height: 88px; line-height: 1.6; }

.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 40px;
  cursor: pointer;
}

.hint { margin-top: 6px; font-size: 12px; color: var(--text-3); }
.error { margin-top: 6px; font-size: 12.5px; color: var(--neg); }

.input-group { display: flex; gap: 9px; }
.input-group .input { flex: 1; }

/* radio cards for debt direction */

.choice-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }

.choice {
  position: relative;
  display: block;
  padding: 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-2);
  cursor: pointer;
  transition: all var(--transition);
}
.choice:hover { border-color: var(--text-3); }
.choice input { position: absolute; opacity: 0; pointer-events: none; }

.choice-title {
  display: flex; align-items: center; gap: 9px;
  font-weight: 600; font-size: 14px; color: var(--text);
}
.choice-hint { display: block; margin-top: 4px; font-size: 12px; color: var(--text-3); }

.choice-pos:has(input:checked) { border-color: var(--pos); background: var(--pos-soft); }
.choice-pos:has(input:checked) .choice-title { color: var(--pos); }
.choice-neg:has(input:checked) { border-color: var(--neg); background: var(--neg-soft); }
.choice-neg:has(input:checked) .choice-title { color: var(--neg); }

/* --------------------------------------------------------------- avatar */

.avatar {
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  display: grid; place-items: center;
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--text-2);
  font-size: 12.5px;
  font-weight: 800;
  letter-spacing: -0.5px;
  flex-shrink: 0;
}
.avatar-sm { width: 28px; height: 28px; font-size: 11px; border-radius: 8px; }
.avatar-lg { width: 46px; height: 46px; font-size: 16px; border-radius: 12px; }
.avatar-pos { background: var(--pos-soft); color: var(--pos); border-color: var(--pos-line); }
.avatar-neg { background: var(--neg-soft); color: var(--neg); border-color: var(--neg-line); }

/* --------------------------------------------------------------- debt rows */

.debt-list { display: flex; flex-direction: column; }

.debt-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  transition: background 0.12s;
}
.debt-row:last-child { border-bottom: 0; }
.debt-row:hover { background: var(--bg-2); }

.debt-row-main { flex: 1; min-width: 0; }

.debt-row-name {
  display: block;
  font-weight: 600;
  font-size: 13.5px;
  color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.debt-row-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 5px;
  font-size: 12px;
  color: var(--text-3);
}

.debt-row-amount {
  text-align: right;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}
.debt-row-value { display: block; font-weight: 700; font-size: 14.5px; letter-spacing: -0.01em; color: var(--text); }
.debt-row-value.pos { color: var(--pos); }
.debt-row-value.neg { color: var(--neg); }
.debt-row-note { display: block; font-size: 11.5px; color: var(--text-3); margin-top: 3px; }

.contact-notes {
  display: block;
  margin-top: 8px;
  padding: 9px 13px;
  border-left: 2px solid var(--border);
  background: var(--bg-2);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--text-2);
  white-space: pre-wrap;
  word-break: break-word;
}

/* --------------------------------------------------------------- table */

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table {
  width: 100%;
  border-collapse: collapse;
  min-width: 680px;
}

.table thead tr { border-bottom: 1.5px solid var(--border); }

.table th {
  text-align: left;
  padding: 11px 16px;
  font-size: 10px;
  font-weight: 700;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 1px;
  white-space: nowrap;
}
.table th.right, .table td.right { text-align: right; }

.table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.12s;
  cursor: pointer;
}
.table tbody tr:last-child { border-bottom: none; }
.table tbody tr:hover { background: var(--bg-2); }

.table td {
  padding: 12px 16px;
  vertical-align: middle;
  font-size: 13.5px;
}

.cell-party { display: flex; align-items: center; gap: 11px; min-width: 0; }
.cell-party-name {
  font-size: 13.5px; font-weight: 600; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cell-party-phone { font-size: 11.5px; color: var(--text-3); }

.cell-amount { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.cell-amount.pos { color: var(--pos); }
.cell-amount.neg { color: var(--neg); }
.cell-muted { color: var(--text-3); font-size: 12.5px; white-space: nowrap; }

/* --------------------------------------------------------------- modal */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0,0,0,.65);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px;
  overflow-y: auto;
}
.modal-backdrop[hidden] { display: none; }

.modal {
  width: 100%;
  max-width: 560px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  margin: auto;
}

.modal-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
}
.modal-head h2 { font-family: var(--font-display); font-size: 18px; flex: 1; }

.modal-close {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
  transition: all 0.15s;
}
.modal-close:hover { color: var(--text); border-color: var(--text-3); background: var(--bg-2); }

.modal-body { padding: 22px; }

.modal-foot {
  display: flex;
  gap: 10px;
  padding: 18px 22px;
  border-top: 1px solid var(--border);
}
.modal-foot .btn { flex: 1; }

body.modal-open { overflow: hidden; }

/* --------------------------------------------------------------- progress */

.progress {
  height: 6px;
  border-radius: var(--radius-xl);
  background: var(--bg-2);
  border: 1px solid var(--border);
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  border-radius: var(--radius-xl);
  background: var(--pos);
  transition: width 0.4s var(--transition);
}
.progress-sm { height: 4px; }

.progress-legend {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 9px;
  font-size: 12px;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}

/* --------------------------------------------------------------- ranking */

.rank-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
}
.rank-row:last-child { border-bottom: 0; }
.rank-row-main { flex: 1; min-width: 0; }
.rank-row-name {
  display: block;
  font-size: 13px; font-weight: 600; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.rank-row-sub { display: block; font-size: 11.5px; color: var(--text-3); }
.rank-row-amount {
  font-weight: 700; font-size: 13.5px;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

/* --------------------------------------------------------------- messages */

.thread {
  display: flex;
  flex-direction: column;
  gap: 11px;
  padding: 20px;
  max-height: 420px;
  overflow-y: auto;
}

.bubble {
  max-width: 78%;
  padding: 10px 15px;
  border-radius: var(--radius-md);
  font-size: 13.5px;
  line-height: 1.55;
  word-wrap: break-word;
}
.bubble-mine {
  align-self: flex-end;
  background: var(--text);
  color: var(--bg);
  border-bottom-right-radius: 5px;
}
.bubble-theirs {
  align-self: flex-start;
  background: var(--bg-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-bottom-left-radius: 5px;
}
.bubble-time { margin-top: 4px; font-size: 10.5px; opacity: .6; }

.quick-replies { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }

.chip {
  padding: 6px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-xl);
  background: transparent;
  color: var(--text-2);
  font-family: var(--font-body);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}
.chip:hover { color: var(--text); border-color: var(--text); }

/* --------------------------------------------------------------- filters */

.filters {
  display: flex;
  gap: 9px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 16px;
}

.tab {
  padding: 8px 18px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-xl);
  background: transparent;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
  transition: all var(--transition);
}
.tab:hover { color: var(--text); border-color: var(--text); }
.tab.active { background: var(--text); border-color: var(--text); color: var(--bg); font-weight: 600; }

/* --------------------------------------------------------------- alerts */

.alert {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 14px 18px;
  border-radius: var(--radius-md);
  font-size: 13.5px;
  margin-bottom: 18px;
  border: 1px solid var(--border);
  background: var(--bg-2);
  color: var(--text-2);
}
.alert-success { background: var(--pos-soft);  color: var(--pos);  border-color: var(--pos-line); }
.alert-error   { background: var(--neg-soft);  color: var(--neg);  border-color: var(--neg-line); }
.alert-warn    { background: var(--warn-soft); color: var(--warn); border-color: var(--warn-line); }
.alert-info    { background: var(--bg-2);      color: var(--text-2); border-color: var(--border); }
.alert svg { flex-shrink: 0; margin-top: 2px; }

/* --------------------------------------------------------------- empty */

.empty {
  padding: 52px 24px;
  text-align: center;
  color: var(--text-3);
}
.empty-icon {
  width: 48px; height: 48px;
  margin: 0 auto 14px;
  border-radius: var(--radius-md);
  background: var(--bg-2);
  border: 1px solid var(--border);
  display: grid; place-items: center;
  color: var(--text-3);
}
.empty-title { font-size: 14px; font-weight: 600; color: var(--text-2); }
.empty-hint { font-size: 12.5px; margin-top: 5px; }

/* --------------------------------------------------------------- details */

.detail-list { display: flex; flex-direction: column; }
.detail-row {
  display: flex;
  align-items: baseline;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
}
.detail-row:last-child { border-bottom: 0; }
.detail-key {
  color: var(--text-3); flex-shrink: 0; min-width: 130px;
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.8px;
}
.detail-val { flex: 1; text-align: right; font-weight: 500; color: var(--text); }

/* --------------------------------------------------------------- pagination */

.pagination {
  display: flex;
  gap: 6px;
  justify-content: center;
  margin-top: 22px;
  flex-wrap: wrap;
}
.pagination a, .pagination span {
  min-width: 34px;
  height: 34px;
  padding: 0 10px;
  display: grid;
  place-items: center;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-2);
  font-size: 13px;
  transition: all 0.15s;
}
.pagination a:hover { color: var(--text); border-color: var(--text); }
.pagination .active span { background: var(--text); border-color: var(--text); color: var(--bg); font-weight: 600; }
.pagination .disabled span { opacity: .35; }

/* --------------------------------------------------------------- auth */

.auth-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px 20px 56px;
}

.auth-card { width: 100%; max-width: 400px; }

.auth-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 11px;
  margin-bottom: 26px;
}
.auth-brand-name {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 600;
  color: var(--text);
}

.auth-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 30px 28px;
}

.auth-title { font-family: var(--font-display); font-size: 22px; }
.auth-sub { color: var(--text-2); font-size: 13.5px; margin: 7px 0 24px; }

.auth-foot {
  margin-top: 20px;
  text-align: center;
  font-size: 13.5px;
  color: var(--text-2);
}
.auth-foot a { color: var(--text); font-weight: 600; border-bottom: 1px solid var(--text-3); }
.auth-foot a:hover { border-color: var(--text); }

.auth-lang {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-top: 20px;
}
.auth-lang a {
  padding: 6px 14px;
  border-radius: var(--radius-xl);
  font-size: 12.5px;
  color: var(--text-3);
  transition: all var(--transition);
}
.auth-lang a:hover { color: var(--text); background: var(--bg-2); }
.auth-lang a.active { background: var(--bg-2); color: var(--text); font-weight: 600; }

/* --------------------------------------------------------------- lookup */

.lookup-result {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border);
  background: var(--bg-2);
  margin-top: 12px;
}
.lookup-result.found   { border-color: var(--pos-line);  background: var(--pos-soft);  color: var(--pos); }
.lookup-result.missing { border-color: var(--warn-line); background: var(--warn-soft); color: var(--warn); }
.lookup-result-main { flex: 1; min-width: 0; }
.lookup-result-title { display: block; font-weight: 700; font-size: 13.5px; }
.lookup-result-sub { display: block; font-size: 12px; opacity: .85; margin-top: 3px; }

/* --------------------------------------------------------------- mobile */

.sidebar-scrim {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  z-index: 55;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
}

.mobile-only { display: none; }
.mobile-hide { display: inline; }
.bottom-nav { display: none; }

@media (max-width: 1024px) {
  :root { --sidebar-w: 230px; }
  .grid-main { grid-template-columns: minmax(0, 1fr); }
  .content { padding: 24px 20px; }
}

@media (max-width: 860px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform var(--transition);
    box-shadow: var(--shadow-lg);
  }
  body.nav-open .sidebar { transform: translateX(0); }
  body.nav-open .sidebar-scrim { opacity: 1; pointer-events: auto; }
  body.nav-open { overflow: hidden; }

  .main { margin-left: 0; }
  .mobile-only { display: inline-flex; }
  .mobile-hide { display: none; }
  .content { padding: 20px 16px 100px; }
  .topbar { padding: 0 16px; }

  h1 { font-size: 22px; }

  .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 11px; }
  .stat { padding: 15px 16px; }
  .stat-value { font-size: 18px; }

  .choice-grid { grid-template-columns: 1fr; }

  .debt-row { padding: 13px 16px; }
  .rank-row { padding: 11px 16px; }
  .card-head { padding: 14px 16px; }
  .card-body { padding: 16px; }

  .detail-key { min-width: 96px; }
  .bubble { max-width: 86%; }

  /* Keep the table readable without a horizontal scrollbar: drop the two
     columns that repeat information already visible in the amount cell. */
  .table { min-width: 0; }
  .table .col-optional { display: none; }
  .table th, .table td { padding: 11px 12px; }

  .modal-backdrop { padding: 0; align-items: stretch; }
  .modal {
    max-width: none;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    margin: auto 0 0;
  }

  /* Thumb-reachable primary navigation */
  .bottom-nav {
    position: fixed;
    inset: auto 0 0 0;
    z-index: 50;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    padding-bottom: env(safe-area-inset-bottom);
  }

  .bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 9px 2px 8px;
    color: var(--text-3);
    font-size: 9.5px;
    font-weight: 600;
    letter-spacing: 0.3px;
    text-transform: uppercase;
    position: relative;
    transition: color var(--transition);
  }
  .bottom-nav-item.active { color: var(--text); }

  .bottom-nav-fab {
    width: 38px; height: 38px;
    margin-top: -14px;
    border-radius: var(--radius-sm);
    background: var(--text);
    color: var(--bg);
    display: grid; place-items: center;
    box-shadow: var(--shadow-md);
  }

  .bottom-nav-dot {
    position: absolute;
    top: 5px;
    left: 50%;
    margin-left: 5px;
    min-width: 16px; height: 16px;
    padding: 0 4px;
    border-radius: var(--radius-xl);
    background: var(--neg);
    color: #fff;
    font-size: 9.5px;
    font-weight: 700;
    display: grid; place-items: center;
  }
}

@media (max-width: 420px) {
  .stats { grid-template-columns: minmax(0, 1fr); }
  .stat-value { font-size: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
