@font-face { font-family: "Instrument Sans"; font-style: normal; font-weight: 400; font-display: swap; src: url(/vendor/fonts/instrument-sans-latin-400-normal.woff2) format("woff2"); }
@font-face { font-family: "Instrument Sans"; font-style: normal; font-weight: 500; font-display: swap; src: url(/vendor/fonts/instrument-sans-latin-500-normal.woff2) format("woff2"); }
@font-face { font-family: "Instrument Sans"; font-style: normal; font-weight: 600; font-display: swap; src: url(/vendor/fonts/instrument-sans-latin-600-normal.woff2) format("woff2"); }
@font-face { font-family: "Instrument Sans"; font-style: normal; font-weight: 700; font-display: swap; src: url(/vendor/fonts/instrument-sans-latin-700-normal.woff2) format("woff2"); }
:root {
  --green-900: #2F4F3A;   /* primary */
  --green-700: #547B59;   /* secondary */
  --green-100: #E3ECE2;
  --bg: #F6F8F6;
  --card: #FFFFFF;
  --ink: #1E2922;
  --ink-2: #738078;
  --line: #DFE6DF;
  --ok: #2E8B4E;          /* working */
  --stop: #B5473A;        /* stopped, restrained red */
  --idle: #A3ABA5;        /* never used */
  --warn: #B7791F;
  --r-lg: 14px;
  --r-sm: 8px;
  --font: "Instrument Sans", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 var(--font); }
[hidden] { display: none !important; }
a { color: var(--green-900); }
button { font: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--green-700); outline-offset: 2px; }
.muted { color: var(--ink-2); }
.num { font-variant-numeric: tabular-nums; }

