/* Kadro — dark-only calm tool. Tokens documented in docs/DESIGN.md */
:root {
  --bg: #08090A;
  --s1: #101113;
  --s2: #16171A;
  --s3: #1D1E22;
  --line: #25272C;
  --line-2: #34363C;
  --ink: #F4F5F6;
  --ink-2: #C6CAD1;
  --ink-3: #8B9099;
  --accent: #2EC4B6;
  --accent-hover: #4FD8CB;
  --accent-ink: #03201D;
  --neg: #F07A7A;
  --st-progress: #E6B455;
  --st-delivered: #7AA7F0;
  --st-paid: #5CC98A;

  --r-xs: 6px; --r-sm: 10px; --r-md: 14px; --r-lg: 20px;
  --font: Inter, -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Noto Sans", system-ui, sans-serif;
  --tab-h: 64px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --ease: cubic-bezier(.2, .8, .2, 1);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; background: var(--bg); }
body {
  margin: 0; min-height: 100dvh; background: var(--bg); color: var(--ink);
  font: 400 16px/1.5 var(--font); letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent; overscroll-behavior-y: none;
}
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, p { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }
.num { font-variant-numeric: tabular-nums; }
.neg { color: var(--neg) !important; }
.warn-text { color: var(--st-progress); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.ico { display: inline-flex; flex: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }

.skip { position: fixed; left: 12px; top: calc(var(--safe-t) + 8px); z-index: 100; padding: 10px 14px; background: var(--accent); color: var(--accent-ink); border-radius: var(--r-sm); transform: translateY(-200%); }
.skip:focus { transform: none; }

.boot { min-height: 100dvh; }

/* ---------- Shell ---------- */
#app { min-height: 100dvh; }
.main {
  max-width: 640px; margin: 0 auto; outline: none;
  padding: calc(var(--safe-t) + 8px) calc(16px + var(--safe-r)) calc(var(--tab-h) + var(--safe-b) + 32px) calc(16px + var(--safe-l));
}
.sidebar { display: none; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(5, 1fr); align-items: center;
  height: calc(var(--tab-h) + var(--safe-b)); padding: 0 calc(4px + var(--safe-r)) var(--safe-b) calc(4px + var(--safe-l));
  background: rgb(16 17 19 / .92); border-top: 1px solid var(--line);
  -webkit-backdrop-filter: saturate(140%) blur(16px); backdrop-filter: saturate(140%) blur(16px);
}
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  height: var(--tab-h); color: var(--ink-3); font-size: 11px; font-weight: 500; letter-spacing: 0;
  transition: color .15s;
}
.tab.active { color: var(--ink); }
.tab.active .ico { color: var(--accent); }
.tab:active .ico { transform: scale(.92); }
.tab-new {
  justify-self: center; width: 52px; height: 52px; border-radius: 50%;
  display: grid; place-items: center; background: var(--accent); color: var(--accent-ink);
  transition: transform .15s var(--ease), background .15s;
}
.tab-new:hover { background: var(--accent-hover); }
.tab-new:active { transform: scale(.94); }

.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { display: inline-flex; }
.brand-name { font-weight: 650; font-size: 17px; letter-spacing: -0.02em; }

@media (min-width: 1024px) {
  #app { display: grid; grid-template-columns: 248px 1fr; }
  .tabbar { display: none; }
  .sidebar {
    display: flex; flex-direction: column; gap: 6px; position: sticky; top: 0; height: 100dvh;
    padding: 20px 12px; border-right: 1px solid var(--line); background: var(--bg);
  }
  .sidebar .brand { padding: 4px 10px 18px; }
  .side-new { margin: 0 4px 14px; }
  .side-nav { display: flex; flex-direction: column; gap: 2px; }
  .side-link {
    display: flex; align-items: center; gap: 12px; height: 40px; padding: 0 12px; border-radius: var(--r-sm);
    color: var(--ink-2); font-size: 15px; font-weight: 500; text-align: left; transition: background .15s, color .15s;
  }
  .side-link:hover { background: var(--s1); color: var(--ink); }
  .side-link.active { background: var(--s2); color: var(--ink); }
  .side-link.active .ico { color: var(--accent); }
  .side-logout { margin-top: auto; color: var(--ink-3); }
  .main { max-width: 880px; width: 100%; padding: 28px 40px 64px; }
}

