/* ============================================================
   style.css  –  FinTrack Design System v2
   Font: Playfair Display (display) + Plus Jakarta Sans (body)
   Aesthetic: Refined editorial · warm ivory · deep ink · gold accent
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,500;0,600;0,700;1,500&family=Plus+Jakarta+Sans:wght@300;400;500;600;700&display=swap');

/* ── Light Mode Variables ───────────────────────────────────── */
:root {
  --font-display: 'Playfair Display', Georgia, serif;
  --font-body:    'Plus Jakarta Sans', sans-serif;

  --bg:           #F9F7F3;
  --surface:      #FFFFFF;
  --surface-2:    #F3F0EB;
  --surface-3:    #EAE5DC;
  --border:       rgba(0,0,0,0.07);
  --border-hover: rgba(0,0,0,0.14);
  --border-strong:rgba(0,0,0,0.18);

  --text-primary:   #181410;
  --text-secondary: #6B5F52;
  --text-hint:      #A89A8A;

  --accent:       #B8813A;
  --accent-rgb:   184,129,58;
  --accent-light: #FDF4E3;
  --accent-mid:   #D4A054;
  --accent-dark:  #8C5E1E;

  --green:      #2A7A50;
  --green-bg:   #EBF6F0;
  --red:        #B83030;
  --red-bg:     #FDF0EE;
  --blue:       #2060A8;
  --blue-bg:    #EBF2FC;
  --amber:      #A84E08;
  --amber-bg:   #FEF3C7;
  --purple:     #6030A0;
  --purple-bg:  #F3EDFC;

  --radius-xs:  4px;
  --radius-sm:  8px;
  --radius-md:  12px;
  --radius-lg:  18px;
  --radius-xl:  26px;

  --shadow-xs:  0 1px 2px rgba(0,0,0,0.05);
  --shadow-sm:  0 2px 8px rgba(0,0,0,0.06), 0 0 1px rgba(0,0,0,0.04);
  --shadow-md:  0 4px 20px rgba(0,0,0,0.09), 0 0 1px rgba(0,0,0,0.04);
  --shadow-lg:  0 12px 40px rgba(0,0,0,0.13), 0 0 1px rgba(0,0,0,0.04);
  --shadow-xl:  0 24px 64px rgba(0,0,0,0.18);

  --transition-fast: 0.12s ease;
  --transition:      0.2s ease;
  --transition-slow: 0.35s cubic-bezier(0.4,0,0.2,1);

  --sidebar-w: 268px;
}

/* ── Dark Mode Variables ────────────────────────────────────── */
[data-theme="dark"] {
  --bg:           #0D0C09;
  --surface:      #161410;
  --surface-2:    #1F1D18;
  --surface-3:    #2A2720;
  --border:       rgba(255,255,255,0.065);
  --border-hover: rgba(255,255,255,0.13);
  --border-strong:rgba(255,255,255,0.18);

  --text-primary:   #F0EAE0;
  --text-secondary: #9A8C7C;
  --text-hint:      #58504A;

  --accent:       #D4A040;
  --accent-rgb:   212,160,64;
  --accent-light: #1C1608;
  --accent-mid:   #C8903C;
  --accent-dark:  #E0B860;

  --green:      #4AB870;
  --green-bg:   #081A0E;
  --red:        #E06860;
  --red-bg:     #1A0808;
  --blue:       #5090D8;
  --blue-bg:    #060E1A;
  --amber:      #D09030;
  --amber-bg:   #160D02;
  --purple:     #9870D8;
  --purple-bg:  #0E0818;

  --shadow-xs:  0 1px 2px rgba(0,0,0,0.35);
  --shadow-sm:  0 2px 8px rgba(0,0,0,0.4);
  --shadow-md:  0 4px 20px rgba(0,0,0,0.5);
  --shadow-lg:  0 12px 40px rgba(0,0,0,0.6);
  --shadow-xl:  0 24px 64px rgba(0,0,0,0.7);
}

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

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text-primary);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  transition: background-color var(--transition-slow), color var(--transition-slow);
}

a      { text-decoration: none; color: inherit; }
button { font-family: var(--font-body); cursor: pointer; border: none; background: none; }
input, select, textarea { font-family: var(--font-body); }
img    { display: block; max-width: 100%; }

/* ── Dot grid texture ───────────────────────────────────────── */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: radial-gradient(circle, var(--text-hint) 1px, transparent 1px);
  background-size: 28px 28px;
  opacity: 0.12;
  pointer-events: none;
  z-index: 0;
}

.hidden { display: none !important; }

/* ══════════════════════════════════════════════════════════════
   AUTH PAGES
══════════════════════════════════════════════════════════════ */
.auth-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  position: relative;
  z-index: 1;
}

@media (max-width: 820px) {
  .auth-page { grid-template-columns: 1fr; }
  .auth-brand { display: none; }
}

.auth-brand {
  background: #0F0E0B;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 4rem 3.5rem;
  position: relative;
  overflow: hidden;
}

.auth-brand::before {
  content: '';
  position: absolute;
  width: 640px; height: 640px;
  border-radius: 50%;
  border: 90px solid rgba(255,255,255,0.035);
  top: -200px; right: -220px;
  pointer-events: none;
}
.auth-brand::after {
  content: '';
  position: absolute;
  width: 420px; height: 420px;
  border-radius: 50%;
  border: 65px solid rgba(255,255,255,0.025);
  bottom: -130px; left: -130px;
  pointer-events: none;
}

.brand-eyebrow {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--accent-mid);
  margin-bottom: 1.4rem;
  position: relative; z-index: 1;
}

.brand-logo {
  font-family: var(--font-display);
  font-size: 3.4rem;
  font-weight: 700;
  color: #FFF;
  line-height: 1.1;
  margin-bottom: 1.4rem;
  position: relative; z-index: 1;
}
.brand-logo em { font-style: italic; color: var(--accent-mid); }

.brand-tagline {
  font-size: 1.05rem;
  font-weight: 300;
  color: rgba(255,255,255,0.5);
  max-width: 340px;
  line-height: 1.75;
  margin-bottom: 3.2rem;
  position: relative; z-index: 1;
}

