:root {
  color-scheme: light;
  --bg: #f3f8f4;
  --surface: #ffffff;
  --surface-soft: #eef7f1;
  --ink: #14251d;
  --muted: #5d7066;
  --line: #ccddd3;
  --brand: #183629;
  --brand-2: #2f7551;
  --accent: #67d493;
  --accent-soft: #e5f8ec;
  --warning: #fff3d8;
  --danger: #fff0ee;
  --shadow: 0 14px 42px rgba(20, 53, 38, .10);
  --radius: 24px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1713;
  --surface: #17231d;
  --surface-soft: #1c2d24;
  --ink: #eef8f2;
  --muted: #a3b8ac;
  --line: #324a3d;
  --brand: #10271c;
  --brand-2: #286344;
  --accent: #71d99a;
  --accent-soft: #193726;
  --warning: #3a2e18;
  --danger: #3f2422;
  --shadow: 0 16px 46px rgba(0, 0, 0, .32);
}

* { box-sizing: border-box; }
html { min-width: 320px; min-height: 100%; background: var(--bg); -webkit-text-size-adjust: 100%; }
body {
  min-width: 320px;
  min-height: 100%;
  margin: 0;
  overflow-x: hidden;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 18% -8%, rgba(255,255,255,.92), transparent 34%),
    var(--bg);
  overscroll-behavior-y: none;
}
html[data-theme="dark"] body { background: radial-gradient(circle at 18% -8%, #263a30, transparent 34%), var(--bg); }
button, input, select, textarea { font: inherit; }
button, .btn, .puff, .tab, .trigger, .mini-refresh { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
a { color: var(--brand-2); }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid rgba(75, 198, 126, .42);
  outline-offset: 2px;
}

.app {
  width: 100%;
  max-width: 540px;
  min-height: 100svh;
  margin: 0 auto;
  padding: 18px max(14px, env(safe-area-inset-left)) calc(106px + var(--safe-bottom)) max(14px, env(safe-area-inset-right));
}
.top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 16px; }
.brand { display: flex; align-items: center; gap: 11px; min-width: 0; }
.brand > div:last-child { min-width: 0; }
.logo {
  display: grid; place-items: center; flex: 0 0 44px; width: 44px; height: 44px;
  border-radius: 15px; background: var(--brand); color: #fff; font-size: 24px; font-weight: 900;
  box-shadow: 0 9px 22px rgba(20, 53, 38, .16);
}
.brand b { display: block; font-size: 19px; line-height: 1.1; }
.brand span { display: block; max-width: 320px; overflow: hidden; color: var(--muted); font-size: 12px; white-space: nowrap; text-overflow: ellipsis; }
.pill {
  display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto;
  max-width: 104px; padding: 8px 11px; border: 1px solid var(--line); border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 88%, transparent); color: var(--ink); font-size: 12px; font-weight: 850; line-height: 1.05; white-space: nowrap;
}
.pro-pill { color: #fff; border-color: transparent; background: linear-gradient(160deg, #10251b, #2c6547); }
.wait-pill { color: #674514; border-color: #efd18c; background: #fff4db; }
.pro-soft { color: #18472d; border-color: #bde8cd; background: #edfff3; }

.hero, .card, .today { overflow: hidden; border-radius: var(--radius); }
.hero {
  position: relative; padding: 26px 20px; border: 1px solid var(--line);
  background: linear-gradient(150deg, var(--surface), var(--surface-soft)); box-shadow: var(--shadow);
}
.hero::after { content: ""; position: absolute; top: -65px; right: -65px; width: 190px; height: 190px; border-radius: 50%; background: rgba(103,212,147,.20); pointer-events: none; }
.h1 { position: relative; margin: 7px 0 12px; max-width: 410px; font-size: clamp(32px, 9vw, 41px); font-weight: 900; line-height: .98; letter-spacing: -1.7px; }
.lead { position: relative; margin: 0; color: #405249; font-size: 16px; line-height: 1.48; }
html[data-theme="dark"] .lead { color: var(--muted); }

.card {
  margin-top: 14px; padding: 19px; border: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 96%, transparent); box-shadow: var(--shadow);
}
.card h2, .card h3, .today h2 { overflow-wrap: anywhere; }
.card h2 { margin: 0 0 11px; font-size: 23px; line-height: 1.12; letter-spacing: -.45px; }
.card h3 { margin: 0 0 10px; font-size: 17px; line-height: 1.25; }
.card p:first-child { margin-top: 0; }
.muted { color: var(--muted); font-size: 13px; line-height: 1.48; overflow-wrap: anywhere; }
.hint { margin: 7px 2px 0; color: var(--muted); font-size: 12px; line-height: 1.42; }
.spacer { height: 14px; }
.gap-top { margin-top: 10px; }
.separator { margin: 18px 0; border: 0; border-top: 1px solid var(--line); }
.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }

.label { display: block; margin: 15px 0 7px; font-size: 13px; font-weight: 850; }
.input, .select, .textarea {
  width: 100%; min-height: 52px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 17px;
  appearance: none; -webkit-appearance: none; outline: 0; background: var(--surface); color: var(--ink); font-size: 16px; line-height: 1.25;
}
.input::placeholder, .textarea::placeholder { color: color-mix(in srgb, var(--muted) 75%, transparent); }
.input:focus, .select:focus, .textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(79,199,128,.14); }
.select {
  padding-right: 42px;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 22px) 22px, calc(100% - 16px) 22px;
  background-size: 6px 6px; background-repeat: no-repeat;
}
.textarea { min-height: 112px; resize: vertical; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; width: 100%; min-height: 52px; padding: 14px 18px;
  border: 0; border-radius: 18px; cursor: pointer; color: #11251b;
  background: linear-gradient(180deg, #a6efbf, #62d18f); box-shadow: 0 13px 28px rgba(46, 181, 105, .21);
  font-size: 16px; font-weight: 900; text-decoration: none; transition: transform .08s ease, filter .12s ease;
}
.btn:hover { filter: brightness(.985); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; box-shadow: none; }
.btn.secondary { color: var(--ink); border: 1px solid var(--line); background: var(--surface); box-shadow: none; }
.btn.dark { color: #fff; background: var(--brand); box-shadow: none; }
.btn.warn { color: #5c3e0c; border: 1px solid #eed29a; background: var(--warning); box-shadow: none; }
.btn.small { width: auto; min-height: 42px; padding: 10px 13px; border-radius: 14px; font-size: 13px; }
.logout-btn { margin-top: 12px; color: #702c2b !important; border-color: #debcbc !important; background: #fff8f7 !important; }
html[data-theme="dark"] .logout-btn { color: #ffd9d7 !important; border-color: #684443 !important; background: #2c1d1c !important; }

.notice {
  padding: 13px 14px; border: 1px solid var(--line); border-radius: 17px;
  background: var(--surface-soft); color: color-mix(in srgb, var(--ink) 78%, var(--muted)); font-size: 13px; line-height: 1.45; overflow-wrap: anywhere;
}
.notice + .notice { margin-top: 10px; }
.notice.good { color: #173f29; border-color: #b9e9ca; background: #e8f9ee; }
.notice.bad { color: #74342d; border-color: #f1c1bc; background: var(--danger); }
html[data-theme="dark"] .notice.good { color: #d7f7e2; border-color: #315c42; background: #173323; }
html[data-theme="dark"] .notice.bad { color: #ffd8d4; border-color: #6a4140; background: #33201f; }
.notice code, .recovery-box code { display: block; margin: 9px 0; padding: 11px; border-radius: 13px; background: var(--surface); color: var(--ink); font-size: 17px; font-weight: 900; letter-spacing: .04em; user-select: all; }

.today {
  margin-top: 14px; padding: 22px; color: #fff; background: linear-gradient(155deg, #132b21, #285c42); box-shadow: 0 18px 44px rgba(13, 44, 29, .24);
}
.today .muted { color: #d3e7dc; }
.today .pill { color: #fff; border-color: rgba(255,255,255,.20); background: rgba(255,255,255,.12); }
.today h2 { margin: 2px 0 0; }
.meter { height: 14px; margin: 18px 0; overflow: hidden; border-radius: 999px; background: rgba(255,255,255,.15); }
.meter span { display: block; height: 100%; min-width: 3px; border-radius: inherit; background: linear-gradient(90deg, #a5efbd, #51d083); }
.numbers { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 9px; }
.num { min-width: 0; padding: 12px 7px; border-radius: 17px; background: rgba(255,255,255,.10); text-align: center; }
.num b { display: block; font-size: 24px; }
.num span { display: block; min-height: 28px; color: #d3e7dc; font-size: 11px; }
.puffs { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 9px; margin-top: 14px; }
.puff { min-width: 0; padding: 16px 7px; border: 0; border-radius: 18px; background: #fff; color: #143024; font-size: 20px; font-weight: 900; cursor: pointer; }
.manual { display: grid; grid-template-columns: minmax(0,1fr) 132px; gap: 9px; margin-top: 10px; }
.manual .input { min-width: 0; background: #fff; color: #11251c; }
.manual .btn { width: 100%; }
.mini-refresh { padding: 9px 11px; border: 1px solid rgba(255,255,255,.28); border-radius: 999px; background: rgba(255,255,255,.12); color: #fff; font-size: 12px; font-weight: 850; cursor: pointer; }

.timer { margin: 13px 0 15px; font-size: 55px; font-weight: 900; line-height: 1; letter-spacing: -2px; text-align: center; }
.triggergrid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 9px; }
.trigger { padding: 12px; border: 1px solid var(--line); border-radius: 15px; background: var(--surface); color: var(--ink); font-weight: 850; cursor: pointer; }

.route-card { background: linear-gradient(150deg, var(--surface), var(--surface-soft)); }
.route-card .notice { border-color: #c6e6d2; }
.route-status { display: inline-flex; margin-top: 6px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 999px; font-size: 12px; font-weight: 900; }
.route-status.on_track { color: #264f79; border-color: #cbdcf0; background: #edf4ff; }
.route-status.hard_day { color: #694611; border-color: #ecd08c; background: #fff4dc; }
.route-status.ahead { color: #175c35; border-color: #bee5cc; background: #e8f8ed; }
.route-status.not_enough_data { color: var(--muted); background: var(--surface-soft); }
.mini-kpi { min-width: 88px; padding: 10px 13px; border-radius: 18px; background: var(--brand); color: #fff; text-align: center; }
.mini-kpi span { display: block; color: #cfe2d7; font-size: 11px; font-weight: 850; }
.mini-kpi b { font-size: 28px; line-height: 1; }
.mission-card { border-color: #c7e6d2; background: linear-gradient(150deg, #fffaf0, #effaf3); }
html[data-theme="dark"] .mission-card { background: linear-gradient(150deg, #2d281c, #193025); }
.mission-card p { margin: 0; font-size: 17px; font-weight: 900; line-height: 1.38; }

.procard { color: #fff; border: 0; background: linear-gradient(150deg, #0f1f18, #274d39); }
.procard .muted { color: #cfe1d7; }
.procard .notice.pro-trust { color: #e2f0e8; border-color: rgba(255,255,255,.16); background: rgba(255,255,255,.09); }
.feature { display: flex; align-items: flex-start; gap: 10px; padding: 11px 0; border-bottom: 1px solid rgba(255,255,255,.12); }
.feature:last-child { border-bottom: 0; }
.check { display: grid; place-items: center; flex: 0 0 24px; width: 24px; height: 24px; border-radius: 50%; background: #79df9d; color: #10261c; font-weight: 900; }
.account-actions .btn.small { width: 100%; }

.history { display: grid; gap: 8px; }
.history-summary { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 8px; margin: 12px 0 14px; }
.history-summary > div { min-width: 0; padding: 11px 7px; border: 1px solid var(--line); border-radius: 17px; background: var(--surface-soft); text-align: center; }
.history-summary b { display: block; color: var(--ink); font-size: 20px; line-height: 1.1; }
.history-summary span { display: block; min-height: 24px; margin-top: 3px; color: var(--muted); font-size: 11px; font-weight: 850; }
.history-day { padding: 11px 10px; overflow: hidden; border: 1px solid var(--line); border-radius: 17px; background: var(--surface); box-shadow: 0 5px 17px rgba(20,53,38,.04); }
.history-day.no-data { opacity: .72; }
.history-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.history-head b { color: var(--ink); font-size: 14px; }
.barrow { display: grid; grid-template-columns: 65px minmax(0,1fr) 42px; align-items: center; gap: 8px; }
.barrow + .barrow { margin-top: 5px; }
.barrow b { color: var(--ink); font-size: 13px; text-align: right; }
.bar { height: 13px; overflow: hidden; border-radius: 999px; background: color-mix(in srgb, var(--line) 60%, var(--surface)); }
.bar span { display: block; height: 100%; min-width: 3px; border-radius: inherit; background: #70d697; }
.barrow.plan { opacity: .72; }
.barrow.plan .bar span { background: #a8c8b5; }
.history-day.no-data .barrow:first-of-type .bar span { width: 0 !important; min-width: 0; }

.tabs {
  position: fixed; z-index: 30; left: 50%; bottom: calc(8px + var(--safe-bottom)); transform: translateX(-50%);
  display: grid; grid-template-columns: repeat(5,1fr); gap: 4px; width: min(510px, calc(100vw - 16px)); padding: 7px;
  border: 1px solid color-mix(in srgb, var(--line) 88%, transparent); border-radius: 22px;
  background: color-mix(in srgb, var(--surface) 90%, transparent); box-shadow: 0 10px 32px rgba(20,48,38,.16); backdrop-filter: blur(18px);
}
.tab { padding: 10px 3px; border: 0; border-radius: 15px; background: transparent; color: var(--muted); font-size: 11px; font-weight: 850; cursor: pointer; }
.tab.active { background: var(--brand); color: #fff; }

.links { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; margin-top: 12px; }
.links a { padding: 10px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--ink); font-size: 12px; font-weight: 850; text-align: center; text-decoration: none; }
.hide { display: none !important; }
.fade { animation: fade .18s ease-out; }
@keyframes fade { from { opacity: .45; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.legal { width: 100%; max-width: 780px; margin: 0 auto; padding: 26px 14px calc(64px + var(--safe-bottom)); }
.legal h1 { margin: 12px 0 18px; font-size: clamp(31px,8vw,42px); line-height: 1; letter-spacing: -1.1px; }
.legal ul { padding-left: 20px; line-height: 1.6; }
.back { display: inline-flex; padding: 10px 14px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--ink); font-weight: 900; text-decoration: none; }
.button { display: inline-flex; padding: 14px 17px; border-radius: 16px; background: var(--accent); color: #11251c; font-weight: 900; text-decoration: none; }

.adminwrap { width: 100%; max-width: 920px; margin: 0 auto; padding: 20px 14px 56px; }
.tablewrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; min-width: 680px; border-collapse: collapse; font-size: 13px; }
.table th, .table td { padding: 10px 9px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
pre { max-width: 100%; margin: 0; overflow: auto; white-space: pre-wrap; word-break: break-word; }

@media (max-width: 430px) {
  .app { max-width: none; padding-top: 14px; padding-left: 10px; padding-right: 10px; }
  .logo { flex-basis: 40px; width: 40px; height: 40px; border-radius: 13px; font-size: 22px; }
  .brand b { font-size: 17px; }
  .brand span { max-width: 200px; font-size: 11px; }
  .top > .pill { max-width: 92px; padding: 8px 9px; font-size: 11px; }
  .hero { padding: 23px 17px; }
  .lead { font-size: 15px; }
  .card { margin-top: 12px; padding: 15px; }
  .card h2 { font-size: 21px; }
  .today { padding: 18px; border-radius: 25px; }
  .num { padding: 10px 5px; }
  .num b { font-size: 20px; }
  .puffs { gap: 7px; }
  .puff { padding: 15px 5px; font-size: 18px; }
  .manual { grid-template-columns: 1fr; }
  .grid2 { grid-template-columns: 1fr; }
  .btn.small { width: 100%; }
  .triggergrid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .timer { font-size: 49px; }
  .barrow { grid-template-columns: 47px minmax(0,1fr) 35px; gap: 6px; }
  .barrow .muted { font-size: 11px; }
  .history-head { display: block; }
  .history-head .muted { display: block; margin-top: 3px; }
  .history-summary { gap: 6px; }
  .history-summary > div { padding: 9px 5px; border-radius: 14px; }
  .history-summary b { font-size: 17px; }
  .history-summary span { font-size: 10px; }
  .mini-kpi { min-width: 78px; }
  .mini-kpi b { font-size: 24px; }
  .tabs { width: calc(100vw - 12px); padding: 6px; }
  .tab { padding: 9px 2px; font-size: 10px; }
  .adminwrap { padding: 12px 10px 44px; }
}

@media (max-width: 350px) {
  .brand span { max-width: 138px; }
  .top > .pill { max-width: 82px; font-size: 10px; }
  .card { padding-left: 13px; padding-right: 13px; }
  .timer { font-size: 44px; }
  .links { grid-template-columns: 1fr; }
  .history-summary span { font-size: 9px; }
}

.admin-kpi{font-size:22px;font-weight:900;color:var(--ink)}

/* Release accessibility: interactive targets stay usable on narrow phones. */
.btn.small, .tab, .trigger, .mini-refresh, .links a { min-height: 44px; }
.links a { display: inline-flex; align-items: center; justify-content: center; }
html[data-theme="dark"] .btn.warn { color: #ffe6b5; border-color: #745b31; background: #3a2e18; }
