/* ── THEME VARIABLES ── */
:root {
  --bg:       #0b0b0b;  --bg2:   #131313;  --card:  #191919;  --hover: #202020;
  --gold:     #c9a84c;  --gold2: #e2bb60;
  --gold-bg:  rgba(201,168,76,.10);  --gold-b: rgba(201,168,76,.35);
  --red:      #c44040;  --red-bg:  rgba(196,64,64,.08);
  --blue:     #3a7fc1;  --blue-bg: rgba(58,127,193,.08);
  --green:    #3aad6a;
  --text:     #efefef;  --muted: #888;  --dim: #444;
  --border:   #1e1e1e;  --border2: #2c2c2c;
}
html.light {
  --bg:       #f4f4f4;  --bg2:   #eaeaea;  --card:  #ffffff;  --hover: #f8f8f8;
  --gold:     #9a7010;  --gold2: #b88a1a;
  --gold-bg:  rgba(154,112,16,.08);  --gold-b: rgba(154,112,16,.28);
  --red:      #b83030;  --red-bg:  rgba(184,48,48,.07);
  --blue:     #1d5fa0;  --blue-bg: rgba(29,95,160,.07);
  --green:    #1a9050;
  --text:     #1a1a1a;  --muted: #666;  --dim: #aaa;
  --border:   #e0e0e0;  --border2: #cccccc;
}
*,*::before,*::after { box-sizing:border-box; margin:0; padding:0; }
body { font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,sans-serif; background:var(--bg); color:var(--text); min-height:100vh; font-size:14px; transition: background .2s, color .2s; }
.hidden { display:none!important; }
button:disabled { opacity:.35; cursor:not-allowed; }
.spinner {width: 14px;height: 14px;border: 2px solid rgba(255,255,255,0.3);border-top: 2px solid #2d2b2b;border-radius: 50%;display: inline-block;margin-left: 8px;animation: spin 0.7s linear infinite;vertical-align: middle;}
@keyframes spin {to { transform: rotate(360deg); }}
.btn.loading {opacity: 0.7;pointer-events: none;}

/* ── HEADER ── */
.hdr { display:flex; align-items:center; justify-content:space-between; padding:12px 24px; background:var(--bg2); border-bottom:1px solid var(--border2); position:sticky; top:0; z-index:100; gap:12px; }
.brand { font-size:17px; font-weight:700; letter-spacing:.07em; color:var(--gold); flex-shrink:0; }
.brand sub { font-size:11px; font-weight:400; color:var(--muted); letter-spacing:.03em; margin-left:7px; vertical-align:middle; }
.hdr-right { display:flex; align-items:center; gap:10px; flex-wrap:wrap; }
.user-pill { font-size:12px; padding:4px 13px; border-radius:99px; background:var(--gold-bg); border:1px solid var(--gold-b); color:var(--gold); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; max-width:220px; }
.mfr-pill  { font-size:12px; padding:4px 13px; border-radius:99px; background:var(--blue-bg); border:1px solid rgba(58,127,193,.35); color:var(--blue); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; max-width:220px; }
.theme-btn { background:transparent; border:1px solid var(--border2); border-radius:6px; color:var(--muted); padding:5px 11px; cursor:pointer; font-size:13px; transition:.2s; white-space:nowrap; }
.theme-btn:hover { border-color:var(--gold); color:var(--gold); }

/* ── PROGRESS ── */
.prog { background:var(--bg2); border-bottom:1px solid var(--border2); padding:13px 24px; }
.prog-inner { max-width:540px; margin:0 auto; display:flex; align-items:flex-start; }
.prog-step { flex:1; display:flex; flex-direction:column; align-items:center; position:relative; }
.prog-step:not(:last-child)::after { content:''; position:absolute; top:12px; left:calc(50% + 16px); width:calc(100% - 32px); height:1px; background:var(--border2); }
.prog-step.done:not(:last-child)::after { background:var(--gold); }
.prog-dot { width:25px; height:25px; border-radius:50%; border:2px solid var(--border2); background:var(--card); display:flex; align-items:center; justify-content:center; font-size:11px; font-weight:600; color:var(--muted); z-index:1; transition:.25s; }
.prog-step.active .prog-dot { border-color:var(--gold); color:var(--gold); background:var(--gold-bg); }
.prog-step.done   .prog-dot { border-color:var(--gold); background:var(--gold); color:#000; }
.prog-label { font-size:10px; color:var(--dim); margin-top:5px; text-align:center; letter-spacing:.04em; }
.prog-step.active .prog-label, .prog-step.done .prog-label { color:var(--muted); }

/* ── LAYOUT ── */
.main      { max-width:820px; margin:0 auto; padding:44px 24px; }
.main.wide { max-width:100%; padding:24px 28px; }
.card { background:var(--card); border:1px solid var(--border2); border-radius:12px; padding:36px; }
h2 { font-size:20px; font-weight:600; margin-bottom:6px; }
.sub { font-size:13px; color:var(--muted); margin-bottom:28px; line-height:1.6; }

/* ── FORM ── */
.fgrp { margin-bottom:20px; }
label { display:block; font-size:10px; font-weight:700; letter-spacing:.09em; text-transform:uppercase; color:var(--muted); margin-bottom:7px; }
input[type=email], input[type=text] { width:100%; background:var(--bg2); border:1px solid var(--border2); border-radius:8px; padding:12px 16px; color:var(--text); font-size:15px; outline:none; transition:border .2s; }
input[type=email]:focus, input[type=text]:focus { border-color:var(--gold); }
input[type=password] { width:100%; background:var(--bg2); border:1px solid var(--border2); border-radius:8px; padding:12px 16px; color:var(--text); font-size:15px; outline:none; transition:border .2s; }
input.err, select.err { border-color:var(--red)!important; }
.errtxt { font-size:12px; color:var(--red); margin-top:5px; }

/* ── BUTTONS ── */
.btn { display:inline-flex; align-items:center; gap:7px; padding:10px 22px; border-radius:8px; font-size:13px; font-weight:500; cursor:pointer; border:none; transition:.2s; white-space:nowrap; }
.btn-gold  { background:var(--gold); color:#000; }
.btn-gold:hover:not(:disabled)  { background:var(--gold2); }
.btn-ghost { background:transparent; border:1px solid var(--border2); color:var(--text); }
.btn-ghost:hover:not(:disabled) { background:var(--hover); }
.btn-row { display:flex; gap:10px; justify-content:flex-end; margin-top:28px; }

/* ── DROP ZONE ── */
.drop { border:2px dashed var(--border2); border-radius:12px; padding:56px 24px; text-align:center; cursor:pointer; transition:.2s; }
.drop:hover, .drop.over { border-color:var(--gold); background:var(--gold-bg); }
.drop-icon { font-size:42px; margin-bottom:14px; }
.drop h3 { font-size:16px; font-weight:500; margin-bottom:6px; }
.drop p { font-size:12px; color:var(--muted); }
.file-tag { display:inline-flex; align-items:center; gap:8px; margin-top:18px; padding:8px 16px; background:var(--gold-bg); border:1px solid var(--gold-b); border-radius:8px; font-size:12px; color:var(--gold); }

/* ── MAPPING TABLE ── */
.maptbl { width:100%; border-collapse:collapse; margin-top:10px; }
.maptbl th { font-size:10px; text-transform:uppercase; letter-spacing:.07em; color:var(--muted); padding:9px 14px; border-bottom:1px solid var(--border2); text-align:left; }
.maptbl td { padding:9px 14px; border-bottom:1px solid var(--border); font-size:13px; vertical-align:middle; }
.maptbl tr:last-child td { border-bottom:none; }
.badge { display:inline-block; font-size:9px; font-weight:700; padding:2px 7px; border-radius:4px; letter-spacing:.04em; margin-left:7px; vertical-align:middle; }
.badge-req { background:var(--red-bg);  color:var(--red);  border:1px solid rgba(196,64,64,.3); }
.badge-sys { background:rgba(255,255,255,.04); color:var(--muted); border:1px solid var(--border2); }
.badge-usr { background:var(--blue-bg); color:var(--blue); border:1px solid rgba(58,127,193,.3); }
select { background:var(--bg2); border:1px solid var(--border2); border-radius:6px; padding:7px 10px; color:var(--text); font-size:13px; outline:none; min-width:180px; cursor:pointer; max-width:260px; }
select:focus { border-color:var(--gold); }
.map-ok { font-size:11px; color:var(--green); }

/* ── DATA TABLE ── */
.tbl-scroll { overflow-x:auto; border:1px solid var(--border2); border-radius:10px; }
.dtbl { border-collapse:collapse; font-size:12px; width:max-content; min-width:100%; }
.dtbl th { padding:8px 10px; font-size:9px; text-transform:uppercase; letter-spacing:.07em; font-weight:700; white-space:nowrap; border-bottom:1px solid var(--border2); border-right:1px solid var(--border); position:sticky; top:0; z-index:2; vertical-align:top; }
.dtbl th:last-child { border-right:none; }
.th-req { background:#160808; color:#d97070; }
.th-sys { background:#111111; color:#555; }
.th-usr { background:#080d18; color:#5a9fd4; }
.th-photo { background:#080d18; color:#5a9fd4; }
.dtbl td { padding:6px 10px; border-bottom:1px solid var(--border); border-right:1px solid var(--border); white-space:nowrap; vertical-align:middle; }
.dtbl td:last-child { border-right:none; }
.dtbl tr:last-child td { border-bottom:none; }
.dtbl tr:hover td { background:rgba(128,128,128,.04); }
.td-sys { color:var(--muted); font-size:12px; }
.row-num { color:var(--dim); font-size:11px; text-align:right; user-select:none; min-width:24px; }
/* Editable inputs in table */
.inp-txt { background:transparent; border:1px solid transparent; border-radius:4px; padding:3px 6px; color:var(--text); font-size:12px; width:130px; outline:none; }
.inp-txt:focus { border-color:var(--gold); background:var(--bg2); }
.inp-cmt { background:transparent; border:1px solid transparent; border-radius:4px; padding:3px 6px; color:var(--text); font-size:12px; width:210px; outline:none; font-family:inherit; }
.inp-cmt:focus { border-color:var(--gold); background:var(--bg2); }
.inp-chk { width:15px; height:15px; cursor:pointer; accent-color:var(--gold); }
/* Dropdown selects inside table cells */
.tbl-sel { background:transparent; border:1px solid transparent; border-radius:4px; padding:3px 6px; color:var(--text); font-size:12px; cursor:pointer; outline:none; min-width:0; }
.tbl-sel:hover, .tbl-sel:focus { border-color:var(--gold); background:var(--bg2); }
.tbl-sel.cat { width:158px; }
.tbl-sel.def { width:200px; }

/* ── CUSTOM NUMBER STEPPER ── */
.stepper { display:inline-flex; align-items:center; background:var(--bg2); border:1px solid var(--border2); border-radius:5px; overflow:hidden; }
.stp-btn { background:transparent; border:none; color:var(--gold); font-size:17px; font-weight:700; width:28px; height:28px; cursor:pointer; display:flex; align-items:center; justify-content:center; transition:.15s; padding:0; line-height:1; flex-shrink:0; }
.stp-btn:hover:not(:disabled) { background:var(--gold-bg); color:var(--gold2); }
.stp-val { min-width:30px; text-align:center; font-size:13px; font-weight:600; color:var(--text); padding:0 3px; user-select:none; }

/* ── KEYBOARD NAVIGATION ── */
td.cell-active { outline:2px solid var(--gold) !important; outline-offset:-2px; background:rgba(201,168,76,.07) !important; }

/* ── PHOTO COLUMN ── */
.photo-btn { background:transparent; border:none; cursor:pointer; font-size:17px; padding:0; line-height:1; transition:transform .15s; display:block; margin:0 auto; }
.photo-btn:hover { transform:scale(1.25); }
.photo-thumb { width:44px; height:33px; object-fit:cover; border-radius:3px; cursor:pointer; display:block; margin:0 auto; border:1px solid var(--border2); transition:border-color .15s; }
.photo-thumb:hover { border-color:var(--gold); }

/* ── SORT + FILTER IN COLUMN HEADERS ── */
.th-sort { cursor:pointer; user-select:none; }
.th-sort:hover { opacity:.82; }
.sort-icon { display:inline-block; margin-left:3px; font-size:9px; vertical-align:middle; min-width:9px; }
.sort-icon.none::after  { content:'⇅'; color:var(--dim); }
.sort-icon.asc::after   { content:'↑'; color:var(--gold); }
.sort-icon.desc::after  { content:'↓'; color:var(--gold); }
.filter-cell { margin-top:5px; }
/* Fix: override global input[type=text] specificity with !important */
.flt-inp {
  width:100%; background:var(--bg); border:1px solid var(--border2); border-radius:3px;
  padding:2px 5px !important; color:var(--text); font-size:10px !important; font-weight:400; letter-spacing:0;
  text-transform:none; outline:none; min-width:48px; cursor:text;
}
.flt-inp:focus { border-color:var(--gold); background:var(--bg2); }
.flt-sel {
  width:100%; background:var(--bg); border:1px solid var(--border2); border-radius:3px;
  padding:2px 3px; color:var(--text); font-size:10px; font-weight:400; letter-spacing:0;
  text-transform:none; cursor:pointer; outline:none;
}
.flt-sel:focus { border-color:var(--gold); }

/* ── PHOTO EDITOR MODAL ── */
.photo-modal-overlay { position:fixed; inset:0; background:rgba(0,0,0,.88); z-index:1000; display:flex; align-items:center; justify-content:center; padding:12px; }
.photo-modal-box { background:var(--card); border:1px solid var(--border2); border-radius:12px; width:min(97vw,980px); max-height:96vh; display:flex; flex-direction:column; overflow:hidden; }
.photo-modal-header { display:flex; align-items:center; justify-content:space-between; padding:11px 16px; border-bottom:1px solid var(--border2); flex-shrink:0; }
.photo-modal-header span { font-size:14px; font-weight:600; color:var(--text); }
.photo-close-btn { background:transparent; border:none; font-size:20px; cursor:pointer; color:var(--muted); padding:2px 8px; border-radius:4px; transition:.2s; line-height:1; }
.photo-close-btn:hover { color:var(--red); background:var(--red-bg); }
.photo-toolbar { display:flex; align-items:center; gap:6px; padding:7px 12px; border-bottom:1px solid var(--border2); flex-wrap:wrap; flex-shrink:0; background:var(--bg2); }
.pt-group { display:flex; align-items:center; gap:4px; }
.pt-sep { width:1px; height:22px; background:var(--border2); margin:0 3px; flex-shrink:0; }
.pt-btn { background:var(--bg); border:1px solid var(--border2); border-radius:5px; color:var(--text); font-size:12px; padding:4px 9px; cursor:pointer; transition:.15s; white-space:nowrap; line-height:1.4; }
.pt-btn:hover { border-color:var(--gold); color:var(--gold); }
.pt-btn.active { background:var(--gold-bg); border-color:var(--gold); color:var(--gold); }
.pt-btn.pt-save { background:var(--gold); color:#000; border-color:var(--gold); font-weight:600; }
.pt-btn.pt-save:hover { background:var(--gold2); }
input[type=color].pt-color-inp { width:28px; height:26px; padding:1px; border:1px solid var(--border2); border-radius:4px; cursor:pointer; background:none; }
input[type=range].pt-range { width:68px; cursor:pointer; accent-color:var(--gold); }
.crop-action-bar { display:flex; align-items:center; gap:8px; padding:5px 12px; background:rgba(201,168,76,.08); border-bottom:1px solid var(--gold-b); flex-shrink:0; font-size:12px; color:var(--muted); }
.photo-canvas-wrap { flex:1; overflow:hidden; display:flex; align-items:center; justify-content:center; padding:12px; background:var(--bg); position:relative; min-height:180px; }
#photo-canvas { display:block; cursor:default; image-rendering:pixelated; }
#photo-canvas.tool-crop, #photo-canvas.tool-arrow, #photo-canvas.tool-circle { cursor:crosshair; }
.photo-status-bar { padding:5px 14px; font-size:11px; color:var(--muted); border-top:1px solid var(--border2); flex-shrink:0; min-height:26px; }

/* ── LIGHT MODE OVERRIDES ── */
html.light .th-req { background:#fce8e8; }
html.light .th-sys { background:#f0f0f0; }
html.light .th-usr { background:#e8f0fa; }
html.light .th-photo { background:#e8f0fa; }
html.light .inp-txt, html.light .inp-cmt { color:var(--text); }
html.light .inp-txt:focus, html.light .inp-cmt:focus { background:var(--bg2); }
html.light .tbl-sel { color:var(--text); }
html.light .tbl-sel:hover, html.light .tbl-sel:focus { background:var(--bg2); }
html.light select { color:var(--text); background:var(--bg2); }
html.light input[type=email], html.light input[type=text] { color:var(--text); background:var(--bg2); }
html.light .flt-inp { background:var(--bg2); color:var(--text); }
html.light .flt-sel { background:var(--bg2); color:var(--text); }
html.light .stepper { background:var(--bg2); }
html.light .photo-modal-box { background:var(--card); }
html.light .photo-toolbar { background:var(--bg2); }
html.light .pt-btn { background:var(--bg); }

/* ── TOOLBAR (step 4) ── */
.toolbar { display:flex; align-items:center; justify-content:space-between; margin-bottom:14px; flex-wrap:wrap; gap:12px; }
.legend { display:flex; gap:18px; flex-wrap:wrap; margin-bottom:14px; }
.leg { display:flex; align-items:center; gap:6px; font-size:11px; color:var(--muted); }
.leg-dot { width:9px; height:9px; border-radius:2px; }
.dot-req { background:#c44040; } .dot-sys { background:#333; } .dot-usr { background:#3a7fc1; }
.serial-note { font-size:11px; color:var(--gold); background:var(--gold-bg); border:1px solid var(--gold-b); border-radius:6px; padding:5px 12px; display:inline-flex; align-items:center; gap:6px; }

/* ── SUCCESS ── */
.success-wrap { text-align:center; padding:12px 0; }
.success-icon { width:62px; height:62px; border-radius:50%; background:rgba(58,173,106,.1); border:2px solid var(--green); display:flex; align-items:center; justify-content:center; margin:0 auto 18px; font-size:26px; color:var(--green); }
.stats { display:flex; gap:14px; flex-wrap:wrap; max-width:600px; margin:24px auto; }
.stat { background:var(--bg2); border:1px solid var(--border2); border-radius:8px; padding:14px 20px; flex:1; min-width:90px; text-align:center; }
.stat-n { font-size:26px; font-weight:700; color:var(--gold); }
.stat-l { font-size:11px; color:var(--muted); margin-top:3px; }
.stat.excl .stat-n { color:var(--muted); }

.photo-container {
  display: flex;
  align-items: center;
  gap: 6px;
}

.photo-thumbs {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  max-width: 120px;
}

.photo-thumb {
  width: 32px;
  height: 32px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid #ccc;
}

.add-photo-btn {
  width: 28px;
  height: 28px;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}