.brand-features { display: flex; flex-direction: column; gap: 1.1rem; position: relative; z-index: 1; }

.brand-feature { display: flex; align-items: flex-start; gap: 14px; }

.brand-feature-icon {
  width: 42px; height: 42px;
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  display: flex; align-items: center; justify-content: center;
  font-size: 19px;
  flex-shrink: 0;
  margin-top: 1px;
}

.brand-feature-text strong {
  display: block;
  font-size: 0.88rem;
  font-weight: 600;
  color: rgba(255,255,255,0.88);
  line-height: 1.3;
}
.brand-feature-text span {
  font-size: 0.77rem;
  color: rgba(255,255,255,0.38);
}

/* ── Auth form panel ─────────────────────────────────────────── */
.auth-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3rem 2.5rem;
  background: var(--surface);
  transition: background var(--transition-slow);
  position: relative; z-index: 1;
}

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

.auth-title {
  font-family: var(--font-display);
  font-size: 2.1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.4rem;
  line-height: 1.2;
}

.auth-sub {
  color: var(--text-secondary);
  font-size: 0.92rem;
  margin-bottom: 2.2rem;
}

.auth-form { display: flex; flex-direction: column; gap: 1.1rem; }

.auth-theme-btn {
  position: fixed;
  top: 1.2rem; right: 1.2rem;
  width: 42px; height: 42px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  font-size: 17px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  z-index: 200;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition);
}
.auth-theme-btn:hover { transform: rotate(20deg) scale(1.1); box-shadow: var(--shadow-md); }

.auth-switch {
  text-align: center;
  margin-top: 1.8rem;
  font-size: 0.88rem;
  color: var(--text-secondary);
}
.auth-switch a { color: var(--accent); font-weight: 700; cursor: pointer; }
.auth-switch a:hover { text-decoration: underline; }

/* ══════════════════════════════════════════════════════════════
   FORM FIELDS
══════════════════════════════════════════════════════════════ */
.field-group { display: flex; flex-direction: column; gap: 6px; }

.field-group label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-secondary);
  letter-spacing: 0.6px;
  text-transform: uppercase;
}

.field-group input,
.field-group select,
.field-group textarea {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-md);
  font-size: 0.93rem;
  color: var(--text-primary);
  background: var(--surface-2);
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
  outline: none;
}
.field-group input:hover,
.field-group select:hover { border-color: var(--border-hover); }
.field-group input:focus,
.field-group select:focus,
.field-group textarea:focus {
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb),0.14);
}
.field-group textarea { resize: vertical; min-height: 80px; }

[data-theme="dark"] .field-group input,
[data-theme="dark"] .field-group select,
[data-theme="dark"] .field-group textarea { background: var(--surface-2); color: var(--text-primary); }
[data-theme="dark"] .field-group input:focus,
[data-theme="dark"] .field-group select:focus,
[data-theme="dark"] .field-group textarea:focus { background: var(--surface-3); }
[data-theme="dark"] .field-group select option  { background: var(--surface-2); }
[data-theme="dark"] .field-group input::placeholder,
[data-theme="dark"] .field-group textarea::placeholder { color: var(--text-hint); }
[data-theme="dark"] .tx-search { background-color: var(--surface-2); }
[data-theme="dark"] .tx-search:focus { background-color: var(--surface-3); }
[data-theme="dark"] #budgetAmount,
[data-theme="dark"] #budgetCategory { background: var(--surface-2); color: var(--text-primary); border-color: var(--border-strong); }

/* ══════════════════════════════════════════════════════════════
   BUTTONS
══════════════════════════════════════════════════════════════ */
.btn-primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 22px;
  background: var(--text-primary);
  color: var(--bg);
  border-radius: var(--radius-md);
  font-size: 0.92rem; font-weight: 700;
  letter-spacing: 0.1px;
  border: none; cursor: pointer;
  transition: all var(--transition);
  position: relative; overflow: hidden;
}
.btn-primary:hover  { opacity: 0.88; transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn-primary:active { transform: scale(0.975); box-shadow: none; }
.btn-primary:disabled { opacity: 0.45; cursor: not-allowed; transform: none; box-shadow: none; }

.btn-secondary {
  padding: 9px 18px;
  background: var(--surface-2);
  color: var(--text-secondary);
  border-radius: var(--radius-md);
  font-size: 0.84rem; font-weight: 600;
  border: 1px solid var(--border-strong);
  transition: all var(--transition);
}
.btn-secondary:hover { background: var(--surface-3); color: var(--text-primary); }

.btn-icon {
  width: 30px; height: 30px;
  border-radius: var(--radius-sm);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px;
  transition: all var(--transition-fast);
  color: var(--text-hint);
}
.btn-icon:hover             { background: var(--surface-2); color: var(--text-secondary); }
.btn-icon.btn-delete:hover  { background: var(--red-bg); color: var(--red); }

.btn-text-danger {
  font-size: 0.79rem; font-weight: 500;
  color: var(--red); background: none; padding: 0; cursor: pointer;
  transition: opacity var(--transition);
}
.btn-text-danger:hover { opacity: 0.7; }

/* ── Error / Success ─────────────────────────────────────────── */
.error-msg {
  font-size: 0.83rem; font-weight: 500;
  color: var(--red); background: var(--red-bg);
  padding: 10px 14px; border-radius: var(--radius-sm);
  border-left: 3px solid var(--red); display: none;
}
.success-msg {
  font-size: 0.83rem; font-weight: 500;
  color: var(--green); background: var(--green-bg);
  padding: 10px 14px; border-radius: var(--radius-sm);
  border-left: 3px solid var(--green); display: none;
}

/* ══════════════════════════════════════════════════════════════
   DASHBOARD LAYOUT
══════════════════════════════════════════════════════════════ */
.dashboard {
  display: flex;
  min-height: 100vh;
  position: relative; z-index: 1;
}
@media (max-width: 960px) {
  .dashboard { display: block; }
  .sidebar   { display: none; }
}

/* ══════════════════════════════════════════════════════════════
   SIDEBAR
══════════════════════════════════════════════════════════════ */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
  overflow-y: auto; overflow-x: hidden;
  width: var(--sidebar-w);
  transition: width 0.28s cubic-bezier(0.4,0,0.2,1), background var(--transition-slow);
  flex-shrink: 0;
}

