@import url('https://fonts.googleapis.com/css2?family=Barlow:wght@300;400;500;600;700;800&family=Barlow+Condensed:wght@600;700&family=JetBrains+Mono:wght@400;600&display=swap');

/* ── RESET & ROOT ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:         #0d1117;
  --surface:    #161b22;
  --card:       #21262d;
  --border:     #30363d;
  --border2:    #21262d;
  --blue:       #58a6ff;
  --blue-dim:   #1f6feb;
  --green:      #3fb950;
  --orange:     #f0883e;
  --red:        #f85149;
  --yellow:     #d29922;
  --text:       #e6edf3;
  --muted:      #8b949e;
  --muted2:     #484f58;
  --font:       'Barlow', sans-serif;
  --mono:       'JetBrains Mono', monospace;
  --cond:       'Barlow Condensed', sans-serif;
  --sidebar-w:  360px;
  --topbar-h:   52px;
  --radius:     8px;
  --radius-lg:  12px;
}

html, body { height: 100%; overflow: hidden; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

/* ── SCROLLBAR ────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted2); }

/* ── TOPBAR ───────────────────────────────────────────────────── */
#topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  gap: 12px;
  position: relative;
  z-index: 100;
  flex-shrink: 0;
}

.topbar-brand {
  font-family: var(--cond);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-brand::before {
  content: '';
  display: block;
  width: 20px;
  height: 20px;
  background: var(--blue);
  clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
  flex-shrink: 0;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 5px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}

.role-tag {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--blue);
  background: rgba(88,166,255,0.12);
  padding: 2px 7px;
  border-radius: 10px;
}

.topbar-btn {
  padding: 6px 14px;
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  border: 1px solid var(--border);
  transition: all 0.15s;
  white-space: nowrap;
  letter-spacing: 0.3px;
}

.btn-admin {
  background: var(--blue-dim);
  border-color: var(--blue);
  color: white;
}
.btn-admin:hover { background: var(--blue); }

.btn-logout {
  background: transparent;
  color: var(--muted);
  border-color: var(--border);
}
.btn-logout:hover { color: var(--text); border-color: var(--muted2); }

/* ── APP BODY ─────────────────────────────────────────────────── */
#app-body {
  display: flex;
  flex: 1;
  overflow: hidden;
  height: calc(100vh - var(--topbar-h));
}

/* ── SIDEBAR ──────────────────────────────────────────────────── */
#sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  padding: 20px 20px 0;
  flex-shrink: 0;
}

.sidebar-title {
  font-family: var(--cond);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.sidebar-body {
  padding: 0 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

/* ── FORM ELEMENTS ────────────────────────────────────────────── */
.field-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  display: block;
  margin: 12px 0 5px;
}

select, input[type="number"] {
  width: 100%;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 9px 12px;
  font-size: 13px;
  font-family: var(--font);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
  appearance: none;
  -webkit-appearance: none;
}

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238b949e' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
}

select:focus, input[type="number"]:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(88,166,255,0.1);
}

.row-2 { display: flex; gap: 8px; }
.row-2 > div { flex: 1; }

/* ── CHECKBOXES ───────────────────────────────────────────────── */
.check-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 6px;
  padding: 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.check-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 4px;
  cursor: pointer;
  border-radius: 5px;
  transition: background 0.1s;
}
.check-item:hover { background: rgba(88,166,255,0.06); }

.check-item input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--blue);
  cursor: pointer;
  flex-shrink: 0;
}

.check-item span {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}

/* ── CALC BUTTON ──────────────────────────────────────────────── */
#generateBtn {
  width: 100%;
  margin-top: 16px;
  padding: 13px;
  background: var(--blue);
  border: none;
  border-radius: var(--radius);
  color: white;
  font-family: var(--cond);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.15s;
  position: relative;
  overflow: hidden;
}

#generateBtn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.1), transparent);
  transform: translateX(-100%);
  transition: transform 0.4s;
}

#generateBtn:hover {
  background: #79b8ff;
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(88,166,255,0.35);
}
#generateBtn:hover::after { transform: translateX(100%); }
#generateBtn:active { transform: translateY(0); }

/* ── PRICE RESULT CARD ────────────────────────────────────────── */
#price-card {
  margin-top: 12px;
  padding: 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: none;
}

#price-card.visible { display: block; }

.price-placeholder {
  text-align: center;
  padding: 16px;
  color: var(--muted2);
  font-size: 12px;
  margin-top: 12px;
}

.price-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  margin-bottom: 4px;
}

