/* Ultra Factory design system: tokens and components for dashboards.
   Teal #08435C carries structure and text. Orange #FF5533 is a highlight only:
   the active place, focus, the current step, the "now" line. Status colours
   mean one thing each. Light theme is the default; dark is set with
   <html data-theme="dark">. Logical properties only, so right-to-left works.
   Fonts: include fonts.css (bundled woff2) before this file. */

/* ------------------------------------------------------------ tokens */
:root {
  color-scheme: light;
  --ink: #08435C;        /* text, rail, primary buttons, structure */
  --ink-2: #33606F;      /* secondary text */
  --ink-3: #6A8590;      /* quiet text, labels */
  --paper: #F2F5F6;      /* page background */
  --surface: #FFFFFF;    /* panels and cards */
  --surface-2: #F7F9FA;  /* table heads, hover */
  --rule: #D7E0E4;       /* borders */
  --rule-2: #E8EEF0;     /* inner dividers */
  --rail: #08435C;       /* the left navigation rail */
  --rail-ink: #A9C6D1;   /* rail text */
  --signal: #FF5533;     /* highlight only */
  --select: #E7F0F3;     /* selected row */

  /* status: one meaning each (use through the .t-* tone classes) */
  --ok: #17905F;   --ok-bg: #E3F4EC;    /* running, in spec, done */
  --bad: #D33A2C;  --bad-bg: #FCE9E6;   /* stopped, alarm, out of spec, late */
  --work: #C77A00; --work-bg: #FFF1D6;  /* warning, in repair, near a limit */
  --wait: #9A6A00; --wait-bg: #FBF0D9;  /* waiting on something outside */
  --new: #2463A6;  --new-bg: #E5EFFA;   /* needs a decision, information */
  --plan: #33606F; --plan-bg: #E8F0F2;  /* planned, assigned, idle-ready */
  --off: #7D8B91;  --off-bg: #EEF1F2;   /* offline, inactive, no data */

  /* chart series (neutral first; status colours only for thresholds) */
  --series-1: #08435C; --series-2: #4E8CA3; --series-3: #9DBFCB; --series-4: #6A8590;

  --display: "Barlow Condensed", "Bahnschrift", "Arial Narrow", sans-serif;
  --body: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  --r: 8px;
  --shadow: 0 12px 32px rgba(8, 67, 92, .18);
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --ink: #E4EEF1; --ink-2: #B5C9D0; --ink-3: #87A0A9;
  --paper: #0B1C23; --surface: #102832; --surface-2: #13303B;
  --rule: #22424E; --rule-2: #1A3743; --rail: #061419; --rail-ink: #7FA3B0; --select: #173B48;
  --ok: #3CC48A; --ok-bg: #123A2C; --bad: #FF6A5A; --bad-bg: #44201C;
  --work: #F2A93B; --work-bg: #3D2D10; --wait: #E3B65A; --wait-bg: #382E16;
  --new: #6EA8EA; --new-bg: #15304B; --plan: #B5C9D0; --plan-bg: #1A3743;
  --off: #8B9AA0; --off-bg: #1C3038; --shadow: 0 12px 32px rgba(0, 0, 0, .5);
  --series-1: #E4EEF1; --series-2: #7FB6C9; --series-3: #4E7E8E; --series-4: #87A0A9;
}
.t-ok { --tone: var(--ok); --tone-bg: var(--ok-bg); }
.t-bad { --tone: var(--bad); --tone-bg: var(--bad-bg); }
.t-work { --tone: var(--work); --tone-bg: var(--work-bg); }
.t-wait { --tone: var(--wait); --tone-bg: var(--wait-bg); }
.t-new { --tone: var(--new); --tone-bg: var(--new-bg); }
.t-plan { --tone: var(--plan); --tone-bg: var(--plan-bg); }
.t-off { --tone: var(--off); --tone-bg: var(--off-bg); }