.sidebar-top {
  padding: 1.2rem 1.2rem 1rem;
  border-bottom: 1px solid var(--border);
}

.sidebar-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.sidebar-logo {
  font-family: var(--font-display);
  font-size: 1.4rem; font-weight: 600;
  color: var(--text-primary);
  display: flex; align-items: center; gap: 10px;
  min-width: 0; overflow: hidden;
}

.sidebar-logo-text {
  white-space: nowrap;
  overflow: hidden;
}

.sidebar-logo-text em { font-style: italic; color: var(--accent); }
.sidebar-logo em { font-style: italic; color: var(--accent); }

.sidebar-logo-icon {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, #3A52CC, #5B6EE8);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 700;
  color: white; font-family: var(--font-body);
  box-shadow: 0 2px 8px rgba(58,82,204,0.35);
  flex-shrink: 0;
  letter-spacing: -1px;
}

/* Sidebar expand tab — floats outside the sidebar, only visible when collapsed */
.sidebar-expand-tab {
  display: none;
  position: fixed;
  top: 1.2rem;
  left: 68px;
  width: 22px;
  height: 40px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-left: none;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-hint);
  z-index: 199;
  box-shadow: 2px 2px 8px rgba(0,0,0,0.15);
  transition: background 0.15s, color 0.15s;
  padding: 0;
}
.sidebar-expand-tab:hover {
  background: var(--surface-2);
  color: var(--accent);
}
body.sidebar-is-collapsed .sidebar-expand-tab { display: flex; }
@media (max-width: 960px) { .sidebar-expand-tab { display: none !important; } }

.sidebar-nav { padding: 1rem 0.8rem; flex: 1; }

.sidebar-section-label {
  font-size: 0.65rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 1.5px;
  color: var(--text-hint);
  padding: 0 0.8rem;
  margin: 1.1rem 0 0.35rem;
}

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px;
  color: var(--text-secondary); font-size: 0.88rem; font-weight: 500;
  cursor: pointer; border-radius: var(--radius-md);
  margin-bottom: 1px; transition: all var(--transition);
  position: relative;
  white-space: nowrap; overflow: hidden;
}
.nav-item:hover { background: var(--surface-2); color: var(--text-primary); }
.nav-item.active {
  background: var(--accent-light); color: var(--accent-dark); font-weight: 600;
}
[data-theme="dark"] .nav-item.active { background: var(--accent-light); color: var(--accent); }
.nav-item.active::before {
  content: ''; position: absolute;
  left: 0; top: 22%; bottom: 22%;
  width: 3px; border-radius: 0 3px 3px 0;
  background: var(--accent);
}

.nav-label {
  flex: 1;
  transition: opacity 0.2s ease, width 0.2s ease;
  overflow: hidden;
}

.nav-icon {
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm); font-size: 16px;
  background: var(--surface-2); flex-shrink: 0;
  transition: background var(--transition);
}
.nav-item.active .nav-icon { background: rgba(var(--accent-rgb),0.15); }
.nav-item:hover  .nav-icon { background: var(--surface-3); }

/* ── Theme toggle ────────────────────────────────────────────── */
.sidebar-prefs { padding: 0.5rem 0.8rem; }

.theme-toggle {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; cursor: pointer;
  color: var(--text-secondary); font-size: 0.86rem; font-weight: 500;
  border-radius: var(--radius-md);
  transition: all var(--transition); user-select: none;
}
.theme-toggle:hover { background: var(--surface-2); color: var(--text-primary); }

.theme-toggle-icon {
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm); background: var(--surface-2);
  font-size: 15px; flex-shrink: 0;
}

.toggle-track {
  width: 38px; height: 21px; border-radius: 12px;
  background: var(--surface-3); border: 1.5px solid var(--border-strong);
  position: relative; transition: all 0.25s ease;
  flex-shrink: 0; margin-left: auto;
}
[data-theme="dark"] .toggle-track { background: var(--accent); border-color: var(--accent); }

.toggle-thumb {
  width: 13px; height: 13px; border-radius: 50%; background: white;
  position: absolute; top: 3px; left: 3px;
  transition: transform 0.25s cubic-bezier(0.4,0,0.2,1);
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}
[data-theme="dark"] .toggle-thumb { transform: translateX(17px); }

/* ── Sidebar footer ──────────────────────────────────────────── */
.sidebar-footer {
  padding: 0.9rem 1.1rem;
  border-top: 1px solid var(--border);
}

.sidebar-footer-inner {
  display: flex;
  align-items: center;
  gap: 6px;
}

.user-chip {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 9px; border-radius: var(--radius-md);
  transition: background var(--transition); cursor: default;
  min-width: 0; overflow: hidden;
}
.user-chip:hover { background: var(--surface-2); }

.logout-btn {
  font-size: 16px;
  color: var(--text-hint);
  padding: 7px 8px;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
  flex-shrink: 0;
  background: none;
  border: none;
  cursor: pointer;
  line-height: 1;
}
.logout-btn:hover { color: var(--red); background: var(--red-bg); }

.user-avatar {
  width: 34px; height: 34px; border-radius: var(--radius-sm);
  background: var(--text-primary); color: var(--bg);
  font-family: var(--font-display); font-size: 0.95rem; font-weight: 600;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}

.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 0.84rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text-primary); }
.user-role { font-size: 0.7rem; color: var(--text-hint); }



/* ══════════════════════════════════════════════════════════════
   MAIN CONTENT
══════════════════════════════════════════════════════════════ */
.main-content { flex: 1; min-width: 0; padding: 2.2rem 2.6rem; overflow-x: hidden; }
@media (max-width: 640px) { .main-content { padding: 1.2rem 1rem; } }

.page-section { display: none; min-width: 0; }
.page-section.active { display: block; animation: pageFadeIn 0.28s ease; min-width: 0; }

@keyframes pageFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