/* ---------- Page heads ---------- */
.page-head { display: flex; align-items: center; justify-content: space-between; min-height: 56px; margin-bottom: 8px; }
.page-head-title { margin: 8px 0 4px; }
.page-title { font-size: 28px; line-height: 1.15; font-weight: 650; letter-spacing: -0.022em; }
.month-body > .page-title, .main > div > .page-title { margin: 4px 0 16px; }
.lead { color: var(--ink-3); font-size: 14px; margin-bottom: 16px; }
.back { display: inline-flex; align-items: center; gap: 2px; min-height: 44px; margin-left: -8px; padding-right: 8px; color: var(--ink-2); font-size: 15px; }
.back:hover { color: var(--ink); }

.month-switch { display: flex; align-items: center; gap: 4px; width: 100%; justify-content: space-between; }
.month-label {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 44px;
  font-size: 17px; font-weight: 600; letter-spacing: -0.015em;
}
.month-label small { font-size: 12px; font-weight: 500; color: var(--accent); letter-spacing: 0; }
@media (min-width: 1024px) {
  .month-switch { justify-content: flex-start; }
  .month-label { flex: none; min-width: 200px; }
}

.icon-btn {
  display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: var(--r-sm);
  color: var(--ink-2); transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--s2); color: var(--ink); }
.icon-btn:active { background: var(--s3); }
.icon-btn:disabled { opacity: .35; cursor: default; background: none; }

/* ---------- Hero + KPIs ---------- */
.hero { padding: 12px 0 20px; }
.hero-label { font-size: 13px; font-weight: 600; color: var(--ink-3); letter-spacing: .02em; }
.hero-num { font-size: 44px; line-height: 1.05; font-weight: 650; letter-spacing: -0.035em; margin: 6px 0 6px; }
.hero-sub { font-size: 13px; color: var(--ink-3); }
@media (max-width: 359px) { .hero-num { font-size: 36px; } }

.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 28px; }
.kpis-3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 420px) { .kpis-3 { grid-template-columns: 1fr 1fr; } .kpis-3 .kpi:last-child { grid-column: span 2; } }
@media (min-width: 1024px) { .kpis { grid-template-columns: repeat(4, 1fr); } .kpis .kpi-wide { grid-column: auto; } .kpis-3 { grid-template-columns: repeat(3, 1fr); } }
.kpi { background: var(--s1); border: 1px solid var(--line); border-radius: var(--r-md); padding: 14px 14px 12px; min-width: 0; }
.kpi-wide { grid-column: span 2; }
.kpi-label { font-size: 13px; color: var(--ink-3); font-weight: 500; }
.kpi-num { font-size: 20px; font-weight: 600; letter-spacing: -0.02em; margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-sub { font-size: 12px; color: var(--ink-3); margin-top: 2px; }
.kpi.warn { border-color: rgb(230 180 85 / .35); }
.kpi.warn .kpi-num { color: var(--st-progress); }
.kpi.neg .kpi-num { color: var(--neg); }

/* ---------- Sections & lists ---------- */
.block { margin-bottom: 28px; }
.block-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; margin-bottom: 4px; }
.block-title { font-size: 15px; font-weight: 600; color: var(--ink-2); letter-spacing: -0.01em; }
.block-count { font-size: 13px; color: var(--ink-3); background: var(--s2); border-radius: 999px; padding: 1px 9px; }
.block-sub { font-size: 13px; color: var(--ink-3); margin: -2px 0 10px; }
.link-btn { display: inline-flex; align-items: center; gap: 4px; min-height: 44px; padding: 0 4px; color: var(--accent); font-size: 15px; font-weight: 500; }
.link-btn:hover { color: var(--accent-hover); }