/* brand */
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: -0.01em; }
.brand .mark { width: 26px; height: 26px; border-radius: 7px; background: var(--green-900); position: relative; flex: none; }
.brand .mark::after { content: ""; position: absolute; inset: 7px 6px; border-top: 2.4px solid #C9D8C4; border-bottom: 2.4px solid #C9D8C4; }
.brand-lg { font-size: 22px; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(1200px 600px at 20% 10%, #E8EFE6, transparent), var(--bg); }
.login-card { width: min(380px, 100%); background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 32px; display: grid; gap: 14px; }
.login-card label { display: grid; gap: 6px; font-weight: 500; font-size: 14px; }
.login-card input { font: inherit; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-sm); }
.form-error { color: var(--stop); min-height: 1.2em; margin: 0; font-size: 14px; }
.btn-primary { background: var(--green-900); color: #fff; border: 0; border-radius: var(--r-sm); padding: 11px 16px; font-weight: 600; }
.btn-primary:hover { background: #243F2E; }
.link { background: none; border: 0; color: var(--green-900); padding: 4px 6px; font-weight: 500; }

/* shell */
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; background: linear-gradient(to right, var(--green-900) 220px, transparent 220px); }
.shell.mini { grid-template-columns: 64px 1fr; background: linear-gradient(to right, var(--green-900) 64px, transparent 64px); }
.side { background: var(--green-900); color: #E7EFE5; padding: 18px 12px; display: flex; flex-direction: column; gap: 22px;
  position: sticky; top: 0; height: 100vh; }
.side .brand { padding: 0 8px; color: #fff; }
.side .brand .mark { background: #E7EFE5; }
.side .brand .mark::after { border-color: var(--green-900); }
.side nav { display: grid; gap: 2px; }
.side nav a { display: flex; gap: 12px; align-items: center; color: #C9D8C4; text-decoration: none; padding: 9px 10px; border-radius: var(--r-sm); font-weight: 500; }
.side nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.side nav a.on { background: rgba(255,255,255,.12); color: #fff; }
.side svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; flex: none; }
.collapse { margin-top: auto; background: none; border: 0; color: #C9D8C4; align-self: flex-start; padding: 8px 10px; }
.shell.mini .brand-text, .shell.mini nav span { display: none; }
.shell.mini .collapse svg { transform: rotate(180deg); }
.main { min-width: 0; }
.top { display: flex; align-items: center; gap: 16px; padding: 12px 28px; border-bottom: 1px solid var(--line); background: var(--card); position: sticky; top: 0; z-index: 500; }
.search { flex: 1; max-width: 520px; }
.search input { width: 100%; font: inherit; padding: 8px 12px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--bg); }
.sync { font-size: 13px; color: var(--ink-2); display: flex; align-items: center; gap: 6px; margin-left: auto; white-space: nowrap; }
.sync::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }
.sync.bad { color: var(--stop); }
.sync.bad::before { background: var(--stop); }
.user { display: flex; gap: 8px; align-items: center; font-size: 14px; white-space: nowrap; }
#view { padding: 24px 28px 48px; max-width: 1480px; outline: none; }

/* page heading */
.page-head { display: flex; align-items: baseline; gap: 14px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { font-size: 26px; letter-spacing: -0.02em; margin: 0; }
.page-head .muted { font-size: 14px; }

/* overview: the fleet map is the hero */
.fleet { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; margin-bottom: 20px; }
.map-wrap { position: relative; background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; min-height: 560px; }
#map { position: absolute; inset: 0; }
.map-tools { position: absolute; z-index: 400; top: 12px; left: 12px; display: flex; gap: 6px; flex-wrap: wrap; }
.chip { background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 5px 11px; font-size: 13px; font-weight: 500; display: inline-flex; gap: 6px; align-items: center; color: var(--ink); }
.chip[aria-pressed="true"] { background: var(--green-900); border-color: var(--green-900); color: #fff; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; }
.dot.green { background: var(--ok); } .dot.red { background: var(--stop); } .dot.grey { background: var(--idle); }

.status-col { display: grid; gap: 12px; align-content: start; }
.status-big { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 18px 20px; }
.status-big .n { font-size: 44px; font-weight: 700; letter-spacing: -0.03em; line-height: 1; }
.status-big .what { display: flex; align-items: center; gap: 8px; font-weight: 600; margin-top: 8px; }
.status-big .sub { color: var(--ink-2); font-size: 13px; margin-top: 2px; }
.status-big.green .n { color: var(--ok); } .status-big.red .n { color: var(--stop); }
.status-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.status-row .status-big .n { font-size: 28px; }

.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; margin-bottom: 20px; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 20px; margin-bottom: 20px; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 18px 20px; min-width: 0; }
.panel h2 { font-size: 15px; margin: 0 0 12px; }
.panel h2 .muted { font-weight: 400; }
.kv { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.kv div { display: grid; }
.kv b { font-size: 24px; letter-spacing: -0.02em; }
.kv span { color: var(--ink-2); font-size: 13px; }

/* bars */
.bars { display: flex; align-items: flex-end; gap: 3px; height: 150px; padding-top: 8px; }
.bars div { flex: 1; background: var(--green-700); border-radius: 3px 3px 0 0; min-height: 1px; position: relative; }
.bars div:hover { background: var(--green-900); }
.bars-axis { display: flex; justify-content: space-between; color: var(--ink-2); font-size: 12px; margin-top: 6px; }
.hbar { display: grid; grid-template-columns: 150px 1fr 40px; gap: 10px; align-items: center; font-size: 13px; padding: 4px 0; text-decoration: none; color: var(--ink); }
.hbar .track { height: 8px; background: var(--green-100); border-radius: 4px; overflow: hidden; }
.hbar .fill { height: 100%; background: var(--green-700); }
.hbar:hover .fill { background: var(--green-900); }

/* tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-weight: 600; color: var(--ink-2); font-size: 13px; padding: 9px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 9px 10px; border-bottom: 1px solid #EEF2EE; vertical-align: top; }
tr.click { cursor: pointer; }
tr.click:hover td { background: #F3F7F2; }
td.r, th.r { text-align: right; }
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 500; white-space: nowrap; }
.pill { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--green-100); color: var(--green-900); font-weight: 600; white-space: nowrap; }
.pill.crit { background: #F6E3E0; color: var(--stop); } .pill.warn { background: #F7EEDD; color: var(--warn); }
.pill.aws { background: #E3EAF3; color: #2F4A6B; }

.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar input[type=search] { font: inherit; padding: 8px 12px; border: 1px solid var(--line); border-radius: var(--r-sm); min-width: 280px; background: var(--card); }
.toolbar .spacer { flex: 1; }
.btn { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 7px 12px; font-weight: 500; }

/* machine detail */
.mhead { display: flex; gap: 20px; align-items: flex-start; flex-wrap: wrap; margin-bottom: 18px; }
.mhead h1 { font-size: 26px; margin: 0; letter-spacing: -0.02em; }
.mhead .meta { display: flex; flex-wrap: wrap; gap: 6px 18px; color: var(--ink-2); font-size: 14px; margin-top: 4px; }
.mhead .meta b { color: var(--ink); font-weight: 500; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 20px 0 14px; }
.tabs button { background: none; border: 0; padding: 10px 14px; font-weight: 500; color: var(--ink-2); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button[aria-selected="true"] { color: var(--green-900); border-color: var(--green-900); }
.stat-row { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 14px 16px; }
.stat b { display: block; font-size: 22px; letter-spacing: -0.02em; }
.stat span { color: var(--ink-2); font-size: 13px; }
.complete { display: inline-flex; align-items: center; gap: 8px; }
.complete .track { width: 70px; height: 6px; border-radius: 3px; background: #EEF2EE; overflow: hidden; }
.complete .fill { height: 100%; background: var(--ok); }
.complete.bad .fill { background: var(--warn); }
select { font: inherit; padding: 7px 10px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--card); }
.legend { display: flex; gap: 14px; font-size: 13px; color: var(--ink-2); flex-wrap: wrap; }
.legend i { display: inline-block; width: 14px; height: 3px; border-radius: 2px; vertical-align: middle; margin-right: 5px; }

/* drawer */
.drawer { position: fixed; top: 0; right: 0; height: 100vh; width: min(620px, 100%); background: var(--card); z-index: 1001;
  border-left: 1px solid var(--line); transform: translateX(100%); transition: transform .2s ease; display: flex; flex-direction: column; }
.drawer.open { transform: none; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 22px; border-bottom: 1px solid var(--line); }
.drawer-head h2 { margin: 0; font-size: 18px; }
.drawer-body { overflow-y: auto; padding: 18px 22px 40px; }
.drawer-body h3 { font-size: 14px; margin: 22px 0 8px; }
.scrim { position: fixed; inset: 0; background: rgba(30,41,34,.25); z-index: 1000; }
.rgb { display: inline-flex; gap: 4px; font-variant-numeric: tabular-nums; font-size: 13px; }
.rgb span { padding: 1px 6px; border-radius: 4px; background: #F1F4F1; }
.rgb span.max { background: #F6E3E0; color: var(--stop); font-weight: 600; }
.missing { color: var(--idle); }

.empty, .error-box, .loading { padding: 40px 20px; text-align: center; color: var(--ink-2); }
.error-box { color: var(--stop); }
.leaflet-popup-content { font: 13px/1.45 var(--font); margin: 12px 14px; }
.leaflet-popup-content b { font-size: 14px; }
.pop-status { display: flex; align-items: center; gap: 6px; font-weight: 600; margin: 4px 0; }

@media (max-width: 1180px) {
  .fleet { grid-template-columns: 1fr; }
  .status-col { grid-template-columns: repeat(2, 1fr); }
  .status-row { grid-column: span 2; }
  .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .stat-row { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 760px) {
  .shell, .shell.mini { grid-template-columns: 1fr; background: none; }
  .side { position: static; height: auto; flex-direction: row; align-items: center; padding: 10px 12px; }
  .side nav { display: flex; }
  .collapse { display: none; }
  .top { flex-wrap: wrap; padding: 10px 16px; }
  #view { padding: 16px; }
  .map-wrap { min-height: 420px; }
  .stat-row { grid-template-columns: repeat(2, 1fr); }
  .kv { grid-template-columns: repeat(2, 1fr); }
}
@media (prefers-reduced-motion: reduce) { .drawer { transition: none; } }
