:root {
  --bg: #f4f6f9; --surface: #ffffff; --text: #1d2433; --muted: #5d6779; --border: #dde2ea;
  /* Brand colours: defaults only - overridden by Admin > Settings (see templates/_brand_style.html) */
  --brand: #1e7ab0; --brand-dark: #14557d; --brand-soft: #e4f0f8; --brand-accent: #8ccbef;
  --ok: #1d7a46; --ok-soft: #e3f4ea; --warn: #9a6000; --warn-soft: #fdf1dc;
  --bad: #b3261e; --bad-soft: #fbe5e3; --info: #3d5a80; --info-soft: #e7edf5;
  --radius: 8px; --sidebar: 232px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: 0 0 .25rem; font-weight: 800; letter-spacing: -.01em; }
h2 { font-size: 1.15rem; margin: 0 0 .75rem; }
h3 { font-size: 1rem; margin: 1rem 0 .5rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.pre { white-space: pre-wrap; }

/* layout */
.layout { display: flex; min-height: 100vh; }
.sidebar { width: var(--sidebar); background: var(--brand-dark); color: #fff; flex-shrink: 0; padding: 1rem 0; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.sidebar .brand { padding: 0 .9rem 1rem; font-weight: 700; line-height: 1.25; border-bottom: 1px solid rgba(255,255,255,.12); margin-bottom: .5rem; }
.sidebar .brand small { display: block; font-weight: 400; opacity: .75; font-size: .78rem; }
.sidebar nav a { display: block; color: #dbe7f5; padding: .45rem 1.1rem; font-size: .93rem; }
.sidebar nav a:hover, .sidebar nav a.active { background: rgba(255,255,255,.1); color: #fff; text-decoration: none; }
.sidebar nav a.active { box-shadow: inset 4px 0 0 var(--brand-accent); }
.brand-link { display: block; color: #fff; text-decoration: none !important; }
.sidebar-logo { display: block; width: 100%; max-height: 72px; object-fit: contain; object-position: left; margin-bottom: .35rem; }
.login-logo { display: block; width: 100%; max-width: 300px; max-height: 100px; object-fit: contain; object-position: left; margin-bottom: 1.25rem; }
.sidebar nav .section { padding: .9rem 1.1rem .25rem; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; opacity: .6; }
.sidebar .user { padding: 1rem 1.1rem; border-top: 1px solid rgba(255,255,255,.12); margin-top: 1rem; font-size: .85rem; }
.sidebar .user form { display: inline; }
.sidebar .user button { background: none; border: 0; color: #dbe7f5; padding: 0; cursor: pointer; font: inherit; text-decoration: underline; }
.main { flex: 1; min-width: 0; padding: 1.5rem 2rem 3rem; }
.page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 1.25rem; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.actions form { margin: 0; }
.menu-toggle { display: none; }

/* cards & grid */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.1rem 1.25rem; margin-bottom: 1.25rem; }
.card > h2:first-child { margin-top: 0; }
.grid { display: grid; gap: 1.25rem; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .9rem 1rem; display: block; color: var(--text); }
.stat:hover { text-decoration: none; border-color: var(--brand); }
.stat .value { font-size: clamp(1.1rem, 1.55vw, 1.75rem); font-weight: 700; line-height: 1.1; white-space: nowrap; }
.stat .label { color: var(--muted); font-size: .85rem; }
.stat.bad .value { color: var(--bad); } .stat.warn .value { color: var(--warn); } .stat.ok .value { color: var(--ok); }

dl.details { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1.25rem; margin: 0; }
dl.details dt { color: var(--muted); }
dl.details dd { margin: 0; }

/* tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .55rem .6rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; background: #fafbfc; }
tr:hover td { background: #fafcff; }
td.num, th.num { text-align: right; white-space: nowrap; }
tfoot td { font-weight: 700; border-top: 2px solid var(--border); }
.empty { color: var(--muted); padding: 1rem 0; }

/* badges */
.badge { display: inline-block; padding: .1rem .5rem; border-radius: 999px; font-size: .76rem; font-weight: 600; background: var(--info-soft); color: var(--info); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.grey { background: #eef0f3; color: var(--muted); }
.badge.p1 { background: var(--bad); color: #fff; }

/* forms */
form.stack { display: grid; gap: .9rem; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: .9rem 1.1rem; align-items: start; }
.form-grid .wide { grid-column: 1 / -1; }
label.field { display: grid; gap: .25rem; font-size: .88rem; color: var(--muted); }
label.field span { font-weight: 600; }
label.check { display: flex; align-items: center; gap: .5rem; font-size: .92rem; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=datetime-local], input[type=tel], input[type=search], select, textarea {
  width: 100%; padding: .5rem .6rem; border: 1px solid #c5ccd8; border-radius: 6px; font: inherit; color: var(--text); background: #fff; }
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }
.inline-form { display: flex; flex-wrap: wrap; gap: .5rem; align-items: flex-end; }
.inline-form label.field { min-width: 120px; }
.filters { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: 1rem; }
.filters input, .filters select { width: auto; min-width: 150px; }
.filters input[type=checkbox] { min-width: 0; }

.table-wrap table { font-variant-numeric: tabular-nums; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: .9rem 1rem 1rem; margin: 0; }
legend { font-weight: 700; padding: 0 .35rem; }

.btn { display: inline-flex; align-items: center; gap: .35rem; padding: .48rem .95rem; border-radius: 6px; border: 1px solid var(--brand); background: var(--brand); color: #fff; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--brand-dark); text-decoration: none; }
.btn.secondary { background: #fff; color: var(--brand); }
.btn.secondary:hover { background: var(--brand-soft); }
.btn.danger { background: #fff; color: var(--bad); border-color: var(--bad); }
.btn.danger:hover { background: var(--bad-soft); }
.btn.ok { background: var(--ok); border-color: var(--ok); }
.btn.small { padding: .25rem .6rem; font-size: .82rem; }
.btn.big { padding: .75rem 1.25rem; font-size: 1.02rem; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--bad); cursor: pointer; font: inherit; font-size: .85rem; }

/* flashes */
.flash { padding: .7rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; border: 1px solid; }
.flash.success { background: var(--ok-soft); border-color: #b6dfc6; color: var(--ok); }
.flash.error { background: var(--bad-soft); border-color: #f0bbb6; color: var(--bad); }
.flash.info { background: var(--info-soft); border-color: #c8d5e6; color: var(--info); }

/* tabs */
.tabs { display: flex; flex-wrap: wrap; gap: .25rem; border-bottom: 1px solid var(--border); margin-bottom: 1.25rem; }
.tabs a { padding: .55rem .9rem; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 600; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.active { color: var(--brand); border-bottom-color: var(--brand); }

/* allocation board */
.board { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; }
.job-card { border: 1px solid var(--border); border-left: 4px solid var(--info); border-radius: 6px; padding: .6rem .75rem; margin-bottom: .6rem; background: #fff; font-size: .9rem; }
.job-card.callout { border-left-color: var(--bad); }
.job-card.ppm { border-left-color: var(--ok); }
.job-card.repair { border-left-color: var(--warn); }
.job-card .title { font-weight: 600; }

.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { padding: .45rem 0; border-bottom: 1px dashed var(--border); font-size: .9rem; }

/* login */
/* Diagonal split echoes the angled edge of the Dawson logo */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1rem; background: linear-gradient(112deg, var(--brand) 0 56%, var(--brand-dark) 56% 57%, #eaf3f9 57%); }
.login-card { width: 100%; max-width: 400px; background: #fff; border-radius: 12px; padding: 2rem; box-shadow: 0 10px 40px rgba(0,0,0,.2); }

/* print */
.print-page { max-width: 820px; margin: 0 auto; background: #fff; padding: 2.5rem; }
.print-head { display: flex; justify-content: space-between; gap: 2rem; border-bottom: 3px solid var(--brand); padding-bottom: 1rem; margin-bottom: 1.5rem; }
.print-actions { max-width: 820px; margin: 1rem auto; display: flex; gap: .5rem; }
@media print {
  .no-print, .sidebar, .print-actions { display: none !important; }
  body { background: #fff; }
  .main { padding: 0; }
  .print-page { padding: 0; }
}

@media (max-width: 900px) {
  .layout { display: block; }
  .sidebar { position: static; width: 100%; height: auto; padding: .5rem 0; }
  .sidebar nav, .sidebar .user { display: none; }
  .sidebar.open nav, .sidebar.open .user { display: block; }
  .sidebar .brand { display: flex; justify-content: space-between; align-items: center; border: 0; margin: 0; padding: .25rem 1rem; }
  .menu-toggle { display: inline-block; background: none; border: 1px solid rgba(255,255,255,.4); color: #fff; border-radius: 6px; padding: .3rem .6rem; font: inherit; }
  .main { padding: 1rem; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .filters input, .filters select { min-width: 0; flex: 1 1 140px; }
}

.alloc-grid { grid-template-columns: minmax(280px, 1fr) 3fr; }
@media (max-width: 900px) { .alloc-grid { grid-template-columns: 1fr; } }

.signature-pad { width: 100%; max-width: 560px; height: 190px; border: 2px dashed #9aa6b6; border-radius: 8px; background: #fff; touch-action: none; display: block; }
.signature-img { max-width: 320px; border-bottom: 1px solid var(--text); background: #fff; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .75rem; }
.photo-grid figure { margin: 0; }
.photo-grid img { width: 100%; height: 130px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); display: block; }
.photo-grid figcaption { font-size: .8rem; color: var(--muted); margin-top: .2rem; }
.lw-panel { border-left: 4px solid var(--ok); }
.lw-panel.escalated { border-left-color: var(--bad); background: var(--bad-soft); }
@media print { .photo-grid img { height: 160px; } }
table.compact th, table.compact td { padding: .45rem .4rem; font-size: .88rem; }
table.compact th.num { white-space: normal; }
