/* ARLLogistics design system. Brand reds from arltruckrepairs.com. Inter is self-hosted. */
@font-face {
  font-family: Inter;
  src: url("/fonts/inter-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: Inter;
  src: url("/fonts/inter-500.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: Inter;
  src: url("/fonts/inter-600.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-1: #ffffff;
  --surface-2: #f3f4f6;
  --surface-3: #f8e8e8;
  --text: #1b1b1b;
  --muted: #5e5e5e;
  --line: #e4e6eb;
  --line-strong: #c6c6c6;
  --primary: #ae373b;
  --primary-dark: #812629;
  --primary-soft: #f8ecec;
  --accent: #d8464b;
  --gold: #ae373b;
  --gold-fill: #ecb0b1;
  --pine: #ae373b;
  --danger: #9d1c1c;
  --ok: #146c36;
  --ok-soft: #e7f6ee;
  --warn: #8a5a00;
  --warn-soft: #fff6e5;
  --dark: #161616;
  --sidebar: #161616;
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(22, 22, 22, 0.06);
  --shadow: 0 8px 24px rgba(22, 22, 22, 0.06);
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --font: Inter, "Segoe UI", sans-serif;
  --text-xs: 12px;
  --text-sm: 13px;
  --text-md: 14px;
  --text-lg: 18px;
  --text-xl: 24px;
  --sidebar-w: 240px;
  --topbar-h: 60px;
  --header: 60px;
  --nav: 64px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  font-size: var(--text-md);
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
}
body.has-nav { padding-bottom: calc(var(--nav) + 16px); }
a { color: var(--primary-dark); text-decoration-thickness: 1px; text-underline-offset: 2px; }
h1, h2, h3 { font-weight: 600; letter-spacing: -0.02em; margin: 0 0 8px; line-height: 1.25; }
h1 { font-size: var(--text-xl); }
h2 { font-size: var(--text-lg); }
p { margin: 0 0 8px; }

.icon { width: 18px; height: 18px; flex: 0 0 18px; }

.app { min-height: 100vh; }
.sidebar {
  display: none;
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: var(--sidebar);
  color: #f4f4f4;
  padding: 18px 12px;
  z-index: 20;
}
.sidebar .logo-plate {
  background: #fff;
  border-radius: var(--radius);
  padding: 8px 10px;
  margin: 0 4px 16px;
}
.sidebar .logo { height: 42px; width: auto; display: block; }
.sidebar .product {
  display: block;
  margin: 8px 4px 0;
  color: #fff;
  font-weight: 600;
  font-size: 14px;
  text-decoration: none;
}
.sidebar nav { display: flex; flex-direction: column; gap: 2px; margin-top: 18px; }
.sidebar a.nav {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #d7d7d7;
  text-decoration: none;
  padding: 9px 10px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
}
.sidebar a.nav:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }
.sidebar a.nav.active { background: var(--primary); color: #fff; }
.topbar {
  display: none;
  position: sticky;
  top: 0;
  z-index: 15;
  height: var(--topbar-h);
  align-items: center;
  gap: 16px;
  padding: 0 24px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: saturate(1.2) blur(8px);
  border-bottom: 1px solid var(--line);
}
.search {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 420px;
  background: var(--surface-2);
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0 12px;
}
.search:focus-within { border-color: var(--primary); background: #fff; }
.search input {
  border: 0;
  background: transparent;
  min-height: 36px;
  padding: 0;
  width: 100%;
}
.search input:focus { outline: none; }
.topbar .shop { font-weight: 600; font-size: 14px; }
.menu { position: relative; margin-left: auto; }
.menu summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  font-weight: 500;
}
.menu summary::-webkit-details-marker { display: none; }
.avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: grid; place-items: center; font-size: 12px; font-weight: 600;
}
.menu-panel {
  position: absolute;
  right: 0; top: calc(100% + 6px);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-width: 200px;
  padding: 6px;
  z-index: 30;
}
.menu-panel a, .menu-panel button {
  width: 100%;
  justify-content: flex-start;
  background: transparent;
  color: var(--text);
  border: 0;
  min-height: 36px;
}
.menu-panel form { margin: 0; }
.content { padding: 20px 16px 32px; max-width: 1200px; }
body:not(.has-nav) .content { max-width: none; padding: 0; min-height: 100vh; }
.mobile-bar {
  position: sticky; top: 0; z-index: 15;
  height: 56px; display: flex; align-items: center; gap: 10px;
  padding: 0 12px; background: #fff; border-bottom: 1px solid var(--line);
}
.mobile-bar .logo { height: 32px; }
.mobile-bar strong { font-size: 14px; }

.page-head {
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end;
  gap: 12px; margin-bottom: 20px;
}
.crumbs { color: var(--muted); font-size: var(--text-sm); margin: 0 0 4px; }
.crumbs a { color: var(--muted); text-decoration: none; }
.sub { color: var(--muted); margin: 0; }
.page-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 20px; }
.kpi {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 14px 16px;
  text-decoration: none;
  color: inherit;
  display: block;
}
.kpi:hover { border-color: var(--line-strong); }
.kpi .label { color: var(--muted); font-size: var(--text-xs); font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; }
.kpi .value { font-size: 28px; font-weight: 600; letter-spacing: -0.03em; margin-top: 4px; }
.kpi .hint { color: var(--muted); font-size: var(--text-xs); }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 16px;
  margin-bottom: 12px;
}
.grid { display: grid; gap: 12px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.muted { color: var(--muted); }
.split { display: grid; gap: 8px; }

button, .button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 8px 14px;
  border-radius: 8px; border: 1px solid var(--primary);
  background: var(--primary); color: #fff;
  font: inherit; font-weight: 600; font-size: 14px;
  text-decoration: none; cursor: pointer;
}
button:hover, .button:hover, .btn:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
button.secondary, .button.secondary, .btn.secondary, .btn-secondary {
  background: #fff; color: var(--text); border-color: var(--line-strong);
}
button.secondary:hover, .button.secondary:hover { background: var(--surface-2); }
.btn.ghost, button.ghost {
  background: transparent; color: var(--text); border-color: transparent;
}
button.ghost:hover { background: var(--surface-2); }
button.warn { background: var(--warn); border-color: var(--warn); color: #fff; }
button.danger, .btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
button:disabled { opacity: 0.45; cursor: not-allowed; }

label {
  display: block; font-size: 12px; font-weight: 600; color: var(--muted);
  margin: 10px 0 4px;
}
input, select, textarea {
  width: 100%; font: inherit; color: var(--text);
  background: #fff; border: 1px solid var(--line-strong);
  border-radius: 8px; padding: 9px 12px; min-height: 40px;
}
textarea { min-height: 88px; resize: vertical; }
.check { display: flex; gap: 8px; align-items: center; font-size: 14px; font-weight: 500; color: var(--text); text-transform: none; }
.check input { width: auto; min-height: 0; }

.pill, .chip {
  display: inline-flex; align-items: center;
  font-size: 12px; font-weight: 600;
  padding: 3px 8px; border-radius: 999px;
  background: var(--surface-2); color: var(--text);
}
.pill.awaiting_authorisation, .pill.pending { background: var(--warn-soft); color: var(--warn); }
.pill.authorised, .pill.estimate { background: var(--primary-soft); color: var(--primary-dark); }
.pill.in_progress { background: var(--ok-soft); color: var(--ok); }
.pill.waiting_on_parts { background: #fff1e6; color: #9a4d12; }
.pill.completed, .pill.paid { background: var(--ok-soft); color: var(--ok); }
.pill.invoiced { background: #e8eefc; color: #1d3f91; }
.pill.closed, .pill.declined { background: #eee; color: #555; }

.table-wrap, .scroll {
  overflow: auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th {
  position: sticky; top: 0; z-index: 1;
  background: #fafafa;
  font-size: 11px; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--muted); font-weight: 600;
}
tbody tr:nth-child(even) { background: #fcfcfd; }
tbody tr:hover { background: #f6f7f9; }
td.money, th.money, .money { text-align: right; font-variant-numeric: tabular-nums; }

.toast, .flash {
  border-radius: 10px; padding: 10px 14px; margin-bottom: 12px;
  border: 1px solid var(--line); background: #fff; box-shadow: var(--shadow-sm);
}
.flash.ok, .toast.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.flash.err, .toast.err { background: #fde8e6; color: var(--danger); border-color: transparent; }

.empty {
  text-align: center; padding: 28px 16px; color: var(--muted);
}
.empty strong { display: block; color: var(--text); margin-bottom: 4px; }

.skeleton {
  background: linear-gradient(90deg, #eee 25%, #f6f6f6 37%, #eee 63%);
  background-size: 400% 100%;
  animation: shimmer 1.2s ease infinite;
  border-radius: 8px; height: 14px;
}
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }

dialog.modal {
  border: 0; border-radius: var(--radius-lg); padding: 0; box-shadow: var(--shadow);
  width: min(480px, calc(100% - 32px));
}
dialog.modal::backdrop { background: rgba(22, 22, 22, 0.45); }

.board { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.column {
  flex: 0 0 200px; background: #f3f4f6;
  border-radius: var(--radius); padding: 10px;
}
.column h2 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.job {
  display: block; background: #fff; border: 1px solid var(--line);
  border-radius: 8px; padding: 10px; margin-bottom: 8px;
  text-decoration: none; color: inherit; box-shadow: var(--shadow-sm);
}
.job:hover { border-color: var(--line-strong); }

.order-layout { display: grid; gap: 16px; }
.totals .line { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid var(--line); }
.totals .grand { font-size: 18px; font-weight: 600; }

.clock-button { width: 100%; font-size: 18px; min-height: 64px; margin: 8px 0; }
.clock-grid { display: grid; gap: 12px; }

.login-shell { min-height: 100vh; display: grid; }
.login-brand {
  display: none; background: var(--dark); color: #fff;
  padding: 48px; 
}
.login-brand .logo-plate { background: #fff; display: inline-block; border-radius: 12px; padding: 16px 18px; }
.login-brand h2 { color: #fff; font-size: 32px; max-width: 420px; margin-top: 28px; }
.login-brand p { color: #cfcfcf; max-width: 420px; }
.login-panel { display: grid; place-items: center; padding: 32px 16px; }
.login-card { width: min(420px, 100%); margin: 0; }
.login-logo { height: 72px; width: auto; display: block; margin: 0 auto 16px; }

:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: 0; border-color: var(--primary); }

@media (min-width: 800px) {
  .sidebar { display: flex; flex-direction: column; width: 76px; padding: 14px 8px; }
  .sidebar .product, .sidebar a.nav span.label { position: absolute; width: 1px; height: 1px; overflow: hidden; }
  .sidebar a.nav { justify-content: center; }
  .sidebar .logo { height: 28px; }
  .topbar { display: flex; margin-left: 76px; }
  .content { margin-left: 76px; padding: 24px; }
  .mobile-bar, .bottom-nav { display: none; }
  body.has-nav { padding-bottom: 0; }
  .kpis { grid-template-columns: repeat(3, 1fr); }
  .split.two { grid-template-columns: 1fr 1fr; }
  .login-shell { grid-template-columns: 1fr 1fr; }
  .login-brand { display: flex; flex-direction: column; justify-content: flex-end; }
}

@media (min-width: 1180px) {
  .sidebar { width: var(--sidebar-w); padding: 18px 12px; }
  .sidebar .product, .sidebar a.nav span.label { position: static; width: auto; height: auto; overflow: visible; }
  .sidebar a.nav { justify-content: flex-start; }
  .sidebar .logo { height: 42px; }
  .topbar, .content { margin-left: var(--sidebar-w); }
  .kpis { grid-template-columns: repeat(6, 1fr); }
  .order-layout { grid-template-columns: minmax(0, 1fr) 300px; align-items: start; }
  .totals { position: sticky; top: 76px; }
  .dash { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; align-items: start; }
  .split.three { grid-template-columns: 1fr 1fr 1fr; }
}

.dash > section:first-child { min-width: 0; }
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; height: var(--nav);
  display: flex; background: #fff; border-top: 1px solid var(--line); z-index: 16;
}
.bottom-nav a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; text-decoration: none; color: var(--text); font-size: 11px; font-weight: 600;
}
@media (min-width: 800px) {
  .bottom-nav { display: none; }
}
