:root {
  --bg: #f4f7f7;
  --surface: #ffffff;
  --surface-soft: #f8fbfb;
  --text: #12233f;
  --muted: #6e7c91;
  --line: #dde5e7;
  --teal: #0f9f9a;
  --teal-dark: #087b83;
  --teal-soft: #e8f8f6;
  --coral: #f35f50;
  --coral-soft: #fff0ed;
  --amber: #e79b0c;
  --amber-soft: #fff7e4;
  --green: #2b9c55;
  --green-soft: #eaf8ef;
  --purple: #7659c4;
  --shadow: 0 12px 34px rgba(25, 52, 74, .08);
  --shadow-soft: 0 3px 12px rgba(25, 52, 74, .06);
  --radius: 18px;
  --radius-sm: 12px;
  --sidebar: 244px;
  font-family: Inter, "Yu Gothic UI", "Yu Gothic", Meiryo, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body { min-width: 320px; min-height: 100vh; margin: 0; background: var(--bg); color: var(--text); }
button, input, select, textarea { font: inherit; }
button { color: inherit; }
button, [role="button"] { -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid rgba(15, 159, 154, .22); outline-offset: 2px; }
[hidden] { display: none !important; }

.offline-banner {
  position: fixed;
  z-index: 200;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 36px;
  padding: 7px 16px;
  background: #17233a;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}
.offline-banner .status-dot { background: #ffb84d; box-shadow: 0 0 0 4px rgba(255, 184, 77, .2); }

.login-view {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: grid;
  place-items: center;
  overflow: auto;
  padding: 28px;
  background:
    radial-gradient(circle at 15% 15%, rgba(15, 159, 154, .15), transparent 30%),
    radial-gradient(circle at 85% 85%, rgba(243, 167, 18, .12), transparent 28%),
    #f3f7f7;
}
.login-view::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .36;
  background-image: linear-gradient(rgba(18, 35, 63, .035) 1px, transparent 1px), linear-gradient(90deg, rgba(18, 35, 63, .035) 1px, transparent 1px);
  background-size: 32px 32px;
}
.login-card {
  position: relative;
  width: min(100%, 460px);
  padding: 34px;
  border: 1px solid rgba(255,255,255,.8);
  border-radius: 28px;
  background: rgba(255,255,255,.95);
  box-shadow: 0 25px 80px rgba(22, 58, 73, .14);
  backdrop-filter: blur(16px);
}
.brand { display: flex; align-items: center; gap: 11px; }
.brand strong { display: block; font-size: 21px; letter-spacing: .05em; }
.brand small { display: block; margin-top: 2px; color: var(--muted); font-size: 11px; }
.brand-mark {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border-radius: 13px 13px 17px 13px;
  background: linear-gradient(145deg, #13b7ad, #087b83);
  color: #fff;
  box-shadow: 0 8px 18px rgba(15,159,154,.22);
  font-size: 13px;
  font-weight: 900;
  letter-spacing: -.03em;
}
.brand-login { padding-bottom: 26px; border-bottom: 1px solid var(--line); }
.login-copy { margin: 30px 0 24px; }
.eyebrow { margin: 0 0 7px; color: var(--teal-dark); font-size: 10px; font-weight: 900; letter-spacing: .13em; text-transform: uppercase; }
.login-copy h1 { margin: 0 0 9px; font-size: 31px; letter-spacing: -.035em; }
.login-copy p:not(.eyebrow) { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.75; }
.login-form { display: grid; gap: 10px; }
.login-form label, .field label, .field-label { color: #314158; font-size: 12px; font-weight: 800; }
.password-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.login-help { display: flex; gap: 10px; margin-top: 20px; padding: 13px; border-radius: 13px; background: var(--surface-soft); color: var(--muted); }
.login-help p { margin: 0; font-size: 11px; line-height: 1.65; word-break: break-word; }
.mini-icon { display: grid; place-items: center; flex: 0 0 20px; height: 20px; border-radius: 50%; background: var(--teal-soft); color: var(--teal-dark); font-size: 11px; font-weight: 900; }
.form-error { min-height: 17px; margin: 2px 0 0; color: var(--coral); font-size: 12px; font-weight: 700; }

input, select, textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 13px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #fff;
  color: var(--text);
  transition: border-color .16s, box-shadow .16s, background .16s;
}
input:hover, select:hover, textarea:hover { border-color: #c7d3d6; }
input:focus, select:focus, textarea:focus { border-color: var(--teal); box-shadow: 0 0 0 4px rgba(15,159,154,.08); outline: none; }
input::placeholder, textarea::placeholder { color: #9aa7b8; }
textarea { min-height: 74px; resize: vertical; }

.primary-button, .secondary-button, .danger-button, .ghost-button, .text-button, .icon-button, .avatar-button {
  border: 0;
  cursor: pointer;
}
.primary-button, .secondary-button, .danger-button, .ghost-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 17px;
  border-radius: 11px;
  font-size: 13px;
  font-weight: 800;
  transition: transform .15s, filter .15s, box-shadow .15s;
}
.primary-button { background: linear-gradient(135deg, var(--teal), #0b8c91); color: #fff; box-shadow: 0 8px 18px rgba(15,159,154,.18); }
.primary-button.coral { background: linear-gradient(135deg, #ff725e, #ed5046); box-shadow: 0 8px 18px rgba(243,95,80,.16); }
.secondary-button { background: var(--teal-soft); color: var(--teal-dark); }
.danger-button { background: var(--coral-soft); color: #c6453c; }
.ghost-button { border: 1px solid var(--line); background: #fff; color: #435268; }
.wide { width: 100%; }
.primary-button:hover, .secondary-button:hover, .danger-button:hover, .ghost-button:hover { filter: brightness(.98); transform: translateY(-1px); }
.primary-button:active, .secondary-button:active, .danger-button:active, .ghost-button:active { transform: translateY(0); }
.text-button { padding: 8px; background: transparent; color: var(--teal-dark); font-size: 12px; font-weight: 800; }
.icon-button {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 11px;
  background: transparent;
  color: #5d6a7c;
  font-weight: 800;
}
.icon-button:hover { background: var(--surface-soft); color: var(--text); }
.avatar-button { width: 36px; height: 36px; border-radius: 50%; background: #e7ecef; color: #617083; font-size: 11px; font-weight: 900; }

.app-shell { min-height: 100vh; }
.main-content:focus { outline: none; }
body.offline-mode .app-shell { padding-top: 36px; }
body.offline-mode .sidebar { top: 36px; }
body.offline-mode .topbar { top: 36px; }
.sidebar {
  position: fixed;
  z-index: 30;
  inset: 0 auto 0 0;
  display: flex;
  flex-direction: column;
  width: var(--sidebar);
  padding: 24px 17px;
  border-right: 1px solid var(--line);
  background: rgba(255,255,255,.94);
  backdrop-filter: blur(14px);
}
.sidebar > .brand { padding: 0 12px 24px; }
.main-nav { display: grid; gap: 5px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 46px;
  padding: 9px 13px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: #435168;
  cursor: pointer;
  font-size: 13px;
  font-weight: 750;
  text-align: left;
}
.nav-icon { display: grid; place-items: center; width: 24px; color: #667589; font-size: 20px; line-height: 1; }
.nav-item:hover { background: var(--surface-soft); }
.nav-item.active { background: linear-gradient(135deg, #12aaa5, #088b91); color: #fff; box-shadow: 0 8px 20px rgba(15,159,154,.18); }
.nav-item.active .nav-icon { color: #fff; }
.sidebar-tip { margin-top: auto; padding: 18px; border: 1px solid #cfe8e6; border-radius: 16px; background: linear-gradient(155deg, #f4fbfa, #fff); }
.sidebar-tip strong { font-size: 12px; }
.sidebar-tip p { margin: 7px 0 0; color: var(--muted); font-size: 10px; line-height: 1.65; }
.tip-plant { float: right; color: var(--teal); font-size: 30px; }

.workspace { min-height: 100vh; margin-left: var(--sidebar); }
.topbar {
  position: sticky;
  z-index: 25;
  top: 0;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  min-height: 72px;
  padding: 12px clamp(18px, 2.4vw, 34px);
  border-bottom: 1px solid rgba(221,229,231,.9);
  background: rgba(244,247,247,.88);
  backdrop-filter: blur(18px);
}
.month-switcher { display: inline-flex; align-items: center; gap: 4px; }
.month-label { min-width: 130px; padding: 8px 12px; border: 0; background: transparent; color: var(--text); cursor: default; font-size: 18px; font-weight: 900; letter-spacing: -.02em; }
.status-cluster { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.status-pill { display: inline-flex; align-items: center; gap: 7px; min-height: 30px; padding: 6px 10px; border-radius: 999px; font-size: 10px; font-weight: 800; }
.status-pill.saved { background: var(--green-soft); color: #25884b; }
.status-pill.synced { background: #eaf3ff; color: #3b78bd; }
.status-pill.pending { background: var(--amber-soft); color: #a76b00; }
.status-pill.offline { background: #eef1f4; color: #667589; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.mobile-brand { display: none; }

.main-content { width: 100%; max-width: 1500px; margin: 0 auto; padding: 4px clamp(18px, 2.4vw, 34px) 40px; }
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin: 24px 0 18px; }
.page-header h1 { margin: 0; font-size: 22px; letter-spacing: -.03em; }
.page-header p { margin: 6px 0 0; color: var(--muted); font-size: 12px; }
.page-actions { display: flex; flex-wrap: wrap; gap: 9px; }

.summary-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)) 1.1fr; gap: 12px; }
.summary-card, .usage-card, .panel {
  border: 1px solid rgba(217,226,228,.94);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}
.summary-card { position: relative; overflow: hidden; min-height: 121px; padding: 18px; border-radius: var(--radius); }
.summary-card::after { content: ""; position: absolute; right: -23px; bottom: -28px; width: 85px; height: 85px; border-radius: 50%; opacity: .65; }
.summary-card.income { background: linear-gradient(140deg, #fff, #f0fbfa); }
.summary-card.expense { background: linear-gradient(140deg, #fff, #fff5f2); }
.summary-card.balance { background: linear-gradient(140deg, #fff, #fff9e9); }
.summary-card.income::after { background: #d8f4f1; }
.summary-card.expense::after { background: #ffe1db; }
.summary-card.balance::after { background: #ffedbd; }
.summary-title { display: flex; align-items: center; gap: 8px; margin-bottom: 17px; color: #566478; font-size: 11px; font-weight: 800; }
.summary-icon { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 10px; font-size: 16px; }
.income .summary-icon { background: var(--teal-soft); color: var(--teal-dark); }
.expense .summary-icon { background: var(--coral-soft); color: var(--coral); }
.balance .summary-icon { background: var(--amber-soft); color: var(--amber); }
.summary-amount { position: relative; z-index: 1; font-size: clamp(22px, 2.3vw, 31px); font-weight: 900; letter-spacing: -.035em; white-space: nowrap; }
.summary-amount small { margin-left: 3px; font-size: 12px; }
.income .summary-amount { color: var(--teal-dark); }
.expense .summary-amount { color: var(--coral); }
.balance .summary-amount { color: #c68100; }
.usage-card { display: grid; grid-template-columns: 1fr auto; align-items: center; min-height: 121px; padding: 17px 19px; border-radius: var(--radius); }
.usage-card .summary-title { margin-bottom: 5px; }
.usage-value { color: var(--teal-dark); font-size: clamp(28px, 2.7vw, 39px); font-weight: 900; letter-spacing: -.04em; }
.usage-ring { --rate: 0; position: relative; display: grid; place-items: center; width: 77px; height: 77px; border-radius: 50%; background: conic-gradient(var(--teal) calc(min(var(--rate),100) * 1%), #e7ecee 0); }
.usage-ring::after { content: ""; width: 56px; height: 56px; border-radius: 50%; background: #fff; }
.usage-ring span { position: absolute; z-index: 1; color: var(--teal-dark); font-size: 13px; font-weight: 900; }

.dashboard-grid { display: grid; grid-template-columns: minmax(0,1.65fr) minmax(290px,.95fr); gap: 14px; margin-top: 14px; }
.dashboard-main, .dashboard-side { display: grid; align-content: start; gap: 14px; min-width: 0; }
.panel { min-width: 0; padding: 18px; border-radius: var(--radius); }
.panel-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.panel-title { margin: 0; font-size: 14px; font-weight: 900; }
.panel-subtitle { margin: 4px 0 0; color: var(--muted); font-size: 10px; }
.panel-link { border: 0; background: transparent; color: var(--teal-dark); cursor: pointer; font-size: 11px; font-weight: 800; }
.chart-grid { display: grid; grid-template-columns: minmax(0,1.2fr) minmax(240px,.8fr); gap: 16px; }
.trend-wrap { position: relative; min-height: 260px; }
.trend-canvas { width: 100%; height: 250px; }
.chart-legend { display: flex; gap: 13px; margin-bottom: 8px; color: var(--muted); font-size: 10px; }
.legend-dot { display: inline-block; width: 8px; height: 8px; margin-right: 5px; border-radius: 3px; }
.donut-layout { display: grid; grid-template-columns: 150px minmax(0,1fr); align-items: center; gap: 12px; min-height: 220px; }
.donut { position: relative; display: grid; place-items: center; width: 142px; height: 142px; margin: auto; border-radius: 50%; background: #edf1f2; }
.donut::after { content: ""; width: 82px; height: 82px; border-radius: 50%; background: #fff; box-shadow: inset 0 0 0 1px var(--line); }
.donut-total { position: absolute; z-index: 1; text-align: center; }
.donut-total strong { display: block; font-size: 15px; }
.donut-total small { color: var(--muted); font-size: 9px; }
.category-legend { display: grid; gap: 9px; }
.category-row { display: grid; grid-template-columns: 8px minmax(0,1fr) auto; align-items: center; gap: 8px; font-size: 10px; }
.category-row .color { width: 8px; height: 8px; border-radius: 50%; }
.category-row .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.category-row .amount { color: #435168; font-weight: 800; }

.insight-card { display: flex; align-items: center; gap: 12px; padding: 15px 17px; border: 1px solid #f7c5bd; border-radius: 14px; background: #fff6f3; }
.insight-card.good { border-color: #bce2ca; background: #f1fbf4; }
.insight-card.warning { border-color: #f3d38c; background: #fff9eb; }
.insight-icon { display: grid; place-items: center; flex: 0 0 32px; height: 32px; border-radius: 50%; background: #fff; color: var(--coral); font-weight: 900; }
.insight-card.good .insight-icon { color: var(--green); }
.insight-card.warning .insight-icon { color: var(--amber); }
.insight-copy strong { display: block; font-size: 12px; }
.insight-copy small { display: block; margin-top: 3px; color: var(--muted); font-size: 9px; }

.quick-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.quick-actions .primary-button { min-height: 47px; }
.quick-form { display: grid; gap: 13px; }
.quick-type { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; padding: 4px; border-radius: 12px; background: #eef3f3; }
.quick-type button { min-height: 38px; border: 0; border-radius: 9px; background: transparent; color: #687689; cursor: pointer; font-size: 12px; font-weight: 800; }
.quick-type button.active.expense { background: #fff; color: var(--coral); box-shadow: var(--shadow-soft); }
.quick-type button.active.income { background: #fff; color: var(--teal-dark); box-shadow: var(--shadow-soft); }
.amount-input-wrap { position: relative; }
.amount-input-wrap input { height: 57px; padding-right: 42px; font-size: 25px; font-weight: 900; letter-spacing: -.02em; }
.amount-input-wrap span { position: absolute; top: 50%; right: 14px; transform: translateY(-50%); color: var(--muted); font-size: 12px; font-weight: 800; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; }
.field { display: grid; gap: 6px; min-width: 0; }
.field.full { grid-column: 1 / -1; }
.category-chips { display: flex; flex-wrap: wrap; gap: 7px; }
.category-chip { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 10px; background: #fff; cursor: pointer; color: #45536a; font-size: 11px; font-weight: 750; }
.category-chip .chip-dot { width: 8px; height: 8px; border-radius: 50%; }
.category-chip.selected { border-color: var(--chip-color, var(--teal)); background: color-mix(in srgb, var(--chip-color, var(--teal)) 10%, white); color: var(--chip-color, var(--teal-dark)); box-shadow: 0 0 0 2px color-mix(in srgb, var(--chip-color, var(--teal)) 12%, transparent); }
.category-chip.add { border-style: dashed; color: var(--teal-dark); }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; color: #435168; font-size: 11px; font-weight: 750; }
.toggle { position: relative; width: 42px; height: 24px; }
.toggle input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.toggle span { position: absolute; inset: 0; border-radius: 999px; background: #dfe5e8; transition: .2s; cursor: pointer; }
.toggle span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 2px 5px rgba(0,0,0,.14); transition: .2s; }
.toggle input:checked + span { background: var(--teal); }
.toggle input:checked + span::after { transform: translateX(18px); }

.records-table { width: 100%; border-collapse: collapse; }
.records-table th { padding: 9px 10px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 9px; font-weight: 800; text-align: left; }
.records-table td { padding: 11px 10px; border-bottom: 1px solid #edf1f2; font-size: 10px; vertical-align: middle; }
.records-table tr:last-child td { border-bottom: 0; }
.records-table tbody tr:hover { background: #fafcfc; }
.record-category { display: flex; align-items: center; gap: 8px; font-weight: 750; }
.record-icon { display: grid; place-items: center; width: 27px; height: 27px; border-radius: 9px; color: #fff; font-size: 12px; font-weight: 900; }
.amount-income { color: var(--teal-dark); font-weight: 900; white-space: nowrap; }
.amount-expense { color: var(--coral); font-weight: 900; white-space: nowrap; }
.type-badge { display: inline-flex; padding: 4px 7px; border-radius: 7px; font-size: 8px; font-weight: 900; }
.type-badge.income { background: var(--teal-soft); color: var(--teal-dark); }
.type-badge.expense { background: var(--coral-soft); color: var(--coral); }
.record-actions { white-space: nowrap; text-align: right; }
.mini-button { min-width: 30px; min-height: 30px; padding: 5px 8px; border: 0; border-radius: 8px; background: transparent; color: #657387; cursor: pointer; font-size: 11px; }
.mini-button:hover { background: #edf2f3; }
.mobile-record-list { display: none; }

.fixed-summary { display: grid; gap: 10px; }
.fixed-row { display: grid; grid-template-columns: 34px minmax(0,1fr) auto; align-items: center; gap: 10px; padding: 10px; border-radius: 11px; background: var(--surface-soft); }
.fixed-row .fixed-icon { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: var(--teal-soft); color: var(--teal-dark); }
.fixed-row.expense .fixed-icon { background: var(--coral-soft); color: var(--coral); }
.fixed-row strong { display: block; font-size: 11px; }
.fixed-row small { color: var(--muted); font-size: 9px; }
.fixed-row .fixed-amount { font-size: 12px; font-weight: 900; }
.budget-progress-list { display: grid; gap: 13px; }
.budget-progress-head { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 6px; font-size: 10px; }
.budget-progress-head strong { font-weight: 800; }
.budget-progress-head span { color: var(--muted); }
.progress-track { height: 7px; overflow: hidden; border-radius: 999px; background: #e9edef; }
.progress-bar { height: 100%; border-radius: 999px; background: var(--bar-color, var(--teal)); transition: width .4s; }
.empty-state { display: grid; place-items: center; min-height: 170px; padding: 24px; border: 1px dashed #d5dfe1; border-radius: 14px; background: #fbfdfd; color: var(--muted); text-align: center; }
.empty-state .empty-icon { margin-bottom: 8px; color: var(--teal); font-size: 30px; }
.empty-state strong { color: #435168; font-size: 13px; }
.empty-state p { max-width: 350px; margin: 7px 0 14px; font-size: 10px; line-height: 1.7; }

.filters { display: grid; grid-template-columns: 1fr 160px 200px auto; gap: 9px; margin-bottom: 14px; }
.history-stats { display: grid; grid-template-columns: repeat(3,1fr); gap: 10px; margin-bottom: 14px; }
.mini-stat { padding: 13px 15px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface-soft); }
.mini-stat small { display: block; color: var(--muted); font-size: 9px; }
.mini-stat strong { display: block; margin-top: 5px; font-size: 17px; }

.recurring-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.recurring-list { display: grid; gap: 9px; }
.recurring-card { display: grid; grid-template-columns: 42px minmax(0,1fr) auto; align-items: center; gap: 11px; padding: 12px; border: 1px solid var(--line); border-radius: 13px; background: #fff; }
.recurring-card.inactive { opacity: .58; }
.recurring-card-icon { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 12px; color: #fff; font-size: 17px; }
.recurring-card h3 { overflow: hidden; margin: 0; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.recurring-card p { margin: 5px 0 0; color: var(--muted); font-size: 9px; }
.recurring-card .right { text-align: right; }
.recurring-card .right strong { display: block; font-size: 13px; }
.recurring-card .right .mini-button { margin-top: 4px; }

.budget-editor-list { display: grid; gap: 10px; }
.budget-editor-row { display: grid; grid-template-columns: minmax(150px,1fr) 180px minmax(150px,1fr); align-items: center; gap: 14px; padding: 11px 12px; border: 1px solid #e8edef; border-radius: 12px; }
.budget-editor-name { display: flex; align-items: center; gap: 9px; font-size: 11px; font-weight: 800; }
.budget-editor-name span { width: 10px; height: 10px; border-radius: 50%; }
.budget-input-wrap { position: relative; }
.budget-input-wrap input { min-height: 39px; padding-right: 30px; text-align: right; font-weight: 800; }
.budget-input-wrap small { position: absolute; top: 50%; right: 10px; transform: translateY(-50%); color: var(--muted); }
.budget-meter small { display: block; margin-top: 5px; color: var(--muted); font-size: 9px; text-align: right; }

.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.setting-list { display: grid; gap: 0; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 58px; padding: 11px 0; border-bottom: 1px solid #edf1f2; }
.setting-row:last-child { border-bottom: 0; }
.setting-row strong { display: block; font-size: 11px; }
.setting-row p { margin: 4px 0 0; color: var(--muted); font-size: 9px; line-height: 1.5; }
.storage-path { margin-top: 10px; padding: 11px; border-radius: 10px; background: #f2f5f6; color: #536175; font-family: Consolas, monospace; font-size: 9px; line-height: 1.6; word-break: break-all; }
.security-form { display: grid; gap: 10px; }
.offline-queue-list { display: grid; gap: 8px; margin-top: 12px; }
.offline-queue-item { display: grid; grid-template-columns: 1fr auto; gap: 10px; padding: 10px; border: 1px solid #f0d59d; border-radius: 11px; background: #fff9eb; font-size: 10px; }

.modal-backdrop { position: fixed; z-index: 400; inset: 0; display: grid; place-items: center; padding: 20px; background: rgba(13,28,44,.46); backdrop-filter: blur(5px); }
.modal { width: min(100%, 590px); max-height: min(90vh, 850px); overflow: hidden; border-radius: 23px; background: #fff; box-shadow: 0 30px 90px rgba(9,27,45,.26); animation: modal-in .2s ease-out; }
@keyframes modal-in { from { opacity: 0; transform: translateY(13px) scale(.985); } to { opacity: 1; transform: none; } }
.modal-handle { display: none; }
.modal-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 20px 22px 13px; border-bottom: 1px solid #edf1f2; }
.modal-header h2 { margin: 0; font-size: 18px; }
.modal-body { max-height: calc(90vh - 82px); overflow: auto; overscroll-behavior: contain; padding: 20px 22px 24px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 18px; }
.modal-actions .primary-button { min-width: 140px; }

.toast-region { position: fixed; z-index: 600; right: 22px; bottom: 22px; display: grid; gap: 9px; pointer-events: none; }
.toast { min-width: 230px; max-width: 360px; padding: 13px 16px; border: 1px solid #cde5df; border-radius: 13px; background: #fff; box-shadow: var(--shadow); color: #314158; font-size: 11px; font-weight: 750; animation: toast-in .2s ease-out; }
.toast.error { border-color: #f0c2ba; color: #b43e35; }
.toast.warning { border-color: #efd391; color: #926000; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.mobile-nav { display: none; }

@media (max-width: 1180px) {
  :root { --sidebar: 214px; }
  .summary-grid { grid-template-columns: repeat(3,1fr); }
  .usage-card { grid-column: 1 / -1; min-height: 96px; }
  .chart-grid { grid-template-columns: 1fr; }
  .donut-layout { grid-template-columns: 170px 1fr; }
  .dashboard-grid { grid-template-columns: minmax(0,1.45fr) minmax(270px,.8fr); }
}

@media (max-width: 920px) {
  :root { --sidebar: 78px; }
  .sidebar { padding-inline: 10px; }
  .sidebar > .brand { justify-content: center; padding-inline: 0; }
  .sidebar > .brand > div, .nav-item span:last-child, .sidebar-tip { display: none; }
  .nav-item { justify-content: center; padding-inline: 8px; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .dashboard-side { grid-template-columns: 1fr 1fr; }
  .dashboard-side > .panel:first-child { grid-column: 1 / -1; }
  .settings-grid { grid-template-columns: 1fr; }
}

@media (max-width: 680px) {
  :root { --radius: 16px; }
  body { background: #f7f9f9; }
  .offline-banner { font-size: 10px; }
  .login-view { padding: 16px; }
  .login-card { padding: 25px 21px; border-radius: 22px; }
  .login-copy { margin-block: 24px 20px; }
  .login-copy h1 { font-size: 27px; }
  .sidebar { display: none; }
  .workspace { margin-left: 0; padding-bottom: calc(78px + env(safe-area-inset-bottom)); }
  body.offline-mode .app-shell { padding-top: 36px; }
  .topbar {
    grid-template-columns: 1fr auto 1fr;
    min-height: 108px;
    padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
    background: rgba(255,255,255,.93);
  }
  .mobile-brand { display: flex; }
  .mobile-brand .brand-mark { width: 32px; height: 32px; border-radius: 10px; font-size: 10px; }
  .mobile-brand strong { font-size: 14px; }
  .month-switcher { grid-column: 1 / -1; grid-row: 2; justify-content: center; margin-top: 5px; }
  .month-label { min-width: 135px; font-size: 17px; }
  .status-cluster { grid-column: 3; grid-row: 1; }
  .status-cluster .avatar-button, .status-pill.saved { display: none; }
  .status-pill { padding-inline: 9px; }
  .main-content { padding: 1px 12px 23px; }
  .page-header { align-items: center; margin: 17px 2px 13px; }
  .page-header h1 { font-size: 18px; }
  .page-header p { font-size: 10px; }
  .page-actions .primary-button, .page-actions .ghost-button { min-height: 39px; padding: 8px 11px; font-size: 11px; }
  .summary-grid { grid-template-columns: repeat(3,1fr); gap: 8px; }
  .usage-card { grid-column: 1 / -1; grid-row: 1; min-height: 118px; padding: 15px 17px; }
  .usage-card .usage-ring { width: 74px; height: 74px; }
  .summary-card { min-height: 104px; padding: 12px 10px; text-align: center; }
  .summary-title { justify-content: center; gap: 5px; margin-bottom: 12px; font-size: 9px; }
  .summary-icon { width: 25px; height: 25px; border-radius: 8px; font-size: 12px; }
  .summary-amount { font-size: clamp(15px, 5vw, 21px); }
  .summary-amount small { display: block; margin: 2px 0 0; font-size: 9px; }
  .dashboard-grid { gap: 11px; margin-top: 11px; }
  .dashboard-main, .dashboard-side { gap: 11px; }
  .dashboard-side { grid-template-columns: 1fr; }
  .panel { padding: 15px; }
  .chart-panel { display: none; }
  .insight-card { padding: 13px; }
  .records-table-wrap { display: none; }
  .mobile-record-list { display: grid; gap: 0; }
  .mobile-record { display: grid; grid-template-columns: 38px minmax(0,1fr) auto; align-items: center; gap: 10px; min-height: 60px; padding: 9px 0; border-bottom: 1px solid #edf1f2; }
  .mobile-record:last-child { border-bottom: 0; }
  .mobile-record .record-icon { width: 38px; height: 38px; border-radius: 12px; }
  .mobile-record strong { display: block; overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
  .mobile-record small { display: block; margin-top: 4px; color: var(--muted); font-size: 9px; }
  .mobile-record .right { text-align: right; }
  .mobile-record .right strong { font-size: 12px; }
  .dashboard-side .quick-panel { display: none; }
  .recurring-grid { grid-template-columns: 1fr; }
  .filters { grid-template-columns: 1fr 1fr; }
  .filters .search-field { grid-column: 1 / -1; }
  .filters .primary-button { grid-column: 1 / -1; }
  .history-stats { gap: 7px; }
  .mini-stat { padding: 11px 10px; text-align: center; }
  .mini-stat strong { font-size: 14px; }
  .budget-editor-row { grid-template-columns: 1fr 128px; gap: 10px; }
  .budget-meter { grid-column: 1 / -1; }
  .settings-grid { gap: 11px; }
  .mobile-nav {
    position: fixed;
    z-index: 80;
    right: 0;
    bottom: 0;
    left: 0;
    display: grid;
    grid-template-columns: 1fr 1fr 72px 1fr 1fr;
    align-items: end;
    min-height: calc(66px + env(safe-area-inset-bottom));
    padding: 7px 10px calc(7px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--line);
    background: rgba(255,255,255,.96);
    box-shadow: 0 -8px 30px rgba(24,46,68,.07);
    backdrop-filter: blur(18px);
  }
  .mobile-nav-item { display: grid; place-items: center; gap: 3px; min-height: 46px; border: 0; background: transparent; color: #697789; cursor: pointer; }
  .mobile-nav-item span { font-size: 20px; line-height: 1; }
  .mobile-nav-item small { font-size: 9px; font-weight: 750; }
  .mobile-nav-item.active { color: var(--teal); }
  .mobile-add { align-self: start; width: 58px; height: 58px; margin: -25px auto 0; border: 5px solid #f7f9f9; border-radius: 50%; background: linear-gradient(135deg, #15b0aa, #07868e); color: #fff; box-shadow: 0 10px 22px rgba(15,159,154,.3); cursor: pointer; font-size: 32px; line-height: 1; }
  .modal-backdrop { align-items: end; padding: 0; }
  .modal { width: 100%; max-height: 92vh; border-radius: 23px 23px 0 0; animation-name: sheet-in; }
  @keyframes sheet-in { from { transform: translateY(100%); } to { transform: none; } }
  .modal-handle { display: block; width: 44px; height: 5px; margin: 9px auto 0; border-radius: 99px; background: #cbd3dc; }
  .modal-header { padding: 12px 18px 11px; }
  .modal-body { max-height: calc(92vh - 77px); padding: 16px 18px calc(22px + env(safe-area-inset-bottom)); }
  .modal-actions { position: sticky; bottom: 0; padding-top: 11px; background: linear-gradient(transparent, #fff 18%); }
  .modal-actions .primary-button { flex: 1; min-height: 51px; }
  .toast-region { right: 12px; bottom: calc(80px + env(safe-area-inset-bottom)); left: 12px; }
  .toast { min-width: 0; max-width: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
