/* NetSuite-inspired light theme — cleaner, denser, modern */
:root {
  --bg: #f3f4f7;
  --panel: #ffffff;
  --panel-alt: #fafbfc;
  --line: #dde0e6;
  --line-strong: #c8ccd4;
  --text: #1f2330;
  --muted: #5b6478;
  --muted-2: #8189a0;

  --brand: #ff6b1a;          /* Matrix Piping orange */
  --brand-dark: #d8531a;
  --brand-tint: #fff1e6;

  --link: #1d6fc1;
  --link-dark: #155596;
  --header: #1d2c4a;          /* deep navy */
  --header-2: #243a64;

  --green: #1f9d55;
  --red: #d12a3a;
  --amber: #c97a00;

  --radius: 4px;
  --radius-lg: 6px;
  --shadow: 0 1px 2px rgba(20,30,50,.06), 0 1px 1px rgba(20,30,50,.04);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Inter, Helvetica, Arial, system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  line-height: 1.45;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--link); text-decoration: none; }
a:hover { color: var(--link-dark); text-decoration: underline; }

code { font-family: ui-monospace, SF Mono, Menlo, Consolas, monospace; font-size: 12px; color: var(--text); }

/* ---------- Layout: top header + content ---------- */
.app { display: grid; grid-template-rows: auto 1fr; min-height: 100vh; }

aside.sidebar {
  background: var(--header);
  color: #e8edf7;
  border-bottom: 3px solid var(--brand);
  padding: 0;
  position: sticky;
  top: 0;
  z-index: 30;
  box-shadow: 0 2px 8px rgba(0,0,0,.08);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 24px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  background: linear-gradient(180deg, var(--header) 0%, var(--header-2) 100%);
}
.brand .logo {
  display: flex; align-items: center; gap: 12px;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -.01em;
  color: #fff;
}
.brand .logo-mark {
  width: 30px; height: 30px;
  border-radius: var(--radius);
  background: var(--brand);
  display: grid; place-items: center;
  color: #1a1006;
  font-weight: 800;
  font-size: 14px;
  box-shadow: inset 0 -2px 0 rgba(0,0,0,.2);
}
.brand .tag {
  font-size: 10px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: rgba(255,255,255,.55);
  font-weight: 600;
  margin-top: 1px;
}

/* Horizontal tab nav */
.nav {
  display: flex;
  flex-wrap: wrap;
  padding: 0 16px;
  gap: 0;
}
.nav .label { display: none; }
.nav a {
  color: rgba(255,255,255,.78);
  padding: 10px 16px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .02em;
  text-transform: uppercase;
  position: relative;
  border-bottom: 3px solid transparent;
  margin-bottom: -3px;
  transition: color .12s ease, background .12s ease;
}
.nav a:hover { color: #fff; background: rgba(255,255,255,.05); text-decoration: none; }
.nav a.active {
  color: #fff;
  border-bottom-color: var(--brand);
  background: rgba(255,255,255,.04);
}

/* ---------- Main ---------- */
.main {
  padding: 18px 24px 60px;
  max-width: 1480px;
  width: 100%;
  margin: 0 auto;
}
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}
.topbar h1 {
  font-size: 18px;
  font-weight: 600;
  margin: 0;
  letter-spacing: -.005em;
  color: var(--header);
}
.topbar .subtitle { color: var(--muted); font-size: 12px; margin-top: 2px; }
.topbar .actions { display: flex; gap: 8px; align-items: center; }

