/* ---- 00-base.css ---- */
/* Leafline design system: green liquid glass.
   Colours are tokens on :root; dark theme redefines them. Text colours were checked against the glass
   panels composited over the brightest and darkest background blobs (see tests/contrast.js): body text
   is 7:1+, secondary 4.5:1+ in both themes. */
:root {
  --g50: #effbf3; --g100: #d9f5e2; --g200: #b3ebc7; --g300: #80dca4; --g400: #46c47c; --g500: #1fa95e; --g600: #138a4a; --g700: #0f6e3d; --g800: #0e5733; --g900: #0b3f26; --g950: #052114;
  --lime: #c6ef6a; --mint: #7deec7; --teal: #22b7a0;

  --bg: #e6f2eb;
  --blob1: #9be8bf; --blob2: #d4f59a; --blob3: #7fe0d0; --blob4: #b9eecb;
  --text: #0a2618; --text2: #34574a; --text3: #4b6a5b; --line: rgba(13, 64, 38, .1); --line2: rgba(13, 64, 38, .16);
  --glass: rgba(255, 255, 255, .6); --glass2: rgba(255, 255, 255, .78); --glass-hi: rgba(255, 255, 255, .85); --glass-edge: rgba(255, 255, 255, .72);
  --inset: rgba(255, 255, 255, .55); --inset-focus: rgba(255, 255, 255, .9);
  --shadow: 0 1px 2px rgba(8, 50, 28, .06), 0 10px 30px -8px rgba(8, 60, 32, .16);
  --shadow-lg: 0 2px 6px rgba(8, 50, 28, .06), 0 30px 70px -20px rgba(8, 60, 32, .32);
  --accent: var(--g600); --accent-text: #0b6b39; --on-accent: #fff;
  --btn: linear-gradient(180deg, #27b866, #12904c); --btn-edge: rgba(255, 255, 255, .45);
  --chip: rgba(13, 90, 50, .08);
  --red: #b3302a; --red-bg: rgba(220, 60, 45, .12); --amber: #8a4f00; --amber-bg: rgba(240, 160, 30, .16); --blue: #1f5fbf; --blue-bg: rgba(50, 120, 230, .12);
  --green-bg: rgba(20, 160, 80, .13);
  --chart1: #13a052; --chart2: #64c9a4; --chart-fill: rgba(31, 169, 94, .22); --grid: rgba(13, 64, 38, .08);
  --blur: blur(26px) saturate(1.8);
  --r: 22px; --r-sm: 14px; --r-xs: 10px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI Variable Text", "Segoe UI", Inter, Roboto, "Helvetica Neue", sans-serif;
  --font-d: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI Variable Display", "Segoe UI", Inter, Roboto, sans-serif;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --spring: cubic-bezier(.25, 1.25, .4, 1);
  --spring-soft: cubic-bezier(.2, .9, .3, 1);
  --sab: env(safe-area-inset-bottom, 0px); --sat: env(safe-area-inset-top, 0px);
  color-scheme: light;
}
@supports (transition-timing-function: linear(0, 1)) {
  :root {
    --spring: linear(0, .006, .025 2.8%, .101 6.1%, .539 18.9%, .721 25.3%, .849 31.5%, .937 38.1%, .968 41.8%, .991 45.7%, 1.006 50.1%, 1.015 55%, 1.017 63.9%, 1.001 85.9%, 1);
    --spring-soft: linear(0, .009, .037 2.4%, .149 5.2%, .538 13.7%, .705 18.6%, .829 23.9%, .912 29.5%, .962 35.4%, .99 42.1%, 1.002 50.6%, 1.004 63%, 1);
  }
}
:root[data-theme="dark"] {
  --bg: #03100a;
  --blob1: #0d6b3f; --blob2: #3f6a12; --blob3: #0b5e57; --blob4: #0f4a2c;
  --text: #ecf8f1; --text2: #aecbbb; --text3: #8fae9e; --line: rgba(220, 255, 235, .09); --line2: rgba(220, 255, 235, .15);
  --glass: rgba(16, 36, 26, .56); --glass2: rgba(20, 42, 31, .78); --glass-hi: rgba(32, 60, 46, .9); --glass-edge: rgba(200, 255, 225, .13);
  --inset: rgba(0, 12, 6, .32); --inset-focus: rgba(0, 12, 6, .5);
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 12px 34px -10px rgba(0, 0, 0, .55);
  --shadow-lg: 0 2px 8px rgba(0, 0, 0, .35), 0 30px 80px -20px rgba(0, 0, 0, .7);
  --accent: var(--g400); --accent-text: #7fe0a6; --on-accent: #fff;
  --btn: linear-gradient(180deg, #23b263, #0f8044); --btn-edge: rgba(255, 255, 255, .28);
  --chip: rgba(150, 255, 200, .08);
  --red: #ff8a7f; --red-bg: rgba(255, 100, 85, .15); --amber: #ffc561; --amber-bg: rgba(255, 180, 60, .14); --blue: #8db8ff; --blue-bg: rgba(90, 150, 255, .15);
  --green-bg: rgba(60, 220, 130, .14);
  --chart1: #4fd88a; --chart2: #2f9e86; --chart-fill: rgba(79, 216, 138, .2); --grid: rgba(220, 255, 235, .07);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #03100a;
    --blob1: #0d6b3f; --blob2: #3f6a12; --blob3: #0b5e57; --blob4: #0f4a2c;
    --text: #ecf8f1; --text2: #aecbbb; --text3: #8fae9e; --line: rgba(220, 255, 235, .09); --line2: rgba(220, 255, 235, .15);
    --glass: rgba(16, 36, 26, .56); --glass2: rgba(20, 42, 31, .78); --glass-hi: rgba(32, 60, 46, .9); --glass-edge: rgba(200, 255, 225, .13);
    --inset: rgba(0, 12, 6, .32); --inset-focus: rgba(0, 12, 6, .5);
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 12px 34px -10px rgba(0, 0, 0, .55);
    --shadow-lg: 0 2px 8px rgba(0, 0, 0, .35), 0 30px 80px -20px rgba(0, 0, 0, .7);
    --accent: var(--g400); --accent-text: #7fe0a6; --on-accent: #fff;
    --btn: linear-gradient(180deg, #23b263, #0f8044); --btn-edge: rgba(255, 255, 255, .28);
    --chip: rgba(150, 255, 200, .08);
    --red: #ff8a7f; --red-bg: rgba(255, 100, 85, .15); --amber: #ffc561; --amber-bg: rgba(255, 180, 60, .14); --blue: #8db8ff; --blue-bg: rgba(90, 150, 255, .15);
    --green-bg: rgba(60, 220, 130, .14);
    --chart1: #4fd88a; --chart2: #2f9e86; --chart-fill: rgba(79, 216, 138, .2); --grid: rgba(220, 255, 235, .07);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; background: var(--bg); }
body { margin: 0; min-height: 100dvh; background: transparent; color: var(--text); font: 15px/1.5 var(--font); letter-spacing: -.005em;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; overflow-x: hidden; }
h1, h2, h3, h4 { font-family: var(--font-d); margin: 0; letter-spacing: -.022em; line-height: 1.15; font-weight: 700; }
h1 { font-size: clamp(26px, 4vw, 34px); }
h2 { font-size: 20px; letter-spacing: -.018em; }
h3 { font-size: 16px; font-weight: 650; letter-spacing: -.01em; }
p { margin: 0; }
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
button, input, textarea, select { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; }
img, svg { display: block; }
:focus-visible { outline: 2.5px solid var(--g400); outline-offset: 2px; border-radius: 8px; }
::selection { background: rgba(70, 196, 124, .35); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--text2); } .faint { color: var(--text3); } .small { font-size: 13px; } .tiny { font-size: 12px; }
.num { font-variant-numeric: tabular-nums; }
.row { display: flex; align-items: center; gap: 10px; } .wrap { flex-wrap: wrap; } .grow { flex: 1; min-width: 0; } .between { justify-content: space-between; }
.stack { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); } .stack-lg { display: grid; gap: 22px; grid-template-columns: minmax(0, 1fr); }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- animated background ---------- */
.bg { position: fixed; inset: 0; z-index: -1; overflow: hidden; background: var(--bg); pointer-events: none; }
.bg i { position: absolute; width: 62vmax; height: 62vmax; border-radius: 50%; opacity: .9; will-change: transform;
  background: radial-gradient(closest-side, var(--c) 0%, color-mix(in srgb, var(--c) 55%, transparent) 45%, transparent 100%); }
.bg i:nth-child(1) { --c: var(--blob1); left: -18vmax; top: -22vmax; animation: drift1 26s ease-in-out infinite alternate; }
.bg i:nth-child(2) { --c: var(--blob2); right: -22vmax; top: -12vmax; width: 52vmax; height: 52vmax; animation: drift2 32s ease-in-out infinite alternate; }
.bg i:nth-child(3) { --c: var(--blob3); left: 20vmax; bottom: -30vmax; animation: drift3 29s ease-in-out infinite alternate; }
.bg i:nth-child(4) { --c: var(--blob4); right: -10vmax; bottom: -20vmax; width: 45vmax; height: 45vmax; animation: drift1 37s ease-in-out infinite alternate-reverse; }
.bg::after { content: ""; position: absolute; inset: 0; background: radial-gradient(120% 80% at 50% 0%, transparent 40%, color-mix(in srgb, var(--bg) 55%, transparent) 100%); }
@keyframes drift1 { to { transform: translate3d(14vmax, 10vmax, 0) scale(1.12); } }
@keyframes drift2 { to { transform: translate3d(-12vmax, 14vmax, 0) scale(.9); } }
@keyframes drift3 { to { transform: translate3d(10vmax, -12vmax, 0) scale(1.08); } }

/* ---------- glass ---------- */
.glass { position: relative; background: var(--glass); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
  border-radius: var(--r); box-shadow: var(--shadow), inset 0 1px 0 var(--glass-edge), inset 0 0 0 1px var(--line); isolation: isolate; }
.glass::before { content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; z-index: -1;
  background: linear-gradient(140deg, rgba(255, 255, 255, .5), rgba(255, 255, 255, 0) 32%, rgba(255, 255, 255, 0) 70%, rgba(255, 255, 255, .14)); opacity: .55; }
:root[data-theme="dark"] .glass::before { opacity: .12; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .glass::before { opacity: .12; } }
.card { padding: 22px; }
.card-sm { padding: 16px; }
.card h2 + *, .card h3 + * { margin-top: 4px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.card-head h2, .card-head h3 { margin: 0; }
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) { :root { --glass: var(--glass2); } }

/* ---- 10-components.css ---- */
/* ---------- buttons ---------- */
.btn { --h: 42px; position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: var(--h); padding: 0 18px;
  border: 0; border-radius: 13px; font-weight: 600; font-size: 14.5px; white-space: nowrap; text-decoration: none !important; user-select: none;
  background: var(--glass2); color: var(--text); box-shadow: inset 0 0 0 1px var(--line2), inset 0 1px 0 var(--glass-edge), 0 1px 2px rgba(0, 0, 0, .05);
  transition: transform .45s var(--spring), box-shadow .2s, background .2s, opacity .2s; -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); }
.btn:hover { background: var(--glass-hi); }
.btn:active { transform: scale(.965); transition-duration: .08s; }
.btn svg { width: 18px; height: 18px; flex: none; }
.btn.primary { background: var(--btn); color: var(--on-accent); box-shadow: inset 0 1px 0 var(--btn-edge), inset 0 0 0 1px rgba(0, 60, 30, .25), 0 6px 18px -6px rgba(18, 140, 74, .6); text-shadow: 0 1px 1px rgba(0, 50, 20, .25); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.primary::after { content: ""; position: absolute; inset: 1px 1px 50% 1px; border-radius: 12px 12px 6px 6px; background: linear-gradient(rgba(255, 255, 255, .22), rgba(255, 255, 255, 0)); pointer-events: none; }
.btn.danger { color: var(--red); }
.btn.ghost { background: transparent; box-shadow: none; -webkit-backdrop-filter: none; backdrop-filter: none; }
.btn.ghost:hover { background: var(--chip); }
.btn.sm { --h: 34px; padding: 0 13px; font-size: 13.5px; border-radius: 11px; }
.btn.lg { --h: 52px; padding: 0 24px; font-size: 16px; border-radius: 16px; }
.btn.block { width: 100%; }
.btn.icon { width: var(--h); padding: 0; }
.btn[disabled], .btn.busy { opacity: .55; pointer-events: none; }
.btn.busy::before { content: ""; width: 15px; height: 15px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(1turn); } }

/* ---------- forms ---------- */
.field { display: grid; gap: 6px; }
.field > span, .label { font-size: 13px; font-weight: 600; color: var(--text2); }
.field small { color: var(--text3); font-size: 12.5px; }
.input { width: 100%; min-height: 46px; padding: 11px 14px; border: 0; border-radius: 13px; background: var(--inset); outline: none;
  box-shadow: inset 0 0 0 1px var(--line2), inset 0 1px 2px rgba(0, 0, 0, .04); transition: box-shadow .2s, background .2s; font-size: 16px; }
.input::placeholder { color: var(--text3); opacity: .85; }
.input:focus { background: var(--inset-focus); box-shadow: inset 0 0 0 1.5px var(--g500), 0 0 0 4px rgba(31, 169, 94, .18); }
textarea.input { resize: vertical; min-height: 96px; line-height: 1.5; }
select.input { appearance: none; padding-right: 38px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none' stroke='%23558870' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M1 1.5l5 5 5-5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
@media (max-width: 640px) { .grid2, .grid3 { grid-template-columns: 1fr; } }
.check { display: flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 500; }
.check input { width: 20px; height: 20px; accent-color: var(--g500); }
.switch { position: relative; width: 50px; height: 30px; flex: none; appearance: none; border-radius: 99px; background: var(--line2); cursor: pointer; transition: background .25s; margin: 0; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 26px; height: 26px; border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, .2); transition: transform .5s var(--spring); }
.switch:checked { background: var(--g500); } .switch:checked::after { transform: translateX(20px); }

/* ---------- segmented control (sliding pill) ---------- */
.seg { position: relative; display: inline-grid; grid-auto-flow: column; grid-auto-columns: 1fr; padding: 3px; border-radius: 13px; background: var(--chip); box-shadow: inset 0 0 0 1px var(--line); }
.seg button { position: relative; z-index: 1; border: 0; background: none; height: 32px; padding: 0 14px; border-radius: 10px; font-size: 13.5px; font-weight: 600; color: var(--text2); transition: color .2s; white-space: nowrap; }
.seg button[aria-pressed="true"] { color: var(--text); }
.seg .pill { position: absolute; z-index: 0; top: 3px; bottom: 3px; left: 0; border-radius: 10px; background: var(--glass-hi); box-shadow: 0 1px 3px rgba(0, 0, 0, .1), inset 0 0 0 .5px var(--line2), inset 0 1px 0 var(--glass-edge);
  transition: transform .55s var(--spring), width .55s var(--spring); }

/* ---------- chips & badges ---------- */
.chip { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: 99px; font-size: 12px; font-weight: 650; white-space: nowrap; background: var(--chip); color: var(--text2); }
.chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85; }
.chip.plain::before { display: none; }
.chip.green { background: var(--green-bg); color: var(--accent-text); }
.chip.red { background: var(--red-bg); color: var(--red); }
.chip.amber { background: var(--amber-bg); color: var(--amber); }
.chip.blue { background: var(--blue-bg); color: var(--blue); }
.badge { display: inline-grid; place-items: center; min-width: 19px; height: 19px; padding: 0 5px; border-radius: 99px; background: #ef4136; color: #fff; font-size: 11px; font-weight: 700; line-height: 1; box-shadow: 0 0 0 2px var(--glass2); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #ef4136; flex: none; }

/* ---------- lists ---------- */
.list { display: grid; grid-template-columns: minmax(0, 1fr); }
.li { display: flex; align-items: center; gap: 14px; padding: 13px 4px; border-top: 1px solid var(--line); color: inherit; text-decoration: none !important; border-radius: 12px; transition: background .2s; }
.li:first-child { border-top: 0; }
a.li:hover, button.li:hover { background: var(--chip); }
button.li { width: 100%; border: 0; border-top: 1px solid var(--line); background: none; text-align: left; }
.li .ic { width: 38px; height: 38px; flex: none; border-radius: 12px; display: grid; place-items: center; background: var(--chip); color: var(--accent-text); }
.li .ic svg { width: 19px; height: 19px; }
.li .t { font-weight: 600; } .li .s { font-size: 13px; color: var(--text2); }
.li .end { margin-left: auto; text-align: right; flex: none; display: flex; align-items: center; gap: 10px; }
.chev { width: 16px; height: 16px; color: var(--text3); flex: none; }

/* ---------- avatars ---------- */
.av { width: 34px; height: 34px; flex: none; border-radius: 50%; display: grid; place-items: center; font-size: 13px; font-weight: 700; color: #fff;
  background: linear-gradient(135deg, var(--c, #2bb673), color-mix(in srgb, var(--c, #2bb673) 60%, #063)); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35), 0 1px 3px rgba(0, 0, 0, .15); }
.av.lg { width: 48px; height: 48px; font-size: 17px; border-radius: 15px; }

/* ---------- stat tiles ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; }
.tile { padding: 18px 18px 16px; display: grid; gap: 4px; min-width: 0; }
.tile .k { font-size: 13px; font-weight: 600; color: var(--text2); display: flex; align-items: center; gap: 7px; }
.tile .k svg { width: 16px; height: 16px; color: var(--accent-text); }
.tile .v { font: 700 30px/1.1 var(--font-d); letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.tile .d { font-size: 12.5px; color: var(--text3); }
.delta { font-weight: 700; } .delta.up { color: var(--accent-text); } .delta.down { color: var(--red); }

/* ---------- progress ---------- */
.bar { height: 8px; border-radius: 99px; background: var(--chip); overflow: hidden; box-shadow: inset 0 0 0 1px var(--line); }
.bar > i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--g400), var(--lime)); transform-origin: left; animation: grow 1s var(--spring-soft) both; }
@keyframes grow { from { transform: scaleX(0); } }
.ring { --p: 0; width: 54px; height: 54px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; font-weight: 700;
  background: conic-gradient(var(--g500) calc(var(--p) * 1%), var(--chip) 0); -webkit-mask: radial-gradient(circle, transparent 54%, #000 55%); mask: radial-gradient(circle, transparent 54%, #000 55%); }

/* ---------- tables ---------- */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12px; font-weight: 650; color: var(--text3); text-transform: uppercase; letter-spacing: .04em; padding: 0 10px 10px; }
.table td { padding: 12px 10px; border-top: 1px solid var(--line); vertical-align: middle; }
.table tr.click { cursor: pointer; } .table tr.click:hover td { background: var(--chip); }
.table td:first-child, .table th:first-child { padding-left: 4px; } .table .r { text-align: right; }
.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -4px; padding: 0 4px; }

/* ---------- empty states ---------- */
.empty { display: grid; justify-items: center; text-align: center; gap: 10px; padding: 46px 22px; }
.empty .art { width: 92px; height: 92px; margin-bottom: 6px; border-radius: 28px; display: grid; place-items: center; color: var(--accent-text);
  background: radial-gradient(circle at 30% 25%, rgba(255, 255, 255, .7), transparent 60%), linear-gradient(140deg, var(--green-bg), var(--chip)); box-shadow: inset 0 0 0 1px var(--line), inset 0 1px 0 var(--glass-edge), var(--shadow); }
.empty .art svg { width: 42px; height: 42px; }
.empty p { max-width: 420px; color: var(--text2); }
.empty .btn { margin-top: 8px; }

/* ---------- skeletons ---------- */
.sk { border-radius: 10px; background: linear-gradient(90deg, var(--chip) 25%, color-mix(in srgb, var(--chip) 30%, var(--glass-edge)) 50%, var(--chip) 75%); background-size: 300% 100%; animation: shimmer 1.4s ease infinite; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }

/* ---------- toast ---------- */
.toasts { position: fixed; z-index: 100; left: 50%; top: calc(14px + var(--sat)); transform: translateX(-50%); display: grid; gap: 8px; width: min(420px, calc(100vw - 32px)); pointer-events: none; }
.toast { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: 16px; font-weight: 600; font-size: 14px; background: var(--glass2); pointer-events: auto;
  -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); box-shadow: var(--shadow-lg), inset 0 0 0 1px var(--line2), inset 0 1px 0 var(--glass-edge); animation: toastIn .6s var(--spring) both; }
