/* CRUZE OilCheck — approved look: pure white, black readable text, CRUZE blue + red accents, light buttons. */
:root {
  color-scheme: light only;
  --blue: #314883;
  --blue-dark: #22335f;
  --blue-light: #e9eef8;
  --blue-line: #c9d4ea;
  --red: #c1272d;
  --red-dark: #8f1b20;
  --red-light: #fbeaea;
  --ink: #000;
  --ink-2: #222;
  --muted: #4a4a4a;
  --line: #d9dde5;
  --ok-bg: #e6f4ea;   --ok-ink: #14532d;
  --warn-bg: #fff3d6; --warn-ink: #6b4200;
  --bad-bg: #fde8e8;  --bad-ink: #8f1b20;
  --radius: 10px;
}
* { box-sizing: border-box; }
html, body { background: #fff !important; color: var(--ink) !important; }
@media (prefers-color-scheme: dark) { html, body { background: #fff !important; color: #000 !important; } }
body { margin: 0; font: 16px/1.5 "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; }
.wrap { max-width: 1200px; margin: 0 auto; padding: 0 20px; }
a { color: var(--blue); }
h1 { font-size: 28px; margin: 6px 0 4px; }
h2 { font-size: 21px; margin: 28px 0 12px; }
h3 { font-size: 17px; margin: 18px 0 8px; }
p { margin: 8px 0; }
small, .small { font-size: 14px; }
.muted { color: var(--muted); }

/* Top bar */
.topbar { background: #fff; border-bottom: 3px solid var(--blue); position: relative; }
.topbar::after { content: ""; position: absolute; left: 0; right: 0; bottom: -6px; height: 3px; background: var(--red); }
.topbar-inner { display: flex; align-items: center; gap: 22px; min-height: 72px; flex-wrap: wrap; padding-top: 8px; padding-bottom: 8px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.brand img { height: 38px; width: auto; }
.brand span { font-weight: 700; font-size: 20px; color: var(--blue); border-left: 2px solid var(--line); padding-left: 10px; }
.mainnav { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
.mainnav a { text-decoration: none; color: var(--ink); font-weight: 600; padding: 8px 12px; border-radius: 8px; }
.mainnav a:hover { background: var(--blue-light); }
.mainnav a.active { background: var(--blue-light); color: var(--blue-dark); box-shadow: inset 0 -3px 0 var(--blue); }
.userbox { display: flex; align-items: center; gap: 8px; }
.who { display: flex; flex-direction: column; text-align: right; font-weight: 600; line-height: 1.2; margin-right: 6px; }
.who small { font-weight: 400; color: var(--muted); }

main.wrap { padding-top: 22px; padding-bottom: 40px; min-height: 70vh; }
.crumbs { font-size: 15px; margin-bottom: 8px; color: var(--muted); }
.crumbs a { text-decoration: none; }
.crumbs .sep { margin: 0 6px; }

/* Buttons — light backgrounds, dark readable text */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 9px 16px; border-radius: 8px; border: 1px solid var(--blue-line);
  background: var(--blue-light); color: var(--blue-dark); font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; line-height: 1.2; }
.btn:hover { border-color: var(--blue); }
.btn-primary { background: #dfe7f6; border-color: var(--blue); color: var(--blue-dark); }
.btn-danger { background: var(--red-light); border-color: #efb9bb; color: var(--red-dark); }
.btn-danger:hover { border-color: var(--red); }
.btn-ghost { background: #fff; border-color: var(--line); color: var(--ink); }
.btn-sm { padding: 6px 10px; font-size: 14px; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
button:disabled, .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }

/* Page head */
.pagehead { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 10px; }
.pagehead .sub { color: var(--muted); font-size: 16px; }

/* Cards / grid */
.card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; margin: 14px 0; }
.card.narrow { max-width: 560px; margin: 40px auto; }
.card h2:first-child, .card h3:first-child { margin-top: 0; }
.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin: 16px 0; }
.stat { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; border-top: 4px solid var(--blue); }
.stat .n { font-size: 30px; font-weight: 700; line-height: 1.1; }
.stat .l { font-size: 15px; color: var(--ink-2); font-weight: 600; }
.stat.s-critical { border-top-color: var(--red); }
.stat.s-caution { border-top-color: #d99a00; }
.stat.s-normal { border-top-color: #2e7d46; }
.stat.s-muted { border-top-color: #9aa3b5; }

/* Key/value */
dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 0; }
dl.kv dt { font-weight: 600; color: var(--ink-2); font-size: 15px; }
dl.kv dd { margin: 0; }

/* Tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
table { border-collapse: collapse; width: 100%; background: #fff; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 15px; font-weight: 700; color: var(--ink); background: #f6f8fc; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.nowrap, .nowrap { white-space: nowrap; }
tr.group td { background: var(--blue-light); font-weight: 700; color: var(--blue-dark); font-size: 15px; }
tr.row-link { cursor: pointer; }
tr.row-link:hover td { background: #fafbfe; }
td .unit { color: var(--muted); font-size: 14px; }
.cell-caution { background: var(--warn-bg) !important; color: var(--warn-ink); font-weight: 700; }
.cell-critical { background: var(--bad-bg) !important; color: var(--bad-ink); font-weight: 700; }

/* Badges */
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 14px; font-weight: 700; border: 1px solid transparent; white-space: nowrap; }
.cond-normal { background: var(--ok-bg); color: var(--ok-ink); border-color: #b8dfc4; }
.cond-caution { background: var(--warn-bg); color: var(--warn-ink); border-color: #f0d38a; }
.cond-critical { background: var(--bad-bg); color: var(--bad-ink); border-color: #f2b5b5; }
.cond-none, .sev-none { background: #f1f2f5; color: #333; border-color: #dcdfe6; }
.sev-s0 { background: #eef8ef; color: #14532d; border-color: #c4e3ca; }
.sev-s1 { background: #d8f0dc; color: #14532d; border-color: #a9d9b3; }
.sev-s2 { background: #fff4c7; color: #5e4300; border-color: #ecd47a; }
.sev-s3 { background: #ffe2c6; color: #7a3300; border-color: #f2b47d; }
.sev-s4 { background: #fbdcdc; color: #8f1b20; border-color: #ee9fa2; }
.sevscale { display: inline-block; }
.sevscale .sevbox { display: inline-block; width: 38px; height: 34px; line-height: 32px; text-align: center; font-weight: 800; font-size: 18px; border: 1px solid #9aa0aa; margin-right: -1px; color: #000; position: relative; }
.sevbox-0 { background: #fff; } .sevbox-1 { background: #b9e7b9; } .sevbox-2 { background: #ffd23f; } .sevbox-3 { background: #f39a3d; } .sevbox-4 { background: #d62828; color: #fff !important; }
.sevscale .sevbox.on { outline: 3px solid #000; outline-offset: -3px; z-index: 1; }
.sevscale .sevbox.on::after { content: "▼"; position: absolute; top: -20px; left: 0; right: 0; font-size: 14px; color: #e07a00; }
.sevscale .sevlabels { display: grid; grid-template-columns: 2fr 2fr 1fr; font-size: 12px; font-weight: 700; text-align: center; margin-top: 3px; letter-spacing: .03em; }
.sevscale .sevbox, .sevscale { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.infohead { background: #9b9b9b; color: #fff; font-weight: 700; text-align: center; padding: 5px 8px; margin: 0 0 8px; border-radius: 4px; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.infogrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px 22px; margin: 14px 0; }
.infogrid dl.kv { grid-template-columns: max-content 1fr; }
@media (max-width: 900px) { .infogrid { grid-template-columns: 1fr; } }
.st-released { background: var(--blue-light); color: var(--blue-dark); border-color: var(--blue-line); }
.st-draft { background: #fff; color: var(--red-dark); border: 1px dashed var(--red); }
.dots { display: inline-flex; gap: 4px; vertical-align: middle; }
.dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; border: 1px solid rgba(0,0,0,.15); }
.dot.normal { background: #2e7d46; } .dot.caution { background: #e0a100; } .dot.critical { background: var(--red); } .dot.none { background: #c4c9d4; }
.dot.s0 { background: #8fd18f; } .dot.s1 { background: #2e9d4a; } .dot.s2 { background: #f2c200; } .dot.s3 { background: #ef8a1a; } .dot.s4 { background: #d62828; }
.trend { font-weight: 700; font-size: 15px; white-space: nowrap; }
.trend.worse { color: var(--red-dark); } .trend.better { color: var(--ok-ink); } .trend.same { color: var(--muted); }
.reasons { margin: 0; padding-left: 18px; }

/* Assessment blocks */
.assess { border-left: 5px solid var(--blue); background: #fafbfe; padding: 14px 16px; border-radius: 0 var(--radius) var(--radius) 0; }
.assess.critical { border-left-color: var(--red); background: #fff8f8; }
.assess.caution { border-left-color: #e0a100; background: #fffcf3; }
.assess-head { display: flex; justify-content: space-between; gap: 18px; flex-wrap: wrap; align-items: flex-end; }
.assess h3 { margin: 0 0 6px; }
.prewrap { white-space: pre-wrap; }

/* Forms */
form .field { margin-bottom: 14px; }
label, .label { display: block; font-weight: 600; font-size: 15px; margin-bottom: 5px; color: var(--ink); }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], select, textarea {
  width: 100%; padding: 10px 12px; font: inherit; color: #000; background: #fff; border: 1px solid #b9c0cc; border-radius: 8px; }
input:focus, select:focus, textarea:focus { outline: 3px solid #bccbeb; border-color: var(--blue); }
textarea { min-height: 110px; resize: vertical; }
.hint { font-size: 14px; color: var(--muted); margin-top: 4px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 16px; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 600; }
.check input { width: 18px; height: 18px; }
.results-input td { padding: 6px 10px; }
.results-input input { padding: 7px 9px; max-width: 160px; }
.sticky-actions { position: sticky; bottom: 0; background: #fff; border-top: 2px solid var(--blue); padding: 12px 0; margin-top: 18px; z-index: 5; }

/* Alerts */
.alert { padding: 12px 16px; border-radius: 8px; margin: 10px 0; font-weight: 600; border: 1px solid; }
.alert-ok { background: var(--ok-bg); color: var(--ok-ink); border-color: #b8dfc4; }
.alert-error { background: var(--bad-bg); color: var(--bad-ink); border-color: #f2b5b5; }
.alert-info { background: var(--blue-light); color: var(--blue-dark); border-color: var(--blue-line); }

/* Charts */
.charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 14px; }
.chart-card { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; break-inside: avoid; }
.chart-card h3 { margin: 0 0 2px; font-size: 16px; }
.chart-card .meta { font-size: 14px; color: var(--muted); }
.chart-card.flagged { border-color: #f0d38a; }
.chart-card.flagged-critical { border-color: #f2b5b5; }
.chart-legend { display: flex; gap: 18px; flex-wrap: wrap; font-size: 14px; margin: 4px 0 12px; align-items: center; }
.chart-legend .ring { display: inline-block; width: 14px; height: 14px; border: 2.5px solid var(--red); border-radius: 50%; vertical-align: middle; }
.chart-legend .dash { display: inline-block; width: 22px; border-top: 2px dashed; vertical-align: middle; }
.trend-chart { width: 100%; height: auto; display: block; }
.trend-chart .grid { stroke: #e7eaf0; stroke-width: 1; }
.trend-chart .ylab, .trend-chart .xlab { font-size: 13px; fill: #222; }
.trend-chart .line { fill: none; stroke: var(--blue); stroke-width: 2.5; }
.trend-chart .pt { stroke: #fff; stroke-width: 2; }
.trend-chart .pt-normal { fill: var(--blue); } .trend-chart .pt-caution { fill: #e0a100; } .trend-chart .pt-critical { fill: var(--red); }
.trend-chart .pt-ring { fill: none; stroke: var(--red); stroke-width: 2.5; }
.trend-chart .lim { stroke-dasharray: 6 5; stroke-width: 1.6; }
.trend-chart .lim-caution { stroke: #c58a00; fill: #8a5d00; } .trend-chart .lim-critical { stroke: var(--red); fill: var(--red-dark); }
.trend-chart .limlab { font-size: 12px; font-weight: 700; stroke: none; }

/* Login */
.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: #fff; }
.login-card { width: 100%; max-width: 440px; border: 1px solid var(--line); border-radius: 14px; padding: 30px 30px 24px; border-top: 5px solid var(--blue); position: relative; }
.login-card::before { content: ""; position: absolute; top: -5px; right: 0; width: 34%; height: 5px; background: var(--red); border-top-right-radius: 14px; }
.login-card img { width: 230px; max-width: 80%; display: block; margin: 4px auto 6px; }
.login-card h1 { text-align: center; font-size: 23px; margin: 8px 0 2px; }
.login-card .lead { text-align: center; color: var(--muted); margin-bottom: 20px; }
.login-card .btn { width: 100%; justify-content: center; padding: 12px; font-size: 17px; }
.login-note { font-size: 14px; color: var(--muted); text-align: center; margin-top: 16px; }

.foot { display: flex; justify-content: space-between; gap: 10px; border-top: 1px solid var(--line); padding-top: 14px; padding-bottom: 24px; font-size: 14px; color: var(--muted); }
.print-only { display: none; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.filters .field { margin: 0; min-width: 180px; }

@media (max-width: 760px) {
  .userbox { width: 100%; justify-content: flex-end; }
  .charts { grid-template-columns: 1fr; }
  dl.kv { grid-template-columns: 1fr; }
  h1 { font-size: 24px; }
}

@media print {
  .topbar .mainnav, .userbox, .no-print, .btn, .crumbs, .sticky-actions { display: none !important; }
  .print-only { display: inline; }
  body { font-size: 12.5px; }
  main.wrap { padding-top: 8px; }
  .card, .chart-card, .table-wrap { break-inside: avoid; }
  .charts { grid-template-columns: 1fr 1fr; }
  a { color: #000; text-decoration: none; }
  th { background: #eef1f7 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .badge, .dot, .cell-caution, .cell-critical, .stat, tr.group td { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* Wear metal history table, as on the laboratory report */
.wm-table th, .wm-table td { padding: 7px 9px; }
.wm-table tr.wm-current td { background: #eef3fc; font-weight: 700; }
.wm-table tr.wm-current td:first-child { box-shadow: inset 4px 0 0 var(--blue); }