.list { background: var(--s1); border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; }
.row { display: flex; align-items: center; border-top: 1px solid var(--line); }
.row:first-child { border-top: 0; }
.row-main {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; min-height: 64px; padding: 10px 8px 10px 14px; text-align: left;
  transition: background .15s;
}
.row-main:hover { background: var(--s2); }
.row-link { display: grid; place-items: center; width: 44px; height: 44px; flex: none; color: var(--ink-3); border-radius: 10px; }
.row-link:hover, .row-link:focus-visible { color: var(--accent); background: var(--s2); }
.row-main:active { background: var(--s3); }
.row-bar { width: 3px; align-self: stretch; border-radius: 3px; background: var(--c); flex: none; margin: 2px 0; }
.row-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.row-title { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-meta { font-size: 13px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-amount { display: flex; flex-direction: column; align-items: flex-end; flex: none; font-weight: 500; }
.row-amount small { font-size: 11px; color: var(--ink-3); font-weight: 500; }
.row > .status { margin-right: 8px; }

.status {
  display: inline-flex; align-items: center; gap: 6px; flex: none; min-height: 44px; padding: 0 10px; border-radius: var(--r-sm);
  font-size: 12px; font-weight: 500; color: var(--ink-2); transition: background .15s;
}
.status:hover { background: var(--s2); }
.status-label { white-space: nowrap; }
@media (max-width: 420px) {
  .row .status-label { display: none; }
  .row > .status { padding: 0 14px; margin-right: 0; }
}
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--ink-3); display: inline-block; }
.dot.progress { background: var(--st-progress); }
.dot.delivered { background: var(--st-delivered); }
.dot.paid { background: var(--st-paid); }
.status.progress { color: var(--st-progress); }
.status.delivered { color: var(--st-delivered); }
.status.paid { color: var(--st-paid); }