/* ------------------------------------------------------------ base */
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--paper); color: var(--ink); font: 400 14px/1.45 var(--body); -webkit-font-smoothing: antialiased; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--signal); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--ink-3); }
.small { font-size: 12.5px; }
.num { font-variant-numeric: tabular-nums; text-align: end; }
.code { font: 700 15px/1.2 var(--display); letter-spacing: .3px; white-space: nowrap; } /* machine, sensor, order codes */
.ico { flex: none; width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ------------------------------------------------------------ shell: rail + top bar */
.shell { display: grid; grid-template-columns: 84px 1fr; grid-template-rows: minmax(0, 1fr); height: 100%; }
.rail { background: var(--rail); display: flex; flex-direction: column; padding: 14px 0; gap: 2px; }
.rail-logo { display: grid; place-items: center; height: 48px; margin-bottom: 14px; color: #FFFFFF; }
.rail-item { position: relative; display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 11px 4px 10px; border: 0; background: transparent; color: var(--rail-ink); text-decoration: none; font-size: 11px; font-weight: 500; cursor: pointer; }
.rail-item .ico { width: 22px; height: 22px; }
.rail-item:hover { color: #fff; background: rgba(255, 255, 255, .06); }
.rail-item.on { color: #fff; background: rgba(255, 255, 255, .09); }
.rail-item.on::before { content: ""; position: absolute; inset-inline-start: 0; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--signal); }
/* a module the customer does not have yet: visible, quiet, with a lock */
.rail-item.is-locked { color: rgba(169, 198, 209, .55); }
.rail-item.is-locked:hover { color: var(--rail-ink); }
.rail-lock { position: absolute; top: 6px; inset-inline-end: 18px; width: 14px; height: 14px; padding: 2px; border-radius: 50%; background: var(--rail); stroke-width: 2.2; }

.frame { display: grid; grid-template-rows: auto minmax(0, 1fr); min-width: 0; min-height: 0; }
.top { display: flex; align-items: center; gap: 20px; padding: 12px 24px; background: var(--surface); border-bottom: 1px solid var(--rule); }
.top-title { margin: 0; font: 700 26px/1 var(--display); letter-spacing: .2px; }
.top-ctx { display: flex; align-items: center; gap: 14px; margin-inline-start: auto; color: var(--ink-2); font-size: 13px; }
.top-ctx select { height: 34px; border: 1px solid var(--rule); border-radius: var(--r); background: var(--surface); padding: 0 10px; font-weight: 600; color: var(--ink); }
.clock { display: inline-flex; align-items: center; gap: 7px; font-variant-numeric: tabular-nums; }
.shift { margin-inline-start: 6px; padding: 3px 8px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--rule-2); font-weight: 600; color: var(--ink); }
.live { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; color: var(--ok); }
.live::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }
.live.is-stale { color: var(--work); } .live.is-stale::before { background: var(--work); }
.top-user { display: flex; align-items: center; gap: 8px; }
.icon-btn { width: 36px; height: 36px; display: grid; place-items: center; border: 0; background: transparent; border-radius: var(--r); color: var(--ink-2); cursor: pointer; }
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--ink); color: var(--surface); font: 700 13px/1 var(--display); letter-spacing: .5px; border: 0; }
.main { overflow: auto; min-height: 0; }
.page { padding: 22px 24px 40px; }

/* page tabs under the top bar */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin: -4px 0 16px; border-bottom: 1px solid var(--rule); }
.subnav { display: flex; gap: 22px; overflow-x: auto; }
.subnav a { padding: 8px 0 11px; text-decoration: none; color: var(--ink-3); font-weight: 600; border-bottom: 3px solid transparent; white-space: nowrap; }
.subnav a:hover { color: var(--ink); }
.subnav a.on { color: var(--ink); border-bottom-color: var(--signal); }
.tab-n { margin-inline-start: 6px; padding: 1px 6px; border-radius: 6px; background: var(--new-bg); color: var(--new); font: 700 13px/1.3 var(--display); }

/* ------------------------------------------------------------ section heads and panels */
.sec-head { display: flex; align-items: baseline; gap: 12px; margin: 0 0 10px; }
.sec-head h2 { margin: 0; font: 700 20px/1.1 var(--display); letter-spacing: .2px; }
.sec-gap { margin-top: 22px; }
.panel { background: var(--surface); border: 1px solid var(--rule); border-radius: 10px; padding: 14px 16px; }
.split { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }

