/* ============================================================
   Margins — quote builder
   Minimal monochrome styling. Thin type. Generous whitespace.
   ============================================================ */

:root {
  --bg:        #fafaf8;
  --surface:   #ffffff;
  --ink:       #0a0a0a;
  --ink-2:     #444444;
  --muted:     #8a8a86;
  --line:      #e8e8e2;
  --line-2:    #f0f0eb;
  --hover:     #f5f5f1;
  --accent:    #0a0a0a;
  --ok:        #1f6b46;
  --warn:      #8a5d10;
  --bad:       #952626;
  --ok-bg:     #ecf3ef;
  --warn-bg:   #faeeda;
  --bad-bg:    #fbebeb;
  --radius:    8px;
  --radius-lg: 12px;
  --shadow:    0 1px 0 rgba(0,0,0,0.02), 0 8px 24px rgba(0,0,0,0.04);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--ink); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ============ Header ============ */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.site-header-inner {
  max-width: 1240px; margin: 0 auto;
  padding: 18px 28px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 24px;
}
.brand {
  display: flex; align-items: center; gap: 12px;
  text-decoration: none; color: var(--ink);
}
.brand img { height: 28px; width: auto; display: block; }
.brand .brand-sub {
  font-size: 11px; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.18em;
  border-left: 1px solid var(--line); padding-left: 12px;
}
.nav { display: flex; gap: 4px; }
.nav a {
  padding: 7px 14px; border-radius: 6px;
  font-size: 13px; color: var(--ink-2);
  text-decoration: none;
}
.nav a:hover { background: var(--hover); text-decoration: none; }
.nav a.active { background: var(--ink); color: #fff; }
.nav-user {
  font-size: 12px; color: var(--muted);
  padding: 7px 8px 7px 16px;
  border-left: 1px solid var(--line);
  margin-left: 8px;
}
.nav-logout {
  font-size: 12px; color: var(--muted);
  padding: 7px 8px;
}
.nav-logout:hover { color: var(--ink); text-decoration: none; }

/* ============ Main ============ */
.page {
  max-width: 1240px; margin: 0 auto;
  padding: 28px;
}
.page-header {
  display: flex; align-items: flex-end; justify-content: space-between;
  margin-bottom: 22px;
}
.page-title {
  font-size: 28px; font-weight: 300; letter-spacing: -0.01em;
  margin: 0;
}
.page-sub { color: var(--muted); font-size: 13px; margin-top: 4px; }

/* ============ Cards ============ */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 14px;
}
.card h2 {
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.14em;
  color: var(--muted); margin: 0 0 14px 0;
}
.card-row {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}

/* ============ Forms ============ */
label { display: block; font-size: 11px; color: var(--muted); margin-bottom: 5px; text-transform: uppercase; letter-spacing: 0.08em; font-weight: 500; }
input, select, textarea {
  width: 100%; box-sizing: border-box;
  padding: 9px 12px; font-size: 13px;
  border: 1px solid var(--line); border-radius: 6px;
  font-family: inherit; background: var(--surface); color: var(--ink);
  transition: border-color 0.12s, box-shadow 0.12s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(10,10,10,0.06);
}
textarea { min-height: 64px; resize: vertical; }
input[type="number"] { -moz-appearance: textfield; }
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }

.form-row { display: grid; gap: 12px; }
.form-row.cols-2 { grid-template-columns: 1fr 1fr; }
.form-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
@media (max-width: 700px) {
  .form-row.cols-2, .form-row.cols-3 { grid-template-columns: 1fr; }
}

