/* ─────────────────────────────────────────
   Design System — Personal Dashboard
   Font: Inter | Icons: Lucide
───────────────────────────────────────── */

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

/* ── TOKENS ── */
:root[data-theme="dark"] {
  --bg:        #0f1117;
  --surface:   #161b27;
  --surface2:  #1e2433;
  --surface3:  #252d3d;
  --border:    #252d3d;
  --border2:   #2f3a4f;
  --text:      #e8eaf0;
  --text2:     #8892a4;
  --text3:     #4a5568;
  --accent:    #00d97e;
  --accent-bg: rgba(0, 217, 126, 0.10);
  --accent-dim: rgba(0, 217, 126, 0.06);
  --red:       #ff5263;
  --red-bg:    rgba(255, 82, 99, 0.10);
  --yellow:    #ffc107;
  --yellow-bg: rgba(255, 193, 7, 0.10);
  --blue:      #4d9fff;
  --blue-bg:   rgba(77, 159, 255, 0.10);
  --purple:    #a78bfa;
  --purple-bg: rgba(167, 139, 250, 0.10);
  --shadow:    0 1px 3px rgba(0,0,0,.5);
  --shadow-md: 0 4px 12px rgba(0,0,0,.5);
  --shadow-lg: 0 8px 24px rgba(0,0,0,.6);
  --sidebar-w: 224px;
  --topbar-h:  56px;
}

:root[data-theme="light"] {
  --bg:        #f0f2f7;
  --surface:   #ffffff;
  --surface2:  #f8fafc;
  --surface3:  #f1f5f9;
  --border:    #e2e8f0;
  --border2:   #cbd5e1;
  --text:      #0f172a;
  --text2:     #64748b;
  --text3:     #94a3b8;
  --accent:    #059669;
  --accent-bg: rgba(5, 150, 105, 0.08);
  --accent-dim: rgba(5, 150, 105, 0.04);
  --red:       #dc2626;
  --red-bg:    rgba(220, 38, 38, 0.08);
  --yellow:    #d97706;
  --yellow-bg: rgba(217, 119, 6, 0.08);
  --blue:      #2563eb;
  --blue-bg:   rgba(37, 99, 235, 0.08);
  --purple:    #7c3aed;
  --purple-bg: rgba(124, 58, 237, 0.08);
  --shadow:    0 1px 3px rgba(0,0,0,.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,.08);
  --shadow-lg: 0 8px 24px rgba(0,0,0,.10);
  --sidebar-w: 224px;
  --topbar-h:  56px;
}

/* ── RESET ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background .2s, color .2s;
}
a { text-decoration: none; color: inherit; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }

/* ── LAYOUT ── */
.layout {
  display: flex;
  min-height: 100vh;
}

/* ── SIDEBAR ── */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0; top: 0; bottom: 0;
  z-index: 200;
  transition: transform .25s ease;
}
.sidebar-brand {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: 0 1.1rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.brand-mark {
  width: 28px; height: 28px;
  background: var(--accent);
  border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  flex-shrink: 0;
}
.brand-mark svg { width: 15px; height: 15px; stroke: #fff; }
.brand-name {
  font-size: .85rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -.01em;
}
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: .75rem 0;
}
.nav-section {
  margin-bottom: .25rem;
}
.nav-section-label {
  font-size: .65rem;
  font-weight: 600;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: .08em;
  padding: .5rem 1.1rem .35rem;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .5rem 1.1rem;
  margin: 1px .5rem;
  border-radius: 7px;
  font-size: .82rem;
  font-weight: 500;
  color: var(--text2);
  cursor: pointer;
  transition: background .12s, color .12s;
  user-select: none;
}
.nav-item svg { width: 15px; height: 15px; flex-shrink: 0; stroke: currentColor; }
.nav-item:hover { background: var(--surface2); color: var(--text); }
.nav-item.active {
  background: var(--accent-bg);
  color: var(--accent);
}
.nav-item.active svg { stroke: var(--accent); }
.sidebar-footer {
  border-top: 1px solid var(--border);
  padding: .75rem .5rem;
}
.sidebar-footer .nav-item { color: var(--text2); }

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

/* ── TOPBAR ── */
.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 100;
  flex-shrink: 0;
}
.topbar-left { display: flex; align-items: center; gap: .5rem; }
.breadcrumb {
  display: flex;
  align-items: center;
  gap: .35rem;
  font-size: .82rem;
  color: var(--text2);
}
.breadcrumb-sep { color: var(--text3); }
.breadcrumb-current { color: var(--text); font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: .5rem; }
.icon-btn {
  width: 32px; height: 32px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text2);
  display: flex; align-items: center; justify-content: center;
  transition: all .12s;
  cursor: pointer;
}
.icon-btn svg { width: 15px; height: 15px; stroke: currentColor; }
.icon-btn:hover { background: var(--surface3); color: var(--text); border-color: var(--border2); }