.price-value {
  font-family: var(--mono);
  font-size: 32px;
  font-weight: 600;
  color: var(--green);
  line-height: 1.1;
}

.price-meta {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.price-meta-row {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--muted);
}

.price-meta-row span:last-child {
  color: var(--text);
  font-weight: 500;
}

.print-btn {
  width: 100%;
  margin-top: 12px;
  padding: 8px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--muted);
  font-family: var(--font);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.print-btn:hover { border-color: var(--muted2); color: var(--text); }

/* ── MAIN AREA ────────────────────────────────────────────────── */
#main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* ── 3D VIEWER ────────────────────────────────────────────────── */
#viewer-section {
  height: 340px;
  flex-shrink: 0;
  position: relative;
  border-bottom: 1px solid var(--border);
  background: #0a0e13;
}

#container3d {
  width: 100%;
  height: 100%;
  position: relative;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  outline: none;
}

#debug-overlay {
  position: absolute;
  top: 10px;
  right: 12px;
  background: rgba(0,0,0,0.7);
  color: var(--muted);
  font-size: 11px;
  font-family: var(--mono);
  padding: 4px 10px;
  border-radius: 4px;
  pointer-events: none;
  z-index: 10;
}

.viewer-label {
  position: absolute;
  bottom: 12px;
  left: 14px;
  font-family: var(--cond);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--muted2);
  pointer-events: none;
}

/* ── RESULTS SECTION ──────────────────────────────────────────── */
#results-section {
  flex: 1;
  overflow-y: auto;
  padding: 0;
}

.results-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 12px;
  color: var(--muted2);
  padding: 40px;
}

.results-empty-icon {
  font-size: 40px;
  opacity: 0.4;
}

.results-empty-text {
  font-size: 13px;
  text-align: center;
  line-height: 1.6;
}

/* ── RESULTS HEADER ───────────────────────────────────────────── */
.results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.results-title {
  font-family: var(--cond);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--muted);
}

.results-summary {
  display: flex;
  gap: 20px;
  align-items: center;
}

.stat-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}

.stat-chip-label { color: var(--muted); }
.stat-chip-value { font-family: var(--mono); font-weight: 600; color: var(--text); }

/* ── BOM TABLE ────────────────────────────────────────────────── */
.bom-table {
  width: 100%;
  border-collapse: collapse;
}

.bom-table th {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  border-top: none;
  padding: 10px 16px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--muted);
  text-align: left;
  position: sticky;
  top: 53px;
  z-index: 5;
}

.bom-table th.center { text-align: center; }
.bom-table th.right  { text-align: right; }

.bom-row {
  border-bottom: 1px solid var(--border2);
  transition: background 0.1s;
}

.bom-row:hover { background: rgba(88,166,255,0.04); }

.bom-row td {
  padding: 12px 16px;
  vertical-align: top;
  color: var(--text);
  font-size: 13px;
}

.bom-row td.center { text-align: center; }
.bom-row td.right  { text-align: right; }

.bars-count {
  font-family: var(--mono);
  font-size: 22px;
  font-weight: 600;
  color: var(--blue);
  display: block;
  text-align: center;
  line-height: 1;
}

.bars-label {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted2);
  text-align: center;
  display: block;
  margin-top: 3px;
}

.profile-code {
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.profile-name {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.profile-badge {
  display: inline-block;
  margin-top: 5px;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: rgba(88,166,255,0.12);
  color: var(--blue);
  border: 1px solid rgba(88,166,255,0.2);
}

.bar-type-info {
  font-size: 10px;
  color: var(--muted2);
  margin-top: 4px;
  font-family: var(--mono);
}

.length-val {
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  display: block;
  text-align: center;
}

.length-type {
  font-size: 10px;
  color: var(--muted2);
  text-align: center;
  display: block;
  font-family: var(--mono);
}

.waste-val {
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 700;
  display: block;
  text-align: center;
}

.waste-val.good    { color: var(--green); }
.waste-val.warn    { color: var(--yellow); }
.waste-val.bad     { color: var(--red); }

.waste-mm {
  font-size: 10px;
  color: var(--muted2);
  font-family: var(--mono);
  text-align: center;
  display: block;
}

.kg-val {
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  text-align: right;
  display: block;
}

/* ── CUT DETAILS INLINE ───────────────────────────────────────── */
.cut-inline {
  margin-top: 10px;
  padding: 10px;
  background: rgba(0,0,0,0.3);
  border-radius: 6px;
  border: 1px solid var(--border2);
}

.cut-bar-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 0;
  font-size: 11px;
  font-family: var(--mono);
}

.cut-bar-row + .cut-bar-row {
  border-top: 1px solid var(--border2);
  margin-top: 4px;
  padding-top: 8px;
}

.cut-bar-num {
  color: var(--muted);
  min-width: 50px;
  font-weight: 600;
}

.cut-bar-cuts { color: var(--text); flex: 1; }

.cut-bar-waste { color: var(--orange); font-weight: 600; }

.cut-more {
  text-align: center;
  font-size: 10px;
  color: var(--muted2);
  margin-top: 6px;
  font-family: var(--mono);
}

.cut-viz-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  padding: 5px 12px;
  background: transparent;
  border: 1px solid var(--blue-dim);
  border-radius: 5px;
  color: var(--blue);
  font-family: var(--font);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  width: auto;
}
.cut-viz-btn:hover {
  background: rgba(88,166,255,0.1);
  border-color: var(--blue);
  transform: none;
}

