/* Roemer's Grinding Works – brand styling (after roemers.co.za: Poppins, deep navy, royal blue, steel grey) */
:root {
  /* brand */
  --navy-900: #0e152f;
  --navy: #1b2c60;          /* headings */
  --logo-navy: #283963;     /* logo ink */
  --royal: #213a82;         /* primary / top strip */
  --royal-2: #2e499f;       /* hover */
  --bright: #3467ef;        /* link / highlight */
  --steel: #999fad;         /* saw blade grey */
  --steel-soft: #e9ebf0;

  /* surfaces & text */
  --bg: #f3f5f9;
  --surface: #ffffff;
  --surface-2: #f6f7fb;
  --border: #e2e5ec;
  --border-strong: #cdd2dc;
  --text: #333333;
  --heading: var(--navy);
  --muted: #777777;
  --accent: var(--royal);
  --accent-ink: #ffffff;
  --accent-soft: #e6ebf8;

  --ok: #1f7a4d;   --ok-soft: #e2f3ea;
  --warn: #9a6400; --warn-soft: #fbf0d9;
  --bad: #b42318;  --bad-soft: #fde7e5;
  --info: #213a82; --info-soft: #e6ebf8;
  --hold: #5b4b8a; --hold-soft: #ece9f5;

  /* chart series: navy, bright blue, steel */
  --s1: #1b2c60; --s2: #3467ef; --s3: #999fad;

  --shadow: 0 1px 2px rgba(14,21,47,.05), 0 2px 8px rgba(14,21,47,.06);
  --radius: 4px;
  --font: "Poppins", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1024; --surface: #131a35; --surface-2: #19213f; --border: #262f52; --border-strong: #34406a;
    --text: #e3e6ef; --heading: #e9edfa; --muted: #9ba3bb; --accent: #6f8ff5; --accent-ink: #0b1024; --accent-soft: #1d2a55;
    --ok: #5cc48e; --ok-soft: #153126; --warn: #e2b04a; --warn-soft: #382c12; --bad: #f2776b; --bad-soft: #3c1b1a;
    --info: #9db4ff; --info-soft: #1d2a55; --hold: #b9a8ec; --hold-soft: #2a2448; --steel-soft: #232b48;
    --s1: #9db4ff; --s2: #3467ef; --s3: #999fad; --shadow: none;
  }
}
:root[data-theme="dark"] {
  --bg: #0b1024; --surface: #131a35; --surface-2: #19213f; --border: #262f52; --border-strong: #34406a;
  --text: #e3e6ef; --heading: #e9edfa; --muted: #9ba3bb; --accent: #6f8ff5; --accent-ink: #0b1024; --accent-soft: #1d2a55;
  --ok: #5cc48e; --ok-soft: #153126; --warn: #e2b04a; --warn-soft: #382c12; --bad: #f2776b; --bad-soft: #3c1b1a;
  --info: #9db4ff; --info-soft: #1d2a55; --hold: #b9a8ec; --hold-soft: #2a2448; --steel-soft: #232b48;
  --s1: #9db4ff; --s2: #3467ef; --s3: #999fad; --shadow: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { color: var(--heading); font-weight: 700; }
.hidden { display: none !important; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }

/* ---- top strip (navy, like the site's contact bar) ---- */
.strip { background: var(--royal); color: #fff; font-size: 13px; }
.strip-inner { max-width: 1800px; margin: 0 auto; padding: 6px 20px; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.strip-title { text-transform: uppercase; letter-spacing: .08em; font-weight: 500; font-size: 12px; opacity: .9; }
.dayctl { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.openday { display: flex; align-items: baseline; gap: 8px; padding: 3px 0; }
.openday .label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; opacity: .75; }
.openday strong { font-weight: 600; }
.whoami { display: flex; align-items: center; gap: 8px; padding-left: 12px; border-left: 1px solid rgba(255,255,255,.25); }
.whoami a { color: #fff; opacity: .85; text-decoration: underline; font-size: 12px; }
.role-chip { font-size: 10px; text-transform: uppercase; letter-spacing: .08em; background: rgba(255,255,255,.16); padding: 2px 7px; border-radius: 2px; font-weight: 600; }
body.readonly td[data-k] { cursor: default; }
/* ---- sign-in / error page ---- */
body.auth-page { min-height: 100vh; display: grid; place-items: center; background: var(--royal); padding: 16px; }
.auth-card { background: #fff; color: #1f2430; width: min(400px, 100%); padding: 28px 28px 24px; border-top: 4px solid var(--bright); box-shadow: 0 10px 30px rgba(0,0,0,.25); }
.auth-card h1 { font-size: 20px; margin: 18px 0 8px; color: var(--navy); }
.auth-card p { color: #4a5160; line-height: 1.5; }
.auth-card .form { display: grid; gap: 12px; margin-top: 12px; }
.auth-card .field label { color: #4a5160; }
.auth-card input, .auth-card select { background: #fff; color: #1f2430; }
.auth-logo { max-width: 220px; height: auto; display: block; }
.btn-ms { display: flex; align-items: center; justify-content: center; gap: 12px; width: 100%; height: 44px; margin: 20px 0 6px;
  padding: 0 16px; background: #fff; border: 1px solid #8c8c8c; border-radius: 2px; color: #5e5e5e;
  font: 600 15px "Segoe UI", var(--font); text-decoration: none; cursor: pointer; }
.btn-ms:hover { background: #f3f3f3; color: #2f2f2f; }
.btn-ms:focus-visible { outline: 2px solid var(--bright); outline-offset: 2px; }
.btn-ms svg { width: 21px; height: 21px; flex: none; }
.auth-card .auth-note { font-size: 12.5px; margin-top: 10px; }
.warn { background: #fbf0d9; color: #7a4f00; padding: 2px 10px; border-radius: 2px; font-size: 12px; font-weight: 600; }

/* ---- white brand bar with logo + nav (always light, like the website header) ---- */
.brandbar { background: #ffffff; border-bottom: 1px solid #e2e5ec; box-shadow: 0 2px 10px rgba(14,21,47,.06); position: sticky; top: 0; z-index: 30; }
.brandbar-inner { max-width: 1800px; margin: 0 auto; padding: 0 20px; display: flex; align-items: center; gap: 24px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; padding: 10px 0; }
.logo-img { height: 46px; width: auto; display: block; }
.tabs { display: flex; gap: 2px; overflow-x: auto; flex: 1; scrollbar-width: thin; }
.tabs > .tab:first-child { margin-left: auto; }
.tab { padding: 20px 11px 18px; border: 0; background: none; cursor: pointer; color: #0e152f; white-space: nowrap;
  border-bottom: 3px solid transparent; font-weight: 600; font-size: 13px; }
.tab:hover { color: #3467ef; }
.tab.active { color: #213a82; border-bottom-color: #213a82; }
.tab .count { font-size: 11px; background: #e9ebf0; border-radius: 2px; padding: 0 6px; margin-left: 6px; color: #5a6276; font-weight: 500; }
@media (max-width: 1440px) {
  .tabs { flex-basis: 100%; margin: 0 -8px; }
  .tabs > .tab:first-child { margin-left: 0; }
  .tab { padding: 10px 11px; }
  .brand { padding: 10px 0 2px; }
}

main { padding: 22px 20px 50px; max-width: 1800px; margin: 0 auto; }
.foot { text-align: center; color: var(--muted); font-size: 12px; padding: 18px 16px 28px; border-top: 1px solid var(--border); }

/* ---- buttons (square, uppercase like the site's CTAs) ---- */
.btn { border: 1px solid var(--border-strong); background: var(--surface); padding: 7px 14px; border-radius: 2px;
  cursor: pointer; font-weight: 500; white-space: nowrap; text-transform: uppercase; letter-spacing: .05em; font-size: 12px; }
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--royal); border-color: var(--royal); color: #fff; }
.btn.primary:hover { background: var(--royal-2); border-color: var(--royal-2); color: #fff; }
.btn.light { background: #fff; border-color: #fff; color: var(--royal); font-weight: 600; }
.btn.light:hover { background: #e6ebf8; color: var(--royal); }
.btn.danger { color: var(--bad); }
.btn.danger:hover { border-color: var(--bad); }
.btn.sm { padding: 3px 9px; font-size: 11px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.icon-btn { border: 0; background: none; cursor: pointer; padding: 4px 6px; border-radius: 2px; color: var(--muted); }
.icon-btn:hover { background: var(--accent-soft); color: var(--accent); }

/* ---- page hero band (royal blue with soft "bokeh" circles, after the site's blue sections) ---- */
.page-head { position: relative; overflow: hidden; display: flex; align-items: flex-end; justify-content: space-between; gap: 12px;
  margin: 0 0 20px; padding: 26px 26px 22px; flex-wrap: wrap; color: #fff; border-radius: var(--radius);
  background:
    radial-gradient(circle at 88% 20%, rgba(255,255,255,.10) 0 70px, transparent 71px),
    radial-gradient(circle at 72% 110%, rgba(255,255,255,.07) 0 110px, transparent 111px),
    radial-gradient(circle at 97% 95%, rgba(255,255,255,.06) 0 40px, transparent 41px),
    linear-gradient(120deg, #1b2c60 0%, #213a82 55%, #2e499f 100%); }
.page-head h1 { font-size: 24px; margin: 0; color: #fff; letter-spacing: .01em; }
.page-head h1::before { content: ""; display: block; width: 42px; height: 3px; background: var(--steel); margin-bottom: 10px; }
.page-head .muted { color: rgba(255,255,255,.78); }
.page-head .btn { background: transparent; color: #fff; border-color: rgba(255,255,255,.6); }
.page-head .btn:hover { background: #fff; color: var(--royal); }

/* ---- cards ---- */
.grid { display: grid; gap: 18px; }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3, .g2 { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 560px) { .logo-img { height: 34px; } .tab { padding: 8px 10px; } .g4 { grid-template-columns: minmax(0, 1fr); } main { padding: 16px 16px 40px; } .page-head { padding: 20px 16px; } }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 0; }
.card-head { padding: 14px 16px 0; display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.card-head h3 { margin: 0; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.card-head h3::before { content: ""; width: 4px; height: 16px; background: var(--accent); border-radius: 1px; }
.card-body { padding: 10px 16px 16px; overflow-x: auto; }
.stat { padding: 16px 18px; border-top: 0; border-left: 4px solid var(--accent); }
.stat .k { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; font-weight: 600; }
.stat .v { font-size: 30px; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 2px; color: var(--heading); line-height: 1.2; }
.stat .sub { color: var(--muted); font-size: 12px; }
.g4 > .stat:nth-child(2) { border-left-color: var(--bright); }
.g4 > .stat:nth-child(3) { border-left-color: var(--steel); }
.g4 > .stat:nth-child(4) { border-left-color: var(--navy-900); }
:root[data-theme="dark"] .g4 > .stat:nth-child(4) { border-left-color: #9db4ff; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .g4 > .stat:nth-child(4) { border-left-color: #9db4ff; } }
.section-title { font-size: 16px; margin: 28px 0 12px; }

table.t { width: 100%; border-collapse: collapse; font-size: 13px; }
table.t th, table.t td { padding: 7px 9px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; }
table.t th { color: var(--heading); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; background: var(--surface-2); }
table.t tr.total td { font-weight: 700; color: var(--heading); border-top: 2px solid var(--accent); background: var(--accent-soft); }
table.t tr.zero td { color: var(--muted); }
table.t tbody tr:hover td { background: var(--surface-2); }
.pct { display: inline-block; min-width: 46px; }
.bar { height: 6px; background: var(--steel-soft); border-radius: 1px; overflow: hidden; width: 80px; display: inline-block; vertical-align: middle; margin-left: 6px; }
.bar > i { display: block; height: 100%; background: var(--accent); }

/* ---- chips ---- */
.chip { display: inline-block; padding: 1px 8px; border-radius: 2px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.c-todo { background: var(--info-soft); color: var(--info); }
.c-prog { background: var(--warn-soft); color: var(--warn); }
.c-fault, .c-fail { background: var(--bad-soft); color: var(--bad); }
.c-done, .c-ok { background: var(--ok-soft); color: var(--ok); }
.c-hold { background: var(--hold-soft); color: var(--hold); }
.c-none { background: var(--steel-soft); color: var(--muted); }

/* ---- list toolbar & grid ---- */
.toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.toolbar .grow { flex: 1; }
.search, .filter-sel { padding: 7px 10px; border: 1px solid var(--border-strong); border-radius: 2px; background: var(--surface); }
.search { min-width: 260px; }
.filter-sel { max-width: 190px; }
.search:focus, .filter-sel:focus, .field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }
.summary-line { color: var(--muted); font-size: 13px; }

.grid-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: auto;
  max-height: calc(100vh - 240px); box-shadow: var(--shadow); }
table.jobs { border-collapse: separate; border-spacing: 0; font-size: 13px; min-width: 100%; }
table.jobs th { position: sticky; top: 0; background: var(--royal); z-index: 2; text-align: left; font-weight: 600;
  color: #fff; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; padding: 9px 8px; white-space: nowrap;
  cursor: pointer; user-select: none; }
table.jobs th:hover { background: var(--royal-2); }
table.jobs th.sorted { background: var(--navy); box-shadow: inset 0 -3px 0 var(--steel); }
table.jobs td { padding: 0; border-bottom: 1px solid var(--border); height: 32px; vertical-align: middle; }
table.jobs tbody tr:nth-child(even) td { background: color-mix(in srgb, var(--surface-2) 60%, var(--surface)); }
table.jobs td .cell { padding: 5px 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: text; min-height: 31px; }
table.jobs td.ro .cell { cursor: default; }
table.jobs tr:hover td { background: var(--accent-soft) !important; }
table.jobs td.editing { outline: 2px solid var(--accent); outline-offset: -2px; background: var(--surface) !important; }
table.jobs td input, table.jobs td select { width: 100%; border: 0; padding: 5px 8px; background: var(--surface); outline: none; height: 31px; }
table.jobs td.sticky-l, table.jobs th.sticky-l { position: sticky; left: 0; z-index: 1; background: var(--surface); }
table.jobs th.sticky-l { z-index: 3; background: var(--royal); }
table.jobs td.actions { white-space: nowrap; padding: 0 4px; }
table.jobs td.actions .icon-btn[data-act="next"] { color: var(--accent); font-weight: 700; }
td.late .cell { color: var(--bad); font-weight: 600; }
td.soon .cell { color: var(--warn); font-weight: 600; }
td.flash { animation: flash 1s ease; }
@keyframes flash { from { background: var(--ok-soft); } to { background: transparent; } }
.ms-group { border-left: 2px solid var(--steel); }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; padding: 12px 0; }

/* ---- menus ---- */
.menu { position: fixed; background: var(--surface); border: 1px solid var(--border-strong); border-top: 3px solid var(--accent); border-radius: 2px;
  box-shadow: 0 10px 28px rgba(14,21,47,.18); padding: 4px; z-index: 60; min-width: 200px; }
.menu button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 7px 10px; border-radius: 2px; cursor: pointer; }
.menu button:hover { background: var(--accent-soft); color: var(--accent); }
.menu hr { border: 0; border-top: 1px solid var(--border); margin: 4px 0; }
.menu .danger { color: var(--bad); }

/* ---- modal ---- */
.modal-back { position: fixed; inset: 0; background: rgba(14,21,47,.55); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: var(--surface); border-radius: var(--radius); width: min(760px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column;
  border: 1px solid var(--border); overflow: hidden; box-shadow: 0 20px 50px rgba(14,21,47,.3); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; background: var(--royal); }
.modal-head h2 { margin: 0; font-size: 16px; color: #fff; }
.modal-head .icon-btn { color: rgba(255,255,255,.8); }
.modal-head .icon-btn:hover { background: rgba(255,255,255,.15); color: #fff; }
.modal-body { padding: 18px; overflow: auto; }
.modal-foot { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; background: var(--surface-2); }
.form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; }
.form .full { grid-column: 1 / -1; }
@media (max-width: 560px) { .form { grid-template-columns: 1fr; } }
.field label { display: block; font-size: 11px; color: var(--heading); margin-bottom: 4px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.page-head .field label { color: #fff; }
.field input, .field select, .field textarea { width: 100%; padding: 7px 9px; border: 1px solid var(--border-strong); border-radius: 2px; background: var(--surface); }
.field textarea { min-height: 60px; resize: vertical; }
.err { color: var(--bad); font-size: 13px; margin-top: 8px; }

.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: var(--navy-900); color: #fff; border-left: 4px solid var(--bright);
  padding: 10px 16px; border-radius: 2px; z-index: 70; font-weight: 500; max-width: calc(100vw - 32px); box-shadow: 0 8px 24px rgba(14,21,47,.25); }
.toast.bad { background: var(--bad); border-left-color: #fff; }

/* ---- pivot / history / lookups ---- */
.slicers { display: flex; gap: 12px; flex-wrap: wrap; align-items: end; margin-bottom: 16px; padding: 14px 16px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.slicers .field { min-width: 150px; }
.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 2px; overflow: hidden; }
.seg button { border: 0; background: var(--surface); padding: 6px 12px; cursor: pointer; border-right: 1px solid var(--border); font-size: 13px; }
.seg button:last-child { border-right: 0; }
.seg button:hover { color: var(--accent); }
.seg button.on { background: var(--royal); color: #fff; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--heading); }
.list-pick { display: flex; flex-direction: column; gap: 2px; }
.list-pick button { text-align: left; border: 0; background: none; padding: 8px 10px; border-radius: 2px; cursor: pointer; display: flex; justify-content: space-between; border-left: 3px solid transparent; }
.list-pick button:hover { background: var(--surface-2); }
.list-pick button.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; border-left-color: var(--accent); }
.lk-row { display: flex; align-items: center; gap: 6px; padding: 5px 6px; border-bottom: 1px solid var(--border); }
.lk-row span { flex: 1; }
.callout { background: var(--accent-soft); color: var(--text); border-left: 4px solid var(--accent); border-radius: 2px; padding: 10px 14px; font-size: 13px; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 1px; margin-right: 5px; vertical-align: -1px; }
svg text { fill: var(--muted); font-size: 11px; font-family: var(--font); }

/* ---- Owner View ---- */
.hero-ctl { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.hero-ctl input[type="date"] { padding: 6px 9px; border: 1px solid rgba(255,255,255,.6); border-radius: 2px; background: rgba(255,255,255,.12); color: #fff; color-scheme: dark; }
.tile { padding: 18px 20px; border-left: 6px solid var(--steel); }
.tile.lvl-ok { border-left-color: var(--ok); }
.tile.lvl-warn { border-left-color: var(--warn); }
.tile.lvl-bad { border-left-color: var(--bad); }
.tile .k { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; font-weight: 600; }
.tile .v { font-size: 40px; font-weight: 700; color: var(--heading); line-height: 1.15; margin-top: 4px; font-variant-numeric: tabular-nums; }
.tile .v small { font-size: 15px; font-weight: 500; color: var(--muted); }
.tile .sub { color: var(--text); font-size: 13px; margin-top: 2px; }
.tile .foot-line { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); font-size: 12px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.tile a { color: var(--accent); font-weight: 600; text-decoration: none; }
.bad-t { color: var(--bad); }
.delta { font-weight: 600; }
.delta.up { color: var(--ok); }
.delta.down { color: var(--bad); }
.flow-sum { font-size: 13px; margin-top: 8px; color: var(--text); }
table.t td.desc { max-width: 280px; overflow: hidden; text-overflow: ellipsis; }
table.t tr.hot td { background: var(--warn-soft); font-weight: 600; }
table.targets input { width: 100%; padding: 6px 8px; border: 1px solid var(--border-strong); border-radius: 2px; background: var(--surface); }
