/* Hark EA Manager PWA. Layout and colours follow work/mockups/apps (make_apps.py / make_features.py). */
:root { --bg: rgb(11,14,19); --panel: rgb(22,27,34); --p2: rgb(30,36,45); --line: rgb(44,50,58); --txt: rgb(232,238,244); --mut: rgb(140,149,160);
  --acc: rgb(212,175,55); --grn: rgb(46,204,113); --red: rgb(235,87,87); --nav: rgb(18,21,27); --pill: rgb(20,60,35); --on-acc: rgb(20,18,10);
  --org: #FF9F43; --blue: #58A6FF; --pur: #A371F7; --teal: #2DD4BF;
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px); --r: 18px; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--txt); font: 15px/1.35 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "DejaVu Sans", sans-serif; }
body { overscroll-behavior-y: none; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; padding: 0; }
input, select, textarea { font: inherit; color: var(--txt); background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; width: 100%; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--acc); }
a { color: var(--acc); text-decoration: none; }
.hidden { display: none !important; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, "DejaVu Sans Mono", monospace; }
.mut { color: var(--mut); } .grn { color: var(--grn); } .red { color: var(--red); } .acc { color: var(--acc); } .org { color: var(--org); }
.b { font-weight: 700; } .sm { font-size: 13px; } .xs { font-size: 12px; } .right { text-align: right; } .center { text-align: center; }

#app { min-height: 100%; display: flex; flex-direction: column; }
#top { position: sticky; top: 0; z-index: 20; background: var(--bg); padding: calc(var(--safe-t) + 14px) 22px 6px; }
#top.scrolled { border-bottom: 1px solid var(--line); }
.top-row { display: flex; align-items: center; gap: 10px; min-height: 44px; }
#title { flex: 1; margin: 0; font-size: 30px; font-weight: 800; letter-spacing: -0.3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#top.small #title { font-size: 22px; }
#actions { display: flex; gap: 8px; align-items: center; }
.icon-btn { width: 38px; height: 38px; border-radius: 19px; display: grid; place-items: center; background: var(--p2); color: var(--txt); }
.icon-btn svg { width: 20px; height: 20px; }
#back { background: none; width: 30px; margin-left: -8px; color: var(--acc); }
#subbar:empty { display: none; }
#subbar { padding-top: 6px; display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; }
#subbar::-webkit-scrollbar { display: none; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: 16px; background: var(--p2); color: var(--txt); font-size: 13px; font-weight: 600; white-space: nowrap; }
.chip.on { background: var(--acc); color: var(--on-acc); }
.chip .dot { width: 8px; height: 8px; border-radius: 4px; }
.badge { display: inline-block; font-size: 10.5px; font-weight: 800; letter-spacing: .4px; padding: 2px 7px; border-radius: 8px; background: var(--acc-soft); color: var(--acc); vertical-align: middle; }
.badge.cent { background: rgba(255,159,67,.2); color: var(--org); } .badge.pkr { background: var(--grn-soft); color: var(--grn); }

