/* ── Variables ──────────────────────────────────────────────── */
:root {
  --accent:       #0066FF;
  --accent-light: #EBF2FF;
  --accent-dark:  #0052CC;
  --green:        #00B37D;
  --green-light:  #E6F7F2;
  --red:          #E53935;
  --red-light:    #FFF0EF;
  --orange:       #F59E0B;
  --orange-light: #FFF8E6;
  --purple:       #7C3AED;
  --purple-light: #F3EEFF;

  --bg:        #F5F7FA;
  --bg2:       #FFFFFF;
  --bg3:       #F0F2F5;
  --bg4:       #E8ECF0;

  --text:      #0D1117;
  --text2:     #4B5563;
  --text3:     #9CA3AF;
  --text4:     #D1D5DB;

  --border:    rgba(0,0,0,0.07);
  --border2:   rgba(0,0,0,0.12);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow:    0 4px 12px rgba(0,0,0,0.08), 0 1px 3px rgba(0,0,0,0.05);
  --shadow-lg: 0 16px 40px rgba(0,0,0,0.12), 0 4px 12px rgba(0,0,0,0.06);

  --radius-sm: 6px;
  --radius:    10px;
  --radius-lg: 14px;
  --radius-xl: 20px;

  --sidebar-w: 240px;
  --header-h:  56px;
  --font:      -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', sans-serif;
}

[data-theme="dark"] {
  --bg:     #0D1117;
  --bg2:    #161B22;
  --bg3:    #1C2128;
  --bg4:    #242B35;
  --text:   #E6EDF3;
  --text2:  #8B949E;
  --text3:  #484F58;
  --text4:  #30363D;
  --border:  rgba(255,255,255,0.06);
  --border2: rgba(255,255,255,0.10);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow:    0 4px 12px rgba(0,0,0,0.4);
  --shadow-lg: 0 16px 40px rgba(0,0,0,0.5);
  --accent-light: rgba(0,102,255,0.12);
  --green-light:  rgba(0,179,125,0.12);
  --red-light:    rgba(229,57,53,0.12);
  --orange-light: rgba(245,158,11,0.12);
}

