/* ============================================================
   นายอะไหล่ยนต์ — Garage System
   Design tokens
============================================================ */

:root {
  /* Type */
  --font-sans: "IBM Plex Sans", "IBM Plex Sans Thai", "Sarabun", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-thai: "IBM Plex Sans Thai", "Sarabun", "IBM Plex Sans", sans-serif;
  --font-mono: "JetBrains Mono", "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  /* Surfaces — warm off-white "paper" feel */
  --bg: #f5f3ee;
  --bg-2: #efece5;
  --surface: #ffffff;
  --surface-2: #faf8f3;
  --surface-3: #f1eee7;
  --line: #e3ded3;
  --line-strong: #d3ccbd;
  --line-soft: #ece8de;

  /* Text */
  --ink: #14110d;
  --ink-2: #3a342b;
  --ink-3: #6c6557;
  --ink-4: #9a9385;
  --ink-5: #b8b1a2;

  /* Accents */
  --accent: #c8302a;        /* signal red — destructive, alerts, active route */
  --accent-ink: #ffffff;
  --accent-soft: #f7e2e0;
  --accent-deep: #8e1b16;

  --ok: #1f7a3a;
  --ok-soft: #dff0e3;
  --warn: #b27300;
  --warn-soft: #fbeccc;
  --info: #1d5fa1;
  --info-soft: #d8e7f5;
  --muted-soft: #ece8de;

  /* Sidebar */
  --sb-bg: #15130f;
  --sb-bg-2: #1c1a15;
  --sb-line: #2a2722;
  --sb-ink: #e9e4d6;
  --sb-ink-2: #a39d8e;
  --sb-ink-3: #6c6657;
  --sb-active-bg: #28241d;
  --sb-active-bar: var(--accent);

  /* Density */
  --row-h: 44px;
  --row-h-tight: 36px;
  --pad-x: 16px;
  --pad-y: 12px;
  --radius: 6px;
  --radius-lg: 10px;

  /* Shadows */
  --shadow-sm: 0 1px 0 rgba(20,17,13,0.04), 0 1px 2px rgba(20,17,13,0.04);
  --shadow-md: 0 1px 0 rgba(20,17,13,0.04), 0 6px 18px -8px rgba(20,17,13,0.18);
  --shadow-lg: 0 10px 40px -12px rgba(20,17,13,0.28);
}

[data-theme="dark"] {
  --bg: #0d0c0a;
  --bg-2: #131210;
  --surface: #1a1815;
  --surface-2: #221f1b;
  --surface-3: #2a2620;
  --line: #2c2823;
  --line-strong: #3a352d;
  --line-soft: #232020;

  --ink: #f3eee0;
  --ink-2: #d4cdba;
  --ink-3: #a39d8e;
  --ink-4: #7a7466;
  --ink-5: #524d44;

  --accent: #e8443c;
  --accent-soft: #3a1a17;
  --ok: #4ea868;
  --ok-soft: #1a2e21;
  --warn: #d49a2c;
  --warn-soft: #2e2515;
  --info: #4a8ec5;
  --info-soft: #16242f;
  --muted-soft: #232020;

  --sb-bg: #080705;
  --sb-bg-2: #100e0b;
  --sb-line: #1d1a16;
  --sb-active-bg: #1d1a14;
}

[data-density="compact"] {
  --row-h: 36px;
  --row-h-tight: 30px;
  --pad-x: 12px;
  --pad-y: 8px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "ss01", "cv11";
}

#root { height: 100%; }

button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }

/* ============================================================
   APP SHELL
============================================================ */

.app {
  display: grid;
  grid-template-columns: 248px 1fr;
  height: 100vh;
  background: var(--bg);
}

.app[data-nav="collapsed"] {
  grid-template-columns: 64px 1fr;
}

/* ----- Sidebar ----- */
.sidebar {
  background: var(--sb-bg);
  color: var(--sb-ink);
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--sb-line);
  overflow: hidden;
}

