/* ========================================
   Brown Corp Admin PWA – Global Styles
   ======================================== */

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

/* ── DARK THEME (default) ──────────────── */
:root,
[data-theme="dark"] {
  --brown-dark: #3d1f00;
  --brown-mid: #5c2e00;
  --brown-light: #7a4520;
  --amber: #f5a623;
  --amber-light: #ffd07a;
  --amber-dark: #d4861a;
  --green: #4a7c3f;
  --green-light: #6aaf5e;
  --green-dark: #2e5228;
  --terracotta: #c4703a;
  --cream: #f5e6c8;
  --cream-dark: #edd5a8;

  --bg: #1a0e05;
  --surface: #241408;
  --surface-2: #2e1a0a;
  --surface-3: #3a2210;
  --border: rgba(245, 166, 35, 0.15);
  --border-hover: rgba(245, 166, 35, 0.35);

  --text-primary: #f5e6c8;
  --text-secondary: #c8a878;
  --text-muted: #8a6840;

  --status-active: #4a7c3f;
  --status-overdue: #c4703a;
  --status-paid: #f5a623;
  --status-defaulted: #8b1a1a;

  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 16px;
  --r-xl: 24px;

  --shadow-sm: 0 1px 4px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.6);
  --shadow-amber: 0 4px 20px rgba(245, 166, 35, 0.2);

  --sidebar-w: 240px;
  --topbar-h: 60px;

  /* Notif panel */
  --notif-bg: #1f1208;
  --notif-border: rgba(245, 166, 35, 0.18);
}

/* ── LIGHT THEME ───────────────────────── */
[data-theme="light"] {
  --bg: #f7f0e6;
  --surface: #ffffff;
  --surface-2: #f5eee3;
  --surface-3: #ede3d4;
  --border: rgba(61, 31, 0, 0.12);
  --border-hover: rgba(61, 31, 0, 0.28);

  --text-primary: #2a1500;
  --text-secondary: #5c3510;
  --text-muted: #9b6b3a;

  --shadow-sm: 0 1px 4px rgba(61, 31, 0, 0.1);
  --shadow-md: 0 4px 16px rgba(61, 31, 0, 0.12);
  --shadow-lg: 0 8px 32px rgba(61, 31, 0, 0.15);
  --shadow-amber: 0 4px 20px rgba(245, 166, 35, 0.25);

  --notif-bg: #fffaf3;
  --notif-border: rgba(61, 31, 0, 0.14);
}

/* ── BASE ──────────────────────────────── */
html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: "Nunito", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  transition:
    background 0.3s ease,
    color 0.3s ease;
}

/* ── SCROLLBAR ─────────────────────────── */
::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}
::-webkit-scrollbar-track {
  background: var(--surface);
}
::-webkit-scrollbar-thumb {
  background: var(--brown-light);
  border-radius: 99px;
}

/* ── LAYOUT ────────────────────────────── */
.app-shell {
  display: flex;
  min-height: 100vh;
}
.app-shell-inner {
  display: flex;
  width: 100%;
}

