:root {
  color-scheme: dark;
  --bg: #070a10;
  --panel: #10151e;
  --panel2: #151b25;
  --line: rgba(255,255,255,.09);
  --text: #f5f7fb;
  --muted: #8f98aa;
  --green: #45e58f;
  --blue: #4eb7ff;
  --purple: #8c62ff;
  --cyan: #32d6cf;
  --danger: #ff5f70;
  --warn: #ffbf52;
  --radius: 18px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; min-width: 0; }
html, body { margin: 0; width: 100%; min-height: 100%; max-width: 100%; overflow-x: hidden; background: var(--bg); font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang SC", sans-serif; color: var(--text); }
body { padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom); overscroll-behavior-x: none; }
button, input { font: inherit; max-width: 100%; }
button { cursor: pointer; }
.hidden { display: none !important; }
.app { width: 100%; max-width: 560px; min-height: 100dvh; margin: 0 auto; padding: 18px 16px calc(126px + env(safe-area-inset-bottom)); overflow-x: hidden; background: radial-gradient(circle at 80% 0%, rgba(76,92,190,.10), transparent 32%), var(--bg); }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin: 8px 2px 20px; overflow: hidden; }
.title-wrap { min-width: 0; }
.title-line { display: flex; align-items: baseline; gap: 7px; min-width: 0; }
.title-line span { color: #60708a; font-size: 11px; font-weight: 700; white-space: nowrap; }
.eyebrow { color: #6f788a; font-size: 10px; letter-spacing: .12em; font-weight: 700; }
h1 { font-size: 28px; margin: 3px 0 0; letter-spacing: -.03em; white-space: nowrap; }
h2 { margin: 3px 0 0; font-size: 23px; }
.pill { flex: 0 0 auto; padding: 8px 11px; border-radius: 999px; font-size: 11px; font-weight: 800; letter-spacing: .04em; border: 1px solid var(--line); }
.pill.dry { color: var(--blue); background: rgba(61,154,255,.10); }
.pill.live { color: #fff; background: rgba(255,69,86,.82); border-color: rgba(255,120,132,.8); box-shadow: 0 0 24px rgba(255,69,86,.25); }
.page { display: none; width: 100%; max-width: 100%; overflow-x: hidden; }
.page.active { display: block; }
.status-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; width: 100%; }
.status-card, .panel { background: linear-gradient(145deg, rgba(24,30,41,.96), rgba(13,17,24,.96)); border: 1px solid var(--line); box-shadow: inset 0 1px 0 rgba(255,255,255,.025); }
.status-card { min-height: 104px; border-radius: var(--radius); padding: 17px; display: flex; flex-direction: column; justify-content: space-between; overflow: hidden; }
.status-card span { color: var(--muted); font-size: 13px; }
.status-card strong { display: block; max-width: 100%; font-size: 18px; color: var(--green); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.panel { width: 100%; border-radius: var(--radius); padding: 17px; margin-top: 12px; overflow: hidden; }
.panel-title { font-size: 13px; color: var(--muted); margin-bottom: 12px; }
.task-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.task-title b { max-width: 56%; color: var(--blue); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.metric-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 0; border-bottom: 1px solid rgba(255,255,255,.055); }
.metric-row:last-child { border: 0; }
.metric-row span { color: #a9b0bd; font-size: 14px; }
.metric-row b { font-size: 14px; white-space: nowrap; }
.task-box { color: #d8dce5; font-size: 13px; line-height: 1.65; overflow-wrap: anywhere; word-break: break-word; }
.quick-actions { display: grid; grid-template-columns: 1.4fr .8fr; gap: 11px; margin-top: 16px; }
.primary, .secondary { border: 0; min-height: 54px; border-radius: 16px; font-weight: 760; font-size: 16px; color: #fff; }
.primary { background: linear-gradient(100deg, #703df0, #3c84ef 52%, #32d4c7); box-shadow: 0 10px 30px rgba(70,91,220,.18); }
.primary.running { background: linear-gradient(105deg,#d9374f,#ff5f70 58%,#d84835); box-shadow: 0 8px 24px rgba(255,68,88,.20); }
.secondary { background: #171d27; border: 1px solid var(--line); }
.full { width: 100%; margin-top: 11px; }
.segmented { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0,1fr); background: #10151e; border: 1px solid var(--line); border-radius: 13px; padding: 3px; overflow: hidden; }
.seg { min-width: 0; min-height: 38px; border: 0; border-radius: 10px; background: transparent; color: #a9b1bf; font-size: 13px; padding: 0 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seg.active { color: #fff; background: linear-gradient(100deg, rgba(116,65,238,.86), rgba(70,100,218,.62)); }
.mode-tabs { margin-bottom: 12px; }
.form-panel label { display: flex; justify-content: space-between; gap: 8px; color: #dce0e8; font-size: 14px; margin: 18px 1px 8px; }
.form-panel label:first-child { margin-top: 0; }
.form-panel label span { color: #697386; font-size: 11px; align-self: center; white-space: nowrap; }
input { width: 100%; height: 48px; border-radius: 12px; border: 1px solid var(--line); background: #0c1118; color: #fff; padding: 0 13px; outline: none; }
input:focus { border-color: rgba(94,132,255,.65); box-shadow: 0 0 0 3px rgba(88,108,235,.10); }
.big-input { height: 54px; font-size: 13px; }
.compact-input { margin-top: 7px; height: 42px; }
.presets { grid-auto-flow: column; grid-template-columns: repeat(4, minmax(0, 1fr)); }
details { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 13px; }
summary { color: #8d96aa; font-size: 13px; }
.policy-quick { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 7px; width: 100%; }
.policy-chip { min-width: 0; min-height: 42px; border: 1px solid var(--line); border-radius: 11px; background: #0d131b; color: #8f98aa; padding: 6px 8px; display: flex; align-items: center; justify-content: space-between; gap: 5px; overflow: hidden; }
.policy-chip span { min-width: 0; font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.policy-chip b { flex: 0 0 auto; font-size: 11px; color: #8791a2; }
.policy-chip.active { border-color: rgba(69,229,143,.32); background: rgba(69,229,143,.08); color: #dffbed; }
.policy-chip.active b { color: var(--green); }
.policy-chip.hold.active { border-color: rgba(50,214,207,.45); background: rgba(50,214,207,.10); }
.policy-chip.hold.active b { color: var(--cyan); }
.policy-chip.locked, .policy-detail.locked { opacity: .55; cursor: not-allowed; }
.policy-detail { width: 100%; min-height: 46px; margin-top: 8px; padding: 0 12px; border: 1px solid var(--line); border-radius: 12px; background: #0d131b; color: #d9dee7; display: grid; grid-template-columns: auto minmax(0,1fr) auto; gap: 9px; align-items: center; text-align: left; }
.policy-detail span { font-size: 12px; }
.policy-detail b { color: #8f98aa; font-size: 11px; font-weight: 600; text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.policy-detail i { color: #697386; font-style: normal; }
.logs-head { display: flex; justify-content: space-between; align-items: center; margin: 4px 2px 12px; }
.tiny { border: 1px solid var(--line); background: #111720; color: #b5bdcb; padding: 8px 12px; border-radius: 10px; }
.logs { display: flex; flex-direction: column; gap: 8px; width: 100%; }
.log { width: 100%; min-width: 0; border: 1px solid var(--line); border-radius: 13px; background: #0f141c; padding: 11px 12px; overflow: hidden; }
.log-top { display: flex; gap: 8px; align-items: center; font-size: 10px; color: #657083; }
.log-level { font-weight: 800; color: var(--green); }
.log.WARN .log-level { color: var(--warn); }
.log.ERROR .log-level { color: var(--danger); }
.log-message { font-size: 13px; margin-top: 5px; line-height: 1.5; overflow-wrap: anywhere; }
.log-data { color: #7f899c; font-size: 10px; margin-top: 5px; white-space: pre-wrap; overflow-wrap: anywhere; }
.bottom-nav { position: fixed; left: 50%; transform: translateX(-50%); bottom: max(10px, env(safe-area-inset-bottom)); width: min(calc(100% - 28px), 532px); height: 70px; border-radius: 22px; border: 1px solid rgba(255,255,255,.10); background: rgba(14,18,26,.94); backdrop-filter: blur(18px); display: grid; grid-template-columns: repeat(3,1fr); z-index: 20; box-shadow: 0 15px 40px rgba(0,0,0,.32); }
.nav { min-width: 0; border: 0; color: #7c8494; background: transparent; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 3px; }
.nav span { font-size: 22px; line-height: 1; }
.nav small { font-size: 10px; }
.nav.active { color: var(--purple); }
.toast { position: fixed; left: 50%; transform: translateX(-50%) translateY(-20px); top: max(18px, env(safe-area-inset-top)); max-width: calc(100% - 36px); background: #1b2330; color: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 11px 15px; opacity: 0; pointer-events: none; transition: .2s ease; z-index: 100; font-size: 13px; overflow: hidden; text-overflow: ellipsis; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.login-screen { min-height: 100dvh; padding: 24px; display: grid; place-items: center; overflow-x: hidden; background: radial-gradient(circle at 50% 15%, rgba(97,72,255,.15), transparent 32%), var(--bg); }
.login-card { width: min(100%, 380px); border: 1px solid var(--line); border-radius: 24px; background: #10151e; padding: 28px; text-align: center; }
.brand-mark { width: 58px; height: 58px; display: grid; place-items: center; margin: 0 auto 14px; border-radius: 18px; font-weight: 900; font-size: 25px; background: linear-gradient(145deg,#6b45ef,#2bcfc5); }
.login-card h1 { font-size: 25px; }
.login-card p { color: var(--muted); margin: 6px 0 22px; }
.login-card input { margin-bottom: 4px; }
.login-note { color: #677186; font-size: 11px; margin-top: 15px; }
.sheet { position: fixed; inset: 0; z-index: 80; background: rgba(0,0,0,.70); backdrop-filter: blur(8px); display: grid; place-items: center; padding: max(14px,env(safe-area-inset-top)) 13px max(14px,env(safe-area-inset-bottom)); overflow: hidden; }
.sheet-card { width: min(100%,520px); max-height: calc(100dvh - 28px); overflow-y: auto; overflow-x: hidden; border: 1px solid rgba(255,255,255,.12); background: #101620; border-radius: 22px; padding: 15px; box-shadow: 0 24px 80px rgba(0,0,0,.5); }
.sheet-head { display: flex; justify-content: space-between; align-items: center; height: 48px; }
.sheet-head small { color: #69758a; font-size: 8px; letter-spacing: .12em; }
.sheet-close { width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 50%; background: #171e29; color: #adb5c3; font-size: 21px; }
.hold-toggle { width: 100%; min-height: 58px; margin: 9px 0 6px; border: 1px solid rgba(75,183,255,.22); border-radius: 13px; background: #0d151f; color: #fff; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 11px; text-align: left; }
.hold-toggle span { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.hold-toggle b { font-size: 13px; }
.hold-toggle small { color: #788499; font-size: 9px; }
.hold-toggle i, .toggle { min-width: 42px; height: 28px; border: 1px solid var(--line); border-radius: 999px; background: #202733; color: #9aa3b2; font-style: normal; font-size: 10px; display: grid; place-items: center; }
.hold-toggle.active { border-color: rgba(50,214,207,.55); background: rgba(25,123,116,.13); }
.hold-toggle.active i { background: rgba(50,214,207,.20); color: var(--cyan); }
.rug-note { color: var(--warn); font-size: 9px; line-height: 1.4; padding: 0 2px 8px; }
.exit-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.exit-section { border: 1px solid var(--line); border-radius: 12px; background: #0c121a; padding: 8px; }
.exit-section.wide { grid-column: 1 / -1; }
.exit-title { display: flex; justify-content: space-between; align-items: center; color: #cdd3dd; font-size: 11px; margin-bottom: 6px; }
.toggle { border: 0; cursor: pointer; }
.toggle.active { color: var(--green); background: rgba(69,229,143,.13); }
.exit-section label { font-size: 8px; color: #7d8799; margin: 0; display: block; }
.exit-section input { height: 34px; padding: 0 7px; margin-top: 3px; font-size: 11px; }
.one-input { display: grid !important; grid-template-columns: auto minmax(70px,110px); align-items: center; gap: 8px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.four-col { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 6px; }
.compact-exit { display: grid; grid-template-columns: 1fr 1fr; align-items: center; }
.compact-exit .exit-title { margin: 0; }
@media (max-width: 390px) {
  .app { padding-left: 13px; padding-right: 13px; }
  .status-card { padding: 14px; min-height: 98px; }
  .status-card strong { font-size: 16px; }
  h1 { font-size: 25px; }
  .seg { font-size: 12px; }
  .policy-chip { padding: 6px; }
  .policy-chip span { font-size: 10px; }
}
@media (min-width: 700px) { .app { border-left: 1px solid var(--line); border-right: 1px solid var(--line); } }