.sb-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--sb-line);
  min-height: 60px;
}
.sb-brand-mark {
  width: 32px; height: 32px;
  background: var(--sb-ink);
  border-radius: 4px;
  display: grid; place-items: center;
  flex-shrink: 0;
  overflow: hidden;
}
.sb-brand-mark img { width: 100%; height: 100%; object-fit: contain; padding: 2px; }
.sb-brand-text { display: flex; flex-direction: column; min-width: 0; }
.sb-brand-name {
  font-family: var(--font-thai);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sb-brand-sub {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--sb-ink-3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.sb-nav { flex: 1; overflow-y: auto; padding: 10px 0; }
.sb-nav::-webkit-scrollbar { width: 4px; }
.sb-nav::-webkit-scrollbar-thumb { background: var(--sb-line); border-radius: 2px; }

.sb-section-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--sb-ink-3);
  padding: 14px 18px 6px;
}

.sb-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 8px 16px;
  margin: 1px 8px;
  border-radius: 6px;
  color: var(--sb-ink-2);
  cursor: pointer;
  position: relative;
  user-select: none;
  font-size: 13.5px;
}
.sb-item:hover { background: var(--sb-bg-2); color: var(--sb-ink); }
.sb-item.active {
  background: var(--sb-active-bg);
  color: #fff;
}
.sb-item.active::before {
  content: "";
  position: absolute;
  left: -8px;
  top: 8px; bottom: 8px;
  width: 3px;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
}
.sb-item-icon {
  width: 18px; height: 18px;
  flex-shrink: 0;
  display: grid; place-items: center;
  color: currentColor;
}
.sb-item-label {
  flex: 1;
  font-family: var(--font-thai);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sb-item-shortcut {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--sb-ink-3);
  background: var(--sb-bg-2);
  padding: 2px 5px;
  border-radius: 3px;
  border: 1px solid var(--sb-line);
}
.sb-item-badge {
  font-family: var(--font-mono);
  font-size: 10px;
  background: var(--accent);
  color: #fff;
  padding: 1px 6px;
  border-radius: 10px;
  font-weight: 600;
}

.sb-foot {
  border-top: 1px solid var(--sb-line);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.sb-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: grid; place-items: center;
  font-weight: 600;
  font-size: 12px;
  flex-shrink: 0;
}
.sb-foot-text { flex: 1; min-width: 0; font-size: 12px; }
.sb-foot-name { color: var(--sb-ink); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-foot-role { color: var(--sb-ink-3); font-size: 10px; font-family: var(--font-mono); text-transform: uppercase; letter-spacing: 0.06em; }

[data-nav="collapsed"] .sb-brand-text,
[data-nav="collapsed"] .sb-section-label,
[data-nav="collapsed"] .sb-item-label,
[data-nav="collapsed"] .sb-item-shortcut,
[data-nav="collapsed"] .sb-item-badge,
[data-nav="collapsed"] .sb-foot-text { display: none; }
[data-nav="collapsed"] .sb-item { justify-content: center; margin: 1px 6px; padding: 9px 0; }
[data-nav="collapsed"] .sb-foot { justify-content: center; }

/* ----- Main column ----- */
.main {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

.topbar {
  height: 60px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 16px;
  flex-shrink: 0;
}

.tb-crumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--ink-3);
  font-family: var(--font-thai);
}
.tb-crumbs strong { color: var(--ink); font-weight: 600; }
.tb-crumbs .sep { color: var(--ink-5); }

.tb-search {
  flex: 1;
  max-width: 480px;
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 12px;
  cursor: pointer;
  color: var(--ink-3);
  font-size: 13px;
  transition: border-color .12s, background .12s;
}
.tb-search:hover { border-color: var(--line-strong); background: var(--surface); }
.tb-search-icon { color: var(--ink-4); }
.tb-search-text { flex: 1; }
.tb-search-kbd {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-3);
  background: var(--surface);
  padding: 2px 6px;
  border-radius: 3px;
  border: 1px solid var(--line);
}

.tb-actions { display: flex; gap: 8px; align-items: center; }

.tb-iconbtn {
  width: 36px; height: 36px;
  border-radius: 6px;
  display: grid; place-items: center;
  background: transparent;
  border: 1px solid transparent;
  color: var(--ink-2);
  position: relative;
}
.tb-iconbtn:hover { background: var(--bg-2); border-color: var(--line); }
.tb-iconbtn .dot {
  position: absolute;
  top: 7px; right: 7px;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--surface);
}