/* ── Page header ─────────────────────────────────────────────── */
.page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 2rem; flex-wrap: wrap; gap: 1rem;
}

.page-title {
  font-family: var(--font-display);
  font-size: 2rem; font-weight: 600;
  color: var(--text-primary); line-height: 1.15;
}

.page-subtitle { font-size: 0.86rem; color: var(--text-hint); margin-top: 4px; }

/* ── Month navigation ────────────────────────────────────────── */
.month-nav {
  display: flex; align-items: center; gap: 4px;
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius-md); padding: 3px;
  box-shadow: var(--shadow-xs);
}
.month-nav button {
  width: 30px; height: 30px; border-radius: var(--radius-sm);
  background: transparent; font-size: 1rem;
  color: var(--text-secondary); transition: all var(--transition-fast);
  display: flex; align-items: center; justify-content: center;
}
.month-nav button:hover { background: var(--surface-2); color: var(--text-primary); }
#monthLabel { font-size: 0.86rem; font-weight: 700; min-width: 126px; text-align: center; padding: 0 4px; }

/* ══════════════════════════════════════════════════════════════
   SUMMARY CARDS
══════════════════════════════════════════════════════════════ */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 1rem; margin-bottom: 1.8rem;
}

.summary-card {
  background: var(--surface); border-radius: var(--radius-lg);
  padding: 1.4rem 1.6rem; border: 1px solid var(--border);
  position: relative; overflow: hidden;
  transition: all var(--transition); cursor: default;
}
.summary-card::after {
  content: ''; position: absolute;
  bottom: 0; left: 0; right: 0; height: 3px;
}
.summary-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--border-hover); }