.toast svg { width: 20px; height: 20px; flex: none; color: var(--accent-text); } .toast.err svg { color: var(--red); }
.toast.out { animation: toastOut .3s var(--ease) both; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-16px) scale(.94); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-10px) scale(.96); } }

/* ---------- sheet / modal ---------- */
.scrim { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 20px; background: rgba(2, 20, 10, .32); animation: fade .3s var(--ease) both; }
.scrim.out { animation: fade .22s var(--ease) reverse both; }
.sheet { width: min(560px, 100%); max-height: min(86dvh, 820px); overflow: auto; overscroll-behavior: contain; padding: 24px; background: var(--glass2); border-radius: 26px; box-shadow: var(--shadow-lg), inset 0 0 0 1px var(--line2), inset 0 1px 0 var(--glass-edge);
  -webkit-backdrop-filter: blur(40px) saturate(1.8); backdrop-filter: blur(40px) saturate(1.8); animation: pop .6s var(--spring) both; }
.sheet.wide { width: min(760px, 100%); }
.scrim.out .sheet { animation: popOut .22s var(--ease) both; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 18px; }
.sheet-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; flex-wrap: wrap; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(14px) scale(.94); } }
@keyframes popOut { to { opacity: 0; transform: scale(.96); } }
@media (max-width: 640px) {
  .scrim { align-items: end; padding: 0; }
  .sheet, .sheet.wide { width: 100%; border-radius: 26px 26px 0 0; padding-bottom: calc(24px + var(--sab)); animation-name: slideUp; }
  .scrim.out .sheet { animation: slideDown .25s var(--ease) both; }
  .sheet::before { content: ""; display: block; width: 38px; height: 5px; border-radius: 9px; background: var(--line2); margin: -10px auto 14px; }
}
@keyframes slideUp { from { transform: translateY(100%); } }
@keyframes slideDown { to { transform: translateY(100%); } }

