/* ===========================================================
   Moliyam — dizayn tizimi
   =========================================================== */
:root {
  --brand:        #5b5bd6;
  --brand-strong: #4342c7;
  --brand-soft:   #eceafd;
  --income:       #10b981;
  --income-soft:  #dcfce7;
  --expense:      #f43f5e;
  --expense-soft: #ffe4e6;
  --transfer:     #0ea5e9;
  --warn:         #f59e0b;

  --bg:        #f5f6fb;
  --surface:   #ffffff;
  --surface-2: #f1f3f9;
  --surface-3: #e9ecf5;
  --text:      #14151f;
  --muted:     #6b7280;
  --faint:     #9aa1ad;
  --border:    #e6e8f0;
  --border-2:  #d9dce8;

  --radius:    16px;
  --radius-sm: 10px;
  --radius-lg: 22px;
  --shadow:    0 1px 2px rgba(19,21,35,.04), 0 6px 20px rgba(19,21,35,.06);
  --shadow-lg: 0 10px 40px rgba(19,21,35,.14);

  --space:     clamp(1rem, .6rem + 1.4vw, 1.6rem);
  --sidebar-w: 258px;
  --ease:      cubic-bezier(.16,1,.3,1);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

[data-theme="dark"] {
  --brand:        #8b87ff;
  --brand-strong: #a5a1ff;
  --brand-soft:   #23233a;
  --income:       #34d399;
  --income-soft:  #10331f;
  --expense:      #fb7185;
  --expense-soft: #3a1620;
  --transfer:     #38bdf8;

  --bg:        #0d0f16;
  --surface:   #161923;
  --surface-2: #1d212e;
  --surface-3: #262b3a;
  --text:      #eef1f7;
  --muted:     #9aa3b2;
  --faint:     #6b7383;
  --border:    #262b38;
  --border-2:  #333a4b;
  --shadow:    0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.4);
  --shadow-lg: 0 12px 48px rgba(0,0,0,.55);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: -.01em; line-height: 1.2; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }
.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }

/* ---------- Layout ---------- */
.app-shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }

.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  background: var(--surface); border-right: 1px solid var(--border);
  padding: 20px 14px; gap: 4px;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 6px 10px 18px; }
.brand-logo {
  width: 38px; height: 38px; border-radius: 11px; flex: none;
  background: linear-gradient(135deg, var(--brand), var(--transfer));
  display: grid; place-items: center; color: #fff; box-shadow: var(--shadow);
}
.brand-name { font-weight: 800; font-size: 1.18rem; letter-spacing: -.02em; }
.brand-sub { font-size: .72rem; color: var(--faint); }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-link {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  color: var(--muted); font-weight: 600; font-size: .93rem;
  transition: background .16s var(--ease), color .16s var(--ease);
}
.nav-link:hover { background: var(--surface-2); color: var(--text); }
.nav-link.active { background: var(--brand-soft); color: var(--brand-strong); }
.nav-link .icon { flex: none; }
.nav-spacer { flex: 1; }

.side-user {
  border-top: 1px solid var(--border); padding-top: 12px; margin-top: 8px;
  display: flex; align-items: center; gap: 10px;
}
.avatar {
  width: 34px; height: 34px; border-radius: 50%; flex: none;
  background: var(--brand); color: #fff; display: grid; place-items: center;
  font-weight: 700; font-size: .9rem;
}

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 14px;
  padding: 16px var(--space); background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: 1.32rem; }
.topbar .sub { color: var(--muted); font-size: .85rem; }
.topbar-spacer { flex: 1; }
.content { padding: var(--space); display: flex; flex-direction: column; gap: var(--space); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px; border-radius: var(--radius-sm); border: 1px solid transparent;
  font-weight: 650; font-size: .9rem; cursor: pointer; white-space: nowrap;
  transition: transform .08s var(--ease), background .16s, box-shadow .16s, border-color .16s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand); color: #fff; box-shadow: var(--shadow); }
