[hidden] { display: none !important; }

:root {
  --bg:          #f4f5f7;
  --panel:       #ffffff;
  --ink:         #111827;
  --muted:       #6b7280;
  --line:        #e5e7eb;
  --accent:      #1d4ed8;
  --accent-dark: #1e40af;
  --soft:        #eff6ff;
  --danger:      #dc2626;
  --total-col:   116px;  /* fixed width for every amount column */
  --remove-col:  36px;
}

* { box-sizing: border-box; }
html { height: 100%; }

body {
  margin: 0;
  height: 100%;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font: 13px/1.5 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

button, input, select, textarea { font: inherit; }

button {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
  min-height: 32px;
  padding: 0 12px;
  white-space: nowrap;
}
button:hover { border-color: var(--accent); color: var(--accent-dark); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { border-color: var(--danger); background: #fef2f2; color: var(--danger); }
.btn-sm   { font-size: 12px; min-height: 28px; padding: 0 10px; }
.btn-link { color: var(--muted); font-size: 12px; text-decoration: none; padding: 4px 8px; border-radius: 4px; border: none; background: none; }
.btn-link:hover { color: var(--accent-dark); background: var(--soft); }
.crm-pick-btn { font-size: 12px; min-height: 28px; padding: 0 10px; color: var(--accent); border-color: var(--accent); }

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--panel);
  color: var(--ink);
  min-height: 34px;
  padding: 5px 9px;
  font-size: 13px;
  text-transform: none;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(29,78,216,.1);
}

/* ── Layout chrome ───────────────────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  flex-wrap: wrap;
}
.eyebrow { margin: 0 0 2px; color: var(--accent-dark); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 20px; font-weight: 700; }
h2 { font-size: 15px; font-weight: 700; }
h3 { font-size: 13px; font-weight: 700; }

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

.workspace { padding: 16px; display: flex; flex: 1; min-height: 0; flex-direction: column; gap: 10px; overflow: hidden; }
.status-bar { color: var(--muted); font-size: 12px; }

/* SSO banner */
.sso-banner {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 16px; background: var(--panel); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 1000;
}
.sso-avatar { width: 26px; height: 26px; border-radius: 50%; object-fit: cover; background: #ddd; }
.sso-name { font-weight: 600; font-size: 13px; }
.sso-actions { display: flex; gap: 8px; align-items: center; margin-left: auto; }

.order-row {
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.order-row:hover { background: var(--soft); }
.order-row.active { background: var(--soft); border-left: 3px solid var(--accent); }
.order-row:last-child { border-bottom: 0; }
.order-row-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 2px; }
.order-row-customer { font-size: 12px; color: var(--ink); }
.order-row-sub { font-size: 11px; color: var(--muted); }
.status-badge { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
#emptyOrders { text-align: center; color: var(--muted); padding: 32px 16px; font-size: 13px; }

/* ── Work Order editor (main panel) ─────────────────────────────────────── */
.order-editor {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow-y: auto;
}

/* ── WO top action bar ───────────────────────────────────────────────────── */
.wo-header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 10;
}
.wo-header-left { display: flex; align-items: center; gap: 10px; }
.wo-header-left h2 { font-size: 16px; }
.wo-status-chip {
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); background: var(--bg); border: 1px solid var(--line);
  border-radius: 20px; padding: 2px 9px;
}
.wo-header-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.btn-primary-action { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn-primary-action:hover { background: var(--accent-dark); border-color: var(--accent-dark); color: #fff; }
.btn-dispatch { background: var(--accent); border-color: var(--accent); color: #fff; font-size: 12px; font-weight: 600; min-height: 28px; padding: 0 10px; }
.btn-dispatch:hover { background: var(--accent-dark); color: #fff; }
.btn-dispatch-outline { background: transparent; border-color: var(--accent); color: var(--accent); font-size: 12px; font-weight: 600; min-height: 28px; padding: 0 10px; }

/* ── WO form body ────────────────────────────────────────────────────────── */
.wo-form {
  padding: 0 20px 28px;
  display: flex;
  flex-direction: column;
}

/* Section divider label */
.wo-divider {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 20px 0 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--line);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
}

/* Generic field label */
label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
}

/* Row helpers */
.wo-row        { display: flex; gap: 12px; align-items: flex-start; }
.wo-row.four-col { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 12px; }
.grid          { display: grid; gap: 10px; }
.grid.two      { grid-template-columns: repeat(2, minmax(0,1fr)); }

/* Customer rows */
.customer-search-row { display: flex; gap: 8px; align-items: center; }
.customer-search-row input { flex: 1; }
.customer-locked-row { display: flex; gap: 8px; align-items: flex-start; }
.customer-card {
  flex: 1;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--soft);
  padding: 8px 12px;
  min-height: 46px;
  color: var(--muted);
  font-size: 13px;
}
.customer-card strong { display: block; color: var(--ink); font-size: 13px; }

.add-customer-form {
  border: 1px solid var(--line); border-radius: 6px;
  background: #f8fafc; padding: 12px;
  display: flex; flex-direction: column; gap: 10px;
}
.form-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
#newCustomerStatus { font-size: 12px; color: var(--muted); }

/* ── Parts & Labour tables ───────────────────────────────────────────────── */
/*
  Column structure (both tables share the same total/remove col widths):
    Parts:  [desc flex] [qty 60px] [unit-price 108px] [total TOT] [remove REM]
    Labour: [opcode 88px] [desc flex] [hours 68px] [rate 96px] [total TOT] [remove REM]
*/

.wo-line-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

/* thead */
.wo-line-table thead tr {
  border-bottom: 1px solid var(--line);
}
.wo-line-table thead th {
  padding: 5px 6px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
  text-align: left;
  white-space: nowrap;
}
.wo-line-table thead th.num { text-align: right; }

/* tbody */
.wo-line-table tbody td {
  padding: 3px 4px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.wo-line-table tbody tr:last-child td { border-bottom: none; }

/* inputs inside table cells — strip extra chrome */
.wo-line-table input {
  width: 100%;
  min-height: 30px;
  padding: 3px 6px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  font-size: 13px;
}
.wo-line-table input:hover  { border-color: var(--line); }
.wo-line-table input:focus  { border-color: var(--accent); background: var(--panel); box-shadow: 0 0 0 2px rgba(29,78,216,.1); outline: none; }
.wo-line-table input[type=number] { text-align: right; }

/* line total cell */
.wo-line-table td.line-total {
  width: var(--total-col);
  text-align: right;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  color: var(--ink);
  white-space: nowrap;
  padding: 3px 8px;
}

/* remove button cell */
.wo-line-table td.line-remove {
  width: var(--remove-col);
  text-align: center;
  padding: 0 2px;
}
.wo-line-table td.line-remove button {
  min-height: 26px;
  padding: 0 8px;
  font-size: 15px;
  color: var(--muted);
  border: none;
  background: none;
}
.wo-line-table td.line-remove button:hover { color: var(--danger); background: #fef2f2; border-radius: 4px; border: none; }

/* tfoot — subtotal + grand total rows */
.wo-line-table tfoot td {
  padding: 0;
  border: none;
}
.wo-line-table tfoot tr.tfoot-subtotal td {
  padding: 6px 8px 4px;
  border-top: 1px solid var(--line);
}
.wo-line-table tfoot tr.tfoot-grand td {
  padding: 7px 8px 5px;
  border-top: 2px solid var(--ink);
}
.tfoot-label {
  text-align: right;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
}
.tfoot-grand .tfoot-label {
  font-size: 11px;
  color: var(--ink);
}
.tfoot-amount {
  width: var(--total-col);
  text-align: right;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  padding: 0 8px;
  color: var(--ink);
}
.tfoot-subtotal .tfoot-amount { font-size: 13px; }
.tfoot-grand    .tfoot-amount { font-size: 16px; }
.tfoot-remove   { width: var(--remove-col); }

/* ── Op code cell ────────────────────────────────────────────────────────── */
.ll-code-cell {
  display: flex; align-items: center; gap: 4px; white-space: nowrap;
}
.ll-code-text {
  font-family: monospace; font-size: 12px; font-weight: 700;
  color: var(--accent); min-width: 48px;
}
.ll-pick-btn {
  font-size: 10px; font-weight: 700; padding: 2px 6px; border-radius: 4px;
  border: 1px solid var(--line); background: var(--panel); color: var(--muted);
  cursor: pointer; white-space: nowrap; min-height: auto;
  transition: border-color .15s, color .15s, box-shadow .15s;
}
.ll-pick-btn.is-missing {
  border-color: #d97706; color: #d97706; background: rgba(217,119,6,.07);
  animation: labour-code-pulse 1.8s ease-in-out infinite;
}
@keyframes labour-code-pulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(217,119,6,0); }
  50%      { box-shadow: 0 0 0 4px rgba(217,119,6,.25); }
}
.ll-pick-btn:not(.is-missing):hover { background: var(--soft); }

/* ── Parts quickpick bar ─────────────────────────────────────────────────── */
.parts-quickpick-bar {
  display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 6px;
}

/* ── Cross-module xmodule sections ──────────────────────────────────────── */
.xmodule-link {
  font-size: 11px; font-weight: 600; color: var(--accent); text-decoration: none; white-space: nowrap;
}
.xmodule-link:hover { text-decoration: underline; }
.xmodule-row {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 0; border-bottom: 1px solid var(--line);
}
.xmodule-row:last-of-type { border-bottom: 0; }
.xmodule-row-link { flex: 1; font-size: 12px; color: var(--accent); text-decoration: none; }
.xmodule-row-link:hover { text-decoration: underline; }
.xmodule-unlink-btn {
  font-size: 14px; color: var(--muted); background: none; border: none;
  cursor: pointer; padding: 0 4px; line-height: 1; min-height: auto;
}
.xmodule-unlink-btn:hover { color: var(--danger); }
.xmodule-link-row { display: flex; align-items: center; gap: 6px; }
.xmodule-travel-fee {
  font-size: 11px; font-weight: 600; color: #d97706;
  background: rgba(217,119,6,.08); border: 1px solid rgba(217,119,6,.25);
  border-radius: 10px; padding: 1px 6px; margin-left: 4px; white-space: nowrap;
}
.xmodule-travel-total {
  font-size: 12px; font-weight: 700; color: #d97706;
  padding: 6px 0 2px; border-top: 1px solid var(--line); margin-top: 4px;
}

/* ── Misc helpers ────────────────────────────────────────────────────────── */
.field-group  { display: flex; flex-direction: column; gap: 6px; }
.field-header { display: flex; align-items: center; justify-content: flex-start; gap: 8px; }
.field-label  { color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.parts-badge  { display: none; } /* replaced by wo-divider button */

/* ── Modals ──────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(0,0,0,.45); display: flex;
  align-items: center; justify-content: center; padding: 16px;
}
.modal-panel {
  background: var(--panel); border-radius: 10px;
  box-shadow: 0 8px 32px rgba(0,0,0,.18);
  width: 100%; max-width: 520px; max-height: 80vh;
  display: flex; flex-direction: column; overflow: hidden;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 1px solid var(--line);
}
.modal-header h3 { font-size: 14px; font-weight: 700; }
.modal-close   { min-height: 26px; padding: 0 10px; font-size: 18px; line-height: 1; }
.modal-search  { margin: 8px 16px 4px; width: calc(100% - 32px); }
.crm-results   { flex: 1; overflow-y: auto; padding: 4px 8px 10px; }
.crm-result-row { padding: 9px; border-radius: 6px; cursor: pointer; }
.crm-result-row:hover { background: var(--soft); }
.crm-result-row strong { display: block; color: var(--ink); font-size: 13px; }
.crm-result-row span   { display: block; color: var(--muted); font-size: 11px; }
.crm-no-results { text-align: center; color: var(--muted); padding: 24px; }

/* Op Code modal */
.opcode-picker-filters {
  display: flex; flex-wrap: wrap; gap: 8px;
  padding: 10px 16px; border-bottom: 1px solid var(--line);
}
.opcode-pick-results { flex: 1; overflow-y: auto; padding: 4px 8px 10px; }
.opcode-pick-row { padding: 8px 10px; border-radius: 6px; cursor: pointer; }
.opcode-pick-row:hover { background: var(--soft); }
.opcode-new-rate-bar { padding: 8px 16px; border-top: 1px solid var(--line); }
.opcode-new-rate-form { padding: 12px 16px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; }
.opcode-new-rate-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.opcode-new-rate-actions { display: flex; align-items: center; gap: 8px; }
.btn-accent { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }

/* Parts catalog modal */
.parts-catalog-results { flex: 1; overflow-y: auto; padding: 4px 8px 10px; }

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; overflow: auto; }
  .order-list { max-height: 260px; }
  .wo-row.four-col { grid-template-columns: 1fr 1fr; }
  .topbar { flex-direction: column; align-items: stretch; }
}

/* ── Landing page ────────────────────────────────────────────────────────── */
.landing-wrap { max-width: 900px; margin: 0 auto; padding: 48px 24px 32px; }
.landing-hero { margin-bottom: 40px; }
.landing-sub { color: var(--muted); font-size: 15px; margin-top: 6px; max-width: 520px; }
.landing-actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-top: 24px; }
.btn-signin { display: inline-block; padding: 10px 28px; background: var(--accent); color: #fff; border-radius: 8px; font-size: 15px; font-weight: 700; text-decoration: none; }
.btn-signin:hover { background: var(--accent-dark); }
.btn-hub { display: inline-block; padding: 10px 20px; background: transparent; color: var(--muted); border-radius: 8px; font-size: 14px; font-weight: 600; text-decoration: none; border: 1px solid var(--line); }
.btn-hub:hover { border-color: var(--accent); color: var(--accent-dark); }
.feature-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; margin-bottom: 32px; }
.feature-card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 20px 18px; }
.feature-card svg { width: 26px; height: 26px; stroke: var(--accent); fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; display: block; margin-bottom: 12px; }
.feature-card h3 { margin: 0 0 4px; font-size: 14px; }
.feature-card p { margin: 0; color: var(--muted); font-size: 13px; }
.landing-footer { text-align: center; padding: 24px 16px; font-size: 12px; color: var(--muted); }
.landing-footer a { color: inherit; text-decoration: underline; }

/* ── Tech time tickets read-only display (service WO) ── */
.tech-tickets-readonly {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.tech-tickets-header {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 700;
  color: #166534;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.tech-tickets-totals { font-weight: 600; color: #166534; }
.tech-ticket-entry {
  border-top: 1px solid #bbf7d0;
  padding-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.tech-ticket-meta {
  display: flex;
  gap: 12px;
  font-size: 12px;
  color: #166534;
  flex-wrap: wrap;
}
.tech-ticket-num { font-family: monospace; font-weight: 700; }
.tech-ticket-notes {
  font-size: 13px;
  color: #1f2937;
  white-space: pre-wrap;
  line-height: 1.5;
}
.tech-ticket-label { font-size: 10px; font-weight: 700; text-transform: uppercase; opacity: 0.7; margin-right: 4px; }
.tech-ticket-internal { background: #fefce8; border-radius: 4px; padding: 3px 6px; color: #713f12; }

#statusBar { position: fixed; bottom: 0; left: 0; right: 0; z-index: 150; border-top: 1px solid var(--border); border-bottom: none !important; }