/* ── PAGE CONTENT ── */
.page-content {
  flex: 1;
  padding: 1.5rem;
  max-width: 1200px;
  width: 100%;
}
.page-header {
  margin-bottom: 1.5rem;
}
.page-title {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -.025em;
  color: var(--text);
}
.page-subtitle {
  font-size: .8rem;
  color: var(--text2);
  margin-top: .2rem;
}

/* ── GRID LAYOUTS ── */
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; }
.grid-2-1 { display: grid; grid-template-columns: 2fr 1fr; gap: 1rem; }
.grid-1-2 { display: grid; grid-template-columns: 1fr 2fr; gap: 1rem; }
@media(max-width: 1100px) { .grid-3 { grid-template-columns: repeat(2, 1fr); } .grid-4 { grid-template-columns: repeat(2, 1fr); } }
@media(max-width: 760px) { .grid-3, .grid-2, .grid-4, .grid-2-1, .grid-1-2 { grid-template-columns: 1fr; } }

/* ── CARDS ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  transition: border-color .15s, box-shadow .15s;
}
.card:hover { border-color: var(--border2); }
.card-pad { padding: 1.1rem 1.25rem; }
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: .9rem;
}
.card-title {
  font-size: .72rem;
  font-weight: 600;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: .08em;
}
.card-action {
  font-size: .75rem;
  color: var(--accent);
  font-weight: 500;
  cursor: pointer;
}
.card-action:hover { opacity: .8; }
.card-divider { border: none; border-top: 1px solid var(--border); margin: .75rem 0; }

/* ── STAT CARD ── */
.stat-card { padding: 1.1rem 1.25rem; }
.stat-icon {
  width: 34px; height: 34px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: .75rem;
}
.stat-icon svg { width: 16px; height: 16px; stroke: currentColor; }
.stat-icon.green { background: var(--accent-bg); color: var(--accent); }
.stat-icon.red { background: var(--red-bg); color: var(--red); }
.stat-icon.blue { background: var(--blue-bg); color: var(--blue); }
.stat-icon.yellow { background: var(--yellow-bg); color: var(--yellow); }
.stat-icon.purple { background: var(--purple-bg); color: var(--purple); }
.stat-label {
  font-size: .72rem;
  color: var(--text2);
  font-weight: 500;
  margin-bottom: .3rem;
}
.stat-value {
  font-size: 1.55rem;
  font-weight: 800;
  letter-spacing: -.035em;
  color: var(--text);
  line-height: 1;
}
.stat-meta {
  display: flex;
  align-items: center;
  gap: .4rem;
  margin-top: .4rem;
  font-size: .72rem;
  color: var(--text2);
}
.stat-delta {
  display: inline-flex;
  align-items: center;
  gap: .2rem;
  font-size: .7rem;
  font-weight: 600;
  padding: .15rem .4rem;
  border-radius: 5px;
}
.stat-delta svg { width: 10px; height: 10px; }
.stat-delta.up { background: var(--accent-bg); color: var(--accent); }
.stat-delta.down { background: var(--red-bg); color: var(--red); }

/* ── PROGRESS BAR ── */
.progress-track {
  background: var(--surface3);
  border-radius: 999px;
  height: 4px;
  overflow: hidden;
  margin-top: .75rem;
}
.progress-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
  transition: width .6s ease;
}
.progress-fill.warn { background: var(--yellow); }
.progress-fill.danger { background: var(--red); }