/* ── CUT MODAL ────────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 5000;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(4px);
  padding: 20px;
  overflow-y: auto;
}

.modal-overlay.open { display: flex; align-items: flex-start; justify-content: center; }

.modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 860px;
  margin: auto;
  overflow: hidden;
  box-shadow: 0 24px 64px rgba(0,0,0,0.6);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
}

.modal-head-title {
  font-family: var(--cond);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text);
}

.modal-close {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  transition: all 0.15s;
}
.modal-close:hover { color: var(--text); border-color: var(--muted2); }

.modal-body { padding: 20px 24px; max-height: 70vh; overflow-y: auto; }

.modal-profile-info {
  padding: 14px 16px;
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin-bottom: 18px;
}

.modal-profile-code {
  font-family: var(--mono);
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
}

.modal-profile-name {
  font-size: 13px;
  color: var(--muted);
  margin-top: 4px;
}

.modal-profile-stats {
  display: flex;
  gap: 20px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.modal-stat {
  font-size: 12px;
  color: var(--muted);
}
.modal-stat strong { color: var(--text); }

/* Bar diagram */
.bar-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 10px;
}

.bar-card-title {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.bar-diagram {
  height: 44px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 5px;
  display: flex;
  overflow: hidden;
}

.seg-cut {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  border-right: 1px solid rgba(0,0,0,0.4);
  font-size: 9px;
  font-family: var(--mono);
  font-weight: 600;
  color: white;
  background: var(--blue-dim);
  overflow: hidden;
  transition: filter 0.1s;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 0 2px;
}
.seg-cut:hover { filter: brightness(1.25); }

.seg-waste {
  height: 100%;
  background: repeating-linear-gradient(
    45deg, rgba(240,136,62,0.25), rgba(240,136,62,0.25) 4px,
    rgba(240,136,62,0.12) 4px, rgba(240,136,62,0.12) 8px
  );
  border-left: 1px solid rgba(240,136,62,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-family: var(--mono);
  font-weight: 600;
  color: var(--orange);
}

.bar-card-meta {
  margin-top: 8px;
  font-size: 11px;
  font-family: var(--mono);
  color: var(--muted);
}

/* ── LOGIN OVERLAY ────────────────────────────────────────────── */
#login-overlay {
  position: fixed;
  inset: 0;
  z-index: 9000;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

#login-overlay::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 600px 400px at 20% 50%, rgba(31,111,235,0.12) 0%, transparent 70%),
    radial-gradient(ellipse 400px 600px at 80% 50%, rgba(63,185,80,0.07) 0%, transparent 70%);
  pointer-events: none;
}

#login-overlay.hidden { display: none; }

.login-card {
  position: relative;
  z-index: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px 36px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 24px 80px rgba(0,0,0,0.5);
  animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popIn {
  from { transform: scale(0.9); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}

.login-logo {
  width: 44px;
  height: 44px;
  background: var(--blue-dim);
  clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
  margin: 0 auto 16px;
}

.login-brand {
  text-align: center;
  font-family: var(--cond);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 4px;
}

.login-title {
  text-align: center;
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 28px;
}

.login-field { margin-bottom: 14px; }

.login-field label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  margin-bottom: 6px;
}

.login-field input {
  width: 100%;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 11px 14px;
  font-size: 14px;
  font-family: var(--font);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
}

.login-field input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(88,166,255,0.1);
}

.login-btn {
  width: 100%;
  margin-top: 6px;
  padding: 13px;
  background: var(--blue);
  border: none;
  border-radius: var(--radius);
  color: white;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
  letter-spacing: 0.5px;
}
.login-btn:hover { background: #79b8ff; transform: translateY(-1px); }
.login-btn:active { transform: translateY(0); }
.login-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

#login-error {
  margin-top: 12px;
  padding: 10px 14px;
  background: rgba(248,81,73,0.1);
  border: 1px solid rgba(248,81,73,0.3);
  border-radius: var(--radius);
  color: var(--red);
  font-size: 13px;
  font-weight: 500;
  text-align: center;
  display: none;
}

/* ── ADMIN OVERLAY ────────────────────────────────────────────── */
#admin-overlay {
  position: fixed;
  inset: 0;
  z-index: 8000;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

#admin-overlay.hidden { display: none; }

#admin-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 780px;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 80px rgba(0,0,0,0.5);
  animation: popIn 0.25s ease;
}

