/* Prismatica dashboard.
   One sans-serif family and a fixed type scale:
     page title 26 bold · section title 17 semibold · body 15 · tables 14 ·
     labels 13 · big values 24 bold.
   Tables live in bordered panels with a shaded header row. Colour is used for
   status only: green = fine, amber = waiting, red = problem, grey = off. */

:root {
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --bg: #f3f4f6;
  --panel: #ffffff;
  --text: #111418;
  --text-2: #3b4250;
  --muted: #666d7a;
  --border: #d8dbe0;
  --row: #e9ebee;
  --head: #f5f6f8;
  --stripe: #fafbfc;
  --hover: #eef3fb;
  --accent: #1f5fae;
  --accent-text: #ffffff;

  --ok: #1e6b35;      --ok-bg: #e3f2e7;
  --warn: #875600;    --warn-bg: #fbf0d9;
  --bad: #b3261e;     --bad-bg: #fbe8e6;
  --idle: #525a66;    --idle-bg: #eceef1;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111214;
    --panel: #1a1c1f;
    --text: #eceef1;
    --text-2: #c4c8cf;
    --muted: #979da7;
    --border: #30343a;
    --row: #272a2f;
    --head: #212428;
    --stripe: #1d1f23;
    --hover: #222a36;
    --accent: #6ea5f0;
    --accent-text: #0e1116;

    --ok: #7ccf8f;      --ok-bg: #19301f;
    --warn: #e4b45b;    --warn-bg: #36291a;
    --bad: #f09a90;     --bad-bg: #3a1e1b;
    --idle: #b3b9c2;    --idle-bg: #2a2d32;
  }
}

* { box-sizing: border-box; }

html { background: var(--bg); color: var(--text); }

body { margin: 0; font: 15px/1.5 var(--font); -webkit-font-smoothing: antialiased; }

.wrap { max-width: 1200px; margin: 0 auto; padding-left: 24px; padding-right: 24px; }

/* ---- header -------------------------------------------------------------- */

.top { background: var(--panel); border-bottom: 1px solid var(--border); }

.top-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-top: 14px; }

.brand { font-size: 19px; font-weight: 700; color: var(--text); text-decoration: none; letter-spacing: -0.01em; }

.where { display: flex; align-items: center; gap: 12px; font-size: 14px; color: var(--text-2); }

nav { display: flex; gap: 4px; margin-top: 10px; overflow-x: auto; scrollbar-width: none; }
nav::-webkit-scrollbar { display: none; }
nav a {
  display: block;
  padding: 10px 14px 11px;
  font-size: 15px;
  font-weight: 500;
  color: var(--text-2);
  text-decoration: none;
  border-bottom: 3px solid transparent;
  white-space: nowrap;
}
nav a:hover { color: var(--text); }
nav a[aria-current="page"] { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

/* ---- page ---------------------------------------------------------------- */

main { padding-top: 28px; padding-bottom: 80px; }

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }

h1 { font-size: 26px; line-height: 1.25; font-weight: 700; margin: 0; letter-spacing: -0.015em; }
.intro { font-size: 15px; color: var(--text-2); margin: 6px 0 0; max-width: 72ch; }

h2 { font-size: 17px; font-weight: 600; margin: 0; }

p { margin: 0 0 10px; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.back { display: inline-block; font-size: 14px; margin-bottom: 10px; }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: var(--mono); font-size: 13.5px; }
.strong { font-weight: 600; }
.nowrap { white-space: nowrap; }

.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* ---- panels --------------------------------------------------------------- */

