/* ============================================================
   COSTING DESK — Industrial / Editorial
   Palette: deep ink navy, bone paper, amber accent, graphite
   Type: Fraunces (display serif) + Space Grotesk (body) + JetBrains Mono
   ============================================================ */
:root {
  --ink:       #0F1B2D;
  --ink-soft:  #1A2B44;
  --line:      #DCD6C5;
  --line-soft: #EFEADB;
  --paper:     #F5F1E6;
  --paper-2:   #FAF6EC;
  --amber:     #D97706;
  --amber-dk:  #B45309;
  --amber-bg:  #FEF3C7;
  --red:       #B91C1C;
  --green:     #166534;
  --graphite:  #1E293B;
  --dim:       #334155;
  --focus:     #1D4ED8;
  --radius:    3px;
  --shadow:    0 1px 2px rgba(15,27,45,.06), 0 8px 24px rgba(15,27,45,.05);
}

* { box-sizing: border-box; }
html { min-height: var(--page-h, 100vh); }
body {
  margin: 0;
  min-height: var(--page-h, 100vh);
  font-family: 'Space Grotesk', system-ui, sans-serif;
  background: var(--paper);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; font-weight: 700; }
a { color: var(--ink); text-decoration: none; }
a:hover { color: var(--amber); }
.mono { font-family: 'JetBrains Mono', ui-monospace, monospace; }

/* ----------- Shell (dashboard layout) ----------- */
.shell {
  display: grid;
  grid-template-columns: 200px 1fr;
  min-height: var(--page-h, 100vh);
}

.sidebar {
  background: var(--ink);
  color: #E7E4D8;
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  position: sticky; top: 0;
  height: var(--page-h, 100vh);
  border-right: 1px solid var(--ink);
}