.ap-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.ap-title {
  font-family: var(--cond);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text);
}

.ap-close {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--muted);
  font-size: 16px;
  transition: all 0.15s;
}
.ap-close:hover { color: var(--text); border-color: var(--muted2); }

.ap-body { padding: 20px 24px; overflow-y: auto; flex: 1; }

.ap-section { margin-bottom: 28px; }

.ap-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--muted);
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.ap-form { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.ap-field { display: flex; flex-direction: column; gap: 5px; }
.ap-field.full { grid-column: 1 / -1; }

.ap-field label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
}

.ap-field input, .ap-field select {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 9px 12px;
  font-size: 13px;
  font-family: var(--font);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
  width: 100%;
}
.ap-field input:focus, .ap-field select:focus { border-color: var(--blue); }

.ap-submit {
  width: 100%;
  padding: 11px;
  background: var(--blue-dim);
  border: 1px solid var(--blue);
  border-radius: var(--radius);
  color: white;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
}
.ap-submit:hover { background: var(--blue); }

.ap-msg {
  margin-top: 10px;
  padding: 9px 14px;
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 500;
  display: none;
}
.ap-msg.ok  { background: rgba(63,185,80,0.1);  border: 1px solid rgba(63,185,80,0.3);  color: var(--green); }
.ap-msg.err { background: rgba(248,81,73,0.1);  border: 1px solid rgba(248,81,73,0.3);  color: var(--red); }

.users-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.users-table th {
  background: var(--bg);
  padding: 9px 12px;
  text-align: left;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}
.users-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border2);
  color: var(--text);
  vertical-align: middle;
}
.users-table tr:hover td { background: rgba(88,166,255,0.04); }

.status-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.status-active   { background: rgba(63,185,80,0.12);  color: var(--green); border: 1px solid rgba(63,185,80,0.25); }
.status-inactive { background: rgba(248,81,73,0.12);  color: var(--red);   border: 1px solid rgba(248,81,73,0.25); }

.role-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}
.role-admin { background: rgba(88,166,255,0.12); color: var(--blue); }
.role-user  { background: rgba(139,148,158,0.15); color: var(--muted); }

.tbl-btn {
  padding: 4px 10px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  border: 1px solid;
  transition: all 0.1s;
  margin: 1px;
  white-space: nowrap;
}
.btn-activate   { background: rgba(63,185,80,0.1);  border-color: rgba(63,185,80,0.3);  color: var(--green); }
.btn-deactivate { background: rgba(248,81,73,0.1);  border-color: rgba(248,81,73,0.3);  color: var(--red); }
.btn-pwd        { background: rgba(88,166,255,0.1); border-color: rgba(88,166,255,0.3); color: var(--blue); }
.tbl-btn:hover { filter: brightness(1.3); }

/* ── PRINT ────────────────────────────────────────────────────── */
@media print {
  #topbar, #sidebar, #viewer-section, .cut-viz-btn { display: none !important; }
  #app-body { height: auto; overflow: visible; }
  #main { height: auto; overflow: visible; }
  #results-section { height: auto; overflow: visible; }
  body { background: white; color: black; }
  .bom-table th, .bom-table td { color: black; }
  .results-header { background: white; }
}

/* ── RESPONSIVE ───────────────────────────────────────────────── */
@media (max-width: 900px) {
  html, body { overflow: auto; height: auto; }
  #app-body { flex-direction: column; height: auto; overflow: visible; }
  #sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--border); overflow: visible; }
  #main { height: auto; overflow: visible; }
  #viewer-section { height: 280px; }
  #results-section { height: auto; overflow: visible; }
  :root { --sidebar-w: 100%; }
}
