/* ============================================================
   GMA Sistema de Trazabilidad — style.css v1.0
   ============================================================ */
:root {
  --navy:       #0d1b2e;
  --navy-mid:   #1a2f4e;
  --navy-light: #243b5c;
  --navy-pale:  #e8f0f8;
  --red:        #c41d1d;
  --red-hover:  #a81515;
  --steel:      #4a6080;
  --border:     #d0dce8;
  --surface:    #f4f7fb;
  --white:      #ffffff;
  --text:       #1a2f4e;
  --muted:      #5a7090;
  --green:      #1a7a45;
  --warn:       #b06a00;
  --sw: 230px;
  --th: 56px;
}
*, *::before, *::after { box-sizing: border-box; }
body { font-family: 'Segoe UI', system-ui, -apple-system, sans-serif; background: var(--surface); color: var(--text); margin: 0; min-height: 100vh; }
a { text-decoration: none; }

/* ── SIDEBAR ─────────────────────────────────────────────── */
.sidebar {
  width: var(--sw); background: var(--navy); position: fixed;
  top: 0; left: 0; height: 100vh; display: flex;
  flex-direction: column; z-index: 1000;
  transition: transform .25s ease; overflow: hidden;
}
.sidebar.closed { transform: translateX(calc(-1 * var(--sw))); }

.sb-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px; border-bottom: 1px solid rgba(255,255,255,.08);
  min-height: 70px;
}
.sb-logo { width: 40px; height: 40px; object-fit: contain; background: white; border-radius: 6px; padding: 2px; flex-shrink: 0; }
.sb-name { color: white; font-size: 17px; font-weight: 700; letter-spacing: .5px; }
.sb-sub  { color: rgba(255,255,255,.38); font-size: 9.5px; letter-spacing: 1px; text-transform: uppercase; }

.sb-nav { flex: 1; overflow-y: auto; padding: 8px 0; }
.sb-sec { color: rgba(255,255,255,.28); font-size: 10px; font-weight: 700; letter-spacing: 1.5px; text-transform: uppercase; padding: 10px 16px 3px; }
.sb-link {
  display: flex; align-items: center; gap: 10px; padding: 9px 16px;
  color: rgba(255,255,255,.6); font-size: 13.5px;
  border-left: 3px solid transparent; transition: all .15s;
}
.sb-link:hover { background: rgba(255,255,255,.07); color: white; }
.sb-link.active { background: rgba(196,29,29,.18); color: white; border-left-color: var(--red); }
.sb-link i { font-size: 15px; width: 18px; flex-shrink: 0; }

.sb-foot {
  padding: 12px 14px; border-top: 1px solid rgba(255,255,255,.08);
  display: flex; align-items: center; gap: 10px;
}
.sb-avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--red); color: white; display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 700; flex-shrink: 0; }
.sb-uname { color: white; font-size: 13px; font-weight: 600; display: block; }
.sb-urol  { color: rgba(255,255,255,.4); font-size: 11px; text-transform: capitalize; }
.sb-logout { color: rgba(255,255,255,.45); font-size: 19px; margin-left: auto; }
.sb-logout:hover { color: var(--red); }

/* ── MAIN ────────────────────────────────────────────────── */
.main { margin-left: var(--sw); transition: margin-left .25s ease; display: flex; flex-direction: column; min-height: 100vh; }
.main.expanded { margin-left: 0; }

