/* ============================================================================
   tokenio beta — app stylesheet
   ----------------------------------------------------------------------------
   Loads AFTER assets/tokens.css (canonical brand tokens). The beta client uses
   the light, warm, phone-sized visual language of site/demo.html, so this file
   re-maps the surface/text/line/status tokens to the light ramp while keeping
   the brand anchors (--sun / --sky / gradients / on-colors) from tokens.css.
   Motion follows design/MOTION_SPEC.md: everything settles, nothing snaps.
   ============================================================================ */

:root {
  /* Light surface remap (demo palette) */
  --ink: #17181F;
  --ink-2: #5f6672;
  --ink-3: #9aa0aa;
  --bg: #FBF7EE;
  --bg-2: #F2ECDD;
  --card: #FFFFFF;
  --card-2: #FCFAF4;
  --line: rgba(20, 22, 30, .08);
  --line-2: rgba(20, 22, 30, .14);
  --navy: #122234;
  --good: #12b981;
  --bad: #e5533c;
  --warn: #b7791f;
  --shadow: 0 12px 30px -14px rgba(20, 22, 30, .28);

  /* Motion tokens (design/MOTION_SPEC.md) */
  --tk-ease-settle: cubic-bezier(0.22, 1, 0.36, 1);
  --tk-ease-expo: cubic-bezier(0.16, 1, 0.3, 1);
  --tk-ease-soft: cubic-bezier(0.4, 0, 0.2, 1);
  --tk-ease-breath: cubic-bezier(0.37, 0, 0.63, 1);
  --tk-dur-fast: 180ms;
  --tk-dur-base: 420ms;
  --tk-dur-hop: 640ms;
  --tk-dur-settle: 900ms;
  --tk-dur-spin: 1600ms;
  --tk-dur-loop: 4200ms;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

.phone {
  max-width: 440px;
  margin: 0 auto;
  min-height: 100vh;
  position: relative;
  padding-bottom: 96px;
  background:
    radial-gradient(600px 300px at 100% -8%, rgba(63, 183, 242, .10), transparent 60%),
    radial-gradient(500px 260px at -10% 104%, rgba(255, 203, 45, .14), transparent 55%),
    var(--bg);
}
@media (min-width: 520px) {
  .phone { border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
}

.ico { display: inline-flex; align-items: center; justify-content: center; vertical-align: -.16em; line-height: 0; }
.ico svg { width: 1.15em; height: 1.15em; display: block; }

/* ── Header ─────────────────────────────────────────────────────── */
.head { display: flex; align-items: center; gap: 11px; padding: 18px 20px 6px; }
.badge { width: 38px; height: 38px; border-radius: 12px; background: var(--navy); display: flex; align-items: center; justify-content: center; flex: 0 0 auto; }
.badge .mark { width: 26px; height: 26px; }
.brand { font-size: 17px; font-weight: 800; letter-spacing: -.02em; }
.brand .io { color: var(--sky-deep); }
.userbox { margin-left: auto; display: flex; align-items: center; gap: 8px; min-width: 0; }
.username {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11.5px; font-weight: 700; color: var(--sky-deep);
  background: rgba(63, 183, 242, .12); border: 1px solid rgba(63, 183, 242, .3);
  border-radius: 999px; padding: 6px 12px; max-width: 160px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.username .ico svg { width: 14px; height: 14px; }
.logoutbtn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 10px; border: 1px solid var(--line-2);
  background: var(--card-2); color: var(--ink-2); cursor: pointer;
  transition: background var(--tk-dur-fast) var(--tk-ease-soft), transform var(--tk-dur-fast) var(--tk-ease-soft);
}
.logoutbtn:hover { background: var(--bg-2); }
.logoutbtn:active { transform: translateY(1px); }
.logoutbtn .ico svg { width: 16px; height: 16px; }
.sim { padding: 2px 20px 0; font-size: 10.5px; color: var(--ink-3); }

/* ── Page shell ─────────────────────────────────────────────────── */
.page { padding: 14px 20px 0; animation: pin var(--tk-dur-base) var(--tk-ease-settle); }
@keyframes pin { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.heroblk { text-align: center; padding: 16px 0 6px; }
.heroblk .lbl { font-size: 12px; font-weight: 600; color: var(--ink-2); }
.heroblk .amt { font-size: 40px; font-weight: 800; letter-spacing: -.03em; line-height: 1; margin-top: 6px; }
.heroblk .sub { font-size: 12px; color: var(--ink-3); margin-top: 8px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 18px; box-shadow: var(--shadow); margin-bottom: 14px; }
.card h3 { margin: 0 0 12px; font-size: 13px; font-weight: 750; display: flex; align-items: center; gap: 7px; }
.card h3 .ico { color: var(--ink-3); }
.card h3 .ico svg { width: 16px; height: 16px; }
.muted { color: var(--ink-2); }
.tiny { font-size: 11.5px; color: var(--ink-3); line-height: 1.5; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: .92em; letter-spacing: 0; word-break: break-all; }

.agentcard { background: linear-gradient(135deg, #16324c, #0f2233); color: #fff; border: 0; }
.agentcard h3 { color: rgba(255, 255, 255, .9); }
.agentcard h3 .ico { color: var(--sun); }
.agentcard .say { font-size: 14.5px; line-height: 1.55; color: #eaf1f6; }
.agentcard .say b { color: #fff; }
.agentcard .em { color: var(--sun); }

/* ── Forms / buttons ────────────────────────────────────────────── */
input, select {
  font: inherit; font-size: 15px; color: var(--ink); background: var(--card-2);
  border: 1px solid var(--line-2); border-radius: 12px; padding: 12px 13px;
  outline: none; width: 100%;
  transition: border-color var(--tk-dur-fast) var(--tk-ease-soft);
}
input:focus { border-color: var(--sky); }
input.invalid { border-color: var(--bad); }
label.fl { display: block; font-size: 11.5px; font-weight: 700; color: var(--ink-2); margin: 12px 0 5px; }
.fielderr { font-size: 11px; color: var(--bad); margin-top: 4px; min-height: 0; }
.row { display: flex; gap: 9px; align-items: flex-end; }
.field { flex: 1; min-width: 0; }

.btn {
  font-size: 14px; font-weight: 750; border-radius: 13px; padding: 12px 16px; cursor: pointer;
  border: 1px solid transparent; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 7px; justify-content: center;
  transition: transform var(--tk-dur-fast) var(--tk-ease-soft), background var(--tk-dur-fast) var(--tk-ease-soft), opacity var(--tk-dur-fast) var(--tk-ease-soft);
}
.btn .ico svg { width: 16px; height: 16px; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn.pri { background: var(--sun); color: var(--on-sun, #2a2000); }
.btn.pri:hover:not(:disabled) { background: var(--sun-deep); }
.btn.dark { background: var(--navy); color: #fff; }
.btn.dark:hover:not(:disabled) { opacity: .92; }
.btn.sky { background: var(--sky); color: var(--on-sky, #06263a); }
.btn.sky:hover:not(:disabled) { background: var(--sky-deep); }
.btn.ghost { background: var(--card-2); color: var(--ink); border-color: var(--line-2); }
.btn.sm { padding: 9px 12px; font-size: 12.5px; border-radius: 11px; }
.btn.block { width: 100%; }
.btn.busy { pointer-events: none; opacity: .7; }

/* ── Lists / chips / bars ───────────────────────────────────────── */
.listitem { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 11px 0; border-top: 1px solid var(--line); font-size: 13px; }
.listitem:first-of-type { border-top: 0; }
.listitem .a { font-weight: 750; white-space: nowrap; text-align: right; }
.catico { width: 36px; height: 36px; border-radius: 11px; display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; }
.catico svg { width: 19px; height: 19px; }
.lead { display: flex; align-items: center; gap: 11px; min-width: 0; }
.lead .t { min-width: 0; }
.lead .t b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pill { display: inline-flex; align-items: center; gap: 4px; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; padding: 2px 8px; border-radius: 999px; }
.pill.good { background: rgba(18, 185, 129, .14); color: var(--good); }
.pill.sky { background: rgba(63, 183, 242, .16); color: var(--sky-deep); }
.pill.off { background: var(--bg-2); color: var(--ink-3); }
.pill.bad { background: rgba(229, 83, 60, .12); color: var(--bad); }
.bar { height: 8px; border-radius: 6px; background: var(--bg-2); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--grad-brand); transition: width var(--tk-dur-base) var(--tk-ease-settle); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 2px; }
.chip { font-size: 11.5px; font-weight: 600; padding: 5px 10px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--card-2); color: var(--ink-2); }

.sumline { display: flex; justify-content: space-between; align-items: center; font-size: 13px; padding: 7px 0; border-top: 1px solid var(--line); gap: 10px; }
.sumline:first-of-type { border-top: 0; }
.sumline.tot { font-weight: 800; border-top: 2px solid var(--line-2); margin-top: 2px; }

.statgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { background: var(--card-2); border: 1px solid var(--line); border-radius: 12px; padding: 11px 12px; }
.stat .v { font-size: 18px; font-weight: 800; }

/* ── Sliders ────────────────────────────────────────────────────── */
input[type="range"] { -webkit-appearance: none; appearance: none; background: transparent; border: 0; padding: 8px 0; accent-color: var(--sun); }
input[type="range"]::-webkit-slider-runnable-track { height: 8px; border-radius: 6px; background: var(--bg-2); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 20px; height: 20px; margin-top: -6px; border-radius: 50%;
  background: var(--sun); border: 2.5px solid #fff; box-shadow: 0 2px 8px rgba(20, 22, 30, .25); cursor: pointer;
}
input[type="range"]::-moz-range-track { height: 8px; border-radius: 6px; background: var(--bg-2); }
input[type="range"]::-moz-range-thumb { width: 15px; height: 15px; border-radius: 50%; background: var(--sun); border: 2.5px solid #fff; box-shadow: 0 2px 8px rgba(20, 22, 30, .25); cursor: pointer; }

.allocrow { padding: 12px 0 4px; border-top: 1px solid var(--line); }
.allocrow:first-of-type { border-top: 0; }
.alloctop { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 13px; }
.allocpct { font-weight: 800; min-width: 44px; text-align: right; }
.meter { display: flex; justify-content: space-between; font-size: 12px; font-weight: 600; margin-bottom: 6px; }
.meter .over { color: var(--bad); }

/* ── Nav ────────────────────────────────────────────────────────── */
.nav {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 0; width: 100%; max-width: 440px;
  background: rgba(251, 247, 238, .9); backdrop-filter: blur(12px); border-top: 1px solid var(--line);
  display: flex; padding: 10px 20px calc(10px + env(safe-area-inset-bottom)); gap: 10px; z-index: 20;
}
.navbtn { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; background: none; border: 0; cursor: pointer; color: var(--ink-3); font-size: 11.5px; font-weight: 700; padding: 6px 0; border-radius: 12px; transition: color var(--tk-dur-fast) var(--tk-ease-soft); }
.navbtn .ico svg { width: 22px; height: 22px; }
.navbtn.on { color: var(--ink); }
.nav[hidden] { display: none; }

/* ── Auth screen ────────────────────────────────────────────────── */
.authwrap { padding: 8vh 20px 40px; animation: pin var(--tk-dur-base) var(--tk-ease-settle); }
.authcard { background: var(--card); border: 1px solid var(--line); border-radius: 22px; padding: 24px 22px; box-shadow: var(--shadow); }
.authtoggle { display: flex; background: var(--bg-2); border-radius: 12px; padding: 4px; margin: 16px 0 4px; }
.authtoggle button { flex: 1; border: 0; background: transparent; font: inherit; font-size: 13px; font-weight: 750; padding: 9px 0; border-radius: 9px; color: var(--ink-2); cursor: pointer; transition: background var(--tk-dur-fast) var(--tk-ease-soft), color var(--tk-dur-fast) var(--tk-ease-soft); }
.authtoggle button.on { background: var(--card); color: var(--ink); box-shadow: 0 2px 8px rgba(20, 22, 30, .10); }

/* ── Banners / states ───────────────────────────────────────────── */
.errbanner { display: flex; align-items: flex-start; gap: 8px; background: rgba(229, 83, 60, .10); border: 1px solid rgba(229, 83, 60, .3); color: #a33a28; border-radius: 12px; padding: 10px 12px; font-size: 12.5px; line-height: 1.45; margin: 10px 0; animation: pin var(--tk-dur-fast) var(--tk-ease-settle); }
.errbanner .ico { color: var(--bad); margin-top: 1px; }
.okbanner { background: rgba(18, 185, 129, .10); border: 1px solid rgba(18, 185, 129, .3); color: #0e7a5b; border-radius: 12px; padding: 10px 12px; font-size: 12.5px; line-height: 1.45; margin: 10px 0; animation: pin var(--tk-dur-fast) var(--tk-ease-settle); }
.winbanner { background: linear-gradient(135deg, rgba(255, 203, 45, .25), rgba(63, 183, 242, .18)); border: 1px solid rgba(244, 169, 22, .45); border-radius: 14px; padding: 14px; font-size: 14px; font-weight: 750; text-align: center; margin: 10px 0; animation: pin var(--tk-dur-settle) var(--tk-ease-settle); }

.emptystate { text-align: center; padding: 26px 14px; }
.emptystate .catico { width: 46px; height: 46px; margin: 0 auto 10px; background: var(--bg-2); color: var(--ink-2); }
.emptystate .catico svg { width: 23px; height: 23px; }
.emptystate b { display: block; font-size: 14.5px; margin-bottom: 4px; }

.loading { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 34px 0; color: var(--ink-3); font-size: 12.5px; font-weight: 600; }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid var(--bg-2); border-top-color: var(--sky); animation: spin var(--tk-dur-spin) linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Toasts ─────────────────────────────────────────────────────── */
#toasts { position: fixed; bottom: 104px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 50; align-items: center; width: 100%; max-width: 420px; padding: 0 16px; pointer-events: none; }
.toast { background: var(--navy); color: #fff; border-radius: 14px; padding: 12px 16px; font-size: 13.5px; box-shadow: 0 16px 40px -16px rgba(0, 0, 0, .5); animation: tin var(--tk-dur-base) var(--tk-ease-settle); width: 100%; }
.toast .em { font-weight: 800; color: var(--sun); }
.toast.good { background: #0e7a5b; }
.toast.good .em { color: #d3ffe9; }
.toast.bad { background: #b23a26; }
@keyframes tin { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* ── Animated logo (canonical 4200ms loop, from the demo) ───────── */
.tk-anim-logo { display: block; }
.tk-anim-logo svg { width: 100%; height: 100%; overflow: visible; }
.tk-anim-logo .tk-stem-top { stroke: var(--sun); stroke-width: 4.4; stroke-linecap: round; fill: none; stroke-dasharray: 12.5; stroke-dashoffset: 12.5; animation: tk-stemGrow var(--tk-dur-loop) ease-in-out infinite; }
.tk-anim-logo .tk-stem-lower { stroke: var(--sun); stroke-width: 4.4; stroke-linecap: round; fill: none; }
.tk-anim-logo .tk-crossbar { stroke: var(--sun); stroke-width: 4.4; stroke-linecap: round; transform-box: fill-box; transform-origin: 50% 50%; animation: tk-crossbarSquash var(--tk-dur-loop) ease-in-out infinite; }
.tk-anim-logo .tk-dot { fill: var(--sky); transform-box: fill-box; transform-origin: 50% 50%; animation: tk-dotMove var(--tk-dur-loop) ease-in-out infinite; }
.tk-anim-logo .tk-dot-shadow { fill: #000; opacity: 0; transform-box: fill-box; transform-origin: 50% 50%; animation: tk-shadowPulse var(--tk-dur-loop) ease-in-out infinite; }
@keyframes tk-dotMove { 0%, 14% { transform: translateY(0) scale(1, 1); } 22% { transform: translateY(-6px) scale(.97, 1.04); } 30% { transform: translateY(0) scale(1.03, .97); } 32% { transform: translateY(0) scale(1, 1); } 49% { transform: translateY(4.5px) scale(.99, 1.02); } 63% { transform: translateY(9px) scale(1.03, .98); } 66%, 88% { transform: translateY(9px) scale(1, 1); } 95% { transform: translateY(1.5px) scale(1.01, .99); } 100% { transform: translateY(0) scale(1, 1); } }
@keyframes tk-shadowPulse { 0%, 14% { opacity: .26; } 30% { opacity: .3; transform: scale(1.12, .72); } 32% { opacity: .26; } 63% { opacity: .3; transform: translateY(9px) scale(1.16, .6); } 66%, 88% { opacity: 0; transform: translateY(9px); } 100% { opacity: .26; } }
@keyframes tk-crossbarSquash { 0%, 14%, 32% { transform: scale(1, 1); } 30% { transform: scale(1.02, .95); } 63% { transform: scale(1.05, .92); } 68%, 88% { transform: scale(1, 1); } 100% { transform: scale(1, 1); } }
@keyframes tk-stemGrow { 0%, 32% { stroke-dashoffset: 12.5; } 49% { stroke-dashoffset: 6.5; } 64% { stroke-dashoffset: 0; } 88% { stroke-dashoffset: 0; } 96% { stroke-dashoffset: 9; } 100% { stroke-dashoffset: 12.5; } }

@media (prefers-reduced-motion: reduce) {
  .tk-anim-logo * { animation: none !important; }
  .tk-anim-logo .tk-dot { transform: translateY(9px); }
  .tk-anim-logo .tk-stem-top { stroke-dashoffset: 0; }
  .page, .toast, .errbanner, .okbanner, .winbanner, .authwrap { animation: none !important; }
  .bar > i { transition: none !important; }
}
