@import url("https://fonts.googleapis.com/css2?family=Big+Shoulders+Display:wght@600;800&family=Courier+Prime:wght@400;700&display=swap");

:root {
  --bg: #0a0b0d;
  --panel: #101215;
  --bg-line: rgba(233, 230, 220, 0.05);
  --fg: #eae6d9;
  --fg-dim: #8b8878;
  --accent: #d3652f;
  --border: rgba(233, 230, 220, 0.16);
  --up: #3ddc6f;
  --down: #ff4a3d;
  --tawny: #e2a03f;
  --danger: #e5372e;
  --amber: #e3b341;
  --head: "Big Shoulders Display", ui-sans-serif, "Arial Narrow", sans-serif;
  --mono: "Courier Prime", ui-monospace, "Courier New", monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg); font-family: var(--mono);
  background-image:
    linear-gradient(var(--bg-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--bg-line) 1px, transparent 1px);
  background-size: 44px 44px; background-position: -1px -1px;
}
button { font-family: var(--mono); }
.dim { color: var(--fg-dim); }
.up { color: var(--up); } .down { color: var(--down); } .flat { color: var(--tawny); }
.num { font-family: var(--head); font-weight: 800; letter-spacing: 0.01em; font-variant-numeric: tabular-nums; }

/* =====================  PUBLIC DISPLAY  ===================== */

body.display { font-size: clamp(6px, min(0.78vw, 1.4vh), 22px); overflow: hidden; }
.screen { height: 100vh; display: flex; flex-direction: column; padding: 1.6em 2em 1.2em; gap: 1.2em; }

.top { display: flex; align-items: flex-end; justify-content: space-between; gap: 2em; }
.brand .eyebrow { font-family: var(--head); font-weight: 600; font-size: 1.9em; text-transform: uppercase; color: var(--accent); line-height: 1; letter-spacing: .04em; }
.brand h1 { margin: 0; font-family: var(--head); font-weight: 800; font-size: 6em; line-height: .84; text-transform: uppercase; }
.status { text-align: right; display: flex; align-items: flex-end; gap: 2.2em; }
.status .k { font-size: 1.1em; letter-spacing: .12em; text-transform: uppercase; color: var(--fg-dim); }
.status .v { font-family: var(--head); font-weight: 800; font-size: 3.6em; line-height: .9; text-transform: uppercase; }
.status .v.timer { color: var(--accent); min-width: 3.4ch; text-align: right; font-variant-numeric: tabular-nums; }
.status .v.timer.zero { color: var(--danger); animation: blink 1s steps(2) infinite; }
.status .v.timer.paused { color: var(--fg-dim); }
@keyframes blink { 50% { opacity: .25; } }

.banner { border: 1px solid var(--accent); background: rgba(211, 101, 47, .12); color: var(--fg); padding: .7em 1.2em; font-weight: 700; font-size: 1.7em; letter-spacing: .04em; text-transform: uppercase; display: flex; gap: 1em; align-items: center; }
.banner::before { content: "▲"; color: var(--accent); }

.grid { flex: 1; min-height: 0; display: grid; gap: 1.2em; grid-template-columns: .9fr 1fr 1fr; grid-template-rows: auto 1fr; }
#p-stocks { grid-row: 1 / 3; }
.panel { background: rgba(16, 18, 21, .86); border: 1px solid var(--border); padding: 1.1em 1.3em; min-height: 0; overflow: hidden; display: flex; flex-direction: column; position: relative; }
.panel.flash { animation: flash 1.4s ease-out; }
@keyframes flash { 0% { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), 0 0 2em rgba(211, 101, 47, .35); } 100% { border-color: var(--border); box-shadow: none; } }
.panel h2 { margin: 0 0 .7em; font-family: var(--head); font-weight: 600; font-size: 1.7em; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); display: flex; justify-content: space-between; align-items: baseline; }
.panel h2 small { font-family: var(--mono); font-size: .55em; letter-spacing: .06em; color: var(--fg-dim); font-weight: 400; }