/* ------------------------------------------------------------ KPI band: one panel divided by rules */
.kpis { display: grid; grid-template-columns: repeat(var(--n, 6), minmax(0, 1fr)); margin-bottom: 18px; background: var(--surface); border: 1px solid var(--rule); border-radius: 10px; }
.kpi { display: flex; flex-direction: column; gap: 4px; padding: 14px 16px; border-inline-start: 1px solid var(--rule-2); min-width: 0; }
.kpi:first-child { border-inline-start: 0; }
.kpi-label { font-size: 12.5px; color: var(--ink-2); font-weight: 500; }
.kpi-val { font: 700 32px/1 var(--display); font-variant-numeric: tabular-nums; }
.kpi-val small { font-size: 17px; color: var(--ink-3); font-weight: 600; }
.kpi-val.is-bad { color: var(--bad); }
.kpi-val.is-good { color: var(--ok); }
.kpi-sub { font-size: 12px; color: var(--ink-3); }
.kpi-delta { font-size: 12px; font-weight: 600; }
.kpi-delta.up { color: var(--ok); } .kpi-delta.down { color: var(--bad); }

/* ------------------------------------------------------------ machine / sensor tile with a status plate */
/* Like the label plate on a machine: solid tone colour when something is
   wrong, a quiet green plate when running. Never a coloured side stripe. */
.board { background: var(--surface); border: 1px solid var(--rule); border-radius: 10px; overflow: hidden; }
.board-row { display: grid; grid-template-columns: 200px minmax(0, 1fr) 180px; gap: 16px; align-items: center; padding: 14px 16px; border-top: 1px solid var(--rule-2); }
.board-row:first-child { border-top: 0; }
.board-name { display: block; font: 600 17px/1.15 var(--display); }
.board-name::before { content: ""; display: inline-block; width: 10px; height: 10px; margin-inline-end: 8px; vertical-align: 1px; background: var(--tone, var(--ok)); }
.board-code { display: block; margin-top: 3px; font-size: 12px; color: var(--ink-3); }
.tiles { display: flex; flex-wrap: wrap; gap: 8px; }
.tile { display: grid; grid-template-columns: 1fr auto; grid-template-rows: auto auto 1fr; column-gap: 8px; width: 196px; min-height: 72px; padding: 9px 12px 0; border: 1px solid var(--rule); border-radius: 4px; background: var(--surface); text-decoration: none; overflow: hidden; color: var(--ink); }
.tile:hover { border-color: var(--ink-3); }
.tile-code { font: 700 21px/1 var(--display); letter-spacing: .3px; }
.tile-ref { grid-row: 1; grid-column: 2; align-self: start; font: 600 12px/1.6 var(--display); color: var(--tone); }
.tile-name { grid-column: 1 / -1; font-size: 11.5px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 3px; }
.tile-value { grid-column: 1 / -1; margin-top: 6px; font: 700 24px/1 var(--display); font-variant-numeric: tabular-nums; }
.tile-value small { font-size: 14px; color: var(--ink-3); font-weight: 600; }
.tile-state { grid-column: 1 / -1; align-self: end; margin: 8px -12px 0; padding: 4px 12px 5px; font-size: 12.5px; font-weight: 600; background: var(--tone); color: var(--surface); }
.tile.t-ok > .tile-state { background: var(--ok-bg); color: var(--ok); }
.tile.t-off > .tile-state { background: var(--off-bg); color: var(--off); }
.tile.t-wait > .tile-state { background-image: repeating-linear-gradient(135deg, transparent 0 6px, rgba(255, 255, 255, .2) 6px 9px); }
.tile.big { width: auto; min-height: 112px; padding: 14px 16px 0; }
.tile.big .tile-code { font-size: 30px; }
.tile.big .tile-state { margin: 10px -16px 0; padding: 7px 16px; font-size: 15px; }

/* status lamp: a small filled square before a name, in list rows */
.lamp { display: inline-block; width: 9px; height: 9px; margin-inline-end: 8px; vertical-align: 1px; background: var(--tone); }
/* pill: a status word */
.pill { display: inline-flex; align-items: center; height: 24px; padding: 0 9px; border-radius: 999px; background: var(--tone-bg); color: var(--tone); font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill.t-wait { background-image: repeating-linear-gradient(135deg, transparent 0 5px, rgba(154, 106, 0, .08) 5px 7px); }

/* ------------------------------------------------------------ alerts list ("Needs attention") */
.att-list { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--rule); border-radius: 10px; overflow: hidden; }
.att-list li + li { border-top: 1px solid var(--rule-2); }
.att { display: grid; grid-template-columns: 1fr auto; column-gap: 12px; padding: 11px 16px; text-decoration: none; color: var(--ink); }
.att:hover { background: var(--surface-2); }
.att-title { font: 600 17px/1.2 var(--display); }
.att-title::before { content: ""; display: inline-block; width: 9px; height: 9px; margin-inline-end: 8px; vertical-align: 1px; background: var(--tone); }
.att-body { grid-column: 1; font-size: 13px; color: var(--ink-2); }
.att-meta { grid-column: 1; font-size: 12px; color: var(--ink-3); margin-top: 1px; }
.att-go { grid-column: 2; grid-row: 1 / span 3; align-self: center; color: var(--ink-3); }

