@import url('https://fonts.googleapis.com/css2?family=Rajdhani:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500;600&family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
  --bg: #141619;
  --bg2: #1a1d21;
  --surface: #1e2226;
  --surface2: #252a30;
  --surface3: #2d343b;
  --border: #363b43;
  --border2: #4a4f57;
  --accent: #7b1e2b;
  --accent2: #9b2536;
  --accent-glow: rgba(123,30,43,0.18);
  --blue: #2563eb;
  --blue2: #3b82f6;
  --blue-dim: rgba(37,99,235,0.15);
  --green: #10b981;
  --green2: #34d399;
  --green-dim: rgba(16,185,129,0.12);
  --red: #ef4444;
  --red-dim: rgba(239,68,68,0.12);
  --orange: #f97316;
  --orange-dim: rgba(249,115,22,0.12);
  --purple: #8b5cf6;
  --purple-dim: rgba(139,92,246,0.12);
  --teal: #14b8a6;
  --teal-dim: rgba(20,184,166,0.12);
  --text: #ececec;
  --text2: #b0b3b8;
  --text-inactive: #9ca0a6;
  --muted: #4a4f57;
  --mono: 'IBM Plex Mono', monospace;
  --display: 'Rajdhani', sans-serif;
  --body: 'Outfit', sans-serif;
  --radius: 10px;
  --shadow: 0 4px 20px rgba(0,0,0,0.5);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: var(--body); background: var(--bg); color: var(--text); min-height: 100vh; font-size: 14px; }

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--bg2); }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }

/* ─── LOGIN ─── */
#login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  position: relative;
  overflow: hidden;
}
#login-screen::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 30% 50%, rgba(123,30,43,0.12) 0%, transparent 60%),
              radial-gradient(ellipse at 70% 20%, rgba(74,79,87,0.10) 0%, transparent 50%);
}
#login-screen::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(74,79,87,0.15) 1px, transparent 1px),
    linear-gradient(90deg, rgba(74,79,87,0.15) 1px, transparent 1px);
  background-size: 40px 40px;
}
.login-box {
  position: relative;
  z-index: 10;
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px;
  box-shadow: 0 24px 80px rgba(0,0,0,0.5);
}
.login-logo {
  text-align: center;
  margin-bottom: 32px;
}
.login-logo-icon {
  width: 64px; height: 64px;
  background: linear-gradient(135deg, var(--accent) 0%, #5c1520 100%);
  border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  font-size: 28px;
  margin: 0 auto 14px;
  box-shadow: 0 8px 24px rgba(123,30,43,0.35);
}
.login-title {
  font-family: var(--display);
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 1px;
}
.login-sub { font-size: 12px; color: var(--text2); margin-top: 4px; }

.login-field { margin-bottom: 16px; }
.login-field label { display: block; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 1px; color: var(--text2); margin-bottom: 6px; }
.login-field input {
  width: 100%; padding: 11px 14px;
  background: var(--bg2); border: 1.5px solid var(--border);
  border-radius: 8px; color: var(--text);
  font-family: var(--body); font-size: 14px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.login-field input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }

.btn-login {
  width: 100%; padding: 12px;
  background: linear-gradient(135deg, var(--accent) 0%, #5c1520 100%);
  border: none; border-radius: 8px;
  color: #fff; font-family: var(--display); font-size: 16px; font-weight: 700;
  cursor: pointer; letter-spacing: 1px;
  transition: opacity 0.2s, transform 0.1s;
  margin-top: 8px;
}
.btn-login:hover { opacity: 0.9; transform: translateY(-1px); }
.login-error { background: var(--red-dim); border: 1px solid var(--red); border-radius: 8px; padding: 10px 14px; font-size: 12.5px; color: #fca5a5; margin-top: 12px; display: none; }

/* ─── MAIN APP ─── */
#app { display: none; min-height: 100vh; flex-direction: column; }
#app.visible { display: flex; }

/* HEADER */
.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky; top: 0; z-index: 200;
  box-shadow: 0 2px 12px rgba(0,0,0,0.3);
}
.app-logo { display: flex; align-items: center; gap: 10px; }
.app-logo-icon {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, var(--accent) 0%, #5c1520 100%);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  box-shadow: 0 2px 8px rgba(123,30,43,0.35);
}
.app-logo-text { font-family: var(--display); font-size: 17px; font-weight: 700; letter-spacing: 0.5px; }
.app-logo-sub { font-size: 10px; color: var(--text2); }

.header-right { display: flex; align-items: center; gap: 12px; }
.header-user { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--text2); }
.user-avatar {
  width: 28px; height: 28px;
  background: var(--blue-dim); border: 1px solid var(--blue);
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 12px; color: var(--blue2);
}
.btn-logout {
  padding: 5px 12px; border-radius: 6px;
  background: transparent; border: 1px solid var(--border2);
  color: var(--text2); font-size: 11.5px; cursor: pointer;
  transition: all 0.2s;
}
.btn-logout:hover { border-color: var(--red); color: var(--red); }

/* Report language menu (globe + select, left of the user chip): small, dark, never wraps. */
.header-lang { display: flex; align-items: center; gap: 5px; flex: 0 0 auto; white-space: nowrap; font-size: 12px; color: var(--text2); }
.header-lang-select {
  padding: 4px 6px; border-radius: 6px; max-width: 110px;
  background: var(--bg2); border: 1px solid var(--border2);
  color: var(--text); font: inherit; font-size: 11.5px; cursor: pointer;
}
.header-lang-select:hover { border-color: var(--blue2); }
.header-lang-select:disabled { opacity: .55; cursor: wait; }
.header-lang-select option { background: var(--bg2); color: var(--text); }
@media (max-width: 700px) { .header-lang-icon { display: none; } }

/* NAV TABS */
.nav-tabs {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  display: flex; gap: 2px; padding: 0 16px;
  overflow-x: auto;
}
.nav-tabs::-webkit-scrollbar { height: 0; }
.nav-tab {
  padding: 11px 18px;
  border: none; background: none;
  color: var(--text2); font-family: var(--body); font-size: 13px; font-weight: 500;
  cursor: pointer; white-space: nowrap;
  border-bottom: 3px solid transparent;
  transition: color 0.15s, border-color 0.15s;
  display: flex; align-items: center; gap: 7px;
}
.nav-tab:hover { color: var(--text); }
.nav-tab.active { color: #e8828c; border-bottom-color: var(--accent); }

/* MAIN CONTENT */
.main-content { flex: 1; overflow-y: auto; }
.page { padding: 20px 24px; max-width: 1400px; margin: 0 auto; }
.pane { display: none; }
.pane.active { display: block; }

/* ─── CARDS ─── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 14px;
}
.card-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 16px; padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.card-title {
  font-family: var(--display); font-size: 16px; font-weight: 700;
  display: flex; align-items: center; gap: 8px;
  letter-spacing: 0.3px;
}
.card-title .icon { font-size: 18px; }

/* ─── STATS ROW ─── */
.stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  position: relative; overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 3px;
}
.stat-card.s-amber::before { background: var(--accent); }
.stat-card.s-blue::before { background: var(--blue2); }
.stat-card.s-green::before { background: var(--green); }
.stat-card.s-purple::before { background: var(--purple); }
.stat-card.s-red::before { background: var(--red); }
.stat-card.s-teal::before { background: var(--teal); }
.stat-val { font-family: var(--mono); font-size: 28px; font-weight: 600; line-height: 1; margin-bottom: 4px; }
.stat-card.s-amber .stat-val { color: #e8828c; }
.stat-card.s-blue .stat-val { color: var(--blue2); }
.stat-card.s-green .stat-val { color: var(--green2); }
.stat-card.s-purple .stat-val { color: var(--purple); }
.stat-card.s-red .stat-val { color: var(--red); }
.stat-card.s-teal .stat-val { color: var(--teal); }
.stat-lbl { font-size: 11px; color: var(--text2); text-transform: uppercase; letter-spacing: 0.5px; font-weight: 500; }

/* ─── BUTTONS ─── */
.btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 7px 14px; border-radius: 7px; border: none;
  cursor: pointer; font-family: var(--body); font-size: 13px; font-weight: 500;
  transition: all 0.15s; white-space: nowrap;
}
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: #1d4ed8; }
.btn-amber { background: var(--accent); color: #fff; font-weight: 600; }
.btn-amber:hover { background: var(--accent2); }
.btn-success { background: var(--green); color: #fff; }
.btn-success:hover { background: #059669; }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-ghost { background: var(--surface3); color: var(--text); border: 1px solid var(--border2); }
.btn-ghost:hover { background: var(--border2); }
.btn-purple { background: var(--purple); color: #fff; }
.btn-purple:hover { background: #7c3aed; }
.btn-sm { padding: 4px 10px; font-size: 12px; border-radius: 6px; }
.btn-xs { padding: 3px 8px; font-size: 11px; border-radius: 5px; }
.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }
a.btn { text-decoration: none; }
.btn:focus-visible { outline: 2px solid var(--blue2); outline-offset: 2px; }

/* Disabled buttons look disabled and never glow on hover (UI-09). Declared after the variants so it wins. */
.btn:disabled, .btn[disabled], .btn[aria-disabled="true"] {
  opacity: .45; cursor: not-allowed; box-shadow: none; transform: none; filter: none;
}
.btn:disabled:hover, .btn[disabled]:hover, .btn[aria-disabled="true"]:hover { box-shadow: none; transform: none; filter: none; }
.btn-primary:disabled:hover, .btn-primary[disabled]:hover { background: var(--blue); }
.btn-amber:disabled:hover, .btn-amber[disabled]:hover { background: var(--accent); }
.btn-success:disabled:hover, .btn-success[disabled]:hover { background: var(--green); }
.btn-danger:disabled:hover, .btn-danger[disabled]:hover { background: var(--red); }
.btn-ghost:disabled:hover, .btn-ghost[disabled]:hover { background: var(--surface3); }
.btn-purple:disabled:hover, .btn-purple[disabled]:hover { background: var(--purple); }

/* ─── FORMS ─── */
.form-grid { display: grid; gap: 12px; }
.form-grid.g2 { grid-template-columns: 1fr 1fr; }
.form-grid.g3 { grid-template-columns: 1fr 1fr 1fr; }
.form-grid.g4 { grid-template-columns: repeat(4, 1fr); }
.span2 { grid-column: span 2; }
.span3 { grid-column: span 3; }
.span4 { grid-column: span 4; }

.form-row { display: flex; flex-direction: column; gap: 5px; }
.form-row label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text2); }
.form-row input, .form-row select, .form-row textarea {
  padding: 8px 11px;
  background: var(--bg2); border: 1.5px solid var(--border);
  border-radius: 7px; color: var(--text);
  font-family: var(--body); font-size: 13px;
  transition: border-color 0.15s, box-shadow 0.15s;
  width: 100%;
}
.form-row input:focus, .form-row select:focus, .form-row textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow);
}
.form-row select { cursor: pointer; }
.form-row textarea { resize: vertical; min-height: 70px; }
.form-row input[readonly] { background: var(--surface3); color: var(--text2); cursor: default; }

/* ─── BADGES ─── */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 9px; border-radius: 20px;
  font-size: 11px; font-weight: 600;
}
/* An invoice number on an order card is free text up to 100 characters: one without a break point wraps inside the card instead of pushing it wider than a phone. */
.order-invoices .badge { min-width: 0; max-width: 100%; overflow-wrap: anywhere; }
.b-amber { background: var(--accent-glow); color: #e8828c; border: 1px solid rgba(123,30,43,0.35); }
.b-blue { background: var(--blue-dim); color: var(--blue2); border: 1px solid rgba(37,99,235,0.3); }
.b-green { background: var(--green-dim); color: var(--green2); border: 1px solid rgba(16,185,129,0.3); }
.b-red { background: var(--red-dim); color: #fca5a5; border: 1px solid rgba(239,68,68,0.3); }
.b-orange { background: var(--orange-dim); color: var(--orange); border: 1px solid rgba(249,115,22,0.3); }
.b-purple { background: var(--purple-dim); color: var(--purple); border: 1px solid rgba(139,92,246,0.3); }
.b-teal { background: var(--teal-dim); color: var(--teal); border: 1px solid rgba(20,184,166,0.3); }
.b-gray { background: rgba(63,84,120,0.3); color: var(--text2); border: 1px solid var(--border2); }

/* ─── PROGRESS BARS ─── */
.progress-wrap { background: var(--bg2); border-radius: 20px; height: 8px; overflow: hidden; }
.progress-bar {
  height: 100%; border-radius: 20px;
  transition: width 0.6s ease;
}
.pb-amber { background: linear-gradient(90deg, var(--accent), var(--accent2)); }.pb-green { background: linear-gradient(90deg, var(--green), var(--green2)); }
.pb-blue { background: linear-gradient(90deg, var(--blue), var(--blue2)); }
.pb-red { background: linear-gradient(90deg, #dc2626, var(--red)); }

.progress-lg { height: 12px; }
.progress-label { display: flex; justify-content: space-between; align-items: center; margin-bottom: 5px; font-size: 12px; }
.progress-label .pct { font-family: var(--mono); font-size: 11px; color: var(--text2); }

/* ─── LOCATION STEPPER ─── */
.location-stepper { display: flex; align-items: center; gap: 0; margin: 12px 0; }
.step-item {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  flex: 1;
}
.step-circle {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--surface3); border: 2px solid var(--border2);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; position: relative; z-index: 2;
  transition: all 0.3s;
}
.step-item.done .step-circle { background: var(--green); border-color: var(--green); }
.step-item.active .step-circle { background: var(--accent); border-color: var(--accent); box-shadow: 0 0 10px var(--accent-glow); }.step-label { font-size: 10px; color: var(--text2); text-align: center; white-space: nowrap; max-width: 60px; }
.step-item.done .step-label { color: var(--green2); }
.step-item.active .step-label { color: #e8828c; font-weight: 600; }
.step-line { flex: 1; height: 2px; background: var(--border); margin: 0 -1px; margin-top: -22px; position: relative; z-index: 1; }
.step-line.done { background: var(--green); }

/* ─── TABLE ─── */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; }
thead th {
  background: var(--surface2); color: var(--text2);
  padding: 10px 12px; text-align: left;
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px;
  white-space: nowrap; border-bottom: 1px solid var(--border);
}
tbody td { padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 13px; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: rgba(74,79,87,0.2); }
tfoot td { padding: 10px 12px; font-weight: 700; border-top: 2px solid var(--border2); background: var(--surface2); }
.mono { font-family: var(--mono); font-size: 12px; }
.tc { text-align: center; }
.tr { text-align: right; }

/* ─── FILTERS BAR ─── */
.filters-bar {
  display: flex; gap: 10px; flex-wrap: wrap;
  align-items: flex-end;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px;
  margin-bottom: 16px;
}
.filter-group { display: flex; flex-direction: column; gap: 4px; }
.filter-group label { font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text2); }
.filter-group input, .filter-group select {
  padding: 7px 10px; background: var(--bg2); border: 1.5px solid var(--border);
  border-radius: 7px; color: var(--text); font-family: var(--body); font-size: 13px;
  min-width: 130px;
}
.filter-group input:focus, .filter-group select:focus { outline: none; border-color: var(--accent); }

/* ─── ORDER CARD ─── */
.order-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  transition: border-color 0.2s, box-shadow 0.2s;
  position: relative;
}
.order-card:hover { border-color: var(--border2); box-shadow: 0 4px 16px rgba(0,0,0,0.3); }
.order-card-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 12px; }
.order-no { font-family: var(--mono); font-size: 13px; font-weight: 600; color: #e8828c; }
.order-source-badge { padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 700; }
.src-turkey { background: rgba(220,38,38,0.15); color: #fca5a5; border: 1px solid rgba(220,38,38,0.3); }
.src-libya { background: rgba(16,185,129,0.15); color: var(--green2); border: 1px solid rgba(16,185,129,0.3); }
.src-siemens { background: var(--blue-dim); color: var(--blue2); border: 1px solid rgba(37,99,235,0.3); }
.order-meta { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12px; color: var(--text2); margin-bottom: 10px; }
.order-meta span strong { color: var(--text); }
.order-financials { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.fin-pill {
  background: var(--surface2); border: 1px solid var(--border2);
  border-radius: 20px; padding: 4px 12px;
  font-family: var(--mono); font-size: 12px;
}
.fin-pill.main { background: var(--accent-glow); border-color: rgba(123,30,43,0.35); color: #e8828c; }

/* ─── MFG PROJECT CARD ─── */
.proj-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 14px;
  overflow: hidden;
  transition: border-color 0.2s;
}
.proj-card:hover { border-color: var(--border2); }
.proj-card-head {
  padding: 14px 18px;
  display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap; gap: 8px 12px;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
}
.proj-card-body { padding: 16px 18px; }
.proj-name { font-family: var(--display); font-size: 18px; font-weight: 700; }
.proj-customer { font-size: 12px; color: var(--text2); }
.panel-item {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 13px;
  margin-bottom: 8px;
  transition: border-color 0.2s;
}
.panel-item:hover { border-color: var(--border2); }
.panel-item-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
/* A long unbroken panel name (the converter keeps up to 255 characters) must wrap inside the card instead of pushing the stage badge and the buttons off a phone. */
.panel-item-head > div:first-child { min-width: 0; flex: 1 1 200px; }
.panel-item-head > div:last-child { flex-wrap: wrap; }
.panel-name { font-weight: 600; font-size: 14px; overflow-wrap: anywhere; min-width: 0; }
.stage-badge { padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 700; }
.stage-design { background: var(--purple-dim); color: var(--purple); border: 1px solid rgba(139,92,246,0.3); }
.stage-manufacturing { background: var(--orange-dim); color: var(--orange); border: 1px solid rgba(249,115,22,0.3); }
.stage-testing { background: var(--blue-dim); color: var(--blue2); border: 1px solid rgba(37,99,235,0.3); }
.stage-ready { background: var(--teal-dim); color: var(--teal); border: 1px solid rgba(20,184,166,0.3); }
.stage-delivered { background: var(--green-dim); color: var(--green2); border: 1px solid rgba(16,185,129,0.3); }

/* ─── DELIVERY CARD ─── */
.delivery-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  transition: border-color 0.2s;
}
.delivery-card:hover { border-color: var(--border2); }
.panel-count-display {
  display: flex; gap: 12px; flex-wrap: wrap; align-items: center; margin: 10px 0;
}
.panel-count-item {
  text-align: center;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 16px;
}
.panel-count-val { font-family: var(--mono); font-size: 20px; font-weight: 600; }
.panel-count-lbl { font-size: 10px; color: var(--text2); text-transform: uppercase; letter-spacing: 0.5px; }

/* ─── MODAL ─── */
.overlay {
  position: fixed; inset: 0;
  background: rgba(20,22,25,0.88);
  z-index: 500; display: none;
  align-items: flex-start; justify-content: center;
  padding: 20px; overflow-y: auto;
  backdrop-filter: blur(4px);
}
.overlay.open { display: flex; }
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  width: 100%; max-width: 780px;
  margin: auto;
  box-shadow: 0 32px 80px rgba(0,0,0,0.6);
  animation: modal-in 0.2s ease;
}
.modal-lg { max-width: 1000px; }
.modal-xl { max-width: 1200px; }
@keyframes modal-in { from { opacity: 0; transform: translateY(-14px); } to { opacity: 1; transform: translateY(0); } }
.modal-head {
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  border-radius: 14px 14px 0 0;
  padding: 14px 20px;
  display: flex; justify-content: space-between; align-items: center;
}
.modal-title { font-family: var(--display); font-size: 17px; font-weight: 700; }
.modal-close {
  width: 28px; height: 28px; background: var(--surface3); border: 1px solid var(--border2);
  border-radius: 6px; display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 14px; color: var(--text2); transition: all 0.15s;
}
.modal-close:hover { background: var(--red-dim); border-color: var(--red); color: var(--red); }
.modal-body { padding: 20px; max-height: 80vh; overflow-y: auto; }
.modal-foot {
  padding: 14px 20px; border-top: 1px solid var(--border);
  display: flex; gap: 10px; background: var(--bg2);
  border-radius: 0 0 14px 14px; flex-wrap: wrap;
}
.doc-file-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 6px 10px; background: var(--bg2); border: 1px solid var(--border);
  border-radius: 7px; margin-bottom: 6px;
}
.doc-file-row a { color: var(--text); font-size: 13px; text-decoration: none; }
.doc-file-row a:hover { color: var(--accent); }