/* DEFCON */
.defcon { display: flex; gap: 1.6em; align-items: stretch; flex: 1; }
.defcon .big { font-family: var(--head); font-weight: 800; font-size: 11em; line-height: .8; align-self: center; min-width: .7em; text-align: center; }
.defcon .ladder { flex: 1; display: flex; flex-direction: column; justify-content: space-between; gap: .25em; }
.defcon .rung { display: flex; gap: .8em; align-items: baseline; padding: .15em .5em; border-left: 3px solid var(--border); color: var(--fg-dim); font-size: 1.05em; }
.defcon .rung b { font-family: var(--head); font-size: 1.7em; width: 1ch; }
.defcon .rung.on { color: var(--fg); background: rgba(233, 230, 220, .07); border-left-color: var(--lvl); }
.defcon .rung.on b { color: var(--lvl); }
.panel.defcon-hot { border-color: var(--danger); animation: hot 1.6s ease-in-out infinite; }
@keyframes hot { 50% { box-shadow: inset 0 0 3em rgba(229, 55, 46, .25); } }
.lvl5 { --lvl: #8b8878; } .lvl4 { --lvl: #eae6d9; } .lvl3 { --lvl: #e3b341; } .lvl2 { --lvl: #d3652f; } .lvl1 { --lvl: #e5372e; }

/* DOOM */
.doom-row { display: flex; align-items: baseline; gap: .5em; }
.doom-row .big { font-family: var(--head); font-weight: 800; font-size: 8.5em; line-height: .85; }
.doom-row .of { color: var(--fg-dim); font-size: 1.6em; }
.doom-row .delta { margin-left: auto; font-size: 1.5em; font-weight: 700; }
.cells { display: flex; gap: .3em; height: 2.4em; margin-top: .8em; }
.cells i { flex: 1; border: 1px solid var(--border); background: rgba(233, 230, 220, .05); transition: background .5s ease; }
.cells i.on { background: var(--c); border-color: var(--c); }
.cells-scale { display: flex; gap: .3em; color: var(--fg-dim); font-size: .95em; margin-top: .3em; }
.cells-scale span { flex: 1; text-align: center; }
.meter { position: relative; height: 1.7em; border: 1px solid var(--border); margin-top: .6em; background: repeating-linear-gradient(90deg, transparent 0 calc(5% - 1px), rgba(233, 230, 220, .1) calc(5% - 1px) 5%); }
.meter i { position: absolute; inset: 0 auto 0 0; background: linear-gradient(90deg, #8b8878 0%, #e3b341 45%, #d3652f 70%, #e5372e 100%); background-size: 100vw 100%; transition: width .8s ease; }
.meter-scale { display: flex; justify-content: space-between; color: var(--fg-dim); font-size: .95em; margin-top: .3em; }
.spark { width: 100%; height: 3.2em; margin-top: auto; display: block; }
.spark-cap { color: var(--fg-dim); font-size: .9em; display: flex; justify-content: space-between; }

/* indices */
.idx { display: grid; grid-template-columns: 1fr 1fr; gap: 1em; margin-bottom: .2em; }
.idx .lbl { color: var(--fg-dim); text-transform: uppercase; letter-spacing: .1em; font-size: .95em; }

/* stocks */
.stocks { overflow: hidden; flex: 1; min-height: 0; columns: 1; column-gap: 1.6em; }
.stocks.two { columns: 2; }
.grp { break-inside: avoid; margin-bottom: .6em; }
.grp > .gname { font-size: .95em; letter-spacing: .14em; text-transform: uppercase; color: var(--fg-dim); border-bottom: 1px solid var(--border); padding-bottom: .15em; margin-bottom: .2em; }
.stock { display: grid; grid-template-columns: 4.6ch minmax(0, 1fr) 3.6em 6.6em 3.8em; align-items: center; gap: .7em; padding: .28em 0; break-inside: avoid; }
.stock .tk { font-weight: 700; font-size: 1.2em; }
.stock .nm { color: var(--fg-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: .95em; }
.stock .px { font-family: var(--head); font-weight: 800; font-size: 2.3em; line-height: 1; text-align: right; font-variant-numeric: tabular-nums; }
.stock .ch { font-size: 1.3em; font-weight: 700; text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.stock .spark { height: 1.7em; margin: 0; }
.stock.halt .px { color: var(--fg-dim); text-decoration: line-through; }
.tag { display: inline-block; border: 1px solid var(--danger); color: var(--danger); font-size: .75em; padding: 0 .4em; margin-left: .5em; letter-spacing: .08em; }

/* regional prices */
table.rp { width: 100%; border-collapse: collapse; }
.rp th { text-align: right; font-weight: 400; color: var(--fg-dim); font-size: .85em; text-transform: uppercase; letter-spacing: .06em; padding: 0 0 .5em .6em; line-height: 1.1; vertical-align: bottom; }
.rp th:first-child, .rp td:first-child { text-align: left; }
.rp td { text-align: right; padding: .42em 0; border-top: 1px solid var(--border); }
.rp td:first-child { font-size: 1.15em; font-weight: 700; white-space: nowrap; }
.rp .dot { display: inline-block; width: .7em; height: .7em; margin-right: .6em; }
.rp .c { font-family: var(--head); font-weight: 800; font-size: 2.3em; line-height: 1; }
.rp .p { display: block; font-size: .9em; font-weight: 700; margin-top: -.1em; }
.rp tr.base td { color: var(--fg-dim); border-top: 0; }
.rp tr.base .c { font-size: 1.7em; }
.rp .pos { color: var(--down); } .rp .neg { color: var(--up); }

/* compute */
.cmp-total { display: flex; align-items: baseline; gap: .6em; }
.cmp-total .big { font-size: 5.4em; line-height: .85; }
.cmp-total .d { font-weight: 700; font-size: 1.3em; }
.stack { display: flex; height: 1.1em; margin: .6em 0 .4em; border: 1px solid var(--border); }
.stack i { display: block; height: 100%; }
.legend { display: flex; flex-wrap: wrap; gap: .2em 1.1em; font-size: .95em; margin-bottom: .8em; }
.legend span::before { content: ""; display: inline-block; width: .7em; height: .7em; background: var(--c); margin-right: .35em; }
.bars { flex: 1; min-height: 0; overflow: hidden; display: flex; flex-direction: column; gap: .35em; }
.bar { display: grid; grid-template-columns: 1fr 3.5ch; gap: .6em; align-items: center; position: relative; }
.bar .fill { position: absolute; inset: 0 auto 0 0; background: var(--c); opacity: .28; }
.bar .nm { position: relative; padding: .22em .5em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border-left: 3px solid var(--c); }
.bar .v { text-align: right; font-weight: 700; font-size: 1.15em; }
.empty { color: var(--fg-dim); font-style: italic; padding: 1em 0; }

/* =====================  ADMIN  ===================== */

body.admin { font-size: 14px; }
.bar-top { position: sticky; top: 0; z-index: 10; background: rgba(10, 11, 13, .96); border-bottom: 1px solid var(--border); display: flex; flex-wrap: wrap; gap: .8em 1.6em; align-items: center; padding: .7em 1.4em; }
.bar-top .ttl { font-family: var(--head); font-weight: 800; font-size: 2em; text-transform: uppercase; line-height: 1; }
.bar-top .ttl small { color: var(--accent); font-weight: 600; font-size: .55em; letter-spacing: .1em; margin-left: .5em; }
.bar-top .sp { flex: 1; }
.bar-top .live { display: flex; gap: 1.2em; align-items: baseline; }
.bar-top .live b { font-family: var(--head); font-size: 1.6em; }
.tabs { display: flex; gap: 0; padding: 0 1.4em; border-bottom: 1px solid var(--border); overflow-x: auto; }
.tab { background: none; border: 0; border-bottom: 3px solid transparent; color: var(--fg-dim); padding: .8em 1.1em; font-size: 13px; letter-spacing: .08em; text-transform: uppercase; cursor: pointer; font-weight: 700; white-space: nowrap; }
.tab:hover { color: var(--fg); }
.tab.on { color: var(--fg); border-bottom-color: var(--accent); }
.page { padding: 1.4em; max-width: 1500px; }
.cards { display: grid; gap: 1.2em; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); align-items: start; }
.card { background: rgba(16, 18, 21, .9); border: 1px solid var(--border); padding: 1.1em 1.2em; }
.card h3 { margin: 0 0 .8em; font-family: var(--head); font-weight: 600; font-size: 1.5em; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); display: flex; justify-content: space-between; align-items: baseline; }
.card h3 small { font-family: var(--mono); font-size: .6em; color: var(--fg-dim); font-weight: 400; letter-spacing: .04em; text-transform: none; }
.card p.hint { color: var(--fg-dim); margin: 0 0 .9em; font-size: 12.5px; line-height: 1.45; }

.btn { background: var(--accent); color: #0a0b0d; border: 1px solid var(--accent); font-weight: 700; font-size: 12.5px; letter-spacing: .06em; text-transform: uppercase; padding: .55em 1em; cursor: pointer; white-space: nowrap; }
.btn:hover { opacity: .85; }
.btn:focus-visible, .tab:focus-visible, .chip:focus-visible, .sq:focus-visible { outline: 2px solid var(--fg); outline-offset: 2px; }
.btn.ghost { background: transparent; color: var(--fg); border-color: var(--border); }
.btn.ghost:hover { border-color: var(--fg); opacity: 1; }
.btn.danger { background: transparent; color: var(--down); border-color: var(--down); }
.btn[disabled] { opacity: .35; cursor: default; }
.btn.sm { padding: .3em .6em; font-size: 11.5px; }
.sq { background: transparent; border: 1px solid var(--border); color: var(--fg); width: 2.1em; height: 2.1em; cursor: pointer; font-weight: 700; font-size: 14px; }
.sq:hover { border-color: var(--accent); color: var(--accent); }
.sq.x { color: var(--fg-dim); }
.sq.x:hover { color: var(--down); border-color: var(--down); }

input, select, textarea { background: transparent; border: 1px solid var(--border); color: var(--fg); font-family: var(--mono); font-size: 14px; padding: .45em .6em; min-width: 0; }
select option { background: #15171a; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
input[type=number] { width: 5.2em; text-align: center; -moz-appearance: textfield; }
input[type=number]::-webkit-inner-spin-button { display: none; }
input.w-t { width: 6.5em; } input.w-n { width: 100%; } input.w-p { width: 6.2em; text-align: right; } input.w-s { width: 4.2em; text-align: center; }
textarea { width: 100%; min-height: 4.5em; resize: vertical; }

.step { display: inline-flex; align-items: center; gap: 0; }
.step .sq { width: 2.3em; height: 2.35em; }
.step input { height: 2.35em; border-left: 0; border-right: 0; }
.row { display: flex; flex-wrap: wrap; gap: .5em; align-items: center; }
.row + .row { margin-top: .6em; }
.chips { display: flex; flex-wrap: wrap; gap: .4em; }
.chip { background: transparent; border: 1px solid var(--border); color: var(--fg-dim); padding: .5em .9em; cursor: pointer; font-weight: 700; font-size: 13px; }
.chip:hover { color: var(--fg); border-color: var(--fg-dim); }
.chip.on { color: #0a0b0d; background: var(--accent); border-color: var(--accent); }

.defbtns { display: grid; grid-template-columns: repeat(5, 1fr); gap: .4em; }
.defbtns .chip { padding: .9em 0; font-family: var(--head); font-size: 2.1em; line-height: 1; text-align: center; }
.defbtns .chip.on { background: var(--lvl); border-color: var(--lvl); }
.big-readout { font-family: var(--head); font-weight: 800; font-size: 4.6em; line-height: .9; }

table.t { width: 100%; border-collapse: collapse; }
.t th { text-align: left; color: var(--fg-dim); font-weight: 400; font-size: 11.5px; letter-spacing: .1em; text-transform: uppercase; padding: 0 .5em .5em 0; white-space: nowrap; }
.t td { padding: .35em .5em .35em 0; border-top: 1px solid var(--border); vertical-align: middle; }
.t td.r, .t th.r { text-align: right; }
.t .dot { display: inline-block; width: .7em; height: .7em; margin-right: .5em; }
.t tr.zero td { opacity: .55; }
.t tr.zero td:hover, .t tr.zero:hover td { opacity: 1; }
.addrow { display: flex; flex-wrap: wrap; gap: .5em; align-items: center; margin-top: 1em; padding-top: 1em; border-top: 1px dashed var(--border); }
.addrow label { color: var(--fg-dim); font-size: 12px; }
.log { font-size: 12.5px; max-height: 380px; overflow: auto; }
.log div { padding: .2em 0; border-top: 1px solid var(--border); display: flex; gap: 1em; }
.log time { color: var(--fg-dim); min-width: 8ch; }
.toast { position: fixed; bottom: 1.2em; right: 1.2em; background: var(--fg); color: #0a0b0d; padding: .7em 1.1em; font-weight: 700; opacity: 0; transition: opacity .2s; pointer-events: none; }
.toast.on { opacity: 1; }
.filter { margin-bottom: .9em; }

@media (prefers-reduced-motion: reduce) {
  .panel.flash, .panel.defcon-hot, .status .v.timer.zero { animation: none; }
  .meter i { transition: none; }
}

/* ===== hosted extras ===== */
.wait { position: fixed; inset: 0; z-index: 20; background: var(--bg); display: flex; align-items: center; justify-content: center; text-align: center; }
.wait[hidden] { display: none; }
.wait .eyebrow { font-family: var(--head); font-weight: 600; color: var(--accent); text-transform: uppercase; font-size: 3em; letter-spacing: .04em; }
.wait .msg { font-family: var(--head); font-weight: 800; text-transform: uppercase; font-size: 7em; line-height: .9; }
body.display .wait { font-size: clamp(6px, min(.78vw, 1.4vh), 22px); }
.conn { position: fixed; right: 1em; bottom: .6em; font-size: 11px; letter-spacing: .1em; color: var(--fg-dim); z-index: 5; }
.conn.ok { color: var(--up); opacity: .55; }
.conn.bad { color: var(--tawny); }
.conn[hidden] { display: none; }
body.display .conn { font-size: max(9px, .9vw); }

.login { position: fixed; inset: 0; z-index: 30; background: var(--bg); display: flex; align-items: center; justify-content: center; padding: 1.5em; }
.login form { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: .9em; }
.login h1 { margin: 0; font-family: var(--head); font-weight: 800; font-size: 4em; line-height: .9; text-transform: uppercase; }
.login .eyebrow { font-family: var(--head); font-weight: 600; font-size: 1.6em; text-transform: uppercase; color: var(--accent); }
.login input[type=password] { width: 100%; padding: .8em; font-size: 16px; }
.login label { color: var(--fg-dim); font-size: 12.5px; display: flex; gap: .5em; align-items: center; }
.login .err { color: var(--down); min-height: 1.4em; font-size: 13px; }
.save { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; }
.save.ok { color: var(--up); } .save.busy { color: var(--tawny); } .save.bad { color: #0a0b0d; background: var(--down); padding: .25em .6em; font-weight: 700; }

/* ===== Power incomes strip ===== */
#p-incomes { flex-direction: row; align-items: stretch; gap: 1.1em; padding: .55em 1.1em; flex: none; }
#p-incomes.hidden { display: none; }
.inc-label { display: flex; flex-direction: column; justify-content: center; min-width: 8.5em; padding-right: .4em; }
.inc-label b { font-family: var(--head); font-weight: 600; font-size: 1.5em; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); line-height: 1; }
.inc-label span { color: var(--fg-dim); font-size: .85em; margin-top: .2em; }
.inc { flex: 1; min-width: 0; display: grid; grid-template-columns: 1fr auto; grid-template-rows: auto auto; align-items: baseline; column-gap: .5em; padding: .1em .8em; border-left: 3px solid var(--c); }
.inc .n { grid-column: 1 / 3; color: var(--fg-dim); font-size: .95em; letter-spacing: .1em; text-transform: uppercase; white-space: nowrap; }
.inc .v { font-size: 2.9em; line-height: .95; }
.inc .d { font-size: 1.1em; font-weight: 700; text-align: right; white-space: nowrap; }

/* ===== ledger: cost pills, order cards ===== */
.pill { display: inline-block; border: 1px solid var(--border); padding: .15em .6em; font-weight: 700; white-space: nowrap; }
.pill.short { border-style: dashed; background: rgba(233, 230, 220, .08); }
.ord { border-top: 1px solid var(--border); padding: .9em 0; }
.ord:first-of-type { border-top: 0; }

/* ===== The five Resources: one colour each, used everywhere they appear ===== */
:root {
  --r-capital: #6aa84f;
  --r-talent: #ffd966;
  --r-compute: #4285f4;
  --r-influence: #9900ff;
  --r-fabrication: #ff0000;
}
.rc-capital { color: var(--r-capital); } .rc-talent { color: var(--r-talent); } .rc-compute { color: var(--r-compute); }
.rc-influence { color: var(--r-influence); } .rc-fabrication { color: var(--r-fabrication); }
.pill.res-capital { color: var(--r-capital); border-color: var(--r-capital); }
.pill.res-talent { color: var(--r-talent); border-color: var(--r-talent); }
.pill.res-compute { color: var(--r-compute); border-color: var(--r-compute); }
.pill.res-influence { color: var(--r-influence); border-color: var(--r-influence); }
.pill.res-fabrication { color: var(--r-fabrication); border-color: var(--r-fabrication); }
.sq.res-capital { color: var(--r-capital); border-color: var(--r-capital); } .sq.res-capital:hover { background: var(--r-capital); color: #0a0b0d; }
.sq.res-talent { color: var(--r-talent); border-color: var(--r-talent); } .sq.res-talent:hover { background: var(--r-talent); color: #0a0b0d; }
.sq.res-compute { color: var(--r-compute); border-color: var(--r-compute); } .sq.res-compute:hover { background: var(--r-compute); color: #0a0b0d; }
.sq.res-influence { color: var(--r-influence); border-color: var(--r-influence); } .sq.res-influence:hover { background: var(--r-influence); color: #fff; }
.sq.res-fabrication { color: var(--r-fabrication); border-color: var(--r-fabrication); } .sq.res-fabrication:hover { background: var(--r-fabrication); color: #0a0b0d; }
/* table headers have their own grey; make sure the resource colour wins there */
th.rc-capital { color: var(--r-capital); } th.rc-talent { color: var(--r-talent); } th.rc-compute { color: var(--r-compute); }
th.rc-influence { color: var(--r-influence); } th.rc-fabrication { color: var(--r-fabrication); }

/* military map (public display) */
.mapview { display: grid; grid-template-columns: minmax(0, 2.6fr) minmax(16em, 1fr); gap: 1.2em; align-items: start; }
@media (max-width: 900px) { .mapview { grid-template-columns: 1fr; } }
.mapwrap { position: relative; background: #b0d3e2; line-height: 0; }
.mapwrap img { width: 100%; display: block; }
.forces .fh { font-family: var(--head, inherit); letter-spacing: .12em; text-transform: uppercase; color: var(--fg-dim, #999); font-size: .8em; margin: 1em 0 .4em; }
.forces .fh:first-child { margin-top: 0; }
.forces .fp { border-left: 4px solid var(--c, #888); padding: .15em .6em; margin-bottom: .45em; }
.forces .fl { border-top: 1px solid var(--border, #333); padding: .4em 0; }
.forces .dim { color: var(--fg-dim, #999); font-size: .85em; }
.mapovl { position: absolute; left: 0; top: 0; width: 100%; height: 100%; }
.mapkey { margin-top: .5em; font-size: .85em; color: var(--fg-dim, #999); letter-spacing: .04em; }

/* the hidden attribute must win over .panel / .grid display rules (map <-> dashboard switch) */
[hidden] { display: none !important; }
