/* Page styles carried over from the SkyDock lager prototype. Colours and fonts come from theme.css,
   which maps the names used here (--bg, --line, --accent, ...) onto the Hub tokens. */
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font-family: var(--font-body); font-size: 15px; line-height: 1.45; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.wrap { max-width: 1320px; margin: 0 auto; padding: 24px 20px 48px; display: grid; gap: 18px; }
header.top { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; }
header.top h1 { margin: 0; font-size: 26px; letter-spacing: -0.01em; text-wrap: balance; }
header.top p { margin: 2px 0 0; color: var(--muted); }
.conn { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.dot.live { background: var(--ok); }
.dot.err { background: var(--crit); }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: grid; gap: 2px; text-align: left; cursor: pointer; }
.tile:hover { border-color: var(--accent); }
.tile .lbl { font-size: 13px; color: var(--muted); }
.tile .num { font-size: 30px; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1.1; }
.tile .sub { font-size: 12px; color: var(--muted); min-height: 1.2em; }
.tile.warn .num { color: var(--warn); }
.tile.crit .num { color: var(--crit); }
.tile.active { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.tile.static { cursor: default; }
.tile.static:hover { border-color: var(--line); }

.banner { border-radius: var(--radius); padding: 12px 16px; display: grid; gap: 6px; background: var(--warn-soft); border: 1px solid color-mix(in srgb, var(--warn) 40%, transparent); }
.banner.crit { background: var(--crit-soft); border-color: color-mix(in srgb, var(--crit) 40%, transparent); }
.banner strong { font-size: 15px; }
.banner .items { display: flex; flex-wrap: wrap; gap: 6px; }
.banner .items button { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 2px 10px; font-size: 13px; cursor: pointer; }
.banner .items button .c { font-family: var(--font-mono); font-weight: 600; margin-left: 4px; }
.banner .items button.z .c { color: var(--crit); }
.banner .items button.l .c { color: var(--warn); }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.search { flex: 1 1 260px; min-width: 0; position: relative; }
.search input { width: 100%; padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
select.sel { padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.btn { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 8px 14px; cursor: pointer; font-weight: 500; white-space: nowrap; }
.btn:hover:not(:disabled) { border-color: var(--accent); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover:not(:disabled) { filter: brightness(1.08); }
.btn.danger { color: var(--crit); }
.btn.danger.confirm { background: var(--crit); color: #fff; border-color: var(--crit); }

.main { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 18px; align-items: start; }
@media (max-width: 1000px) { .main { grid-template-columns: minmax(0, 1fr); } }

.list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.listhead, .row { display: grid; grid-template-columns: minmax(0, 1fr) 90px 90px 120px 230px; gap: 12px; align-items: center; padding: 10px 16px 10px 20px; }
.listhead { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--bg) 50%, var(--surface)); }
.listhead .r, .row .r { text-align: right; }
.group { padding: 8px 20px; font-size: 13px; font-weight: 600; color: var(--muted); background: color-mix(in srgb, var(--bg) 60%, var(--surface)); border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; }
.row { border-bottom: 1px solid var(--line); position: relative; }
.row:last-child { border-bottom: 0; }
.row::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: transparent; }
.row.s-low::before { background: var(--warn); }
.row.s-out::before { background: var(--crit); }
.row.s-low { background: color-mix(in srgb, var(--warn-soft) 45%, var(--surface)); }
.row.s-out { background: color-mix(in srgb, var(--crit-soft) 50%, var(--surface)); }
.row.flash { animation: flash .8s ease-out; }
@keyframes flash { from { box-shadow: inset 0 0 0 2px var(--accent); } to { box-shadow: inset 0 0 0 2px transparent; } }
@media (prefers-reduced-motion: reduce) { .row.flash { animation: none; } }
.pinfo { min-width: 0; display: grid; gap: 1px; }
.pinfo .t { font-weight: 600; overflow-wrap: anywhere; }
.pinfo .pn { font-family: var(--font-mono); font-size: 12.5px; color: var(--muted); }
.pinfo .d { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.num-cell { font-variant-numeric: tabular-nums; font-family: var(--font-mono); text-align: right; }
.num-cell small { display: none; }
.stockcell { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
.stock { font-family: var(--font-mono); font-size: 24px; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1; background: none; border: 0; padding: 2px 4px; border-radius: 6px; cursor: pointer; }
.stock:hover:not(:disabled) { background: var(--accent-soft); }
.stock:disabled { cursor: default; }
.row.s-low .stock { color: var(--warn); }
.row.s-out .stock { color: var(--crit); }
.row.s-none .stock { color: var(--muted); font-size: 20px; }
.pill { font-size: 11.5px; font-weight: 600; padding: 1px 8px; border-radius: 999px; white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.low { background: var(--warn-soft); color: var(--warn); }
.pill.out { background: var(--crit-soft); color: var(--crit); }
.pill.none { background: var(--none-soft); color: var(--muted); }
.acts { display: flex; gap: 6px; justify-content: flex-end; }
.acts .use { min-width: 104px; }
.acts .plus, .acts .edit { padding: 8px 11px; }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); display: grid; gap: 10px; justify-items: center; }

@media (max-width: 760px) {
  .listhead { display: none; }
  .row { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "info stock" "meta meta" "acts acts"; row-gap: 8px; }
  .row .pinfo { grid-area: info; }
  .row .stockcell { grid-area: stock; }
  .row .meta { grid-area: meta; display: flex; gap: 14px; }
  .row .acts { grid-area: acts; justify-content: stretch; }
  .row .acts .use { flex: 1; }
  .num-cell { text-align: left; font-size: 13px; color: var(--muted); }
  .num-cell small { display: inline; font-family: var(--font-body); }
}
@media (min-width: 761px) { .row .meta { display: contents; } }

aside.log { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: grid; gap: 10px; position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow: auto; }
aside.log h2 { margin: 0; font-size: 15px; }
aside.log ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
aside.log li { display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: 10px; font-size: 13px; }
aside.log .delta { font-family: var(--font-mono); font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
aside.log .delta.neg { color: var(--crit); }
aside.log .delta.pos { color: var(--ok); }
aside.log .delta.set { color: var(--accent); }
aside.log .w { color: var(--muted); font-size: 12px; }
aside.log .note { color: var(--muted); font-size: 13px; }
@media (max-width: 1000px) { aside.log { position: static; max-height: none; } }

.notice { font-size: 13px; color: var(--muted); background: var(--surface); border: 1px dashed var(--line); border-radius: 8px; padding: 8px 12px; }
.notice.err { color: var(--crit); border-color: var(--crit); }

dialog { border: 1px solid var(--line); border-radius: 14px; padding: 0; background: var(--surface); color: var(--ink); width: min(560px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(10, 14, 22, .45); }
dialog form { padding: 20px; display: grid; gap: 14px; }
dialog h2 { margin: 0; font-size: 19px; }
dialog .grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
dialog .grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (max-width: 480px) { dialog .grid2, dialog .grid3 { grid-template-columns: 1fr; } }
dialog label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
dialog input, dialog select, dialog textarea { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--ink); width: 100%; }
dialog input[readonly] { opacity: .7; }
dialog .hint { font-size: 12px; color: var(--muted); margin: -6px 0 0; }
dialog .foot { display: flex; gap: 8px; justify-content: space-between; flex-wrap: wrap; }
dialog .foot .right { display: flex; gap: 8px; }
dialog .formerr { color: var(--crit); font-size: 13px; min-height: 1em; margin: 0; }

.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 8px; font-size: 14px; display: none; z-index: 10; max-width: calc(100vw - 32px); }
.toast.show { display: block; }
.toast button { margin-left: 10px; background: none; border: 1px solid currentColor; color: inherit; border-radius: 6px; padding: 2px 8px; cursor: pointer; }