/* ── TABLE / LIST ── */
.list-item {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .65rem 0;
  border-bottom: 1px solid var(--border);
}
.list-item:last-child { border-bottom: none; }
.list-icon {
  width: 32px; height: 32px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  background: var(--surface2);
  color: var(--text2);
}
.list-icon svg { width: 14px; height: 14px; stroke: currentColor; }
.list-body { flex: 1; min-width: 0; }
.list-title {
  font-size: .82rem;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.list-subtitle { font-size: .72rem; color: var(--text2); margin-top: .1rem; }
.list-right { text-align: right; flex-shrink: 0; }
.list-amount { font-size: .85rem; font-weight: 600; color: var(--text); }
.list-date { font-size: .7rem; color: var(--text3); margin-top: .1rem; }

/* ── BADGE / CHIP ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  padding: .2rem .55rem;
  border-radius: 5px;
  font-size: .68rem;
  font-weight: 600;
}
.badge svg { width: 10px; height: 10px; }
.badge-green { background: var(--accent-bg); color: var(--accent); }
.badge-red { background: var(--red-bg); color: var(--red); }
.badge-yellow { background: var(--yellow-bg); color: var(--yellow); }
.badge-blue { background: var(--blue-bg); color: var(--blue); }
.badge-purple { background: var(--purple-bg); color: var(--purple); }
.badge-neutral { background: var(--surface3); color: var(--text2); }

/* ── FORMS ── */
.form-group { margin-bottom: .85rem; }
.form-label {
  display: block;
  font-size: .72rem;
  font-weight: 600;
  color: var(--text2);
  margin-bottom: .35rem;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.form-input {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: .55rem .8rem;
  font-size: .82rem;
  outline: none;
  transition: border-color .15s;
  -webkit-appearance: none;
}
.form-input:focus { border-color: var(--accent); }
.form-input::placeholder { color: var(--text3); }
select.form-input { cursor: pointer; }
select.form-input option { background: var(--surface); }
textarea.form-input { resize: vertical; min-height: 80px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
@media(max-width: 480px) { .form-row { grid-template-columns: 1fr; } }

/* ── BUTTONS ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .5rem 1rem;
  border-radius: 8px;
  font-size: .8rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: opacity .15s, background .15s;
}
.btn svg { width: 14px; height: 14px; stroke: currentColor; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { opacity: .88; }
.btn-ghost {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text2);
}
.btn-ghost:hover:not(:disabled) { background: var(--surface3); color: var(--text); }
.btn-danger { background: var(--red-bg); color: var(--red); }
.btn-danger:hover:not(:disabled) { opacity: .8; }
.btn-sm { padding: .35rem .75rem; font-size: .75rem; }
.btn-sm svg { width: 12px; height: 12px; }

/* ── EMPTY STATE ── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2.5rem 1rem;
  text-align: center;
  color: var(--text3);
}
.empty-state svg { width: 32px; height: 32px; stroke: var(--text3); margin-bottom: .75rem; opacity: .5; }
.empty-state p { font-size: .82rem; }

/* ── TOAST ── */
.toast-container {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: .5rem;
}
.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: .7rem 1rem;
  font-size: .8rem;
  color: var(--text);
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  gap: .5rem;
  animation: toast-in .2s ease;
  min-width: 200px;
}
.toast svg { width: 14px; height: 14px; flex-shrink: 0; }
.toast.success { border-color: var(--accent); }
.toast.success svg { stroke: var(--accent); }
.toast.error { border-color: var(--red); }
.toast.error svg { stroke: var(--red); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ── SKELETON ── */
@keyframes shimmer { 0%,100% { opacity: .35; } 50% { opacity: .65; } }
.skel {
  background: var(--surface3);
  border-radius: 5px;
  animation: shimmer 1.5s infinite;
  display: inline-block;
}

/* ── RESPONSIVE ── */
@media(max-width: 760px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .page-content { padding: 1rem; }
}