/* ------------------------------------------------------------ tables */
.table-wrap { background: var(--surface); border: 1px solid var(--rule); border-radius: 10px; overflow: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th { position: sticky; top: 0; background: var(--surface-2); text-align: start; font-size: 12px; font-weight: 600; color: var(--ink-3); padding: 9px 12px; border-bottom: 1px solid var(--rule); white-space: nowrap; }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--rule-2); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--surface-2); }
.table tr.is-active td { background: var(--select); }
.table .sub { display: block; font-size: 12px; color: var(--ink-3); margin-top: 2px; }
.table th.num, .table td.num { text-align: end; }

/* ------------------------------------------------------------ controls */
.btn { display: inline-flex; align-items: center; gap: 7px; height: 38px; padding: 0 14px; border: 1px solid var(--rule); border-radius: var(--r); background: var(--surface); color: var(--ink); font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: var(--ink-3); }
.btn.primary { background: var(--ink); border-color: var(--ink); color: var(--surface); }
.btn.primary:hover { background: var(--ink-2); }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.small { height: 32px; padding: 0 10px; font-size: 13px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 9px; background: var(--rule-2); }
.seg button { display: inline-flex; align-items: center; gap: 7px; height: 32px; padding: 0 12px; border: 0; border-radius: 7px; background: transparent; cursor: pointer; font-weight: 600; font-size: 13px; color: var(--ink-2); }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(8, 67, 92, .14); }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; margin-bottom: 12px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.field input, .field select, .field textarea { min-height: 40px; padding: 8px 10px; border: 1px solid var(--rule); border-radius: var(--r); background: var(--surface); color: var(--ink); font-weight: 400; }
.facts { display: grid; grid-template-columns: 140px minmax(0, 1fr); gap: 9px 14px; margin: 0; font-size: 13.5px; }
.facts dt { color: var(--ink-3); } .facts dd { margin: 0; }