.card-income::after  { background: linear-gradient(90deg, var(--green), #6EBF8A); }
.card-expense::after { background: linear-gradient(90deg, var(--red), #E08888); }
.card-balance::after { background: linear-gradient(90deg, var(--accent), var(--accent-mid)); }
.card-count::after   { background: linear-gradient(90deg, var(--purple), #9870D8); }

.sc-icon-wrap {
  width: 40px; height: 40px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 19px; margin-bottom: 1rem;
}
.card-income  .sc-icon-wrap { background: var(--green-bg); }
.card-expense .sc-icon-wrap { background: var(--red-bg); }
.card-balance .sc-icon-wrap { background: var(--amber-bg); }
.card-count   .sc-icon-wrap { background: var(--purple-bg); }

.sc-label {
  font-size: 0.69rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.9px;
  color: var(--text-hint); margin-bottom: 4px;
}
.sc-value {
  font-family: var(--font-display);
  font-size: 1.65rem; font-weight: 600;
  color: var(--text-primary); line-height: 1.1;
}
.sc-sub { font-size: 0.73rem; color: var(--text-hint); margin-top: 4px; }

/* ══════════════════════════════════════════════════════════════
   PANELS
══════════════════════════════════════════════════════════════ */
.two-col {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 1.2rem; margin-bottom: 1.5rem;
  min-width: 0;
}
.two-col > * { min-width: 0; }
@media (max-width: 820px) { .two-col { grid-template-columns: 1fr; } }

.panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 1.4rem 1.6rem;
  transition: background var(--transition-slow), border-color var(--transition-slow);
  min-width: 0; overflow: hidden;
}

.panel-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1.2rem;
}

.panel-title {
  font-size: 0.69rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 1.2px;
  color: var(--text-hint);
}

.panel-action {
  font-size: 0.78rem; font-weight: 600;
  color: var(--accent); cursor: pointer;
  background: none; border: none;
  transition: opacity var(--transition);
}
.panel-action:hover { opacity: 0.7; }

/* ══════════════════════════════════════════════════════════════
   TRANSACTIONS
══════════════════════════════════════════════════════════════ */
.tx-toolbar {
  display: flex; align-items: center;
  gap: 10px; margin-bottom: 1.2rem; flex-wrap: wrap;
}

.filter-btns { display: flex; gap: 5px; }

.filter-btn {
  padding: 6px 14px; border-radius: 20px;
  font-size: 0.78rem; font-weight: 600;
  border: 1.5px solid var(--border-strong);
  color: var(--text-secondary); background: transparent;
  transition: all var(--transition); cursor: pointer;
}
.filter-btn:hover  { border-color: var(--accent); color: var(--accent); }
.filter-btn.active { background: var(--text-primary); border-color: var(--text-primary); color: var(--bg); }
[data-theme="dark"] .filter-btn.active { background: var(--surface-3); border-color: var(--accent); color: var(--accent); }

.tx-search {
  flex: 1; min-width: 150px;
  padding: 7px 14px 7px 36px;
  border: 1.5px solid var(--border-strong); border-radius: 20px;
  font-size: 0.84rem; outline: none;
  background: var(--surface-2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='13' height='13' viewBox='0 0 24 24' fill='none' stroke='%23A89A8A' stroke-width='2.5'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E") no-repeat 12px center;
  color: var(--text-primary); transition: all var(--transition);
}
.tx-search:focus { border-color: var(--accent); background-color: var(--surface); box-shadow: 0 0 0 3px rgba(var(--accent-rgb),0.1); }

.tx-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 8px; border-bottom: 1px solid var(--border);
  transition: background var(--transition-fast);
  border-radius: var(--radius-sm);
  margin: 0 -8px;
  animation: txIn 0.2s ease;
}
@keyframes txIn {
  from { opacity: 0; transform: translateX(-5px); }
  to   { opacity: 1; transform: none; }
}
.tx-row:last-child { border-bottom: none; }
.tx-row:hover      { background: var(--surface-2); }

.tx-icon {
  width: 40px; height: 40px; border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; flex-shrink: 0;
}

.tx-details { flex: 1; min-width: 0; }
.tx-desc { font-size: 0.88rem; font-weight: 600; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-meta { font-size: 0.74rem; color: var(--text-hint); margin-top: 2px; }
.tx-note { font-size: 0.72rem; color: var(--text-hint); margin-top: 2px; display: block; font-style: italic; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; opacity: 0.8; }

.tx-right { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.tx-amount { font-size: 0.93rem; font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
.amount-income  { color: var(--green); }
.amount-expense { color: var(--red); }

.tx-actions { display: flex; gap: 2px; opacity: 0; transition: opacity var(--transition); }
.tx-row:hover .tx-actions { opacity: 1; }

/* ══════════════════════════════════════════════════════════════
   DONUT / CHARTS
══════════════════════════════════════════════════════════════ */
.donut-wrap { position: relative; height: 196px; margin-bottom: 1.2rem; }

.donut-legend { display: flex; flex-direction: column; gap: 6px; }
.legend-item  { display: flex; align-items: center; gap: 9px; font-size: 0.81rem; }
.legend-dot   { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.legend-label { flex: 1; color: var(--text-secondary); font-weight: 500; }
.legend-pct   { font-weight: 700; color: var(--text-primary); font-size: 0.79rem; }

.trend-wrap { position: relative; height: 130px; }
.trend-legend {
  display: flex; gap: 14px; margin-top: 8px;
  font-size: 0.75rem; color: var(--text-hint); font-weight: 500;
}
.trend-legend span { display: flex; align-items: center; gap: 5px; }
.trend-legend i    { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }

/* ══════════════════════════════════════════════════════════════
   BUDGET
══════════════════════════════════════════════════════════════ */
.budget-row { margin-bottom: 1.2rem; }
.budget-row:last-child { margin-bottom: 0; }

.budget-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 7px; gap: 8px; }
.budget-cat    { font-size: 0.87rem; font-weight: 600; }
.budget-amounts { font-size: 0.77rem; color: var(--text-secondary); text-align: right; white-space: nowrap; }
.budget-amounts.over { color: var(--red); font-weight: 700; }

.over-badge {
  display: inline-block; background: var(--red-bg); color: var(--red);
  padding: 1px 7px; border-radius: 20px; font-size: 0.67rem;
  font-weight: 700; margin-left: 5px; text-transform: uppercase; letter-spacing: 0.5px;
}

.progress-bg   { height: 6px; border-radius: 10px; background: var(--surface-3); overflow: hidden; }
.progress-fill { height: 100%; border-radius: 10px; transition: width 0.6s cubic-bezier(0.4,0,0.2,1); }

.budget-footer { display: flex; justify-content: space-between; align-items: center; margin-top: 5px; }
.budget-pct    { font-size: 0.72rem; color: var(--text-hint); font-weight: 500; }

.budget-form-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: 10px; align-items: end; }
@media (max-width: 500px) { .budget-form-row { grid-template-columns: 1fr; } }

/* ══════════════════════════════════════════════════════════════
   INSIGHTS CHIPS
══════════════════════════════════════════════════════════════ */
.insights-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 1.2rem; }

.insight-chip { border-radius: var(--radius-md); padding: 14px 15px; transition: transform var(--transition); }
.insight-chip:hover { transform: translateY(-1px); }

.insight-val {
  font-family: var(--font-display); font-size: 1.3rem; font-weight: 600;
  display: block; line-height: 1.1;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.insight-label {
  font-size: 0.67rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.8px;
  display: block; margin-top: 4px; opacity: 0.7;
}

.chip-green { background: var(--green-bg); }
.chip-green .insight-val, .chip-green .insight-label { color: var(--green); }

.chip-amber { background: var(--amber-bg); }
.chip-amber .insight-val, .chip-amber .insight-label { color: var(--amber); }

.chip-blue { background: var(--blue-bg); }
.chip-blue .insight-val, .chip-blue .insight-label { color: var(--blue); }

.chip-red { background: var(--red-bg); }
.chip-red .insight-val, .chip-red .insight-label { color: var(--red); }

/* ══════════════════════════════════════════════════════════════
   MODAL
══════════════════════════════════════════════════════════════ */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(12,10,8,0.6);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  display: none; align-items: center; justify-content: center;
  z-index: 1000; padding: 1rem;
}
.modal-overlay.open { display: flex; }

.modal {
  background: var(--surface); border-radius: var(--radius-xl);
  width: 100%; max-width: 460px; max-height: 92vh; overflow-y: auto;
  box-shadow: var(--shadow-xl); border: 1px solid var(--border);
  animation: modalPop 0.22s cubic-bezier(0.34,1.56,0.64,1);
}
@keyframes modalPop {
  from { opacity: 0; transform: scale(0.92) translateY(12px); }
  to   { opacity: 1; transform: none; }
}

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1.6rem 1.8rem 0; margin-bottom: 1.4rem;
}
.modal-title { font-family: var(--font-display); font-size: 1.35rem; font-weight: 600; }

.modal-close {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--surface-2); color: var(--text-secondary);
  display: flex; align-items: center; justify-content: center; font-size: 15px;
  transition: all var(--transition);
}
.modal-close:hover { background: var(--surface-3); color: var(--text-primary); transform: rotate(90deg); }

.modal-form { display: flex; flex-direction: column; gap: 1.1rem; padding: 0 1.8rem 1.8rem; }

.type-toggle { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.type-btn {
  padding: 11px; border-radius: var(--radius-md);
  border: 2px solid var(--border-strong);
  font-size: 0.88rem; font-weight: 600;
  transition: all var(--transition);
  text-align: center; color: var(--text-secondary); background: var(--surface-2);
}
.type-btn:hover { border-color: var(--accent); }
.type-btn[data-type="income"].selected  { background: var(--green-bg); border-color: var(--green); color: var(--green); }
.type-btn[data-type="expense"].selected { background: var(--red-bg); border-color: var(--red); color: var(--red); }

/* ══════════════════════════════════════════════════════════════
   TOAST
══════════════════════════════════════════════════════════════ */
.toast {
  position: fixed; bottom: 1.8rem; right: 1.8rem;
  display: flex; align-items: center; gap: 10px;
  padding: 12px 18px;
  background: var(--text-primary); color: var(--bg);
  border-radius: var(--radius-md); font-size: 0.87rem; font-weight: 500;
  box-shadow: var(--shadow-lg); z-index: 9999;
  opacity: 0; transform: translateY(12px) scale(0.96);
  transition: all 0.25s cubic-bezier(0.34,1.56,0.64,1);
  max-width: 320px; border: 1px solid var(--border-strong);
}
.toast.show { opacity: 1; transform: none; }
.toast-icon { font-size: 14px; }
.toast-success .toast-icon { color: var(--green); }
.toast-error   .toast-icon { color: var(--red); }
.toast-info    .toast-icon { color: var(--blue); }
[data-theme="dark"] .toast { background: var(--surface-3); color: var(--text-primary); }

/* ══════════════════════════════════════════════════════════════
   GLOBAL LOADER
══════════════════════════════════════════════════════════════ */
#globalLoader {
  position: fixed; inset: 0;
  background: rgba(249,247,243,0.88); backdrop-filter: blur(4px);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  z-index: 9000; gap: 1rem;
}
[data-theme="dark"] #globalLoader { background: rgba(13,12,9,0.88); }

.spinner {
  width: 36px; height: 36px;
  border: 2.5px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: 50%; animation: spin 0.7s linear infinite;
}
.loader-text { font-size: 0.8rem; font-weight: 500; color: var(--text-hint); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ══════════════════════════════════════════════════════════════
   EMPTY STATE
══════════════════════════════════════════════════════════════ */
.empty-state { text-align: center; padding: 2.5rem 1.5rem; color: var(--text-secondary); }
.empty-icon  { font-size: 2.8rem; margin-bottom: 0.8rem; display: block; opacity: 0.55; }
.empty-state p     { font-weight: 600; font-size: 0.93rem; margin-bottom: 4px; }
.empty-state small { font-size: 0.8rem; color: var(--text-hint); }

/* ══════════════════════════════════════════════════════════════
   ANALYTICS TABLE
══════════════════════════════════════════════════════════════ */
.pill { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 20px; font-size: 0.75rem; font-weight: 700; }
.pill-green  { background: var(--green-bg);  color: var(--green); }
.pill-red    { background: var(--red-bg);    color: var(--red); }
.pill-amber  { background: var(--amber-bg);  color: var(--amber); }

/* ══════════════════════════════════════════════════════════════
   SCROLLBAR
══════════════════════════════════════════════════════════════ */
::-webkit-scrollbar       { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-hint); }

/* ══════════════════════════════════════════════════════════════
   MOBILE SIDEBAR + HAMBURGER
══════════════════════════════════════════════════════════════ */
.mobile-topbar {
  display: none;
  position: sticky; top: 0; z-index: 200;
  height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  align-items: center;
  padding: 0 1rem;
  gap: 12px;
}

.hamburger-btn {
  width: 38px; height: 38px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0;
  font-size: 18px;
  transition: background var(--transition);
}
.hamburger-btn:hover { background: var(--surface-3); }

.mobile-topbar-logo {
  font-family: var(--font-display);
  font-size: 1.1rem; font-weight: 600;
  color: var(--text-primary);
  flex: 1;
}
.mobile-topbar-logo em { font-style: italic; color: var(--accent); }



/* ══════════════════════════════════════════════════════════════
   PASSWORD EYE TOGGLE
══════════════════════════════════════════════════════════════ */
.pass-field-wrap {
  position: relative;
}
.pass-field-wrap input {
  width: 100%;
  padding-right: 44px !important;
}
.pass-eye-btn {
  position: absolute;
  right: 12px; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer;
  font-size: 16px; color: var(--text-hint);
  padding: 4px; border-radius: 4px;
  transition: color var(--transition);
  line-height: 1;
}
.pass-eye-btn:hover { color: var(--text-secondary); }

/* ══════════════════════════════════════════════════════════════
   IMPORT CSV BUTTON
══════════════════════════════════════════════════════════════ */
.import-drop-zone {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-md);
  padding: 2rem;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  background: var(--surface-2);
}
.import-drop-zone:hover,
.import-drop-zone.drag-over {
  border-color: var(--accent);
  background: var(--accent-light);
}
.import-drop-zone p { font-size: 0.9rem; color: var(--text-secondary); margin-top: 8px; }
.import-drop-zone small { font-size: 0.78rem; color: var(--text-hint); }

/* ══════════════════════════════════════════════════════════════
   OVERVIEW PERIOD TABS
══════════════════════════════════════════════════════════════ */

/* Overview controls: period tabs + month nav side by side */
.overview-controls {
  display: flex;
  align-items: center;
  gap: 0;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 3px;
  box-shadow: var(--shadow-xs);
}

.overview-controls .period-tabs {
  background: none;
  border-radius: 0;
  padding: 0;
  gap: 2px;
}

.overview-controls .month-nav {
  border: none;
  border-left: 1px solid var(--border-strong);
  border-radius: 0;
  padding: 0 2px;
  box-shadow: none;
  background: none;
  margin-left: 2px;
}

.period-tabs {
  display: flex;
  background: var(--surface-2);
  border-radius: 20px;
  padding: 3px;
  gap: 2px;
}

/* All period-tab states unified — Day same as Month/Year/All */
.period-tab {
  padding: 5px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem; font-weight: 600;
  color: var(--text-secondary);
  background: transparent; border: none; cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  line-height: 1.4;
}
.period-tab:hover {
  background: var(--surface-3);
  color: var(--text-primary);
}
.period-tab.active {
  background: var(--surface);
  color: var(--text-primary);
  box-shadow: var(--shadow-xs);
}
[data-theme="dark"] .period-tab.active {
  background: var(--surface-3);
  color: var(--accent);
}

/* Sidebar overlay */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(2px);
  z-index: 150;
}
.sidebar-overlay.active { display: block; }

/* ══════════════════════════════════════════════════════════════
   TRANSACTION FILTER DROPDOWNS
══════════════════════════════════════════════════════════════ */
.tx-filter-select {
  padding: 7px 32px 7px 12px;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-md);
  font-size: 0.85rem; font-weight: 600;
  color: var(--text-primary);
  background: var(--surface-2);
  cursor: pointer; outline: none;
  appearance: none;
  -webkit-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='%23A89A8A' stroke-width='2.5'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  transition: all var(--transition);
  min-width: 130px;
}
.tx-filter-select:hover { border-color: var(--border-hover); }
.tx-filter-select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(var(--accent-rgb),0.12); }
[data-theme="dark"] .tx-filter-select { background-color: var(--surface-2); }