/* ── SIDEBAR ───────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  transition:
    transform 0.3s ease,
    background 0.3s ease;
}

.sidebar-logo {
  padding: 20px 18px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-logo img {
  width: 40px;
  height: 40px;
  object-fit: contain;
  border-radius: 8px;
}
.sidebar-logo-text .brand {
  font-size: 15px;
  font-weight: 800;
  color: var(--amber);
}
.sidebar-logo-text .sub {
  font-size: 10px;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
  overflow-y: auto;
}

.nav-section-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 12px 18px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  margin: 1px 8px;
  border-radius: var(--r-md);
  cursor: pointer;
  transition: all 0.18s ease;
  text-decoration: none;
  color: var(--text-secondary);
  font-size: 13.5px;
  font-weight: 600;
  user-select: none;
}
.nav-item:hover {
  background: var(--surface-2);
  color: var(--text-primary);
}
.nav-item.active {
  background: linear-gradient(135deg, var(--amber-dark), var(--amber));
  color: var(--brown-dark);
  box-shadow: var(--shadow-amber);
}
.nav-item .nav-icon {
  font-size: 15px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}
.nav-item .nav-badge {
  margin-left: auto;
  background: var(--status-overdue);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 99px;
}

.sidebar-footer {
  padding: 14px 18px;
  border-top: 1px solid var(--border);
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--r-md);
  background: var(--surface-2);
  cursor: pointer;
  transition: background 0.18s;
}
.user-chip:hover {
  background: var(--surface-3);
}
.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--amber), var(--terracotta));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 800;
  color: var(--brown-dark);
  flex-shrink: 0;
  overflow: hidden;
}
.user-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}
.user-info .user-name {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-primary);
}
.user-info .user-role {
  font-size: 10px;
  color: var(--text-muted);
}

/* ── MAIN CONTENT ──────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  position: relative;
}

/* ── TOP BAR ───────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 14px;
  transition: background 0.3s ease;
}
.topbar-title {
  font-size: 17px;
  font-weight: 800;
  color: var(--text-primary);
  flex: 1;
}
.topbar-title span {
  color: var(--amber);
}

.search-wrap {
  position: relative;
  flex: 0 0 260px;
}
.search-wrap input {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 7px 14px 7px 36px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  outline: none;
  transition: border-color 0.18s;
}
.search-wrap input:focus {
  border-color: var(--amber);
}
.search-wrap .search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 13px;
}

.topbar-cash {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 700;
  color: var(--green-light);
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 6px;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 15px;
  color: var(--text-secondary);
  transition: all 0.18s;
  position: relative;
  flex-shrink: 0;
}
.icon-btn:hover {
  background: var(--surface-3);
  color: var(--text-primary);
}

/* Notification badge */
.notif-count {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 17px;
  height: 17px;
  background: var(--status-overdue);
  color: #fff;
  font-size: 9px;
  font-weight: 800;
  border-radius: 99px;
  border: 2px solid var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
}

/* ── NOTIFICATION PANEL ────────────────── */
.notif-panel {
  position: absolute;
  top: calc(var(--topbar-h) + 8px);
  right: 20px;
  width: 340px;
  max-height: 480px;
  background: var(--notif-bg);
  border: 1px solid var(--notif-border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  z-index: 200;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: notif-drop 0.2s ease;
}
@keyframes notif-drop {
  from {
    opacity: 0;
    transform: translateY(-8px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}
.notif-panel.hidden {
  display: none;
}

.notif-panel-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--notif-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.notif-panel-title {
  font-size: 13px;
  font-weight: 800;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}
.notif-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  padding: 4px;
  border-radius: 6px;
  transition: color 0.15s;
}
.notif-close:hover {
  color: var(--text-primary);
}

.notif-list {
  overflow-y: auto;
  flex: 1;
}

.notif-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
  cursor: pointer;
  transition: background 0.15s;
  border-bottom: 1px solid var(--notif-border);
  position: relative;
}
.notif-item:last-child {
  border-bottom: none;
}
.notif-item:hover {
  background: var(--surface-2);
}
.notif-item.unread {
  background: rgba(245, 166, 35, 0.04);
}

.notif-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  flex-shrink: 0;
  margin-top: 1px;
}
.notif-body {
  flex: 1;
  min-width: 0;
}
.notif-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-primary);
}
.notif-msg {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 2px;
  line-height: 1.4;
}
.notif-time {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 4px;
}
.notif-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--amber);
  flex-shrink: 0;
  margin-top: 5px;
}

/* ── PAGE AREA ─────────────────────────── */
.page-area {
  padding: 24px;
  flex: 1;
}

