:root {
  --bg: #f4f4f1; --surface: #ffffff; --ink: #0b0b0b; --ink2: #3d3c39; --muted: #6b6a65;
  --line: #d6d5ce; --grid: #e1e0d9; --accent: #1c5cab; --accent-ink: #ffffff;
  --good: #0a7d0a; --warn-bg: #fff3d6; --warn: #8a5a00; --crit-bg: #fde4e4; --crit: #a32020;
  --idle: #6b6a65;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink);
  font: 17px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); }
.tnum, td.num, th.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
header.top { background: #12161c; color: #fff; padding: 10px 16px; display: flex; flex-wrap: wrap;
  align-items: center; gap: 8px 18px; }
header.top .brand { font-weight: 800; font-size: 22px; letter-spacing: .3px; color: #fff; text-decoration: none; }
header.top .brand span { color: #ffb21a; }
header.top nav { display: flex; flex-wrap: wrap; gap: 4px; }
header.top nav a { color: #fff; text-decoration: none; padding: 10px 12px; border-radius: 8px; min-height: 44px;
  display: inline-flex; align-items: center; font-weight: 600; }
header.top nav a:hover, header.top nav a.on { background: rgba(255,255,255,.14); }
header.top .site { color: #c9cbd1; font-size: 15px; }
main { max-width: 1320px; margin: 0 auto; padding: 16px; }
h1 { font-size: 26px; margin: 4px 0 12px; }
h2 { font-size: 20px; margin: 0 0 10px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 16px; margin-bottom: 16px; }
.row { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 480px), 1fr)); }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 12px; }
.toolbar .spacer { flex: 1; }
.btn, button { font: inherit; font-weight: 700; min-height: 48px; padding: 0 18px; border-radius: 10px;
  border: 2px solid var(--accent); background: var(--accent); color: var(--accent-ink); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
.btn.ghost, button.ghost { background: transparent; color: var(--accent); }
.btn.small, button.small { min-height: 40px; padding: 0 12px; font-size: 15px; }
input, select, textarea { font: inherit; min-height: 48px; padding: 8px 10px; border: 2px solid #9b9a94;
  border-radius: 8px; background: #fff; color: var(--ink); max-width: 100%; }
input:focus, select:focus, textarea:focus, .btn:focus-visible, button:focus-visible { outline: 3px solid #ffb21a; outline-offset: 1px; }
label { font-weight: 600; }

/* KPI strip */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.kpi .v { font-size: 30px; font-weight: 800; line-height: 1.1; }
.kpi .l { color: var(--muted); font-size: 14px; font-weight: 600; text-transform: uppercase; letter-spacing: .4px; }

/* rig cards */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 290px), 1fr)); gap: 14px; margin-bottom: 16px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px; border-top: 6px solid var(--rig, #888); }
.card .name { font-size: 22px; font-weight: 800; display: flex; align-items: center; gap: 8px; }
.card .model { color: var(--muted); font-size: 15px; margin-bottom: 8px; }
.status { display: inline-flex; align-items: center; gap: 8px; font-weight: 800; padding: 6px 10px; border-radius: 8px; font-size: 16px; }
.status .ic { font-size: 18px; line-height: 1; }
.st-drilling { background: #dff3df; color: #0a5c0a; }
.st-delay { background: var(--warn-bg); color: var(--warn); }
.st-silent { background: var(--crit-bg); color: var(--crit); }
.st-idle { background: #ececea; color: #45443f; }
.status-detail { font-size: 15px; color: var(--ink2); margin: 4px 0 10px; min-height: 22px; }
.metres { font-size: 32px; font-weight: 800; }
.metres small { font-size: 17px; color: var(--muted); font-weight: 600; }
.bar { height: 14px; background: #e6e5df; border-radius: 7px; overflow: hidden; margin: 6px 0 10px; position: relative; }
.bar > i { display: block; height: 100%; border-radius: 0 7px 7px 0; background: var(--rig, var(--accent)); }
.card dl { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px 8px; margin: 0; }
.card dt { font-size: 13px; color: var(--muted); font-weight: 700; text-transform: uppercase; }
.card dd { margin: 0; font-size: 20px; font-weight: 700; }
.card .foot { margin-top: 10px; font-size: 15px; display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.swatch { width: 14px; height: 14px; border-radius: 3px; display: inline-block; background: var(--rig); }

/* alerts */
.alerts { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.alerts li { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 10px; font-weight: 600; }
.alerts li.critical { background: var(--crit-bg); color: var(--crit); }
.alerts li.warning { background: var(--warn-bg); color: var(--warn); }
.alerts li .tag { font-weight: 800; min-width: 74px; }
.alerts li a { color: inherit; }
.ok-box { background: #dff3df; color: #0a5c0a; padding: 10px 12px; border-radius: 10px; font-weight: 700; }

/* charts */
svg.chart { width: 100%; height: auto; display: block; font-family: system-ui, -apple-system, "Segoe UI", sans-serif; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 15px; color: var(--ink2); margin-bottom: 8px; }
.legend i { display: inline-block; width: 14px; height: 14px; border-radius: 3px; vertical-align: -2px; margin-right: 6px; }
.legend .dash { width: 18px; height: 0; border-top: 2px dashed #52514e; border-radius: 0; vertical-align: 4px; }
.multiples { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 250px), 1fr)); gap: 12px; }
.multiples h3 { font-size: 16px; margin: 0 0 2px; display: flex; gap: 8px; align-items: center; }

/* tables */
.tablewrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { border-collapse: collapse; width: 100%; font-size: 16px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--grid); vertical-align: top; }
th { font-size: 13px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); border-bottom: 2px solid var(--line); }
td.num, th.num { text-align: right; }
tr.redrill td { background: #fff8e6; }
.pill { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 13px; font-weight: 800; }
.pill.open { background: #dff3df; color: #0a5c0a; } .pill.ended { background: var(--warn-bg); color: var(--warn); }
.pill.check { background: var(--warn-bg); color: var(--warn); font-size: 11px; cursor: help; }
.pill.signed { background: #e3ebf7; color: #1c4f8a; }
.flash { padding: 10px 14px; border-radius: 10px; margin-bottom: 12px; font-weight: 700; }
.flash.ok { background: #dff3df; color: #0a5c0a; } .flash.error { background: var(--crit-bg); color: var(--crit); }
.updated { font-size: 14px; color: var(--muted); }
.grid2 { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; }
.grid2 dt { color: var(--muted); font-weight: 600; } .grid2 dd { margin: 0; font-weight: 600; }

/* login */
.login { max-width: 420px; margin: 8vh auto; }
.login form { display: grid; gap: 12px; }
.login input, .login button { width: 100%; }

/* setup */
.setup table input, .setup table select { min-height: 44px; width: 100%; min-width: 70px; }
.setup table td { padding: 6px; }
.setup td.chk { text-align: center; } .setup td.chk input { width: 26px; height: 26px; min-height: 0; }
.setup tr.new td { background: #f6f9fd; }
.setup nav.jump { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }

@media (max-width: 600px) {
  body { font-size: 16px; }
  .kpi .v { font-size: 24px; }
  main { padding: 12px; }
}