/* ══════════════════════════════════════════════════════════════
   SIDEBAR TOGGLE + MOBILE RESPONSIVE
══════════════════════════════════════════════════════════════ */

/* Hamburger toggle button */
.sidebar-toggle-btn {
  display: none;
  position: fixed;
  bottom: 1.2rem;
  left: 1.2rem;
  width: 48px; height: 48px;
  border-radius: 50%;
  background: var(--text-primary);
  color: var(--bg);
  border: none;
  font-size: 20px;
  align-items: center; justify-content: center;
  cursor: pointer;
  z-index: 300;
  box-shadow: var(--shadow-lg);
  transition: all 0.2s ease;
}
.sidebar-toggle-btn:hover { transform: scale(1.08); }

/* Desktop sidebar collapse — icon-only button */
.sidebar-collapse-btn {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text-hint);
  cursor: pointer;
  transition: all 0.15s;
  flex-shrink: 0;
  padding: 0;
}
.sidebar-collapse-btn:hover {
  background: var(--surface-3);
  color: var(--text-secondary);
  border-color: var(--border-hover);
}

.sidebar-expand-btn {
  display: none;
  width: 32px; height: 32px;
  align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text-hint);
  cursor: pointer;
  transition: all 0.15s;
  padding: 0;
  margin: 0 auto;
}
.sidebar-expand-btn:hover {
  background: var(--surface-3);
  color: var(--text-secondary);
}