/* ----- Page area ----- */
.page {
  flex: 1;
  overflow-y: auto;
  padding: 24px 28px 64px;
}
[data-density="compact"] .page { padding: 16px 20px 48px; }

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}
.page-title {
  font-family: var(--font-thai);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0;
  color: var(--ink);
  line-height: 1.2;
}
.page-sub {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-4);
  margin-top: 4px;
}
.page-actions { display: flex; gap: 8px; align-items: center; }

/* ============================================================
   PRIMITIVES
============================================================ */

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  border-radius: 6px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
  transition: background .12s, border-color .12s;
  font-family: var(--font-thai);
}
.btn:hover { background: var(--bg-2); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12px; }
.btn-lg { height: 44px; padding: 0 18px; font-size: 14px; }

.btn-default {
  background: var(--surface);
  border-color: var(--line-strong);
  color: var(--ink);
}
.btn-default:hover { background: var(--bg-2); border-color: var(--ink-4); }

.btn-primary {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--bg);
}
.btn-primary:hover { background: var(--ink-2); border-color: var(--ink-2); }

.btn-accent {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn-accent:hover { background: var(--accent-deep); border-color: var(--accent-deep); }

.btn-ghost { color: var(--ink-2); }
.btn-ghost:hover { background: var(--bg-2); color: var(--ink); }

.btn-danger {
  background: transparent;
  border-color: var(--line);
  color: var(--accent);
}
.btn-danger:hover { background: var(--accent-soft); border-color: var(--accent); }

.btn .kbd {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 3px;
  background: rgba(255,255,255,0.15);
  margin-left: 4px;
}

.btn-default .kbd, .btn-ghost .kbd {
  background: var(--bg-2);
  color: var(--ink-3);
  border: 1px solid var(--line);
}

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}
.card-head {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.card-title {
  font-family: var(--font-thai);
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}
.card-sub {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-4);
}
.card-body { padding: 16px; }
.card-foot {
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  background: var(--surface-2);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border: 1px solid transparent;
  white-space: nowrap;
}
.badge-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.badge-default { background: var(--muted-soft); color: var(--ink-2); border-color: var(--line); }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-danger { background: var(--accent-soft); color: var(--accent); }
.badge-solid { background: var(--ink); color: var(--bg); }
.badge-outline { border-color: var(--line-strong); color: var(--ink-2); background: transparent; }

/* Tables */
.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.tbl th {
  text-align: left;
  font-family: var(--font-mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-4);
  font-weight: 500;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
  position: sticky;
  top: 0;
}
.tbl td {
  padding: 0 14px;
  border-bottom: 1px solid var(--line-soft);
  height: var(--row-h);
  vertical-align: middle;
  color: var(--ink);
  font-family: var(--font-thai);
}
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr { cursor: pointer; transition: background .08s; }
.tbl tbody tr:hover { background: var(--surface-2); }
.tbl tbody tr.selected { background: var(--accent-soft); }
.tbl .num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; text-align: right; }
.tbl .code { font-family: var(--font-mono); font-size: 12px; color: var(--ink-2); }
.tbl-empty {
  padding: 48px 16px;
  text-align: center;
  color: var(--ink-4);
  font-family: var(--font-thai);
  font-size: 13px;
}

/* Inputs */
.field { display: flex; flex-direction: column; gap: 6px; }
.label {
  font-family: var(--font-thai);
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-2);
}
.label .req { color: var(--accent); }
.hint {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ink-4);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.input, .select, .textarea {
  width: 100%;
  height: 38px;
  padding: 0 12px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  font-size: 13px;
  color: var(--ink);
  font-family: var(--font-thai);
  transition: border-color .12s, box-shadow .12s;
}
.textarea { height: auto; padding: 10px 12px; resize: vertical; min-height: 80px; }
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--ink-2);
  box-shadow: 0 0 0 3px rgba(20,17,13,0.06);
}
.input::placeholder { color: var(--ink-5); }
.input-group {
  display: flex;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  height: 38px;
  padding: 0 12px;
  gap: 8px;
}
.input-group:focus-within { border-color: var(--ink-2); box-shadow: 0 0 0 3px rgba(20,17,13,0.06); }
.input-group input {
  flex: 1; border: 0; background: transparent; outline: none; font-size: 13px; color: var(--ink);
  font-family: var(--font-thai); height: 100%;
}
.input-group .icon { color: var(--ink-4); flex-shrink: 0; }
.input-group .kbd {
  font-family: var(--font-mono); font-size: 10px;
  padding: 2px 5px; border-radius: 3px;
  background: var(--bg-2); color: var(--ink-3); border: 1px solid var(--line);
}