/* ── TOPBAR ──────────────────────────────────────────────── */
.topbar {
  height: var(--th); background: white; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 22px; position: sticky; top: 0; z-index: 900;
}
.topbar-left { display: flex; align-items: center; gap: 14px; }
.btn-toggle { background: transparent; border: none; font-size: 22px; color: var(--navy); cursor: pointer; padding: 4px 6px; border-radius: 6px; }
.btn-toggle:hover { background: var(--surface); }
.topbar-title { font-size: 16px; font-weight: 600; color: var(--navy); }
.topbar-right { display: flex; align-items: center; gap: 14px; font-size: 12px; color: var(--muted); }
.status-dot { display: flex; align-items: center; gap: 5px; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: #22c55e; }

/* ── CONTENT ─────────────────────────────────────────────── */
.content { padding: 22px; flex: 1; }

/* ── PAGE HEADER ─────────────────────────────────────────── */
.ph { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 20px; gap: 12px; flex-wrap: wrap; }
.ph-title { font-size: 21px; font-weight: 700; color: var(--navy); margin: 0; }
.ph-sub   { font-size: 13px; color: var(--muted); margin: 3px 0 0; }
.ph-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── STAT CARDS ──────────────────────────────────────────── */
.stat { background: white; border: 1px solid var(--border); border-radius: 10px; padding: 18px 20px; display: flex; align-items: center; gap: 16px; }
.stat-ico { width: 46px; height: 46px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 21px; flex-shrink: 0; }
.ico-navy  { background: var(--navy-pale); color: var(--navy); }
.ico-red   { background: #fde8e8; color: var(--red); }
.ico-green { background: #dcfce7; color: var(--green); }
.ico-warn  { background: #fef3c7; color: var(--warn); }
.stat-val  { font-size: 26px; font-weight: 700; color: var(--navy); line-height: 1; }
.stat-lbl  { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; margin-top: 3px; }

/* ── CARDS ───────────────────────────────────────────────── */
.card { background: white; border: 1px solid var(--border); border-radius: 10px; padding: 20px; margin-bottom: 18px; }
.card-hdr { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.card-title { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; margin: 0; }

/* ── BUTTONS ─────────────────────────────────────────────── */
.btn-primary   { background: var(--navy); color: white; border: none; padding: 9px 18px; border-radius: 7px; font-size: 13.5px; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; transition: background .15s; }
.btn-primary:hover   { background: var(--navy-mid); color: white; }
.btn-danger    { background: var(--red); color: white; border: none; padding: 9px 18px; border-radius: 7px; font-size: 13.5px; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.btn-danger:hover    { background: var(--red-hover); color: white; }
.btn-outline   { background: white; color: var(--navy); border: 1.5px solid var(--border); padding: 8px 17px; border-radius: 7px; font-size: 13.5px; font-weight: 500; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.btn-outline:hover   { background: var(--surface); color: var(--navy); }
.btn-success   { background: var(--green); color: white; border: none; padding: 9px 18px; border-radius: 7px; font-size: 13.5px; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.btn-sm        { padding: 5px 12px; font-size: 12.5px; border-radius: 6px; }
.btn-xs        { padding: 3px 9px; font-size: 11.5px; border-radius: 5px; }
.w-full        { width: 100%; justify-content: center; }

/* ── TABLE ───────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th { background: var(--navy); color: white; padding: 10px 14px; font-size: 12px; font-weight: 600; text-align: left; white-space: nowrap; }
tbody td { padding: 9px 14px; font-size: 13px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:hover { background: var(--navy-pale); }
tbody tr:last-child td { border-bottom: none; }

/* ── BADGES ──────────────────────────────────────────────── */
.badge { display: inline-block; padding: 3px 9px; border-radius: 20px; font-size: 11.5px; font-weight: 600; }
.b-navy    { background: var(--navy); color: white; }
.b-new     { background: #fef3c7; color: #7a4f00; }
.b-exists  { background: #dcfce7; color: #14532d; }
.b-active  { background: #dcfce7; color: #14532d; }
.b-pending { background: #fef3c7; color: #7a4f00; }
.b-done    { background: #dbeafe; color: #1e3a8a; }
.b-printed { background: var(--navy-pale); color: var(--navy); }
.b-red     { background: #fee2e2; color: #7f1d1d; }

/* ── UPLOAD ZONE ─────────────────────────────────────────── */
.upload-zone { border: 2.5px dashed var(--border); border-radius: 10px; padding: 46px 24px; text-align: center; cursor: pointer; transition: all .2s; background: var(--surface); }
.upload-zone:hover, .upload-zone.drag { border-color: var(--navy); background: var(--navy-pale); }
.uz-icon  { font-size: 46px; color: var(--navy-light); opacity: .5; margin-bottom: 12px; }
.uz-title { font-size: 16px; font-weight: 600; color: var(--navy); }
.uz-sub   { font-size: 13px; color: var(--muted); margin: 4px 0 0; }
.uz-ext   { display: inline-block; background: var(--border); color: var(--muted); font-size: 11px; padding: 2px 12px; border-radius: 20px; margin-top: 10px; }

/* ── STEP BAR ────────────────────────────────────────────── */
.steps { display: flex; margin-bottom: 22px; }
.step-item { flex: 1; text-align: center; padding: 9px 4px; background: var(--surface); border: 1px solid var(--border); font-size: 12px; color: var(--muted); }
.step-item:first-child { border-radius: 8px 0 0 8px; }
.step-item:last-child  { border-radius: 0 8px 8px 0; }
.step-item.done    { background: var(--navy); color: white; border-color: var(--navy); }
.step-item.current { background: var(--red); color: white; border-color: var(--red); }
.step-n { font-size: 18px; font-weight: 700; display: block; }

/* ── FORM ────────────────────────────────────────────────── */
.form-label { font-size: 11.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; display: block; margin-bottom: 5px; }
.form-ctrl { width: 100%; padding: 9px 12px; border: 1.5px solid var(--border); border-radius: 7px; font-size: 13.5px; color: var(--text); background: white; transition: border-color .15s; }
.form-ctrl:focus { outline: none; border-color: var(--navy); box-shadow: 0 0 0 3px rgba(13,27,46,.1); }
.form-text { font-size: 11.5px; color: var(--muted); margin-top: 4px; }
.form-row  { display: grid; gap: 14px; }
.col-2 { grid-template-columns: repeat(2,1fr); }
.col-3 { grid-template-columns: repeat(3,1fr); }
.col-4 { grid-template-columns: repeat(4,1fr); }

/* ── LABEL PREVIEW ───────────────────────────────────────── */
.lp-wrap  { border: 2px solid #222; border-radius: 5px; overflow: hidden; background: white; max-width: 320px; }
.lp-head  { background: var(--navy); color: white; display: flex; align-items: center; justify-content: space-between; padding: 5px 10px; }
.lp-co    { font-size: 11px; font-weight: 700; }
.lp-sn    { font-size: 10px; color: rgba(255,255,255,.6); }
.lp-body  { display: flex; }
.lp-info  { flex: 1; padding: 7px 10px; }
.lp-row   { display: flex; margin-bottom: 2px; }
.lp-k     { font-size: 10px; color: #888; min-width: 66px; }
.lp-v     { font-size: 11px; font-weight: 700; color: #111; }
.lp-codes { display: flex; flex-direction: column; align-items: center; padding: 7px; border-left: 1px solid #e5e7eb; gap: 5px; }
.lp-foot  { background: #111; color: white; text-align: center; font-size: 9px; letter-spacing: .8px; padding: 3px; text-transform: uppercase; }

/* ── INFO BOX ────────────────────────────────────────────── */
.info-box { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 10px 13px; }
.info-box label { font-size: 10px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; display: block; }
.info-box p { font-size: 14px; font-weight: 600; color: var(--navy); margin: 2px 0 0; word-break: break-word; }

/* ── PAPER CARD ──────────────────────────────────────────── */
.paper-card { border: 1.5px solid var(--border); border-radius: 9px; padding: 15px; cursor: pointer; transition: all .15s; }
.paper-card:hover { border-color: var(--navy); }
.paper-card.sel   { border-color: var(--red); box-shadow: 0 0 0 2px rgba(196,29,29,.2); }
.paper-rect { border: 2px solid var(--navy); background: white; box-shadow: 2px 2px 5px rgba(0,0,0,.15); }

/* ── SCAN PAGE ───────────────────────────────────────────── */
.scan-page { min-height: 100vh; background: var(--navy); display: flex; align-items: center; justify-content: center; padding: 24px; }
.scan-card { background: white; border-radius: 12px; max-width: 480px; width: 100%; overflow: hidden; }
.scan-head { background: var(--navy); color: white; padding: 18px 22px; display: flex; align-items: center; gap: 14px; }
.scan-body { padding: 22px; }
.scan-field { background: var(--surface); border-radius: 7px; padding: 9px 13px; margin-bottom: 8px; }
.scan-field label { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; font-weight: 600; }
.scan-field p { font-size: 15px; font-weight: 600; color: var(--navy); margin: 2px 0 0; }
.scan-foot { background: var(--surface); padding: 11px 18px; text-align: center; border-top: 1px solid var(--border); font-size: 11px; color: var(--muted); }

/* ── LOGIN ───────────────────────────────────────────────── */
.login-wrap { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--navy); padding: 20px; }
.login-card { background: white; border-radius: 12px; width: 100%; max-width: 380px; overflow: hidden; box-shadow: 0 24px 60px rgba(0,0,0,.45); }
.login-head { background: var(--navy); padding: 28px 28px 22px; text-align: center; }
.login-logo { width: 64px; height: 64px; object-fit: contain; background: white; border-radius: 8px; padding: 4px; margin-bottom: 12px; }
.login-title { color: white; font-size: 21px; font-weight: 700; margin: 0; }
.login-sub   { color: rgba(255,255,255,.45); font-size: 12px; margin-top: 4px; }
.login-body  { padding: 26px 28px; }
.login-foot  { background: var(--surface); border-top: 1px solid var(--border); padding: 12px 18px; text-align: center; font-size: 11.5px; color: var(--muted); }

/* ── GRID ────────────────────────────────────────────────── */
.grid { display: grid; gap: 16px; }
.g-4 { grid-template-columns: repeat(4,1fr); }
.g-3 { grid-template-columns: repeat(3,1fr); }
.g-2 { grid-template-columns: repeat(2,1fr); }
.g-1 { grid-template-columns: 1fr; }

/* ── ALERT ───────────────────────────────────────────────── */
.alert { padding: 11px 15px; border-radius: 8px; font-size: 13.5px; display: flex; align-items: flex-start; gap: 8px; margin-bottom: 14px; }
.alert-success { background: #dcfce7; color: #14532d; border: 1px solid #bbf7d0; }
.alert-danger  { background: #fee2e2; color: #7f1d1d; border: 1px solid #fecaca; }
.alert-warning { background: #fef3c7; color: #7a4f00; border: 1px solid #fde68a; }
.alert-info    { background: #dbeafe; color: #1e3a8a; border: 1px solid #bfdbfe; }

/* ── MODAL ───────────────────────────────────────────────── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 2000; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal-box { background: white; border-radius: 12px; width: 100%; max-width: 680px; max-height: 90vh; overflow-y: auto; box-shadow: 0 25px 60px rgba(0,0,0,.35); }
.modal-head { background: var(--navy); color: white; padding: 16px 22px; display: flex; align-items: center; justify-content: space-between; border-radius: 12px 12px 0 0; }
.modal-head-title { font-size: 15px; font-weight: 700; }
.modal-close { background: transparent; border: none; color: white; font-size: 22px; cursor: pointer; line-height: 1; }
.modal-body { padding: 22px; }
.modal-foot { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* ── UTILITIES ───────────────────────────────────────────── */
.mt-1{margin-top:6px} .mt-2{margin-top:12px} .mt-3{margin-top:18px} .mt-4{margin-top:24px}
.mb-1{margin-bottom:6px} .mb-2{margin-bottom:12px} .mb-3{margin-bottom:18px}
.d-flex{display:flex} .align-center{align-items:center} .justify-between{justify-content:space-between}
.gap-1{gap:6px} .gap-2{gap:12px} .gap-3{gap:18px}
.fw-bold{font-weight:700} .fw-semi{font-weight:600}
.text-muted{color:var(--muted)} .text-navy{color:var(--navy)} .text-red{color:var(--red)}
.text-sm{font-size:12px} .text-xs{font-size:11px}
.text-center{text-align:center} .text-right{text-align:right}
.hidden{display:none} .w-100{width:100%}
code{background:#f4f4f4;padding:1px 5px;border-radius:4px;font-size:12px;color:#c41d1d}
hr{border:none;border-top:1px solid var(--border);margin:16px 0}

/* ── SPINNER ─────────────────────────────────────────────── */
.spinner { display: inline-block; width: 18px; height: 18px; border: 2.5px solid rgba(255,255,255,.4); border-top-color: white; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── PRINT ───────────────────────────────────────────────── */
@media print {
  .sidebar, .topbar, .no-print { display: none !important; }
  .main { margin-left: 0 !important; }
  .content { padding: 0 !important; }
  body { background: white !important; }
}

/* ── RESPONSIVE ──────────────────────────────────────────── */
@media (max-width: 900px) {
  .sidebar { transform: translateX(calc(-1 * var(--sw))); }
  .sidebar.mobile-open { transform: translateX(0); }
  .main { margin-left: 0; }
  .g-4 { grid-template-columns: repeat(2,1fr); }
  .g-3 { grid-template-columns: repeat(2,1fr); }
}
@media (max-width: 600px) {
  .g-4, .g-3, .g-2 { grid-template-columns: 1fr; }
  .col-2, .col-3, .col-4 { grid-template-columns: 1fr; }
  .content { padding: 14px; }
}