.panel { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; margin: 0 0 24px; overflow: hidden; }

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
}
.panel-title { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.panel-sub { font-size: 14px; color: var(--muted); }
.panel-body { padding: 16px; }
.panel-body > :last-child { margin-bottom: 0; }

/* ---- stat boxes ----------------------------------------------------------- */

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin: 0 0 24px; }
.stat { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 14px 16px; }
.stat-label { font-size: 13px; font-weight: 500; color: var(--muted); }
.stat-value { font-size: 24px; font-weight: 700; line-height: 1.25; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat-sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.tone-ok { color: var(--ok); }
.tone-warn { color: var(--warn); }
.tone-bad { color: var(--bad); }
.tone-idle { color: var(--idle); }

/* ---- tables --------------------------------------------------------------- */

.table-scroll { overflow-x: auto; }

table.data { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
table.data th {
  background: var(--head);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 600;
  text-align: left;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.data td { padding: 11px 16px; border-bottom: 1px solid var(--row); vertical-align: middle; }
table.data tbody tr:nth-child(even) td { background: var(--stripe); }
table.data tbody tr:hover td { background: var(--hover); }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data .num { text-align: right; }
table.data th.shrink { width: 1%; }
table.data td.wrap { white-space: normal; }
table.data td.cell-main { font-weight: 600; }
.cell-sub { display: block; font-size: 12.5px; color: var(--muted); font-weight: 400; margin-top: 1px; }

.empty { padding: 18px 16px; color: var(--muted); }

/* A label / value table: the label column is shaded, the value is the text. */
table.kv { width: 100%; border-collapse: collapse; font-size: 14.5px; }
table.kv th {
  width: 38%;
  background: var(--head);
  color: var(--text-2);
  font-weight: 500;
  text-align: left;
  padding: 10px 16px;
  border-bottom: 1px solid var(--row);
  vertical-align: top;
}
table.kv td { padding: 10px 16px; border-bottom: 1px solid var(--row); font-weight: 600; }
table.kv tr:last-child th, table.kv tr:last-child td { border-bottom: 0; }

/* ---- status tags ----------------------------------------------------------- */

.tag {
  display: inline-block;
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.5;
  padding: 1px 8px;
  border-radius: 4px;
  white-space: nowrap;
  margin: 1px 4px 1px 0;
}
.tag-ok { color: var(--ok); background: var(--ok-bg); }
.tag-warn { color: var(--warn); background: var(--warn-bg); }
.tag-bad { color: var(--bad); background: var(--bad-bg); }
.tag-idle { color: var(--idle); background: var(--idle-bg); }

/* ---- messages -------------------------------------------------------------- */

.notice {
  border: 1px solid var(--border);
  border-left: 4px solid var(--idle);
  background: var(--panel);
  border-radius: 6px;
  padding: 10px 14px;
  margin: 0 0 20px;
  font-size: 14.5px;
  white-space: pre-wrap;
}
.notice-ok { border-left-color: var(--ok); }
.notice-bad { border-left-color: var(--bad); }
.notice-warn { border-left-color: var(--warn); }
.notice strong { display: block; margin-bottom: 4px; }
.notice ol { margin: 4px 0 0; padding-left: 22px; white-space: normal; }
.notice li { margin: 3px 0; }

.field-reply { margin: 8px 0 0; padding: 7px 12px; font-size: 14px; border-radius: 6px; background: var(--head); white-space: pre-wrap; }
.field-reply.bad { color: var(--bad); background: var(--bad-bg); }

/* ---- controls ----------------------------------------------------------------- */

button, .button {
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 14px;
  line-height: 1.35;
  cursor: pointer;
  white-space: nowrap;
}
button:hover, .button:hover { border-color: var(--muted); }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
button.primary:hover { filter: brightness(0.95); }
button.danger { color: var(--bad); }
button.small { font-size: 13px; padding: 4px 10px; }
button.linkish { border: 0; background: none; padding: 0; color: var(--accent); font-weight: 500; }
button.linkish:hover { text-decoration: underline; }
button:disabled { opacity: 0.5; cursor: default; }

input, select, textarea {
  font: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 10px;
}
input:not([type="file"]), select { height: 36px; }
.toolbar button, .row > button:not(.linkish):not(.small) { height: 36px; }
input[type="number"] { width: 9em; }
input[type="text"] { width: 13em; }
input[type="search"], input.wide { width: 24em; max-width: 100%; }
textarea { width: 100%; font-family: var(--mono); font-size: 13px; line-height: 1.5; resize: vertical; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.toolbar { display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: flex-end; margin: 0 0 16px; }
.control { display: flex; flex-direction: column; gap: 5px; }
.control > span { font-size: 13px; font-weight: 600; color: var(--text-2); }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.segmented { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; background: var(--panel); margin: 0 0 16px; }
.segmented button { border: 0; border-right: 1px solid var(--border); border-radius: 0; padding: 7px 14px; }
.segmented button:last-child { border-right: 0; }
.segmented button[aria-pressed="true"] { background: var(--text); color: var(--panel); }
.segmented .count { font-weight: 700; margin-left: 6px; }

/* ---- settings form --------------------------------------------------------------- */

.form-row { display: grid; grid-template-columns: minmax(200px, 320px) minmax(0, 1fr); gap: 8px 32px; padding: 14px 16px; border-bottom: 1px solid var(--row); }
.form-row:last-child { border-bottom: 0; }
.form-label label, .form-label .name { font-size: 14.5px; font-weight: 600; }
.form-label .help { font-size: 13px; color: var(--muted); margin-top: 3px; }
.unit { font-size: 14px; color: var(--muted); }

/* ---- castle ------------------------------------------------------------------------ */

.two-col { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: 24px; align-items: start; }
.two-col .panel { margin-bottom: 0; }
.gear-img { display: block; width: 100%; max-width: 580px; height: auto; border-radius: 6px; }
.gear-list { margin: 14px 0 0; padding-left: 24px; font-size: 14.5px; }
.gear-list li { margin: 3px 0; }
.gear-list .empty-slot { color: var(--muted); }

/* ---- commands ------------------------------------------------------------------------ */

.output pre { font-family: var(--mono); font-size: 13.5px; line-height: 1.55; white-space: pre-wrap; margin: 0; }
.output h3 { font-size: 16px; margin: 0 0 8px; }
.output img { max-width: 100%; margin-top: 12px; border-radius: 6px; border: 1px solid var(--border); }
.examples { font-size: 14px; color: var(--muted); margin-top: 12px; }

.file-pick input[type="file"] { display: none; }
.spaced { margin-top: 20px; }

@media (max-width: 800px) {
  .wrap { padding-left: 14px; padding-right: 14px; }
  h1 { font-size: 23px; }
  .form-row { grid-template-columns: 1fr; }
  .two-col { grid-template-columns: 1fr; }
  .two-col .panel { margin-bottom: 24px; }
  input[type="search"], input.wide { width: 100%; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