/* Stat / KPI */
.kpi {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  position: relative;
  overflow: hidden;
}
.kpi-label {
  font-family: var(--font-mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-4);
}
.kpi-value {
  font-family: var(--font-mono);
  font-size: 26px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.02em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  display: flex; align-items: baseline; gap: 6px;
}
.kpi-value .unit { font-size: 13px; color: var(--ink-3); font-weight: 500; letter-spacing: 0; }
.kpi-delta {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-3);
  display: flex; align-items: center; gap: 4px;
}
.kpi-delta.up { color: var(--ok); }
.kpi-delta.down { color: var(--accent); }

/* Section header inside cards */
.row-flex { display: flex; align-items: center; gap: 10px; }
.row-flex.between { justify-content: space-between; }
.spacer { flex: 1; }

/* Tags / chips */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 10px;
  border-radius: 13px;
  background: var(--surface-3);
  border: 1px solid var(--line);
  font-size: 12px;
  color: var(--ink-2);
  font-family: var(--font-thai);
}
.chip.active { background: var(--ink); color: var(--bg); border-color: var(--ink); }

/* Filter bar */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

/* Avatar */
.avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--surface-3);
  color: var(--ink-2);
  display: grid; place-items: center;
  font-weight: 600;
  font-size: 11px;
  border: 1px solid var(--line);
  font-family: var(--font-mono);
  flex-shrink: 0;
}
.avatar-sm { width: 22px; height: 22px; font-size: 10px; }
.avatar-lg { width: 36px; height: 36px; font-size: 13px; }
.avatar-red { background: var(--accent); color: #fff; border-color: var(--accent); }
.avatar-amber { background: var(--warn); color: #fff; border-color: var(--warn); }
.avatar-green { background: var(--ok); color: #fff; border-color: var(--ok); }
.avatar-ink { background: var(--ink); color: var(--bg); border-color: var(--ink); }

/* Tabs */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--line);
  margin-bottom: 16px;
}
.tab {
  padding: 10px 14px;
  font-family: var(--font-thai);
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-3);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  display: inline-flex; align-items: center; gap: 6px;
}
.tab:hover { color: var(--ink); }
.tab.active { color: var(--ink); border-bottom-color: var(--accent); }
.tab .count {
  font-family: var(--font-mono);
  font-size: 10px;
  background: var(--bg-2);
  padding: 1px 5px;
  border-radius: 3px;
  color: var(--ink-3);
}
.tab.active .count { background: var(--ink); color: var(--bg); }

/* Modal */
.scrim {
  position: fixed; inset: 0;
  background: rgba(20,17,13,0.4);
  z-index: 50;
  display: grid;
  place-items: start center;
  padding-top: 12vh;
  backdrop-filter: blur(2px);
}

.modal {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  width: min(640px, 92vw);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

/* Cmd-K */
.cmdk { width: min(640px, 92vw); background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-lg); overflow: hidden; }
.cmdk-search {
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 10px;
}
.cmdk-search input {
  flex: 1; border: 0; outline: none; background: transparent;
  font-size: 15px; color: var(--ink); font-family: var(--font-thai);
}
.cmdk-list { max-height: 50vh; overflow-y: auto; padding: 6px; }
.cmdk-group-label {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-4);
  padding: 10px 12px 4px;
}
.cmdk-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-family: var(--font-thai);
  font-size: 13px;
  color: var(--ink-2);
}
.cmdk-item:hover, .cmdk-item.active { background: var(--bg-2); color: var(--ink); }
.cmdk-item .icon { color: var(--ink-4); width: 16px; flex-shrink: 0; }
.cmdk-item .kbd { font-family: var(--font-mono); font-size: 10px; color: var(--ink-3); background: var(--bg-2); padding: 1px 5px; border-radius: 3px; border: 1px solid var(--line); margin-left: auto; }

