/* Tappio UI kit v2 — shared by every generated app (/_kit.css).
   A native-feeling app design system. Theme with CSS variables: set --accent (and optionally
   --accent-2, --font, --font-display, --radius) in :root. Light and dark are both built in. */
@import url("https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap");
:root {
  --accent: #5b5bf0; --accent-2: color-mix(in srgb, var(--accent) 70%, #ff7a59); --accent-ink: #fff;
  --accent-soft: color-mix(in srgb, var(--accent) 12%, transparent); --accent-tint: color-mix(in srgb, var(--accent) 8%, var(--surface));
  --bg: #f4f5f8; --surface: #ffffff; --surface-2: #eef0f4; --surface-3: #e3e6ec; --ink: #0f1218; --muted: #667085; --line: #e6e8ee;
  --good: #12b76a; --warn: #f79009; --bad: #f04438; --info: #2e90fa;
  --radius: 18px; --radius-sm: 12px; --radius-lg: 26px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 6px 20px rgba(16, 24, 40, .06);
  --shadow-lg: 0 2px 6px rgba(16, 24, 40, .05), 0 24px 50px rgba(16, 24, 40, .12);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Plus Jakarta Sans", ui-sans-serif, system-ui, "Segoe UI", Roboto, sans-serif;
  --font-display: var(--font);
  --tabbar-h: 66px;
  --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);
  color-scheme: light;
}
/* Dark mode is opt-in: an app follows the phone's setting only with <html data-theme="auto">,
   so a custom palette is never half-overridden by the kit's dark tokens. */
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    --bg: #0b0d12; --surface: #151821; --surface-2: #1c202b; --surface-3: #262b38; --ink: #eef0f6; --muted: #98a2b3; --line: #252a36;
    --accent-tint: color-mix(in srgb, var(--accent) 14%, var(--surface));
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35); --shadow-lg: 0 24px 60px rgba(0, 0, 0, .55); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b0d12; --surface: #151821; --surface-2: #1c202b; --surface-3: #262b38; --ink: #eef0f6; --muted: #98a2b3; --line: #252a36;
  --accent-tint: color-mix(in srgb, var(--accent) 14%, var(--surface));
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35); --shadow-lg: 0 24px 60px rgba(0, 0, 0, .55); color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { width: 100%; max-width: 100%; min-height: 100%; margin: 0; overflow-x: hidden; overflow-x: clip; background: var(--bg); color: var(--ink); font: 500 15px/1.5 var(--font); -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
body { min-height: 100vh; min-height: 100dvh; }
a { color: var(--accent); text-decoration: none; }
img { max-width: 100%; display: block; }
svg.i { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
h1, h2, h3, .display { font-family: var(--font-display); line-height: 1.15; margin: 0 0 .4em; letter-spacing: -.02em; font-weight: 800; text-wrap: balance; }
h1 { font-size: 1.75rem; } h2 { font-size: 1.3rem; } h3 { font-size: 1.05rem; font-weight: 700; }
.large-title { font-family: var(--font-display); font-size: 2.1rem; font-weight: 800; letter-spacing: -.035em; line-height: 1.05; margin: 4px 0 2px; }
.eyebrow, .caption { font-size: .72rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); } .small { font-size: .85rem; } .center { text-align: center; }
::selection { background: var(--accent-soft); }

/* ---- layout ---- */
.app { max-width: 960px; margin: 0 auto; padding: 20px 16px 48px; }
.app.narrow { max-width: 560px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; } .row.between { justify-content: space-between; } .row.nowrap { flex-wrap: nowrap; }
.stack > * + * { margin-top: 12px; } .stack.tight > * + * { margin-top: 6px; } .stack.loose > * + * { margin-top: 20px; }
.spacer { flex: 1; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.scroll-x { display: flex; gap: 12px; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; margin: 0 -16px; padding: 2px 16px 6px; }
.scroll-x::-webkit-scrollbar { display: none; } .scroll-x > * { scroll-snap-align: start; flex: none; }

/* ---- app shell: app bar + screen + bottom tab bar (sidebar on desktop) ---- */
.shell { width: 100%; max-width: 100%; min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.appbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 10px; min-height: 56px; padding: calc(8px + var(--safe-t)) calc(16px + var(--safe-r)) 8px calc(16px + var(--safe-l));
  background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: saturate(1.6) blur(18px); -webkit-backdrop-filter: saturate(1.6) blur(18px); }
.appbar.line { border-bottom: 1px solid var(--line); }
.appbar .title { font-family: var(--font-display); font-weight: 800; font-size: 1.05rem; letter-spacing: -.01em; flex: 1; min-width: 0; overflow-wrap: anywhere; }
.screen { flex: 1; width: 100%; max-width: 720px; margin: 0 auto; padding: 8px calc(16px + var(--safe-r)) calc(var(--tabbar-h) + var(--safe-b) + 28px) calc(16px + var(--safe-l)); }
.screen.no-tabs { padding-bottom: 40px; }
.section-title { display: flex; align-items: baseline; justify-content: space-between; margin: 22px 2px 10px; font-family: var(--font-display); font-weight: 800; font-size: 1.1rem; letter-spacing: -.02em; }
.section-title a, .section-title button { font: 600 .85rem var(--font); color: var(--accent); background: none; border: 0; cursor: pointer; }
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; display: flex; justify-content: space-around; padding: 6px calc(8px + var(--safe-r)) calc(6px + var(--safe-b)) calc(8px + var(--safe-l));
  background: color-mix(in srgb, var(--surface) 86%, transparent); backdrop-filter: saturate(1.6) blur(20px); -webkit-backdrop-filter: saturate(1.6) blur(20px); border-top: 1px solid var(--line); }
.tabbar button, .tabbar a { appearance: none; flex: 1; max-width: 96px; display: grid; justify-items: center; gap: 3px; padding: 6px 4px; border: 0; background: none; color: var(--muted); font: 600 12px var(--font); cursor: pointer; border-radius: 12px; transition: color .15s; }
.tabbar svg.i { width: 23px; height: 23px; }
.tabbar .on { color: var(--accent); }
.tabbar .on svg.i { stroke-width: 2.4; }
@media (min-width: 900px) {
  .shell.has-tabs { padding-left: 232px; }
  .shell.has-tabs .tabbar { top: 0; right: auto; width: 232px; flex-direction: column; justify-content: flex-start; gap: 4px; padding: 24px 14px; border-top: 0; border-right: 1px solid var(--line); background: var(--surface); }
  .shell.has-tabs .tabbar button, .shell.has-tabs .tabbar a { max-width: none; flex: none; display: flex; align-items: center; gap: 12px; padding: 11px 14px; font-size: 14px; justify-items: start; }
  .shell.has-tabs .tabbar .on { background: var(--accent-soft); }
  .screen { max-width: 980px; padding-left: 32px; padding-right: 32px; }
  .shell.has-tabs .screen, .screen.no-tabs { padding-bottom: 48px; }
}
@media (max-width: 599px) {
  input, select, textarea { font-size: 16px !important; }
}
.tabbar > .brand { display: none !important; align-items: center; gap: 10px; padding: 0 8px 18px; font-family: var(--font-display); font-weight: 800; font-size: 1.05rem; }
@media (min-width: 900px) { .shell.has-tabs .tabbar > .brand { display: flex !important; } }

/* ---- surfaces ---- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.card.flat { box-shadow: none; } .card.tint { background: var(--accent-tint); border-color: transparent; box-shadow: none; }
.card + .card { margin-top: 12px; } .grid > .card, .row > .card, .scroll-x > .card { margin-top: 0; }
.hero-card { position: relative; overflow: hidden; border-radius: var(--radius-lg); padding: 20px; color: var(--accent-ink);
  background: radial-gradient(120% 90% at 100% 0%, color-mix(in srgb, var(--accent-2) 85%, transparent), transparent 60%), linear-gradient(140deg, var(--accent), color-mix(in srgb, var(--accent) 65%, #000)); box-shadow: 0 18px 40px color-mix(in srgb, var(--accent) 35%, transparent); }
.hero-card .muted, .hero-card .caption { color: color-mix(in srgb, var(--accent-ink) 75%, transparent); }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; display: grid; gap: 4px; }
.tile .v { font-family: var(--font-display); font-size: 1.5rem; font-weight: 800; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.tile .l { font-size: .78rem; color: var(--muted); font-weight: 600; }
.stat { font-family: var(--font-display); font-size: 1.8rem; font-weight: 800; letter-spacing: -.03em; font-variant-numeric: tabular-nums; } .stat-label { color: var(--muted); font-size: .85rem; }
.media { border-radius: var(--radius); overflow: hidden; background: var(--surface-2); aspect-ratio: 16 / 10; }

/* grouped list (iOS-style) */
.list-group { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.row-item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; min-height: 58px; background: none; border: 0; width: 100%; text-align: left; font: inherit; color: inherit; cursor: pointer; }
.list-group .row-item + .row-item { border-top: 1px solid var(--line); }
.row-item .body { flex: 1; min-width: 0; } .row-item .body b, .row-item .body strong { display: block; font-weight: 700; overflow-wrap: anywhere; }
.row-item .body span, .row-item .body small { display: block; color: var(--muted); font-size: .84rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-item .trail { color: var(--muted); font-weight: 600; font-size: .9rem; display: flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; }
.row-item:active { background: var(--surface-2); }
.ib { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; flex: none; background: var(--accent-soft); color: var(--accent); }
.ib.round { border-radius: 50%; } .ib.lg { width: 52px; height: 52px; border-radius: 16px; } .ib.sm { width: 32px; height: 32px; border-radius: 10px; }
.ib.good { background: color-mix(in srgb, var(--good) 14%, transparent); color: var(--good); } .ib.warn { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); }
.ib.bad { background: color-mix(in srgb, var(--bad) 14%, transparent); color: var(--bad); } .ib.info { background: color-mix(in srgb, var(--info) 14%, transparent); color: var(--info); }
.avatar { width: 40px; height: 40px; border-radius: 50%; flex: none; display: grid; place-items: center; font-weight: 800; font-size: .9rem; color: #fff; background: linear-gradient(135deg, var(--accent-2), var(--accent)); object-fit: cover; }
.avatar.sm { width: 30px; height: 30px; font-size: .75rem; } .avatar.lg { width: 64px; height: 64px; font-size: 1.3rem; }
.avatars { display: flex; } .avatars > * { margin-left: -8px; box-shadow: 0 0 0 2px var(--surface); } .avatars > :first-child { margin-left: 0; }

/* ---- controls ---- */
.btn { appearance: none; border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 14px; padding: 11px 16px; font: 700 .95rem var(--font); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; transition: transform .12s, filter .15s, background .15s; min-height: 44px; }
.btn:hover { background: var(--surface-2); } .btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); box-shadow: 0 8px 20px color-mix(in srgb, var(--accent) 30%, transparent); }
.btn.primary:hover { filter: brightness(1.06); background: var(--accent); }
.btn.soft { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.btn.danger { color: var(--bad); } .btn.ghost { border-color: transparent; background: transparent; }
.btn.block { width: 100%; } .btn.lg { min-height: 54px; font-size: 1.02rem; border-radius: 16px; }
.btn.sm { padding: 6px 12px; font-size: .84rem; min-height: 34px; border-radius: 11px; }
.btn.icon { width: 44px; padding: 0; } .btn.icon.sm { width: 34px; }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.fab { position: fixed; right: 18px; bottom: calc(var(--tabbar-h) + var(--safe-b) + 16px); z-index: 35; width: 58px; height: 58px; border-radius: 20px; border: 0; display: grid; place-items: center; background: var(--accent); color: var(--accent-ink); box-shadow: 0 14px 30px color-mix(in srgb, var(--accent) 45%, transparent); cursor: pointer; }
.fab svg.i { width: 26px; height: 26px; } .shell:not(.has-tabs) .fab { bottom: calc(20px + var(--safe-b)); }
.input, select.input, textarea.input { width: 100%; border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 14px; padding: 12px 14px; font: 500 1rem var(--font); min-height: 48px; transition: border-color .15s, box-shadow .15s; }
.input::placeholder { color: color-mix(in srgb, var(--muted) 75%, transparent); }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
textarea.input { resize: vertical; min-height: 96px; }
.search { position: relative; } .search .input { padding-left: 42px; background: var(--surface-2); border-color: transparent; } .search svg.i { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); }
label.field { display: block; } label.field > span { display: block; font-size: .82rem; font-weight: 700; margin-bottom: 6px; color: var(--muted); }
.seg { display: flex; background: var(--surface-2); border-radius: 13px; padding: 3px; gap: 2px; }
.seg button { appearance: none; flex: 1; border: 0; background: none; padding: 8px 10px; border-radius: 10px; font: 700 .85rem var(--font); color: var(--muted); cursor: pointer; white-space: nowrap; }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(16, 24, 40, .1); }
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; } .chips::-webkit-scrollbar { display: none; }
.chip { appearance: none; flex: none; display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 99px; padding: 8px 14px; font: 600 .86rem var(--font); cursor: pointer; white-space: nowrap; }
.chip.on { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.switch { appearance: none; position: relative; width: 50px; height: 30px; border-radius: 99px; background: var(--surface-3); cursor: pointer; transition: background .2s; flex: none; border: 0; margin: 0; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, .2); transition: transform .2s; }
.switch:checked { background: var(--good); } .switch:checked::after { transform: translateX(20px); }
.stepper { display: inline-flex; align-items: center; gap: 4px; background: var(--surface-2); border-radius: 12px; padding: 3px; }
.stepper button { width: 34px; height: 34px; border: 0; border-radius: 9px; background: var(--surface); color: var(--ink); font: 800 1.1rem var(--font); cursor: pointer; }
.stepper output, .stepper span { min-width: 30px; text-align: center; font-weight: 800; font-variant-numeric: tabular-nums; }

