/* Extreme ARC — Staff Dashboard styles
   Mobile-first, responsive via Flexbox/Grid, no build tools. */

:root {
  --brand: #b3121b;
  --brand-dark: #7d0c12;
  --ink: #1c1e21;
  --muted: #667085;
  --bg: #f4f5f7;
  --card: #ffffff;
  --border: #e3e5e9;
  --ok: #1a7f37;
  --warn: #b8860b;
  --danger: #b3121b;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.45;
}

a { color: var(--brand-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 12px;
}

/* ---------- Top bar / nav ---------- */
.topbar {
  background: var(--ink);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  flex-wrap: wrap;
  gap: 8px;
}
.brand {
  font-weight: 700;
  font-size: 1.15rem;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 8px;
}
.brand .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--brand); display:inline-block; }

nav.mainnav { display: flex; flex-wrap: wrap; gap: 4px 14px; }
nav.mainnav a { color: #d8dae0; font-size: 0.92rem; padding: 6px 2px; }
nav.mainnav a:hover, nav.mainnav a.active { color: #fff; text-decoration: underline; }

.user-chip { font-size: 0.85rem; color: #d8dae0; display:flex; align-items:center; gap:10px; }
.user-chip a { color: #fff; background: var(--brand); padding: 5px 10px; border-radius: 6px; }

/* ---------- Global search ---------- */
.search-bar { margin: 14px 0; }
.search-bar form { display: flex; gap: 8px; flex-wrap: wrap; }
.search-bar input[type=text] {
  flex: 1;
  min-width: 200px;
  padding: 12px 14px;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.search-bar button {
  padding: 12px 18px;
  font-size: 1rem;
}
/* Below ~480px, three items squeezed onto one row (input + Search +
   Scan) get crushed to the point the input is barely usable and the
   Scan button's label wraps mid-word. Stack everything full-width
   instead — much more usable with a thumb on an actual phone. */
@media (max-width: 480px) {
  .search-bar form { flex-direction: column; align-items: stretch; }
  .search-bar input[type=text] { min-width: 0; width: 100%; }
  .search-bar button, .search-bar .btn { width: 100%; }
}

/* ---------- Cards / layout ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}
.grid { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 720px) {
  .grid.cols-2 { grid-template-columns: 1fr 1fr; }
  .grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
  .grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 719px) {
  .grid.cols-4 { grid-auto-flow: column; grid-auto-columns: minmax(130px, 1fr); overflow-x: auto; padding-bottom: 4px; }
}

h1 { font-size: 1.5rem; margin: 6px 0 14px; }
h2 { font-size: 1.2rem; margin: 0 0 10px; }
h3 { font-size: 1.02rem; margin: 0 0 8px; }
.muted { color: var(--muted); font-size: 0.9rem; }

/* ---------- Forms ---------- */
label { display: block; font-weight: 600; font-size: 0.88rem; margin: 10px 0 4px; }
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], input[type=file], select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  background: #fff;
  color: var(--ink);
}
textarea { min-height: 80px; }
.field-row { display: flex; gap: 10px; flex-wrap: wrap; }
.field-row > div { flex: 1; min-width: 140px; }

button, .btn {
  display: inline-block;
  background: var(--brand);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 0.95rem;
  cursor: pointer;
  text-align: center;
}
button:hover, .btn:hover { background: var(--brand-dark); text-decoration:none; }
.btn.secondary { background: #fff; color: var(--ink); border: 1px solid var(--border); }
.btn.secondary:hover { background: #f0f0f2; }
.btn.small { padding: 6px 10px; font-size: 0.82rem; }
.btn.icon-btn { padding: 6px 9px; line-height: 1; }
.btn.ok { background: var(--ok); }
.btn.warn { background: var(--warn); }

/* Inline text-style button (used for the clickable supplier name) */
.link-btn {
  display: inline;
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  color: var(--brand-dark);
  font: inherit;
  font-weight: 600;
  text-decoration: underline;
  cursor: pointer;
}
.link-btn:hover { color: var(--brand); background: none; }

/* ---------- Tables (responsive: card-style stack on mobile) ---------- */
table.data { width: 100%; border-collapse: collapse; }
table.data th, table.data td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  font-size: 0.92rem;
}
table.data th { color: var(--muted); font-weight: 600; font-size: 0.8rem; text-transform: uppercase; }

@media (max-width: 700px) {
  table.data thead { display: none; }
  table.data, table.data tbody, table.data tr, table.data td { display: block; width: 100%; }
  table.data tr { border: 1px solid var(--border); border-radius: 8px; margin-bottom: 10px; padding: 6px 10px; background: #fff; }
  table.data td { border: none; padding: 6px 0; }
  table.data td[data-label]::before {
    content: attr(data-label);
    display: block;
    font-size: 0.72rem;
    text-transform: uppercase;
    color: var(--muted);
    font-weight: 600;
  }
  /* A cell's content (e.g. the Order Status <select> + custom input +
     button all inline) should stack full-width on mobile too, not stay
     jammed onto one line inside an already-narrow card row. */
  table.data td .flex { width: 100%; }
  table.data td .flex > * { flex: 1 1 auto; min-width: 0; }
}

/* ---------- Flagged rows (e.g. Markup Price exceeds Quoted Price) ---------- */
table.data tr.row-flag-red {
  background: #fdecea;
}
table.data tr.row-flag-red:hover {
  background: #fbdedb;
}
@media (max-width: 700px) {
  table.data tr.row-flag-red {
    border-color: var(--danger);
    border-width: 2px;
  }
}

/* ---------- Additional Parts (added after the first order was sent) ----------
   Shown in yellow everywhere they appear — the Additional Parts card
   (Parts Ordered / Additional Parts stages) and the GRV Outstanding /
   Received lists — so staff can tell at a glance which parts weren't
   part of the original quote. If a row is ALSO over-quote, the red
   flag (a genuine pricing problem) takes visual priority. */
table.data tr.row-flag-yellow {
  background: #fff8db;
}
table.data tr.row-flag-yellow:hover {
  background: #fff1b8;
}
@media (max-width: 700px) {
  table.data tr.row-flag-yellow {
    border-color: var(--warn);
    border-width: 2px;
  }
}
.badge.additional-part { background: var(--warn); color: #1c1e21; }

/* ---------- Status badges ---------- */
.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
}
.badge.pending { background: #8a8f98; }
.badge.ordered { background: #2b6cb0; }
.badge.back_order { background: var(--warn); }
.badge.installed { background: #2f855a; }
.badge.done { background: var(--ok); }
.badge.stage { background: var(--brand); }
.badge.approved { background: var(--ok); }
.badge.notapproved { background: #8a8f98; }

/* ---------- Alerts ---------- */
.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 12px; font-size: 0.92rem; }
.alert.success { background: #e6f4ea; color: #1a7f37; border: 1px solid #b7e1c1; }
.alert.error { background: #fdecea; color: #b3121b; border: 1px solid #f4c1bd; }
.alert.info { background: #eaf1fb; color: #1e4e8c; border: 1px solid #c3d7f4; }

/* ---------- Stage pipeline ---------- */
.pipeline { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 16px; }
.pipeline .step {
  flex: 1;
  min-width: 110px;
  text-align: center;
  padding: 8px 6px;
  border-radius: 8px;
  background: #eceef1;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
}
.pipeline .step.current { background: var(--brand); color: #fff; }
.pipeline .step.past { background: #d7e9dc; color: #1a7f37; }

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.login-card { max-width: 380px; width: 100%; }
.login-card h1 { text-align: center; }

/* ---------- Utility ---------- */
.flex { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.flex.between { justify-content: space-between; }
.mt-0 { margin-top: 0; }
.text-right { text-align: right; }
.small { font-size: 0.85rem; }
hr.sep { border: none; border-top: 1px solid var(--border); margin: 16px 0; }

footer.site-footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.8rem;
  padding: 20px 0 40px;
}

/* ---------- Supplier info modal ---------- */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(28, 30, 33, 0.55);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-overlay.open { display: flex; }
body.modal-open { overflow: hidden; }

.modal {
  background: #fff;
  border-radius: var(--radius);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 10px 40px rgba(0,0,0,0.25);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: #fff;
}
.modal-close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.4rem;
  line-height: 1;
  padding: 4px 8px;
  cursor: pointer;
}
.modal-close:hover { background: #f0f0f2; color: var(--ink); border-radius: 6px; }
.modal-body { padding: 4px 18px 18px; }
.modal-section { margin-top: 14px; }
.modal-section h4 {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
  margin: 0 0 6px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 6px;
}
table.modal-kv { width: 100%; border-collapse: collapse; }
table.modal-kv td {
  padding: 5px 0;
  font-size: 0.92rem;
  vertical-align: top;
}
table.modal-kv td:first-child {
  color: var(--muted);
  width: 40%;
  font-weight: 600;
}

@media print {
  .topbar, .no-print { display: none !important; }
  body { background: #fff; }
  .card { border: none; }
}