/* ── PAGE HEADER ───────────────────────── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}
.page-header-left .page-title {
  font-size: 22px;
  font-weight: 900;
  color: var(--text-primary);
  line-height: 1.2;
}
.page-header-left .page-sub {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 3px;
  font-weight: 500;
}

/* ── BUTTONS ───────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: var(--r-md);
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  border: none;
  transition: all 0.18s ease;
  white-space: nowrap;
  text-decoration: none;
}
.btn-primary {
  background: linear-gradient(135deg, var(--amber-dark), var(--amber));
  color: var(--brown-dark);
  box-shadow: var(--shadow-amber);
}
.btn-primary:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
}
.btn-secondary {
  background: var(--surface-2);
  color: var(--text-primary);
  border: 1px solid var(--border);
}
.btn-secondary:hover {
  background: var(--surface-3);
  border-color: var(--border-hover);
}
.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-ghost:hover {
  color: var(--text-primary);
  background: var(--surface-2);
}
.btn-danger {
  background: rgba(139, 26, 26, 0.2);
  color: #f87171;
  border: 1px solid rgba(139, 26, 26, 0.4);
}
.btn-danger:hover {
  background: rgba(139, 26, 26, 0.3);
}
.btn-sm {
  padding: 5px 12px;
  font-size: 12px;
}
.btn-icon {
  padding: 8px;
  border-radius: var(--r-md);
}

/* ── CARDS ─────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 20px;
  transition: background 0.3s ease;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.card-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ── METRIC CARDS ──────────────────────── */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.metric-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 20px;
  position: relative;
  overflow: hidden;
  transition:
    border-color 0.2s,
    box-shadow 0.2s,
    background 0.3s;
}
.metric-card:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow-md);
}
.metric-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  border-radius: var(--r-lg) var(--r-lg) 0 0;
}
.metric-card.mc-amber::before {
  background: linear-gradient(90deg, var(--amber-dark), var(--amber));
}
.metric-card.mc-green::before {
  background: linear-gradient(90deg, var(--green-dark), var(--green-light));
}
.metric-card.mc-red::before {
  background: linear-gradient(90deg, #8b1a1a, #c4703a);
}
.metric-card.mc-blue::before {
  background: linear-gradient(90deg, #1a3a5c, #2e7dd1);
}

.metric-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  margin-bottom: 14px;
}
.mc-amber .metric-icon {
  background: rgba(245, 166, 35, 0.15);
  color: var(--amber);
}
.mc-green .metric-icon {
  background: rgba(74, 124, 63, 0.15);
  color: var(--green-light);
}
.mc-red .metric-icon {
  background: rgba(196, 112, 58, 0.15);
  color: var(--terracotta);
}
.mc-blue .metric-icon {
  background: rgba(46, 125, 209, 0.15);
  color: #5ba3e8;
}

.metric-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 6px;
}
.metric-value {
  font-size: 24px;
  font-weight: 900;
  color: var(--text-primary);
  line-height: 1;
}
.metric-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 6px;
  font-weight: 500;
}
.metric-change {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  font-weight: 700;
  margin-top: 6px;
}
.metric-change.up {
  color: var(--green-light);
}
.metric-change.down {
  color: var(--terracotta);
}

/* ── TABLE ─────────────────────────────── */
.table-wrap {
  overflow-x: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
}
thead th {
  padding: 10px 14px;
  text-align: left;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody tr {
  border-bottom: 1px solid rgba(245, 166, 35, 0.06);
  transition: background 0.14s;
  cursor: pointer;
}
tbody tr:hover {
  background: var(--surface-2);
}
tbody tr:last-child {
  border-bottom: none;
}
tbody td {
  padding: 12px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  vertical-align: middle;
}
td.td-muted {
  color: var(--text-secondary);
  font-size: 12px;
}

/* ── BADGES ────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}
.badge::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  display: inline-block;
}
.badge-active {
  background: rgba(74, 124, 63, 0.18);
  color: var(--green-light);
  border: 1px solid rgba(74, 124, 63, 0.3);
}
.badge-active::before {
  background: var(--green-light);
}
.badge-overdue {
  background: rgba(196, 112, 58, 0.18);
  color: #e8935a;
  border: 1px solid rgba(196, 112, 58, 0.3);
}
.badge-overdue::before {
  background: #e8935a;
}
.badge-paid {
  background: rgba(245, 166, 35, 0.15);
  color: var(--amber);
  border: 1px solid rgba(245, 166, 35, 0.3);
}
.badge-paid::before {
  background: var(--amber);
}
.badge-defaulted {
  background: rgba(139, 26, 26, 0.2);
  color: #f87171;
  border: 1px solid rgba(139, 26, 26, 0.3);
}
.badge-defaulted::before {
  background: #f87171;
}
.badge-repayment {
  background: rgba(74, 124, 63, 0.18);
  color: var(--green-light);
  border: 1px solid rgba(74, 124, 63, 0.3);
}
.badge-repayment::before {
  background: var(--green-light);
}
.badge-disbursement {
  background: rgba(245, 166, 35, 0.15);
  color: var(--amber);
  border: 1px solid rgba(245, 166, 35, 0.3);
}
.badge-disbursement::before {
  background: var(--amber);
}

/* ── AVATAR ────────────────────────────── */
.borrower-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}
.b-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brown-light), var(--terracotta));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 800;
  color: var(--cream);
  flex-shrink: 0;
}
.b-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
}
.b-phone {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 1px;
}

