:root {
  --ground: #F2F3F1;
  --surface: #FFFFFF;
  --ink: #16181B;
  --muted: #4B5157;
  --line: #CDD1D5;
  --line-soft: #E2E5E7;
  --accent: #C2410C;
  --accent-dark: #9A3412;
  --accent-tint: #FFF4ED;
  --ok: #1F6F43;
  --ok-tint: #EAF5EE;
  --radius: 10px;
  font-family: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color: var(--ink);
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--ground); line-height: 1.45; }
h1 { font-size: 26px; line-height: 1.2; margin: 0 0 4px; }
a { color: var(--accent); }
a:hover { color: var(--accent-dark); }

.topbar { background: var(--ink); color: var(--ground); }
.topbar-inner { max-width: 1100px; margin: 0 auto; padding: 0 16px; min-height: 56px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.brand { color: #fff; font-weight: 700; font-size: 17px; text-decoration: none; }
.brand:hover { color: #fff; }
.who { display: flex; align-items: center; gap: 16px; font-size: 14px; color: #D2D6DA; }
.who form { margin: 0; }
.link-button { background: none; border: 0; padding: 8px 0; min-height: 44px; color: #fff; font: inherit;
  text-decoration: underline; cursor: pointer; }

.page { max-width: 1100px; margin: 0 auto; padding: 28px 16px 48px; }
.muted { color: var(--muted); margin: 0; }
.small { font-size: 13px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.login { max-width: 420px; margin: 40px auto; padding: 28px; }
.stack { display: flex; flex-direction: column; gap: 16px; margin-top: 20px; }
.field { display: flex; flex-direction: column; gap: 6px; }
label { font-size: 14px; font-weight: 600; }
input, select {
  font: inherit; font-size: 16px; min-height: 44px; padding: 0 12px; color: var(--ink);
  background: #fff; border: 1px solid #8F959B; border-radius: 8px;
}
input:focus-visible, select:focus-visible, button:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
button.primary {
  font: inherit; font-size: 16px; font-weight: 600; min-height: 48px; padding: 0 22px;
  color: #fff; background: var(--accent); border: 0; border-radius: 8px; cursor: pointer;
}
button.primary:hover { background: var(--accent-dark); }
button.primary:active { transform: translateY(1px); }

.alert { margin: 12px 0; padding: 12px 14px; border-radius: 8px; background: var(--accent-tint);
  border: 1px solid var(--accent); color: var(--accent-dark); }
.notice { margin: 12px 0; padding: 12px 14px; border-radius: 8px; background: var(--ok-tint);
  border: 1px solid var(--ok); color: var(--ok); }

.heading-row { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px;
  flex-wrap: wrap; margin-bottom: 16px; }
.week-picker { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.table-card { padding: 0; overflow: hidden; }
.table-scroll { overflow-x: auto; }
table.fuel { width: 100%; border-collapse: collapse; font-size: 15px; }
table.fuel thead th { text-align: left; font-size: 13px; font-weight: 600; color: var(--muted);
  padding: 12px 16px; border-bottom: 1px solid var(--line); background: #F7F8F7; white-space: nowrap; }
table.fuel td, table.fuel tbody th { padding: 8px 16px; border-bottom: 1px solid var(--line-soft);
  vertical-align: middle; text-align: left; font-weight: 400; }
table.fuel .num { text-align: right; }
table.fuel td.num input { width: 110px; text-align: right; font-family: 'IBM Plex Mono', monospace; }
table.fuel tr.flag { background: var(--accent-tint); }
table.fuel tr.down th { color: var(--muted); }
.unit { font-family: 'IBM Plex Mono', monospace; font-weight: 500; margin-right: 6px; }
.tag { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 999px;
  background: var(--line-soft); color: var(--muted); margin-left: 6px; white-space: nowrap; }
td.check { min-width: 240px; font-size: 13px; }
.warn, .err { display: block; color: var(--accent-dark); }
.err { font-weight: 600; }
input[aria-invalid="true"] { border-color: var(--accent); border-width: 2px; }

.form-foot { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 16px; border-top: 1px solid var(--line); }
.form-foot p { max-width: 60ch; }
.last-saved { padding: 0 16px 16px; }

/* Admin navigation and pages */
.nav { display: flex; gap: 4px; flex-wrap: wrap; margin-right: auto; margin-left: 24px; }
.nav a { color: #D2D6DA; text-decoration: none; font-size: 14px; padding: 10px 12px; border-radius: 6px;
  min-height: 44px; display: inline-flex; align-items: center; }
.nav a:hover { color: #fff; background: #2B2F33; }
.nav a[aria-current="page"] { color: #fff; background: #2B2F33; font-weight: 600; }
h2 { font-size: 18px; margin: 0 0 4px; }
.pad { padding: 20px; }
.admin-grid { display: grid; grid-template-columns: minmax(280px, 380px) minmax(0, 1fr); gap: 20px;
  align-items: start; margin-top: 16px; }
.stack-col { display: flex; flex-direction: column; gap: 20px; }
.two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.stack.tight { gap: 10px; margin-top: 0; }
.strong { font-weight: 600; margin: 0; }
.mono { font-family: 'IBM Plex Mono', monospace; }
button.secondary { font: inherit; font-size: 15px; font-weight: 600; min-height: 44px; padding: 0 16px;
  color: var(--ink); background: #fff; border: 1px solid #8F959B; border-radius: 8px; cursor: pointer; }
button.secondary:hover { border-color: var(--ink); }
button.primary:disabled { background: #8F959B; cursor: progress; }
table.users { width: 100%; border-collapse: collapse; font-size: 15px; }
table.users thead th { text-align: left; font-size: 13px; font-weight: 600; color: var(--muted); padding: 12px 16px;
  border-bottom: 1px solid var(--line); background: #F7F8F7; }
table.users td, table.users tbody th { padding: 10px 16px; border-bottom: 1px solid var(--line-soft);
  text-align: left; font-weight: 400; vertical-align: top; }
table.users tr.inactive th, table.users tr.inactive td { color: var(--muted); }
.people { overflow: hidden; }
.people-head, .person > summary { display: grid; grid-template-columns: 1.4fr 1fr 1.1fr 0.8fr 70px; gap: 12px;
  align-items: center; padding: 12px 16px; }
.people-head { font-size: 13px; font-weight: 600; color: var(--muted); background: #F7F8F7; border-bottom: 1px solid var(--line); }
.person { border-bottom: 1px solid var(--line-soft); }
.person:last-child { border-bottom: 0; }
.person > summary { cursor: pointer; list-style: none; min-height: 48px; font-size: 15px; }
.person > summary::-webkit-details-marker { display: none; }
.person > summary:hover { background: #FAFAF9; }
.person[open] > summary { background: #F7F8F7; }
.person.inactive > summary { color: var(--muted); }
.p-change { color: var(--accent); font-weight: 600; text-align: right; }
.person[open] .p-change { color: var(--muted); }
.edit-panel { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; padding: 16px 16px 20px;
  background: #FAFAF9; border-top: 1px solid var(--line-soft); }
.check-row { display: flex; align-items: center; gap: 8px; font-weight: 400; min-height: 44px; }
.check-row input { min-height: 0; width: 20px; height: 20px; }
.price-list { list-style: none; padding: 0; margin: 14px 0 0; border-top: 1px solid var(--line-soft); }
.price-list li { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--line-soft);
  font-size: 14px; }
td.downloads { display: flex; gap: 16px; }
td.downloads a { font-weight: 600; min-height: 32px; display: inline-flex; align-items: center; }

/* Overview and machine pages */
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin: 8px 0 20px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.tile-value { font-family: 'IBM Plex Mono', monospace; font-size: 26px; font-weight: 500; line-height: 1.2; }
.tile-label { font-size: 13px; color: var(--muted); margin-top: 2px; }
.alert-tile { background: var(--accent-tint); border-color: var(--accent); }
.alert-tile .tile-value { color: var(--accent-dark); }
.small-tiles .tile-value { font-size: 22px; }
.overview-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: 20px; align-items: start;
  margin-bottom: 20px; }
.attention { list-style: none; padding: 0; margin: 12px 0 0; }
.attention li { display: grid; grid-template-columns: 56px minmax(0, 1fr); gap: 12px; padding: 10px 0;
  border-top: 1px solid var(--line-soft); }
.attention .level { font-size: 12px; font-weight: 600; padding: 2px 0; text-align: center; border-radius: 999px;
  height: fit-content; background: var(--line-soft); color: var(--muted); }
.attention li.high .level { background: var(--accent-tint); color: var(--accent-dark); }
.a-title { margin: 0; font-weight: 600; }
.chart { width: 100%; height: auto; display: block; margin-top: 8px; font-family: 'IBM Plex Sans', sans-serif; }
.chart-gap { margin-top: 24px; }
.legend { display: flex; gap: 16px; font-size: 13px; color: var(--muted); margin-top: 6px; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.table-view { margin-top: 12px; }
.table-view summary { cursor: pointer; color: var(--accent); font-weight: 600; font-size: 14px; min-height: 32px; }
table.mini { width: 100%; border-collapse: collapse; font-size: 14px; margin-top: 8px; }
table.mini th, table.mini td { padding: 7px 10px; border-bottom: 1px solid var(--line-soft); text-align: left; font-weight: 400; }
table.mini thead th { font-size: 12px; font-weight: 600; color: var(--muted); }
table.mini .num, table.users .num { text-align: right; font-variant-numeric: tabular-nums; }
.sites-card { margin-bottom: 20px; }
.bad { color: var(--accent-dark); font-weight: 600; }
.filter-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0 16px; }
.chip { font: inherit; font-size: 14px; min-height: 40px; padding: 0 14px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line); background: #fff; color: var(--ink); }
.chip[aria-pressed="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }
table.machines tr.flag { background: var(--accent-tint); }
table.machines th a { font-weight: 600; text-decoration: none; }
.status-pill { padding: 8px 14px; border-radius: 999px; background: var(--ok-tint); color: var(--ok); font-weight: 600; font-size: 14px; }
.status-pill.down { background: var(--accent-tint); color: var(--accent-dark); }
.wo-list { list-style: none; padding: 0; margin: 12px 0 0; }
.wo-list li { padding: 10px 0; border-top: 1px solid var(--line-soft); }
.wo-list p { margin: 2px 0; }
.tag.open { background: var(--accent-tint); color: var(--accent-dark); }

/* Ask page */
.ask-form { display: flex; flex-direction: column; gap: 8px; margin: 12px 0 20px; }
textarea { font: inherit; font-size: 16px; padding: 10px 12px; border: 1px solid #8F959B; border-radius: 8px;
  resize: vertical; color: var(--ink); }
textarea:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.ask-actions { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.examples { display: flex; flex-wrap: wrap; gap: 8px; flex: 1; }
.chip.example { font-size: 13px; min-height: 36px; }
.answer { margin-bottom: 20px; border-color: var(--ink); }
.answer-text p { margin: 8px 0; }
.answer-text ul { margin: 8px 0; padding-left: 20px; }
.answer-text li { margin: 4px 0; }
pre.context { white-space: pre-wrap; font-size: 12px; background: #F7F8F7; border: 1px solid var(--line-soft);
  border-radius: 8px; padding: 12px; max-height: 420px; overflow: auto; }
.recent-q { color: var(--ink) !important; font-weight: 600; }

@media (max-width: 860px) {
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .overview-grid { grid-template-columns: 1fr; }
  .admin-grid { grid-template-columns: 1fr; }
  .people-head { display: none; }
  .person > summary { grid-template-columns: 1fr auto; }
  .person > summary > span:nth-child(2), .person > summary > span:nth-child(4) { display: none; }
  .edit-panel { grid-template-columns: 1fr; }
  .nav { margin-left: 0; width: 100%; order: 3; }
}

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

@media (max-width: 640px) {
  h1 { font-size: 22px; }
  /* Each machine becomes a card: name, then labeled hours and gallons, then any checks */
  table.fuel thead { display: none; }
  table.fuel, table.fuel tbody, table.fuel tr { display: block; width: 100%; }
  table.fuel tr { padding: 12px 14px; border-bottom: 1px solid var(--line-soft); }
  table.fuel tbody th { display: block; padding: 0 0 6px; border: 0; font-weight: 600; }
  table.fuel td { display: flex; justify-content: space-between; align-items: center; gap: 12px;
    padding: 4px 0; border: 0; text-align: right; }
  table.fuel td[data-label]:not([data-label=""])::before { content: attr(data-label); font-size: 13px;
    color: var(--muted); text-align: left; }
  table.fuel td.check { display: block; min-width: 0; text-align: left; padding-top: 6px; }
  table.fuel td.check:empty { display: none; }
  .table-scroll { overflow-x: visible; }
  .form-foot button { width: 100%; }
}