.btn-primary:hover { background: var(--brand-strong); }
.btn-ghost { background: var(--surface); color: var(--text); border-color: var(--border-2); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-soft { background: var(--surface-2); color: var(--text); }
.btn-soft:hover { background: var(--surface-3); }
.btn-danger { background: var(--expense); color: #fff; }
.btn-danger:hover { filter: brightness(.95); }
.btn-sm { padding: 6px 11px; font-size: .82rem; }
.btn-icon { padding: 8px; width: 36px; height: 36px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ---------- Cards & stats ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px;
}
.card-pad-0 { padding: 0; overflow: hidden; }
.card-title { font-size: .95rem; font-weight: 700; }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; gap: 10px; }
.section-title { font-size: 1.02rem; font-weight: 750; letter-spacing: -.01em; }

.grid { display: grid; gap: var(--space); }
.stat-grid { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.cols-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.cols-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }

.stat { position: relative; overflow: hidden; }
.stat-label { color: var(--muted); font-size: .82rem; font-weight: 600; display: flex; align-items: center; gap: 7px; }
.stat-value { font-size: 1.85rem; font-weight: 800; margin-top: 8px; letter-spacing: -.02em; }
.stat-value .cur { font-size: .95rem; font-weight: 600; color: var(--faint); margin-left: 3px; }
.stat-badge { display:inline-flex; align-items:center; gap:5px; margin-top:10px; font-size:.8rem; font-weight:650; }
.stat-ico { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; position: absolute; top: 18px; right: 18px; }

.tone-income { color: var(--income); }
.tone-expense { color: var(--expense); }
.tone-brand  { color: var(--brand); }
.tone-muted  { color: var(--muted); }
.bg-income  { background: var(--income-soft); color: var(--income); }
.bg-expense { background: var(--expense-soft); color: var(--expense); }
.bg-brand   { background: var(--brand-soft); color: var(--brand-strong); }
.bg-transfer{ background: color-mix(in srgb, var(--transfer) 16%, transparent); color: var(--transfer); }

/* ---------- Badges & chips ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 9px; border-radius: 999px; font-size: .76rem; font-weight: 650;
}
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.chip {
  display: inline-flex; align-items: center; gap: 7px; padding: 7px 13px;
  border-radius: 999px; background: var(--surface); border: 1px solid var(--border-2);
  font-size: .85rem; font-weight: 600; color: var(--muted); cursor: pointer;
}
.chip.active, .chip:hover { border-color: var(--brand); color: var(--brand-strong); background: var(--brand-soft); }

/* ---------- Progress ---------- */
.progress { height: 9px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: 999px; background: var(--brand); transition: width .5s var(--ease); }
.progress.over > span { background: var(--expense); }

/* ---------- Tables / lists ---------- */
.txn-list { display: flex; flex-direction: column; }
.txn {
  display: grid; grid-template-columns: 42px 1fr auto; align-items: center; gap: 13px;
  padding: 13px 20px; border-bottom: 1px solid var(--border);
}
.txn:last-child { border-bottom: none; }
.txn:hover { background: var(--surface-2); }
.txn-ico { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; flex: none; }
.txn-main { min-width: 0; }
.txn-title { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.txn-sub { font-size: .8rem; color: var(--muted); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.txn-amt { font-weight: 750; text-align: right; white-space: nowrap; }
.txn-actions { display: flex; gap: 4px; opacity: 0; transition: opacity .15s; }
.txn:hover .txn-actions { opacity: 1; }

.data-table { width: 100%; border-collapse: collapse; }
.data-table th, .data-table td { text-align: left; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.data-table th { font-size: .78rem; color: var(--muted); font-weight: 650; text-transform: uppercase; letter-spacing: .03em; }
.data-table tr:last-child td { border-bottom: none; }
.data-table .num { text-align: right; }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: .83rem; font-weight: 650; color: var(--muted); }
.input, .select, textarea.input {
  width: 100%; padding: 11px 13px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-2); background: var(--surface); color: var(--text);
  font-size: .95rem; font-family: inherit; transition: border-color .15s, box-shadow .15s;
}
.input:focus, .select:focus, textarea.input:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 22%, transparent);
}
.input.amount { font-size: 1.15rem; font-weight: 700; }
.field-row { display: flex; gap: 12px; flex-wrap: wrap; }
.field-row > .field { flex: 1; min-width: 140px; }
.hint { font-size: .78rem; color: var(--faint); }
.seg { display: flex; gap: 6px; background: var(--surface-2); padding: 4px; border-radius: var(--radius-sm); }
.seg label { flex: 1; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span {
  display: block; text-align: center; padding: 9px; border-radius: 8px;
  font-weight: 650; font-size: .88rem; color: var(--muted); cursor: pointer; transition: all .15s;
}
.seg input:checked + span { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.seg.income input:checked + span { color: var(--income); }
.seg.expense input:checked + span { color: var(--expense); }
.color-picker { display: flex; flex-wrap: wrap; gap: 8px; }
.color-picker input { position: absolute; opacity: 0; }
.color-picker label { width: 30px; height: 30px; border-radius: 50%; cursor: pointer; border: 3px solid transparent; }
.color-picker input:checked + label { border-color: var(--text); }

/* ---------- Dialog / modal ---------- */
dialog.modal {
  border: none; border-radius: var(--radius-lg); padding: 0; width: min(520px, 94vw);
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg);
}
dialog.modal::backdrop { background: rgba(12,14,22,.5); backdrop-filter: blur(3px); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 20px 22px 0; }
.modal-head h3 { font-size: 1.15rem; }
.modal-body { padding: 18px 22px 22px; }
.modal-foot { display: flex; gap: 10px; justify-content: flex-end; margin-top: 6px; }

/* ---------- Empty / misc ---------- */
.empty { text-align: center; padding: 46px 20px; color: var(--muted); }
.empty .icon-lg { width: 52px; height: 52px; margin: 0 auto 12px; color: var(--faint); }
.empty h3 { color: var(--text); margin-bottom: 6px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.icon { width: 20px; height: 20px; stroke-width: 2; }
.icon-sm { width: 16px; height: 16px; }
.icon-lg { width: 34px; height: 34px; }
.flex { display: flex; align-items: center; gap: 10px; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.wrap { flex-wrap: wrap; }
.gap-sm { gap: 6px; }
.mt { margin-top: 14px; }
.right { margin-left: auto; }
.text-right { text-align: right; }
.hide { display: none !important; }

/* ---------- Flash / toast ---------- */
.toasts { position: fixed; top: 16px; right: 16px; z-index: 100; display: flex; flex-direction: column; gap: 10px; max-width: 340px; }
.toast {
  display: flex; align-items: flex-start; gap: 10px; padding: 13px 15px;
  border-radius: var(--radius-sm); background: var(--surface); box-shadow: var(--shadow-lg);
  border-left: 4px solid var(--brand); font-size: .9rem; animation: slidein .3s var(--ease);
}
.toast.success { border-color: var(--income); }
.toast.error   { border-color: var(--expense); }
.toast.info    { border-color: var(--transfer); }
.toast button { background: none; border: none; color: var(--faint); cursor: pointer; margin-left: auto; }
@keyframes slidein { from { transform: translateX(20px); opacity: 0; } }

/* ---------- Charts ---------- */
.chart-bars { display: flex; align-items: flex-end; gap: 10px; height: 180px; padding-top: 10px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.bar-stack { width: 100%; display: flex; gap: 3px; align-items: flex-end; height: 100%; justify-content: center; }
.bar { width: 12px; border-radius: 5px 5px 0 0; min-height: 3px; transition: height .5s var(--ease); }
.bar.inc { background: var(--income); }
.bar.exp { background: var(--expense); }
.bar-label { font-size: .72rem; color: var(--muted); }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: .82rem; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.donut-wrap { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; }
.donut-legend { flex: 1; min-width: 160px; display: flex; flex-direction: column; gap: 9px; }
.donut-legend .row { display: flex; align-items: center; gap: 9px; font-size: .87rem; }
.donut-legend .row .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.donut-center-val { font-weight: 800; font-size: 1rem; }

/* ---------- Auth ---------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px;
  background: radial-gradient(1200px 500px at 70% -10%, var(--brand-soft), transparent), var(--bg); }
.auth-card { width: min(420px, 100%); }
.auth-brand { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-bottom: 22px; }
.auth-brand .brand-logo { width: 54px; height: 54px; border-radius: 16px; }
.auth-brand h1 { font-size: 1.5rem; }
.auth-alt { text-align: center; margin-top: 16px; color: var(--muted); font-size: .9rem; }

/* ---------- Bottom nav (mobile) ---------- */
.bottom-nav { display: none; }

@media (max-width: 860px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .content { padding-bottom: 84px; }
  .bottom-nav {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
    background: var(--surface); border-top: 1px solid var(--border);
    padding: 8px 6px calc(8px + env(safe-area-inset-bottom)); justify-content: space-around;
  }
  .bottom-nav a { display: flex; flex-direction: column; align-items: center; gap: 3px;
    color: var(--muted); font-size: .66rem; font-weight: 600; padding: 4px 8px; border-radius: 10px; }
  .bottom-nav a.active { color: var(--brand-strong); }
  .txn-actions { opacity: 1; }
}
@media (max-width: 520px) {
  .txn { grid-template-columns: 38px 1fr auto; padding: 12px 14px; }
  .content { padding-left: 12px; padding-right: 12px; }
}