/* ─── ALERTS ─── */
.alert {
  padding: 11px 14px; border-radius: 8px;
  font-size: 13px; display: flex; align-items: flex-start; gap: 9px;
  border: 1px solid; margin-bottom: 12px;
}
.alert-info { background: var(--blue-dim); border-color: rgba(37,99,235,0.4); color: #93c5fd; }
.alert-success { background: var(--green-dim); border-color: rgba(16,185,129,0.4); color: var(--green2); }
.alert-warning { background: var(--accent-glow); border-color: rgba(123,30,43,0.4); color: #e8828c; }
.alert-danger { background: var(--red-dim); border-color: rgba(239,68,68,0.4); color: #fca5a5; }

/* ─── SECTION LABEL ─── */
.section-label {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px;
  color: var(--text2); margin: 16px 0 10px;
  display: flex; align-items: center; gap: 8px;
}
.section-label::after { content: ''; flex: 1; height: 1px; background: var(--border); }

/* ─── EMPTY STATE ─── */
.empty { text-align: center; padding: 48px 24px; color: var(--text2); }
.empty-icon { font-size: 48px; margin-bottom: 12px; opacity: 0.4; }
.empty p { font-size: 14px; line-height: 1.6; }

/* ─── SHORTAGE ITEM ─── */
.shortage-item {
  background: var(--red-dim); border: 1px solid rgba(239,68,68,0.3);
  border-radius: 7px; padding: 8px 12px; margin-bottom: 6px;
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
}
.shortage-item .shortage-name { font-size: 12.5px; font-weight: 600; flex: 1; }
.shortage-item .shortage-info { font-size: 11.5px; color: var(--text2); }

/* ─── MATERIAL ITEM ─── */
.mat-item {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; background: var(--surface2); border-radius: 7px; margin-bottom: 5px;
  font-size: 12.5px; border: 1px solid var(--border);
}
.mat-item .mat-name { flex: 1; }
.mat-received { color: var(--green2); font-family: var(--mono); font-size: 12px; }
.mat-pending { color: #fca5a5; font-family: var(--mono); font-size: 12px; }

/* ─── PERSONNEL ─── */
.personnel-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 8px 0; }
.person-chip {
  background: var(--blue-dim); border: 1px solid rgba(37,99,235,0.3);
  border-radius: 20px; padding: 3px 12px; font-size: 12px; color: var(--blue2);
  display: flex; align-items: center; gap: 5px;
}
.person-chip .remove-person { cursor: pointer; color: var(--text2); font-size: 10px; }
.person-chip .remove-person:hover { color: var(--red); }

/* ─── TABS (secondary) ─── */
.sub-tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.sub-tab { padding: 8px 16px; background: none; border: none; cursor: pointer; color: var(--text2); font-size: 12.5px; font-weight: 500; border-bottom: 2px solid transparent; font-family: var(--body); }
.sub-tab.active { color: var(--blue2); border-bottom-color: var(--blue2); }

/* ─── IMPORT/EXPORT CARDS ─── */
.exp-card {
  background: var(--surface2); border: 1px solid var(--border2);
  border-radius: var(--radius); padding: 20px; text-align: center;
  transition: all 0.2s; cursor: pointer;
}
.exp-card:hover { border-color: #e8828c; background: var(--accent-glow); }
.exp-card .exp-icon { font-size: 32px; margin-bottom: 10px; }
.exp-card h3 { font-size: 14px; font-weight: 600; margin-bottom: 6px; }
.exp-card p { font-size: 12px; color: var(--text2); line-height: 1.5; }
.exp-card.imp { border-color: rgba(37,99,235,0.4); }
.exp-card.imp:hover { border-color: var(--blue2); background: var(--blue-dim); }

/* ─── DELIVERY STATUS PILLS ─── */
.del-status { padding: 4px 12px; border-radius: 20px; font-size: 12px; font-weight: 700; display: inline-flex; align-items: center; gap: 5px; }
.ds-delivered { background: var(--green-dim); color: var(--green2); border: 1px solid rgba(16,185,129,0.3); }
.ds-partial { background: var(--orange-dim); color: var(--orange); border: 1px solid rgba(249,115,22,0.3); }
.ds-manufacturing { background: var(--blue-dim); color: var(--blue2); border: 1px solid rgba(37,99,235,0.3); }
.ds-pending { background: var(--purple-dim); color: var(--purple); border: 1px solid rgba(139,92,246,0.3); }

/* ─── CHECKBOX ─── */
.checkbox-row { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.checkbox-row input[type="checkbox"] { width: 15px; height: 15px; accent-color: var(--accent); cursor: pointer; }

/* ─── ACTIVITY FEED ─── */
.activity-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 0; border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.activity-item:last-child { border-bottom: none; }
.activity-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 4px; flex-shrink: 0; }
.activity-time { font-family: var(--mono); font-size: 10.5px; color: var(--muted); min-width: 80px; }
.activity-text { flex: 1; line-height: 1.5; }
.activity-user { margin-left: 6px; font-size: 11.5px; font-weight: 400; color: var(--text2); white-space: nowrap; }

/* ─── LOADING ─── */
#loading-overlay {
  position: fixed; inset: 0; background: rgba(20,22,25,0.85);
  z-index: 9999; display: none; align-items: center; justify-content: center;
  flex-direction: column; gap: 14px; color: var(--text);
}
.spinner { width: 40px; height: 40px; border: 3px solid rgba(123,30,43,0.2); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── RESPONSIVE ─── */
@media (max-width: 700px) {
  .form-grid.g2, .form-grid.g3, .form-grid.g4 { grid-template-columns: 1fr; }
  .span2, .span3, .span4 { grid-column: span 1; }
  .page { padding: 12px; }
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .app-header { padding: 0 14px; }
  .filters-bar { flex-direction: column; align-items: stretch; }
}

/* ─── MATERIAL CATEGORY TABS ─── */
.mat-tabs { display: flex; gap: 4px; margin-bottom: 12px; flex-wrap: wrap; }
.mat-tab { padding: 5px 12px; border-radius: 6px; border: 1px solid var(--border); background: none; color: var(--text2); cursor: pointer; font-size: 12px; font-family: var(--body); transition: all 0.15s; }
.mat-tab.active { background: var(--accent-glow); border-color: rgba(123,30,43,0.4); color: #e8828c; }

/* ─── STEPPER ACTIONS ─── */
.stage-stepper { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.stage-step { padding: 4px 10px; border-radius: 5px; font-size: 11px; font-weight: 600; background: var(--surface3); border: 1px solid var(--border); color: var(--muted); position: relative; }
.stage-step.done { background: var(--green-dim); border-color: rgba(16,185,129,0.3); color: var(--green2); }
.stage-step.current { background: var(--accent-glow); border-color: rgba(123,30,43,0.4); color: #e8828c; }
.stage-step::after { content: '▶'; position: absolute; right: -10px; top: 50%; transform: translateY(-50%); font-size: 8px; color: var(--muted); z-index: 1; }
.stage-step:last-child::after { display: none; }

/* ─── NOTICE ─── */
.notice {
  background: var(--surface2); border-left: 3px solid var(--accent);
  border-radius: 0 7px 7px 0; padding: 10px 14px; font-size: 12.5px; color: var(--text2);
  margin-bottom: 12px; line-height: 1.5;
}
.notice strong { color: #e8828c; }

/* ─── IMPORT AREA ─── */
.import-drop-zone {
  border: 2px dashed var(--border2); border-radius: var(--radius);
  padding: 32px; text-align: center; color: var(--text2);
  cursor: pointer; transition: all 0.2s;
  background: var(--bg2);
}
.import-drop-zone:hover { border-color: var(--accent); background: var(--accent-glow); color: #e8828c; }
.import-drop-zone .drop-icon { font-size: 36px; margin-bottom: 10px; opacity: 0.6; }

/* ─── FILE UPLOAD WRAP ─── */
.file-upload-wrap {
  display: flex; gap: 6px; align-items: center;
}
.file-upload-wrap input[type="text"] {
  flex: 1; cursor: pointer; font-family: var(--mono); font-size: 12px; color: var(--text2) !important;
}
.file-upload-wrap input[type="text"]:not([value=""]) { color: var(--text) !important; }

/* ─── MAT TABLE ─── */
.mat-table { width: 100%; border-collapse: collapse; margin-top: 6px; font-size: 12.5px; }
.mat-table th { background: var(--surface2); color: var(--text2); font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; padding: 7px 10px; text-align: left; font-weight: 600; }
.mat-table td { padding: 7px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.mat-table tr:last-child td { border-bottom: none; }
.mat-table tr:hover td { background: var(--surface2); }
.mat-code { font-family: var(--mono); font-size: 11px; color: var(--blue2); background: var(--blue-dim); padding: 2px 7px; border-radius: 4px; }

/* Settings tabs (gate 1C) */
/* x-cloak hides an Alpine screen until Alpine has started it. When Alpine (or the component script) never starts, that screen stays
   hidden on purpose (half-working controls are worse), and the boot check banner below is what tells the user why. */
[x-cloak] { display: none !important; }
/* Boot check banner (layouts/app.blade.php): at the top of the page, in the flow (it scrolls away: a sticky banner covered the sticky
   app header with its Logout button, and on a 320 px screen it took 40% of the height), never a blocking overlay, never printed. */
.boot-banner { position: relative; z-index: 9000; display: flex; align-items: flex-start; gap: 12px; padding: 10px 14px; background: #4a1218; border-bottom: 2px solid var(--red); color: #fde2e2; font-size: 13px; line-height: 1.45; }
.boot-banner-text { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.boot-banner-text p { margin: 3px 0 0; }
.boot-banner-reload { flex: 0 0 auto; background: var(--red); color: #fff; border: 1px solid var(--red); border-radius: 6px; padding: 6px 12px; cursor: pointer; }
.boot-banner-close { flex: 0 0 auto; background: transparent; border: 0; color: inherit; font-size: 20px; line-height: 1; cursor: pointer; padding: 0 4px; }
.boot-banner-reload:focus-visible, .boot-banner-close:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
@media print { .boot-banner { display: none !important; } }
@media (max-width: 700px) { .boot-banner-text p:last-child { display: none; } }
/* One row that scrolls sideways on a narrow screen (never wraps into several rows); the line under the bar is an
   inset shadow of the bar itself, and the active tab sits on top of it so that it is joined to the panel below. */
.settings-tabs {
  display: flex; gap: 6px; flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden;
  padding-bottom: 1px; box-shadow: inset 0 -1px 0 var(--border); margin-bottom: 16px;
  -webkit-overflow-scrolling: touch; max-width: 100%;
}
.settings-tab { flex: 0 0 auto; white-space: nowrap; background: transparent; color: var(--text2); border: 1px solid transparent; border-bottom: 0; border-radius: 8px 8px 0 0; padding: 9px 16px; font-family: var(--body); font-size: 13px; cursor: pointer; }
.settings-tab:hover { color: var(--text); background: var(--surface2); }
.settings-tab.active { color: var(--text); background: var(--surface); border-color: var(--border); font-weight: 600; margin-bottom: -1px; position: relative; }
.settings-tab:focus-visible { outline: 2px solid var(--blue2); outline-offset: -2px; }
[role="tabpanel"]:focus-visible { outline: 2px solid var(--blue2); outline-offset: 2px; border-radius: 4px; }

/* Toast notifications (htmx errors and confirmations, see layouts/app.blade.php) */
#toast-region { position: fixed; right: 16px; bottom: 16px; z-index: 3000; display: flex; flex-direction: column; gap: 8px; max-width: min(420px, calc(100vw - 32px)); pointer-events: none; }
.toast { position: relative; pointer-events: auto; padding: 10px 40px 10px 14px; border-radius: 8px; border: 1px solid var(--border2); background: var(--surface2); color: var(--text); box-shadow: var(--shadow); font-size: 13px; line-height: 1.4; overflow-wrap: anywhere; word-break: break-word; }
.toast-close { position: absolute; top: 6px; right: 6px; width: 26px; height: 26px; display: flex; align-items: center; justify-content: center; padding: 0; background: transparent; border: 0; border-radius: 6px; color: inherit; font-family: inherit; font-size: 14px; line-height: 1; cursor: pointer; opacity: .85; }
.toast-close:hover { opacity: 1; background: rgba(255,255,255,0.12); }
.toast-close:focus-visible { opacity: 1; outline: 2px solid var(--blue2); outline-offset: 1px; }
.toast-error { border-color: rgba(239,68,68,0.5); background: var(--red-dim); color: #fca5a5; }
.toast-success { border-color: rgba(16,185,129,0.5); background: var(--green-dim); color: var(--green2); }

/* ─── CONTROLS INSIDE TABLES (users / workers rows): same dark look as .form-row inputs ─── */
.ctl {
  padding: 6px 9px; background: var(--bg2); border: 1.5px solid var(--border);
  border-radius: 7px; color: var(--text); font-family: var(--body); font-size: 13px;
  color-scheme: dark; min-width: 0; max-width: 100%;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.ctl:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.ctl::placeholder { color: var(--text2); opacity: .7; }
select.ctl { cursor: pointer; text-overflow: ellipsis; }
select.ctl option { background: var(--bg2); color: var(--text); }
.ctl:disabled { opacity: .55; cursor: not-allowed; }
.ctl-role { width: 210px; }
.ctl-password { width: 170px; }
.ctl-text { width: 100%; max-width: 220px; }

/* ─── LONG TEXT (UI-10): a 100 character role name must never widen the page ─── */
.clamp-cell {
  overflow-wrap: anywhere; word-break: break-word; min-width: 0;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; line-clamp: 3; overflow: hidden;
}
.clamp-name { max-width: 260px; }
.clamp-desc { max-width: 420px; }
.wrap-cell { overflow-wrap: anywhere; word-break: break-word; max-width: 240px; }
.header-user { min-width: 0; }
.header-user > span {
  max-width: min(340px, 46vw); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.header-user .badge {
  display: inline-block; max-width: 160px; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; vertical-align: bottom;
}
.header-right { min-width: 0; }
.users-table { min-width: 820px; }
.roles-table { min-width: 860px; }
.table-wrap { max-width: 100%; -webkit-overflow-scrolling: touch; }

/* ─── MODAL ACCESSIBILITY (UI-11) ─── */
button.modal-close { font-family: inherit; line-height: 1; padding: 0; }
.modal-close:focus-visible { outline: 2px solid var(--blue2); outline-offset: 2px; }
.modal:focus { outline: none; }
.perm-hint { flex-basis: 100%; font-size: 11.5px; color: #e8828c; margin-top: 2px; }
.perm-hint[hidden] { display: none; }

/* ─── ERROR PAGES (resources/views/errors) ─── */
.error-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.error-card {
  width: 100%; max-width: 520px; text-align: center;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  padding: 32px 28px; box-shadow: var(--shadow);
}
.error-icon { font-size: 42px; margin-bottom: 12px; }
.error-code { font-family: var(--mono); font-size: 12px; letter-spacing: 1px; text-transform: uppercase; color: #e8828c; margin-bottom: 8px; }
.error-title { font-family: var(--display); font-size: 28px; font-weight: 700; margin-bottom: 10px; }
.error-text { color: var(--text2); line-height: 1.6; margin-bottom: 22px; overflow-wrap: anywhere; }
.error-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.error-actions form { margin: 0; }

@media (max-width: 700px) {
  .app-logo-sub { display: none; }
  .header-right { gap: 8px; }
  .header-user > span { max-width: 34vw; }
  .error-card { padding: 24px 18px; }
}
.sub-heading { font-size: 14px; font-weight: 600; margin-bottom: 8px; }

/* ─── GATE 1C UI POLISH: reference cards, forms, modals ─── */

/* Text for screen readers only (the empty "actions" column header, ...). */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0, 0, 0, 0); clip-path: inset(50%); white-space: nowrap; border: 0;
}

/* The toast sits bottom right: keep room below the content so the last rows can be scrolled clear of it. */
.page { padding-bottom: 88px; }

/* Card head: the title may wrap, the badge and the Add button stay together. */
.proj-card-head .proj-name { min-width: 0; overflow-wrap: anywhere; }
.proj-card-tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* The wrapper of a scrolling table is the containing block of its absolutely positioned bits (.sr-only header text),
   so that they are clipped with the table instead of widening the whole page. */
.table-wrap { position: relative; }

/* Reference tables (customers, categories, units, currencies). */
.ref-table { min-width: 720px; }
.ref-table td { overflow-wrap: anywhere; }
.ref-name { min-width: 160px; }
/* The Edit / Delete pair stays on one line (a row of two buttons is 190px at least); the other columns give way first. */
.ref-table td:last-child { min-width: 190px; }
.ref-table td:last-child .btn-group { flex-wrap: nowrap; }
.mat-table td.rate-cell { white-space: nowrap; overflow-wrap: normal; }
.ref-sub { font-size: 11.5px; color: var(--text2); }
.ref-muted { color: var(--text2); }
.field-help { font-size: 12px; color: var(--text2); }
.row-hint { font-size: 11.5px; color: var(--text2); margin-top: 4px; max-width: 220px; }

/* An inactive record: only its data cells are dimmed (to a colour that still passes 4.5:1 on the card), the
   status badge and the action buttons keep full strength. */
.mat-table tr.row-inactive td.cell-data,
.mat-table tr.row-inactive td.cell-data .ref-sub,
.mat-table tr.row-inactive td.cell-data .ref-muted { color: var(--text-inactive); }

/* A Delete that can never work for this row (default currency, record in use) is plainly not a live button. */
.btn.btn-locked:disabled, .btn.btn-locked[disabled],
.btn.btn-locked:disabled:hover, .btn.btn-locked[disabled]:hover {
  opacity: 1; background: transparent; color: var(--text2); border: 1px dashed var(--border2); cursor: not-allowed;
}

/* Forms: required marker and invalid fields. */
.req { color: #fca5a5; margin-left: 3px; font-weight: 700; }
.form-note { font-size: 12px; color: var(--text2); margin-bottom: 12px; }
.form-row input[aria-invalid="true"], .form-row select[aria-invalid="true"], .form-row textarea[aria-invalid="true"] { border-color: var(--red); }
.form-row input[aria-invalid="true"]:focus, .form-row select[aria-invalid="true"]:focus, .form-row textarea[aria-invalid="true"]:focus { box-shadow: 0 0 0 3px var(--red-dim); }
.alert[role="alert"]:focus { outline: 2px solid var(--red); outline-offset: 2px; }

/* A modal never exceeds the screen: the host of the content fills the overlay, the dialog is capped by it. */
.modal { min-width: 0; max-width: min(780px, 100%); }
.modal.modal-lg { max-width: min(1000px, 100%); }
.modal.modal-xl { max-width: min(1200px, 100%); }
.overlay > #ref-modal-content:not(:empty), .overlay > #role-modal-content:not(:empty) { width: 100%; max-width: 100%; min-width: 0; }
.modal-body { overflow-wrap: anywhere; }
.modal-title { min-width: 0; overflow-wrap: anywhere; }

/* Loading state of a modal: the overlay opens before the htmx response arrives; its (still empty) content host
   shows a small spinner and the text of its data-loading attribute (set by layouts/app.blade.php). */
.overlay.open [data-loading]:empty {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  width: max-content; max-width: 100%; margin: 18vh 0 0; padding: 14px 22px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow); color: var(--text2); font-size: 13px;
}
.overlay.open [data-loading]:empty::before {
  content: ''; flex: none; width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid rgba(155,37,54,0.3); border-top-color: var(--accent2); animation: spin 0.8s linear infinite;
}
.overlay.open [data-loading]:empty::after { content: attr(data-loading); }
@media (prefers-reduced-motion: reduce) {
  .overlay.open [data-loading]:empty::before { animation: none; }
  .modal { animation: none; }
}

@media (max-width: 700px) {
  .proj-card-head { padding: 12px 14px; }
  .proj-card-body { padding: 14px; }
  .modal-body { padding: 14px; }
  .modal-head, .modal-foot { padding-left: 14px; padding-right: 14px; }
  .overlay { padding: 12px; }
}

/* ─── GATE 2A PRODUCTS SCREEN (adversarial fixes C1) ─── */

/* A notice with the hidden attribute stays hidden (.alert sets display:flex, which would show it). */
.alert[hidden] { display: none; }

/* While a modal is open the page behind it does not scroll: layouts/app.blade.php puts the class on <html>, and a wheel
   over the backdrop never chains on to the page either. */
html.modal-open { overflow: hidden; padding-right: var(--ops-scrollbar, 0px); }
.overlay { overscroll-behavior: contain; }

/* The list takes the focus after a swap removed the control that had it (paging, delete, restore): show where it is. */
#products-list:focus { outline: none; }
#products-list:focus-visible { outline: 2px solid var(--accent2); outline-offset: 4px; border-radius: var(--radius); }

/* The filter bar. Paging scrolls it to the top of the screen, below the 56px sticky header. */
#products-filters { scroll-margin-top: 72px; }
.filters-clear { align-self: flex-end; }
/* A long category name (up to 100 characters) must not make its select as wide as the name: the select is capped and
   the text is cut with an ellipsis (the whole name is in the opened list). */
#products-filters .filter-group { min-width: 0; max-width: 100%; }
#products-filters .filter-group select { max-width: 280px; text-overflow: ellipsis; }
#products-filters .filter-search { flex: 2; min-width: 220px; }
@media (max-width: 700px) {
  /* One column: every group as wide as the bar (not each at its own right edge) and the Clear button too. */
  .filters-clear { align-self: stretch; }
  #products-filters .filter-search { flex: none; min-width: 0; }
  #products-filters .filter-group select { max-width: 100%; }
}

/* The products table. The Phase 1 reference tables let any cell break anywhere (overflow-wrap:anywhere), which also lets
   the auto table layout squeeze a column down to one letter ("Ade/t"): here a word breaks only when it is longer than the
   cell, and a SKU (up to 120 characters) wraps inside its own column instead of running over the next ones. */
.products-table td { overflow-wrap: normal; }
.products-table .wrap-cell { overflow-wrap: break-word; word-break: normal; }
.products-table .sku-cell { min-width: 140px; }

/* Tablet and phone: the table scrolls sideways, so the Edit / Delete column stays in view on the right as two icon buttons
   (their text goes: each button keeps its aria-label with the SKU) instead of sitting 800px away off screen. */
@media (max-width: 900px) {
  .products-table th:last-child, .products-table td:last-child { position: sticky; right: 0; min-width: 0; }
  .products-table td:last-child { background: var(--surface); box-shadow: -8px 0 8px -8px rgba(0, 0, 0, 0.7); }
  .products-table tbody tr:hover td:last-child { background-image: linear-gradient(rgba(74, 79, 87, 0.2), rgba(74, 79, 87, 0.2)); }
  .products-table td:last-child .btn-group { gap: 4px; }
  .products-table .btn-label { display: none; }
}

/* ─── GATE 2A ROUND 2: PRICE RULES CARD (UI-12) ─── */

/* Wide screens: the five columns need room. Tablet and phone: the table scrolls sideways, and the action column (Preview & apply,
   Undo) stays in view on the right as icon buttons (their text goes: each keeps its aria-label and title) instead of sitting
   off screen; its "why is this locked" hint is narrow there. */
.price-rules-table { min-width: 900px; }
@media (max-width: 900px) {
  .price-rules-table { min-width: 680px; }
  .price-rules-table th:last-child, .price-rules-table td:last-child { position: sticky; right: 0; min-width: 0; }
  .price-rules-table td:last-child { background: var(--surface); box-shadow: -8px 0 8px -8px rgba(0, 0, 0, 0.7); }
  .price-rules-table td:last-child .btn-group { gap: 4px; }
  .price-rules-table td:last-child .row-hint { max-width: 92px; }
  .price-rules-table .btn-label { display: none; }
}

/* ─── GATE 2A ROUND 2: PRODUCTS LIST ON A NARROW SCREEN (R2UI-1, R2UI-2) ─── */

/* R2UI-1: the products table is about 1200px wide, so on a tablet, a phone and a small laptop the price columns are off screen
   (at 768px the sticky Edit / Delete column even sits over the List price column) and the horizontal scrollbar is at the
   bottom of a 25-row table. A line ABOVE the table says so; it shows up to the width where the table stops fitting
   (1400px page - 2 x 24px padding - card padding and border - the table's own width of about 1200px, with some room). */
.table-scroll-hint { display: none; margin: 0 0 8px; font-size: 12px; color: var(--text2); }
@media (max-width: 1320px) {
  .table-scroll-hint { display: block; }
}
/* The scrolling wrapper takes the keyboard focus (tabindex="0"), so a keyboard user can scroll the table: show where it is. */
.products-wrap:focus-visible { outline: 2px solid var(--accent2); outline-offset: 2px; }

/* R2UI-2: the title and its button group wrap instead of touching (at 375px the title ended at x=248 and the first button began
   at x=250) with a gap between them; on a phone the group takes its own row under the title. */
.card-head { flex-wrap: wrap; gap: 10px 12px; }
.card-head .btn-group { min-width: 0; }
@media (max-width: 700px) {
  #products-actions { flex: 1 1 100%; }
}

/* ─── GATE 2B: ORDER FORM (resources/views/purchasing/_form.blade.php) ─── */

/* The modal never grows past the screen: the host of the content fills the overlay, the lines table scrolls inside its own wrapper. */
.overlay > #order-modal-content:not(:empty),
.overlay > #price-update-modal-content:not(:empty) { width: 100%; max-width: 100%; min-width: 0; }

/* The toolbar above the lines: the catalog search, the instant line filter and the (later) Excel import hook. */
.of-toolbar { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 10px; }
.of-search { flex: 2 1 320px; min-width: 0; }
.of-filter { flex: 1 1 220px; min-width: 0; }
.of-import-hook { flex: 1 1 100%; min-width: 0; }
.of-import-hook:empty { display: none; }
/* Excel import of lines (gate 2B): the buttons, and the answer of the server under them. */
.of-import-buttons { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; }
.of-import-help { font-size: 12px; color: var(--text2); min-width: 0; }
.of-import-result { position: relative; margin-top: 10px; padding-right: 34px; min-width: 0; overflow-wrap: anywhere; }
.of-import-dismiss { position: absolute; top: 0; right: 0; }
.of-import-note { font-weight: 400; font-size: 12.5px; margin-top: 4px; }
.of-import-notes { margin: 6px 0 0 18px; font-size: 12.5px; color: var(--text2); }
.of-import-notes li { margin: 2px 0; }
.of-import-problems { margin-top: 8px; font-size: 12.5px; }
.of-import-download { margin: 8px 0 4px; }

/* The result list sits in the page flow (never clipped by the scrolling modal body). */
.of-results { border: 1px solid var(--border2); border-radius: 8px; background: var(--bg2); max-height: 280px; overflow-y: auto; margin-bottom: 12px; }
.of-results-note { padding: 9px 12px; font-size: 12.5px; color: var(--text2); }
.of-result {
  display: grid; grid-template-columns: minmax(110px, auto) minmax(0, 1fr) auto auto auto; gap: 4px 12px; align-items: center; width: 100%;
  padding: 8px 12px; background: transparent; border: 0; border-bottom: 1px solid var(--border); color: var(--text);
  font-family: var(--body); font-size: 13px; text-align: left; cursor: pointer;
}
.of-result:last-of-type { border-bottom: 0; }
.of-result.active, .of-result:hover:not(:disabled) { background: var(--surface2); }
.of-result:focus-visible { outline: 2px solid var(--blue2); outline-offset: -2px; }
.of-result:disabled { cursor: not-allowed; opacity: .75; }
.of-result-main { display: flex; flex-direction: column; min-width: 0; overflow-wrap: anywhere; }
.of-result-unit { white-space: nowrap; }
.of-result-price { display: flex; flex-direction: column; align-items: flex-end; font-family: var(--mono); font-size: 12px; white-space: nowrap; }

/* The lines table scrolls sideways inside its own wrapper (11 columns). */
.of-wrap { overflow-x: auto; max-width: 100%; border: 1px solid var(--border); border-radius: 8px; -webkit-overflow-scrolling: touch; }
.of-wrap:focus-visible { outline: 2px solid var(--accent2); outline-offset: 2px; }
.of-table { min-width: 1080px; margin-top: 0; }
.of-table td { vertical-align: top; }
/* Tighter cells: the 12 columns of the edit modal (Actions + Remove included) fit the 1200px modal without a sideways scroll. */
.of-table th, .of-table td { padding-left: 5px; padding-right: 5px; }
.of-table .ctl { width: 100%; }
/* The Remove column stays at the right edge when the table does scroll (a narrow window): the control is never out of reach. */
.of-table th.of-remove, .of-table td.of-remove { position: sticky; right: 0; z-index: 1; background: var(--surface); box-shadow: -8px 0 8px -8px rgba(0, 0, 0, 0.7); }
.of-table th.of-remove { background: var(--surface2); }
.of-table tr:hover td.of-remove { background: var(--surface2); }
.of-num { min-width: 78px; text-align: right; font-family: var(--mono); font-size: 12px; padding: 4px 6px; }
.of-num-sm { min-width: 60px; }
.of-num-h { text-align: right; }
.of-total-cell { text-align: right; font-family: var(--mono); white-space: nowrap; padding-top: 12px; }
.of-item { min-width: 240px; overflow-wrap: anywhere; }
.of-name { margin-top: 4px; }
.of-unit { white-space: nowrap; padding-top: 12px; }
.of-desc { margin-top: 3px; }
.of-row-new td:first-child { box-shadow: inset 3px 0 0 var(--green); }
.of-row-legacy td:first-child { box-shadow: inset 3px 0 0 var(--blue2); }
.of-progress { margin: 5px 0 2px; width: 70px; }
.of-actions { white-space: nowrap; text-align: right; }
.of-over { border-color: var(--red); }
.of-line-msg { color: #fca5a5; font-size: 11.5px; margin-top: 3px; }
.of-totals { display: flex; gap: 8px 24px; flex-wrap: wrap; justify-content: flex-end; padding: 10px 4px 0; font-size: 12.5px; color: var(--text2); }
.of-totals strong { color: var(--text); font-family: var(--mono); }
.of-empty-filter { padding: 10px 4px; font-size: 12.5px; color: var(--text2); }
.ctl[aria-invalid="true"] { border-color: var(--red); }

/* Phone: every line is a card (item on top, the numbers in two columns) instead of a 1200px table behind a sideways scroller. */
@media (max-width: 640px) {
  .of-wrap { overflow-x: visible; border: 0; }
  .of-table { min-width: 0; display: block; }
  .of-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .of-table tbody { display: block; }
  .of-table tr[data-order-line] { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 10px; padding: 10px 8px; border: 1px solid var(--border); border-radius: 8px; margin-bottom: 8px; }
  .of-table td { display: block; padding: 0; border: 0; min-width: 0; }
  .of-table td[data-label]::before { content: attr(data-label); display: block; font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text2); margin-bottom: 2px; }
  .of-table td.of-item, .of-table td[data-label="Status"], .of-table td[data-label="Actions"], .of-table td.of-remove { grid-column: 1 / -1; }
  .of-table td.of-total-cell, .of-table td.of-unit { padding-top: 0; text-align: left; }
  .of-table td.of-actions { text-align: left; }
  .of-table td.of-remove { position: static; box-shadow: none; background: transparent; }
  .of-table tr:hover td, .of-table tr:hover td.of-remove { background: transparent; }
  .of-item { min-width: 0; }
  .of-num { min-width: 0; }
}

@media (max-width: 700px) {
  .of-result { grid-template-columns: minmax(0, 1fr) auto; }
  .of-result .mat-code { grid-column: 1 / -1; justify-self: start; }
  .of-result-unit { display: none; }
}

/* GATE 2B: RATE REDESIGN (the order head summary, the notices, the save-time rate dialog) */
.of-head-main { min-width: 0; }
.of-head-summary { font-family: var(--mono); font-size: 12.5px; color: var(--text2); margin-top: 2px; overflow-wrap: anywhere; }
.of-notice { margin: 8px 0; font-size: 12.5px; }
.of-reprice { align-self: flex-end; }
.of-rate-dialog { margin: auto; border: 1px solid var(--border2); border-radius: 12px; background: var(--surface); color: var(--text); padding: 0; width: min(460px, calc(100vw - 32px)); max-width: none; box-shadow: 0 32px 80px rgba(0,0,0,0.6); }
.of-rate-dialog::backdrop { background: rgba(20,22,25,0.7); }
.of-rate-inner { padding: 18px 20px 20px; }
.of-rate-title { font-family: var(--display); font-weight: 700; font-size: 16px; margin-bottom: 8px; }
.of-rate-text { font-size: 14px; line-height: 1.5; margin: 0 0 10px; }
.of-rate-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
@media (max-width: 480px) {
  .of-rate-actions { flex-direction: column; }
  .of-rate-actions .btn { width: 100%; justify-content: center; }
}

/* ─── MATERIAL MOVEMENT (signers and material movement spec, M.3) ─── */
.movement-intro { margin: 0 0 12px; }
#movement-filters .filter-search { flex: 2 1 260px; min-width: 0; }
#movement-filters .filter-search input { width: 100%; min-width: 0; box-sizing: border-box; }
#movement-filters .filter-group select { min-width: 0; max-width: 100%; }
/* The sources are a fieldset of checkboxes: not a .filter-group (its input rule would stretch every checkbox to the width of a text box). */
.movement-sources { border: 0; margin: 0; padding: 0; min-width: 0; max-width: 100%; flex: 0 1 380px; display: flex; flex-direction: column; gap: 4px; }
.movement-sources legend { padding: 0; margin-bottom: 4px; font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text2); }
.movement-sources-list { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.movement-source-opt { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text); cursor: pointer; }
.movement-source-opt input[type="checkbox"] { width: 15px; height: 15px; margin: 0; accent-color: var(--accent); cursor: pointer; }
.movement-sources-hint { margin: 2px 0 0; }
.movement-note, .movement-found, .movement-legend { margin: 0 0 8px; }
/* The Excel export link and its one sentence: a column that wraps inside the card, so it is as usable at 360px as on a desktop. */
.movement-export { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; min-width: 0; margin: 0 0 12px; }
.movement-export .btn { max-width: 100%; white-space: normal; text-align: left; }
.movement-export-note { margin: 0; min-width: 0; overflow-wrap: anywhere; }
/* The tables scroll inside their own .table-wrap (the page never scrolls sideways): a minimum width keeps the columns readable. */
.movement-timeline { min-width: 900px; }
.movement-summary { min-width: 520px; }
.movement-table td.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.movement-table td.movement-date { white-space: nowrap; }
.movement-table td.movement-event { min-width: 220px; overflow-wrap: anywhere; }
.movement-table td.movement-detail, .movement-table td.movement-name, .movement-table td.movement-ref { min-width: 120px; overflow-wrap: anywhere; }
.movement-table td.movement-sku { overflow-wrap: anywhere; }
/* A step known only as "as of the last update": muted, and the tag says it in words too (colour alone is not enough). */
.movement-table tr.movement-asof td { color: var(--text-inactive); font-style: italic; }
.movement-table tr.movement-asof td .badge { font-style: normal; }
.movement-asof-tag { display: block; font-size: 11px; font-style: normal; color: var(--text2); }
.movement-results .alert ul { margin: 4px 0 0; padding-left: 18px; }
/* The search term is echoed back (up to 120 characters, no spaces needed): it must wrap inside the card, never widen the page. */
.movement-results .empty p, .movement-found, .movement-results .alert, .movement-results .alert li { overflow-wrap: anywhere; min-width: 0; }
/* The browser's default link colours (#0000EE, visited #551A8B) are 1.7:1 and 1.45:1 on the dark card; #93c5fd is 8.9:1 on it (7.9:1 on the row hover). */
.movement-table a, .movement-table a:visited { color: #93c5fd; text-decoration: underline; }
.movement-table a:hover { color: #bfdbfe; }
.movement-table a:focus-visible { outline: 2px solid #93c5fd; outline-offset: 2px; border-radius: 2px; }
/* The Source and Status badges: the palette blue (3.8:1) and purple (3.3:1) text fail WCAG AA at 11 px; lighter tints of the same hues pass (7.7:1). */
.movement-table .badge.b-blue { color: #93c5fd; }
.movement-table .badge.b-purple { color: #c4b5fd; }
@media (max-width: 700px) {
  #movement-filters .filter-search { flex: none; }
  /* .filters-bar is a column here: the 380px flex-basis of the sources would become a HEIGHT of 380px. */
  .movement-sources { flex: none; }
  .movement-submit { align-self: stretch; justify-content: center; }
}

/* QUICK PRICING (docs/quick-pricing-spec.md Q5): the modal of the quotes list (resources/views/quotes/_quick-pricing.blade.php). */
/* Buttons, alerts and tables keep their own display rule: without this the hidden attribute would not hide them. */
.qp [hidden] { display: none !important; }
.qp .qp-intro { margin: 0 0 10px; }
.qp .qp-counts { margin: 0 0 10px; font-weight: 600; }
.qp .qp-counts:focus { outline: none; }
.qp .qp-notices { margin: 6px 0 0; padding-left: 18px; }
/* The table scrolls inside its own box (both ways) and keeps its header in view; the amounts line up on the right. */
.qp .qp-wrap { max-height: 55vh; overflow: auto; margin-top: 10px; }
.qp .qp-table { min-width: 960px; }
.qp .qp-problems-table { min-width: 480px; }
.qp .qp-table thead th { position: sticky; top: 0; z-index: 1; }
.qp .qp-table th.qp-num, .qp .qp-table td.qp-num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
/* .modal-body breaks words anywhere: a column of codes or amounts must not be cut letter by letter, only the product name (free text) may be. */
.qp .qp-table td { overflow-wrap: normal; }
.qp .qp-table td.qp-name { min-width: 200px; overflow-wrap: anywhere; }
.qp .qp-table td.qp-sku { white-space: nowrap; }
.qp .qp-problems-table td.qp-sku { white-space: normal; overflow-wrap: anywhere; }
.qp .qp-problems-table td { overflow-wrap: anywhere; }
.qp .qp-table td.qp-status { min-width: 210px; }
.qp .qp-table td .badge { white-space: normal; text-align: left; border-radius: 12px; }
.qp .qp-table td.qp-total-label { text-align: right; }

/* PRICING LEVELS (docs/pricing-levels-spec.md, L3 "S"): the "Labor and sarf pricing" modal of the Panel types card
   (resources/views/settings/reference/_pricing-levels-modal.blade.php). Two lists, labor and sarf, each a table and an add (or edit) form. */
.pricing-levels-modal .pl-intro { margin-bottom: 8px; }
.pricing-levels-modal .pl-section { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border); }
.pricing-levels-modal .pl-heading { font-family: var(--display); font-size: 15px; font-weight: 700; margin: 0 0 10px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.pricing-levels-modal .pl-subheading { font-size: 13px; font-weight: 700; margin: 0 0 8px; }
/* The table scrolls inside the modal on a narrow screen; the amounts line up on the right and are never cut letter by letter. */
.pricing-levels-modal .pl-table { min-width: 560px; }
.pricing-levels-modal .pl-table td { overflow-wrap: normal; }
.pricing-levels-modal .pl-table td.cell-data .ref-name { overflow-wrap: anywhere; }
.pricing-levels-modal .pl-table th.pl-num, .pricing-levels-modal .pl-table td.pl-num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.pricing-levels-modal .pl-table td:last-child { min-width: 250px; }
.pricing-levels-modal .pl-table td:last-child .btn-group { flex-wrap: wrap; }
.pricing-levels-modal .pl-table tr[aria-current="true"] td { background: var(--surface2); }
.pricing-levels-modal .pl-form { margin-top: 12px; padding: 12px 14px; background: var(--bg2); border: 1px solid var(--border); border-radius: 10px; }
/* The add form is one row: name, cost and the button; it wraps under 700px (the fields stack). */
.pricing-levels-modal .pl-add-row { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) auto; gap: 12px; align-items: end; }
.pricing-levels-modal .pl-add-row .form-row { margin-bottom: 0; }
.pricing-levels-modal .pl-add-default { margin-top: 10px; }
.pricing-levels-modal .pl-form .field-help { margin-top: 6px; }
.pricing-levels-modal .pl-form-actions { margin-top: 12px; }
@media (max-width: 700px) {
  .pricing-levels-modal .pl-add-row { grid-template-columns: 1fr; }
  .pricing-levels-modal .pl-add-submit .btn { width: 100%; justify-content: center; }
}