/* ── Reset ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; -webkit-text-size-adjust: 100%; }
body { font-family: var(--font); background: var(--bg); color: var(--text); line-height: 1.5; min-height: 100vh; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font-family: inherit; font-size: inherit; }
a { text-decoration: none; color: inherit; cursor: pointer; }
img, svg { display: block; }

/* ── Auth ───────────────────────────────────────────────────── */
.auth-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1.5rem; background: var(--bg); }
.auth-container { width: 100%; max-width: 400px; }
.auth-brand { text-align: center; margin-bottom: 2rem; }
.auth-logo { display: inline-flex; align-items: center; gap: 10px; font-size: 20px; font-weight: 700; color: var(--text); margin-bottom: .5rem; }
.auth-tagline { font-size: 13px; color: var(--text3); }
.auth-card { background: var(--bg2); border: 1px solid var(--border2); border-radius: var(--radius-xl); padding: 1.75rem; box-shadow: var(--shadow); }
.auth-banner { display: flex; align-items: flex-start; gap: 8px; padding: 10px 14px; border-radius: var(--radius); font-size: 13px; margin-bottom: 1.25rem; line-height: 1.4; }
.auth-banner.setup   { background: var(--accent-light); color: var(--accent-dark); }
.auth-banner.warning { background: var(--orange-light); color: #92400E; }
.auth-banner.error   { background: var(--red-light); color: #991B1B; }
.auth-banner svg     { flex-shrink: 0; margin-top: 1px; }
.auth-tabs { display: flex; background: var(--bg3); border-radius: var(--radius); padding: 3px; margin-bottom: 1.5rem; gap: 3px; }
.auth-tab { flex: 1; padding: 8px; font-size: 13px; font-weight: 500; border: none; background: none; border-radius: 7px; cursor: pointer; color: var(--text2); transition: all .15s; }
.auth-tab.active { background: var(--bg2); color: var(--text); box-shadow: var(--shadow-sm); }
.auth-fields { display: flex; flex-direction: column; gap: 1rem; margin-bottom: 1.25rem; }
.btn-auth { width: 100%; padding: 11px; background: var(--accent); color: #fff; border: none; border-radius: var(--radius); font-size: 14px; font-weight: 600; cursor: pointer; transition: opacity .15s; letter-spacing: .01em; }
.btn-auth:hover { opacity: .88; }
.btn-auth:disabled { opacity: .5; cursor: not-allowed; }
.auth-version { text-align: center; margin-top: 1.5rem; font-size: 11px; color: var(--text3); }

/* ── Layout ─────────────────────────────────────────────────── */
#mainApp { display: flex; height: 100vh; overflow: hidden; }

/* ── Sidebar ────────────────────────────────────────────────── */
.sidebar { width: var(--sidebar-w); background: var(--bg2); border-right: 1px solid var(--border); display: flex; flex-direction: column; flex-shrink: 0; overflow-y: auto; overflow-x: hidden; }
.sidebar-header { display: flex; align-items: center; justify-content: space-between; padding: 1.25rem 1rem; border-bottom: 1px solid var(--border); }
.sidebar-logo { display: flex; align-items: center; gap: 9px; font-size: 15px; font-weight: 700; color: var(--text); }
.sidebar-close { display: none; background: none; border: none; cursor: pointer; color: var(--text2); padding: 4px; }
.sidebar-nav { flex: 1; padding: .75rem .75rem 0; display: flex; flex-direction: column; gap: 2px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: var(--radius); font-size: 13px; font-weight: 500; color: var(--text2); cursor: pointer; transition: all .12s; border: none; background: none; width: 100%; text-align: left; }
.nav-item:hover { background: var(--bg3); color: var(--text); }
.nav-item.active { background: var(--accent-light); color: var(--accent); }
.nav-item.active svg { stroke: var(--accent); }
.nav-item svg { flex-shrink: 0; opacity: .7; }
.nav-item.active svg { opacity: 1; }
.admin-link { color: var(--purple) !important; }
.admin-link svg { stroke: var(--purple) !important; opacity: 1 !important; }
.admin-link:hover,.admin-link.active { background: var(--purple-light) !important; }
.sidebar-footer { padding: .75rem; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 2px; }
.sidebar-user { display: flex; align-items: center; gap: 9px; padding: 8px 10px; margin-top: 4px; }
.sidebar-avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--accent-light); color: var(--accent); font-size: 12px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-info span { display: block; font-size: 12px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-plan { font-size: 10px !important; color: var(--text3) !important; font-weight: 400 !important; text-transform: uppercase; letter-spacing: .05em; }
.logout-btn { background: none; border: none; cursor: pointer; color: var(--text3); padding: 4px; flex-shrink: 0; transition: color .15s; }
.logout-btn:hover { color: var(--red); }

/* Profile selector */
.profile-selector { padding: .75rem; border-bottom: 1px solid var(--border); position: relative; }
.profile-current { display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px 10px; background: var(--bg3); border: 1px solid var(--border2); border-radius: var(--radius); cursor: pointer; text-align: left; transition: all .12s; }
.profile-current:hover { background: var(--bg4); }
.profile-icon { font-size: 18px; flex-shrink: 0; line-height: 1; }
.profile-info { flex: 1; min-width: 0; }
.profile-name { display: block; font-size: 12px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.profile-type { display: block; font-size: 10px; color: var(--text3); text-transform: capitalize; }
.profile-chevron { flex-shrink: 0; color: var(--text3); transition: transform .15s; }
.profile-menu { position: absolute; top: calc(100% - .25rem); left: .75rem; right: .75rem; background: var(--bg2); border: 1px solid var(--border2); border-radius: var(--radius); box-shadow: var(--shadow-lg); z-index: 100; padding: .5rem; }
.profile-menu-item { display: flex; align-items: center; gap: 8px; padding: 7px 8px; border-radius: var(--radius-sm); cursor: pointer; font-size: 13px; font-weight: 500; color: var(--text2); transition: all .1s; }
.profile-menu-item:hover { background: var(--bg3); color: var(--text); }
.profile-menu-item.active { background: var(--accent-light); color: var(--accent); }
.profile-add-btn { display: flex; align-items: center; gap: 6px; width: 100%; padding: 7px 8px; border: none; background: none; border-top: 1px solid var(--border); margin-top: .25rem; padding-top: .625rem; cursor: pointer; font-size: 12px; color: var(--text3); font-weight: 500; border-radius: 0; transition: color .1s; }
.profile-add-btn:hover { color: var(--accent); }

/* Mobile header */
.mobile-header { display: none; height: var(--header-h); background: var(--bg2); border-bottom: 1px solid var(--border); padding: 0 1rem; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 30; }
.menu-btn,.mobile-logo { background: none; border: none; cursor: pointer; display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 700; color: var(--text); }
.mobile-profile-icon { font-size: 20px; cursor: pointer; }
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 39; backdrop-filter: blur(2px); }

/* Main content */
.main-content { flex: 1; overflow-y: auto; overflow-x: hidden; }
.view { display: none; padding: 2rem; max-width: 1100px; margin: 0 auto; }
.view.active { display: block; }

/* ── Common components ──────────────────────────────────────── */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 2rem; flex-wrap: wrap; gap: 1rem; }
.page-title { font-size: 22px; font-weight: 700; color: var(--text); }
.page-subtitle { font-size: 13px; color: var(--text3); margin-top: 2px; }

/* Cards */
.card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 1.5rem; box-shadow: var(--shadow-sm); }
.card-sm { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow-sm); }

