: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; }
}

/* parts register (hammer, bit, chuck nut, rods) - colour is never the only signal: icon + text too */
.pc-green { --pc: #0a7d0a; --pc-bg: #dff3df; }
.pc-orange { --pc: #9a4f00; --pc-bg: #ffe9c7; }
.pc-red { --pc: #a32020; --pc-bg: #fde4e4; }
.pstate { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 14px; font-weight: 800; background: var(--pc-bg); color: var(--pc); white-space: nowrap; text-decoration: none; }
.pbar { height: 10px; background: #e6e5df; border-radius: 5px; overflow: hidden; margin-top: 4px; min-width: 90px; }
.pbar > i { display: block; height: 100%; background: var(--pc); }
.pbar.pc-orange > i { background: #e08a00; }
.pcounts { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 12px; }
.pgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); gap: 12px; }
.prig { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.prig h3 { margin: 0 0 6px; font-size: 18px; display: flex; justify-content: space-between; align-items: baseline; }
.plist { list-style: none; margin: 0; padding: 0; }
.plist li { padding: 7px 0; border-bottom: 1px solid var(--grid); } .plist li:last-child { border-bottom: 0; }
.pline { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; font-size: 15px; }
.pline.small { font-size: 13px; color: var(--ink2); margin-top: 2px; }
#parts .alerts li .tag, #blocks .alerts li .tag { flex: none; white-space: nowrap; }
.small { font-size: 13px; }
.navcount { background: #ffb21a; color: #12161c; border-radius: 10px; padding: 0 7px; margin-left: 6px; font-size: 13px; font-weight: 800; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.filters label { display: flex; gap: 6px; align-items: center; }
table.parts tr.changed td { color: var(--ink2); background: #f7f7f4; }
form.inline { display: flex; gap: 4px; justify-content: flex-end; }
form.inline input { min-height: 40px; padding: 4px 6px; }
img.thumb { width: 64px; height: 48px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); display: block; }
img.thumb.big { width: 120px; height: 90px; }
.reqs { display: grid; gap: 12px; }
.req { margin: 0; border-left: 6px solid #a32020; }
.req.issued { border-left-color: #8a5a00; } .req.closed { border-left-color: #9b9a94; }
.reqhead { display: flex; justify-content: space-between; gap: 12px; }
.reqtitle { font-size: 19px; }
.reqgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 6px 16px; margin: 10px 0 4px; }
.reqgrid dt { font-size: 13px; color: var(--muted); font-weight: 700; text-transform: uppercase; } .reqgrid dd { margin: 0; font-weight: 600; }
.reqact { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; } .reqact input { flex: 1; min-width: 220px; }
nav.tabs { display: flex; gap: 6px; flex-wrap: wrap; }

/* drilling blocks */
.bs-green { --pc: #0a7d0a; --pc-bg: #dff3df; } .bs-orange { --pc: #9a4f00; --pc-bg: #ffe9c7; }
.bs-red { --pc: #a32020; --pc-bg: #fde4e4; } .bs-done { --pc: #1c4f8a; --pc-bg: #e3ebf7; } .bs-grey { --pc: #45443f; --pc-bg: #ececea; }
.bstate { display: inline-block; padding: 3px 9px; border-radius: 6px; font-size: 14px; font-weight: 800; background: var(--pc-bg); color: var(--pc); white-space: nowrap; }
.pbar.bs-orange > i { background: #e08a00; }
.blockform { display: grid; gap: 10px; } .blockform label { display: grid; gap: 4px; }
.blockform .g2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.blockform h3 { margin: 8px 0 0; }
.calc { background: #f2f6fb; border: 1px solid #c9d7ea; border-radius: 8px; padding: 8px 10px; font-size: 16px; }
.actions-row { display: flex; gap: 8px; flex-wrap: wrap; }
dl.calcs { display: grid; grid-template-columns: max-content 1fr; gap: 8px 14px; margin: 0 0 12px; }
dl.calcs dt { color: var(--muted); font-weight: 700; } dl.calcs dd { margin: 0; }
.bgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); gap: 12px; }
.bcard { border: 1px solid var(--line); border-left: 6px solid var(--pc); border-radius: 10px; padding: 10px 12px; }
.bcard h3 { margin: 0; font-size: 19px; display: flex; justify-content: space-between; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.bcard dl { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 10px; margin: 6px 0 0; font-size: 14px; }
.bcard dt { color: var(--muted); font-weight: 700; font-size: 12px; text-transform: uppercase; } .bcard dd { margin: 0 0 4px; font-weight: 700; }
.alerts li.info { background: #e3ebf7; color: #1c4f8a; }
@media (max-width: 600px) { .blockform .g2, dl.calcs { grid-template-columns: 1fr; } }
table.blocks { font-size: 14px; } table.blocks th { font-size: 11px; } table.blocks th, table.blocks td { padding: 6px 6px; }
table.blocks td { white-space: nowrap; } table.blocks td .small { white-space: normal; }