/* Demo banner */
.demo-banner {
  background: var(--brand-tint);
  border: 1px solid #ffd1ae;
  border-left: 3px solid var(--brand);
  color: #6b3010;
  padding: 10px 14px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 12px;
  display: flex; gap: 10px; align-items: center;
}
.demo-banner strong { color: #3d1a08; }

/* ---------- Cards / KPIs ---------- */
.cards { display: grid; gap: 12px; }
.cards.cols-4 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.cards.cols-3 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.cards.cols-2 { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}
.card h3 {
  margin: 0 0 8px;
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .08em;
  font-weight: 700;
}
.card .big {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -.01em;
  color: var(--header);
  font-variant-numeric: tabular-nums;
}
.card .sub { color: var(--muted-2); font-size: 11px; margin-top: 2px; }

/* ---------- Pipeline (kanban-strip style) ---------- */
.pipeline {
  display: grid;
  grid-template-columns: repeat(9, minmax(108px, 1fr));
  gap: 6px;
  overflow-x: auto;
}
.pipeline .stage {
  background: var(--panel-alt);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px 12px;
  min-height: 78px;
  display: block;
  text-decoration: none;
  color: inherit;
  transition: border-color .15s ease, background .15s ease;
}
.pipeline .stage:hover { border-color: var(--link); background: #fff; text-decoration: none; }
.pipeline .stage .name {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .07em;
  font-weight: 700;
}
.pipeline .stage .count {
  font-size: 22px;
  font-weight: 600;
  margin-top: 4px;
  color: var(--header);
  font-variant-numeric: tabular-nums;
}
.pipeline .stage.empty .count { color: var(--muted-2); opacity: .5; }
.pipeline .stage.busy { border-top: 2px solid var(--brand); padding-top: 9px; }

/* ---------- Tables ---------- */
.table-wrap {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
table { width: 100%; border-collapse: collapse; }
th, td {
  text-align: left;
  padding: 8px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 12.5px;
  vertical-align: middle;
}
th {
  color: var(--muted);
  font-weight: 600;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .07em;
  background: var(--panel-alt);
  border-bottom: 1px solid var(--line-strong);
  padding-top: 9px; padding-bottom: 9px;
  white-space: nowrap;
}
tbody tr:nth-child(even) td { background: var(--panel-alt); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #eef4fb; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.row-action { cursor: pointer; }
.row-action:hover { background: #eef4fb; }

/* ---------- Badges (NetSuite-style status pills) ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px;
  border-radius: 3px;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  background: #e7eaf0;
  color: var(--muted);
  border: 1px solid transparent;
  line-height: 1.5;
}
.badge.stage-enquiry           { background: #e6f0fc; color: #1d4f86; }
.badge.stage-quoting           { background: #fff4d6; color: #8a5a00; }
.badge.stage-awaiting_approval { background: #ffe8c2; color: #8a5400; }
.badge.stage-materials         { background: #e0eefc; color: #1d6fc1; }
.badge.stage-fabrication       { background: #ffe2cc; color: #b8430c; }
.badge.stage-qa                { background: #d8f1e1; color: #126b3d; }
.badge.stage-coating           { background: #ece1fb; color: #5d2da6; }
.badge.stage-dispatch          { background: #fff4d6; color: #8a5a00; }
.badge.stage-invoiced          { background: #d8f1e1; color: #126b3d; }
.badge.stage-complete          { background: #e7eaf0; color: var(--muted); }

.badge.priority-urgent { background: #fde0e3; color: #a31a28; }
.badge.priority-high   { background: #ffe8c2; color: #8a5400; }
.badge.priority-normal { background: #e6f0fc; color: #1d4f86; }
.badge.priority-low    { background: #e7eaf0; color: var(--muted); }

.dot { width: 7px; height: 7px; border-radius: 999px; background: var(--muted); display: inline-block; margin-right: 4px; }
.dot.green { background: var(--green); }
.dot.red { background: var(--red); }
.dot.amber { background: var(--amber); }

/* ---------- Buttons ---------- */
.btn {
  background: #fff;
  border: 1px solid var(--line-strong);
  color: var(--text);
  padding: 6px 12px;
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
  line-height: 1.4;
  font-family: inherit;
  transition: background .12s ease, border-color .12s ease;
}
.btn:hover { background: var(--panel-alt); border-color: #a8aebc; }
.btn.primary {
  background: var(--brand);
  border-color: var(--brand-dark);
  color: #fff;
  box-shadow: inset 0 -1px 0 rgba(0,0,0,.12);
}
.btn.primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--link); }
.btn.ghost:hover { background: var(--panel-alt); }
.btn.sm { padding: 3px 8px; font-size: 11px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* ---------- Inputs ---------- */
input.search, select.search, textarea.search, input[type=date], input[type=text], input[type=search] {
  background: #fff;
  border: 1px solid var(--line-strong);
  color: var(--text);
  padding: 6px 10px;
  border-radius: var(--radius);
  font-size: 12.5px;
  font-family: inherit;
  min-width: 220px;
}
input.search:focus, select.search:focus, textarea.search:focus, input[type=date]:focus, input[type=text]:focus, input[type=search]:focus {
  outline: none;
  border-color: var(--link);
  box-shadow: 0 0 0 2px rgba(29,111,193,.18);
}

/* ---------- Filter chips ---------- */
.filters { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 12px; padding: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); width: fit-content; }
.filters .chip {
  background: transparent;
  border: 1px solid transparent;
  padding: 4px 12px;
  border-radius: 3px;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  color: var(--muted);
  text-transform: capitalize;
}
.filters .chip:hover { background: var(--panel-alt); color: var(--text); }
.filters .chip.active {
  background: var(--header);
  border-color: var(--header);
  color: #fff;
}

/* ---------- Activity feed ---------- */
.activity { display: flex; flex-direction: column; }
.activity .item {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}
.activity .item:last-child { border-bottom: 0; }
.activity .time { color: var(--muted-2); font-size: 11px; min-width: 70px; padding-top: 1px; font-variant-numeric: tabular-nums; }
.activity .content { flex: 1; }
.activity .who { color: var(--muted-2); font-size: 11px; margin-top: 1px; }

/* ---------- Workflow rules diagram ---------- */
.workflow-diagram {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  padding: 8px 4px; overflow-x: auto;
}
.workflow-diagram .node {
  background: var(--panel-alt);
  border: 1px solid var(--line);
  padding: 7px 12px;
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 600;
  color: var(--header);
  display: inline-flex; flex-direction: column; gap: 2px;
  min-width: 90px;
}
.workflow-diagram .node .role {
  font-size: 10px;
  color: var(--muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.workflow-diagram .arrow { color: var(--muted-2); font-weight: 600; }

/* ---------- Drawer ---------- */
.drawer-mask {
  position: fixed; inset: 0;
  background: rgba(20,30,50,.45);
  display: none; z-index: 50;
}
.drawer-mask.open { display: block; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: min(680px, 100%);
  background: var(--panel);
  border-left: 1px solid var(--line);
  z-index: 51;
  transform: translateX(100%);
  transition: transform .25s cubic-bezier(.32,.72,0,1);
  display: flex; flex-direction: column;
  box-shadow: -8px 0 24px rgba(20,30,50,.12);
}
.drawer.open { transform: translateX(0); }
.drawer header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-alt);
  display: flex; justify-content: space-between; align-items: flex-start; gap: 12px;
}
.drawer header h2 { margin: 0 0 4px; font-size: 16px; color: var(--header); font-weight: 600; }
.drawer .body { padding: 16px 20px; overflow-y: auto; flex: 1; }
.drawer .body label { display: block; font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 4px; }
.drawer .close { background: transparent; border: 0; color: var(--muted); font-size: 22px; cursor: pointer; line-height: 1; padding: 0 4px; }
.drawer .close:hover { color: var(--text); }
.drawer footer {
  padding: 12px 20px;
  border-top: 1px solid var(--line);
  background: var(--panel-alt);
  display: flex; gap: 8px; justify-content: flex-end;
}

/* Form grid */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 14px;
}
.form-grid .ff { display: flex; flex-direction: column; }
.form-grid .ff.full { grid-column: 1 / -1; }
.form-grid .ff label {
  font-size: 11px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: .06em;
  margin-bottom: 4px; display: block;
}
.form-grid .ff input.search,
.form-grid .ff select.search,
.form-grid .ff textarea.search { min-width: 0; width: 100%; }

/* Quote line item table inside drawer */
.line-items { width: 100%; border-collapse: collapse; margin-top: 8px; }
.line-items th { background: var(--panel-alt); font-size: 10.5px; padding: 6px 8px; }
.line-items td { padding: 4px 6px; border-bottom: 1px solid var(--line); }
.line-items input { width: 100%; padding: 5px 8px; font-size: 12px; border: 1px solid var(--line); border-radius: 3px; background: #fff; font-family: inherit; }
.line-items td.num input { text-align: right; font-variant-numeric: tabular-nums; }
.line-items .del-row { background: transparent; border: 0; color: var(--muted); cursor: pointer; padding: 4px 6px; font-size: 14px; }
.line-items .del-row:hover { color: var(--red); }
.line-totals { margin-top: 12px; display: flex; flex-direction: column; gap: 3px; align-items: flex-end; font-size: 13px; font-variant-numeric: tabular-nums; }
.line-totals .total { font-weight: 700; color: var(--header); border-top: 1px solid var(--line-strong); padding-top: 6px; margin-top: 4px; }
.line-totals .row { display: flex; gap: 18px; min-width: 220px; justify-content: space-between; }
.section-h { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 700; margin: 18px 0 6px; }

/* Timeline */
.timeline { display: flex; flex-direction: column; gap: 0; padding: 4px 0; }
.timeline .step { display: flex; gap: 12px; align-items: flex-start; padding: 8px 0; position: relative; }
.timeline .step + .step::before {
  content: ''; position: absolute; left: 10px; top: -6px; width: 1px; height: 14px; background: var(--line-strong);
}
.timeline .step .pin {
  width: 21px; height: 21px; border-radius: 999px; flex-shrink: 0;
  background: #fff; border: 2px solid var(--line-strong);
  display: grid; place-items: center; color: var(--muted); font-size: 11px;
  font-weight: 700;
}
.timeline .step.done .pin { background: var(--brand); border-color: var(--brand-dark); color: #fff; }
.timeline .step .body { font-size: 12.5px; flex: 1; }
.timeline .step .body .when { color: var(--muted-2); font-size: 11px; margin-top: 2px; }

/* Breadcrumb-ish (optional) */
.breadcrumb { font-size: 11px; color: var(--muted-2); margin-bottom: 4px; }
.breadcrumb a { color: var(--link); }

/* Utility */
.muted { color: var(--muted); }
.small { font-size: 11.5px; }
.right { text-align: right; }
.flex { display: flex; }
.flex.between { justify-content: space-between; }
.flex.center { align-items: center; }
.gap-8 { gap: 8px; }
.gap-16 { gap: 16px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 20px; }
.spinner {
  display: inline-block; width: 12px; height: 12px;
  border: 2px solid rgba(255,255,255,.4); border-top-color: #fff;
  border-radius: 50%; animation: spin .7s linear infinite;
}
.btn:not(.primary) .spinner { border-color: var(--line-strong); border-top-color: var(--header); }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 900px) {
  .nav a { padding: 10px 12px; font-size: 11.5px; }
  .main { padding: 14px 16px; }
  .pipeline { grid-template-columns: repeat(5, minmax(110px, 1fr)); }
}