.brand {
  display: flex;
  justify-content: center;
}
.brand-logo {
  height: 36px;
  width: auto;
  display: block;
}
.brand-module {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: #A8A293;
  padding: 10px 14px 8px;
  border-top: 1px solid rgba(255,255,255,.1);
  margin-top: auto;
}

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-link {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px;
  color: #C5C1B0;
  border-radius: var(--radius);
  transition: all .15s ease;
  font-weight: 500;
  border-left: 2px solid transparent;
}
.nav-link:hover { background: rgba(255,255,255,.04); color: #fff; }
.nav-link.active { background: var(--ink-soft); color: #fff; border-left-color: var(--amber); }
.nav-ico { width: 18px; text-align: center; font-size: 15px; color: var(--amber); }

.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 12px; padding-top: 20px; border-top: 1px solid rgba(255,255,255,.08); }
.user-chip { display: flex; gap: 10px; align-items: center; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--amber); color: var(--ink); display: grid; place-items: center; font-weight: 700; }
.u-name { font-weight: 600; color: #fff; font-size: 14px; }
.u-role { font-size: 11px; text-transform: uppercase; letter-spacing: .12em; color: #A8A293; }
.logout { color: #A8A293; font-size: 13px; }
.logout:hover { color: var(--amber); }

.main {
  padding: 36px 48px 80px;
  max-width: 1500px;
  width: 100%;
}

/* ----------- Page heads ----------- */
.page-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--paper);
  padding-top: 8px;
}
.tabs {
  position: sticky;
  top: 90px;         /* sits just below the frozen page-head */
  z-index: 49;
  background: var(--paper);
}
.page-eyebrow { font-size: 11px; text-transform: uppercase; letter-spacing: .16em; color: var(--amber-dk); font-weight: 600; }
.page-title {
  font-family: 'Fraunces', serif; font-weight: 900; font-size: 17px;
  line-height: 1.1; letter-spacing: -.01em; margin: 2px 0 1px;
}
.page-product-name {
  font-family: inherit; font-weight: 500; font-size: 14px;
  color: var(--graphite); letter-spacing: 0;
}
.page-sub { color: var(--graphite); font-size: 14px; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ----------- Buttons ----------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 16px;
  border: 1px solid var(--ink);
  background: var(--ink); color: #fff;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600; font-size: 14px;
  cursor: pointer;
  border-radius: var(--radius);
  transition: all .12s ease;
  text-decoration: none;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.btn-primary { background: var(--amber); border-color: var(--amber); color: var(--ink); }
.btn-primary:hover { background: var(--amber-dk); border-color: var(--amber-dk); color: #fff; }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { background: var(--paper-2); border-color: var(--ink); }
.btn-danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn-danger:hover { background: #8B1414; border-color: #8B1414; }
.btn-sm { padding: 6px 10px; font-size: 13px; }
.btn-block { width: 100%; justify-content: center; }

/* ----------- Stat cards ----------- */
.stat-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 28px;
}
.stat-row-3 { grid-template-columns: repeat(3, 1fr); margin-bottom: 0; gap: 8px; }
.stat-row-6 { grid-template-columns: repeat(6, 1fr); margin-bottom: 16px; gap: 8px; }

/* Formula row: [Card] + [Card] = [Card] */
.stat-formula { display: flex; align-items: stretch; gap: 8px; margin-bottom: 28px; }
.stat-formula .stat-card { flex: 1; }
.stat-op {
  display: flex; align-items: center; justify-content: center;
  font-family: 'Fraunces', serif; font-size: 33px; font-weight: 700;
  color: var(--dim); flex-shrink: 0; padding: 0 4px; min-width: 28px;
}
.stat-card-breakdown {
  display: flex; gap: 12px; margin-top: 6px; flex-wrap: wrap;
}
.stat-card-breakdown-item { font-size: 12px; color: var(--dim); }
.stat-card-breakdown-item span { font-weight: 600; color: var(--ink); }

/* Stat group (label + row of 3) */
.stat-group-row { margin-bottom: 10px; }
.stat-group-label {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .14em; color: var(--graphite);
  margin-bottom: 4px; padding-left: 2px;
}

/* Compact cards inside stat-row-3 and stat-row-6 */
.stat-row-3 .stat-card,
.stat-row-6 .stat-card          { padding: 8px 10px; }
.stat-row-3 .stat-label,
.stat-row-6 .stat-label         { font-size: 10px; letter-spacing: .10em; }
.stat-row-3 .stat-val,
.stat-row-6 .stat-val           { font-size: 17px; margin-top: 2px; }
.stat-row-6 .stat-group-label   { font-size: 9px; margin-bottom: 2px; padding: 0; border: none; margin-top: 0; }

/* Stat card colour variants */
.stat-ok            { }
.stat-ok::before    { background: #16A34A !important; }
.stat-ok .stat-val  { color: #15803D; }
.stat-danger::before      { background: #DC2626 !important; }
.stat-danger .stat-val    { color: #B91C1C; }
.stat-amber::before       { background: #D97706 !important; }
.stat-amber .stat-val     { color: #B45309; }
.stat-card {
  background: #fff;
  border: 1px solid var(--line);
  padding: 20px 22px;
  border-radius: var(--radius);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.stat-card::before {
  content: '';
  position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--line);
}
.stat-accent { background: var(--ink); color: #fff; border-color: var(--ink); }
.stat-accent::before { background: var(--amber); }
.stat-accent .stat-val { color: #fff; }
.stat-label {
  font-size: 12px; text-transform: uppercase; letter-spacing: .16em;
  color: var(--dim); font-weight: 600;
  min-height: 2.6em;           /* keeps value vertically aligned across all cards */
  display: flex; align-items: flex-start;
}
.stat-accent .stat-label { color: #A8A293; }

/* Compact stat-row — reduced padding, smaller number, no label min-height */
.stat-row-compact .stat-card { padding: 12px 16px; }
.stat-row-compact .stat-label { font-size: 10px; min-height: unset; letter-spacing: .12em; }
.stat-row-compact .stat-val  { font-size: 22px; margin-top: 2px; }
.stat-row-compact .stat-note { font-size: 9px; margin-top: 3px; }
.stat-row-compact.stat-formula .stat-op { font-size: 22px; min-width: 20px; }

.stat-val {
  font-family: 'Fraunces', serif;
  font-weight: 700; font-size: 33px;
  letter-spacing: -.02em;
  margin-top: 4px;
  color: var(--ink);
}
.stat-note {
  font-size: 11px; color: var(--dim); margin-top: 6px; line-height: 1.3;
  font-style: italic;
}

/* ----------- Panels ----------- */
.panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 22px;
  overflow: hidden;
}
.panel-head {
  padding: 18px 24px;
  display: flex; justify-content: space-between; align-items: center;
  border-bottom: 1px solid var(--line-soft);
  background: var(--paper-2);
}
.panel-head h2 { font-family: 'Fraunces', serif; font-size: 21px; letter-spacing: -.01em; }
.panel-hint { font-size: 13px; color: var(--dim); text-transform: uppercase; letter-spacing: .1em; }

/* ----------- Tables ----------- */
.table-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th, .tbl td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.tbl th {
  background: var(--paper-2);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--graphite);
  font-weight: 600;
  border-bottom: 1.5px solid var(--line);
}
.tbl .r { text-align: right; }
.tbl tbody tr:hover { background: var(--paper-2); }
.tr-total { background: var(--amber-bg) !important; border-top: 2px solid var(--ink); }
.tr-total td { border-bottom: none; padding: 14px; }
.t-strong { font-weight: 600; }
.t-dim { color: var(--dim); font-size: 13px; }

.tbl-edit input, .tbl-edit select {
  width: 100%;
  border: 1px solid transparent;
  background: transparent;
  padding: 3px 6px;
  border-radius: 2px;
  font-family: inherit; font-size: 13px;
  color: var(--ink);
}
.tbl-edit input:focus, .tbl-edit select:focus {
  outline: 2px solid var(--amber);
  background: #fff;
  border-color: var(--amber);
}
.tbl-edit input:hover:not(:focus), .tbl-edit select:hover:not(:focus) {
  background: var(--paper-2);
}

/* ----------- Forms ----------- */
.field {
  display: block;
  margin-bottom: 14px;
}
.field > span {
  display: block;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--graphite);
  margin-bottom: 5px;
  font-weight: 600;
}
.field input, .field select, .field textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-family: inherit; font-size: 15px;
  background: #fff;
  color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--amber);
  box-shadow: 0 0 0 3px rgba(217,119,6,.15);
}
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0 20px; padding: 20px 24px; }

.addcost-grid { padding: 12px 24px 16px; display: flex; flex-direction: column; gap: 0; }
.addcost-row {
  display: grid;
  grid-template-columns: 200px 120px 1fr;
  gap: 8px 12px;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px solid var(--line-soft);
}
.addcost-row:last-child { border-bottom: none; }
.addcost-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--graphite);
  white-space: nowrap;
}
.addcost-amt {
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  text-align: right;
  width: 100%;
}
.addcost-note {
  font-size: 13px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--graphite);
  width: 100%;
}
.addcost-note::placeholder { color: var(--dim); opacity: .7; font-style: italic; }

.pack-details-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--line);
  padding: 0;
}
.pack-details-group {
  background: var(--paper);
  padding: 14px 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.pack-details-title {
  font-family: 'Fraunces', serif;
  font-weight: 700;
  font-size: 15px;
  color: var(--ink);
  border-bottom: 2px solid var(--line);
  padding-bottom: 6px;
  margin-bottom: 2px;
}
.pack-details-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px 18px; padding: 20px 24px; }

.inline-field { display: inline-flex; gap: 8px; align-items: center; font-size: 13px; text-transform: uppercase; letter-spacing: .1em; color: var(--graphite); }
.inline-field input { padding: 6px 10px; border: 1px solid var(--line); border-radius: var(--radius); width: 100px; }

.split-row { display: flex; gap: 8px; align-items: center; }
.split-in { flex: 1; }
.split-tag {
  font-family: 'JetBrains Mono', monospace;
  padding: 8px 12px;
  background: var(--ink); color: #fff;
  border-radius: var(--radius);
  min-width: 60px; text-align: center; font-weight: 600;
}
.split-tag.bad { background: var(--red); }
.split-tag.ok  { background: var(--green); }

/* ----------- Tabs ----------- */
.tabs {
  display: flex; gap: 2px;
  margin-bottom: 22px;
  border-bottom: 2px solid var(--line);
  overflow-x: auto;
}
.tab {
  background: transparent;
  border: none;
  padding: 12px 18px;
  font-family: inherit; font-weight: 600; font-size: 14px;
  color: var(--graphite);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  white-space: nowrap;
  transition: all .15s ease;
}
.tab:hover { color: var(--ink); background: var(--line-soft); border-radius: 6px 6px 0 0; }
.tab.active {
  color: #fff;
  background: var(--amber);
  border-bottom-color: var(--amber);
  border-radius: 6px 6px 0 0;
}
.tab-admin { color: var(--amber) !important; }
.tab-admin.active { background: var(--amber-dk); border-bottom-color: var(--amber-dk); color: #fff; }
.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fadeIn .25s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
@keyframes warnFlash {
  0%, 100% { background: #FEE2E2; }
  50%       { background: #FECACA; box-shadow: 0 0 0 3px rgba(185,28,28,.25); }
}
.warn-flash { animation: warnFlash 1.4s ease-in-out infinite; }

/* ----------- Mould material blocks ----------- */
.mold-grid { padding: 20px 24px; display: grid; grid-template-columns: 1fr; gap: 28px; }
.mold-block { border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper-2); }
.mold-head { padding: 6px 14px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--line); background: #fff; }
.mold-head h3 { font-family: 'Fraunces', serif; font-size: 15px; }
.mold-mat { background: #fff; }
.mold-mat.tbl th, .mold-mat.tbl td { padding: 5px 10px; font-size: 13px; }
.mold-mat.tbl th { font-size: 11px; }
.mold-total-row { background: var(--amber-bg); font-weight: 600; }
.mold-pct-total { font-family: 'JetBrains Mono', monospace; font-weight: 700; color: var(--ink); }

/* ----------- Master cards ----------- */
.master-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.master-card {
  background: #fff; border: 1px solid var(--line); padding: 20px 22px;
  border-radius: var(--radius); position: relative;
  transition: all .2s ease;
  display: block;
}
.master-card:hover { border-color: var(--ink); transform: translateY(-2px); box-shadow: var(--shadow); }
.master-card:hover .mc-arrow { color: var(--amber); transform: translateX(4px); }
.mc-name { font-family: 'Fraunces', serif; font-weight: 700; font-size: 19px; margin-bottom: 4px; }
.mc-cols { font-size: 13px; color: var(--dim); text-transform: uppercase; letter-spacing: .1em; }
.mc-arrow { position: absolute; top: 22px; right: 22px; font-size: 23px; color: var(--line); transition: all .2s ease; }

/* ----------- Badges ----------- */
.badge { display: inline-block; padding: 3px 8px; font-size: 12px; font-weight: 600;
  background: var(--line-soft); color: var(--ink); border-radius: 2px; letter-spacing: .05em; }
.badge-dark { background: var(--ink); color: #fff; font-family: 'JetBrains Mono', monospace; }

/* ----------- Flash messages ----------- */
.flash-stack { margin-bottom: 20px; }
.flash { padding: 12px 18px; border-radius: var(--radius); font-size: 14px; margin-bottom: 10px; border-left: 3px solid; }
.flash-info  { background: #DBEAFE; border-color: #1D4ED8; color: #1E3A8A; }
.flash-error { background: #FEE2E2; border-color: var(--red); color: #7F1D1D; }

.save-chip {
  font-size: 12px; text-transform: uppercase; letter-spacing: .12em;
  padding: 6px 12px; background: var(--amber-bg); color: var(--amber-dk);
  border-radius: 2px; font-weight: 600;
}
.save-chip.saved { background: #D1FAE5; color: var(--green); }

/* ----------- Snapshot ----------- */
.snap { padding: 8px 24px 24px; font-size: 15px; }
.snap .empty { text-align: center; padding: 40px; color: var(--dim); }
.snap-row { display: grid; grid-template-columns: 1.2fr 1fr; gap: 20px; padding: 10px 0; border-bottom: 1px dotted var(--line); }
.snap-row:last-child { border-bottom: none; }
.snap-val { font-family: 'JetBrains Mono', monospace; text-align: right; }

.subgrid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px;
  padding: 20px 24px; background: var(--paper-2); border-top: 1px solid var(--line-soft);
}
.subgrid .dim { font-size: 12px; text-transform: uppercase; letter-spacing: .1em; color: var(--dim); font-weight: 600; }
.subgrid .big { font-family: 'Fraunces', serif; font-weight: 700; font-size: 23px; margin-top: 4px; }

/* ----------- Empty state ----------- */
.empty { padding: 60px 20px; text-align: center; color: var(--dim); }
.empty-ico { font-size: 41px; color: var(--line); margin-bottom: 12px; }
.empty h3 { font-family: 'Fraunces', serif; font-size: 25px; color: var(--ink); margin-bottom: 6px; }
.empty p { margin-bottom: 16px; }

/* ===============================================================
   LOGIN PAGE
=============================================================== */
.auth-body { background: var(--ink); }
.auth-wrap {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  min-height: var(--page-h, 100vh);
}

.auth-art {
  position: relative;
  background: linear-gradient(160deg, var(--ink) 0%, #071121 100%);
  color: #fff;
  overflow: hidden;
  padding: 60px;
  display: flex; flex-direction: column; justify-content: space-between;
}
.art-grid {
  position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.04) 1px, transparent 1px);
  background-size: 40px 40px;
  mask-image: linear-gradient(160deg, rgba(0,0,0,0.8), rgba(0,0,0,0));
}
.art-blob {
  position: absolute;
  width: 520px; height: 520px;
  right: -140px; top: 20%;
  background: radial-gradient(circle at center, rgba(217,119,6,.35), transparent 60%);
  filter: blur(40px);
  animation: float 12s ease-in-out infinite alternate;
}
@keyframes float {
  from { transform: translateY(0) scale(1); }
  to   { transform: translateY(-30px) scale(1.05); }
}
.art-label { position: relative; z-index: 2; }
.art-num {
  font-family: 'Fraunces', serif;
  font-weight: 900; font-size: 120px;
  color: var(--amber);
  line-height: 1;
  letter-spacing: -.05em;
  margin-bottom: 20px;
}
.art-txt {
  font-family: 'Fraunces', serif;
  font-size: 33px; font-weight: 500;
  max-width: 480px; line-height: 1.2;
  letter-spacing: -.01em;
}
.art-ticker {
  position: relative; z-index: 2;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: #A8A293;
  border-top: 1px solid rgba(255,255,255,.12);
  padding-top: 16px;
  letter-spacing: .1em;
}

.auth-card {
  background: var(--paper);
  display: flex; flex-direction: column; justify-content: center;
  padding: 80px 60px;
}
.auth-logo {
  margin-bottom: 16px;
}
.navneet-logo {
  height: 64px;
  width: auto;
  display: block;
}
.auth-module-title {
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--graphite);
  margin-bottom: 20px;
}
.auth-title { font-family: 'Fraunces', serif; font-size: 27px; font-weight: 900; letter-spacing: -.02em; margin-bottom: 6px; }
.auth-sub { color: var(--graphite); margin-bottom: 28px; font-size: 16px; }

.auth-form { max-width: 420px; }
.auth-error {
  background: #FEE2E2; border-left: 3px solid var(--red);
  color: #7F1D1D; padding: 12px 16px; margin-bottom: 18px;
  border-radius: var(--radius); font-size: 14px;
}
.auth-redirect-hint {
  background: #FEF7E1; border-left: 3px solid var(--amber);
  color: #92400E; padding: 12px 16px; margin-bottom: 18px;
  border-radius: var(--radius); font-size: 14px;
}
.auth-redirect-hint strong { word-break: break-all; }
.auth-hint { margin-top: 24px; font-size: 13px; color: var(--dim); padding: 12px 14px; background: var(--paper-2); border-radius: var(--radius); border-left: 2px solid var(--amber); font-family: 'JetBrains Mono', monospace; }

/* ===============================================================
   ERROR PAGE
=============================================================== */
.err-wrap { min-height: var(--page-h, 100vh); display: grid; place-items: center; background: var(--paper); }
.err-code { font-family: 'Fraunces', serif; font-size: 180px; font-weight: 900; color: var(--amber); line-height: 1; letter-spacing: -.04em; }
.err-msg { font-family: 'Fraunces', serif; font-size: 33px; margin: 10px 0 30px; }

/* ----------- Responsive ----------- */
/* Responsive breakpoints disabled — layout fixed at 1920px */

/* ----------- Print ----------- */
@media print {
  .sidebar, .tabs, .head-actions, .btn { display: none !important; }
  .shell { grid-template-columns: 1fr; }
  .main { padding: 0; }
  .panel { border: 1px solid #000; break-inside: avoid; }
}

/* ===============================================================
   DYNAMIC PARTS & ENTRIES (Tab 2 redesign)
=============================================================== */
.parts-banner {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--line);
  border-bottom: 1px solid var(--line);
}
.parts-banner > div {
  background: var(--paper-2);
  padding: 14px 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.pb-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .14em;
  color: var(--dim);
  font-weight: 600;
}
.pb-val {
  font-family: 'Fraunces', serif;
  font-weight: 700;
  font-size: 23px;
  color: var(--ink);
  letter-spacing: -.01em;
}

.parts-max-tag {
  display: inline-block;
  margin-top: 6px;
  font-size: 16px;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  letter-spacing: .04em;
  padding: 6px 14px;
}

.parts-container {
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.parts-foot {
  padding: 0 24px 22px;
  border-top: 1px solid var(--line-soft);
  padding-top: 18px;
}

.part-card {
  border: 1px solid var(--line);
  border-left: 4px solid var(--amber);
  border-radius: var(--radius);
  background: #fff;
  overflow: hidden;
}
.part-head {
  padding: 16px 20px;
  background: var(--paper-2);
  border-bottom: 1px solid var(--line-soft);
  display: grid;
  grid-template-columns: 1fr 160px auto auto;
  gap: 12px 16px;
  align-items: center;
}
.part-name-field { display: flex; flex-direction: column; gap: 4px; }
.part-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .14em;
  color: var(--dim);
  font-weight: 600;
}
.part-name-field input {
  border: none;
  background: transparent !important;
  font-family: 'Fraunces', serif;
  font-size: 23px;
  font-weight: 700;
  color: #0B2161 !important;
  letter-spacing: -.01em;
  padding: 2px 0;
  border-bottom: 1px solid transparent;
  cursor: default;
}
.part-name-field input:focus {
  outline: none;
  border-bottom-color: var(--amber);
}
.part-meta { display: flex; gap: 8px; flex-wrap: wrap; }

.entries {
  padding: 8px 20px 4px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.entry {
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--paper-2);
  overflow: hidden;
}
.entry-head {
  padding: 10px 16px;
  background: #fff;
  border-bottom: 1px solid var(--line-soft);
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
}
.entry-badge {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
  background: var(--ink);
  color: #fff;
  border-radius: 2px;
  letter-spacing: .06em;
}
.entry-badge .entry-num { color: var(--amber); }
.entry-status { display: flex; gap: 6px; flex-wrap: wrap; }
.entry-remove {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--red);
  font-weight: 700;
  width: 26px;
  height: 26px;
  border-radius: 2px;
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  transition: all .12s ease;
}
.entry-remove:hover { background: var(--red); color: #fff; border-color: var(--red); }

.entry-grid {
  padding: 10px 14px;
  background: #fff;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 6px 10px;
}
.entry-grid .field { margin-bottom: 0; }
.entry-grid .field > span {
  font-size: 8.5px;
  letter-spacing: .06em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
  max-width: 100%;
}
.entry-grid .field input,
.entry-grid .field select {
  padding: 4px 7px;
  font-size: 13px;
}
.entry-remark { grid-column: 1 / -1; }

.entry-foot {
  padding: 10px 20px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.entry-hint {
  font-size: 13px;
  color: var(--dim);
  font-style: italic;
}
.hint-good { color: var(--green); font-weight: 600; font-style: normal; }
.hint-warn { color: var(--amber-dk); font-weight: 600; font-style: normal; }

/* --- Chips (status pills) --- */
.chip {
  display: inline-flex;
  align-items: center;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  padding: 4px 10px;
  background: var(--line-soft);
  color: var(--graphite);
  border-radius: 999px;
  font-weight: 500;
  letter-spacing: .02em;
  white-space: nowrap;
}
.chip-info { background: #DBEAFE; color: #1E3A8A; }
.chip-good { background: #D1FAE5; color: var(--green); }
.chip-warn { background: #FEF3C7; color: var(--amber-dk); }
.chip-max  { background: #E0F2FE; color: #0369A1; font-weight: 700; }

/* --- Snap accordion (collapsible section) --- */
.snap-accordion { margin: 24px 0 12px; }
.snap-accordion-toggle {
  display: flex; align-items: center; gap: 10px;
  background: none; border: none; cursor: pointer;
  padding: 0; width: 100%; text-align: left;
  border-bottom: 2px solid var(--line);
  padding-bottom: 8px;
}
.snap-accordion-toggle:hover .snap-accordion-icon { background: var(--ink); color: #fff; }
.snap-accordion-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; border-radius: 50%;
  border: 2px solid var(--ink); font-size: 16px; font-weight: 700;
  color: var(--ink); flex-shrink: 0; line-height: 1;
  transition: transform .2s ease, background .15s ease;
}
.snap-accordion-body { display: none; padding-top: 12px; }
.snap-accordion.open .snap-accordion-body { display: block; }
.snap-accordion.open .snap-accordion-icon { transform: rotate(45deg); }

/* --- Output snapshot, parts breakdown --- */
.snap-part {
  border: 1px solid var(--line-soft);
  border-left: 3px solid var(--amber);
  border-radius: var(--radius);
  margin-bottom: 12px;
  background: var(--paper-2);
  overflow: hidden;
}
.snap-part-head {
  padding: 10px 16px;
  background: #fff;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--line-soft);
  font-size: 14px;
}
.snap-part-entries {
  padding: 8px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.snap-entry {
  display: grid;
  grid-template-columns: 40px 1fr auto auto;
  gap: 10px;
  padding: 4px 0;
  font-size: 13px;
  color: var(--graphite);
}
.snap-entry span:first-child {
  font-weight: 700;
  color: var(--amber-dk);
}

/* @media (max-width: 820px) disabled — fixed 1920px layout */

/* ===============================================================
   V3 ADDITIONS — colour hints, split grid, review card, etc.
=============================================================== */
.field-hint {
  display: block;
  margin-top: 4px;
  color: var(--dim);
  font-size: 12px;
  letter-spacing: .02em;
  font-style: italic;
}

.field.full { grid-column: 1 / -1; }

.stack-inline { display: flex; gap: 8px; align-items: center; }
.stack-inline input, .stack-inline select { flex: 1; }
.span-pick { max-width: 180px; }

/* RFQ tab — 4-column content-sized grid */
.rfq-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px 12px;
  padding: 12px 20px;
}
.rfq-grid .field.full { grid-column: 1 / -1; }
.rfq-grid .span2 { grid-column: span 2; }
.rfq-grid .span3 { grid-column: span 3; }
.rfq-grid-5 { grid-template-columns: repeat(5, 1fr); }
.rfq-grid-6 { grid-template-columns: repeat(6, 1fr); }

/* Compact field sizing for RFQ tab */
#t-rfq .field input, #t-rfq .field select, #t-rfq .field textarea {
  padding: 5px 8px;
  font-size: 14px;
}
#t-rfq .field > span {
  font-size: 11px;
  margin-bottom: 3px;
}
#t-rfq .field { margin-bottom: 8px; }

/* Cap number inputs at a sensible width so they don't stretch */
#t-rfq input[type="number"] { max-width: 130px; }

/* Fixed-width dropdowns sized to ~2 inches */
#f_rfq_input_purpose,
#f_mould_design_years { max-width: 192px; }


/* Field-specific width caps */
#f_material { max-width: 120px; }

/* RFQ No. badge in panel header */
.rfq-no-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--graphite);
  white-space: nowrap;
}
.rfq-no-input {
  width: 100px;
  padding: 2px 5px !important;
  font-size: 12px !important;
  background: var(--surface, #f8f7f4);
}
#f_net_weight_g           { max-width: 100px; }
#f_no_of_colours          { max-width:  80px; }
#f_samples_required,
#f_primary_pack_pcs,
#f_inner_pack_pcs,
#f_master_pack_pcs        { max-width: 110px; }

/* "Over a Year" static label beside total qty */
.field-side-label {
  white-space: nowrap;
  font-size: 12px;
  font-weight: 600;
  color: var(--graphite);
  text-transform: uppercase;
  letter-spacing: .06em;
}

/* Full-width bottom fields (textareas, plant instruction) */
.rfq-full-fields {
  padding: 0 20px 10px;
}
.rfq-full-fields .field { margin-bottom: 10px; }

/* Inline hyperlink row */
.rfq-hyperlink-row { padding-bottom: 4px; }
.rfq-inline-field {
  display: flex; align-items: center; gap: 10px;
}
.rfq-inline-label {
  white-space: nowrap;
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .1em;
  color: var(--graphite); flex-shrink: 0;
}

/* Maybe feedback panel in RFQ tab */
.maybe-feedback-panel {
  border: 2px solid #D97706;
  border-radius: var(--radius);
  margin: 0 20px 16px;
  background: #FFFBEB;
  overflow: hidden;
}
.maybe-feedback-head {
  background: #FEF3C7;
  border-bottom: 1px solid #FCD34D;
  padding: 10px 16px;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.maybe-badge {
  font-size: 13px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .08em; color: #B45309;
}
.maybe-badge.resubmitted { color: #1a7a3c; }
.maybe-feedback-hint { font-size: 13px; color: #92400E; }
.resubmit-done-chip {
  padding: 6px 0; color: #1a7a3c; font-weight: 600; font-size: 14px;
}
/* Maybe-cycle history accordion */
#maybe-cycle-history { border-bottom: 1px dashed #FCD34D; margin-bottom: 0; }
.maybe-history-toggle {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 18px; cursor: pointer; font-size: 13px; font-weight: 600;
  color: #92400E; background: #FEF9EC; user-select: none;
}
.maybe-history-toggle:hover { background: #FEF3C7; }
.mht-icon { font-size: 17px; font-weight: 700; color: #B45309; }
.maybe-history-list { background: #FFFBF0; padding: 0 18px 8px; }
.mh-card {
  border: 1px solid #FCD34D; border-radius: 6px;
  margin: 8px 0; overflow: hidden;
}
.mh-card-head {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  background: #FEF3C7; padding: 6px 12px;
  font-size: 12px;
}
.mh-cycle-no { font-weight: 700; color: #B45309; text-transform: uppercase; letter-spacing: .08em; }
.mh-dates { color: #92400E; }
.mh-card-body { padding: 8px 12px; display: grid; grid-template-columns: 1fr 1fr; gap: 4px 16px; }
.mh-row { display: contents; }
.mh-lbl { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--graphite); padding: 2px 0; }
.mh-val { font-size: 13px; color: var(--ink); padding: 2px 0; white-space: pre-wrap; word-break: break-word; }
.mh-card-body .mh-row:last-child .mh-lbl,
.mh-card-body .mh-row:last-child .mh-val { grid-column: 1 / -1; }
.field-label-sm {
  display: block; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .1em;
  color: var(--graphite); margin-bottom: 4px;
}
.fb-comment-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 4px;
}
.fb-no-action-label {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; font-weight: 600; color: #15803D;
  cursor: pointer; text-transform: uppercase; letter-spacing: .06em;
}
.fb-no-action-label input[type="checkbox"] { accent-color: #15803D; width: 14px; height: 14px; }

.feedback-val {
  font-size: 14px; color: #555;
  background: #F3F4F6; border: 1px solid #D1D5DB;
  border-radius: var(--radius); padding: 6px 10px;
  min-height: 30px; font-style: italic;
}

/* Auto-computed plant instruction lines */
.plant-auto-lines {
  background: var(--surface, #f8f7f4);
  border: 1px solid var(--line);
  border-bottom: none;
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 7px 10px 6px;
}
.auto-line {
  font-size: 13px;
  color: var(--ink);
  font-family: 'JetBrains Mono', monospace;
  line-height: 1.6;
}
.auto-line:empty { display: none; }
.plant-auto-lines + textarea {
  border-radius: 0 0 var(--radius) var(--radius);
  border-top: 1px dashed var(--line);
}

.panel-subhead {
  padding: 16px 24px 4px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
}
.panel-subhead h3 {
  font-family: 'Fraunces', serif;
  font-size: 19px;
  color: var(--ink);
  letter-spacing: -.01em;
}

.split-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  padding: 10px 24px 4px;
}
.split-cell {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  background: #fff;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.split-label { display: flex; flex-direction: column; gap: 2px; }
.split-period {
  font-family: 'Fraunces', serif;
  font-weight: 700;
  font-size: 15px;
  color: var(--ink);
}
.split-days {
  font-size: 11px;
  color: var(--dim);
  letter-spacing: .06em;
}
.split-cell .split-in {
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px;
}
.split-cell .split-in:focus {
  outline: none;
  border-color: var(--amber);
  box-shadow: 0 0 0 3px rgba(217,119,6,.15);
}

.split-qd-row {
  font-size: 12px;
  color: var(--dim);
  border-top: 1px solid var(--line-soft);
  padding-top: 6px;
  margin-top: 2px;
}
.split-qd-row .split-qd-val {
  color: var(--ink);
  font-weight: 600;
  font-size: 13px;
}

.split-total-row {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  padding: 10px 24px 4px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .14em;
  color: var(--graphite);
  font-weight: 600;
}
.split-max-row {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  padding: 4px 24px 20px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .14em;
  color: var(--graphite);
  font-weight: 600;
}

.input-disabled {
  background: var(--line-soft) !important;
  color: var(--dim) !important;
  cursor: not-allowed;
}

/* --- Mould review card on Parts tab --- */
.review-card { border-left: 4px solid var(--ink); }
.review-card .panel-head { padding: 8px 16px; }
.review-card .panel-head h2 { font-size: 15px; }
.review-body { padding: 0; }
.review-body .tbl { margin: 0; }
.review-body .tbl th, .review-body .tbl td {
  padding: 5px 12px;
  font-size: 12px;
}
.review-sub {
  padding: 6px 16px 8px;
  font-size: 12px;
  color: var(--graphite);
  background: var(--paper-2);
  border-top: 1px solid var(--line-soft);
}
.review-sub b { color: var(--ink); font-family: 'JetBrains Mono', monospace; }

/* --- Material block — grand row styling --- */
.mold-grand-row {
  background: var(--amber-bg);
  font-weight: 700;
}
.mold-grand-row td {
  padding: 5px 10px;
  font-size: 13px;
}
.mold-head h3 {
  font-size: 15px;
}
.mold-title::before {
  content: '●';
  color: var(--amber);
  margin-right: 8px;
}

/* ===============================================================
   VIEW-ONLY MODE (for users without edit permission on a tab)
=============================================================== */
.tab-panel.view-only input:not([type=checkbox]):not([type=radio]),
.tab-panel.view-only select,
.tab-panel.view-only textarea {
  background: var(--line-soft) !important;
  color: var(--graphite) !important;
  cursor: not-allowed;
}
.tab-panel.view-only input[readonly]:focus,
.tab-panel.view-only textarea[readonly]:focus {
  border-color: var(--line);
  box-shadow: none;
  outline: none;
}
.view-only-banner {
  margin: 0 0 16px;
  padding: 12px 18px;
  background: var(--amber-bg);
  border-left: 3px solid var(--amber);
  color: var(--amber-dk);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: .02em;
  border-radius: var(--radius);
}

/* ===============================================================
   ADMIN — USERS & PERMISSIONS PAGE
=============================================================== */
.users-tbl {
  font-size: 14px;
}
.users-tbl th, .users-tbl td {
  padding: 10px 12px;
  vertical-align: middle;
}
.users-tbl .c { text-align: center; }
.users-tbl .tab-col {
  text-align: center;
  border-left: 1px dashed var(--line);
  min-width: 130px;
}
.users-tbl .tab-hdr {
  font-weight: 700;
  font-size: 12px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink);
  padding-bottom: 2px;
}
.users-tbl .tab-sub {
  display: flex;
  gap: 10px;
  justify-content: center;
  font-size: 11px;
  color: var(--dim);
  font-weight: 500;
  letter-spacing: .06em;
}
.users-tbl .tab-sub span { flex: 1; }

.row-admin {
  background: linear-gradient(to right, rgba(217,119,6,.06), transparent 40%);
}
.row-admin::before { content: ''; }
.row-admin td:first-child {
  border-left: 3px solid var(--amber);
}

.u-emp {
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px;
  color: var(--ink);
}
.u-name-in {
  width: 100%;
  margin-top: 2px;
  border: 1px solid transparent;
  background: transparent;
  padding: 4px 6px;
  font-family: inherit;
  font-size: 13px;
  color: var(--graphite);
  border-radius: 2px;
}
.u-name-in:focus {
  border-color: var(--amber);
  background: #fff;
  outline: none;
}

.users-tbl select[data-f="role"] {
  width: 90px;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 13px;
  background: #fff;
}

.perm-pair {
  display: flex;
  justify-content: center;
  gap: 10px;
  align-items: center;
}
.perm-pair .cb {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 11px;
  letter-spacing: .08em;
  color: var(--dim);
  text-transform: uppercase;
  cursor: pointer;
  user-select: none;
}
.perm-pair .cb input {
  width: 16px;
  height: 16px;
  accent-color: var(--amber);
  cursor: pointer;
}
.perm-pair .cb input:disabled {
  opacity: .7;
  cursor: not-allowed;
}

/* --- Small iOS-style toggle --- */
.toggle-sm {
  position: relative;
  display: inline-block;
  width: 34px;
  height: 18px;
  cursor: pointer;
}
.toggle-sm input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}
.toggle-sm span {
  position: absolute;
  inset: 0;
  background: var(--line);
  border-radius: 999px;
  transition: background .18s ease;
}
.toggle-sm span::before {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  transition: transform .18s ease;
  box-shadow: 0 1px 2px rgba(0,0,0,.2);
}
.toggle-sm input:checked + span { background: var(--amber); }
.toggle-sm input:checked + span::before { transform: translateX(16px); }
.toggle-sm input:disabled + span { opacity: .5; cursor: not-allowed; }

.u-actions { white-space: nowrap; }
.u-actions .btn { margin-left: 4px; }

/* ===============================================================
   MODAL (for add-user / password reset)
=============================================================== */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity .15s ease;
}
.modal[aria-hidden="false"] {
  pointer-events: auto;
  opacity: 1;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 27, 45, 0.5);
  backdrop-filter: blur(2px);
}
.modal-box {
  position: relative;
  background: var(--paper);
  border: 1px solid var(--ink);
  border-radius: var(--radius);
  width: min(520px, 92vw);
  box-shadow: 0 20px 60px rgba(15,27,45,.25);
  transform: translateY(-10px);
  transition: transform .18s ease;
}
.modal[aria-hidden="false"] .modal-box {
  transform: translateY(0);
}
.modal-sm { width: min(400px, 92vw); }
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 24px;
  border-bottom: 1px solid var(--line);
  background: var(--ink);
  color: #fff;
  border-radius: var(--radius) var(--radius) 0 0;
}
.modal-head h2 {
  font-family: 'Fraunces', serif;
  font-size: 21px;
  color: #fff;
}
.modal-close {
  background: transparent;
  border: none;
  color: #A8A293;
  font-size: 17px;
  cursor: pointer;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  transition: all .12s ease;
}
.modal-close:hover {
  background: rgba(255,255,255,.1);
  color: #fff;
}
.modal-body {
  padding: 22px 24px;
  max-height: 60vh;
  overflow-y: auto;
}
.modal-body .field { margin-bottom: 14px; }
.modal-body .field:last-child { margin-bottom: 0; }
.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 24px;
  border-top: 1px solid var(--line);
  background: var(--paper-2);
  border-radius: 0 0 var(--radius) var(--radius);
}

/* @media (max-width: 1200px) disabled — fixed 1920px layout */

/* ===============================================================
   FEASIBILITY LOCK BANNER
=============================================================== */
.feas-lock-banner {
  margin: 0 0 16px;
  padding: 14px 18px;
  background: #FEE2E2;
  border-left: 4px solid var(--red);
  color: #7F1D1D;
  font-size: 14px;
  border-radius: var(--radius);
  letter-spacing: .02em;
}
.feas-lock-banner strong { color: var(--red); }
.tab-panel.feas-locked .panel { opacity: .72; }
.tab-panel.feas-locked .feas-lock-banner { opacity: 1; }

/* ===============================================================
   TOGGLE ROW (used in Admin → Email page)
=============================================================== */
.toggle-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  cursor: pointer;
}
.toggle-row .toggle-lbl {
  font-size: 14px;
  color: var(--ink);
}
.toggle-row .toggle-lbl small {
  color: var(--dim);
  font-weight: 400;
}

/* ===============================================================
   SAMPLING TAB
=============================================================== */
.sampling-tbl td:first-child {
  background: var(--paper-2);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--graphite);
  vertical-align: top;
  padding-top: 14px;
}
.sampling-tbl td input,
.sampling-tbl td textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 14px;
  background: #fff;
}
.sampling-tbl td textarea { resize: vertical; min-height: 42px; }

/* ===============================================================
   EMAIL ADMIN — schedule table
=============================================================== */
.sched-tbl td { vertical-align: top; }
.sched-tbl .mono { font-size: 12px; }

/* ===============================================================
   SUBMIT ROW (RFQ submit / Plant cost submit)
=============================================================== */
.submit-row {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 28px;
  padding: 18px 20px;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-left: 3px solid var(--amber);
  border-radius: var(--radius);
}
.submit-status {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.submit-label {
  font-size: 11px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--dim);
  font-weight: 700;
}
.submit-help {
  flex: 1;
  font-size: 13px;
  color: var(--graphite);
  font-style: italic;
  min-width: 220px;
}

/* Plant tab note */
.plant-note {
  margin-top: 22px;
  padding: 14px 18px;
  background: var(--amber-bg);
  border-left: 3px solid var(--amber);
  color: var(--amber-dk);
  font-size: 14px;
  border-radius: var(--radius);
}
.plant-note strong { color: var(--ink); }

/* Read-only mirrored values */
.readonly-val {
  padding: 9px 12px;
  background: var(--line-soft);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  font-size: 15px;
  color: var(--graphite);
  min-height: 40px;
  display: flex;
  align-items: center;
}
/* Multi-line variant (div elements with pre-wrap text) */
div.readonly-val {
  align-items: flex-start;
  white-space: pre-wrap;
  line-height: 1.5;
}

/* Feasibility dependent fields greyed when answer ≠ No */
.input-disabled {
  opacity: .55;
  cursor: not-allowed;
  background: var(--line-soft) !important;
}

/* ===============================================================
   PART HEAD (name + net wt side-by-side)
=============================================================== */
/* 2-Shot group colour dot */
.two-shot-dot {
  display: inline-block;
  width: 11px; height: 11px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 0 2px #fff, 0 0 0 3px currentColor;
  cursor: default;
}
.part-head .two-shot-dot {
  width: 13px; height: 13px;
  align-self: center;
  margin-right: 2px;
}
#pmd-tbody td:first-child { position: relative; padding-left: 28px; }
#pmd-tbody td .two-shot-dot {
  width: 9px; height: 9px;
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
}
#pmd-tbody input.pmd-name { width: 100%; }
.part-name-field input { font-weight: 700; }
/* 2-Shot group picker — sits in its own Group column */
.pmd-group-picker {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.pmd-group-swatch {
  display: inline-block;
  width: 18px; height: 18px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform .12s;
  flex-shrink: 0;
}
.pmd-group-swatch:hover { transform: scale(1.25); }

/* 2-Shot group header banner (top of each grouped part card) */
.two-shot-group-banner {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 14px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .04em;
  border-radius: 0;
}
.two-shot-group-banner .two-shot-dot {
  width: 9px; height: 9px;
  box-shadow: none;
  flex-shrink: 0;
}
.tsg-part-role {
  margin-left: auto;
  font-size: 11px;
  font-weight: 500;
  opacity: .85;
}

.part-head {
  display: grid;
  grid-template-columns: 1fr 160px auto auto;
  gap: 12px 16px;
  align-items: center;
}
.part-name-field {
  min-width: 0;
}
.part-wt-field {
  min-width: 0;
}
.part-wt-field input {
  font-family: 'JetBrains Mono', monospace;
  font-size: 15px;
  width: 100%;
}
.part-meta {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: nowrap;
  white-space: nowrap;
}
.req {
  color: var(--red);
  font-weight: 700;
  margin-left: 3px;
}

/* ===============================================================
   ADMIN — master permissions sub-row
=============================================================== */
tr.row-masters {
  background: var(--paper-2);
  border-bottom: 2px solid var(--line);
}
tr.row-masters td {
  padding: 10px 12px;
  vertical-align: top;
}
.masters-cell-label {
  text-align: right;
  padding-right: 14px !important;
}
.masters-row-label {
  font-size: 11px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--dim);
  font-weight: 700;
  padding-top: 8px;
}
.masters-cell {
  padding-left: 0 !important;
}
.masters-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 12px 18px;
  padding: 6px 12px;
}
.master-col {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 6px 8px;
  border-left: 2px solid var(--line);
}
.master-lbl {
  font-size: 12px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--ink);
  font-weight: 700;
}
tr.row-masters.row-admin .master-col {
  border-left-color: var(--amber);
}

/* ===============================================================
   CAPACITY RANGE INDICATORS (Parts & Mould Plan)
=============================================================== */
.field-hint.cap-ok {
  color: var(--green, #15803D);
  font-weight: 600;
}
.field-hint.cap-warn {
  color: var(--red);
  font-weight: 700;
}
.entry.cap-violation {
  border-left: 3px solid var(--red);
  background: linear-gradient(to right, rgba(220,38,38,.04), transparent 30%);
}

/* ===============================================================
   PLANT INSTRUCTION BANNER (shown above tabs except Final Cost)
=============================================================== */
.plant-instruction-banner {
  margin: 0 0 18px;
  padding: 12px 18px 14px;
  background: #FEF7E1;
  border-left: 4px solid var(--amber);
  border-radius: var(--radius);
}
.plant-instruction-banner .pi-label {
  font-size: 11px;
  letter-spacing: .14em;
  text-transform: uppercase;
  font-weight: 800;
  color: var(--amber-dk, #92400E);
  margin-bottom: 4px;
}
.plant-instruction-banner .pi-text {
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  white-space: pre-wrap;
}
.plant-instruction-banner .pi-comment-line {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px dashed #D97706;
  font-size: 13px;
  color: #92400E;
  white-space: pre-wrap;
}

/* ===============================================================
   TAB COMPLETION ICONS  (rendered in <span class="tab-status">)
=============================================================== */
.tab-status {
  display: inline-block;
  margin-left: 6px;
  font-weight: 800;
  font-size: 14px;
  line-height: 1;
  vertical-align: middle;
}
.tab-status.status-complete { color: #15803D; }
.tab-status.status-partial  { color: #B45309; animation: statusPulse 1.6s ease-in-out infinite; cursor: pointer; }
.tab-status.status-error    { color: #B91C1C; animation: statusPulse 1.0s ease-in-out infinite; cursor: pointer; }
.tab-status.status-blank    { display: none; }
.tab-status.status-draft    { color: #B45309; font-style: italic; }

/* ===============================================================
   DRAFT MODE BAR (Parts & Moulds / Product Material tabs)
=============================================================== */
.draft-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 24px;
  background: #FFFBEB;
  border-bottom: 1px solid #FDE68A;
  flex-wrap: wrap;
}
.draft-bar-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}
.draft-bar-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #92400E;
}
.draft-bar-hint {
  font-size: 12px;
  color: #78716C;
  font-style: italic;
}
.draft-bar.is-draft {
  background: #FEF3C7;
  border-bottom-color: #F59E0B;
}
.draft-bar.is-draft .draft-bar-label {
  color: #78350F;
}

@keyframes statusPulse {
  0%, 100% { opacity: 1;   transform: scale(1);    }
  50%       { opacity: 0.4; transform: scale(1.25); }
}

/* Field flash — triggered by JS when navigating to an error */
@keyframes fieldFlash {
  0%        { border-color: var(--line);  box-shadow: none; }
  15%, 45%, 75% { border-color: #DC2626; box-shadow: 0 0 0 4px rgba(220,38,38,.3); }
  30%, 60%  { border-color: #DC2626;     box-shadow: 0 0 0 2px rgba(220,38,38,.15); }
  100%      { border-color: #DC2626;     box-shadow: 0 0 0 3px rgba(220,38,38,.2); }
}
.field-flash {
  animation: fieldFlash 0.55s ease 4 !important;
  border-color: #DC2626 !important;
}

/* ===============================================================
   LOCKED TAB (e.g. Sampling when samples_required = 0)
=============================================================== */
.tab.tab-locked {
  opacity: .42;
  cursor: not-allowed;
  text-decoration: line-through;
  text-decoration-color: rgba(0,0,0,.35);
}
.panel-locked {
  opacity: .55;
  pointer-events: none;
}
.panel-locked::before {
  content: '🔒 Sampling unlocks when "Approx. Samples Required" > 0 on the RFQ tab';
  display: block;
  background: var(--paper-2);
  border-left: 3px solid var(--amber);
  padding: 10px 14px;
  margin: 0 0 14px;
  font-size: 13px;
  color: var(--amber-dk, #92400E);
  font-weight: 700;
  border-radius: var(--radius);
  pointer-events: auto;
}

/* ===============================================================
   VERSION HISTORY (dashboard tree)
=============================================================== */
.btn-ver-toggle {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1px 7px;
  margin-left: 6px;
  font-size: 12px;
  font-family: 'JetBrains Mono', monospace;
  color: var(--dim);
  cursor: pointer;
}
.btn-ver-toggle:hover { color: var(--amber); border-color: var(--amber); }
tr.version-row td {
  background: var(--paper-2);
  padding: 0 14px 14px;
}
.version-tree {
  padding: 10px 0 4px 18px;
  border-left: 2px solid var(--line);
  margin-left: 8px;
}
.version-tree-label {
  font-size: 11px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--dim);
  font-weight: 800;
  margin-bottom: 8px;
}
.version-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.version-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 0;
  border-bottom: 1px dashed var(--line-soft);
  font-size: 14px;
}
.version-item:last-child { border-bottom: none; }
.version-marker { color: var(--amber); font-size: 17px; line-height: 1; }
.version-label { font-weight: 700; color: var(--ink); }
.version-meta { color: var(--dim); font-size: 13px; }
.version-by   { color: var(--dim); font-size: 13px; font-style: italic; }
.btn.btn-xs {
  padding: 2px 8px;
  font-size: 12px;
}
.version-restore { margin-left: auto; }

/* ===============================================================
   USER FILTER BAR (admin/users page)
=============================================================== */
/* Advanced search bar */
.adv-search-bar {
  padding: 12px 16px 10px;
  border-bottom: 1px solid var(--line);
  background: var(--paper-2);
}
.adv-search-fields {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px 12px;
  margin-bottom: 8px;
}
.adv-field {
  display: flex; flex-direction: column; gap: 3px;
}
.adv-field > span {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .12em; color: var(--graphite);
}
.adv-field input, .adv-field select {
  padding: 5px 8px; font-size: 14px; font-family: inherit;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: #fff; color: var(--ink);
}
.adv-search-foot {
  display: flex; align-items: center; gap: 12px;
}

/* Status chip in RFQ table */
.status-chip {
  display: inline-block; padding: 2px 8px;
  border-radius: 10px; font-size: 12px; font-weight: 700;
  letter-spacing: .06em; text-transform: uppercase;
}
.status-chip.status-draft    { background: #F3F4F6; color: #6B7280; }
.status-chip.status-open     { background: #DBEAFE; color: #1D4ED8; }
.status-chip.status-complete { background: #DCFCE7; color: #15803D; }
.status-chip.status-maybe    { background: #FEF3C7; color: #B45309; }

.user-filter-bar {
  display: flex;
  gap: 14px;
  align-items: flex-end;
  padding: 14px;
  border-bottom: 1px solid var(--line);
  background: var(--paper-2);
  flex-wrap: wrap;
}
.user-filter-field { flex: 1; min-width: 280px; display: flex; flex-direction: column; gap: 4px; }
.user-filter-field label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--dim);
}
.user-filter-field input[type="search"] {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 4px;
  font-family: inherit;
  font-size: 14px;
}
.user-filter-quick { display: flex; gap: 6px; flex-wrap: wrap; }
.user-filter-count {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--dim);
  align-self: center;
}

/* ===============================================================
   RFQ submitted lock banner
=============================================================== */
.submitted-lock-banner {
  background: #FEE2E2;
  border-left: 4px solid #DC2626;
  color: #7F1D1D;
  padding: 14px 18px;
  margin: 0 0 18px;
  border-radius: var(--radius);
  font-size: 14px;
}
.submitted-lock-banner strong { color: #B91C1C; font-weight: 800; }
.submitted-lock-banner .mono { color: #7F1D1D; }

/* ===============================================================
   PRODUCT MATERIAL — hide Row Cost column entirely
=============================================================== */
table.hide-row-cost .col-row-cost { display: none; }

/* Polymer warning row text */
.poly-warning-cell {
  background: #FEF2F2;
  color: #991B1B;
  border-top: 2px solid #DC2626;
  border-bottom: 2px solid #DC2626;
  padding: 12px 14px !important;
}
.poly-warning-cell strong { color: #B91C1C; }
.poly-warning-detail { margin-left: 8px; color: #B91C1C; font-weight: 600; }
.poly-warning-sub {
  font-size: 12px;
  color: #B45309;
  margin-top: 4px;
  font-weight: 500;
}

/* ===============================================================
   FINAL COST TAB — Maybe banner
=============================================================== */
.maybe-banner {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 14px 18px;
  margin: 0 0 18px;
  background: #FEF7E1;
  border-left: 4px solid #D97706;
  border-radius: var(--radius);
}
.maybe-banner .maybe-icon {
  font-size: 23px;
  line-height: 1;
  flex-shrink: 0;
  color: #D97706;
}
.maybe-banner strong {
  color: #92400E;
  font-size: 14px;
  display: block;
}
.maybe-banner .maybe-detail {
  font-size: 13px;
  color: #78350F;
  margin-top: 4px;
  line-height: 1.5;
}

/* ===============================================================
   MASTERS EDIT — single common save button at top
=============================================================== */
.masters-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 14px;
  position: sticky;
  top: 0;
  z-index: 5;
}
.masters-toolbar .stretch { flex: 1; }
.masters-toolbar .dirty-count {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  color: var(--amber-dk, #92400E);
  font-weight: 700;
}
.masters-toolbar .dirty-count.zero { color: var(--dim); font-weight: 400; }

tr.row-pending { background: rgba(217,119,6,0.06); }
tr.row-marked-delete { background: rgba(220,38,38,0.08); text-decoration: line-through; }
tr.row-saved-flash { animation: flash-saved .8s ease-out; }
@keyframes flash-saved {
  0%   { background: rgba(21,128,61,0.20); }
  100% { background: transparent; }
}

/* ===============================================================
   BULK EXPORT — Field picker layout
=============================================================== */
.exp-grid {
  display: grid;
  grid-template-columns: 1fr 1.5fr;
  gap: 18px;
  align-items: flex-start;
}
/* @media (max-width: 1100px) disabled — fixed 1920px layout */
.export-fields {
  padding: 18px 22px 22px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.field-group {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}
.field-group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--paper-2);
  border-bottom: 1px solid var(--line);
  border-radius: var(--radius) var(--radius) 0 0;
}
.field-group-head .cb-bold span {
  font-weight: 700;
  font-size: 14px;
  color: var(--ink);
  text-transform: none;
  letter-spacing: 0;
}
.field-group-count {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--dim);
}
.field-group-body {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 6px 14px;
  padding: 12px 14px;
}
.field-group-body .cb {
  flex-direction: row;
  text-transform: none;
  letter-spacing: 0;
  font-size: 13px;
  color: var(--graphite);
}
.field-group-body .cb input { margin-right: 6px; }

.export-actions {
  margin-top: 22px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.export-status {
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px;
  color: var(--dim);
}
.export-status.ok { color: var(--green, #15803D); font-weight: 600; }
.export-status.err { color: var(--red); font-weight: 700; }