/* KPI cards */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1.5rem; }
.kpi-card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 1.25rem 1.5rem; position: relative; overflow: hidden; box-shadow: var(--shadow-sm); }
.kpi-card::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px; border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
.kpi-card.income::before  { background: var(--green); }
.kpi-card.expense::before { background: var(--red); }
.kpi-card.balance::before { background: var(--accent); }
.kpi-card.savings::before { background: var(--orange); }
.kpi-label { font-size: 11px; font-weight: 600; color: var(--text3); text-transform: uppercase; letter-spacing: .06em; margin-bottom: .5rem; display: flex; align-items: center; gap: 5px; }
.kpi-value { font-size: 24px; font-weight: 700; color: var(--text); letter-spacing: -.5px; line-height: 1; }
.kpi-value.positive { color: var(--green); }
.kpi-value.negative { color: var(--red); }
.kpi-delta { font-size: 12px; color: var(--text3); margin-top: 4px; }
.kpi-delta.up   { color: var(--green); }
.kpi-delta.down { color: var(--red); }

/* Buttons */
.btn-primary { display: inline-flex; align-items: center; gap: 6px; padding: 9px 18px; background: var(--accent); color: #fff; border: none; border-radius: var(--radius); font-size: 13px; font-weight: 600; cursor: pointer; transition: opacity .15s; letter-spacing: .01em; }
.btn-primary:hover { opacity: .88; }
.btn-secondary { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; background: var(--bg3); color: var(--text); border: 1px solid var(--border2); border-radius: var(--radius); font-size: 13px; font-weight: 500; cursor: pointer; transition: background .12s; }
.btn-secondary:hover { background: var(--bg4); }
.btn-ghost { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; background: none; color: var(--text2); border: none; border-radius: var(--radius); font-size: 13px; font-weight: 500; cursor: pointer; transition: background .12s; }
.btn-ghost:hover { background: var(--bg3); }
.btn-danger { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; background: var(--red-light); color: var(--red); border: 1px solid rgba(229,57,53,.2); border-radius: var(--radius); font-size: 13px; font-weight: 500; cursor: pointer; }
.btn-icon { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; background: var(--bg3); border: 1px solid var(--border2); border-radius: var(--radius-sm); cursor: pointer; color: var(--text2); transition: all .12s; }
.btn-icon:hover { background: var(--bg4); color: var(--text); }
.btn-icon.danger:hover { background: var(--red-light); color: var(--red); border-color: transparent; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* Form elements */
.field-wrap { display: flex; flex-direction: column; gap: 5px; }
.field-wrap.full { grid-column: 1 / -1; }
.field-wrap label { font-size: 12px; font-weight: 600; color: var(--text2); letter-spacing: .01em; }
.label-hint { font-weight: 400; color: var(--text3); }
input[type=text], input[type=number], input[type=date], input[type=password], input[type=email], select, textarea {
  width: 100%; padding: 9px 12px;
  background: var(--bg3); border: 1px solid var(--border2); border-radius: var(--radius);
  font-size: 13px; color: var(--text); outline: none;
  transition: border-color .15s, box-shadow .15s;
  -webkit-appearance: none; appearance: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0,102,255,.1);
  background: var(--bg2);
}
textarea { resize: vertical; min-height: 72px; font-family: inherit; line-height: 1.5; }
select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236B7280' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 11px center; padding-right: 30px; }
.input-icon-wrap { position: relative; }
.input-icon-wrap input { padding-right: 38px; }
.input-icon-btn { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); background: none; border: none; cursor: pointer; color: var(--text3); padding: 4px; }

