/* Algon Auto-Accept mini app — LimoClick-style dark theme.
   Drop-in replacement for webapp/static/style.css. */
:root {
  --bg: #0a0c11; --bg2: #0e1118; --card: #151926; --card2: #1b2030;
  --line: #242a3a; --line2: #2e3547; --fg: #eef1f7; --muted: #8b93a7; --muted2: #5d6474;
  --blue: #3b82f6; --blue-bg: #17233f; --green: #22c55e; --green-bg: #11291d;
  --red: #ef4444; --red-bg: #2a1518; --amber: #f59e0b; --amber-bg: #2a2110;
  --purple: #8b5cf6; --purple-bg: #1f1a35;
  --font: "Inter", -apple-system, BlinkMacSystemFont, system-ui, "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--fg); font-family: var(--font); font-size: 15px; line-height: 1.5;
  -webkit-font-smoothing: antialiased; overscroll-behavior-y: none; }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); background: var(--bg2); z-index: 60; }
h1,h2,h3,p { margin: 0; }
a { color: var(--blue); }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }
.tnum { font-variant-numeric: tabular-nums; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

.topbar { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 50; display: flex; align-items: center; gap: 12px;
  height: 54px; background: var(--bg2); border-bottom: 1px solid var(--line);
  padding-left: max(14px, env(safe-area-inset-left, 0px)); padding-right: max(14px, env(safe-area-inset-right, 0px)); }
.icon-btn { background: none; border: 0; color: var(--fg); font-size: 20px; line-height: 1; padding: 8px; border-radius: 8px; }
.icon-btn:hover { background: var(--card); }
.brand { display: flex; align-items: center; gap: 8px; margin: 0 auto; font-weight: 700; font-size: 16px; }
.logo { width: 26px; height: 26px; border-radius: 7px; background: var(--blue); display: grid; place-items: center; flex: none; }
.logo svg { width: 16px; height: 16px; }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted2); }
.pill.on { color: var(--green); } .pill.on .dot { background: var(--green); box-shadow: 0 0 10px 0 var(--green); }
.pill.test { color: var(--amber); } .pill.test .dot { background: var(--amber); box-shadow: 0 0 10px 0 var(--amber); }

main { max-width: 920px; margin: 0 auto; padding-block: 18px 80px;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.page-h { font-size: 26px; font-weight: 800; letter-spacing: -0.02em; }
.page-sub { color: var(--muted); font-size: 14px; margin-top: 2px; margin-bottom: 18px; }
.stack { display: grid; gap: 14px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.spacer { flex: 1 1 auto; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 18px; min-width: 0; }
.card .cap { font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); font-weight: 600; }

.stat { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 18px;
  display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 14px; align-items: center; }
.stat .ico { grid-row: 1 / 3; width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; }
.stat .ico svg { width: 22px; height: 22px; }
.stat .trend { grid-column: 2; justify-self: end; font-size: 13px; font-weight: 600; }
.trend.up { color: var(--green); } .trend.down { color: var(--red); }
.stat .label { grid-column: 2; color: var(--muted); font-size: 14px; }
.stat .row2 { grid-column: 2; display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-top: 2px; }
.stat .big { font-size: 30px; font-weight: 800; letter-spacing: -0.02em; }
.stat .val { color: var(--muted); font-weight: 600; font-size: 17px; }
.ico.blue { background: var(--blue-bg); color: var(--blue); } .ico.green { background: var(--green-bg); color: var(--green); }
.ico.red { background: var(--red-bg); color: var(--red); } .ico.amber { background: var(--amber-bg); color: var(--amber); }
.ico.purple { background: var(--purple-bg); color: var(--purple); }
@media (min-width: 640px) { .stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; } }

