/* Korlap console. Same palette as the phone (android ui/theme/Theme.kt). Desktop first,
   usable at half a 1366 px screen (683 px), where the nav becomes a top bar. */
:root {
  --primary: #1F5FAD;
  --ink: #111827;
  --muted: #4B5563;
  --line: #D1D5DB;
  --soft: #E5E7EB;
  --bg: #F3F4F6;
  --surface: #FFFFFF;
  --ok: #15803D;
  --ok-soft: #DCFCE7;
  --warn: #B45309;
  --warn-soft: #FEF3C7;
  --danger: #B91C1C;
  --danger-soft: #FEE2E2;
  --sim-bg: #FFEDD5;
  --sim-fg: #9A3412;
  --radius: 8px;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
  display: grid;
  grid-template-columns: 200px 1fr;
  min-height: 100vh;
}
body:not(.login-page) { background: linear-gradient(to right, var(--ink) 200px, var(--bg) 200px); }
h1, h2 { margin: 0; line-height: 1.2; }
h1 { font-size: 22px; display: flex; align-items: center; gap: 8px; }
h2 { font-size: 16px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.strong { font-weight: 600; }
.r { text-align: right; }
[hidden] { display: none !important; }

/* Nav */
.nav {
  background: var(--ink); color: #F9FAFB; display: flex; flex-direction: column;
  padding: 16px 12px; gap: 16px; position: sticky; top: 0; height: 100vh; align-self: start;
}
.brand { display: flex; flex-direction: column; padding: 0 8px; }
.brand-name { font-weight: 700; }
.brand-sub { font-size: 12px; color: #9CA3AF; }
.nav nav { display: flex; flex-direction: column; gap: 2px; }
.nav nav a {
  color: #E5E7EB; text-decoration: none; padding: 9px 10px; border-radius: 6px;
  display: flex; align-items: center; justify-content: space-between; font-weight: 500;
}
.nav nav a:hover { background: #1F2937; }
.nav nav a.on { background: var(--primary); color: #fff; }
.nav-foot { margin-top: auto; display: flex; flex-direction: column; gap: 6px; padding: 0 8px; font-size: 13px; }
.who { color: #D1D5DB; }
button.link { background: none; border: 0; color: #9CA3AF; padding: 0; cursor: pointer; font: inherit; text-decoration: underline; }

.count { min-width: 22px; height: 22px; padding: 0 7px; border-radius: 11px; font-size: 12px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center; }
.badge { background: var(--danger); color: #fff; }
.muted-count { background: #374151; color: #E5E7EB; }
.badge.pulse { animation: pulse 1.2s ease-out 3; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(185, 28, 28, .7); transform: scale(1); }
  30% { transform: scale(1.25); }
  100% { box-shadow: 0 0 0 12px rgba(185, 28, 28, 0); transform: scale(1); }
}

.live { display: inline-flex; align-items: center; gap: 6px; color: #9CA3AF; }
.live i { width: 8px; height: 8px; border-radius: 50%; background: #6B7280; }
.live.on i { background: #22C55E; box-shadow: 0 0 0 0 rgba(34, 197, 94, .6); animation: live 2s infinite; }
.live.poll i { background: #F59E0B; }
.live.on b::after { content: ""; }
.live.poll b::after { content: " (polling)"; font-weight: 400; }
@keyframes live { 0% { box-shadow: 0 0 0 0 rgba(34,197,94,.6); } 100% { box-shadow: 0 0 0 8px rgba(34,197,94,0); } }

/* Main */
main { padding: 20px 24px 40px; min-width: 0; position: relative; }
.sim { position: absolute; top: 10px; right: 16px; background: var(--sim-bg); color: var(--sim-fg);
  font-size: 11px; font-weight: 700; letter-spacing: .06em; padding: 3px 8px; border-radius: 4px; }
.page-head { margin-bottom: 16px; display: flex; flex-direction: column; gap: 6px; }
.page-head p { margin: 0; max-width: 70ch; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; max-width: 560px; }

.tag { display: inline-block; font-size: 12px; font-weight: 600; padding: 1px 7px; border-radius: 4px; white-space: nowrap; }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.danger { background: var(--danger-soft); color: var(--danger); }
.notice { padding: 8px 12px; border-radius: 6px; margin: 4px 0; }
.notice.ok { background: var(--ok-soft); color: var(--ok); }
.notice.warn { background: var(--warn-soft); color: var(--warn); }
.notice.danger { background: var(--danger-soft); color: var(--danger); }
.lvl { color: var(--c); font-weight: 600; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; border: 1.5px solid transparent; vertical-align: -1px; }

/* Controls */
button, select, input { font: inherit; }
button { border-radius: 6px; padding: 7px 14px; border: 1px solid transparent; cursor: pointer; font-weight: 600; }
button.primary { background: var(--primary); color: #fff; }
button.secondary { background: var(--surface); color: var(--ink); border-color: var(--line); }
button.ok { background: var(--ok); color: #fff; }
button.danger { background: var(--danger); color: #fff; }
button:hover { filter: brightness(1.08); }
select, input { border: 1px solid var(--line); border-radius: 6px; padding: 7px 9px; background: var(--surface); color: var(--ink); }

/* Tables */
table.grid { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.grid th, .grid td { padding: 9px 12px; border-bottom: 1px solid var(--soft); text-align: left; vertical-align: middle; }
.grid th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: #F9FAFB; }
.grid th.r, .grid td.r { text-align: right; }
.grid tbody tr:last-child td { border-bottom: 0; }
tr.unassigned td:first-child { box-shadow: inset 3px 0 0 var(--warn); }
tr.just { animation: flash 2.5s ease-out; }
@keyframes flash { from { background: #DBEAFE; } to { background: transparent; } }
.assign { display: inline-flex; gap: 6px; margin-right: 6px; }
.progress { width: 90px; height: 6px; background: var(--soft); border-radius: 3px; display: inline-block; vertical-align: middle; margin-right: 6px; overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--primary); }

/* W5 */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; display: flex; flex-direction: column; }
.stat .label { font-size: 13px; color: var(--muted); }
.stat b { font-size: 22px; }
.stat .sub { font-size: 12px; color: var(--muted); }
.bars { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 16px; display: flex; flex-direction: column; gap: 8px; }
.bars-legend { display: flex; gap: 16px; flex-wrap: wrap; }
.sw { display: inline-block; width: 12px; height: 10px; border-radius: 2px; margin-right: 4px; vertical-align: -1px; }
.sw.target, .bar .target { background: #CBD5E1; }
.sw.est, .bar .est { background: var(--primary); }
.bar-row { display: grid; grid-template-columns: 150px 1fr 130px; gap: 10px; align-items: center; border-radius: 6px; padding: 2px 4px; }
.bar-label { font-weight: 600; display: flex; gap: 6px; align-items: center; }
.bar { position: relative; height: 18px; background: #F8FAFC; border-radius: 3px; }
.bar i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 3px; transition: width .8s ease; }
.bar .est { top: 4px; bottom: 4px; }
.bar-num { font-variant-numeric: tabular-nums; text-align: right; font-size: 14px; }
.delta { margin-left: 6px; color: var(--ok); font-weight: 700; }
.changed { background: #ECFDF5; box-shadow: inset 3px 0 0 var(--ok); }
tr.kosong td:first-child { box-shadow: inset 3px 0 0 var(--danger); }
td { font-variant-numeric: tabular-nums; }

/* W3 */
body[data-page="peta"] main { padding: 0; height: 100vh; }
/* Top centre: the map tools sit left and the zoom buttons right. */
body[data-page="peta"] .sim { z-index: 3; right: auto; left: 50%; transform: translateX(-50%); }
.map-page { display: grid; grid-template-columns: 1fr 320px; height: 100%; }
.map-wrap { position: relative; min-height: 400px; }
#map { position: absolute; inset: 0; background: #f2efe9; }
.map-tools { position: absolute; top: 12px; left: 12px; display: flex; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; z-index: 2; }
.map-tools button { border-radius: 0; background: none; color: var(--ink); font-weight: 500; padding: 7px 12px; border: 0; border-right: 1px solid var(--line); }
.map-tools button:last-child { border-right: 0; }
.map-tools button.on { background: var(--primary); color: #fff; }
.legend { position: absolute; left: 12px; bottom: 28px; background: rgba(255,255,255,.95); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; display: flex; flex-direction: column; gap: 3px; font-size: 12px; z-index: 2; }
.legend span { display: flex; align-items: center; gap: 6px; }
.ramp { display: inline-block; width: 60px; height: 8px; border-radius: 4px; background: linear-gradient(90deg, rgba(31,95,173,.1), #1F5FAD, #F59E0B, #B91C1C); }
.map-error { position: absolute; top: 56px; left: 12px; background: var(--warn-soft); color: var(--warn); padding: 6px 10px; border-radius: 6px; font-size: 13px; z-index: 2; }
.feed { background: var(--surface); border-left: 1px solid var(--line); padding: 16px; overflow-y: auto; }
.feed h2 { margin-bottom: 8px; }
.activity { list-style: none; margin: 0; padding: 0; }
.activity li { display: grid; grid-template-columns: 44px 1fr; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--soft); font-size: 14px; }
.activity li.new { animation: flash 2.5s ease-out; }
.activity time { color: var(--muted); font-variant-numeric: tabular-nums; }
.activity .tag { margin-left: 4px; }
.pulse-ring { width: 18px; height: 18px; border-radius: 50%; border: 3px solid var(--primary); animation: ring 1.6s ease-out 2; pointer-events: none; }
@keyframes ring { 0% { transform: scale(.4); opacity: 1; } 100% { transform: scale(3.2); opacity: 0; } }

/* W4 */
.cards { display: flex; flex-direction: column; gap: 14px; max-width: 980px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.card.fresh { animation: arrive 3s ease-out; border-color: var(--warn); }
@keyframes arrive { 0% { box-shadow: 0 0 0 4px rgba(245, 158, 11, .6); background: #FFFBEB; } 100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0); } }
.card > header { display: flex; justify-content: space-between; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--soft); }
.card > header p { margin: 2px 0 0; }
.rules { display: flex; gap: 6px; flex-wrap: wrap; align-items: flex-start; }
.card-body { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 14px; padding: 14px; }
.card-body > .photos, .card-body > .minimap { grid-column: 1; }
.card-body > .facts { grid-column: 2; grid-row: 1 / span 2; }
.minimap { margin: 0; }
.minimap-canvas { height: 190px; border-radius: 6px; overflow: hidden; background: #f2efe9; border: 1px solid var(--soft); }
.minimap figcaption { margin-top: 6px; }
.photos { display: flex; gap: 10px; }
.photos figure { margin: 0; flex: 1; }
.photos img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 6px; border: 1px solid var(--soft); display: block; background: var(--soft); }
.photos figcaption { font-size: 12px; color: var(--muted); margin-top: 4px; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0; font-size: 14px; align-content: start; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.card > footer { display: flex; justify-content: flex-end; gap: 10px; padding: 10px 14px; background: #F9FAFB; border-top: 1px solid var(--soft); flex-wrap: wrap; }
.card .reject { display: flex; gap: 6px; }
.card.leaving { transition: opacity .4s, transform .4s; opacity: 0; transform: translateX(24px); }
.empty { padding: 24px; text-align: center; }

/* Toasts */
#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 10; }
.toast { background: var(--ink); color: #fff; padding: 10px 14px; border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.2); font-size: 14px; max-width: 340px; animation: toast-in .25s ease-out; }
.toast.warn { background: var(--warn); }
@keyframes toast-in { from { transform: translateY(10px); opacity: 0; } }

/* Login */
body.login-page { display: flex; align-items: center; justify-content: center; }
.login { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 28px; width: min(380px, 92vw); display: flex; flex-direction: column; gap: 14px; }
.login p { margin: 0; }
.login label { display: flex; flex-direction: column; gap: 4px; font-weight: 500; font-size: 14px; }
.login .error { color: var(--danger); background: var(--danger-soft); padding: 8px 10px; border-radius: 6px; }

/* Half of a 1366 px screen */
@media (max-width: 900px) {
  body { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  body:not(.login-page) { background: var(--bg); }
  .nav { height: auto; position: sticky; flex-direction: row; align-items: center; padding: 8px 10px; gap: 10px; z-index: 5; flex-wrap: wrap; }
  .brand-sub { display: none; }
  .nav nav { flex-direction: row; gap: 2px; flex-wrap: wrap; }
  .nav nav a { padding: 6px 8px; gap: 6px; }
  .nav-foot { margin: 0 0 0 auto; flex-direction: row; align-items: center; gap: 10px; }
  .who { display: none; }
  main { padding: 14px 12px 32px; }
  body[data-page="peta"] main { height: calc(100vh - 52px); }
  .map-page { grid-template-columns: 1fr; grid-template-rows: 1fr 210px; }
  .feed { border-left: 0; border-top: 1px solid var(--line); }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bar-row { grid-template-columns: 110px 1fr 92px; }
  .bar-label { flex-wrap: wrap; gap: 2px 6px; }
  .bar-label .tag { font-size: 11px; }
  .card-body { grid-template-columns: 1fr; }
  .card-body > .facts { grid-column: 1; grid-row: auto; }
  .grid th, .grid td { padding: 7px 8px; }
  table.tps .small { display: none; }
  /* Kontak and Prioritas drop out; the order already shows priority. */
  table.tps th:nth-child(4), table.tps td:nth-child(4),
  table.tps th:nth-child(8), table.tps td:nth-child(8) { display: none; }
  table.tps td:first-child .tag { display: block; width: max-content; margin-top: 2px; }
  table.turfs td:nth-child(2), table.turfs th:nth-child(2) { display: none; }
}

/* W6 Demo */
.demo-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; align-items: start; max-width: 1100px; }
.demo-grid .panel { max-width: none; display: flex; flex-direction: column; gap: 10px; }
.demo-grid .panel p { margin: 0; }
.qr-panel { grid-row: span 2; }
.qr { background: #fff; align-self: center; padding: 6px; }
.qr svg { display: block; width: min(300px, 70vw); height: auto; }
.link-row { display: flex; gap: 6px; }
.link-row input { flex: 1; min-width: 0; font-size: 13px; }
a.button { display: inline-flex; align-items: center; border-radius: 6px; padding: 7px 14px; font-weight: 600; text-decoration: none; }
a.button.secondary { background: var(--surface); color: var(--ink); border: 1px solid var(--line); }
.tag.ok { background: var(--ok-soft); color: var(--ok); }
table.compact th, table.compact td { padding: 6px 8px; font-size: 14px; }
table.compact td:first-child { white-space: nowrap; }