/* ---------- entrance motion ---------- */
.rise { animation: rise .7s var(--spring-soft) both; animation-delay: calc(var(--i, 0) * 45ms); }
@keyframes rise { from { opacity: 0; transform: translateY(14px) scale(.985); } }
.view-enter { animation: viewIn .55s var(--spring-soft) both; }
@keyframes viewIn { from { opacity: 0; transform: translateY(10px); } }

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

.mark { width: 34px; height: 34px; flex: none; }
.paper .mark { width: 44px; height: 44px; }
.empty .art .mark { width: 48px; height: 48px; }
p > svg, .muted > svg { display: inline-block; vertical-align: -3px; width: 15px; height: 15px; }

/* ---- 20-layout.css ---- */
/* ---------- app shell ---------- */
.app { display: grid; grid-template-columns: 264px minmax(0, 1fr); min-height: 100dvh; }
.side { position: sticky; top: 0; height: 100dvh; padding: 16px 0 16px 16px; }
.side-in { height: 100%; display: flex; flex-direction: column; padding: 18px 12px 12px; border-radius: 26px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 10px 18px; color: var(--text); text-decoration: none !important; }
.brand .mark { width: 34px; height: 34px; flex: none; }
.wordmark { font: 750 21px/1 var(--font-d); letter-spacing: -.035em; }
.wordmark b { font-weight: inherit; background: linear-gradient(120deg, var(--g500), var(--teal) 70%); -webkit-background-clip: text; background-clip: text; color: transparent; }
.brand small { display: block; font-size: 10.5px; font-weight: 650; letter-spacing: .09em; text-transform: uppercase; color: var(--text3); margin-top: 4px; }
.nav { display: grid; gap: 2px; }
.nav-h { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--text3); padding: 16px 12px 6px; }
.nav a { position: relative; display: flex; align-items: center; gap: 12px; height: 42px; padding: 0 12px; border-radius: 13px; color: var(--text2); font-weight: 600; font-size: 14.5px; text-decoration: none !important; transition: color .2s, background .2s; }
.nav a svg { width: 20px; height: 20px; flex: none; }
.nav a:hover { color: var(--text); background: var(--chip); }
.nav a[aria-current="page"] { color: var(--text); }
.nav a .badge { margin-left: auto; }
.nav-pill { position: absolute; left: 12px; right: 12px; height: 42px; top: 0; border-radius: 13px; background: var(--glass-hi); pointer-events: none;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .08), inset 0 0 0 1px var(--line), inset 0 1px 0 var(--glass-edge); transition: transform .6s var(--spring), opacity .2s; opacity: 0; }
.nav-wrap { position: relative; }
.nav a[aria-current="page"] svg { color: var(--accent-text); }
.side-foot { margin-top: auto; display: grid; gap: 8px; padding-top: 12px; }
.me { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 16px; background: var(--chip); border: 0; text-align: left; width: 100%; color: inherit; }
.me .grow > * { display: block; } .me .t { font-weight: 650; font-size: 14px; } .me .s { font-size: 12px; color: var(--text3); }