#view { flex: 1; padding: 6px 16px calc(var(--safe-b) + 110px); outline: none; }
#nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex; background: var(--nav); border-top: 1px solid var(--line); padding: 8px 0 calc(var(--safe-b) + 8px); }
#nav button { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 3px; color: var(--mut); font-size: 11px; letter-spacing: -0.1px; white-space: nowrap; }
#nav button svg { width: 22px; height: 22px; }
@media (max-width: 370px) { #nav button { font-size: 10.5px; } #nav button svg { width: 21px; height: 21px; } }
#nav button.on { color: var(--acc); }
body.no-nav #nav { display: none; }

.card { background: var(--panel); border-radius: var(--r); padding: 16px 20px; margin-bottom: 12px; position: relative; }
.card.tap { cursor: pointer; } .card.tap:active { filter: brightness(1.12); }
.card.sel { box-shadow: inset 0 0 0 3px var(--acc); }
.card h3 { margin: 0 0 12px; font-size: 14px; font-weight: 700; color: var(--mut); }
.card .stripe { position: absolute; left: 0; top: 14px; bottom: 14px; width: 5px; border-radius: 0 3px 3px 0; }
.big { font-size: 34px; font-weight: 800; letter-spacing: -.5px; line-height: 1.15; }
.big2 { font-size: 28px; font-weight: 800; line-height: 1.15; }
.val { font-size: 22px; font-weight: 800; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.row + .row { margin-top: 10px; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; font-size: 15px; }
.kv b { font-weight: 700; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.tile { background: var(--panel); border-radius: 16px; padding: 14px 16px; min-height: 84px; }
.tile .l { color: var(--mut); font-size: 13px; } .tile .v { font-size: 22px; font-weight: 800; margin-top: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.live { white-space: nowrap; flex: none; display: inline-flex; align-items: center; gap: 6px; background: var(--pill); color: var(--grn); font-size: 12px; font-weight: 800; padding: 5px 12px; border-radius: 14px; }
.live.off { background: var(--red-soft); color: var(--red); } .live.stale { background: rgba(255,159,67,.18); color: var(--org); }
.seg { display: flex; background: var(--p2); border-radius: 22px; padding: 4px; margin-bottom: 14px; }
.seg button { flex: 1; height: 36px; border-radius: 18px; color: var(--mut); font-weight: 700; font-size: 14px; }
.seg button.on { background: var(--acc); color: var(--on-acc); }
.btn { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; height: 56px; border-radius: 28px; background: var(--p2); color: var(--txt); font-weight: 800; font-size: 17px; margin-bottom: 12px; }
.btn.acc { background: var(--acc); color: var(--on-acc); }
.btn.tg { background: rgb(30,90,140); color: #fff; }
.btn.danger { background: rgb(130,22,22); color: rgb(255,225,225); border-radius: 14px; height: 60px; font-size: 20px; }
.btn.sm { height: 44px; font-size: 15px; }
.btn:disabled { opacity: .5; }
.pill { display: inline-flex; align-items: center; justify-content: center; height: 32px; padding: 0 14px; border-radius: 16px; font-size: 12.5px; font-weight: 800; background: var(--p2); color: var(--txt); white-space: nowrap; }
.pill.acc { background: var(--acc); color: var(--on-acc); } .pill.org { color: var(--org); } .pill.kill { background: rgb(90,22,22); color: rgb(255,200,200); }
.pill.gsoft { background: rgb(20,70,40); color: var(--grn); } .pill.rsoft { background: rgb(80,24,24); color: rgb(255,190,190); }
.pill.big { height: 44px; flex: 1; font-size: 13px; }
.status { display: inline-block; padding: 4px 10px; border-radius: 12px; background: var(--p2); font-size: 11px; font-weight: 800; letter-spacing: .3px; }
.st-running { color: var(--grn); } .st-paused { color: var(--org); } .st-killed, .st-risk_stop { color: var(--red); } .st-idle { color: var(--mut); }
.dot { display: inline-block; width: 12px; height: 12px; border-radius: 6px; flex: none; }
.list-row { display: flex; align-items: center; gap: 12px; padding: 9px 0; }
.list-row .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.switch { width: 52px; height: 30px; border-radius: 15px; background: rgb(70,70,78); position: relative; flex: none; transition: background .2s; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 26px; height: 26px; border-radius: 13px; background: #fff; transition: left .2s; }
.switch.on { background: var(--grn); } .switch.on::after { left: 24px; }
.bar { height: 12px; border-radius: 6px; background: var(--p2); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 6px; background: var(--acc); }
.hbar { display: flex; align-items: center; gap: 10px; padding: 7px 0; }
.hbar .lab { width: 120px; flex: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar .track { flex: 1; height: 16px; position: relative; }
.hbar .track i { position: absolute; top: 0; bottom: 0; border-radius: 4px; }
.hbar .mid { position: absolute; left: 50%; top: -3px; bottom: -3px; width: 1px; background: var(--line); }
canvas.chart { width: 100%; display: block; }
.empty { text-align: center; color: var(--mut); padding: 30px 10px; }
.note { color: var(--mut); font-size: 12px; text-align: center; margin: 4px 8px 14px; }
.warn-box { background: rgba(255,159,67,.12); color: var(--org); border-radius: 14px; padding: 10px 14px; font-size: 13px; margin-bottom: 12px; }
.err-box { background: var(--red-soft); color: var(--red); border-radius: 14px; padding: 10px 14px; font-size: 13px; margin-bottom: 12px; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal .h { text-align: center; color: var(--mut); font-size: 13px; font-weight: 700; padding: 4px 0; }
.cal .d { border-radius: 10px; background: var(--p2); min-height: 62px; padding: 5px 6px; font-size: 12px; font-weight: 700; display: flex; flex-direction: column; justify-content: space-between; }
.cal .d .p { text-align: center; font-size: 11.5px; }
.cal .d.pos { background: var(--grn-fill); } .cal .d.neg { background: var(--red-fill); } .cal .d.blank { background: none; }
.heat { display: grid; gap: 3px; }
.heat .c { border-radius: 5px; min-height: 30px; }
.matrix { display: grid; gap: 4px; font-size: 11.5px; }
.matrix .c { border-radius: 7px; display: grid; place-items: center; min-height: 40px; font-weight: 800; }
.feed .ic { width: 46px; height: 46px; border-radius: 23px; background: var(--p2); display: grid; place-items: center; font-weight: 900; font-size: 18px; flex: none; }
.form-row { margin-bottom: 14px; } .form-row label { display: block; color: var(--mut); font-size: 13px; margin: 0 0 6px 4px; }
.stepper { display: flex; align-items: center; gap: 12px; }
.stepper button { width: 64px; height: 48px; border-radius: 24px; background: var(--p2); font-size: 26px; font-weight: 700; }
.stepper .v { flex: 1; text-align: center; font-size: 40px; font-weight: 800; }
input[type=range] { -webkit-appearance: none; appearance: none; height: 10px; border-radius: 5px; background: var(--p2); border: 0; padding: 0; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 24px; height: 24px; border-radius: 12px; background: var(--acc); }
.themes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.themes button { text-align: center; font-size: 12px; color: var(--txt); }
.themes .sw { height: 60px; border-radius: 12px; border: 1px solid var(--line); position: relative; margin-bottom: 6px; }
.themes .sw i { position: absolute; left: 12px; right: 12px; bottom: 12px; height: 10px; border-radius: 4px; }
.themes button.on .sw { box-shadow: 0 0 0 3px var(--acc); }
.share-card { border: 3px solid var(--acc); border-radius: 22px; background: #10141a; padding: 26px 20px; text-align: center; color: #e8eef4; }
#sheet-bg { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 50; }
#sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 51; background: var(--panel); border-radius: 22px 22px 0 0; padding: 10px 20px calc(var(--safe-b) + 20px); max-height: 82vh; overflow-y: auto; }
#sheet::before { content: ""; display: block; width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 14px; }
#sheet h2 { margin: 0 0 14px; font-size: 20px; }
.sheet-item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 14px 4px; border-bottom: 1px solid var(--line); text-align: left; font-size: 16px; }
#toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--safe-b) + 96px); z-index: 60; background: var(--p2); color: var(--txt); padding: 12px 18px; border-radius: 22px; font-weight: 600; font-size: 14px; box-shadow: 0 6px 24px rgba(0,0,0,.35); max-width: 90vw; }
#lock { position: fixed; inset: 0; z-index: 100; background: var(--bg); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; padding: 30px; }
.logo-circle { width: 92px; height: 92px; border-radius: 46px; border: 3px solid var(--acc); display: grid; place-items: center; background: rgba(212,175,55,.08); }
.logo-circle img { width: 70px; height: 70px; }
.skeleton { background: linear-gradient(90deg, var(--panel), var(--p2), var(--panel)); background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: var(--r); height: 120px; margin-bottom: 12px; }
@keyframes sk { 0% { background-position: 200% 0 } 100% { background-position: -200% 0 } }
.offline-bar { background: rgba(255,159,67,.15); color: var(--org); font-size: 12.5px; font-weight: 700; padding: 6px 12px; border-radius: 12px; margin: 0 0 10px; text-align: center; }
.split2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tag { display: inline-block; background: var(--acc-soft); color: var(--acc); border-radius: 10px; padding: 2px 9px; font-size: 12.5px; font-weight: 700; margin: 0 6px 6px 0; }
@media (min-width: 700px) { #view { max-width: 640px; margin: 0 auto; width: 100%; } #top { max-width: 672px; margin: 0 auto; width: 100%; } }
.badge.live { background: var(--red); color: #fff; } .badge.demo { background: var(--p2); color: var(--mut); }
.pause-all { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.pause-all button { height: 64px; border-radius: 18px; font-weight: 800; font-size: 17px; }
.pause-all .p { background: rgba(255,159,67,.18); color: var(--org); } .pause-all .r { background: var(--grn-soft); color: var(--grn); }
.hist { border-left: 2px solid var(--line); padding: 0 0 12px 14px; margin-left: 6px; position: relative; }
.hist::before { content: ""; position: absolute; left: -6px; top: 4px; width: 10px; height: 10px; border-radius: 5px; background: var(--acc); }
.meter { display: flex; align-items: center; gap: 10px; padding: 6px 0; } .meter .l { width: 70px; } .meter .bar { flex: 1; }
.icon-btn.refresh { width: 34px; height: 34px; } .icon-btn.refresh svg { width: 18px; height: 18px; }
.icon-btn.refresh.small { width: 30px; height: 30px; background: var(--p2); } .icon-btn.refresh.small svg { width: 16px; height: 16px; }
.spin svg { animation: spin .8s linear infinite; } @keyframes spin { to { transform: rotate(360deg); } }
#ptr { position: fixed; left: 50%; top: calc(var(--safe-t) + 70px); transform: translate(-50%, -80px); opacity: 0; z-index: 40; width: 40px; height: 40px; border-radius: 20px; background: var(--p2); display: grid; place-items: center; color: var(--acc); box-shadow: 0 4px 16px rgba(0,0,0,.3); transition: transform .15s; }
#ptr svg { width: 20px; height: 20px; }
#ptr.spin, #ptr.pull { opacity: 1; }
#actions .icon-btn { width: 34px; height: 34px; } #actions .icon-btn svg { width: 19px; height: 19px; } #actions { gap: 6px; }
@media (max-width: 370px) { #title { font-size: 24px; } }