/* Type selector */
.type-selector { display: flex; background: var(--bg3); border-radius: var(--radius); padding: 3px; gap: 3px; margin-bottom: 1.25rem; }
.type-btn { flex: 1; display: flex; align-items: center; justify-content: center; gap: 5px; padding: 8px; font-size: 13px; font-weight: 600; border: none; background: none; border-radius: 7px; cursor: pointer; color: var(--text2); transition: all .15s; }
.type-btn.active.expense { background: var(--bg2); color: var(--red); box-shadow: var(--shadow-sm); }
.type-btn.active.income  { background: var(--bg2); color: var(--green); box-shadow: var(--shadow-sm); }

/* Amount input */
.amount-input-wrap { display: flex; align-items: center; background: var(--bg3); border: 1px solid var(--border2); border-radius: var(--radius-lg); padding: .5rem 1rem; margin-bottom: 1.25rem; gap: 6px; }
.amount-currency { font-size: 24px; font-weight: 700; color: var(--text2); }
.amount-input { flex: 1; background: none; border: none; font-size: 28px; font-weight: 700; color: var(--text); outline: none; padding: 0; min-width: 0; }
.amount-input::placeholder { color: var(--text4); }
.amount-input:focus { box-shadow: none; background: none; border: none; }
.modal-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

/* Tag suggestions */
.tag-suggestions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; }
.tag-pill { display: inline-flex; align-items: center; gap: 3px; padding: 3px 9px; background: var(--bg3); border: 1px solid var(--border2); border-radius: 20px; font-size: 11px; font-weight: 500; color: var(--text2); cursor: pointer; transition: all .1s; }
.tag-pill:hover { background: var(--accent-light); color: var(--accent); border-color: transparent; }

/* Transaction list */
.tx-list { display: flex; flex-direction: column; }
.tx-item { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); transition: background .1s; cursor: default; }
.tx-item:first-child { border-radius: var(--radius) var(--radius) 0 0; }
.tx-item:last-child  { border-radius: 0 0 var(--radius) var(--radius); border-bottom: none; }
.tx-item:only-child  { border-radius: var(--radius); border-bottom: none; }
.tx-item:hover { background: var(--bg3); }
.tx-icon { width: 36px; height: 36px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 15px; flex-shrink: 0; }
.tx-icon.income  { background: var(--green-light); }
.tx-icon.expense { background: var(--red-light); }
.tx-body { flex: 1; min-width: 0; }
.tx-desc { font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-meta { font-size: 11px; color: var(--text3); margin-top: 2px; }
.tx-tags { display: flex; gap: 3px; margin-top: 3px; flex-wrap: wrap; }
.tx-tag { font-size: 10px; padding: 1px 6px; background: var(--bg3); border-radius: 10px; color: var(--text3); border: 1px solid var(--border); }
.tx-amount { font-size: 14px; font-weight: 700; white-space: nowrap; flex-shrink: 0; }
.tx-amount.income  { color: var(--green); }
.tx-amount.expense { color: var(--red); }
.tx-actions { display: flex; gap: 4px; opacity: 0; transition: opacity .15s; }
.tx-item:hover .tx-actions { opacity: 1; }

/* Chart containers */
.chart-wrap { position: relative; width: 100%; }
.chart-wrap.h220 { height: 220px; }
.chart-wrap.h200 { height: 200px; }
.chart-wrap.h180 { height: 180px; }
.chart-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }

/* Progress bars */
.progress-wrap { margin-bottom: 1rem; }
.progress-label { display: flex; justify-content: space-between; align-items: center; margin-bottom: 5px; }
.progress-name { font-size: 13px; font-weight: 500; color: var(--text); }
.progress-info { font-size: 12px; color: var(--text3); }
.progress-bar-bg { height: 6px; background: var(--bg4); border-radius: 3px; overflow: hidden; }
.progress-bar { height: 100%; border-radius: 3px; transition: width .4s ease; }

/* Badges */
.badge { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 600; letter-spacing: .02em; }
.badge.green  { background: var(--green-light);  color: #065F46; }
.badge.red    { background: var(--red-light);    color: #991B1B; }
.badge.blue   { background: var(--accent-light); color: var(--accent-dark); }
.badge.orange { background: var(--orange-light); color: #92400E; }
.badge.purple { background: var(--purple-light); color: var(--purple); }

/* Filters */
.filter-bar { display: flex; gap: 8px; margin-bottom: 1.25rem; flex-wrap: wrap; }
.filter-bar select, .filter-bar input { flex: 1; min-width: 120px; }
.search-wrap { position: relative; flex: 2; min-width: 180px; }
.search-wrap svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text3); pointer-events: none; }
.search-wrap input { padding-left: 34px; }

/* Modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 50; backdrop-filter: blur(3px); }
.modal { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 51; width: 100%; max-width: 520px; background: var(--bg2); border-radius: var(--radius-xl); box-shadow: var(--shadow-lg); max-height: 90vh; display: flex; flex-direction: column; border: 1px solid var(--border2); }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--border); }
.modal-header h3 { font-size: 16px; font-weight: 700; }
.modal-close { background: none; border: none; cursor: pointer; color: var(--text3); padding: 4px; border-radius: var(--radius-sm); transition: all .1s; }
.modal-close:hover { background: var(--bg3); color: var(--text); }
.modal-body { flex: 1; overflow-y: auto; padding: 1.5rem; }
.modal-footer { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 1rem 1.5rem; border-top: 1px solid var(--border); }

/* Color picker */
.color-picker-row { display: flex; gap: 6px; flex-wrap: wrap; }
.color-dot { width: 24px; height: 24px; border-radius: 50%; cursor: pointer; border: 2px solid transparent; transition: transform .1s; }
.color-dot:hover { transform: scale(1.15); }
.color-dot.active { border-color: var(--text); }

/* Section header */
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.section-title { font-size: 14px; font-weight: 700; color: var(--text); }
.section-link { font-size: 12px; color: var(--accent); font-weight: 500; }

/* Empty state */
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--text3); }
.empty-state svg { margin: 0 auto 1rem; opacity: .3; }
.empty-state p { font-size: 14px; }
.empty-state small { font-size: 12px; margin-top: 4px; display: block; }