/* ── PROGRESS BAR ──────────────────────── */
.progress-wrap {
  margin-top: 6px;
}
.progress-bar {
  height: 4px;
  background: var(--surface-3);
  border-radius: 99px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--green-dark), var(--green-light));
  transition: width 0.6s ease;
}

/* ── CHART CARD ────────────────────────── */
.chart-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}
.chart-container {
  position: relative;
  height: 220px;
}

/* ── DONUT LEGEND ──────────────────────── */
.donut-legend {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 16px;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  font-weight: 600;
}
.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.legend-val {
  margin-left: auto;
  font-weight: 700;
  color: var(--text-primary);
}

/* ── RECENT TXNS ───────────────────────── */
.txn-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.txn-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid rgba(245, 166, 35, 0.06);
}
.txn-item:last-child {
  border-bottom: none;
}
.txn-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}
.txn-icon.in {
  background: rgba(74, 124, 63, 0.15);
  color: var(--green-light);
}
.txn-icon.out {
  background: rgba(245, 166, 35, 0.12);
  color: var(--amber);
}
.txn-info {
  flex: 1;
  min-width: 0;
}
.txn-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
}
.txn-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 1px;
}
.txn-amount {
  font-size: 14px;
  font-weight: 800;
  white-space: nowrap;
}
.txn-amount.in {
  color: var(--green-light);
}
.txn-amount.out {
  color: var(--terracotta);
}

/* ── MODAL ─────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-backdrop.hidden {
  display: none;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}
.modal-header {
  padding: 20px 24px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-title {
  font-size: 17px;
  font-weight: 800;
  color: var(--text-primary);
}
.modal-close {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--surface-2);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: var(--text-secondary);
  transition: all 0.15s;
}
.modal-close:hover {
  background: var(--surface-3);
  color: var(--text-primary);
}
.modal-body {
  padding: 20px 24px 24px;
}

/* ── FORMS ─────────────────────────────── */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.form-grid.single {
  grid-template-columns: 1fr;
}
.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.form-group.span2 {
  grid-column: 1 / -1;
}

label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

input,
select,
textarea {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 9px 12px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  outline: none;
  width: 100%;
  transition:
    border-color 0.18s,
    background 0.3s;
}
input:focus,
select:focus,
textarea:focus {
  border-color: var(--amber);
}
select option {
  background: var(--surface-2);
  color: var(--text-primary);
}
textarea {
  resize: vertical;
  min-height: 80px;
}

/* Profile picture upload */
.pfp-upload-area {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px;
  background: var(--surface-2);
  border: 2px dashed var(--border);
  border-radius: var(--r-lg);
  cursor: pointer;
  transition: border-color 0.2s;
}
.pfp-upload-area:hover {
  border-color: var(--amber);
}
.pfp-preview {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--amber), var(--terracotta));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 900;
  color: var(--brown-dark);
  overflow: hidden;
  flex-shrink: 0;
}
.pfp-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ── CALC PAGE ─────────────────────────── */
.calc-result {
  background: var(--surface-2);
  border: 1px solid var(--border-hover);
  border-radius: var(--r-lg);
  padding: 20px;
  margin-top: 20px;
}
.calc-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.calc-row:last-child {
  border-bottom: none;
}
.calc-row .lbl {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
}
.calc-row .val {
  font-size: 14px;
  font-weight: 800;
  color: var(--text-primary);
}
.calc-row .val.highlight {
  color: var(--amber);
  font-size: 16px;
}

/* ── SETTINGS ──────────────────────────── */
.settings-section {
  margin-bottom: 24px;
}
.settings-section h3 {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 12px;
}
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  margin-bottom: 6px;
  gap: 12px;
  transition: background 0.3s;
}
.setting-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}
.setting-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Edit mode inline input in settings */
.setting-edit-input {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 5px 10px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 13px;
  outline: none;
  width: 200px;
  transition: border-color 0.18s;
}
.setting-edit-input:focus {
  border-color: var(--amber);
}

/* Toggle switch */
.toggle {
  position: relative;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}
.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}
.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--surface-3);
  border-radius: 99px;
  cursor: pointer;
  transition: background 0.2s;
}
.toggle-slider::before {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  top: 3px;
  background: var(--text-muted);
  border-radius: 50%;
  transition: all 0.2s;
}
.toggle input:checked + .toggle-slider {
  background: var(--amber);
}
.toggle input:checked + .toggle-slider::before {
  transform: translateX(20px);
  background: var(--brown-dark);
}