/* Empty states */
.empty {
  padding: 60px 24px;
  text-align: center;
  color: var(--ink-3);
  font-family: var(--font-thai);
}
.empty-title { font-size: 15px; color: var(--ink-2); font-weight: 500; margin-bottom: 6px; }
.empty-sub { font-size: 13px; color: var(--ink-4); margin-bottom: 18px; }

/* Grid utils */
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

/* Divider */
.hr { height: 1px; background: var(--line); margin: 16px 0; border: 0; }

/* Misc */
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.thai { font-family: var(--font-thai); }
.muted { color: var(--ink-3); }
.t-num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.t-strong { font-weight: 600; color: var(--ink); }
.t-xs { font-size: 11px; }
.t-sm { font-size: 12px; }
.t-lg { font-size: 16px; }
.t-xl { font-size: 20px; }

/* Status pill (large, used in Job detail headers) */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* Kanban */
.kanban {
  display: grid;
  grid-template-columns: repeat(4, minmax(280px, 1fr));
  gap: 14px;
  height: calc(100vh - 220px);
  min-height: 520px;
}
.kanban-col {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.kanban-col-head {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
}
.kanban-col-title { font-family: var(--font-thai); font-weight: 600; font-size: 13px; flex: 1; display: flex; align-items: center; gap: 8px; }
.kanban-col-count {
  font-family: var(--font-mono);
  font-size: 10px;
  background: var(--bg-2);
  padding: 1px 6px;
  border-radius: 3px;
  color: var(--ink-3);
  border: 1px solid var(--line);
}
.kanban-list { flex: 1; overflow-y: auto; padding: 10px; display: flex; flex-direction: column; gap: 8px; }

.kanban-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  cursor: grab;
  position: relative;
  transition: border-color .12s, transform .08s;
}
.kanban-card:hover { border-color: var(--ink-4); }
.kanban-card.dragging { opacity: 0.5; }
.kanban-card-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.kanban-card-id { font-family: var(--font-mono); font-size: 10px; color: var(--ink-4); letter-spacing: 0.04em; }
.kanban-card-cust { font-family: var(--font-thai); font-size: 13px; font-weight: 500; color: var(--ink); margin-bottom: 2px; }
.kanban-card-vehicle { font-family: var(--font-mono); font-size: 11px; color: var(--ink-3); }
.kanban-card-foot { display: flex; align-items: center; gap: 6px; margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--line); }
.kanban-card-stripe { position: absolute; left: 0; top: 0; bottom: 0; width: 3px; border-radius: 6px 0 0 6px; }
.kanban-card-stripe.red { background: var(--accent); }
.kanban-card-stripe.amber { background: var(--warn); }
.kanban-card-stripe.green { background: var(--ok); }
.kanban-card-stripe.info { background: var(--info); }

/* PWA-feel: app frame */
.app-frame {
  margin: 0;
  height: 100vh;
}

/* Drop zone hint */
.kanban-list.drag-over { background: rgba(200,48,42,0.05); outline: 2px dashed var(--accent); outline-offset: -6px; border-radius: 8px; }

/* Tweaks panel overrides — none required, the starter handles it */

/* Auth page */
.auth-page {
  height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--bg);
}
.auth-art {
  background: var(--ink);
  color: var(--bg);
  padding: 48px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}
.auth-art::before {
  content: ""; position: absolute; inset: 0;
  background-image:
    repeating-linear-gradient(45deg, rgba(255,255,255,0.025) 0 1px, transparent 1px 14px);
  pointer-events: none;
}
.auth-form-wrap {
  display: grid; place-items: center;
  padding: 48px;
}
.auth-form { width: min(380px, 100%); }

/* Print / responsive niceties */
@media (max-width: 880px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
}

/* Subtle paper grain on bg */
.bg-grain {
  background-image:
    radial-gradient(rgba(20,17,13,0.025) 1px, transparent 1px);
  background-size: 18px 18px;
}