/* ---- status + data ---- */
.tag, .pill { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 99px; background: var(--surface-2); color: var(--ink); font-size: .76rem; font-weight: 700; white-space: nowrap; }
.tag.good, .pill.good { background: color-mix(in srgb, var(--good) 14%, transparent); color: var(--good); }
.tag.warn, .pill.warn { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); }
.tag.bad, .pill.bad { background: color-mix(in srgb, var(--bad) 14%, transparent); color: var(--bad); }
.tag.accent, .pill.accent { background: var(--accent-soft); color: var(--accent); }
.tag:empty { display: none; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); display: inline-block; flex: none; }
.progress { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; } .progress > i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .5s cubic-bezier(.2, .8, .2, 1); }
.ring { position: relative; display: inline-grid; place-items: center; } .ring svg { transform: rotate(-90deg); display: block; } .ring > .ring-label { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; line-height: 1.1; }
.list { list-style: none; margin: 0; padding: 0; }
.list > li, .item { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.list > li:last-child { border-bottom: 0; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; overflow-x: auto; scrollbar-width: none; }
.tabs button { appearance: none; background: none; border: 0; padding: 10px 12px; font: 700 .92rem var(--font); color: var(--muted); cursor: pointer; border-bottom: 2.5px solid transparent; white-space: nowrap; }
.tabs button.on { color: var(--ink); border-color: var(--accent); }
.empty { display: grid; justify-items: center; gap: 8px; text-align: center; color: var(--muted); padding: 36px 16px; }
.empty .ib { width: 56px; height: 56px; border-radius: 18px; margin-bottom: 4px; } .empty b, .empty strong { color: var(--ink); font-size: 1.02rem; }
table.table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
table.table th, table.table td { text-align: left; padding: 11px 10px; border-bottom: 1px solid var(--line); }
table.table th { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; }
.table-wrap { overflow-x: auto; }
.skeleton { border-radius: 10px; background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2)); background-size: 200% 100%; animation: k-shimmer 1.2s linear infinite; min-height: 14px; }
@keyframes k-shimmer { to { background-position: -200% 0; } }
.divider { height: 1px; background: var(--line); margin: 14px 0; border: 0; }
.sample-note { display: inline-flex; align-items: center; gap: 8px; padding: 5px 6px 5px 12px; border-radius: 99px; background: var(--surface-2); color: var(--muted); font-size: .76rem; font-weight: 600; margin: 4px 0 10px; }
.sample-note button { font-size: .74rem; padding: 3px 10px; min-height: 0; border-radius: 99px; }
.sample-note button { margin-left: auto; }