.main { min-width: 0; padding: 28px clamp(16px, 3vw, 40px) 60px; }
.page { max-width: 1180px; margin: 0 auto; display: grid; gap: 22px; grid-template-columns: minmax(0, 1fr); }
.ph { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding-top: 6px; }
.ph > .grow { flex: 1 1 300px; }
.ph .eyebrow svg { width: 15px; height: 15px; }
.ph .eyebrow { font-size: 13px; font-weight: 650; color: var(--accent-text); margin-bottom: 6px; display: flex; align-items: center; gap: 6px; }
.ph p { color: var(--text2); margin-top: 6px; }
.back { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; font-size: 14px; color: var(--text2); margin-bottom: 4px; }
.back svg { width: 16px; height: 16px; }
.cols { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 22px; align-items: start; }
.cols2 { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; align-items: start; }
@media (max-width: 1060px) { .cols { grid-template-columns: 1fr; } }
@media (max-width: 860px) { .cols2 { grid-template-columns: 1fr; } }

.topbar, .tabbar { display: none; }
.viewing { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 16px; font-size: 13.5px; font-weight: 600; }

/* ---------- phones: top bar + bottom tab bar ---------- */
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .side { display: none; }
  .main { padding: calc(64px + var(--sat)) 16px calc(100px + var(--sab)); }
  .page { gap: 18px; }
  .topbar { display: flex; position: fixed; z-index: 40; left: 0; right: 0; top: 0; height: calc(56px + var(--sat)); padding: var(--sat) 14px 0; align-items: center; gap: 10px;
    background: color-mix(in srgb, var(--glass2) 70%, transparent); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); box-shadow: inset 0 -1px 0 var(--line); }
  .topbar .brand { padding: 0; } .topbar .brand .mark { width: 30px; height: 30px; } .topbar .wordmark { font-size: 19px; }
  .topbar .end { margin-left: auto; display: flex; gap: 6px; align-items: center; }
  .tabbar.glass { background: var(--glass2); -webkit-backdrop-filter: blur(30px) saturate(2); backdrop-filter: blur(30px) saturate(2); box-shadow: var(--shadow-lg), inset 0 0 0 1px var(--line2), inset 0 1px 0 var(--glass-edge); }
  .li .t.ellipsis { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  .tabbar { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; position: fixed; z-index: 40; left: 10px; right: 10px; bottom: calc(10px + var(--sab)); height: 64px; padding: 6px; border-radius: 24px; }
  .tabbar a, .tabbar button { position: relative; z-index: 1; display: grid; justify-items: center; align-content: center; gap: 3px; border: 0; background: none; border-radius: 18px; color: var(--text3); font-size: 10.5px; font-weight: 650; text-decoration: none !important; transition: color .2s, transform .4s var(--spring); }
  .tabbar a:active, .tabbar button:active { transform: scale(.9); }
  .tabbar svg { width: 23px; height: 23px; }
  .tabbar [aria-current="page"] { color: var(--accent-text); }
  .tabbar .badge { position: absolute; top: 3px; left: calc(50% + 6px); min-width: 17px; height: 17px; font-size: 10px; }
  .tab-pill { position: absolute; z-index: 0; top: 6px; bottom: 6px; left: 0; border-radius: 18px; background: var(--chip); box-shadow: inset 0 0 0 1px var(--line); transition: transform .6s var(--spring); }
  .ph { align-items: flex-start; }
  .card { padding: 18px; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .tile { padding: 14px; } .tile .v { font-size: 25px; }
  .hide-m { display: none !important; }
}
@media (min-width: 861px) { .hide-d { display: none !important; } }

/* ---------- auth screens ---------- */
.auth { min-height: 100dvh; display: grid; place-items: center; padding: calc(24px + var(--sat)) 16px calc(24px + var(--sab)); }
.auth-card { width: min(440px, 100%); padding: 36px 32px 30px; border-radius: 30px; text-align: center; }
.auth-card .mark { width: 64px; height: 64px; margin: 0 auto 18px; filter: drop-shadow(0 10px 22px rgba(18, 140, 74, .35)); animation: float 6s ease-in-out infinite; }
@keyframes float { 50% { transform: translateY(-5px) rotate(-2deg); } }
.auth-card h1 { font-size: 28px; }
.auth-card .lead { color: var(--text2); margin: 10px auto 26px; max-width: 330px; }
.auth-card form { display: grid; gap: 12px; text-align: left; }
.auth-foot { margin-top: 22px; font-size: 13px; color: var(--text3); }
.auth .wordmark { font-size: 15px; }
.auth-brand { position: fixed; top: calc(20px + var(--sat)); left: 24px; display: flex; gap: 8px; align-items: center; }
.auth-brand .mark { width: 26px; height: 26px; }
.env-art { width: 96px; height: 96px; margin: 0 auto 18px; display: grid; place-items: center; border-radius: 30px; color: var(--accent-text);
  background: radial-gradient(circle at 30% 25%, rgba(255, 255, 255, .8), transparent 60%), linear-gradient(140deg, var(--green-bg), var(--chip)); box-shadow: inset 0 0 0 1px var(--line), inset 0 1px 0 var(--glass-edge), var(--shadow); }
.env-art svg { width: 46px; height: 46px; animation: env 2.6s var(--spring-soft) infinite; }
@keyframes env { 0%, 60%, 100% { transform: none; } 30% { transform: translateY(-4px) rotate(-6deg); } }
.env-art.warn { color: var(--amber); } .env-art.warn svg { animation: none; }
.devlink { margin-top: 18px; padding: 12px; border-radius: 14px; background: var(--amber-bg); font-size: 13px; text-align: left; }
.devlink b { color: var(--amber); }

/* ---------- charts ---------- */
.chart { position: relative; width: 100%; }
.chart svg { width: 100%; height: auto; overflow: visible; }
.chart .gl { stroke: var(--grid); stroke-width: 1; }
.chart .ax { fill: var(--text3); font-size: 11px; font-family: var(--font); }
.chart .ln { fill: none; stroke: var(--chart1); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.chart .ln2 { fill: none; stroke: var(--chart2); stroke-width: 2; stroke-dasharray: 4 5; stroke-linecap: round; opacity: .9; }
.chart .draw { stroke-dasharray: var(--len); stroke-dashoffset: var(--len); animation: draw 1.4s var(--spring-soft) .1s forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
.chart .ar { animation: fade 1s var(--ease) .3s both; }
.chart .cross { stroke: var(--text3); stroke-width: 1; stroke-dasharray: 3 3; opacity: 0; transition: opacity .15s; }
.chart .hdot { fill: var(--chart1); stroke: var(--glass-hi); stroke-width: 3; opacity: 0; transition: opacity .15s; }
.chart .bar-r { fill: var(--chart1); transition: opacity .2s; }
.tip { position: absolute; z-index: 5; pointer-events: none; padding: 9px 12px; border-radius: 13px; font-size: 12.5px; white-space: nowrap; background: var(--glass2); opacity: 0;
  -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); box-shadow: var(--shadow-lg), inset 0 0 0 1px var(--line2); transition: opacity .15s, transform .25s var(--spring); transform: translate(-50%, -110%); }
.tip b { display: block; font-size: 14px; } .tip .muted { font-size: 11.5px; }
.legend { display: flex; gap: 16px; font-size: 12.5px; color: var(--text2); font-weight: 600; flex-wrap: wrap; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.blist { display: grid; gap: 4px; grid-template-columns: minmax(0, 1fr); }
.brow { position: relative; display: flex; align-items: center; gap: 10px; height: 36px; padding: 0 12px; border-radius: 10px; font-size: 14px; overflow: hidden; }
.brow > i { position: absolute; inset: 0; right: auto; width: var(--w); border-radius: 10px; background: linear-gradient(90deg, var(--green-bg), color-mix(in srgb, var(--green-bg) 40%, transparent)); transform-origin: left; animation: grow .9s var(--spring-soft) both; animation-delay: calc(var(--i) * 40ms); }
.brow span { position: relative; } .brow .n { margin-left: auto; font-weight: 650; font-variant-numeric: tabular-nums; }
.funnel { display: grid; gap: 10px; grid-template-columns: minmax(0, 1fr); }
.fstep { display: grid; grid-template-columns: minmax(110px, 170px) 1fr auto; gap: 12px; align-items: center; font-size: 14px; }
.fstep .fb { height: 30px; border-radius: 9px; background: var(--chip); overflow: hidden; }
.fstep .fb i { display: block; height: 100%; width: var(--w); border-radius: 9px; background: linear-gradient(90deg, var(--g500), var(--teal)); transform-origin: left; animation: grow 1s var(--spring-soft) both; animation-delay: calc(var(--i) * 70ms); }
.fstep .fv { font-weight: 700; font-variant-numeric: tabular-nums; min-width: 92px; text-align: right; }
.fstep .fv small { display: block; font-weight: 600; color: var(--text3); font-size: 11.5px; }
@media (max-width: 520px) { .fstep { grid-template-columns: 1fr auto; } .fstep .fb { grid-column: 1 / -1; grid-row: 2; height: 22px; } }
.donut-wrap { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; }
.donut { width: 140px; height: 140px; flex: none; }
.donut circle { fill: none; stroke-width: 16; transition: stroke-dasharray 1.1s var(--spring-soft); }

/* ---------- timeline ---------- */
.tl { position: relative; display: grid; gap: 4px; padding-left: 26px; }
.tl::before { content: ""; position: absolute; left: 8px; top: 8px; bottom: 8px; width: 2px; border-radius: 2px; background: linear-gradient(var(--g400), var(--line2)); }
.tl-i { position: relative; padding: 10px 0; }
.tl-i::before { content: ""; position: absolute; left: -24px; top: 15px; width: 14px; height: 14px; border-radius: 50%; background: var(--glass-hi); box-shadow: inset 0 0 0 2.5px var(--g500); }
.tl-i.new::before { background: var(--g500); box-shadow: 0 0 0 4px var(--green-bg); }
.tl-i .when { font-size: 12.5px; color: var(--text3); }
.ms { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-top: 1px solid var(--line); }
.ms:first-child { border-top: 0; }
.ms .tick { width: 24px; height: 24px; flex: none; border-radius: 50%; display: grid; place-items: center; box-shadow: inset 0 0 0 2px var(--line2); color: transparent; border: 0; background: none; padding: 0; transition: background .3s, box-shadow .3s, transform .45s var(--spring); }
.ms .tick svg { width: 14px; height: 14px; }
.ms.done .tick { background: var(--g500); box-shadow: none; color: #fff; }
.ms.done .t { color: var(--text2); text-decoration: line-through; text-decoration-color: var(--line2); }
button.tick:active { transform: scale(.85); }
.steps { display: flex; gap: 6px; }
.steps i { flex: 1; height: 6px; border-radius: 9px; background: var(--chip); }
.steps i.on { background: linear-gradient(90deg, var(--g500), var(--teal)); }
.steps-l { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--text3); font-weight: 600; margin-top: 6px; }
.steps-l .on { color: var(--accent-text); }

/* ---------- message thread ---------- */
.thread { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); }
.msg { display: flex; gap: 10px; align-items: flex-end; max-width: 86%; animation: rise .5s var(--spring-soft) both; }
.msg.mine { margin-left: auto; flex-direction: row-reverse; }
.bubble { padding: 11px 15px; border-radius: 20px 20px 20px 6px; background: var(--glass2); box-shadow: inset 0 0 0 1px var(--line), var(--shadow); white-space: pre-wrap; word-break: break-word; }
.msg.mine .bubble { border-radius: 20px 20px 6px 20px; background: linear-gradient(180deg, #24b463, #119049); color: #fff; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .3), 0 6px 16px -8px rgba(18, 140, 74, .7); }
.msg .meta { font-size: 11.5px; color: var(--text3); margin: 0 6px 4px; }
.msg.mine .meta { text-align: right; }
.newline { display: flex; align-items: center; gap: 10px; font-size: 12px; font-weight: 700; color: #ef4136; }
.newline::before, .newline::after { content: ""; flex: 1; height: 1px; background: rgba(239, 65, 54, .35); }
.composer { position: sticky; bottom: 12px; display: flex; gap: 10px; align-items: flex-end; padding: 10px; border-radius: 22px; }
.composer.glass { background: var(--glass2); box-shadow: var(--shadow-lg), inset 0 0 0 1px var(--line2), inset 0 1px 0 var(--glass-edge); }
.composer textarea { min-height: 44px; max-height: 200px; resize: none; }
@media (max-width: 860px) { .composer { bottom: calc(84px + var(--sab)); } .msg { max-width: 94%; } }
.files { display: flex; flex-wrap: wrap; gap: 8px; }
.file { display: inline-flex; align-items: center; gap: 8px; max-width: 100%; padding: 7px 12px 7px 8px; border-radius: 12px; background: var(--chip); font-size: 13px; font-weight: 600; color: var(--text); text-decoration: none !important; box-shadow: inset 0 0 0 1px var(--line); }
.file svg { width: 18px; height: 18px; color: var(--accent-text); flex: none; }
.file img { width: 34px; height: 34px; border-radius: 8px; object-fit: cover; }
.msg.mine .file { background: rgba(255, 255, 255, .18); color: #fff; } .msg.mine .file svg { color: #fff; }

/* ---------- invoice paper ---------- */
.paper { padding: clamp(22px, 4vw, 44px); border-radius: 26px; }
.paper .top { display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap; }
.paper .big { font: 750 clamp(30px, 5vw, 42px)/1 var(--font-d); letter-spacing: -.035em; font-variant-numeric: tabular-nums; }
.paper .items { margin-top: 26px; }
.paper .tot { display: grid; justify-content: end; gap: 6px; margin-top: 14px; font-variant-numeric: tabular-nums; }
.paper .tot div { display: flex; gap: 40px; justify-content: space-between; } .paper .tot .grand { font-size: 18px; font-weight: 750; padding-top: 8px; border-top: 1px solid var(--line2); }
.pay { display: grid; gap: 14px; }
.method { padding: 18px; border-radius: 18px; background: var(--chip); box-shadow: inset 0 0 0 1px var(--line); }
.method dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 12px 0 0; font-size: 14px; }
.method dt { color: var(--text3); font-weight: 600; } .method dd { margin: 0; font-weight: 600; word-break: break-all; display: flex; align-items: center; gap: 6px; }
.copy { border: 0; background: none; padding: 2px; color: var(--accent-text); border-radius: 6px; } .copy svg { width: 15px; height: 15px; }
.paid-stamp { display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 12px; font-weight: 750; color: var(--accent-text); background: var(--green-bg); }
.paid-stamp svg { width: 18px; height: 18px; }
.items-edit .ie { display: grid; grid-template-columns: 1fr 80px 120px 36px; gap: 8px; align-items: center; margin-bottom: 8px; }
@media (max-width: 640px) { .items-edit .ie { grid-template-columns: 1fr 64px 96px 34px; } }

/* ---------- iOS add-to-home hint ---------- */
.a2hs { position: fixed; z-index: 60; left: 12px; right: 12px; bottom: calc(86px + var(--sab)); padding: 14px 16px; display: flex; gap: 12px; align-items: center; border-radius: 20px; animation: rise .7s var(--spring) both; }
.a2hs .mark { width: 40px; height: 40px; flex: none; }
.a2hs .share { display: inline-block; width: 16px; height: 16px; vertical-align: -3px; color: var(--blue); }
.auth ~ .a2hs, .a2hs.top { bottom: calc(16px + var(--sab)); }

/* ---------- print (invoice) ---------- */
@media print {
  @page { margin: 14mm; }
  :root { --text: #000; --text2: #333; --text3: #555; --line: #ddd; --line2: #bbb; --chip: #f3f5f4; --accent-text: #0b6b39; }
  body, html { background: #fff !important; }
  .bg, .side, .topbar, .tabbar, .toasts, .a2hs, .no-print, .viewing { display: none !important; }
  .app { display: block; } .main { padding: 0; } .page { max-width: none; }
  .glass { background: #fff !important; box-shadow: none !important; -webkit-backdrop-filter: none !important; backdrop-filter: none !important; }
  .glass::before { display: none; }
  .paper { padding: 0; } .cols { display: block; } .pay .method { break-inside: avoid; margin-top: 18px; }
  .chip { border: 1px solid #ccc; }
}