/* List item rows (sidebar-y) */
.lst { display: flex; flex-direction: column; }
.lst-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line-soft);
  cursor: pointer;
  font-family: var(--font-thai);
}
.lst-item:hover { background: var(--surface-2); }
.lst-item:last-child { border-bottom: 0; }

/* Aging table colors */
.aging-0 { color: var(--ok); }
.aging-1 { color: var(--ink-2); }
.aging-2 { color: var(--warn); }
.aging-3 { color: var(--accent); }

/* utility focus ring */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* Inline editable */
.inline-edit {
  border: 1px dashed transparent;
  padding: 1px 4px;
  border-radius: 3px;
  cursor: text;
}
.inline-edit:hover { border-color: var(--line-strong); background: var(--surface-2); }
.inline-edit.editing { border-color: var(--ink-2); border-style: solid; background: var(--surface); }


/* ============ Swimlane (Jobs) ============ */
.swimlane {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  align-items: start;
}
.swim-lane {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  min-height: 400px;
  transition: background .15s, border-color .15s;
}
.swim-lane.drag-over {
  background: var(--surface-3);
  border-color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--ink);
}
.swim-head {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 8px;
}
.swim-count {
  padding: 2px 8px;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
}
.swim-body {
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}
.swim-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  cursor: grab;
  transition: border-color .15s, box-shadow .15s, transform .15s;
  position: relative;
}
.swim-card:hover { border-color: var(--line-strong); box-shadow: var(--shadow-1); }
.swim-card.dragging { opacity: .4; cursor: grabbing; }
.swim-card.just-moved {
  border-color: var(--ok);
  box-shadow: 0 0 0 2px var(--ok-soft);
  animation: pulseMove 1.6s ease-out;
}
@keyframes pulseMove {
  0% { background: var(--ok-soft); transform: scale(1.02); }
  100% { background: var(--surface); transform: scale(1); }
}
.swim-card-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.swim-tags { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 6px; }
.swim-card-foot { display: flex; align-items: center; gap: 6px; margin-top: 8px; padding-top: 6px; border-top: 1px solid var(--line-soft); }
.swim-eta {
  margin-top: 6px;
  padding: 4px 8px;
  background: var(--surface-2);
  border-radius: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.swim-empty {
  padding: 24px 8px;
  text-align: center;
  color: var(--ink-5);
  font-family: var(--font-thai);
  font-size: 11px;
  border: 1px dashed var(--line);
  border-radius: 6px;
}

/* Live dot */
.live-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 0 var(--ok);
  animation: livePulse 1.6s infinite;
  display: inline-block;
}
.live-dot.small { width: 6px; height: 6px; }
@keyframes livePulse {
  0% { box-shadow: 0 0 0 0 rgba(31,122,58,0.5); }
  70% { box-shadow: 0 0 0 8px rgba(31,122,58,0); }
  100% { box-shadow: 0 0 0 0 rgba(31,122,58,0); }
}

.btn-ink {
  background: var(--ink);
  color: var(--surface);
  border-color: var(--ink);
}
.btn-ink:hover { background: var(--ink-2); }

/* Boss inbox */
.boss-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--ink-4);
  border-radius: 6px;
  padding: 12px 14px;
  margin-bottom: 10px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.boss-card:hover { background: var(--surface-2); }
.boss-card.severity-high { border-left-color: var(--accent); }
.boss-card.severity-med { border-left-color: var(--warn); }
.boss-card.severity-low { border-left-color: var(--info); }
.boss-card.unread { background: var(--surface-2); }
.boss-card.unread::before {
  content:""; width:6px; height:6px; border-radius:50%;
  background: var(--accent); position:absolute; margin-left:-12px; margin-top:6px;
}
.boss-icon {
  width: 36px; height: 36px;
  border-radius: 6px;
  display: grid; place-items: center;
  background: var(--surface-2);
  border: 1px solid var(--line);
  flex-shrink: 0;
}
.boss-icon.high { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.boss-icon.med { background: var(--warn-soft); color: var(--warn); border-color: var(--warn); }
.boss-icon.low { background: var(--info-soft); color: var(--info); border-color: var(--info); }
