:root {
  color-scheme: light;
  --bg: #f3f6fb;
  --surface: #ffffff;
  --surface-soft: #f7f9fc;
  --surface-strong: #edf1f7;
  --text: #172033;
  --muted: #6c778a;
  --border: #e3e8f0;
  --primary: #5a6ff0;
  --primary-dark: #475bd6;
  --primary-soft: #eef0ff;
  --green: #15956f;
  --green-soft: #e7f7f1;
  --red: #dc5262;
  --red-soft: #fff0f2;
  --amber: #d89525;
  --shadow: 0 18px 50px rgb(31 45 79 / 8%);
  --radius: 22px;
  --sidebar: 248px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  font-family: Inter, "Noto Sans JP", "Hiragino Sans", "Yu Gothic UI", sans-serif;
  font-synthesis: none;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d111b;
  --surface: #151b27;
  --surface-soft: #1b2230;
  --surface-strong: #242c3b;
  --text: #f1f4fa;
  --muted: #9ba6ba;
  --border: #293244;
  --primary: #8392ff;
  --primary-dark: #7282ef;
  --primary-soft: #242b50;
  --green: #57c99d;
  --green-soft: #183a32;
  --red: #ff7d8b;
  --red-soft: #41252b;
  --amber: #f4b75d;
  --shadow: 0 18px 50px rgb(0 0 0 / 22%);
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--bg); scroll-behavior: smooth; }
body { min-width: 320px; min-height: 100vh; margin: 0; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; }
button { color: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible { outline: 3px solid color-mix(in srgb, var(--primary) 30%, transparent); outline-offset: 2px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.auth-screen { min-height: 100vh; display: grid; grid-template-columns: minmax(520px, 0.95fr) minmax(380px, 1.05fr); background: var(--surface); }
.auth-panel { width: min(100%, 620px); min-height: 100vh; padding: 100px clamp(30px, 6vw, 76px) 46px; display: flex; flex-direction: column; justify-content: center; }
.auth-brand { position: absolute; top: 32px; display: flex; align-items: center; gap: 12px; }
.auth-brand strong, .auth-brand small { display: block; }
.auth-brand small { margin-top: 3px; color: var(--muted); font-size: 0.69rem; }
.auth-copy h1 { margin: 0 0 12px; font-size: clamp(2.2rem, 4vw, 3.25rem); line-height: 1.15; letter-spacing: -0.06em; word-break: keep-all; }
.auth-copy > p:last-child { max-width: 410px; margin: 0; color: var(--muted); font-size: 0.92rem; line-height: 1.8; }
.auth-endpoint-settings { margin-top: 24px; padding: 10px 12px; background: var(--surface-soft); border: 1px solid var(--border); border-radius: 12px; }
.auth-endpoint-settings summary { color: var(--muted); font-size: 0.7rem; font-weight: 750; cursor: pointer; }
.auth-config-form { margin-top: 10px; display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 9px; }
.auth-config-form label { min-width: 0; }
.auth-config-form input { width: 100%; min-height: 44px; padding: 0 13px; }
.auth-flow { margin-top: 22px; }
.auth-form { display: grid; gap: 14px; }
.auth-form label > span { display: block; margin-bottom: 7px; color: var(--text); font-size: 0.72rem; font-weight: 750; }
.auth-form input { width: 100%; min-height: 50px; padding: 0 14px; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 11px; }
.auth-form input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 12%, transparent); }
.auth-submit { width: 100%; min-height: 50px; margin-top: 2px; }
.auth-switch { margin: 1px 0 0; color: var(--muted); font-size: 0.72rem; text-align: center; }
.auth-switch button, .auth-inline-actions button { padding: 0; color: var(--primary); font-weight: 750; background: transparent; border: 0; cursor: pointer; }
.auth-field-note { margin: -6px 0 0; color: var(--muted); font-size: 0.66rem; }
.auth-status { min-height: 1.2em; margin: 13px 0 0; color: var(--muted); font-size: 0.7rem; text-align: center; line-height: 1.5; }
.auth-status.error { color: var(--red); }
.auth-status.success { color: var(--green); }
.auth-verify-form { justify-items: stretch; }
.mail-badge { width: 50px; height: 50px; display: grid; place-items: center; justify-self: center; color: var(--primary); font-size: 1.35rem; background: var(--primary-soft); border-radius: 50%; }
.verification-copy { margin: 0 0 2px; color: var(--muted); font-size: 0.76rem; line-height: 1.7; text-align: center; }
.verification-copy strong { color: var(--text); }
.auth-form .verification-code { font-size: 1.4rem; font-weight: 800; letter-spacing: 0.42em; text-align: center; }
.auth-inline-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px 22px; font-size: 0.7rem; }
.auth-divider { margin: 18px 0; display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 0.66rem; }
.auth-divider::before, .auth-divider::after { height: 1px; flex: 1; content: ""; background: var(--border); }
.demo-button { min-height: 44px; color: var(--text); font-size: 0.8rem; font-weight: 750; background: var(--surface-soft); border: 1px solid var(--border); border-radius: 11px; cursor: pointer; }
.auth-note { margin: 14px 0 0; color: var(--muted); font-size: 0.67rem; line-height: 1.65; text-align: center; }
.auth-visual { position: relative; padding: 60px; overflow: hidden; display: grid; place-items: center; color: white; background: linear-gradient(145deg, #4f69df 0%, #5955b9 48%, #292b68 100%); }
.auth-visual::before, .auth-visual::after { position: absolute; content: ""; border: 1px solid rgb(255 255 255 / 13%); border-radius: 50%; }
.auth-visual::before { width: 620px; height: 620px; right: -260px; top: -260px; }
.auth-visual::after { width: 430px; height: 430px; left: -220px; bottom: -160px; }
.auth-visual > p { position: absolute; left: 60px; bottom: 55px; margin: 0; font-size: clamp(1.5rem, 3vw, 2.7rem); line-height: 1.25; letter-spacing: -0.04em; }
.auth-orb { width: min(29vw, 280px); aspect-ratio: 1; display: grid; place-items: center; position: relative; color: #5363c9; font-size: clamp(3.5rem, 8vw, 6rem); font-weight: 850; background: rgb(255 255 255 / 94%); border-radius: 36%; box-shadow: 0 45px 90px rgb(16 19 63 / 38%); transform: rotate(-7deg); }
.auth-orb::before { position: absolute; inset: -35px; content: ""; border: 1px solid rgb(255 255 255 / 20%); border-radius: 38%; }
.auth-orb i { position: absolute; width: 58px; height: 58px; right: -15px; top: -15px; background: #83dfb4; border: 8px solid #5a5aba; border-radius: 50%; }
.signed-in-user { margin-bottom: 18px; padding: 12px 14px; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; background: var(--surface-soft); border: 1px solid var(--border); border-radius: 13px; }
.signed-in-user strong, .signed-in-user small { display: block; }
.signed-in-user strong { font-size: 0.82rem; }
.signed-in-user small { margin-top: 3px; color: var(--muted); font-size: 0.68rem; }

.app-shell { min-height: 100vh; }
.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 20; width: var(--sidebar); padding: 28px 18px; display: flex; flex-direction: column; background: var(--surface); border-right: 1px solid var(--border); }
.brand { display: flex; gap: 12px; align-items: center; padding: 0 10px 28px; color: var(--text); text-decoration: none; }
.brand-mark { width: 42px; height: 42px; display: grid; place-items: center; color: white; font-size: 1.2rem; font-weight: 900; border-radius: 13px; background: linear-gradient(135deg, #567cf7, #7453d6); box-shadow: 0 8px 20px rgb(86 124 247 / 28%); }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 1rem; letter-spacing: -0.02em; }
.brand small { margin-top: 3px; color: var(--muted); font-size: 0.7rem; letter-spacing: 0.04em; }
.nav-list { display: grid; gap: 7px; }
.nav-item { width: 100%; padding: 12px 14px; display: flex; gap: 13px; align-items: center; color: var(--muted); font-weight: 650; text-align: left; background: transparent; border: 0; border-radius: 13px; cursor: pointer; transition: 160ms ease; }
.nav-item:hover { color: var(--text); background: var(--surface-soft); }
.nav-item.is-active { color: var(--primary); background: var(--primary-soft); }
.nav-icon { width: 24px; font-size: 1.25rem; text-align: center; }
.sidebar-foot { margin-top: auto; padding: 15px; display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 0.78rem; background: var(--surface-soft); border-radius: 13px; }
.connection-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--amber); box-shadow: 0 0 0 4px color-mix(in srgb, var(--amber) 15%, transparent); }
.connection-dot.is-online { background: var(--green); box-shadow: 0 0 0 4px color-mix(in srgb, var(--green) 15%, transparent); }

.workspace { min-height: 100vh; margin-left: var(--sidebar); }
.topbar { min-height: 108px; padding: 28px clamp(24px, 4vw, 52px) 18px; display: flex; align-items: center; justify-content: space-between; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(18px); }
.eyebrow, .overline { margin: 0 0 5px; color: var(--muted); font-size: 0.67rem; font-weight: 800; letter-spacing: 0.14em; text-transform: uppercase; }
.topbar h1 { margin: 0; font-size: clamp(1.55rem, 3vw, 2rem); letter-spacing: -0.045em; }
.top-actions { display: flex; gap: 10px; align-items: center; }
.icon-button, .avatar { width: 42px; height: 42px; display: grid; place-items: center; border: 1px solid var(--border); cursor: pointer; }
.icon-button { color: var(--muted); font-size: 1.25rem; background: var(--surface); border-radius: 13px; }
.avatar { color: white; font-size: 0.74rem; font-weight: 800; background: linear-gradient(135deg, #29354d, #65718b); border-radius: 50%; }
main { padding: 8px clamp(24px, 4vw, 52px) 60px; }
.view { max-width: 1440px; margin: 0 auto; animation: view-in 260ms ease; }
@keyframes view-in { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: none; } }

.balance-hero { min-height: 200px; padding: clamp(28px, 4vw, 46px); display: flex; align-items: center; justify-content: space-between; gap: 32px; color: white; overflow: hidden; position: relative; border-radius: 30px; background: linear-gradient(125deg, #536ee9 0%, #625ec8 55%, #3a3e92 100%); box-shadow: 0 22px 60px rgb(75 86 183 / 25%); }
.balance-hero::after { position: absolute; width: 330px; height: 330px; right: -90px; top: -170px; content: ""; border: 70px solid rgb(255 255 255 / 8%); border-radius: 50%; }
.hero-label { margin: 0 0 7px; font-size: 0.82rem; font-weight: 700; opacity: 0.75; }
.hero-value { margin: 0; font-size: clamp(2.4rem, 6vw, 4.4rem); font-weight: 850; letter-spacing: -0.055em; line-height: 1; }
.hero-delta { margin: 15px 0 0; font-size: 0.82rem; opacity: 0.74; }
.hero-actions { z-index: 1; display: grid; grid-template-columns: repeat(2, minmax(88px, 1fr)); gap: 10px; }
.alert-stack { margin-top: 14px; display: grid; gap: 8px; }
.app-alert { padding: 12px 15px; display: flex; gap: 10px; align-items: flex-start; color: var(--red); font-size: 0.76rem; font-weight: 650; line-height: 1.55; background: var(--red-soft); border: 1px solid color-mix(in srgb, var(--red) 18%, transparent); border-radius: 12px; }
.quick-button { min-height: 68px; padding: 11px 16px; display: flex; align-items: center; gap: 9px; color: white; font-size: 0.8rem; font-weight: 700; background: rgb(255 255 255 / 12%); border: 1px solid rgb(255 255 255 / 16%); border-radius: 15px; backdrop-filter: blur(8px); cursor: pointer; }
.quick-button:hover { background: rgb(255 255 255 / 20%); transform: translateY(-1px); }
.quick-button b { width: 30px; height: 30px; display: grid; place-items: center; font-size: 1.05rem; background: rgb(255 255 255 / 13%); border-radius: 9px; }

.metric-grid { margin: 20px 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.metric-grid.compact { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.metric { min-height: 116px; padding: 20px; background: var(--surface); border: 1px solid var(--border); border-radius: 18px; box-shadow: 0 8px 30px rgb(31 45 79 / 4%); }
.metric-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.metric-icon { width: 32px; height: 32px; display: grid; place-items: center; font-size: 0.92rem; border-radius: 10px; background: var(--surface-soft); }
.metric small { color: var(--muted); font-weight: 650; }
.metric strong { margin-top: 13px; display: block; font-size: clamp(1.15rem, 2.2vw, 1.6rem); letter-spacing: -0.035em; }
.metric strong.positive, .positive { color: var(--green) !important; }
.metric strong.negative, .negative { color: var(--red) !important; }
.metric .sub { margin-top: 5px; display: block; color: var(--muted); font-size: 0.71rem; }

.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(310px, 0.75fr); gap: 18px; }
.card { padding: clamp(20px, 2.5vw, 28px); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-head { margin-bottom: 20px; display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.card-head h2 { margin: 0; font-size: 1.05rem; letter-spacing: -0.02em; }
.chart-wrap { height: 245px; }
.chart-wrap.short { height: 210px; }
.chart-wrap canvas { width: 100%; height: 100%; }
.compact-select, .filter-bar input, .filter-bar select, input, select { color: var(--text); background: var(--surface-soft); border: 1px solid var(--border); border-radius: 11px; }
.compact-select { padding: 8px 11px; color: var(--muted); font-size: 0.78rem; }
.advice-card { background: linear-gradient(145deg, var(--surface) 35%, var(--primary-soft)); }
.advice-card > p { margin: 30px 0; font-size: 1rem; font-weight: 620; line-height: 1.9; }
.spark { width: 42px; height: 42px; display: grid; place-items: center; color: var(--primary); background: var(--primary-soft); border-radius: 14px; }
.text-button { padding: 0; color: var(--primary); font-size: 0.78rem; font-weight: 750; background: none; border: 0; cursor: pointer; }
.donut-layout { min-height: 200px; display: flex; align-items: center; justify-content: center; gap: 30px; }
.chart-legend { min-width: 145px; display: grid; gap: 11px; }
.legend-item { display: grid; grid-template-columns: 8px 1fr auto; align-items: center; gap: 8px; color: var(--muted); font-size: 0.74rem; }
.legend-dot { width: 8px; height: 8px; border-radius: 50%; }
.legend-item b { color: var(--text); }
.account-list, .mini-list, .settings-list { display: grid; gap: 2px; }
.account-row, .mini-row, .settings-row { padding: 13px 0; display: flex; align-items: center; justify-content: space-between; gap: 15px; border-bottom: 1px solid var(--border); }
.account-row:last-child, .mini-row:last-child, .settings-row:last-child { border: 0; }
.account-info { display: flex; align-items: center; gap: 11px; }
.account-symbol { width: 36px; height: 36px; display: grid; place-items: center; color: var(--primary); background: var(--primary-soft); border-radius: 11px; }
.account-info strong, .account-info small { display: block; }
.account-info strong { font-size: 0.85rem; }
.account-info small { margin-top: 3px; color: var(--muted); font-size: 0.68rem; }
.account-row > strong { font-size: 0.9rem; }

.page-actions { margin-bottom: 20px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.segmented { padding: 4px; display: inline-flex; gap: 3px; background: var(--surface-strong); border-radius: 12px; }
.segmented button { padding: 8px 15px; color: var(--muted); font-size: 0.78rem; font-weight: 700; background: transparent; border: 0; border-radius: 9px; cursor: pointer; }
.segmented button.is-active { color: var(--text); background: var(--surface); box-shadow: 0 3px 10px rgb(29 41 70 / 8%); }
.segmented.full { width: 100%; margin-bottom: 20px; }
.segmented.full button { flex: 1; }
.primary-button, .secondary-button { min-height: 41px; padding: 10px 17px; font-size: 0.8rem; font-weight: 750; border-radius: 11px; cursor: pointer; }
.primary-button { color: white; background: var(--primary); border: 1px solid var(--primary); box-shadow: 0 7px 18px color-mix(in srgb, var(--primary) 24%, transparent); }
.primary-button:hover { background: var(--primary-dark); }
.secondary-button { color: var(--text); background: var(--surface); border: 1px solid var(--border); }
button:disabled { opacity: 0.45; cursor: not-allowed; }
.filter-bar { margin-bottom: 18px; display: grid; grid-template-columns: minmax(220px, 1fr) 170px 190px; gap: 10px; }
.filter-bar.advanced { grid-template-columns: minmax(220px, 1.4fr) repeat(6, minmax(120px, 0.7fr)); }
.filter-bar > input, .filter-bar > select { min-height: 42px; padding: 0 12px; }
.search-field { min-height: 42px; padding: 0 12px; display: flex; align-items: center; gap: 8px; color: var(--muted); background: var(--surface-soft); border: 1px solid var(--border); border-radius: 11px; }
.search-field input { width: 100%; min-width: 0; padding: 0; background: transparent; border: 0; outline: 0; }
.search-field.small { min-height: 36px; max-width: 230px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; white-space: nowrap; }
th { padding: 11px 13px; color: var(--muted); font-size: 0.68rem; font-weight: 750; text-align: left; border-bottom: 1px solid var(--border); }
td { padding: 15px 13px; font-size: 0.82rem; border-bottom: 1px solid var(--border); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-soft); }
.number { text-align: right; font-variant-numeric: tabular-nums; }
.row-title { font-weight: 700; }
.type-badge { padding: 5px 8px; color: var(--muted); font-size: 0.68rem; font-weight: 700; background: var(--surface-soft); border-radius: 7px; }
.row-actions { display: flex; justify-content: flex-end; gap: 5px; }
.row-action { width: 30px; height: 30px; display: grid; place-items: center; color: var(--muted); background: transparent; border: 0; border-radius: 8px; cursor: pointer; }
.row-action:hover { color: var(--text); background: var(--surface-strong); }
.empty-state { padding: 60px 20px; color: var(--muted); text-align: center; }
.empty-state > span { font-size: 2rem; }
.empty-state h3 { margin: 10px 0 5px; color: var(--text); }
.empty-state p { margin: 0; font-size: 0.82rem; }

.month-switcher { display: flex; align-items: center; gap: 14px; }
.month-switcher button { width: 34px; height: 34px; display: grid; place-items: center; color: var(--muted); font-size: 1.35rem; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; cursor: pointer; }
.pachinko-layout { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(285px, 0.62fr); gap: 18px; }
.stack { display: grid; gap: 18px; }
.calendar-week, .calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.calendar-week { margin-bottom: 8px; color: var(--muted); font-size: 0.67rem; font-weight: 700; text-align: center; }
.calendar-day { min-height: 76px; padding: 9px; text-align: left; background: var(--surface-soft); border: 1px solid transparent; border-radius: 11px; cursor: default; }
button.calendar-day { cursor: pointer; }
button.calendar-day:hover { border-color: var(--primary); }
.calendar-day.is-outside { opacity: 0.32; }
.calendar-day time { display: block; color: var(--muted); font-size: 0.67rem; }
.calendar-day strong { margin-top: 15px; display: block; font-size: clamp(0.67rem, 1.1vw, 0.85rem); text-align: right; }
.budget-ring { width: 168px; height: 168px; margin: 6px auto 18px; display: grid; place-items: center; border-radius: 50%; background: conic-gradient(var(--primary) var(--budget-angle, 0%), var(--surface-strong) 0); }
.budget-ring::before { position: absolute; width: 132px; height: 132px; content: ""; background: var(--surface); border-radius: 50%; }
.budget-ring div { z-index: 1; text-align: center; }
.budget-ring strong, .budget-ring small { display: block; }
.budget-ring strong { font-size: 1.25rem; }
.budget-ring small { margin-top: 5px; color: var(--muted); font-size: 0.68rem; }
.center { text-align: center; }
.muted { color: var(--muted); font-size: 0.75rem; }
.limit-alert { margin-top: 13px; padding: 12px; color: var(--red); font-size: 0.75rem; font-weight: 650; line-height: 1.6; background: var(--red-soft); border-radius: 10px; }
.section-gap { margin-top: 18px; }
.session-list { display: grid; }
.session-row { padding: 15px 0; display: grid; grid-template-columns: 86px minmax(0, 1fr) minmax(100px, auto) auto; align-items: center; gap: 16px; border-bottom: 1px solid var(--border); }
.session-row:last-child { border-bottom: 0; }
.session-date { color: var(--muted); font-size: 0.75rem; }
.session-main strong, .session-main small { display: block; }
.session-main small { margin-top: 4px; color: var(--muted); font-size: 0.7rem; }
.session-profit { font-size: 0.95rem; font-weight: 800; text-align: right; }
.breakdown-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.breakdown-block { min-width: 0; }
.breakdown-block h3 { margin: 0 0 10px; font-size: 0.78rem; }
.breakdown-row { padding: 8px 0; display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 0.74rem; border-bottom: 1px solid var(--border); }

.ai-hero { margin-bottom: 18px; padding: 28px; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 22px; background: linear-gradient(125deg, var(--primary-soft), var(--surface)); border: 1px solid var(--border); border-radius: var(--radius); }
.ai-hero h2 { margin: 0 0 7px; font-size: 1.5rem; }
.ai-hero p:last-child { margin: 0; color: var(--muted); font-size: 0.84rem; }
.ai-orb { width: 64px; height: 64px; display: grid; place-items: center; color: white; font-size: 1.7rem; background: linear-gradient(145deg, #667cf3, #7953c8); border-radius: 21px; box-shadow: 0 13px 28px rgb(96 105 218 / 25%); }
.insight-grid { margin-bottom: 18px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.insight-card { min-height: 180px; padding: 22px; background: var(--surface); border: 1px solid var(--border); border-radius: 18px; }
.insight-card .insight-icon { width: 36px; height: 36px; display: grid; place-items: center; color: var(--primary); background: var(--primary-soft); border-radius: 11px; }
.insight-card h3 { margin: 20px 0 8px; font-size: 0.92rem; }
.insight-card p { margin: 0; color: var(--muted); font-size: 0.78rem; line-height: 1.75; }
.privacy-badge, .status-pill { padding: 6px 10px; color: var(--green); font-size: 0.66rem; font-weight: 700; background: var(--green-soft); border-radius: 999px; }
.suggestion-row { display: flex; gap: 8px; flex-wrap: wrap; }
.suggestion-row button { padding: 8px 11px; color: var(--primary); font-size: 0.7rem; font-weight: 650; background: var(--primary-soft); border: 0; border-radius: 9px; cursor: pointer; }
.chat-log { min-height: 230px; max-height: 420px; margin: 18px 0; padding: 18px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; background: var(--surface-soft); border-radius: 14px; }
.chat-message { max-width: 82%; display: flex; align-items: flex-start; gap: 9px; }
.chat-message span { width: 28px; height: 28px; flex: 0 0 auto; display: grid; place-items: center; color: var(--primary); background: var(--primary-soft); border-radius: 9px; }
.chat-message p { margin: 0; padding: 10px 13px; font-size: 0.8rem; line-height: 1.65; background: var(--surface); border: 1px solid var(--border); border-radius: 4px 12px 12px; white-space: pre-wrap; }
.chat-message.user { margin-left: auto; flex-direction: row-reverse; }
.chat-message.user span { color: white; background: var(--primary); }
.chat-message.user p { color: white; background: var(--primary); border-color: var(--primary); border-radius: 12px 4px 12px 12px; }
.chat-form { display: grid; grid-template-columns: 1fr auto; gap: 10px; }
.chat-form input { min-height: 44px; padding: 0 14px; }

.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.settings-card.full { grid-column: 1 / -1; }
.endpoint-form { display: grid; grid-template-columns: minmax(250px, 1fr) auto auto; align-items: end; gap: 10px; }
label > span, .inline-form label > span { margin-bottom: 7px; display: block; color: var(--muted); font-size: 0.72rem; font-weight: 650; }
.endpoint-form input, .inline-form input, .inline-form select { width: 100%; min-height: 42px; padding: 0 12px; }
.form-note { margin: 12px 0 0; color: var(--muted); font-size: 0.71rem; line-height: 1.6; }
.theme-options { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.theme-options button { min-height: 90px; display: grid; place-items: center; gap: 4px; color: var(--muted); font-size: 1.4rem; background: var(--surface-soft); border: 1px solid var(--border); border-radius: 13px; cursor: pointer; }
.theme-options button span { font-size: 0.7rem; font-weight: 700; }
.theme-options button.is-active { color: var(--primary); background: var(--primary-soft); border-color: var(--primary); }
.inline-form { display: flex; align-items: end; gap: 8px; flex-wrap: wrap; }
.inline-form label { flex: 1; min-width: 160px; }
.toggle-label { min-height: 42px; display: flex; align-items: center; gap: 10px; }
.toggle-label input { width: 18px; min-height: 18px; accent-color: var(--primary); }
.toggle-label > span { margin: 0; color: var(--text); }
.inline-form > input, .inline-form > select { flex: 1; min-width: 120px; }
.inline-form.three > input { min-width: 160px; }
.inline-form.dense > input, .inline-form.dense > select { min-width: 130px; }
.settings-list, .chip-list { margin-top: 18px; }
.subsection-title { margin: 24px 0 12px; padding-top: 18px; font-size: 0.86rem; border-top: 1px solid var(--border); }
.settings-row strong, .settings-row small { display: block; }
.settings-row small { margin-top: 4px; color: var(--muted); font-size: 0.7rem; }
.settings-row-actions { display: flex; align-items: center; gap: 12px; }
.chip-list { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { padding: 7px 10px; display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 0.72rem; background: var(--surface-soft); border: 1px solid var(--border); border-radius: 999px; }
.chip button { padding: 0; color: var(--muted); background: transparent; border: 0; cursor: pointer; }
.button-row { display: flex; gap: 10px; flex-wrap: wrap; }

.bottom-nav { display: none; }
.modal { width: 100%; max-width: 650px; max-height: calc(100dvh - 40px); padding: 0; color: var(--text); background: transparent; border: 0; overflow: visible; }
.modal::backdrop { background: rgb(11 17 29 / 52%); backdrop-filter: blur(5px); }
.modal-panel { max-height: calc(100dvh - 40px); padding: clamp(22px, 4vw, 32px); overflow-y: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 24px; box-shadow: 0 30px 100px rgb(0 0 0 / 25%); }
.modal-panel.small { max-width: 500px; margin: auto; }
.modal-head { margin-bottom: 20px; display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.modal-head h2 { margin: 0; font-size: 1.35rem; }
.close-button { width: 36px; height: 36px; display: grid; place-items: center; color: var(--muted); font-size: 1.3rem; background: var(--surface-soft); border: 0; border-radius: 10px; cursor: pointer; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; }
.form-grid.one { grid-template-columns: 1fr; }
.form-grid label { min-width: 0; }
.form-grid input, .form-grid select { width: 100%; min-height: 43px; padding: 0 12px; }
.span-2 { grid-column: span 2; }
.currency-field { display: flex; align-items: center; background: var(--surface-soft); border: 1px solid var(--border); border-radius: 11px; }
.currency-field b { padding-left: 12px; color: var(--muted); }
.currency-field input { background: transparent; border: 0; }
.upload-disabled { padding: 13px; display: flex; align-items: center; gap: 12px; color: var(--muted); background: var(--surface-soft); border: 1px dashed var(--border); border-radius: 11px; }
.upload-disabled > span { font-size: 1.5rem; }
.upload-disabled strong, .upload-disabled small { display: block; }
.upload-disabled strong { font-size: 0.78rem; }
.upload-disabled small { margin-top: 3px; font-size: 0.65rem; }
.modal-actions { margin-top: 24px; display: flex; justify-content: flex-end; gap: 9px; }
.profit-preview { margin-top: 18px; padding: 14px; display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 0.78rem; background: var(--surface-soft); border-radius: 11px; }
.profit-preview strong { color: var(--text); font-size: 1.1rem; }

.loading-overlay { position: fixed; inset: 0; z-index: 100; display: grid; place-content: center; justify-items: center; color: white; background: rgb(18 25 41 / 62%); backdrop-filter: blur(5px); }
.loading-overlay p { font-size: 0.8rem; }
.spinner { width: 38px; height: 38px; border: 3px solid rgb(255 255 255 / 25%); border-top-color: white; border-radius: 50%; animation: spin 800ms linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.toast-region { position: fixed; z-index: 120; right: 24px; bottom: 24px; display: grid; gap: 9px; }
.toast { min-width: 260px; max-width: 380px; padding: 13px 15px; color: var(--text); font-size: 0.78rem; font-weight: 650; background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--primary); border-radius: 11px; box-shadow: var(--shadow); animation: toast-in 200ms ease; }
.toast.error { border-left-color: var(--red); }
@keyframes toast-in { from { opacity: 0; transform: translateY(7px); } }

@media (max-width: 1100px) {
  :root { --sidebar: 84px; }
  .brand { justify-content: center; padding-inline: 0; }
  .brand > span:last-child, .nav-item > span:last-child, .sidebar-foot > span:last-child { display: none; }
  .nav-item { justify-content: center; padding-inline: 0; }
  .sidebar-foot { justify-content: center; }
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .insight-grid { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  :root { --radius: 18px; }
  body { padding-bottom: calc(76px + var(--safe-bottom)); }
  body:has(.auth-screen:not([hidden])) { padding-bottom: 0; }
  .auth-screen { min-height: 100dvh; grid-template-columns: 1fr; }
  .auth-panel { width: 100%; min-height: 100dvh; padding: 90px 24px 34px; justify-content: center; }
  .auth-brand { top: calc(24px + env(safe-area-inset-top, 0px)); }
  .auth-visual { display: none; }
  .auth-config-form { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .workspace { margin-left: 0; }
  .topbar { min-height: 86px; padding: calc(16px + env(safe-area-inset-top, 0px)) 18px 12px; }
  .topbar .eyebrow { display: none; }
  .topbar h1 { font-size: 1.45rem; }
  .top-actions .avatar { display: none; }
  main { padding: 5px 14px 28px; }
  .balance-hero { min-height: 280px; padding: 26px 22px; display: block; border-radius: 24px; }
  .hero-actions { margin-top: 30px; grid-template-columns: repeat(4, 1fr); }
  .quick-button { min-width: 0; padding: 9px 4px; flex-direction: column; justify-content: center; font-size: 0.66rem; }
  .metric-grid, .metric-grid.compact { grid-template-columns: repeat(2, 1fr); gap: 9px; }
  .metric { min-height: 105px; padding: 15px; }
  .dashboard-grid, .pachinko-layout, .settings-grid { grid-template-columns: 1fr; }
  .breakdown-grid { grid-template-columns: 1fr; }
  .settings-card.full { grid-column: auto; }
  .chart-wide { grid-column: auto; }
  .card { padding: 19px 17px; }
  .donut-layout { gap: 15px; }
  .donut-layout canvas { width: 145px; height: 145px; }
  .page-actions { align-items: stretch; flex-direction: column-reverse; }
  .page-actions > .primary-button { width: 100%; }
  .segmented { width: 100%; overflow-x: auto; }
  .segmented button { flex: 1; white-space: nowrap; }
  .filter-bar { grid-template-columns: 1fr 1fr; }
  .filter-bar.advanced { grid-template-columns: 1fr 1fr; }
  .filter-bar .search-field { grid-column: 1 / -1; }
  .calendar-day { min-height: 62px; padding: 6px; }
  .calendar-day strong { margin-top: 13px; font-size: 0.57rem; }
  .session-row { grid-template-columns: 65px minmax(0, 1fr) auto; gap: 9px; }
  .session-row .row-actions { grid-column: 2 / -1; }
  .ai-hero { grid-template-columns: auto 1fr; padding: 22px; }
  .ai-hero .primary-button { grid-column: 1 / -1; }
  .ai-orb { width: 52px; height: 52px; }
  .privacy-badge { display: none; }
  .endpoint-form { grid-template-columns: 1fr 1fr; }
  .endpoint-form label { grid-column: 1 / -1; }
  .bottom-nav { position: fixed; z-index: 40; inset: auto 0 0; height: calc(68px + var(--safe-bottom)); padding: 7px 10px calc(7px + var(--safe-bottom)); display: grid; grid-template-columns: repeat(5, 1fr); align-items: center; background: color-mix(in srgb, var(--surface) 94%, transparent); border-top: 1px solid var(--border); backdrop-filter: blur(18px); }
  .bottom-nav button { height: 51px; display: grid; place-items: center; gap: 1px; color: var(--muted); font-size: 0.58rem; font-weight: 700; background: transparent; border: 0; cursor: pointer; }
  .bottom-nav button > span { font-size: 1.25rem; }
  .bottom-nav button.is-active { color: var(--primary); }
  .bottom-nav .nav-add span { width: 48px; height: 48px; display: grid; place-items: center; color: white; background: var(--primary); border-radius: 16px; box-shadow: 0 8px 22px color-mix(in srgb, var(--primary) 35%, transparent); transform: translateY(-11px); }
  .modal { max-height: 94dvh; margin: auto 0 0; }
  .modal-panel, .modal-panel.small { max-height: 94dvh; border-radius: 24px 24px 0 0; padding-bottom: calc(25px + var(--safe-bottom)); }
  .form-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .modal-actions { position: sticky; bottom: 0; padding-top: 12px; background: var(--surface); }
  .modal-actions button { flex: 1; }
  .toast-region { right: 14px; bottom: calc(82px + var(--safe-bottom)); left: 14px; }
  .toast { min-width: 0; max-width: none; }
}

@media (max-width: 420px) {
  .hero-value { font-size: 2.35rem; }
  .metric-grid { grid-template-columns: 1fr 1fr; }
  .metric strong { font-size: 1.05rem; }
  .metric small { font-size: 0.68rem; }
  .filter-bar { grid-template-columns: 1fr; }
  .filter-bar .search-field { grid-column: auto; }
  .calendar-week, .calendar-grid { gap: 3px; }
  .calendar-day { min-height: 56px; }
  .theme-options { grid-template-columns: 1fr; }
  .theme-options button { min-height: 58px; grid-template-columns: auto auto; justify-content: center; }
}

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