/* ============ Buttons ============ */
.btn {
  background: var(--surface); border: 1px solid var(--line);
  padding: 7px 14px; border-radius: 6px;
  font-size: 12px; font-family: inherit; color: var(--ink);
  cursor: pointer; transition: background 0.12s, border-color 0.12s;
}
.btn:hover { background: var(--hover); }
.btn-primary { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn-primary:hover { background: #1f1f1f; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--hover); }
.btn-danger { color: var(--bad); border-color: transparent; background: transparent; }
.btn-danger:hover { background: var(--bad-bg); }
.btn-sm { padding: 4px 10px; font-size: 11px; }

/* ============ Tables ============ */
table { border-collapse: collapse; width: 100%; font-size: 13px; }
table th { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); color: var(--muted); font-weight: 500; font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; }
table td { padding: 11px 12px; border-bottom: 1px solid var(--line-2); }
table tbody tr:last-child td { border-bottom: none; }
table tbody tr:hover td { background: var(--hover); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
code { font-family: "SF Mono", ui-monospace, Menlo, monospace; font-size: 12px; }

/* ============ Pills / tags ============ */
.pill { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 11px; font-weight: 500; }
.pill-co  { background: #ecedef; color: #2c3036; }
.pill-ind { background: #f3f1ea; color: #5f5e5a; }
.pill-ok  { background: var(--ok-bg);  color: var(--ok);  }
.pill-low { background: var(--warn-bg); color: var(--warn); }
.pill-out { background: var(--bad-bg);  color: var(--bad); }

/* ============ Search bar ============ */
.search-bar { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.search-bar input { max-width: 420px; }
.search-status { font-size: 12px; color: var(--muted); }
.empty { color: var(--muted); font-style: italic; padding: 20px; text-align: center; font-size: 13px; }

/* ============ Customer / product picker dropdowns ============ */
.picker-host { position: relative; }
.picker-dropdown {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0;
  z-index: 30;
  background: var(--surface);
  border: 1px solid var(--line); border-radius: 8px;
  box-shadow: var(--shadow);
  max-height: 260px; overflow-y: auto;
  display: none;
}
.picker-dropdown.show { display: block; }
.picker-item {
  padding: 9px 12px; cursor: pointer; font-size: 13px;
  border-bottom: 1px solid var(--line-2);
}
.picker-item:last-child { border-bottom: none; }
.picker-item:hover, .picker-item.active { background: var(--hover); }
.picker-item .pick-name { font-weight: 500; }
.picker-item .pick-meta { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* ============ Selected customer card ============ */
.selected-card {
  background: var(--hover);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex; justify-content: space-between; align-items: flex-start;
  margin-top: 12px;
}
.selected-card .sc-name { font-weight: 500; font-size: 13px; }
.selected-card .sc-meta { font-size: 12px; color: var(--muted); margin-top: 3px; }

/* ============ Lines table ============ */
.lines-table { width: 100%; border-collapse: collapse; }
.lines-table th { font-size: 10px; padding: 8px 10px; }
.lines-table td { padding: 8px 10px; vertical-align: middle; }
.lines-table input { padding: 6px 10px; font-size: 13px; }
.lines-table .col-drag { width: 24px; text-align: center; padding-left: 4px; padding-right: 0; }
.lines-table .col-prod { width: 34%; }
.lines-table .col-uom  { width: 7%; color: var(--muted); font-size: 12px; }
.lines-table .col-num  { width: 11%; }
.lines-table .col-disc { width: 9%; }
.lines-table .col-total{ width: 13%; text-align: right; font-weight: 500; font-variant-numeric: tabular-nums; }
.lines-table .col-x    { width: 4%; text-align: center; }
.lines-table tbody tr:hover td { background: transparent; }

/* Drag handle */
.drag-handle {
  display: inline-block;
  color: var(--muted);
  cursor: grab;
  user-select: none;
  padding: 4px 2px;
  font-size: 16px;
  line-height: 1;
  border-radius: 4px;
}
.drag-handle:hover { color: var(--ink); background: var(--hover); }
.drag-handle:active { cursor: grabbing; }
/* SortableJS chosen / ghost states */
.sortable-ghost { opacity: 0.4; }
.sortable-chosen { background: var(--hover); }
.sortable-drag { background: var(--surface); box-shadow: var(--shadow); }

/* Selected-product chip in line */
.line-product-chip {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--hover);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 10px;
  gap: 8px;
}
.line-product-chip .chip-name { font-size: 13px; line-height: 1.2; flex: 1; min-width: 0; }
.line-product-chip .chip-code { font-family: "SF Mono", ui-monospace, Menlo, monospace; font-size: 11px; color: var(--muted); margin-top: 2px; }
.line-product-chip .chip-close { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 14px; padding: 2px 6px; border-radius: 4px; }
.line-product-chip .chip-close:hover { background: var(--bg); color: var(--bad); }

/* ============ Totals sidebar ============ */
.totals { font-size: 13px; }
.total-row { display: flex; justify-content: space-between; padding: 6px 0; }
.total-row.grand {
  border-top: 1px solid var(--ink);
  margin-top: 8px; padding-top: 12px;
  font-size: 17px; font-weight: 500;
}
.total-label { color: var(--muted); }
.total-row.grand .total-label { color: var(--ink); }

.note {
  font-size: 11px; color: var(--muted); margin-top: 4px; line-height: 1.5;
}

.preview-line {
  font-size: 12px; color: var(--muted);
}
.preview-line strong { color: var(--ink); font-weight: 500; font-size: 13px; }