/* ------------------------------------------------------------ IoT readouts */
/* gauge: a 240-degree arc (SVG), value in the middle in Barlow */
.gauge { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.gauge svg { width: 160px; height: 120px; }
.gauge-track { fill: none; stroke: var(--rule-2); stroke-width: 12; stroke-linecap: round; }
.gauge-bar { fill: none; stroke: var(--tone, var(--ok)); stroke-width: 12; stroke-linecap: round; }
.gauge-tick { stroke: var(--ink-3); stroke-width: 2; }
.gauge-val { font: 700 30px/1 var(--display); fill: var(--ink); text-anchor: middle; }
.gauge-unit { font: 600 13px/1 var(--body); fill: var(--ink-3); text-anchor: middle; }
.gauge-label { font-size: 12.5px; color: var(--ink-2); font-weight: 500; }
/* progress bar */
.bar { display: block; height: 8px; background: var(--rule-2); border-radius: 4px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--tone, var(--ink-2)); border-radius: 4px; }
/* trend chart (SVG): series in neutral teals, limits in status colours */
.chart { display: block; width: 100%; height: auto; }
.chart-grid { stroke: var(--rule-2); stroke-width: 1; }
.chart-axis { font: 400 11px/1 var(--body); fill: var(--ink-3); }
.chart-line { fill: none; stroke: var(--series-1); stroke-width: 2; }
.chart-line.s2 { stroke: var(--series-2); } .chart-line.s3 { stroke: var(--series-3); }
.chart-area { fill: var(--series-1); opacity: .08; }
.chart-limit { stroke: var(--bad); stroke-width: 1.4; stroke-dasharray: 6 4; }
.chart-warn { stroke: var(--work); stroke-width: 1.2; stroke-dasharray: 4 4; }
.chart-now { stroke: var(--signal); stroke-width: 2; }
.chart-pt { fill: var(--surface); stroke: var(--series-1); stroke-width: 1.6; }
.chart-pt.is-out { fill: var(--bad); stroke: var(--bad); }
.legend { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-top: 10px; font-size: 12.5px; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { display: inline-block; width: 18px; height: 3px; border-radius: 2px; background: var(--c, var(--series-1)); }
/* sparkline bars (shift output) */
.spark rect { fill: var(--ok); } .spark rect.low { fill: var(--work); }
.spark line { stroke: var(--ink-3); stroke-dasharray: 3 3; }

/* ------------------------------------------------------------ states */
.empty { padding: 28px 16px; text-align: center; }
.empty-title { margin: 0 0 4px; font: 700 18px/1.2 var(--display); }
.empty-body { margin: 0; color: var(--ink-2); font-size: 13.5px; }
.loading { display: flex; align-items: center; gap: 10px; padding: 24px; color: var(--ink-3); }
.loading .spin { width: 40px; height: 3px; background: var(--rule); overflow: hidden; border-radius: 2px; position: relative; }
.loading .spin::after { content: ""; position: absolute; inset-block: 0; inset-inline-start: 0; width: 40%; background: var(--ink-2); animation: slide 1s infinite ease-in-out; }
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(250%); } }
@media (prefers-reduced-motion: reduce) { .loading .spin::after { animation: none; } }
.toast { position: fixed; inset-block-end: 24px; inset-inline-start: 50%; transform: translateX(-50%); padding: 12px 18px; border-radius: 10px; background: var(--ink); color: var(--surface); font-weight: 600; box-shadow: var(--shadow); z-index: 60; }

/* locked module message */
.scrim { position: fixed; inset: 0; background: rgba(8, 67, 92, .35); z-index: 40; }
.dialog { position: fixed; top: 50%; inset-inline-start: 50%; transform: translate(-50%, -50%); width: min(440px, calc(100% - 32px)); padding: 22px 24px; border-radius: 12px; background: var(--surface); box-shadow: var(--shadow); z-index: 41; }
.dialog h2 { display: flex; align-items: center; gap: 10px; margin: 0 0 8px; font: 700 22px/1.1 var(--display); }
.dialog p { margin: 0 0 16px; color: var(--ink-2); }
.dialog .acts { display: flex; gap: 8px; justify-content: flex-end; }

/* ------------------------------------------------------------ responsive */
@media (max-width: 1380px) { .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); } .kpi:nth-child(3n+1) { border-inline-start: 0; } .kpi:nth-child(n+4) { border-top: 1px solid var(--rule-2); } }
@media (max-width: 1180px) {
  .split, .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .board-row { grid-template-columns: 170px 1fr; }
  .board-row > :last-child { grid-column: 2; }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) auto; }
  .rail { grid-row: 2; flex-direction: row; justify-content: space-around; padding: 4px 0 calc(4px + env(safe-area-inset-bottom, 0px)); }
  .rail-logo { display: none; }
  .rail-item { flex: 1; font-size: 10.5px; padding: 8px 2px; }
  .rail-item.on::before { inset-inline-start: 20%; inset-inline-end: 20%; top: 0; bottom: auto; width: auto; height: 3px; border-radius: 0 0 3px 3px; }
  .rail-lock { top: 2px; inset-inline-end: 22%; }
  .frame { grid-row: 1; }
  .top { flex-wrap: wrap; gap: 8px 12px; padding: 10px 16px; }
  .top-ctx { order: 3; width: 100%; margin: 0; flex-wrap: wrap; }
  .top-user { margin-inline-start: auto; }
  .page { padding: 16px 14px 32px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } .kpi { border-inline-start: 0; border-top: 1px solid var(--rule-2); } .kpi:nth-child(even) { border-inline-start: 1px solid var(--rule-2); } .kpi:nth-child(-n+2) { border-top: 0; }
  .grid-3 { grid-template-columns: 1fr; }
  .board-row { grid-template-columns: 1fr; }
  .board-row > :last-child { grid-column: 1; }
  .tile { width: calc(50% - 4px); }
  .facts { grid-template-columns: 1fr; gap: 2px; }
}