/* ── EMPTY STATE ───────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}
.empty-state .empty-icon {
  font-size: 36px;
  margin-bottom: 12px;
  opacity: 0.5;
}
.empty-state p {
  font-size: 13px;
  font-weight: 600;
}

/* ── TABS ──────────────────────────────── */
.tabs {
  display: flex;
  gap: 4px;
  background: var(--surface-2);
  border-radius: var(--r-lg);
  padding: 4px;
  width: fit-content;
  margin-bottom: 18px;
}
.tab-btn {
  padding: 7px 16px;
  border-radius: var(--r-md);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  border: none;
  background: transparent;
  color: var(--text-muted);
  transition: all 0.18s;
  font-family: inherit;
}
.tab-btn.active {
  background: var(--surface);
  color: var(--amber);
  box-shadow: var(--shadow-sm);
}
.tab-btn:hover:not(.active) {
  color: var(--text-secondary);
}

/* ── FILTER BAR ────────────────────────── */
.filter-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  align-items: center;
}
.filter-bar input {
  max-width: 220px;
}

/* ── BREADCRUMB ────────────────────────── */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.breadcrumb span {
  color: var(--text-secondary);
}
.breadcrumb .sep {
  opacity: 0.4;
}

/* ── BORROWER PROFILE ──────────────────── */
.profile-hero {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  margin-bottom: 20px;
}
.profile-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brown-light), var(--terracotta));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 900;
  color: var(--cream);
  flex-shrink: 0;
  border: 3px solid var(--amber);
}
.profile-name {
  font-size: 20px;
  font-weight: 900;
  color: var(--text-primary);
}
.profile-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}
.profile-meta span {
  display: flex;
  align-items: center;
  gap: 5px;
}

/* ── TOAST ─────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 999;
}
.toast {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 12px 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  gap: 8px;
  animation: slideIn 0.3s ease;
  max-width: 280px;
}
.toast.success {
  border-left: 3px solid var(--green-light);
}
.toast.error {
  border-left: 3px solid var(--terracotta);
}
.toast.info {
  border-left: 3px solid var(--amber);
}
@keyframes slideIn {
  from {
    transform: translateX(30px);
    opacity: 0;
  }
  to {
    transform: none;
    opacity: 1;
  }
}

/* ── MOBILE ────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 99;
}
.hamburger {
  display: none;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 18px;
  cursor: pointer;
  padding: 6px;
}

/* ── RESPONSIVE ────────────────────────── */
@media (max-width: 900px) {
  .chart-grid {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 768px) {
  :root {
    --sidebar-w: 240px;
  }
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }
  .sidebar-overlay {
    display: block;
  }
  .main-content {
    margin-left: 0;
  }
  .hamburger {
    display: block;
  }
  .metrics-grid {
    grid-template-columns: 1fr 1fr;
  }
  .topbar {
    padding: 0 16px;
  }
  .page-area {
    padding: 16px;
  }
  .search-wrap {
    flex: 1;
    max-width: none;
  }
  .topbar-cash {
    display: none;
  }
  .form-grid {
    grid-template-columns: 1fr;
  }
  .notif-panel {
    right: 12px;
    width: calc(100vw - 24px);
  }
}
@media (max-width: 480px) {
  .metrics-grid {
    grid-template-columns: 1fr;
  }
  .page-header {
    flex-direction: column;
  }
}

/* ── AOS PAGE TRANSITIONS ──────────────── */
[data-aos] {
  pointer-events: none;
}
[data-aos].aos-animate {
  pointer-events: auto;
}

/* ── UTILITY ───────────────────────────── */
.hidden {
  display: none !important;
}
.text-right {
  text-align: right;
}
.text-center {
  text-align: center;
}
.mt-4 {
  margin-top: 4px;
}
.mt-8 {
  margin-top: 8px;
}
.mt-16 {
  margin-top: 16px;
}
.mb-16 {
  margin-bottom: 16px;
}
.gap-8 {
  gap: 8px;
}
.flex {
  display: flex;
}
.items-center {
  align-items: center;
}
.justify-between {
  justify-content: space-between;
}
.w-full {
  width: 100%;
}
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