/* Mobile sidebar — slide in from left */
@media (max-width: 960px) {
  .sidebar-toggle-btn { display: flex; }
  .sidebar-collapse-btn { display: none; }

  .sidebar {
    display: flex !important;
    position: fixed;
    left: -280px;
    top: 0; bottom: 0;
    width: 280px;
    z-index: 200;
    transition: left 0.28s cubic-bezier(0.4,0,0.2,1);
    box-shadow: none;
  }

  .sidebar.mobile-open {
    left: 0;
    box-shadow: var(--shadow-xl);
  }

  .main-content {
    padding: 1rem;
    padding-top: 68px;
    padding-bottom: 72px;
  }

  /* Mobile bottom nav bar */
  .mobile-bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: 60px;
    background: var(--surface);
    border-top: 1px solid var(--border);
    z-index: 100;
    align-items: stretch;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.08);
  }

  .mobile-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    font-size: 0.6rem;
    font-weight: 600;
    color: var(--text-hint);
    cursor: pointer;
    transition: all 0.15s;
    border: none;
    background: none;
    padding: 6px 4px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
  }
  .mobile-nav-item:hover    { color: var(--text-secondary); }
  .mobile-nav-item.active   { color: var(--accent); }
  .mobile-nav-item .mn-icon { font-size: 20px; line-height: 1; }

  .summary-grid { grid-template-columns: repeat(2, 1fr); }
  .two-col      { grid-template-columns: 1fr; }

  /* Stack tx toolbar on mobile */
  .tx-toolbar { flex-direction: column; align-items: stretch; }

  /* Auth page mobile */
  .auth-page { grid-template-columns: 1fr; }
  .auth-brand { display: none; }
  .auth-panel { padding: 2rem 1.2rem; }
}

/* Small screens */
@media (max-width: 480px) {
  .summary-grid { grid-template-columns: 1fr 1fr; gap: 0.6rem; }
  .sc-value { font-size: 1.3rem; }
  .page-title { font-size: 1.6rem; }
  .panel { padding: 1rem; }
  .tx-filter-select { min-width: unset; width: 100%; }
  .modal { border-radius: var(--radius-lg) !important; }
  .modal-form { padding: 0 1.1rem 1.1rem !important; }
  .modal-header { padding: 1.1rem 1.1rem 0 !important; }
  .type-toggle { grid-template-columns: 1fr 1fr; }
  .account-type-picker-btn { padding: 6px 2px; }
  .account-type-picker-btn span { font-size: 0.55rem; }
  /* Full-width filter dropdowns on small screens */
  #section-transactions .panel > div { flex-direction: column; align-items: stretch !important; }
  .tx-filter-select, .tx-search { width: 100% !important; min-width: unset !important; }
  /* Loan cards */
  .loan-card > div:first-child { flex-direction: column !important; }
}

/* ══════════════════════════════════════════════════════════════
   SIDEBAR COLLAPSED STATE
══════════════════════════════════════════════════════════════ */
.sidebar.collapsed {
  width: 68px;
}

/* Hide all text/labels instantly */
.sidebar.collapsed .sidebar-section-label,
.sidebar.collapsed .user-info,
.sidebar.collapsed .toggle-track,
.sidebar.collapsed .sidebar-logo em {
  display: none;
}

/* Logo: hide text, show just icon centered */
.sidebar.collapsed .sidebar-top-row  { justify-content: center; }
.sidebar.collapsed .sidebar-logo     { gap: 0; justify-content: center; }
.sidebar.collapsed .sidebar-logo-text { display: none; }
.sidebar.collapsed .sidebar-logo-icon {
  width: 34px; height: 34px;
  font-size: 16px;
}

/* Hide collapse btn, show expand row */
.sidebar.collapsed .sidebar-collapse-btn { display: none; }
.sidebar.collapsed .sidebar-expand-row   { display: flex; }

/* Nav items: center icons, hide labels */
.sidebar.collapsed .sidebar-nav { padding: 1rem 0.5rem; }
.sidebar.collapsed .nav-item {
  padding: 10px;
  justify-content: center;
  gap: 0;
}
.sidebar.collapsed .nav-label { display: none; }
.sidebar.collapsed .nav-item.active::before { display: none; }
.sidebar.collapsed .nav-icon {
  width: 36px; height: 36px;
  font-size: 17px;
  flex-shrink: 0;
}

