@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@500;600;700;800&family=Inter:wght@400;500;600&display=swap');

:root {
  --bg: #FFFFFF; --surface: #FFFFFF; --surface-alt: #F3F4F8;
  --sidebar-bg: #405858; --sidebar-bg-soft: #4E6A69; --sidebar-text: #A9BFBD;
  --card-dark: #344A48; --card-dark-soft: #2C3E3C;
  --ink: #2A3B3A; --ink-soft: #647573; --border: #CFE3E1;
  --accent-gold: #D0A010; --accent-gold-deep: #C89830; --accent-blue: #4C6FFF;
  --green: #1FAE64; --green-soft: #E6F7ED; --green-border: #B9E6C9;
  --red: #E5484D; --red-soft: #FDECED; --red-border: #F6C4C6; --red-deep: #B3261E;
  --gold-soft: #FBEFD4; --purple: #6D28D9; --purple-soft: #EDE4FB; --highlight-soft: #FBEFD4;
  --radius-lg: 20px; --radius-md: 14px; --radius-sm: 10px;
  --shadow-card: 0 1px 2px rgba(42,59,58,0.06), 0 8px 24px rgba(42,59,58,0.08);
}
[data-theme="dark"] {
  --bg: #12201F; --surface: #1C2C2A; --surface-alt: #243634;
  --sidebar-bg: #0C1615; --sidebar-bg-soft: #1A2A28; --sidebar-text: #8FA3A0;
  --card-dark: #253A38; --card-dark-soft: #1D2F2D;
  --ink: #E8F2F0; --ink-soft: #93A8A5; --border: #2C3F3D;
  --accent-gold: #E0B22A; --accent-gold-deep: #E8C468; --accent-blue: #7C93FF;
  --green: #34D399; --green-soft: #14301F; --green-border: #1F4A30;
  --red: #F87171; --red-soft: #3A1A1C; --red-border: #5C2A2D; --red-deep: #FCA5A5;
  --gold-soft: #3A2F14; --purple: #A78BFA; --purple-soft: #2D2440; --highlight-soft: #332B14;
  --shadow-card: 0 1px 2px rgba(0,0,0,0.3), 0 8px 24px rgba(0,0,0,0.4);
}
body { transition: background 0.2s ease, color 0.2s ease; }
.surface, .panel, .stat-card, .asset-pill, .stat, .login-card { transition: background 0.2s ease, border-color 0.2s ease; }
* { box-sizing: border-box; }
body { margin: 0; font-family: 'Inter', -apple-system, sans-serif; background: var(--bg); color: var(--ink); font-size: 14px; }
h1,h2,h3 { font-family: 'Plus Jakarta Sans', sans-serif; font-weight: 700; margin: 0; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

.shell { display: flex; min-height: 100vh; padding: 20px; gap: 20px; align-items: flex-start; }
.sidebar { width: 246px; flex-shrink: 0; background: var(--sidebar-bg); color: var(--sidebar-text); display: flex; flex-direction: column; padding: 24px 16px; border-radius: 28px; box-shadow: var(--shadow-card); min-height: calc(100vh - 40px); }
.logo-block { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 8px 0 22px; }
.logo-mark {
  width: 68px; height: 68px; border-radius: 16px;
  background: #F3EFE6;
  display: flex; align-items: center; justify-content: center; overflow: hidden;
  margin-bottom: 10px; padding: 6px;
}
.logo-mark img { width: 100%; height: 100%; object-fit: contain; }
.logo-block .brand-name { font-family: 'Plus Jakarta Sans', sans-serif; font-weight: 800; font-size: 17px; color: #fff; letter-spacing: 0.01em; }

.avatar-photo {
  border-radius: 50%; background: var(--sidebar-bg-soft); display: flex; align-items: center; justify-content: center;
  position: relative; flex-shrink: 0; overflow: hidden; color: var(--sidebar-text);
}
.avatar-photo svg { width: 55%; height: 55%; }
.avatar-photo .cam-badge {
  position: absolute; bottom: -1px; right: -1px; width: 15px; height: 15px; border-radius: 50%;
  background: var(--accent-gold); display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--sidebar-bg); font-size: 8px;
}
.user-chip .avatar-photo .cam-badge { border-color: var(--surface); }

.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; font-size: 13.5px; font-weight: 500; color: var(--sidebar-text); justify-content: space-between; }
.nav-item .nav-left { display: flex; align-items: center; gap: 12px; }
.nav-item:hover { background: var(--sidebar-bg-soft); color: #E8F2F0; }
.nav-item.active {
  background: var(--accent-gold); color: var(--ink); font-weight: 600;
  border-radius: 999px;
}
.nav-icon { width: 18px; text-align: center; opacity: 0.9; }

.nav-section-label { font-size: 10.5px; font-weight: 700; letter-spacing: 0.08em; color: #5E7472; padding: 18px 12px 6px; }

.profile-mini { border-top: 1px solid rgba(255,255,255,0.08); padding: 16px 12px 4px; margin-top: auto; display: flex; align-items: center; gap: 10px; }
.profile-mini .avatar-circle { width: 34px; height: 34px; border-radius: 50%; background: var(--sidebar-bg-soft); display: flex; align-items: center; justify-content: center; font-weight: 700; color: #fff; font-size: 13px; }
.profile-mini strong { display: block; color: #fff; font-size: 13px; font-weight: 600; }
.profile-mini small { display: block; color: var(--sidebar-text); font-size: 11.5px; }
.profile-mini a { display: block; margin-left: auto; color: var(--red); font-size: 12px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 18px; padding: 22px 32px; }
.hamburger { font-size: 18px; color: var(--ink-soft); }
.page-title { font-size: 21px; font-weight: 700; white-space: nowrap; }
.search-wrap { flex: 1; max-width: 460px; position: relative; }
.search { width: 100%; padding: 11px 16px 11px 40px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); font-size: 13.5px; font-family: inherit; }
.search-icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--ink-soft); font-size: 14px; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.icon-btn { position: relative; width: 34px; height: 34px; border-radius: 50%; background: none; border: none; display: flex; align-items: center; justify-content: center; color: var(--ink-soft); }
.icon-btn:hover { background: var(--surface); }
.icon-btn svg { width: 19px; height: 19px; }
.icon-btn .badge { position: absolute; top: -1px; right: -1px; background: var(--red); color: #fff; font-size: 10px; font-weight: 700; width: 16px; height: 16px; border-radius: 50%; display: flex; align-items: center; justify-content: center; border: 2px solid var(--bg); }
.search-icon svg { width: 15px; height: 15px; }
.chev { width: 12px; height: 12px; opacity: 0.6; }
.user-chip { display: flex; align-items: center; gap: 9px; padding: 6px 14px 6px 6px; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; }
.user-chip .avatar-circle { width: 28px; height: 28px; border-radius: 50%; background: var(--ink); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; }
.user-chip span { font-size: 13px; font-weight: 600; }

.content { padding: 0 32px 40px; flex: 1; }

/* Top stat row + net balance */
.top-row { display: grid; grid-template-columns: repeat(4, 1fr) 1.3fr; gap: 14px; margin-bottom: 18px; }
.stat-card { background: var(--surface); border-radius: var(--radius-md); padding: 16px 18px; box-shadow: var(--shadow-card); display: flex; flex-direction: column; gap: 10px; }
.stat-card .top-line { display: flex; align-items: center; gap: 12px; }
.stat-icon { width: 38px; height: 38px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 17px; flex-shrink: 0; }
.stat-icon.blue { background: #EAF0FF; color: var(--accent-blue); }
.stat-icon.orange { background: #FFF1DE; color: #E38B41; }
.stat-icon.green { background: var(--green-soft); color: var(--green); }
.stat-icon.red { background: var(--red-soft); color: var(--red); }
.stat-card .label { font-size: 12.5px; color: var(--ink-soft); font-weight: 500; }
.stat-card strong { font-family: 'Plus Jakarta Sans', sans-serif; font-size: 22px; font-weight: 700; }
.stat-card .delta { font-size: 11.5px; font-weight: 600; }
.stat-card .delta.up { color: var(--green); }
.stat-card .delta.down { color: var(--red); }

.net-balance-card { background: linear-gradient(155deg, var(--card-dark), var(--card-dark-soft)); border-radius: var(--radius-md); padding: 16px 18px; color: #fff; display: flex; flex-direction: column; justify-content: space-between; }
.date-range-pill { align-self: flex-end; font-size: 11px; color: #B8C9C7; background: rgba(255,255,255,0.06); padding: 5px 10px; border-radius: 999px; margin-bottom: 8px; }
.net-balance-card .top-line { display: flex; align-items: center; gap: 12px; }
.net-balance-card .stat-icon { background: rgba(227,179,65,0.18); color: var(--accent-gold); }
.net-balance-card .label { color: var(--sidebar-text); }
.net-balance-card strong { color: #fff; font-size: 22px; }
.net-balance-card .delta.up { color: var(--accent-gold); }

/* Asset row */
.asset-row { display: grid; grid-template-columns: repeat(9, 1fr); gap: 10px; margin-bottom: 20px; }
.asset-pill { background: var(--surface); border-radius: var(--radius-md); padding: 12px 12px; box-shadow: var(--shadow-card); display: flex; flex-direction: column; gap: 7px; }
.asset-pill .top-line { display: flex; align-items: center; gap: 8px; }
.asset-icon { width: 27px; height: 27px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 11.5px; font-weight: 700; color: #fff; flex-shrink: 0; }
.asset-pill .code { font-size: 11.5px; font-weight: 700; }
.asset-pill strong { font-family: 'Plus Jakarta Sans', sans-serif; font-size: 13px; font-weight: 700; }
.asset-pill small { color: var(--ink-soft); font-size: 10px; }

/* Panels */
.panel { background: var(--surface); border-radius: var(--radius-lg); padding: 20px 22px; box-shadow: var(--shadow-card); }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.panel-head h2 { font-size: 15.5px; }
.panel-head button, .panel-head .dropdown-pill { background: var(--bg); border: 1px solid var(--border); padding: 6px 13px; border-radius: 999px; font-size: 12px; font-weight: 600; color: var(--ink); }

.row-2col { display: grid; grid-template-columns: 1.7fr 1fr; gap: 16px; margin-bottom: 16px; }
.row-3col { display: grid; grid-template-columns: 1fr 1fr 1.2fr; gap: 16px; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th { text-align: left; font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-soft); font-weight: 600; padding: 0 8px 10px; border-bottom: 1px solid var(--border); }
tbody td { padding: 11px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }

.trx-avatar { width: 34px; height: 34px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 11.5px; flex-shrink: 0; }
.cell-flex { display: flex; align-items: center; gap: 10px; }
.cell-main strong { display: block; font-size: 13px; font-weight: 600; }
.cell-main small { display: block; font-size: 11px; color: var(--ink-soft); }
.pill-tag { display: inline-block; padding: 4px 9px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.amt.credit { color: var(--green); font-weight: 700; }
.amt.debit { color: var(--red); font-weight: 700; }
.view-all-row { text-align: center; padding: 12px; font-size: 12.5px; font-weight: 600; color: var(--ink-soft); border-top: 1px solid var(--border); margin-top: 6px; }

/* Donut rings */
.donut-row { display: flex; align-items: center; gap: 22px; }
.donut-ring { width: 140px; height: 140px; border-radius: 50%; flex-shrink: 0; display: flex; align-items: center; justify-content: center; position: relative; }
.donut-ring::before { content: ''; position: absolute; inset: 16px; border-radius: 50%; background: var(--surface); }
.donut-ring .ring-center { position: relative; text-align: center; }
.donut-ring .ring-center small { display: block; font-size: 11px; color: var(--ink-soft); }
.donut-ring .ring-center strong { display: block; font-family: 'Plus Jakarta Sans', sans-serif; font-size: 17px; font-weight: 700; }
.donut-legend { display: flex; flex-direction: column; gap: 10px; flex: 1; }
.donut-legend .leg-row { display: flex; align-items: center; gap: 8px; font-size: 12.5px; }
.donut-legend .dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.donut-legend .leg-name { flex: 1; color: var(--ink); font-weight: 500; }
.donut-legend .leg-val { font-weight: 700; }
.donut-legend .leg-pct { color: var(--ink-soft); font-size: 11.5px; width: 42px; text-align: right; }

/* activity chart */
.activity-chart { width: 100%; height: 170px; }

/* ============================================================
   Shared components still used by other pages (Clients, Client
   Profile, Reports, Users, Settings, Login, etc.)
   ============================================================ */

footer { padding: 20px 32px; color: var(--ink-soft); font-size: 12px; display: flex; justify-content: space-between; }

/* Legacy simple stat cards (client profile, reports) */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stats-grid.three { grid-template-columns: repeat(3, 1fr); }
.stat { background: var(--surface); border-radius: var(--radius-md); padding: 18px 20px; box-shadow: var(--shadow-card); }
.stat span { display: block; font-size: 12.5px; color: var(--ink-soft); font-weight: 500; margin-bottom: 8px; }
.stat strong { display: block; font-family: 'Plus Jakarta Sans', sans-serif; font-size: 26px; font-weight: 700; }
.stat small { display: block; font-size: 11.5px; color: var(--ink-soft); margin-top: 4px; }
.stat.green strong { color: var(--green); }
.stat.red strong { color: var(--red); }
.stat.blue strong { color: var(--accent-blue); }
.stat.yellow strong { color: var(--accent-gold-deep); }
.stat.purple strong { color: #8B5CF6; }

/* Dashboard layout grid (still referenced by wide panel) */
.dashboard-grid { display: grid; grid-template-columns: 1.6fr 1fr; gap: 20px; align-items: start; }
.dashboard-grid .panel.wide { grid-column: 1; }

/* panel-head form (search bars inside panels: Clients, Transactions) */
.panel-head form { display: flex; gap: 8px; }
.panel-head form input { padding: 9px 14px; border: 1px solid var(--border); border-radius: 999px; font-size: 13px; font-family: inherit; min-width: 220px; }
.panel-head form button { border: none; background: var(--ink); color: #fff; }

.empty { color: var(--ink-soft); font-size: 13px; padding: 24px 0; text-align: center; }
.hint { color: var(--ink-soft); font-size: 12.5px; margin-top: 10px; }
.table-wrap { overflow-x: auto; }

/* Forms */
.form-grid { display: flex; flex-direction: column; gap: 14px; max-width: 480px; }
.form-grid label { display: flex; flex-direction: column; gap: 6px; font-size: 13.5px; font-weight: 600; color: var(--ink); }
.form-grid input, .form-grid select, .form-grid textarea {
  padding: 11px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 13.5px; font-family: inherit; background: var(--surface);
}
.form-grid input:focus, .form-grid select:focus, .form-grid textarea:focus { outline: none; border-color: var(--accent-gold); }
.form-grid button[type="submit"] {
  align-self: flex-start; padding: 11px 24px; margin-top: 6px;
  background: var(--ink); color: #fff; border: none; border-radius: 999px; font-weight: 600; font-size: 13.5px;
}

.inline-form { display: flex; gap: 6px; align-items: center; }
.inline-form input, .inline-form select { padding: 7px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 12.5px; font-family: inherit; }
.inline-form button { padding: 7px 12px; border: none; border-radius: var(--radius-sm); background: var(--ink); color: #fff; font-size: 12px; font-weight: 600; }

/* Alerts / pills / misc */
.alert { padding: 12px 16px; border-radius: var(--radius-sm); font-size: 13px; margin-bottom: 14px; background: var(--red-soft); color: var(--red); border: 1px solid var(--red-border); }
.alert.success { background: var(--green-soft); color: var(--green); border-color: var(--green-border); }
.pill { display: inline-block; padding: 4px 10px; border-radius: 999px; background: var(--bg); font-size: 11.5px; font-weight: 600; color: var(--ink-soft); margin: 2px 4px 2px 0; }
.eyebrow { font-size: 12px; font-weight: 600; color: var(--accent-gold-deep); letter-spacing: 0.03em; }

.profile-header { display: flex; justify-content: space-between; align-items: flex-start; background: var(--surface); border-radius: var(--radius-lg); padding: 22px 24px; box-shadow: var(--shadow-card); margin-bottom: 20px; }
.profile-header h1 { font-size: 22px; margin-top: 4px; }
.profile-header p { color: var(--ink-soft); font-size: 13px; margin-top: 6px; }
.profile-header button { padding: 10px 18px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); font-weight: 600; font-size: 13px; margin-left: 8px; }

/* legacy asset-strip (client profile / reports currency lists) */
.asset-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 12px; }
.asset-strip > div { background: var(--bg); border-radius: var(--radius-sm); padding: 14px; text-align: center; }
.asset-strip b { display: block; font-size: 11.5px; color: var(--ink-soft); font-weight: 600; }
.asset-strip strong { display: block; font-family: 'Plus Jakarta Sans', sans-serif; font-size: 17px; margin-top: 4px; }
.asset-strip small { display: block; font-size: 10.5px; color: var(--ink-soft); margin-top: 2px; }

/* Login page */
body.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--sidebar-bg); }
.login-card { width: 100%; max-width: 380px; background: var(--surface); border-radius: var(--radius-lg); padding: 40px 36px; box-shadow: var(--shadow-card); }
.login-card .brand { font-family: 'Plus Jakarta Sans', sans-serif; font-weight: 800; font-size: 20px; margin-bottom: 20px; }
.login-card h1 { font-size: 21px; }
.login-card p { color: var(--ink-soft); font-size: 13.5px; margin: 8px 0 22px; }
.login-card label { display: block; font-size: 12.5px; font-weight: 600; margin-bottom: 16px; }
.login-card input { display: block; width: 100%; margin-top: 6px; padding: 11px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 13.5px; font-family: inherit; }
.login-card button { width: 100%; padding: 12px; border: none; border-radius: 999px; background: var(--ink); color: #fff; font-weight: 700; font-size: 13.5px; margin-top: 6px; }
.login-logo { width: 64px; height: 64px; border-radius: 16px; background: #F3EFE6; display: flex; align-items: center; justify-content: center; overflow: hidden; padding: 6px; margin-bottom: 16px; }
.login-logo img { width: 100%; height: 100%; object-fit: contain; }

/* Responsive */
@media (max-width: 960px) {
  .dashboard-grid, .row-2col, .row-3col { grid-template-columns: 1fr; }
  .stats-grid.three, .top-row { grid-template-columns: 1fr; }
  .asset-row { grid-template-columns: repeat(3, 1fr); }
  .sidebar { display: none; }
  .topbar { padding: 16px; flex-wrap: wrap; }
  .content { padding: 0 16px 32px; }
}

/* Accessibility */
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--accent-gold); outline-offset: 2px;
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* Credit/Debit type badges (rectangular, per request) */
.type-badge { display: inline-block; padding: 4px 12px; border-radius: 6px; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.02em; }
.type-badge.credit { background: var(--green-soft); color: var(--green); }
.type-badge.debit { background: var(--red-soft); color: var(--red); }
.edited-badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 10px; font-weight: 700; background: var(--gold-soft); color: var(--accent-gold-deep); margin-left: 6px; vertical-align: middle; }
.account-badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 11px; font-weight: 700; margin-left: 8px; vertical-align: middle; }
.account-badge.open { background: var(--green-soft); color: var(--green); }
.account-badge.closed { background: var(--red-soft); color: var(--red); }
.danger-btn { background: var(--red-soft) !important; color: var(--red) !important; border-color: var(--red-border) !important; }

/* Light/dark mode toggle switch */
.theme-toggle { display: flex; align-items: center; gap: 8px; }
.theme-toggle .theme-icon { font-size: 14px; line-height: 1; }
.theme-switch { position: relative; width: 42px; height: 22px; flex-shrink: 0; }
.theme-switch input { opacity: 0; width: 0; height: 0; }
.theme-switch .slider { position: absolute; inset: 0; background: var(--border); border-radius: 999px; cursor: pointer; transition: background 0.2s; }
.theme-switch .slider::before { content: ''; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: transform 0.2s; }
.theme-switch input:checked + .slider { background: var(--accent-gold); }
.theme-switch input:checked + .slider::before { transform: translateX(20px); }