/* Client cards */
.cards { display: grid; gap: 8px; }
@media (min-width: 720px) { .cards { grid-template-columns: 1fr 1fr; } }
.card {
  display: flex; align-items: center; gap: 12px; min-height: 72px; padding: 14px; background: var(--s1);
  border: 1px solid var(--line); border-radius: var(--r-md); transition: background .15s, border-color .15s, transform .15s var(--ease);
}
.card:hover { background: var(--s2); border-color: var(--line-2); }
.card:active { transform: scale(.99); }
.card-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.card-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-meta { font-size: 13px; color: var(--ink-3); }
.card-nums { display: flex; flex-direction: column; align-items: flex-end; font-weight: 600; flex: none; }
.card-nums small { font-size: 12px; font-weight: 500; color: var(--ink-3); }
.card-nums small.warn-text { color: var(--st-progress); }
.avatar {
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; flex: none;
  font-size: 14px; font-weight: 650; letter-spacing: 0; color: var(--c);
  background: color-mix(in srgb, var(--c) 16%, var(--s2)); border: 1px solid color-mix(in srgb, var(--c) 30%, transparent);
}
.avatar-lg { width: 56px; height: 56px; border-radius: 16px; font-size: 19px; }
.client-head { display: flex; align-items: center; gap: 14px; margin: 4px 0 14px; }
.client-head-text { flex: 1; min-width: 0; }
.client-head .page-title { overflow-wrap: anywhere; }
.contact-links { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.pill-link { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 14px; border: 1px solid var(--line); border-radius: 999px; font-size: 14px; color: var(--ink-2); background: var(--s1); max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.pill-link:hover { border-color: var(--line-2); color: var(--ink); }
.notes { color: var(--ink-2); font-size: 15px; margin-bottom: 16px; white-space: pre-line; }
@media (min-width: 1024px) { .mobile-only { display: none !important; } }
.danger-zone { margin-top: 8px; padding-top: 16px; border-top: 1px solid var(--line); }

/* Panels (finance) */
.panel { background: var(--s1); border: 1px solid var(--line); border-radius: var(--r-md); padding: 16px; margin-bottom: 12px; }
.panel-title { font-size: 15px; font-weight: 600; color: var(--ink-2); margin-bottom: 8px; }
.panel-line { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; color: var(--ink-2); font-size: 15px; }
.panel-total { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding-top: 12px; margin-top: 8px; border-top: 1px solid var(--line); font-weight: 500; }
.panel-total b { font-size: 20px; font-weight: 650; letter-spacing: -0.02em; }
.panel-total.credit b { color: var(--st-paid); }
.panel .hint { margin-top: 8px; }
.compare { display: grid; gap: 14px; }
.cmp-head { display: flex; justify-content: space-between; font-size: 15px; color: var(--ink-2); margin-bottom: 6px; }
.cmp-head b { color: var(--ink); font-weight: 600; }
.cmp-track { height: 10px; background: var(--s3); border-radius: 999px; overflow: hidden; }
.cmp-fill { height: 100%; border-radius: 999px; background: var(--ink-2); transition: width .4s var(--ease); }
.cmp-row.exp .cmp-fill { background: var(--neg); opacity: .8; }
.cat-list { display: grid; gap: 2px; background: var(--s1); border: 1px solid var(--line); border-radius: var(--r-md); padding: 8px 16px; }
.cat-list li { display: grid; grid-template-columns: minmax(0, 1fr) 20% auto; align-items: center; gap: 12px; min-height: 40px; font-size: 15px; color: var(--ink-2); }
.cat-list li > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-bar { height: 6px; border-radius: 999px; background: linear-gradient(to right, var(--neg) var(--w), var(--s3) var(--w)); opacity: .85; }
.cat-list b { font-weight: 500; color: var(--ink); text-align: right; min-width: 76px; }

/* Stats */
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--ink-3); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.lg { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.lg.inc { background: var(--ink-2); }
.lg.exp { background: var(--neg); opacity: .8; }
.lg.net { background: var(--accent); border-radius: 50%; }
.chart-wrap { padding: 12px 8px 4px; }
.bars { width: 100%; height: auto; display: block; }
.bars .grid { stroke: var(--line); stroke-width: 1; }
.bars .axis { stroke: var(--line-2); stroke-width: 1; }
.bars .b-inc { fill: var(--ink-2); }
.bars .b-exp { fill: var(--neg); opacity: .8; }
.bars .net-line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; }
.bars .net-dot { fill: var(--bg); stroke: var(--accent); stroke-width: 2; }
.bars .mlabel { fill: var(--ink-3); font-size: 12px; font-family: var(--font); }
.bars g:hover rect { opacity: 1; filter: brightness(1.15); }
.table-details { margin-top: 4px; }
.table-details summary { min-height: 44px; display: flex; align-items: center; gap: 8px; cursor: pointer; color: var(--ink-2); font-size: 14px; list-style: none; }
.table-details summary::-webkit-details-marker { display: none; }
.table-details summary::before { content: ""; width: 7px; height: 7px; border-right: 1.8px solid currentColor; border-bottom: 1.8px solid currentColor; transform: rotate(-45deg); transition: transform .15s; }
.table-details[open] summary::before { transform: rotate(45deg); }
.table-scroll { overflow-x: auto; background: var(--s1); border: 1px solid var(--line); border-radius: var(--r-md); }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { padding: 10px 14px; text-align: right; border-top: 1px solid var(--line); white-space: nowrap; }
.table thead th { border-top: 0; color: var(--ink-3); font-weight: 500; font-size: 13px; }
.table th:first-child { text-align: left; font-weight: 500; }
.share { display: grid; gap: 4px; background: var(--s1); border: 1px solid var(--line); border-radius: var(--r-md); padding: 6px; }
.share-link { display: block; padding: 10px; border-radius: var(--r-sm); transition: background .15s; }
.share-link:hover { background: var(--s2); }
.share-head { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 8px; font-size: 15px; }
.share-name { display: inline-flex; align-items: center; gap: 8px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.share-head small { color: var(--ink-3); font-size: 13px; }
.share-track { display: block; height: 6px; background: var(--s3); border-radius: 999px; overflow: hidden; }
.share-fill { display: block; height: 100%; background: var(--c); border-radius: 999px; }
.exports { display: grid; gap: 8px; }
@media (min-width: 720px) { .exports { grid-template-columns: repeat(3, 1fr); } }

/* Empty / loading */
.empty {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 12px;
  padding: 32px 20px; background: var(--s1); border: 1px dashed var(--line-2); border-radius: var(--r-md); color: var(--ink-2);
}
.empty-ico { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 14px; background: var(--s2); color: var(--ink-3); }
.skeleton { display: grid; gap: 10px; padding-top: 8px; }
.sk-line { height: 56px; border-radius: var(--r-md); background: linear-gradient(90deg, var(--s1) 0%, var(--s2) 50%, var(--s1) 100%); background-size: 200% 100%; animation: sk 1.2s linear infinite; }
.sk-line:first-child { height: 88px; }
@keyframes sk { to { background-position: -200% 0; } }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 18px;
  border-radius: var(--r-sm); font-size: 16px; font-weight: 600; letter-spacing: -0.01em; white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s, transform .12s var(--ease), opacity .15s;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.is-busy { position: relative; color: transparent !important; }
.btn.is-busy::after { content: ""; position: absolute; width: 18px; height: 18px; border-radius: 50%; border: 2px solid currentColor; border-color: var(--accent-ink) transparent var(--accent-ink) transparent; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--s2); color: var(--ink); border: 1px solid var(--line-2); }
.btn-secondary:hover { background: var(--s3); }
.btn-danger { background: var(--neg); color: #2A0909; }
.btn-ghost-danger { color: var(--neg); background: transparent; border: 1px solid var(--line); }
.btn-ghost-danger:hover { background: rgb(240 122 122 / .08); border-color: rgb(240 122 122 / .35); }
.btn-sm { min-height: 40px; padding: 0 12px; font-size: 14px; }
.btn-wide { width: 100%; }
.btn-left { justify-content: flex-start; }
@media (min-width: 1024px) { .btn { min-height: 42px; font-size: 15px; } .btn-sm { min-height: 36px; } }

/* ---------- Forms ---------- */
.form { display: grid; gap: 16px; }
.field { display: grid; gap: 6px; min-width: 0; }
.field > label, .label { font-size: 14px; font-weight: 500; color: var(--ink-2); }
.input {
  width: 100%; min-height: 48px; padding: 12px 14px; font-size: 16px; /* 16px: no iOS zoom */
  background: var(--s2); border: 1px solid var(--line-2); border-radius: var(--r-sm); color: var(--ink);
  transition: border-color .15s, background .15s; -webkit-appearance: none; appearance: none;
}
.input::placeholder { color: #6E737C; }
.input:hover { border-color: #43464D; }
.input:focus { outline: none; border-color: var(--accent); background-color: var(--s1); box-shadow: 0 0 0 3px rgb(46 196 182 / .18); }
textarea.input { resize: vertical; min-height: 88px; line-height: 1.45; }
select.input {
  padding-right: 40px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%238B9099' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
input[type="date"].input { min-width: 0; display: flex; align-items: center; }
input[type="date"]::-webkit-calendar-picker-indicator { filter: invert(.7); }
.input-money { font-variant-numeric: tabular-nums; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 359px) { .row-2 { grid-template-columns: 1fr; } }
.hint { font-size: 13px; color: var(--ink-3); }
.form-error { padding: 12px 14px; border-radius: var(--r-sm); background: rgb(240 122 122 / .1); border: 1px solid rgb(240 122 122 / .35); color: #FFB4B4; font-size: 15px; }
.gross { display: flex; justify-content: space-between; gap: 12px; margin-top: -8px; padding: 10px 14px; background: var(--s1); border: 1px solid var(--line); border-radius: var(--r-sm); font-size: 14px; color: var(--ink-3); }
.gross b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }

.toggle { display: flex; align-items: center; gap: 12px; min-height: 52px; cursor: pointer; position: relative; }
.toggle-text { flex: 1; display: flex; flex-direction: column; font-weight: 500; }
.toggle-text small { font-size: 13px; color: var(--ink-3); font-weight: 400; }
.toggle input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.toggle-track { width: 48px; height: 30px; border-radius: 999px; background: var(--s3); border: 1px solid var(--line-2); position: relative; flex: none; transition: background .18s, border-color .18s; }
.toggle-track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: var(--ink-2); transition: transform .18s var(--ease), background .18s; }
.toggle input:checked + .toggle-track { background: var(--accent); border-color: var(--accent); }
.toggle input:checked + .toggle-track::after { transform: translateX(18px); background: var(--accent-ink); }
.toggle input:focus-visible + .toggle-track { outline: 2px solid var(--accent); outline-offset: 2px; }

.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; padding: 3px; background: var(--s2); border: 1px solid var(--line-2); border-radius: var(--r-sm); }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label { display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 42px; padding: 0 6px; border-radius: 8px; font-size: 14px; font-weight: 500; color: var(--ink-3); cursor: pointer; text-align: center; transition: background .15s, color .15s; }
.seg input:checked + label { background: var(--s3); color: var(--ink); box-shadow: 0 0 0 1px var(--line-2); }
.seg input:focus-visible + label { outline: 2px solid var(--accent); outline-offset: -2px; }
@media (max-width: 380px) { .seg label { font-size: 13px; gap: 4px; } .seg .dot { width: 6px; height: 6px; } }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips input { position: absolute; opacity: 0; pointer-events: none; }
.chip { display: inline-flex; align-items: center; min-height: 40px; padding: 0 14px; border-radius: 999px; background: var(--s2); border: 1px solid var(--line-2); font-size: 14px; color: var(--ink-2); cursor: pointer; transition: all .15s; }
.chips input:checked + .chip { background: rgb(46 196 182 / .14); border-color: var(--accent); color: var(--ink); }
.chips input:focus-visible + .chip { outline: 2px solid var(--accent); outline-offset: 2px; }

.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.swatches input { position: absolute; opacity: 0; pointer-events: none; }
.swatch { width: 40px; height: 40px; border-radius: 12px; background: var(--c); cursor: pointer; box-shadow: inset 0 0 0 1px rgb(255 255 255 / .1); transition: transform .12s var(--ease); }
.swatches input:checked + .swatch { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--ink); }
.swatches input:focus-visible + .swatch { outline: 2px solid var(--accent); outline-offset: 4px; }

/* ---------- Sheets ---------- */
dialog.sheet {
  margin: 0; padding: 0; border: 0; background: transparent; color: var(--ink);
  position: fixed; inset: 0; max-width: none; max-height: none; width: 100%; height: 100%;
  display: flex; align-items: flex-end; justify-content: center; overflow: hidden;
}
dialog.sheet:not([open]) { display: none; }
dialog.sheet::backdrop { background: rgb(0 0 0 / .6); animation: fade .2s ease-out; }
dialog.sheet.closing::backdrop { opacity: 0; transition: opacity .16s; }
.sheet-panel {
  width: 100%; max-width: 640px; max-height: calc(100% - var(--safe-t) - 24px);
  display: flex; flex-direction: column; background: var(--s1); border: 1px solid var(--line); border-bottom: 0;
  border-radius: var(--r-lg) var(--r-lg) 0 0; box-shadow: 0 -8px 40px rgb(0 0 0 / .5);
  animation: up .24s var(--ease);
}
dialog.sheet.closing .sheet-panel { transform: translateY(100%); transition: transform .16s ease-in; }
.sheet-lg .sheet-panel { height: calc(100% - var(--safe-t) - 24px); }
.sheet-grab { width: 36px; height: 5px; border-radius: 999px; background: var(--line-2); margin: 8px auto 0; flex: none; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 4px 8px 4px 20px; flex: none; }
.sheet-head h2 { font-size: 18px; font-weight: 650; letter-spacing: -0.015em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sheet-body { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 8px 20px 20px; }
.sheet-foot {
  display: flex; gap: 10px; flex: none; padding: 12px calc(20px + var(--safe-r)) calc(12px + var(--safe-b)) calc(20px + var(--safe-l));
  border-top: 1px solid var(--line); background: var(--s1);
}
.sheet-foot .btn { flex: 1; }
.sheet-foot .btn-ghost-danger { flex: none; width: 52px; padding: 0; }
.sheet-sm .sheet-body { padding-bottom: calc(16px + var(--safe-b)); }
.sheet-text { color: var(--ink-2); }
.sheet-sm:has(.sheet-foot) .sheet-body { padding-bottom: 16px; }

.menu { display: grid; gap: 4px; }
.menu-item {
  display: flex; align-items: center; gap: 14px; min-height: 56px; padding: 0 14px; border-radius: var(--r-sm);
  text-align: left; font-size: 16px; font-weight: 500; transition: background .15s;
}
.menu-item:hover, .menu-item:focus-visible { background: var(--s2); }
.menu-item:active { background: var(--s3); }
.menu-item .ico { color: var(--accent); }
.menu-item.active { background: var(--s2); }
.menu-item.active > .ico:last-child { color: var(--ink); }
.menu-label { flex: 1; display: flex; flex-direction: column; }
.menu-label small { font-size: 13px; font-weight: 400; color: var(--ink-3); }
.menu-item .dot { width: 10px; height: 10px; margin: 0 4px; }

@media (min-width: 1024px) {
  dialog.sheet { align-items: center; }
  .sheet-panel { max-width: 520px; max-height: min(760px, calc(100dvh - 64px)); border-radius: var(--r-lg); border-bottom: 1px solid var(--line); animation: pop .2s var(--ease); }
  .sheet-lg .sheet-panel { height: auto; }
  .sheet-sm .sheet-panel { max-width: 420px; }
  .sheet-grab { display: none; }
  .sheet-head { padding-top: 12px; }
  .sheet-foot { padding: 14px 20px; border-radius: 0 0 var(--r-lg) var(--r-lg); justify-content: flex-end; }
  .sheet-foot .btn { flex: none; min-width: 120px; }
  .sheet-foot .btn-ghost-danger { margin-right: auto; min-width: 0; width: 44px; }
  dialog.sheet.closing .sheet-panel { transform: scale(.98); opacity: 0; transition: transform .14s, opacity .14s; }
}

@keyframes up { from { transform: translateY(100%); } }
@keyframes pop { from { transform: scale(.97); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tab-h) + var(--safe-b) + 16px); z-index: 1000;
  transform: translate(-50%, 12px); opacity: 0; pointer-events: none;
  max-width: calc(100vw - 32px); padding: 12px 16px; border-radius: 12px;
  background: var(--s3); border: 1px solid var(--line-2); color: var(--ink); font-size: 15px; font-weight: 500;
  box-shadow: 0 8px 30px rgb(0 0 0 / .5); transition: opacity .18s, transform .18s var(--ease);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { border-color: rgb(240 122 122 / .5); color: #FFB4B4; }
@media (min-width: 1024px) { .toast { bottom: 24px; } }

/* ---------- Login ---------- */
.is-login #app { display: block; }
.login { min-height: 100dvh; display: grid; place-items: center; padding: calc(var(--safe-t) + 24px) 20px calc(var(--safe-b) + 24px); }
.login-form { width: 100%; max-width: 360px; display: grid; gap: 16px; }
.login-form .brand { margin-bottom: 24px; }
.login-title { font-size: 28px; font-weight: 650; letter-spacing: -0.022em; }
.login-sub { color: var(--ink-3); margin-top: -8px; margin-bottom: 8px; }

/* Month change motion */
.month-body { animation: fade .18s ease-out; }
[data-dir="next"] .month-body { animation: from-r .22s var(--ease); }
[data-dir="prev"] .month-body { animation: from-l .22s var(--ease); }
@keyframes from-r { from { opacity: 0; transform: translateX(14px); } }
@keyframes from-l { from { opacity: 0; transform: translateX(-14px); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
.noscript { padding: 24px; }