/* ---- overlays ---- */
.modal-bg { position: fixed; inset: 0; background: rgba(8, 10, 16, .45); backdrop-filter: blur(4px); display: grid; place-items: center; padding: 16px; z-index: 50; animation: k-fade .2s; }
.modal { background: var(--surface); border-radius: var(--radius-lg); padding: 22px; width: 100%; max-width: 460px; max-height: 90vh; overflow: auto; box-shadow: var(--shadow-lg); animation: k-pop .25s cubic-bezier(.2, .9, .3, 1.2); }
.modal-bg.sheet-bg { place-items: end center; padding: 0; }
.sheet { background: var(--surface); width: 100%; max-width: 560px; max-height: 88vh; overflow: auto; border-radius: 28px 28px 0 0; padding: 10px 18px calc(22px + var(--safe-b)); box-shadow: var(--shadow-lg); animation: k-up .3s cubic-bezier(.2, .9, .3, 1); }
.sheet::before { content: ""; display: block; width: 40px; height: 5px; border-radius: 99px; background: var(--surface-3); margin: 0 auto 14px; }
@media (min-width: 900px) { .modal-bg.sheet-bg { place-items: center; padding: 16px; } .sheet { border-radius: var(--radius-lg); } }
.toast { position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + var(--safe-b) + 16px); transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 12px 18px; border-radius: 14px; font-weight: 700; z-index: 60; box-shadow: var(--shadow-lg); animation: k-up .25s; max-width: min(92vw, 420px); width: max-content; text-align: center; overflow-wrap: anywhere; }
.fade-in { animation: k-fade .35s both; } .rise-in { animation: k-up .4s cubic-bezier(.2, .8, .2, 1) both; }
@keyframes k-fade { from { opacity: 0; } } @keyframes k-up { from { opacity: 0; transform: translate(var(--tx, 0), 14px); } } .toast { --tx: -50%; }
@keyframes k-pop { from { opacity: 0; transform: scale(.96); } }

/* legacy names kept for older apps and templates */
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.top .brand, .brand { display: flex; align-items: center; gap: 10px; font-family: var(--font-display); font-weight: 800; font-size: 1.15rem; letter-spacing: -.02em; }
/* Letter-mark tile: only for a text logo (e.g. "R"). A drawn mark (svg or image) keeps its own look. */
.logo:not(svg):not(img):not(:has(svg, img)) { width: 34px; height: 34px; border-radius: 11px; background: linear-gradient(135deg, var(--accent-2), var(--accent)); color: var(--accent-ink); display: grid; place-items: center; font-weight: 800; }
.pa-badge { position: fixed; right: 12px; bottom: calc(var(--safe-b) + 12px); background: #111; color: #fff; font: 700 12px/1 var(--font); padding: 8px 11px; border-radius: 99px; text-decoration: none; opacity: .9; z-index: 45; }
.shell.has-tabs ~ .pa-badge, .shell.has-tabs + .pa-badge { bottom: calc(var(--tabbar-h) + var(--safe-b) + 10px); }
@media (max-width: 600px) { .app { padding: 14px 14px 40px; } h1 { font-size: 1.5rem; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }
