:root {
  color-scheme: light;
  --ink: #222222;
  --muted: #737373;
  --line: #e7e5e4;
  --soft: #f7f6f3;
  --panel: #ffffff;
  --green: #2f6b4f;
  --red: #b85c48;
  --gold: #b88732;
  --shadow: 0 10px 28px rgba(15, 15, 15, 0.06);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: #fff; color: var(--ink); }
button, input, select, textarea { font: inherit; }
button { border: 0; cursor: pointer; }

.auth-shell, .app-shell { width: min(1240px, calc(100% - 40px)); margin: 0 auto; }
.auth-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) 390px; align-items: center; gap: 72px; padding: 56px 0; }
.brand-mark { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 8px; background: var(--ink); color: #fff; font-weight: 800; }
.hero-copy h1 { margin: 34px 0 18px; font-size: clamp(44px, 7vw, 82px); line-height: 1; letter-spacing: 0; font-weight: 800; }
.hero-copy p { max-width: 700px; margin: 0; color: #4a4a4a; font-size: 20px; line-height: 1.55; }
.feature-strip { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 32px; }
.feature-strip span, .saved-badge { padding: 8px 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--soft); color: #44403c; font-size: 13px; font-weight: 700; }

.auth-panel, .drawer, .overview-card, .section-panel, .tracker-row, .finance-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}
.auth-panel, .drawer, .section-panel { padding: 22px; }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 4px; background: var(--soft); border-radius: 8px; margin-bottom: 22px; }
.auth-tabs button { min-height: 40px; border-radius: 6px; color: var(--muted); background: transparent; font-weight: 750; }
.auth-tabs button.active { background: #fff; color: var(--ink); box-shadow: 0 4px 12px rgba(15, 15, 15, 0.06); }

.field { display: grid; gap: 8px; margin-bottom: 15px; }
.field label { color: #44403c; font-size: 14px; font-weight: 750; }
.field input, .field select, .field textarea, .inline-form input, .inline-form select, .date-picker {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 11px 12px;
  outline: none;
}
.field input:focus, .field select:focus, .field textarea:focus, .note-box textarea:focus, .inline-form input:focus, .inline-form select:focus, .date-picker:focus {
  border-color: #b8b2aa;
  box-shadow: 0 0 0 4px rgba(120, 113, 108, 0.12);
}
.compact { min-width: 150px; margin-bottom: 0; }

.primary-btn, .secondary-btn, .ghost-btn, .ghost-link, .icon-btn { min-height: 40px; border-radius: 8px; font-weight: 800; }
.primary-btn { width: 100%; background: var(--ink); color: #fff; }
.secondary-btn { padding: 0 16px; background: var(--ink); color: #fff; }
.ghost-btn, .ghost-link, .icon-btn { background: var(--soft); color: var(--ink); border: 1px solid var(--line); }
.ghost-btn, .ghost-link { padding: 0 14px; }
.ghost-link { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
.icon-btn { width: 40px; flex: 0 0 auto; }
.text-btn { width: 100%; margin-top: 12px; background: transparent; color: var(--ink); text-decoration: underline; text-underline-offset: 3px; font-weight: 750; }
.text-btn.inline { width: auto; min-height: auto; margin-top: 0; padding: 0; }
.full-width { width: 100%; }
.legal-links { display: flex; justify-content: center; align-items: center; flex-wrap: wrap; gap: 8px 14px; margin-top: 14px; text-align: center; }
.auth-banner { grid-column: 1 / -1; display: block; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; box-shadow: var(--shadow); background: #fff; }
.auth-banner img { display: block; width: 100%; height: auto; }
.hint, .empty-state { color: var(--muted); line-height: 1.5; }
.danger { color: #9f2d20; }

.app-shell { min-height: 100vh; padding: 28px 0 42px; }
.topbar { display: grid; grid-template-columns: auto minmax(360px, 1fr) auto; align-items: center; gap: 18px; margin-bottom: 26px; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand h1 { margin: 0; font-size: 20px; }
.brand p { margin: 3px 0 0; color: var(--muted); font-size: 13px; }
.date-switcher { display: flex; align-items: center; justify-content: center; gap: 8px; }
.date-switcher strong { min-width: 190px; text-align: center; text-transform: capitalize; }
.date-picker { width: 154px; }
.user-actions { display: flex; justify-content: flex-end; gap: 8px; }

.overview-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 20px; }
.overview-card { padding: 18px; }
.overview-card span { display: block; color: var(--muted); font-size: 13px; font-weight: 800; }
.overview-card strong { display: block; margin-top: 10px; font-size: 32px; }
.overview-card p { margin: 5px 0 14px; color: var(--muted); }
.progress-bar { height: 9px; border-radius: 999px; background: var(--soft); overflow: hidden; }
.progress-bar div { height: 100%; background: var(--ink); border-radius: inherit; }

.layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; }
.section-panel { margin-bottom: 20px; }
.section-head { display: flex; align-items: start; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.section-head h2, .drawer h2 { margin: 0; font-size: 19px; }
.section-head p { margin: 5px 0 0; color: var(--muted); line-height: 1.45; }

.month-table { display: grid; overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; }
.label-cell, .month-head, .month-cell { min-height: 34px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); background: #fff; }
.label-cell { position: sticky; left: 0; z-index: 2; display: flex; align-items: center; gap: 8px; padding: 8px 10px; background: #fbfaf8; font-weight: 800; }
.tracker-label { font-weight: 650; }
.day-head { display: grid; place-items: center; gap: 1px; padding: 5px 2px; color: var(--muted); }
.day-head strong { color: var(--ink); }
.day-head.selected { background: #eeeae3; }
.month-cell { min-width: 36px; color: var(--muted); font-size: 12px; }
.month-cell.done { background: #dcebd8; color: #24553d; font-weight: 900; }
.month-cell.has-note { box-shadow: inset 0 -3px 0 var(--gold); }

.tracker-list { display: grid; gap: 12px; }
.tracker-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 16px; padding: 14px; box-shadow: none; }
.tracker-title { display: flex; align-items: center; gap: 9px; font-weight: 850; }
.color-dot { width: 10px; height: 10px; border-radius: 50%; flex: 0 0 auto; }
.tracker-meta { margin-top: 5px; color: var(--muted); font-size: 13px; }
.tracker-controls { display: flex; align-items: center; gap: 10px; }
.check-toggle { width: 48px; height: 28px; border-radius: 999px; background: var(--line); position: relative; }
.check-toggle::after { content: ""; width: 22px; height: 22px; border-radius: 50%; background: #fff; position: absolute; top: 3px; left: 3px; box-shadow: 0 2px 8px rgba(15, 15, 15, 0.16); transition: 0.2s ease; }
.check-toggle.on { background: var(--green); }
.check-toggle.on::after { left: 23px; }
.slider-control { display: grid; grid-template-columns: 170px 46px; align-items: center; gap: 10px; }
.slider-control input { accent-color: var(--ink); }
.slider-control strong { text-align: right; font-size: 14px; }

.finance-toolbar { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.finance-summary { display: flex; flex-wrap: wrap; gap: 10px; }
.finance-summary span { padding: 9px 11px; background: var(--soft); border: 1px solid var(--line); border-radius: 8px; }
.inline-form { display: grid; grid-template-columns: 140px 1fr 130px 1fr auto; gap: 8px; margin: 14px 0 18px; }
.chart-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin: 16px 0 18px; }
.chart-card { border: 1px solid var(--line); border-radius: 8px; padding: 15px; background: #fff; min-height: 260px; }
.chart-card h3 { margin: 0 0 14px; text-align: center; color: #6f6256; font-size: 14px; text-transform: uppercase; letter-spacing: 0; }
.bar-chart { height: 170px; display: grid; grid-template-columns: repeat(2, 1fr); gap: 24px; align-items: end; padding: 8px 22px 0; border-bottom: 1px solid var(--line); }
.bar-group { display: grid; gap: 8px; align-items: end; text-align: center; color: var(--muted); font-size: 12px; }
.bars { height: 140px; display: flex; align-items: end; justify-content: center; gap: 6px; }
.bar { width: 28px; min-height: 5px; border-radius: 4px 4px 0 0; }
.bar.plan { background: #f4d7d2; }
.bar.fact { background: #e7aaa3; }
.chart-legend { display: flex; justify-content: center; gap: 14px; margin-top: 12px; color: var(--muted); font-size: 12px; }
.chart-legend span, .donut-legend span { display: flex; align-items: center; gap: 6px; }
.chart-legend i, .donut-legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; flex: 0 0 auto; }
.legend-plan { background: #f4d7d2; }
.legend-fact { background: #e7aaa3; }
.donut-wrap { display: grid; grid-template-columns: 150px 1fr; gap: 14px; align-items: center; min-height: 190px; }
.donut { width: 150px; height: 150px; border-radius: 50%; display: grid; place-items: center; position: relative; }
.donut::after { content: ""; width: 72px; height: 72px; border-radius: 50%; background: #fff; position: absolute; }
.donut span { position: relative; z-index: 1; font-weight: 850; color: var(--ink); }
.donut-legend { display: grid; gap: 8px; color: var(--muted); font-size: 12px; line-height: 1.35; }
.finance-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.finance-card { padding: 15px; box-shadow: none; }
.finance-card h3, .section-panel h3 { margin: 0 0 12px; font-size: 16px; }
.finance-row { display: grid; grid-template-columns: minmax(0, 1fr) 144px; gap: 10px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.finance-row span { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; }
.finance-row input { width: 94px; border: 1px solid var(--line); border-radius: 8px; padding: 8px; text-align: right; }
.finance-row .progress-bar { grid-column: 1 / -1; height: 7px; }
.finance-actions { display: flex; align-items: center; justify-content: flex-end; gap: 6px; }
.transaction-list { display: grid; gap: 8px; }
.transaction-item { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.transaction-item span { display: grid; gap: 3px; color: var(--muted); }
.transaction-item small { color: var(--ink); line-height: 1.35; }

.drawer { position: sticky; top: 18px; height: fit-content; }
.drawer h2 { margin-bottom: 16px; }
.drawer-title { margin-top: 26px !important; }
.account-danger { margin-top: 26px; padding-top: 20px; border-top: 1px solid var(--line); }
.admin-panel { margin-bottom: 24px; padding-bottom: 20px; border-bottom: 1px solid var(--line); }
.compact-head { align-items: center; margin-bottom: 12px; }
.compact-head h2 { margin-bottom: 0; }
.admin-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.admin-grid div { padding: 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--soft); }
.admin-grid span { display: flex; align-items: center; gap: 5px; color: var(--muted); font-size: 12px; font-weight: 800; }
.admin-grid strong { display: block; margin-top: 5px; font-size: 22px; }
.help-dot { width: 17px; height: 17px; display: inline-grid; place-items: center; border: 1px solid #d6d3cf; border-radius: 50%; background: #fff; color: var(--muted); font-size: 11px; font-weight: 900; line-height: 1; }
.color-picker { display: grid; grid-template-columns: repeat(6, 1fr); gap: 7px; }
.color-picker button { height: 30px; border-radius: 6px; border: 2px solid transparent; }
.color-picker button.active { border-color: var(--ink); }

.note-box { display: grid; gap: 12px; }
.note-box textarea { width: 100%; min-height: 120px; border: 1px solid var(--line); border-radius: 8px; padding: 13px; resize: vertical; outline: none; }
.notes-list { display: grid; gap: 8px; margin-top: 14px; }
.note-item { display: grid; gap: 4px; width: 100%; text-align: left; padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.note-item span { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.tg-banner { display: block; margin-top: 22px; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; box-shadow: var(--shadow); background: #fff; }
.tg-banner img { display: block; width: 100%; height: auto; }
.site-footer { display: flex; justify-content: center; gap: 16px; flex-wrap: wrap; margin-top: 18px; padding-bottom: 8px; }
.legal-shell { max-width: 920px; display: grid; justify-items: center; }
.legal-shell > .ghost-btn { justify-self: start; }
.legal-panel { width: min(100%, 820px); margin-top: 18px; text-align: left; }
.legal-panel h1 { margin: 0 0 18px; font-size: 34px; }
.legal-panel h2 { margin: 22px 0 8px; font-size: 18px; }
.legal-panel p { color: #44403c; line-height: 1.65; }
.modal-backdrop { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 18px; background: rgba(34, 34, 34, 0.34); backdrop-filter: blur(8px); }
.guide-modal { width: min(980px, 100%); max-height: min(820px, calc(100vh - 36px)); overflow: auto; padding: 22px; border: 1px solid var(--line); border-radius: 8px; background: #fff; box-shadow: 0 24px 70px rgba(15, 15, 15, 0.22); }
.guide-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.guide-step { display: grid; grid-template-columns: 150px 1fr; gap: 14px; align-items: center; padding: 14px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.guide-shot { min-height: 112px; border-radius: 8px; background: var(--soft); border: 1px solid var(--line); padding: 12px; overflow: hidden; }
.guide-copy { display: flex; gap: 10px; align-items: flex-start; }
.guide-copy > span { width: 26px; height: 26px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 50%; background: var(--ink); color: #fff; font-weight: 900; font-size: 13px; }
.guide-copy h3 { margin: 0 0 5px; font-size: 16px; }
.guide-copy p { margin: 0; color: var(--muted); line-height: 1.45; font-size: 14px; }
.fake-toolbar { display: grid; grid-template-columns: 24px 1fr 24px; gap: 6px; align-items: center; text-align: center; }
.fake-toolbar b, .fake-row b { display: grid; place-items: center; border-radius: 6px; background: #fff; border: 1px solid var(--line); min-height: 24px; }
.fake-toolbar strong { padding: 7px; border-radius: 6px; background: #fff; font-size: 12px; }
.fake-calendar { height: 42px; margin-top: 12px; border-radius: 6px; background: repeating-linear-gradient(90deg, #fff 0 16px, #eeeae3 16px 17px); }
.fake-row { display: grid; grid-template-columns: 10px 1fr 28px; gap: 8px; align-items: center; margin-bottom: 9px; padding: 8px; border-radius: 6px; background: #fff; }
.fake-row span { width: 10px; height: 10px; border-radius: 50%; background: var(--green); }
.fake-row p { margin: 0; font-size: 13px; font-weight: 800; }
.fake-bars { height: 66px; display: flex; align-items: end; justify-content: center; gap: 10px; }
.fake-bars i { width: 22px; border-radius: 5px 5px 0 0; background: #e7aaa3; }
.fake-bars i:nth-child(1) { height: 34px; }
.fake-bars i:nth-child(2) { height: 58px; }
.fake-bars i:nth-child(3) { height: 24px; }
.fake-pills { display: flex; justify-content: center; gap: 6px; margin-top: 12px; }
.fake-pills span { padding: 5px 8px; border-radius: 999px; background: #fff; color: var(--muted); font-size: 11px; font-weight: 800; }
.fake-slider { height: 8px; margin-top: 30px; border-radius: 999px; background: #ddd8d1; }
.fake-slider span { display: block; width: 70%; height: 100%; border-radius: inherit; background: var(--ink); }
.fake-score { margin: 18px auto 0; width: fit-content; padding: 7px 10px; border-radius: 6px; background: #fff; font-weight: 900; }
.fake-note { display: grid; gap: 10px; padding-top: 12px; }
.fake-note p { height: 10px; margin: 0; border-radius: 999px; background: #ddd8d1; }
.fake-note p:nth-child(2) { width: 82%; }
.fake-note p:nth-child(3) { width: 58%; }
.fake-plus { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; background: var(--ink); color: #fff; font-size: 26px; margin: 2px auto 14px; }
.fake-field, .fake-button { height: 22px; border-radius: 6px; background: #fff; border: 1px solid var(--line); margin-bottom: 8px; }
.fake-button { width: 70%; margin: 0 auto; background: var(--ink); }
.toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); padding: 12px 16px; border-radius: 8px; background: var(--ink); color: #fff; font-weight: 750; box-shadow: var(--shadow); z-index: 20; }

@media (max-width: 1000px) {
  .auth-shell, .layout, .finance-grid, .chart-grid { grid-template-columns: 1fr; }
  .guide-grid { grid-template-columns: 1fr; }
  .overview-grid { grid-template-columns: 1fr; }
  .drawer { position: static; }
  .inline-form { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 720px) {
  .auth-shell, .app-shell { width: min(100% - 20px, 1240px); }
  .topbar, .auth-shell { grid-template-columns: 1fr; }
  .auth-shell { gap: 22px; padding: 28px 0; }
  .topbar { gap: 12px; margin-bottom: 18px; }
  .brand { padding-bottom: 2px; }
  .date-switcher {
    width: 100%;
    display: grid;
    grid-template-columns: 40px 1fr 40px;
    gap: 8px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--soft);
  }
  .date-switcher .date-picker {
    grid-column: 1 / -1;
    grid-row: 2;
    width: 100%;
    background: #fff;
  }
  .date-switcher strong {
    min-width: 0;
    text-align: center;
    align-self: center;
    font-size: 15px;
  }
  .date-switcher [data-today] {
    grid-column: 1 / -1;
    width: 100%;
    background: #fff;
  }
  .user-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  .user-actions .support-btn {
    grid-column: 1 / -1;
    min-height: 46px;
    background: #e5f3eb;
    border-color: #b9dfc8;
    color: #24553d;
    box-shadow: 0 8px 20px rgba(47, 107, 79, 0.12);
  }
  .user-actions .danger {
    grid-column: 1 / -1;
  }
  .tracker-row, .inline-form { grid-template-columns: 1fr; }
  .guide-step { grid-template-columns: 1fr; }
  .tracker-controls { justify-content: space-between; }
  .slider-control { grid-template-columns: 1fr 42px; width: 100%; }
  .finance-toolbar { align-items: stretch; flex-direction: column; }
}
