/* Voom design tokens (portal light theme): prussian sidebar, forest accent, lime highlight */
:root {
  --prussian: #00384C;
  --prussian-2: #0B4E66;
  --forest: #478A33;
  --forest-2: #3A7429;
  --lime: #C5E86C;
  --red: #C62828;
  --amber: #E09A1B;
  --ink: #1A2B33;
  --muted: #5F7380;
  --line: #DCE4E8;
  --bg: #F3F6F8;
  --card: #FFFFFF;
  --radius: 12px;
  --font: 'Nunito', system-ui, -apple-system, 'Segoe UI', sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--font); color: var(--ink); background: var(--bg); font-size: 15px; line-height: 1.45; }
a { color: var(--forest); text-decoration: none; }
h1, h2 { margin: 0 0 .35em; font-weight: 800; letter-spacing: -.01em; }
h2 { font-size: 22px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.error { color: var(--red); font-weight: 600; margin: .5em 0 0; }
[hidden] { display: none !important; }

/* ---------- login */
#view-login { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(160deg, var(--prussian), #06263A 70%); padding: 16px; }
.login-card { width: min(420px, 100%); background: var(--card); border-radius: 16px; padding: 32px 28px; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.login-logo { height: 34px; background: var(--prussian); padding: 8px 12px; border-radius: 8px; margin-bottom: 18px; }
.login-card h1 { font-size: 22px; }
form label { display: block; font-weight: 700; font-size: 13px; margin: 14px 0 6px; }
form input { width: 100%; font: inherit; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
form input:focus { outline: 2px solid var(--lime); border-color: var(--forest); }

/* ---------- buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; font: inherit; font-weight: 700; padding: 10px 16px; border-radius: 10px; border: 1px solid transparent; cursor: pointer; background: #fff; color: var(--ink); }
.btn.primary { background: var(--forest); color: #fff; }
.btn.primary:hover { background: var(--forest-2); }
.btn.primary:disabled { opacity: .5; cursor: not-allowed; }
.btn.ghost { background: transparent; border-color: rgba(255,255,255,.35); color: #fff; }
.btn.ghost.dark { border-color: var(--line); color: var(--ink); }
.btn.small { padding: 6px 10px; font-size: 13px; border-radius: 8px; }
form .btn.primary { margin-top: 18px; width: 100%; justify-content: center; }
#upload-form .btn.primary { width: auto; margin-top: 0; }

/* ---------- shell */
.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 24px; padding: 0 16px; height: 58px; background: var(--prussian); color: #fff; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 800; }
.brand img { height: 26px; }
.topbar nav { display: flex; gap: 4px; }
.topbar nav a { color: rgba(255,255,255,.8); padding: 8px 12px; border-radius: 8px; font-weight: 700; }
.topbar nav a.active, .topbar nav a:hover { background: rgba(255,255,255,.12); color: #fff; }
.who { margin-left: auto; display: flex; align-items: center; gap: 10px; font-size: 13px; }
.pill { background: var(--lime); color: var(--prussian); font-weight: 800; padding: 2px 10px; border-radius: 999px; text-transform: uppercase; font-size: 11px; letter-spacing: .04em; }
.viewport { max-width: 1100px; margin: 0 auto; padding: 24px 16px 48px; }
.row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.back { display: inline-block; margin-bottom: 8px; font-weight: 700; }

/* ---------- upload */
.dropzone { margin-top: 16px; border: 2px dashed #9FB3BE; border-radius: var(--radius); padding: 38px 20px; text-align: center; background: var(--card); cursor: pointer; transition: border-color .15s, background .15s; }
.dropzone.over, .dropzone:focus { border-color: var(--forest); background: #F2F9EE; outline: none; }
.file-list { list-style: none; padding: 0; margin: 14px 0; display: grid; gap: 6px; }
.file-list li { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; align-items: center; background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; font-size: 14px; }
.file-list .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-list .rm { border: 0; background: none; cursor: pointer; color: var(--muted); font-size: 16px; }
.file-list .bar { grid-column: 1 / -1; height: 5px; background: var(--line); border-radius: 3px; overflow: hidden; }
.file-list .bar i { display: block; height: 100%; width: 0; background: var(--forest); transition: width .2s; }
.file-list li.done .bar i { background: var(--forest); width: 100%; }
.file-list li.failed .bar i { background: var(--red); }

/* ---------- tables */
.table { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; margin-top: 12px; }
.table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 12px 14px; background: #F7F9FA; border-bottom: 1px solid var(--line); }
.table td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tr.link { cursor: pointer; }
.table tr.link:hover td { background: #F5F9F3; }
.table td.num { font-variant-numeric: tabular-nums; }
.empty { background: var(--card); border: 1px dashed var(--line); border-radius: var(--radius); padding: 32px; text-align: center; color: var(--muted); margin-top: 12px; }

.status { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 800; text-transform: capitalize; }
.status.uploading, .status.uploaded { background: #E8EEF1; color: var(--prussian); }
.status.queued { background: #FFF3D6; color: #8A5A00; }
.status.starting, .status.processing { background: #DCEBFF; color: #0B4E8C; }
.status.done { background: #E3F3DA; color: var(--forest-2); }
.status.failed { background: #FBE3E3; color: var(--red); }
.red-count { font-weight: 800; color: var(--red); }
.zero { color: var(--muted); }

.progress { display: inline-flex; gap: 2px; height: 8px; width: 120px; border-radius: 4px; overflow: hidden; background: var(--line); vertical-align: middle; }
.progress i { display: block; height: 100%; }
.progress .done { background: var(--forest); }
.progress .processing { background: #4A90D9; }
.progress .queued { background: var(--amber); }
.progress .failed { background: var(--red); }

/* ---------- viewer modal */
.modal { position: fixed; inset: 0; z-index: 50; background: #0A1418; display: flex; flex-direction: column; }
.modal-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; background: var(--prussian); color: #fff; }
.modal iframe { flex: 1; border: 0; width: 100%; background: #0A1418; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; font-weight: 700; z-index: 60; box-shadow: 0 10px 30px rgba(0,0,0,.3); }
.toast.bad { background: var(--red); }

@media (max-width: 640px) {
  .topbar { gap: 12px; }
  .topbar nav a { padding: 8px; }
  .who #who-user { display: none; }
  .table th:nth-child(2), .table td:nth-child(2) { display: none; }
}

/* ---------- zone approval banner */
.banner { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-top: 12px; padding: 14px 16px; background: #FFF8E6; border: 1px solid #F1D48A; border-radius: var(--radius); }
.status.awaiting_zones, .status.frame_failed { background: #FFF3D6; color: #8A5A00; }
.status.approved { background: #DCEBFF; color: #0B4E8C; }
.progress .awaiting { background: #E0A73A; }

/* ---------- zone editor */
.editor .editor-body { flex: 1; display: grid; grid-template-columns: 1fr 320px; min-height: 0; background: var(--bg); }
.editor-canvas-wrap { display: flex; flex-direction: column; min-width: 0; padding: 12px 16px; gap: 10px; }
.editor-toolbar label.inline { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 13px; }
.editor-toolbar select { font: inherit; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; max-width: 320px; }
.canvas-box { position: relative; flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; background: #0A1418; border-radius: var(--radius); overflow: hidden; }
.canvas-box canvas { max-width: 100%; max-height: 100%; display: block; cursor: crosshair; touch-action: none; }
.canvas-box canvas.select { cursor: default; }
.hint { position: absolute; left: 12px; bottom: 12px; background: rgba(0,0,0,.65); color: #fff; padding: 6px 10px; border-radius: 8px; font-size: 13px; pointer-events: none; }
.editor-side { display: flex; flex-direction: column; gap: 12px; padding: 16px; background: var(--card); border-left: 1px solid var(--line); overflow-y: auto; }
.editor-side h3 { margin: 0; font-size: 16px; }
.zone-list { display: grid; gap: 8px; }
.zone-item { border: 1px solid var(--line); border-radius: 10px; padding: 10px; display: grid; grid-template-columns: 14px 1fr auto; gap: 8px 10px; align-items: center; cursor: pointer; }
.zone-item.selected { border-color: var(--forest); box-shadow: 0 0 0 2px #C5E86C66; }
.zone-item .dot { width: 14px; height: 14px; border-radius: 50%; }
.zone-item input, .zone-item select { font: inherit; font-size: 13px; padding: 5px 8px; border: 1px solid var(--line); border-radius: 6px; width: 100%; }
.zone-item .row2 { grid-column: 2 / -1; display: grid; grid-template-columns: 1fr 70px; gap: 8px; }
.zone-item .rm { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 16px; }
.zone-item.empty { color: var(--muted); font-size: 13px; cursor: default; display: block; }
.rules div { display: flex; gap: 8px; align-items: flex-start; margin: 4px 0; }
.sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; flex: none; margin-top: 3px; }
.sw.limb { background: rgb(255,64,64); } .sw.body { background: rgb(64,200,255); } .sw.roi { border: 2px dashed #7ED957; }
label.check { display: flex; gap: 8px; align-items: center; font-weight: 600; font-size: 13px; margin: 4px 0; }
label.check input { width: auto; }
.editor-side .btn.primary { width: 100%; justify-content: center; margin-top: auto; }
@media (max-width: 900px) { .editor .editor-body { grid-template-columns: 1fr; grid-template-rows: 1fr auto; } .editor-side { border-left: 0; border-top: 1px solid var(--line); max-height: 45vh; } }

.btn.danger { color: var(--red); border-color: #F1B8B8; }
.btn.danger:hover { background: #FBE3E3; }

/* ---------- zone maps */
.table th.tick, .table td.tick { width: 28px; padding-right: 0; }
.table td select.file-map { font: inherit; font-size: 13px; padding: 5px 8px; border: 1px solid var(--line); border-radius: 6px; max-width: 200px; }
#zones-toolbar select { font: inherit; font-size: 13px; padding: 7px 8px; border: 1px solid var(--line); border-radius: 8px; max-width: 220px; background: #fff; }
.maps-list { display: grid; gap: 10px; margin-top: 12px; }
.map-card { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.map-card.default { border-color: var(--forest); }
.map-card input.rename { font: inherit; font-weight: 800; padding: 4px 8px; border: 1px solid var(--forest); border-radius: 6px; }
.chip { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 700; color: #fff; }
.chip.limb { background: rgb(220,60,60); } .chip.body { background: rgb(40,150,210); }
.editor-side select, .editor-side > input { font: inherit; font-size: 13px; padding: 7px 8px; border: 1px solid var(--line); border-radius: 8px; width: 100%; }

.editor-actions { display: flex; gap: 8px; margin-top: auto; }
.editor-actions .btn { flex: 1; justify-content: center; margin-top: 0; }

.zone-item input[type=color].dot { width: 22px; height: 22px; padding: 0; border: 1px solid var(--line); border-radius: 50%; cursor: pointer; background: none; }
.zone-item input[type=color].dot::-webkit-color-swatch-wrapper { padding: 0; }
.zone-item input[type=color].dot::-webkit-color-swatch { border: 0; border-radius: 50%; }

/* ---- usage ---- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin: 16px 0 20px; }
.tile { background: var(--card, #fff); border: 1px solid var(--line, #e3e8ee); border-radius: 10px; padding: 12px 14px; }
.tile .k { display: block; font-size: 12px; color: var(--muted, #6b7785); text-transform: uppercase; letter-spacing: .04em; }
.tile .v { display: block; font-size: 24px; font-weight: 800; margin-top: 2px; }
.tile .s { display: block; font-size: 12px; color: var(--muted, #6b7785); }
.tile.over .v { color: #c62828; }
.plan-form { margin-top: 16px; padding: 16px; border: 1px solid var(--line, #e3e8ee); border-radius: 10px; background: var(--card, #fff); }
.plan-form .grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px 16px; margin-bottom: 12px; }
.plan-form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.plan-form input, .plan-form select { padding: 7px 9px; border: 1px solid var(--line, #cfd6de); border-radius: 6px; font: inherit; }
.who .switch { padding: 4px 8px; border-radius: 999px; border: 1px solid rgba(255,255,255,.4); background: rgba(255,255,255,.12); color: inherit; font: inherit; font-size: 13px; }
.who .switch option { color: #222; }

/* ---- allowance bars ---- */
.allowance { background: var(--card, #fff); border: 1px solid var(--line, #e3e8ee); border-radius: 10px; padding: 14px 16px; margin: 12px 0; }
.allowance .bar { height: 14px; border-radius: 999px; background: #e9eef3; overflow: hidden; margin: 8px 0 6px; }
.allowance .bar i { display: block; height: 100%; width: 0; background: #478A33; border-radius: 999px; transition: width .4s; }
.allowance .bar i.warn { background: #e0a100; }
.allowance .bar i.over { background: #c62828; }
.table .bar { display: inline-block; width: 110px; height: 10px; border-radius: 999px; background: #e9eef3; overflow: hidden; vertical-align: middle; margin-right: 6px; }
.table .bar i { display: block; height: 100%; background: #478A33; }
.table .bar i.warn { background: #e0a100; }
.table .bar i.over { background: #c62828; }
.plan-form .big { font-size: 20px; padding-top: 4px; }
