*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #f5f4f0; --surface: #ffffff; --surface2: #f0ede8;
  --border: #dddad4; --border2: #ccc9c2;
  --text: #1a1917; --text2: #6b6860;
  --green: #1D9E75; --green-bg: #E1F5EE; --green-dark: #085041;
  --amber: #BA7517; --amber-bg: #FAEEDA; --amber-dark: #412402;
  --red: #993C1D; --red-bg: #FAECE7;
  --blue: #185FA5; --blue-bg: #E6F1FB; --blue-dark: #042C53;
  --purple: #6B3FA0; --purple-bg: #F0EAF9;
  --gray: #5a5856; --gray-bg: #EDEDEB;
  --radius: 10px; --radius-sm: 6px;
}
body { font-family: 'Segoe UI', system-ui, sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; display: flex; margin: 0; padding: 0; }
.app { max-width: 100%; margin: 0; padding: 0 1.5rem 1.5rem; }
/* SIDEBAR */
.sidebar { width: 210px; min-width: 210px; background: var(--blue-dark); min-height: 100vh; display: flex; flex-direction: column; position: fixed; top: 0; left: 0; z-index: 100; overflow-y: auto; }
.sidebar-logo { padding: 16px 14px 12px; border-bottom: 1px solid rgba(255,255,255,.1); display: flex; align-items: center; gap: 10px; }
.sidebar-logo img { height: 32px; width: auto; border-radius: 4px; background: white; padding: 2px 4px; }
.sidebar-logo-text { font-size: 11px; font-weight: 700; color: rgba(255,255,255,.85); line-height: 1.3; }
.sidebar-section { padding: 14px 14px 4px; font-size: 9px; font-weight: 800; color: rgba(255,255,255,.35); text-transform: uppercase; letter-spacing: .1em; }
.sidebar-item { display: flex; align-items: center; gap: 9px; padding: 9px 12px; margin: 1px 8px; border-radius: 7px; color: rgba(255,255,255,.72); font-size: 13px; font-weight: 500; cursor: pointer; text-decoration: none; transition: background .12s, color .12s; }
.sidebar-item:hover { background: rgba(255,255,255,.1); color: white; }
.sidebar-item.active { background: rgba(255,255,255,.15); color: white; font-weight: 600; }
.sidebar-item .si-icon { font-size: 15px; width: 20px; text-align: center; flex-shrink: 0; }
.sidebar-divider { border: none; border-top: 1px solid rgba(255,255,255,.1); margin: 6px 12px; }
.sidebar-config-item { padding: 6px 12px; margin: 1px 6px; border-radius: 6px; }
.sidebar-config-item:hover { background: rgba(255,255,255,.05); }
.sidebar-config-label { font-size: 11px; color: rgba(255,255,255,.65); display: flex; align-items: center; justify-content: space-between; gap: 4px; margin-bottom: 3px; }
.sidebar-config-status { font-size: 10px; font-weight: 700; flex-shrink: 0; }
.sc-ok   { color: #6ee7b7; }
.sc-warn { color: #fcd34d; }
.sidebar-config-btns { display: flex; gap: 4px; }
.sc-btn { font-size: 10px; padding: 2px 8px; border-radius: 4px; border: 1px solid rgba(255,255,255,.18); background: rgba(255,255,255,.07); color: rgba(255,255,255,.78); cursor: pointer; font-family: inherit; }
.sc-btn:hover { background: rgba(255,255,255,.18); }
.sc-btn.del { color: #fca5a5; border-color: rgba(252,165,165,.25); }
.main-content { margin-left: 210px; flex: 1; min-width: 0; }
.header { margin-bottom: 2rem; text-align: center; }
.header-logos { display: flex; align-items: center; justify-content: center; gap: 20px; }
.header-divider { width: 1px; height: 60px; background: #ccc9c2; }
.logo-nerilan { height: 52px; width: auto; object-fit: contain; background: white; border-radius: 6px; padding: 4px 8px; }
.logo-frog { height: 52px; width: auto; object-fit: contain; background: white; border-radius: 6px; padding: 4px 8px; }
.header-title h1 { font-size: 22px; font-weight: 700; }
.header-title p { font-size: 12px; color: var(--text2); margin-top: 3px; }
.header h1 { font-size: 24px; font-weight: 700; }
.header p { font-size: 13px; color: var(--text2); margin-top: 4px; }
.upload-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; margin-bottom: 1rem; }
.upload-box { background: var(--surface); border: 2px dashed var(--border); border-radius: var(--radius); padding: 1rem; cursor: pointer; transition: all 0.15s; text-align: center; position: relative; min-height: 95px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; }
.upload-box:hover { border-color: var(--green); background: var(--green-bg); }
.upload-box.loaded { border-style: solid; border-color: var(--green); background: var(--green-bg); }
.upload-box.optional { border-color: #ccc9c2; }
.upload-box input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.u-icon { font-size: 24px; }
.u-label { font-size: 12px; font-weight: 600; color: var(--text); }
.u-hint { font-size: 11px; color: var(--text2); }
.upload-box.loaded .u-label { color: var(--green-dark); }
.upload-box.loaded .u-hint { color: var(--green); }
.badge-wrap { text-align: center; margin-bottom: 0; }
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; padding: 4px 12px; border-radius: 20px; font-weight: 500; }
.badge-approx { background: var(--amber-bg); color: var(--amber-dark); }
.badge-exact { background: var(--green-bg); color: var(--green-dark); }
.btn-compare { width: 100%; padding: 12px; border: none; border-radius: var(--radius-sm); background: var(--green); color: white; font-size: 15px; font-weight: 600; cursor: pointer; transition: opacity 0.15s; display: flex; align-items: center; justify-content: center; gap: 8px; }
.btn-compare:hover { opacity: 0.88; }
.btn-compare:disabled { opacity: 0.4; cursor: not-allowed; }
.error { background: var(--red-bg); border: 1px solid #F09595; border-radius: var(--radius-sm); padding: 10px 14px; font-size: 13px; color: var(--red); margin-top: 10px; display: none; }
.loading { display: none; align-items: center; justify-content: center; gap: 10px; padding: 1.5rem; color: var(--text2); font-size: 14px; margin-top: 10px; }
.spinner { width: 18px; height: 18px; border: 2.5px solid var(--border); border-top-color: var(--green); border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.results { margin-top: 1.5rem; display: none; }
.summary-grid { display: grid; grid-template-columns: repeat(7,1fr); gap: 10px; margin-bottom: 1.5rem; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px; display: flex; flex-direction: column; justify-content: space-between; min-height: 90px; }
.stat-label { font-size: 10px; color: var(--text2); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat-val { font-size: 26px; font-weight: 600; line-height: 1; }
.stat-pct { font-size: 12px; font-weight: 400; color: var(--text2); display: block; margin-top: 3px; }
.stat-fillrate { border: 2px solid var(--blue); background: var(--blue-bg); }
.stat-fillrate .stat-val { font-size: 28px; }
.stat-fillrate-sub { font-size: 10px; color: var(--blue); margin-top: 4px; opacity: 0.8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.c-blue { color: var(--blue); } .c-green { color: var(--green); }
.c-amber { color: var(--amber); } .c-red { color: var(--red); }
.c-purple { color: var(--purple); } .c-gray { color: var(--gray); }
.section-title { font-size: 12px; font-weight: 600; color: var(--text2); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 8px; }
.filter-row { display: flex; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; justify-content: center; }
.fbtn { padding: 5px 13px; border: 1px solid var(--border); border-radius: 20px; background: var(--surface); font-size: 12px; cursor: pointer; color: var(--text2); transition: all 0.12s; font-family: inherit; }
.fbtn:hover { border-color: var(--border2); color: var(--text); }
.fbtn.active { background: var(--blue-dark); color: white; border-color: var(--blue-dark); font-weight: 500; }
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
table { width: 100%; border-collapse: collapse; font-size: 13px; table-layout: auto; }
thead th { background: var(--surface2); padding: 9px 16px; text-align: left; font-size: 11px; font-weight: 600; color: var(--text2); text-transform: uppercase; letter-spacing: 0.05em; border-bottom: 2px solid var(--border2); border-right: 1px solid var(--border); cursor: pointer; user-select: none; white-space: nowrap; }
thead th:last-child { border-right: none; }
thead th:hover { background: #e8e5e0; color: var(--text); }
thead th .sort-icon { margin-left: 4px; opacity: 0.4; font-style: normal; }
thead th.sort-asc .sort-icon, thead th.sort-desc .sort-icon { opacity: 1; color: var(--blue); }
tbody td { padding: 9px 16px; border-bottom: 1px solid var(--border); border-right: 1px solid #ece9e4; vertical-align: middle; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
tbody td:last-child { border-right: none; }
tbody tr:last-child td { border-bottom: none; }
.row-ok td { background: #1D9E750a; }
.row-warn td { background: #BA751710; }
.row-mv td { background: #993C1D0d; }
.row-moc td { background: #185FA50d; }
.row-nostock td { background: #6B3FA00d; }
.pill { display: inline-block; font-size: 11px; padding: 2px 9px; border-radius: 20px; font-weight: 600; }
.p-ok { background: #9FE1CB; color: #04342C; }
.p-warn { background: #FAC775; color: #412402; }
.p-mv { background: #F5C4B3; color: #4A1B0C; }
.p-moc { background: #B5D4F4; color: #042C53; }
.p-nostock { background: #D8C4F0; color: #3B1A6E; }
.export-row { display: flex; gap: 10px; margin-top: 12px; }
.btn-exp { flex: 1; padding: 9px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); font-size: 13px; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 6px; transition: background 0.12s; font-family: inherit; font-weight: 500; }
.btn-exp:hover { background: var(--surface2); }
.mono { font-family: 'Courier New', monospace; font-size: 12px; }
@media (max-width: 900px) { .upload-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 600px) { .upload-grid { grid-template-columns: 1fr 1fr; } .summary-grid { grid-template-columns: repeat(2,1fr); } }
/* servidor badges */
.servidor-status { display:flex; gap:8px; margin-top:10px; align-items:center; flex-wrap:wrap; }
.srv-badge { display:inline-flex;align-items:center;gap:4px;font-size:11px;padding:3px 10px;border-radius:20px;font-weight:500; }
.srv-ok   { background:var(--green-bg); color:var(--green-dark); }
.srv-warn { background:var(--amber-bg); color:var(--amber-dark); }
.srv-btn  { font-size:11px;padding:3px 10px;border-radius:20px;border:1px solid var(--border);background:var(--surface);cursor:pointer;font-family:inherit; }
.srv-btn:hover { background:var(--surface2); }
/* Menú configuración */
.config-wrap { position:relative; display:inline-block; }
.config-btn { width:34px;height:34px;border-radius:50%;border:1px solid var(--border);background:var(--surface);cursor:pointer;font-size:16px;display:flex;align-items:center;justify-content:center;transition:background .12s; }
.config-btn:hover { background:var(--surface2); transform:rotate(30deg); }
.config-menu { display:none;position:absolute;top:40px;right:0;background:var(--surface);border:1px solid var(--border);border-radius:var(--radius);box-shadow:0 8px 24px rgba(0,0,0,.12);min-width:260px;z-index:50;padding:8px 0; }
.config-menu.open { display:block; }
.config-menu-title { font-size:10px;font-weight:700;color:var(--text2);text-transform:uppercase;letter-spacing:.06em;padding:6px 14px 4px; }
.config-item { display:flex;align-items:center;justify-content:space-between;padding:8px 14px;gap:10px;font-size:13px; }
.config-item label { font-weight:500;color:var(--text);cursor:pointer;flex:1; }
.config-item .config-status { font-size:11px;font-weight:600; }
.config-item .c-ok { color:var(--green); }
.config-item .c-warn { color:var(--amber); }
.config-file-btn { padding:4px 10px;border:1px solid var(--border);border-radius:var(--radius-sm);background:var(--surface2);font-size:11px;cursor:pointer;font-family:inherit;white-space:nowrap; }
.config-file-btn:hover { background:var(--border); }
.config-sep { border:none;border-top:1px solid var(--border);margin:4px 0; }
.u-clear-btn { position:absolute; bottom:6px; right:6px; font-size:10px; padding:2px 7px; border-radius:10px; border:1px solid var(--border2); background:white; color:var(--red); cursor:pointer; font-family:inherit; z-index:2; }
.u-clear-btn:hover { background:var(--red-bg); }
.upload-box { position:relative; }
/* alerta OC duplicada */
.oc-duplicada-alert { display:none; background:#FEF3C7; border:1px solid #F59E0B; border-radius:var(--radius-sm); padding:10px 14px; font-size:13px; color:#92400E; margin-top:10px; }
.oc-duplicada-alert strong { color:#78350F; }
/* Modal OC duplicada */
.dup-overlay { display:none; position:fixed; inset:0; background:rgba(0,0,0,.45); z-index:200; align-items:center; justify-content:center; }
.dup-overlay.open { display:flex; }
.dup-modal { background:#fff; border-radius:12px; max-width:460px; width:90%; padding:28px 28px 22px; box-shadow:0 20px 60px rgba(0,0,0,.3); }
.dup-modal h2 { font-size:17px; font-weight:700; margin-bottom:10px; color:#1a1917; }
.dup-modal p { font-size:13px; color:#6b6860; line-height:1.6; margin-bottom:18px; }
.dup-modal .dup-oc { font-family:'Courier New',monospace; font-weight:700; color:#185FA5; font-size:15px; }
.dup-modal .dup-fecha { color:#BA7517; font-weight:600; }
.dup-actions { display:flex; gap:10px; flex-wrap:wrap; }
.dup-btn-cancel { flex:1; padding:9px; border:1px solid #dddad4; border-radius:6px; background:#fff; font-size:13px; font-weight:600; cursor:pointer; font-family:inherit; color:#1a1917; }
.dup-btn-cancel:hover { background:#f0ede8; }
.dup-btn-delete { flex:2; padding:9px; border:none; border-radius:6px; background:#993C1D; color:white; font-size:13px; font-weight:600; cursor:pointer; font-family:inherit; }
.dup-btn-delete:hover { background:#7a2e14; }
.dup-btn-delete:disabled { opacity:0.5; cursor:not-allowed; }
/* Print */
@media print {
  body { background: white; padding: 0.5rem; display: block; }
  .main-content { margin-left: 0; }
  .app { padding: 0.5rem; }
  .sidebar, .servidor-status, .oc-duplicada-alert, .header, .upload-grid, .badge-wrap,
  .btn-compare, .error, .loading, .filter-row, .export-row { display: none !important; }
  .results { display: block !important; margin-top: 0; }
  .summary-grid { margin-bottom: 1rem; }
  .stat { border: 1px solid #ccc; }
  .table-wrap { border: 1px solid #ccc; border-radius: 0; }
  tbody td { white-space: normal; }
  .section-title { margin-bottom: 6px; }
}

/* Tabla ocupa todo el ancho disponible ignorando padding del .app */
.table-wrap, .results > .table-wrap {
  margin-left: -1.5rem;
  margin-right: -1.5rem;
  border-radius: 0;
}