.seg { display: inline-flex; background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: none; color: var(--muted); font-size: 13px; font-weight: 600; padding: 6px 12px; border-radius: 7px; }
.seg button.active { background: var(--blue); color: #fff; }
.legend { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.legend span { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; color: var(--muted);
  background: var(--bg2); border: 1px solid var(--line); border-radius: 20px; padding: 4px 10px; }
.legend i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.chart-wrap { overflow-x: auto; margin-top: 12px; }
svg.chart { display: block; width: 100%; height: 200px; min-width: 300px; }

.ride { display: grid; gap: 6px; padding: 14px 0; border-top: 1px solid var(--line); cursor: pointer; }
.ride:first-child { border-top: 0; }
.ride .top { display: flex; align-items: center; gap: 8px; }
.badge { font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 6px; }
.badge.red { background: var(--red-bg); color: var(--red); } .badge.green { background: var(--green-bg); color: var(--green); }
.badge.amber { background: var(--amber-bg); color: var(--amber); }
.chip { font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 6px; background: var(--card2); color: var(--muted); }
.chip.blue { background: var(--blue-bg); color: #93b4f7; }
.ride .addr { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ride .price { font-weight: 700; margin-left: auto; }

.frow { display: flex; align-items: center; gap: 14px; background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 16px; text-align: left; width: 100%; color: inherit; }
.frow:hover { border-color: var(--line2); background: var(--card2); }
.frow .fico { width: 44px; height: 44px; border-radius: 11px; display: grid; place-items: center; flex: none; }
.frow .fico svg { width: 22px; height: 22px; }
.frow .ft { font-weight: 700; font-size: 16px; } .frow .fs { color: var(--muted); font-size: 13px; margin-top: 2px; }
.frow .chev { margin-left: auto; color: var(--muted2); flex: none; font-size: 20px; }

label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
input[type=text], input[type=number], input[type=date], input[type=time], input[type=datetime-local], select, textarea {
  width: 100%; background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; color: var(--fg);
  padding: 10px 12px; font-size: 15px; }
textarea { min-height: 90px; resize: vertical; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); outline: none; }
.inline { display: flex; gap: 10px; flex-wrap: wrap; }
.inline > label.field { flex: 1 1 140px; margin-bottom: 0; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; }
.switch input { width: 42px; height: 24px; appearance: none; background: var(--line2); border-radius: 20px; position: relative; cursor: pointer; flex: none; }
.switch input:checked { background: var(--green); }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: left .15s; }
.switch input:checked::after { left: 21px; }

.btn { border: 0; border-radius: 10px; padding: 11px 16px; font-weight: 700; font-size: 14px; background: var(--card2); color: var(--fg);
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; }
.btn.primary { background: var(--blue); color: #fff; } .btn.green { background: var(--green-bg); color: var(--green); }
.btn.red { background: var(--red-bg); color: var(--red); } .btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tablebox { overflow-x: auto; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-size: 11px; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
td.y { color: var(--green); } td.n { color: var(--red); }

.gauge-wrap { display: grid; place-items: center; gap: 4px; padding: 8px 0 4px; }
.gauge-num { font-size: 46px; font-weight: 800; letter-spacing: -0.02em; }
.gauge-sub { color: var(--muted); font-size: 13px; }
.tag { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; font-size: 14px; padding: 7px 14px; border-radius: 20px; background: var(--green-bg); color: var(--green); margin-top: 8px; }
.three { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.three .box { background: var(--bg2); border: 1px solid var(--line); border-radius: 12px; padding: 12px; text-align: center; }
.three .k { font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.three .v { font-size: 22px; font-weight: 800; margin-top: 4px; }
.note { display: flex; gap: 10px; border-radius: 12px; padding: 14px; font-size: 13.5px; line-height: 1.5; }
.note.locked { background: var(--card); border: 1px solid var(--line2); color: var(--muted); }
.note.warn { background: var(--amber-bg); border: 1px solid #4a3a1a; color: #f3c98a; }
.note.info { background: var(--blue-bg); border: 1px solid #1f3355; color: #a9c6f8; }
.note svg { flex: none; width: 18px; height: 18px; margin-top: 1px; }
.bars { display: grid; gap: 8px; margin-top: 8px; }
.bars .b { display: grid; grid-template-columns: 70px 1fr auto; gap: 10px; align-items: center; font-size: 13px; }
.bars .track { height: 10px; background: var(--bg2); border-radius: 6px; overflow: hidden; }
.bars .fill { height: 100%; background: var(--blue); border-radius: 6px; }

.evt { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); font-size: 13px; }
.evt:first-child { border-top: 0; }
.evt .lvl { font-size: 10px; font-weight: 700; padding: 2px 6px; border-radius: 5px; height: fit-content; }
.lvl.info { background: var(--blue-bg); color: #93b4f7; } .lvl.warning { background: var(--amber-bg); color: var(--amber); }
.lvl.error { background: var(--red-bg); color: var(--red); }
.evt .when { color: var(--muted2); font-size: 11px; white-space: nowrap; }

.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 70; opacity: 0; pointer-events: none; transition: opacity .2s; }
.scrim.open { opacity: 1; pointer-events: auto; }
.drawer { position: fixed; top: 0; bottom: 0; left: 0; z-index: 80; width: min(86vw, 340px); background: var(--bg2);
  border-right: 1px solid var(--line); transform: translateX(-102%); transition: transform .22s ease; display: flex; flex-direction: column;
  padding-top: env(safe-area-inset-top, 0px); padding-left: env(safe-area-inset-left, 0px); }
.drawer.open { transform: none; }
.drawer-head { display: flex; align-items: center; gap: 10px; padding: 16px; border-bottom: 1px solid var(--line); }
.drawer-head .logo { width: 30px; height: 30px; } .drawer-head .logo svg { width: 18px; height: 18px; } .drawer-head b { font-size: 16px; }
.drawer-head .x { margin-left: auto; }
.drawer-scroll { overflow-y: auto; padding: 14px; display: grid; gap: 4px; }
.botstat { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-bottom: 8px; }
.botstat .r { display: flex; justify-content: space-between; align-items: center; font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.botbtn { width: 100%; margin-top: 10px; border: 0; border-radius: 10px; padding: 11px; font-weight: 700; font-size: 14px; }
.botbtn.stop { background: var(--red-bg); color: var(--red); } .botbtn.start { background: var(--green-bg); color: var(--green); }
.nav { border: 0; background: none; color: var(--fg); width: 100%; text-align: left; display: flex; align-items: center; gap: 12px;
  padding: 11px 12px; border-radius: 10px; font-size: 15px; font-weight: 500; }
.nav:hover { background: var(--card); }
.nav.active { background: var(--blue-bg); color: #9cc0fb; font-weight: 600; }
.nav .ni { width: 20px; display: grid; place-items: center; color: var(--muted); flex: none; }
.nav.active .ni { color: #9cc0fb; }
.nav .caret { margin-left: auto; color: var(--muted2); transition: transform .15s; }
.nav .caret.open { transform: rotate(180deg); }
.subnav { display: grid; gap: 2px; margin: 2px 0 2px 16px; padding-left: 10px; border-left: 1px solid var(--line); }
.subnav .nav { font-size: 14px; padding: 9px 12px; } .subnav .nav .ni { width: 18px; }
.locktag { margin-left: auto; font-size: 10px; font-weight: 700; color: var(--amber); background: var(--amber-bg); border-radius: 5px; padding: 2px 6px; }

.modal-scrim { position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 90; display: none; align-items: flex-end; justify-content: center; }
.modal-scrim.open { display: flex; }
.modal { background: var(--bg2); border: 1px solid var(--line); border-radius: 18px 18px 0 0; width: 100%; max-width: 560px;
  max-height: 88vh; overflow-y: auto; padding: 18px; padding-bottom: max(20px, env(safe-area-inset-bottom, 0px)); }
.modal .mh { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; margin: 12px 0; font-size: 14px; }
.kv .k { color: var(--muted); } .kv .v { word-break: break-word; }
.checks { display: grid; gap: 7px; margin-top: 10px; }
.chk { display: grid; grid-template-columns: 20px 1fr; gap: 8px; font-size: 13.5px; align-items: start; }
.chk b { font-weight: 600; }
.divider { height: 1px; background: var(--line); margin: 14px 0; }
.toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 100;
  background: var(--card2); color: var(--fg); border: 1px solid var(--line2); padding: 10px 16px; border-radius: 10px; font-size: 14px; font-weight: 600; }
.foot-note { color: var(--muted2); font-size: 12px; text-align: center; margin-top: 24px; line-height: 1.6; }
.loading { color: var(--muted); padding: 20px 0; }
.err { background: var(--red-bg); border: 1px solid #4a1d1d; color: #f2a39b; border-radius: 12px; padding: 14px; font-size: 14px; }