/* Admin specific */
.user-row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.user-row:last-child { border-bottom: none; }
.user-avatar { width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; flex-shrink: 0; }
.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 13px; font-weight: 600; }
.user-meta { font-size: 11px; color: var(--text3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-actions { display: flex; gap: 4px; flex-shrink: 0; }

/* Settings */
.settings-section { margin-bottom: 2rem; }
.settings-title { font-size: 11px; font-weight: 700; color: var(--text3); text-transform: uppercase; letter-spacing: .08em; margin-bottom: .75rem; padding-left: 2px; }
.settings-row { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--border); gap: 1rem; }
.settings-row:last-child { border-bottom: none; }
.settings-row-label { font-size: 13px; font-weight: 500; color: var(--text); }
.settings-row-desc  { font-size: 12px; color: var(--text3); margin-top: 2px; }
.settings-row-right { flex-shrink: 0; }
.settings-row input[type=text],.settings-row input[type=number],.settings-row select { width: auto; min-width: 160px; }

/* Toggle switch */
.toggle { position: relative; width: 40px; height: 22px; flex-shrink: 0; cursor: pointer; }
.toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle-track { position: absolute; inset: 0; background: var(--bg4); border-radius: 11px; transition: background .2s; border: 1px solid var(--border2); }
.toggle-thumb { position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; background: white; border-radius: 50%; transition: transform .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.toggle input:checked ~ .toggle-track { background: var(--accent); border-color: var(--accent); }
.toggle input:checked ~ .toggle-thumb { transform: translateX(18px); }

/* Toast */
.toast-container { position: fixed; bottom: 1.5rem; right: 1.5rem; display: flex; flex-direction: column; gap: 6px; z-index: 200; }
.toast { display: flex; align-items: center; gap: 8px; padding: 10px 16px; background: var(--text); color: var(--bg2); border-radius: var(--radius-lg); font-size: 13px; font-weight: 500; box-shadow: var(--shadow-lg); transform: translateX(120%); transition: transform .25s cubic-bezier(.34,1.56,.64,1); max-width: 320px; }
.toast.show { transform: translateX(0); }
.toast.success svg { color: #4ADE80; }
.toast.error   svg { color: #F87171; }
.toast.info    svg { color: #60A5FA; }

/* Loader */
.global-loader { position: fixed; inset: 0; background: var(--bg); display: flex; align-items: center; justify-content: center; z-index: 999; }
.loader-spinner { width: 36px; height: 36px; border: 3px solid var(--border2); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Goal card */
.goal-card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 1.25rem; position: relative; overflow: hidden; }
.goal-card-accent { position: absolute; top: 0; left: 0; right: 0; height: 3px; border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
.goal-name { font-size: 14px; font-weight: 700; margin-bottom: 2px; }
.goal-sub  { font-size: 12px; color: var(--text3); margin-bottom: 1rem; }
.goal-pct  { font-size: 22px; font-weight: 800; }
.goal-add-row { display: flex; gap: 6px; margin-top: .75rem; }
.goal-add-row input { flex: 1; }

/* Invite code */
.invite-code { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; background: var(--bg3); border: 1px solid var(--border2); border-radius: var(--radius); font-family: 'SF Mono', 'Fira Code', monospace; font-size: 14px; font-weight: 700; letter-spacing: .1em; color: var(--accent); cursor: pointer; }

/* Responsive ─────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { position: fixed; left: -100%; top: 0; bottom: 0; z-index: 40; transition: left .25s ease; box-shadow: var(--shadow-lg); }
  .sidebar.open { left: 0; }
  .sidebar-close { display: flex; }
  .sidebar-overlay.show { display: block; }
  .mobile-header { display: flex; }
  .main-content { padding-top: 0; }
  .view { padding: 1.25rem 1rem; }
  .kpi-grid { grid-template-columns: 1fr 1fr; gap: .75rem; }
  .kpi-value { font-size: 18px; }
  .chart-row-2 { grid-template-columns: 1fr; }
  .modal-grid { grid-template-columns: 1fr; }
  .modal { max-width: calc(100% - 1.5rem); top: auto; bottom: 0; left: 0; right: 0; transform: none; border-radius: var(--radius-xl) var(--radius-xl) 0 0; max-height: 90vh; }
  .modal-backdrop { align-items: flex-end; }
  .page-header { flex-direction: column; align-items: flex-start; gap: .75rem; }
  .filter-bar { gap: 6px; }
  .chart-row-2 { gap: 1rem; }
  .toast-container { bottom: 1rem; right: 1rem; left: 1rem; }
  .toast { max-width: 100%; }
  .tx-actions { opacity: 1; }
}
@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .kpi-card { padding: 1rem; }
  .kpi-value { font-size: 16px; }
  .btn-primary span { display: none; }
}