/* Tooltip on hover when collapsed — positioned via JS to escape overflow */
.sidebar-tooltip {
  position: fixed;
  background: var(--text-primary);
  color: var(--bg);
  font-size: 0.78rem;
  font-weight: 600;
  font-family: var(--font-body);
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  pointer-events: none;
  z-index: 9999;
  box-shadow: var(--shadow-md);
  opacity: 0;
  transition: opacity 0.15s ease;
}
.sidebar-tooltip.visible { opacity: 1; }

/* Footer: center avatar, hide name/role/logout */
.sidebar.collapsed .sidebar-footer       { padding: 0.6rem 0.5rem; }
.sidebar.collapsed .sidebar-top          { padding: 1rem 0.6rem; }
.sidebar.collapsed .sidebar-footer-inner { justify-content: center; gap: 0; }
.sidebar.collapsed .user-chip            { padding: 6px; gap: 0; flex: 0 0 auto; }
.sidebar.collapsed .user-info            { display: none; }
.sidebar.collapsed .logout-btn           { display: none; }
.sidebar.collapsed .user-avatar          { margin: 0; }

/* Mobile bottom nav hidden on desktop */
.mobile-bottom-nav { display: none; }

/* Responsive table */
@media (max-width: 640px) {
  table { font-size: 0.78rem; }
  th, td { padding: 7px 8px !important; }
}

/* Touch-friendly buttons on mobile */
@media (max-width: 960px) {
  .btn-primary, .btn-secondary { padding: 11px 18px; min-height: 44px; }
  .filter-btn  { padding: 8px 14px; min-height: 38px; }
  .tx-sort-btn { padding: 7px 12px; min-height: 36px; }
}

/* ══════════════════════════════════════════════════════════════
   AI ADVISOR
══════════════════════════════════════════════════════════════ */

/* Nav icon accent */
.nav-item[data-section="ai"] .nav-icon {
  background: linear-gradient(135deg, rgba(var(--accent-rgb),0.2), rgba(var(--accent-rgb),0.05));
  color: var(--accent);
  font-size: 14px;
  font-weight: 700;
  font-family: var(--font-display);
}

/* Insight bar */
.ai-insight-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 1.2rem;
  min-height: 72px;
  align-items: stretch;
}
.ai-insight-loading {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.85rem;
  color: var(--text-hint);
  padding: 1rem;
}
.ai-insight-card {
  flex: 1;
  min-width: 160px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.9rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 4px;
  cursor: pointer;
  transition: all var(--transition);
}
.ai-insight-card:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}
.ai-insight-card-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-hint);
}
.ai-insight-card-val {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.1;
}
.ai-insight-card-sub {
  font-size: 0.75rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

/* Prompt chips */
.ai-prompts {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 1.2rem;
}
.ai-prompt-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-hint);
  white-space: nowrap;
}
.ai-chip {
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.80rem;
  font-weight: 500;
  border: 1.5px solid var(--border-strong);
  color: var(--text-secondary);
  background: var(--surface-2);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.ai-chip:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-light);
}

/* Chat window */
.ai-chat-window {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.4rem;
  min-height: 360px;
  max-height: 520px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
  margin-bottom: 1rem;
  scroll-behavior: smooth;
}

/* Welcome state */
.ai-welcome {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 0.8rem;
}
.ai-welcome-icon {
  width: 40px; height: 40px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, rgba(var(--accent-rgb),0.25), rgba(var(--accent-rgb),0.08));
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; color: var(--accent);
  font-family: var(--font-display);
  font-weight: 700;
  flex-shrink: 0;
}
.ai-welcome-text {
  display: flex; flex-direction: column; gap: 6px;
}
.ai-welcome-text strong {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
}
.ai-welcome-text span {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.65;
}

/* Chat messages */
.ai-msg {
  display: flex;
  gap: 12px;
  animation: txIn 0.2s ease;
}
.ai-msg.user { flex-direction: row-reverse; }

.ai-msg-avatar {
  width: 34px; height: 34px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700;
  flex-shrink: 0;
}
.ai-msg.assistant .ai-msg-avatar {
  background: linear-gradient(135deg, rgba(var(--accent-rgb),0.25), rgba(var(--accent-rgb),0.08));
  color: var(--accent);
  font-family: var(--font-display);
}
.ai-msg.user .ai-msg-avatar {
  background: var(--text-primary);
  color: var(--bg);
  font-family: var(--font-display);
}

.ai-msg-bubble {
  max-width: 78%;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  line-height: 1.72;
  color: var(--text-primary);
}
.ai-msg.assistant .ai-msg-bubble {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 4px var(--radius-md) var(--radius-md) var(--radius-md);
}
.ai-msg.user .ai-msg-bubble {
  background: var(--text-primary);
  color: var(--bg);
  border-radius: var(--radius-md) 4px var(--radius-md) var(--radius-md);
}

/* Typing indicator */
.ai-typing {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 10px 14px;
}
.ai-typing span {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--text-hint);
  animation: aiTypingDot 1.2s infinite ease-in-out;
}
.ai-typing span:nth-child(2) { animation-delay: 0.2s; }
.ai-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes aiTypingDot {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-5px); opacity: 1; }
}

/* Markdown-style response formatting */
.ai-msg-bubble strong { font-weight: 700; }
.ai-msg-bubble em { font-style: italic; }
.ai-msg-bubble ul { padding-left: 1.2rem; margin: 6px 0; }
.ai-msg-bubble li { margin-bottom: 4px; }
.ai-msg-bubble .ai-section-head {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--accent);
  margin: 10px 0 4px;
}

/* Input row */
.ai-input-row {
  display: flex;
  gap: 10px;
  align-items: center;
}
.ai-input {
  flex: 1;
  padding: 12px 18px;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-lg);
  font-size: 0.92rem;
  background: var(--surface-2);
  color: var(--text-primary);
  outline: none;
  transition: all var(--transition);
  font-family: var(--font-body);
}
.ai-input:focus {
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.12);
}
.ai-input::placeholder { color: var(--text-hint); }

.ai-send-btn {
  width: 46px; height: 46px;
  border-radius: var(--radius-md);
  background: var(--text-primary);
  color: var(--bg);
  border: none;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
  flex-shrink: 0;
}
.ai-send-btn:hover   { opacity: 0.85; transform: translateY(-1px); }
.ai-send-btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
