/* Era-aware themes: win95 (1993-99), xp (2000-08), flat (2009-16), rgb (2017+) */
:root {
  --font: Tahoma, "MS Sans Serif", Verdana, system-ui, sans-serif;
  --bg: #008080;
  --fg: #000;
  --muted: #404040;
  --panel: #c0c0c0;
  --inset: #fff;
  --radius: 0px;
  --title-bg: linear-gradient(90deg, #000080, #1084d0);
  --title-fg: #fff;
  --accent: #000080;
  --good: #006400;
  --bad: #b00000;
  --warn: #8a5a00;
  --btn: #c0c0c0;
  --btn-fg: #000;
  --bevel: inset -1px -1px #404040, inset 1px 1px #fff, inset -2px -2px #808080, inset 2px 2px #dfdfdf;
  --bevel-in: inset 1px 1px #404040, inset -1px -1px #fff, inset 2px 2px #808080, inset -2px -2px #dfdfdf;
  --box: var(--bevel);
  --scene: linear-gradient(#87ceeb 0 38%, #9a9a9a 38% 52%, #d8c9a0 52%);
  --sel: #000080;
  --sel-fg: #fff;
  --gap: 10px;
}
body[data-theme="xp"] {
  --font: "Trebuchet MS", "Segoe UI", Tahoma, system-ui, sans-serif;
  --bg: linear-gradient(#3a7bd5 0%, #8ec1f2 52%, #5cae3c 53%, #3a8a26 100%);
  --panel: #ece9d8;
  --radius: 8px;
  --title-bg: linear-gradient(#3d95ff, #0a5be0 45%, #0148c8);
  --accent: #0a4bd0;
  --btn: linear-gradient(#fff, #ece9d8 85%, #d6d0be);
  --bevel: 0 0 0 1px #003c9e, 0 2px 4px rgba(0, 0, 0, .35);
  --bevel-in: inset 0 0 0 1px #003c9e, inset 0 2px 5px rgba(0, 0, 0, .3);
  --box: 0 0 0 2px #0a4bd0, 0 4px 10px rgba(0, 0, 0, .35);
  --sel: #316ac5;
  --scene: linear-gradient(#a6d8ff 0 38%, #8c8c8c 38% 52%, #cfe8b0 52%);
}
body[data-theme="flat"] {
  --font: "Segoe UI", Roboto, "Helvetica Neue", system-ui, sans-serif;
  --bg: #e9edf2;
  --fg: #1b2330;
  --muted: #667085;
  --panel: #fff;
  --radius: 12px;
  --title-bg: transparent;
  --title-fg: #1b2330;
  --accent: #2d7ff9;
  --good: #16a34a;
  --bad: #dc2626;
  --warn: #b45309;
  --btn: #2d7ff9;
  --btn-fg: #fff;
  --bevel: 0 1px 2px rgba(16, 24, 40, .18);
  --bevel-in: inset 0 2px 4px rgba(16, 24, 40, .25);
  --box: 0 1px 3px rgba(16, 24, 40, .12), 0 1px 2px rgba(16, 24, 40, .08);
  --inset: #f3f5f8;
  --sel: #2d7ff9;
  --scene: linear-gradient(#cfe5ff 0 38%, #c9ced6 38% 52%, #f1ece0 52%);
}
body[data-theme="rgb"] {
  --font: "Inter", "Segoe UI", Roboto, system-ui, sans-serif;
  --bg: #090a12;
  --fg: #e8eaf6;
  --muted: #8b90b0;
  --panel: #14172a;
  --radius: 12px;
  --title-bg: linear-gradient(#1b1f38, #14172a);
  --title-fg: #fff;
  --accent: #19f0c4;
  --good: #3dff9a;
  --bad: #ff5577;
  --warn: #ffc14d;
  --btn: #1e2342;
  --btn-fg: #e8eaf6;
  --bevel: 0 0 0 1px #2d3566;
  --bevel-in: inset 0 0 0 1px #19f0c4;
  --box: 0 0 0 1px #262c55, 0 8px 24px rgba(0, 0, 0, .5);
  --inset: #0d0f1d;
  --sel: #19f0c4;
  --sel-fg: #00110d;
  --scene: linear-gradient(#171a40 0 38%, #22243a 38% 52%, #15162a 52%);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font: 14px/1.35 var(--font);
  color: var(--fg);
  background: var(--bg);
  background-attachment: fixed;
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: contain;
}
[hidden] { display: none !important; }
button, input, select { font: inherit; color: inherit; }
b { font-weight: 700; }
small { color: var(--muted); }
.money, .num { font-variant-numeric: tabular-nums; }
.good { color: var(--good); } .bad { color: var(--bad); } .warn { color: var(--warn); }

#app {
  display: flex; flex-direction: column; min-height: 100%;
  max-width: 980px; margin: 0 auto;
  padding: max(8px, env(safe-area-inset-top)) 8px calc(72px + env(safe-area-inset-bottom));
  gap: var(--gap);
}
main { display: flex; flex-direction: column; gap: var(--gap); }
.tab { display: flex; flex-direction: column; gap: var(--gap); }

/* Panels */
.panel, .card {
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: var(--box);
  overflow: hidden;
}
body[data-theme="xp"] .panel > .title { border-radius: 6px 6px 0 0; }
.panel > .title {
  background: var(--title-bg); color: var(--title-fg);
  padding: 4px 10px; font-weight: 700; display: flex; justify-content: space-between; align-items: center; gap: 8px;
  min-height: 26px;
}
body[data-theme="xp"] .panel > .title { text-shadow: 1px 1px 0 rgba(0, 0, 0, .4); }
body[data-theme="flat"] .panel > .title { padding-top: 10px; font-size: 15px; }
body[data-theme="rgb"] .panel > .title { border-bottom: 2px solid transparent; border-image: linear-gradient(90deg, #ff3d81, #ffb02e, #19f0c4, #4d7cff, #ff3d81) 1; }
.pbody { padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.era { font-weight: 400; font-size: 12px; opacity: .9; text-align: right; }

/* Header */
#top .topbody { display: flex; gap: 10px; padding: 8px 10px; align-items: flex-end; flex-wrap: wrap; }
.stat { display: flex; flex-direction: column; min-width: 0; }
.stat.grow { flex: 1; }
.stat small { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }
.stat b { font-size: 16px; white-space: nowrap; }
#cash { font-size: 26px; line-height: 1.1; color: var(--good); }
body[data-theme="win95"] #cash { font-family: "Courier New", monospace; background: #000; color: #3f3; padding: 0 8px; box-shadow: var(--bevel-in); }
#ticker { background: var(--inset); color: var(--fg); padding: 3px 8px; overflow: hidden; white-space: nowrap; font-size: 12px; box-shadow: var(--bevel-in); }
body[data-theme="flat"] #ticker, body[data-theme="rgb"] #ticker { box-shadow: none; border-top: 1px solid rgba(128, 128, 160, .25); }
#tickerText { display: inline-block; padding-left: 100%; animation: tick 28s linear infinite; }
@keyframes tick { to { transform: translateX(-100%); } }

/* Buttons & inputs */
button {
  background: var(--btn); color: var(--btn-fg); border: 0; border-radius: var(--radius);
  box-shadow: var(--bevel); padding: 8px 12px; min-height: 40px; cursor: pointer; font-weight: 600;
}
body[data-theme="win95"] button { font-weight: 400; border: 1px solid #000; }
button:active:not(:disabled) { box-shadow: var(--bevel-in); transform: translateY(1px); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.primary { background: var(--accent); color: var(--sel-fg, #fff); }
body[data-theme="win95"] button.primary { background: var(--btn); color: #000; font-weight: 700; }
button.danger { background: #b3202f; color: #fff; }
button.small { min-height: 32px; padding: 4px 10px; font-size: 13px; }
input[type=text], input[type=search], textarea, select {
  background: #fff; color: #000; border: 0; padding: 8px; border-radius: var(--radius); box-shadow: var(--bevel-in); min-height: 38px; width: 100%;
}
body[data-theme="rgb"] input[type=text], body[data-theme="rgb"] input[type=search], body[data-theme="rgb"] textarea, body[data-theme="rgb"] select { background: #0d0f1d; color: #e8eaf6; }
textarea { min-height: 120px; font-family: monospace; font-size: 12px; }
input[type=range] { width: 100%; accent-color: var(--accent); height: 28px; }

/* Shop scene */
.scene { position: relative; height: 150px; background: var(--scene); overflow: hidden; }
.street { position: absolute; left: 0; right: 0; top: 52px; height: 50px; }
.walker { position: absolute; bottom: 0; left: -40px; font-size: 30px; animation: walk 3.4s linear forwards; }
.walker.buy::after { content: "💲"; position: absolute; top: -14px; left: 6px; font-size: 16px; animation: pop 1s ease-out forwards; }
@keyframes walk { to { left: calc(100% + 10px); } }
@keyframes pop { from { transform: translateY(6px); opacity: 0; } 30% { opacity: 1; } to { transform: translateY(-8px); opacity: 0; } }
.shopfront { position: absolute; left: 6px; right: 6px; bottom: 0; height: 56px; padding: 6px 8px; background: rgba(0, 0, 0, .35); color: #fff; display: flex; flex-wrap: wrap; align-content: flex-start; gap: 0 2px; font-size: 17px; line-height: 1.1; overflow: hidden; border-radius: var(--radius) var(--radius) 0 0; }
.shopfront .empty { font-size: 13px; opacity: .85; align-self: center; }
.sign { position: absolute; top: 4px; left: 8px; right: 8px; text-align: center; font-weight: 700; font-size: 15px; color: #fff; text-shadow: 0 1px 3px rgba(0, 0, 0, .8); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#hustle { position: relative; min-height: 64px; font-size: 18px; overflow: hidden; }
#hustle .hbar { position: absolute; left: 0; bottom: 0; height: 5px; background: var(--accent); width: 0; }
.float { position: absolute; pointer-events: none; font-weight: 700; color: var(--good); animation: floatup 1.2s ease-out forwards; text-shadow: 0 0 3px #000; z-index: 5; }
@keyframes floatup { to { transform: translateY(-46px); opacity: 0; } }

.alert { padding: 8px 10px; border-radius: var(--radius); background: var(--inset); box-shadow: var(--bevel-in); }
.alert.bad { color: var(--bad); font-weight: 700; } .alert.warn { color: var(--warn); font-weight: 700; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.mini { background: var(--inset); padding: 6px 8px; border-radius: var(--radius); box-shadow: var(--bevel-in); display: flex; flex-direction: column; }
.mini small { font-size: 11px; } .mini b { font-size: 15px; }
#log { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; font-size: 13px; min-height: 20px; }
#log li { display: flex; justify-content: space-between; gap: 8px; }
#log li span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Cards */
.list { display: flex; flex-direction: column; gap: var(--gap); }
.card { display: grid; grid-template-columns: 44px 1fr; gap: 4px 10px; padding: 10px; }
.card .icon { font-size: 34px; line-height: 1; text-align: center; padding-top: 2px; }
.card > .info:only-child { grid-column: 1 / -1; }
.card .info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.card .info b { overflow-wrap: anywhere; }
.card .acts { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.card .acts button { flex: 1 1 64px; }
.card .acts .grow { flex: 2 1 120px; }
.nums { display: flex; flex-wrap: wrap; gap: 2px 12px; font-size: 13px; }
.tags { display: flex; gap: 4px; flex-wrap: wrap; }
.tag { font-size: 11px; padding: 0 6px; border-radius: var(--radius); background: var(--inset); box-shadow: var(--bevel-in); }
.tag.new { background: #ffd23f; color: #000; font-weight: 700; }
.stepper { display: flex; align-items: center; gap: 6px; flex: 2 1 150px; justify-content: space-between; }
.card .acts .stepper button, .stepper button { flex: 0 0 44px; min-width: 44px; padding: 4px; }
.stepper b { min-width: 28px; text-align: center; }
.stepper .lbl { font-size: 12px; color: var(--muted); flex: 1; line-height: 1.15; }
.bar { height: 8px; background: var(--inset); box-shadow: var(--bevel-in); border-radius: var(--radius); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); width: 0; }
.lockedcard .icon { opacity: .6; }              /* text stays at full contrast in every skin; the lock icon marks it */
.lockedcard .info small, .lockedcard .info b { color: var(--fg); }
h2.sec { margin: 8px 2px 0; font-size: 14px; color: var(--title-fg); text-shadow: 0 1px 2px rgba(0, 0, 0, .6); }
body[data-theme="flat"] h2.sec, body[data-theme="web2"] h2.sec { color: var(--fg); text-shadow: none; }

.field { display: flex; flex-direction: column; gap: 3px; }
.field label { font-size: 12px; color: var(--muted); display: flex; justify-content: space-between; }
.row { display: flex; gap: 8px; flex-wrap: wrap; } .row > * { flex: 1 1 140px; }
.empty-note { padding: 14px; text-align: center; color: var(--muted); }

/* Nav */
#nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; justify-content: center;
  padding: 4px 6px calc(4px + env(safe-area-inset-bottom)); gap: 4px; background: var(--panel); box-shadow: 0 -2px 10px rgba(0, 0, 0, .35);
}
#nav button { flex: 1 1 0; max-width: 150px; display: flex; flex-direction: column; align-items: center; gap: 0; padding: 4px 2px; min-height: 52px; position: relative; font-size: 12px; }
#nav button i { font-style: normal; font-size: 21px; line-height: 1.1; }
#nav button.on { box-shadow: var(--bevel-in); background: var(--inset); color: var(--accent); }
#nav em { position: absolute; top: 2px; right: 8px; background: #e22; color: #fff; font-style: normal; font-size: 11px; font-weight: 700; border-radius: 9px; padding: 0 5px; }

@media (min-width: 760px) {
  #app { padding-bottom: 16px; }
  #nav { position: static; order: 2; background: transparent; box-shadow: none; padding: 0; justify-content: flex-start; }
  #nav button { flex-direction: row; gap: 6px; max-width: none; flex: 0 0 auto; padding: 4px 16px; min-height: 40px; background: var(--btn); }
  #nav button.on { background: var(--inset); }
  main { order: 3; }
  #nav em { position: static; }
  .list.two { display: grid; grid-template-columns: 1fr 1fr; }
  .scene { height: 190px; } .street { top: 70px; }
  .shopfront { height: 78px; font-size: 20px; }
}

/* Toasts & modal */
#toasts { position: fixed; top: max(8px, env(safe-area-inset-top)); left: 8px; right: 8px; z-index: 60; display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; }
.toast { pointer-events: auto; max-width: 480px; width: 100%; background: var(--panel); color: var(--fg); padding: 10px 12px; border-radius: var(--radius); box-shadow: var(--box); border-left: 5px solid var(--accent); animation: tin .25s ease-out; }
.toast.out { opacity: 0; transition: opacity .4s; }
@keyframes tin { from { transform: translateY(-12px); opacity: 0; } }
#modal { position: fixed; inset: 0; background: rgba(0, 0, 0, .6); z-index: 80; display: flex; align-items: center; justify-content: center; padding: 12px; }
#modal .panel { width: 100%; max-width: 520px; max-height: 92vh; display: flex; flex-direction: column; }
#modal .pbody { overflow: auto; }
#modal .btns { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; padding: 0 10px 10px; }
#modal .btns button { flex: 1 1 100px; }
table.rep { width: 100%; border-collapse: collapse; } table.rep td { padding: 2px 0; } table.rep td:last-child { text-align: right; font-weight: 700; }
.ach { display: flex; gap: 8px; align-items: center; padding: 3px 0; } .ach.locked { opacity: .45; }
.menu-btns { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; }

/* Account pages & misc */
.authwrap { justify-content: center; min-height: 100vh; padding-bottom: 20px; }
.authbox { max-width: 420px; width: 100%; margin: 0 auto; }
.authbox a, .pbody a { color: var(--accent); }
body[data-theme="win95"] .authbox a, body[data-theme="win95"] .pbody a { color: #0000c0; }
.authbox hr { border: 0; border-top: 1px solid rgba(128, 128, 128, .5); width: 100%; }
.authbox .list { gap: 8px; }
input[type=password] { background: #fff; color: #000; border: 0; padding: 8px; border-radius: var(--radius); box-shadow: var(--bevel-in); min-height: 38px; width: 100%; }
.btnlink { display: flex; align-items: center; justify-content: center; text-align: center; background: var(--btn); color: var(--btn-fg) !important; border-radius: var(--radius); box-shadow: var(--bevel); padding: 8px 12px; min-height: 40px; text-decoration: none; font-weight: 600; }
body[data-theme="win95"] .btnlink { font-weight: 400; border: 1px solid #000; }
label.check { display: flex; gap: 8px; align-items: center; min-height: 32px; }
label.check input { width: 20px; height: 20px; accent-color: var(--accent); }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chips button { flex: 1 1 90px; min-height: 36px; padding: 4px 8px; font-size: 13px; }
.chips button.on { box-shadow: var(--bevel-in); background: var(--inset); color: var(--accent); }

/* List filters */
.ftools { display: flex; flex-direction: column; gap: 6px; }
.frow { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.frow > small { min-width: 38px; }
.frow .fsel { flex: 1 1 140px; }
.fsel { display: flex; flex-direction: column; gap: 2px; }
.fsel select { min-height: 34px; padding: 4px 8px; }
.fchips { flex: 1 1 auto; }
.fchips button { min-height: 32px; font-size: 13px; flex: 1 1 60px; }
.ftools > .chips { margin: 0; }
h2.sec[hidden] { display: none; }

/* Buyers */
#nav button span { font-size: 11px; }
@media (max-width: 440px) { #nav { gap: 2px; padding-left: 2px; padding-right: 2px; } #nav button { padding: 4px 0; } #nav button span { font-size: 10px; } #nav button i { font-size: 19px; } }
.mgr .pbody { gap: 10px; }
.mgHead { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.mgh { margin: 6px 0 0; font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.mgSkill { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; padding: 4px 0; }
.mgSkill .bar { margin: 3px 0; }
.mgp { display: grid; grid-template-columns: 1fr auto; gap: 0 10px; padding: 4px 0; border-bottom: 1px solid rgba(128, 128, 128, .25); }
.mgp .mgpn { font-weight: 600; overflow-wrap: anywhere; }
.mgp .mgpv { text-align: right; font-weight: 700; }
.mgp .mgpt { grid-column: 1 / -1; font-size: 12px; color: var(--muted); }
details.mgd { background: var(--inset); border-radius: var(--radius); box-shadow: var(--bevel-in); }
details.mgd summary { cursor: pointer; padding: 10px; font-weight: 700; min-height: 40px; }
.mgdb { display: flex; flex-direction: column; gap: 10px; padding: 0 10px 10px; }
.mc .mcreq { color: var(--warn); }
.mgChips, .mcchips { gap: 4px; }
.mcchips button { flex: 0 1 auto; min-height: 30px; padding: 2px 8px; font-size: 12px; }
.mcchips button.on { background: var(--bad); color: #fff; box-shadow: var(--bevel-in); }
[data-mc$=":groups"].mcchips button.on, [data-mc$=":platforms"].mcchips button.on { background: var(--accent); color: var(--sel-fg, #fff); }
.mgLog { margin: 0; padding-left: 18px; font-size: 13px; display: flex; flex-direction: column; gap: 3px; }
.mgrow { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; flex: 2 1 220px; }
.mgrow .mginfo { flex: 1 1 100%; font-size: 13px; }
.mgrow button { flex: 1 1 100px; }
.mgCands .cst { gap: 10px; }

/* Advisor */
#advisor .advsec { display: flex; flex-direction: column; gap: 6px; }
#advisor .advh { font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
#advIns { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
#advIns li { display: flex; gap: 8px; align-items: flex-start; font-size: 13.5px; }
#advIns li > span:first-child { flex: 0 0 22px; text-align: center; }
#advIns li.adv-warn { color: var(--warn); }
#advIns li.adv-bad { color: var(--bad); font-weight: 600; }
#advIns li.adv-good { color: var(--good); }
.card.rec { grid-template-columns: 40px 1fr; padding: 8px; }
.card.rec .rci { font-size: 28px; }
.card.rec .rwhy { overflow-wrap: anywhere; }
.advnote { opacity: .8; }

/* Console market */
.cmrow { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; padding: 4px 0; border-bottom: 1px solid rgba(128, 128, 128, .25); font-size: 13px; }
.cmrow .cmn { font-weight: 700; }
.cmrow .cmst { text-align: right; font-size: 12px; }
.cmrow .cmbar { grid-column: 1 / -1; }
.cmrow .cmv { grid-column: 1 / -1; font-size: 12px; color: var(--muted); }

/* Collapsible buyers */
.mgr .title { gap: 8px; }
.mgTitleR { display: flex; align-items: center; gap: 8px; min-width: 0; }
.mgTitleR .mgName { font-weight: 400; font-size: 12px; opacity: .9; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mgtoggle { min-height: 28px; min-width: 32px; padding: 2px 6px; }
.mgr.collapsed .pbody { display: none; }
.mgSummary { padding: 8px 10px; font-size: 13px; }
.mgAll { gap: 6px; } .mgAll button { flex: 1 1 100px; }
.tag.t-auto { background: #c8e6ff; color: #000; }
.clog { margin: 4px 0 8px 18px; padding: 0; } .clog li { margin: 2px 0; }

/* Era 1: green-screen terminal */
body[data-theme="terminal"] {
  --font: "Courier New", ui-monospace, monospace;
  --bg: #000; --fg: #33ff66; --muted: #1fa545; --panel: #06140a; --inset: #000;
  --radius: 0px; --title-bg: #0b3d1a; --title-fg: #33ff66; --accent: #33ff66;
  --good: #33ff66; --bad: #ff5555; --warn: #ffb000; --btn: #0b2a14; --btn-fg: #33ff66;
  --bevel: 0 0 0 1px #33ff66; --bevel-in: inset 0 0 0 1px #1fa545; --box: 0 0 0 1px #33ff66;
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---- Dial-Up Dynasty game UI ---- */
.hactions { display: flex; gap: 8px; flex-wrap: wrap; }
.hactions button.big { flex: 1 1 140px; padding: 14px 10px; font-size: 1.05em; }
.hactions button small { opacity: .8; }
.alert-btn { outline: 3px solid var(--bad); }
.meter { display: grid; grid-template-columns: 90px 1fr; gap: 2px 8px; align-items: center; margin: 6px 0; }
.meter .mlabel { font-weight: bold; }
.meter .mval { grid-column: 2; font-size: .85em; color: var(--muted); }
.rack { display: flex; flex-wrap: wrap; gap: 2px; padding: 6px; background: var(--inset); box-shadow: var(--bevel-in); min-height: 34px; }
.pt { font-style: normal; width: 16px; height: 16px; line-height: 16px; text-align: center; font-size: 11px; border: 1px solid var(--muted); }
.pt.on { color: #0a0; border-color: #0a0; } .pt.busy { color: #c80; border-color: #c80; } .pt.fault { color: #d00; border-color: #d00; } .pt.idle { opacity: .45; }
body[data-theme="terminal"] .pt.on { color: #33ff66; border-color: #33ff66; text-shadow: 0 0 4px #33ff66; }
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: .8em; margin: 4px 0; }
.rackclock { color: var(--muted); }
#log li.log-bad span:first-child { color: var(--bad); } #log li.log-good span:first-child { color: var(--good); }
#advIns li { display: flex; gap: 8px; margin: 6px 0; list-style: none; }
.alert.warn { border-left: 4px solid var(--warn); }
.toast.bad { border-color: var(--bad); }
@media (max-width: 520px) { .meter { grid-template-columns: 1fr; } .meter .mval { grid-column: 1; } }
.decisions .dec { border-bottom: 1px dashed var(--muted); padding: 6px 0; }
.decisions .dec:last-child { border-bottom: 0; }
.decisions .dec p { margin: 4px 0 8px; }
.decisions .btns { display: flex; gap: 8px; flex-wrap: wrap; }
.mgr .row { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin: 6px 0; flex-wrap: wrap; }
.mgr .chips button.on, .row button.on { box-shadow: var(--bevel-in); font-weight: bold; }
@media (max-width: 520px) { #nav button { font-size: 10.5px; } #nav button i { font-size: 18px; } }

/* Era 4: glossy Web 2.0 */
body[data-theme="web2"] {
  --font: "Lucida Grande", "Segoe UI", Verdana, system-ui, sans-serif;
  --bg: linear-gradient(#eef5fd, #c3d7ee);
  --fg: #1d2733; --muted: #5a6b7d;
  --panel: linear-gradient(#ffffff, #eef3f9);
  --radius: 10px;
  --title-bg: linear-gradient(#78b0ea, #2f6fb9 50%, #255d9e 51%, #3b7dc7);
  --title-fg: #fff; --accent: #1d6fd1;
  --good: #157a32; --bad: #c62828; --warn: #a15c00;
  --btn: linear-gradient(#ffffff, #dfe8f3 50%, #cfdbea 51%, #e6eef7); --btn-fg: #17212c;
  --bevel: 0 0 0 1px #8fa6c2, 0 1px 3px rgba(0, 0, 0, .25);
  --bevel-in: inset 0 1px 3px rgba(0, 0, 0, .3), 0 0 0 1px #8fa6c2;
  --box: 0 0 0 1px #7e97b6, 0 3px 8px rgba(30, 60, 100, .3);
  --inset: #fff; --sel: #2f6fb9;
}
body[data-theme="web2"] .panel > .title { border-radius: 9px 9px 0 0; text-shadow: 0 -1px 0 rgba(0, 0, 0, .35); }
body[data-theme="web2"] button.primary { background: linear-gradient(#9fd0ff, #3a86e0 50%, #2c6fc4 51%, #4b95ea); color: #fff; text-shadow: 0 -1px 0 rgba(0, 0, 0, .35); }
.hactions button.big small { opacity: .8; }
.dec em { color: var(--bad); font-style: normal; }

/* ---- Meta layer: start screen, HQ, trophies ---- */
.logo { display: inline-block; width: 11px; height: 11px; border-radius: 3px; margin-right: 7px; vertical-align: baseline; }
#stColors { display: flex; gap: 8px; flex-wrap: wrap; }
#stColors .sw { width: 34px; height: 34px; padding: 0; border-radius: 6px; border: 2px solid transparent; }
#stColors .sw.on { outline: 3px solid var(--fg); }
label.check small { display: block; margin-left: 24px; color: var(--muted); font-weight: normal; }
.tgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; padding: 0 2px 8px; }
.trophy { padding: 8px; background: var(--panel); box-shadow: var(--bevel); opacity: .55; border-radius: var(--radius); }
.trophy.got, .trophy.now { opacity: 1; }
.trophy small { display: block; color: var(--muted); }
.card em { color: var(--warn); font-style: normal; }
@media (max-width: 520px) { #nav button { font-size: 9.5px; } #nav button i { font-size: 17px; } }

/* ---- Phase 6: accessibility and polish ---- */
.skip { position: absolute; left: -999px; top: 0; z-index: 100; background: #fff; color: #000; padding: 8px 12px; }
.skip:focus { left: 8px; top: 8px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
#coNameWrap { display: inline; margin: 0; font: inherit; }
#netState { padding: 6px 10px; background: var(--warn); color: #fff; font-size: .85em; }
#app, #modal .panel { zoom: var(--tscale, 1); }
#nav button { flex: 1 0 54px; }
.ftools { display: flex; flex-direction: row; gap: 6px; flex-wrap: wrap; margin: 6px 0 8px; align-items: center; }
.ftools input[type=search] { flex: 1 1 140px; min-width: 0; width: auto; height: 38px; }
.ftools select { flex: 1 1 110px; width: auto; min-width: 0; height: 38px; }
.rackbox { margin-bottom: 4px; }
@keyframes ptblink { 0%, 100% { opacity: 1; } 50% { opacity: .4; } }
@keyframes ptpulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.18); } }
.pt.on { animation: ptblink 2.4s ease-in-out infinite; }
.pt.busy { animation: ptpulse .9s ease-in-out infinite; }
.pt.fault { animation: ptpulse 1.6s ease-in-out infinite; }
body.reduce-motion *, body.reduce-motion *::before, body.reduce-motion *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
@media (prefers-reduced-motion: reduce) { .pt.on, .pt.busy, .pt.fault { animation: none; } }
@media (forced-colors: active) { .pt.on, .pt.busy, .pt.fault { border-width: 2px; } }

body[data-theme="terminal"] button.primary { color: #000; font-weight: 700; }
body[data-theme="terminal"] { --muted: #45c46f; }
body[data-theme="rgb"] button.danger { background: #b3203f; }
#nav > .tabrow { display: flex; gap: 4px; justify-content: center; width: 100%; overflow-x: auto; scrollbar-width: thin; }
#top .stat { min-width: 0; }
#cash { font-size: clamp(15px, 5.2vw, 22px); white-space: nowrap; }
@media (max-width: 420px) { #nav > .tabrow { gap: 2px; } #nav button { flex: 1 0 40px; padding: 4px 0; font-size: 9px; } #nav button i { font-size: 16px; } }

/* ---- More tab switcher, trend lines, first goals, welcome-back news ---- */
.subnav { display: flex; gap: 6px; margin: 0 0 10px; }
.subnav button { flex: 1 1 0; min-height: 40px; }
.trend { display: grid; grid-template-columns: 90px 1fr auto; align-items: center; gap: 10px; padding: 4px 0; }
.trend .tlabel { font-size: 13px; }
.trend .tval { display: flex; flex-direction: column; align-items: flex-end; font-size: 13px; }
.trend .tval small { font-size: 11.5px; }
.spark { width: 100%; height: 32px; display: block; color: var(--accent); overflow: visible; }
.bars { width: 100%; height: 90px; display: block; }
.bars-pos { fill: var(--good); }
.bars-neg { fill: var(--bad); }
.bars-zero { stroke: var(--muted); stroke-width: 1; }
.goals { list-style: none; margin: 0; padding: 0; }
.goals li { padding: 3px 0; }
.goals li.next { font-weight: 600; }
.goals li small { display: block; font-weight: 400; color: var(--muted); margin-left: 1.4em; }
.wbnews { list-style: none; margin: 0 0 8px; padding: 0; font-size: 13px; }
.wbnews li { padding: 2px 0; }
.wbnews li span { color: var(--muted); }
.rep tr.you td { font-weight: 700; }

/* ---- network page: map, utilisation bars, day chart, legacy dial-up ---- */
.nmap, .dayc { width: 100%; height: auto; display: block; margin: 4px 0; }
.nmap text, .dayc text { fill: var(--fg); font-family: var(--font); }
.nm-h { font-size: 10px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.nm-t { font-size: 11px; font-weight: 700; } .nm-s { font-size: 9.5px; }
.nm-node rect, .nm-node ellipse { fill: var(--inset); stroke: var(--fg); stroke-width: 1; }
.nm-node.warn rect { stroke: var(--warn); stroke-width: 2; } .nm-node.bad rect { stroke: var(--bad); stroke-width: 2; }
.nm-node .nm-bar { fill: var(--accent); stroke: none; } .nm-node.warn .nm-bar { fill: var(--warn); } .nm-node.bad .nm-bar { fill: var(--bad); }
.nm-flow { fill: none; stroke: var(--accent); stroke-linecap: round; stroke-dasharray: 5 7; animation: nmflow 1.1s linear infinite; }
.nm-flow.bad { stroke: var(--bad); }
@keyframes nmflow { to { stroke-dashoffset: -12; } }
@media (prefers-reduced-motion: reduce) { .nm-flow { animation: none; } }
.util { height: 8px; background: var(--inset); box-shadow: var(--bevel-in); margin: 2px 0 8px; }
.util i { display: block; height: 100%; background: var(--accent); } .util.warn i { background: var(--warn); } .util.bad i { background: var(--bad); }
.netplant { margin-bottom: 4px; }
.dc-line { fill: none; stroke: var(--accent); stroke-width: 1.5; } .dc-fill { fill: var(--accent); opacity: .18; }
.dc-cap { stroke: var(--good); stroke-width: 1.5; stroke-dasharray: 4 3; } .dc-cap.bad { stroke: var(--bad); }
.dc-now { stroke: var(--fg); stroke-width: 1; }
details.legacy { margin: 8px 0; } details.legacy > summary { cursor: pointer; padding: 8px 10px; background: var(--panel); box-shadow: var(--bevel); }

/* Overview: headline numbers, customer mix, compact service gauges, readable news */
.grid.hl { grid-template-columns: repeat(2, 1fr); } @media (min-width: 600px) { .grid.hl { grid-template-columns: repeat(4, 1fr); } }
.mix { display: flex; height: 12px; border-radius: 6px; overflow: hidden; background: var(--inset); }
.mix i { display: block; height: 100%; min-width: 2px; }
.mixkey { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; }
.mixkey i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; vertical-align: -1px; }
.t-dial { background: #8e8e93; } .t-dsl { background: #e0a030; } .t-cable { background: #3a9ad9; } .t-wisp { background: #b070d0; } .t-fiber { background: #2fbf71; }
.svcgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; }
.svcgrid .meter { grid-template-columns: 1fr; margin: 2px 0; } .svcgrid .meter .mval { grid-column: 1; }
@media (max-width: 380px) { .svcgrid { grid-template-columns: 1fr; } }
#log.news li { justify-content: flex-start; align-items: baseline; }
#log.news li > span:first-child { flex: none; min-width: 5.2em; white-space: nowrap; overflow: visible; }
#log.news .nmsg { flex: 1; min-width: 0; overflow-wrap: anywhere; }
#doNext .hactions button.big { flex: 1 1 180px; text-align: left; }
h2.sub { margin: 10px 0 0; font-size: 14px; color: var(--fg); }
#doNext .hactions button small { opacity: 1; }

/* Market: compact campaign list, one-row focus picker, rival details */
.camps { display: flex; flex-direction: column; gap: 4px; }
.camp { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; align-items: center; padding: 4px 0; border-bottom: 1px solid var(--line, rgba(128,128,128,.25)); }
.camp:last-child { border-bottom: 0; }
.camp .cinfo { color: var(--muted); font-size: 13px; }
.segpick { display: flex; flex-wrap: wrap; gap: 6px; }
.segpick button { flex: 1 1 45%; display: flex; flex-direction: column; align-items: center; padding: 8px 6px; }
.segpick button.on { box-shadow: var(--bevel-in); font-weight: bold; }
details.more summary { cursor: pointer; font-size: 12px; margin-top: 2px; }

/* HQ sections */
.hqnav { margin-bottom: 6px; } .hqnav button { flex: 1 1 22%; }
.card.afford { outline: 2px solid var(--accent); outline-offset: -2px; }
.trophy { opacity: .85; }
p.hint { margin: 0 2px; }

/* Customers and Products */
.mrow { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line, rgba(128,128,128,.25)); }
.mrow:last-child { border-bottom: 0; } .mrow .cinfo { color: var(--muted); font-size: 13px; grid-column: 1; } .mrow .stepper { grid-column: 2; grid-row: 1 / span 2; flex: 0 1 auto; }
.techline { display: block; margin: -2px 0 6px; }
.tag.good { color: var(--good); } .tag.bad { color: var(--bad); }
small.hint { display: block; margin: 4px 2px; }

/* Board goals as chips */
.bgoals { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 8px; }
.bgoal { background: var(--inset); padding: 8px; border-radius: var(--radius); box-shadow: var(--bevel-in); display: flex; flex-direction: column; gap: 2px; }
.bgoal.met { outline: 2px solid var(--good); outline-offset: -2px; }
.bgoal small { color: var(--muted); }

/* Network: upgrade path */
ol.path { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
ol.path li { display: grid; grid-template-columns: 1.4em 1fr auto; gap: 8px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line, rgba(128,128,128,.25)); }
ol.path li:last-child { border-bottom: 0; }
ol.path small { display: block; color: var(--muted); }
ol.path li.later b, ol.path li.soon b { font-weight: 500; }
ol.path li.now .pi { color: var(--accent); } ol.path li.done .pi { color: var(--good); }
