/* ===== MerchHub · estilos ===== */
:root {
  --navy: #0d4a7c;
  --navy-dark: #0a3d68;
  --blue: #2f80ed;
  --blue-soft: #eaf2fd;
  --blue-text: #1f6fd6;
  --orange: #f59e0b;
  --orange-soft: #fff8ec;
  --orange-text: #b45309;
  --yellow: #fcc419;
  --yellow-soft: #fff6d6;
  --red: #dc2626;
  --red-soft: #fdecec;
  --green: #15803d;
  --green-soft: #e7f6ec;
  --bg: #f4f6f9;
  --card: #ffffff;
  --line: #e3e7ee;
  --line-soft: #eef1f5;
  --text: #1c2430;
  --muted: #5c6776;
  --radius: 10px;
  --sidebar-w: 302px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
}

a { color: inherit; text-decoration: none; }
svg { display: block; }

/* ----- Sidebar ----- */
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: var(--navy);
  color: #fff;
  display: flex;
  flex-direction: column;
  padding: 26px 18px 0;
  z-index: 20;
  overflow-y: auto;
}

.brand { display: flex; align-items: center; gap: 12px; padding: 0 10px 24px; }
.brand-logo { width: 50px; height: 50px; border-radius: 10px; background: #fff; padding: 3px; }
.brand-name { font-size: 20px; font-weight: 700; }
.brand-sub { font-size: 11.5px; opacity: .85; margin-top: 2px; }

.nav { flex: 1; }
.nav-section {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .02em;
  text-transform: uppercase;
  margin: 18px 0 6px;
  opacity: .95;
}
.nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 14px;
  border-radius: 6px;
  font-size: 14px;
  color: #dde8f3;
  transition: background .15s;
}
.nav a:hover { background: rgba(255, 255, 255, .08); }
.nav a.active { background: var(--blue); color: #fff; font-weight: 600; }
.nav a svg { width: 18px; height: 18px; flex: none; }

.sidebar-foot {
  border-top: 1px solid rgba(255, 255, 255, .2);
  padding: 18px 10px;
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
}
.sidebar-foot span { font-size: 12px; opacity: .85; }

/* ----- Main / topbar ----- */
.main { margin-left: var(--sidebar-w); min-height: 100vh; }

.topbar {
  background: #fff;
  border-bottom: 1px solid var(--line);
  padding: 22px 36px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.crumb { font-size: 12px; color: var(--muted); }
.topbar h1 { font-size: 24px; margin: 4px 0 0; font-weight: 700; }
.menu-btn { display: none; border: 0; background: none; font-size: 22px; cursor: pointer; }

.user { display: flex; align-items: center; gap: 14px; cursor: pointer; }
.avatar {
  width: 46px; height: 46px; border-radius: 50%;
  background: var(--blue-soft); color: var(--navy);
  display: grid; place-items: center;
}
.avatar svg { width: 22px; height: 22px; }
.user-name { font-weight: 600; }
.user-area { font-size: 13px; color: var(--muted); margin-top: 3px; }

.content { padding: 24px 32px 40px; max-width: 1300px; }

/* ----- Encabezado de sección ----- */
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 16px; }
.page-head h2 { font-size: 19px; margin: 0 0 6px; font-weight: 600; }
.page-head p { margin: 0; color: var(--muted); font-size: 14.5px; }
.page-head .side { color: var(--muted); font-size: 13px; padding-top: 12px; text-align: right; }

/* ----- Tarjetas ----- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 14px;
  overflow: hidden;
}
.card-head {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
}
.card-head h3 { margin: 0; font-size: 16px; font-weight: 600; }
.card-head .meta { color: var(--muted); font-size: 12.5px; }
.card-body { padding: 16px 22px; }
.card-foot {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 22px;
  border-top: 1px solid var(--line);
  color: var(--muted); font-size: 12.5px;
}
.card-foot svg { width: 15px; height: 15px; color: #1aa3d9; flex: none; }

/* ----- KPIs ----- */
.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; margin-bottom: 18px; }
.kpi {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px 20px; display: flex; align-items: center; gap: 16px; min-height: 108px;
}
.kpi-icon { width: 46px; height: 46px; border-radius: 8px; display: grid; place-items: center; background: var(--blue-soft); color: var(--navy); flex: none; }
.kpi-icon.warn { background: var(--yellow); color: #3b2a00; }
.kpi-icon svg { width: 22px; height: 22px; }
.kpi-title { font-weight: 600; font-size: 14.5px; }
.kpi-sub { font-size: 12px; color: var(--muted); margin-top: 4px; }
.kpi-num { margin-left: auto; font-size: 36px; font-weight: 700; }

/* ----- Tabs ----- */
.tabs { display: flex; gap: 32px; padding: 0 22px; border-bottom: 1px solid var(--line); }
.tab {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 2px 10px;
  border: 0; background: none; cursor: pointer;
  font: inherit; font-size: 15.5px; color: var(--muted);
  border-bottom: 2px solid transparent;
}
.tab svg { width: 18px; height: 18px; }
.tab.active { color: var(--blue-text); border-bottom-color: var(--blue); font-weight: 500; }

/* ----- Formularios ----- */
label.field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px 18px; }
.row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

input, select, textarea {
  font: inherit;
  color: var(--text);
  border: 1px solid #d5dbe4;
  border-radius: 6px;
  padding: 10px 12px;
  background: #fff;
  width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid #b8d4fb; border-color: var(--blue); }
input[readonly] { background: #f7f9fb; color: var(--muted); }
textarea { resize: vertical; min-height: 40px; }

.search { position: relative; }
.search svg { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--muted); }

/* ----- Botones ----- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 0; border-radius: 6px; cursor: pointer;
  font: inherit; font-weight: 600;
  padding: 11px 24px;
  background: var(--blue); color: #fff;
  transition: filter .15s;
}
.btn:hover { filter: brightness(.94); }
.btn svg { width: 16px; height: 16px; }
.btn.lg { font-size: 16px; padding: 12px 26px; }
.btn.ghost { background: #fff; color: var(--navy); border: 1px solid var(--line); padding: 7px 12px; font-weight: 600; }
.btn.light { background: var(--blue-soft); color: var(--blue-text); padding: 5px 10px; font-weight: 500; }
.btn.ok { background: var(--green-soft); color: var(--green); padding: 5px 10px; }
.btn.no { background: var(--red-soft); color: var(--red); padding: 5px 10px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.icon-btn { border: 0; background: none; cursor: pointer; color: var(--red); padding: 4px; }
.icon-btn svg { width: 18px; height: 18px; }
.link-btn { border: 0; background: none; cursor: pointer; color: var(--blue-text); font: inherit; font-weight: 500; padding: 4px 6px; }

/* Tipo de registro (toggle) */
.toggle {
  display: inline-flex; align-items: center; gap: 10px;
  border: 1px solid var(--line); border-radius: 6px; padding: 6px 12px 6px 6px;
  background: #fafbfc; cursor: pointer; font: inherit; font-size: 15px; color: var(--muted);
}
.toggle .pill { font-size: 12.5px; font-weight: 600; padding: 4px 8px; border-radius: 4px; background: #eceff3; color: var(--muted); border: 1px solid var(--line); }
.toggle.on { border: 2px solid var(--blue); background: var(--blue-soft); color: var(--navy); font-weight: 500; }
.toggle.on .pill { background: var(--blue); color: #fff; border-color: var(--blue); }

/* ----- Tablas ----- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left; font-weight: 500; color: var(--muted); font-size: 13.5px;
  padding: 11px 12px; border-bottom: 1px solid var(--line); background: #fafbfc;
  white-space: nowrap;
}
td { padding: 9px 12px; border-bottom: 1px solid var(--line-soft); font-size: 14.5px; vertical-align: middle; }
th:first-child, td:first-child { padding-left: 22px; }
tr:last-child td { border-bottom: 0; }
tr.alert td { background: var(--yellow-soft); }
td.strong { font-weight: 600; }
td.num { white-space: nowrap; }
.empty { text-align: center; color: var(--muted); padding: 24px; }

/* Tabla de ingreso (auto / manual) */
.entry { border: 1px solid var(--line); margin: 0 8px; border-radius: 4px; }
.legend {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 10px 12px; background: #f6f8fa; border-bottom: 1px solid var(--line);
  font-size: 13px; color: var(--muted);
}
.legend .mov { margin-left: auto; font-size: 15px; color: var(--text); }
.tag { display: inline-block; font-size: 12.5px; font-weight: 600; padding: 2px 7px; border-left: 3px solid; border-radius: 3px; }
.tag.auto { border-color: var(--blue); color: var(--navy); background: var(--blue-soft); }
.tag.manual { border-color: var(--orange); color: #6b3d00; background: var(--orange-soft); }

.entry table { table-layout: fixed; min-width: 860px; }
.entry th, .entry td { border-right: 1px solid var(--line); padding: 8px 7px; vertical-align: top; }
.entry th:first-child, .entry td:first-child { padding-left: 7px; }
.entry th { background: none; color: var(--text); font-size: 14px; white-space: normal; }
.entry th .tag { display: block; width: fit-content; margin-bottom: 4px; }
.entry .c-auto { background: var(--blue-soft); }
.entry .c-manual { background: var(--orange-soft); }
.entry td { height: 110px; }
.entry .hint { display: block; font-size: 12.5px; margin-bottom: 4px; }
.entry .c-auto .hint { color: var(--blue-text); }
.entry .c-manual .hint { color: var(--orange-text); }
.entry td input, .entry td textarea {
  padding: 4px 6px; border: 1px solid transparent; background: transparent; font-weight: 600;
}
.entry td input:hover, .entry td textarea:hover { border-color: #e6c99a; background: #fff; }
.entry td textarea { font-weight: 400; min-height: 54px; }
.entry .val { font-size: 14.5px; }
.entry .row-del { margin-top: 6px; color: var(--muted); }
.entry-foot { display: flex; align-items: center; gap: 12px; padding: 10px 12px; background: #fafbfc; border-top: 1px solid var(--line); font-size: 12.5px; color: var(--muted); }

.form-actions { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 22px 8px 12px; }
.note { display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: var(--blue-soft); font-size: 14px; }
.note .dot { width: 20px; height: 20px; border-radius: 50%; background: var(--blue); color: #fff; display: grid; place-items: center; font-size: 12px; font-weight: 700; }

/* Solicitud: filas de materiales */
.req-table { border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.req-table td { padding: 7px 4px; }
.req-table td:first-child { padding-left: 12px; }
.req-table th:first-child { padding-left: 12px; }
.req-table input, .req-table select { padding: 7px 10px; }
.add-row { display: flex; align-items: center; gap: 8px; padding: 10px 14px; background: var(--blue-soft); color: var(--blue-text); font-weight: 600; font-size: 15px; border: 0; width: 100%; cursor: pointer; border-top: 1px solid var(--line); }
.add-row:hover { filter: brightness(.97); }
.subtle { font-size: 12.5px; color: var(--muted); margin: 2px 0 10px; }
.section-label { font-weight: 600; margin-top: 18px; }

/* ----- Badges ----- */
.badge { display: inline-block; padding: 4px 10px; border-radius: 4px; font-size: 13.5px; font-weight: 500; }
.badge.salida, .badge.rechazada { background: var(--red-soft); color: var(--red); }
.badge.entrada, .badge.pendiente { background: var(--blue-soft); color: var(--navy); font-weight: 600; }
.badge.aprobada, .badge.entregada { background: var(--green-soft); color: var(--green); font-weight: 600; }
.badge.reponer { background: var(--yellow); color: #2b2100; font-weight: 700; display: flex; align-items: center; gap: 6px; }
.badge.reponer svg { width: 15px; height: 15px; }
.badge.ok-punto { background: var(--blue-soft); color: var(--navy); font-weight: 700; display: block; }
.qty-in { color: var(--navy); font-weight: 700; }
.qty-out { color: var(--red); font-weight: 700; }

/* ----- Placeholder ----- */
.placeholder { text-align: center; padding: 60px 20px; color: var(--muted); }
.placeholder h3 { color: var(--text); margin-bottom: 6px; }

/* ----- Toast & modal ----- */
.toast {
  position: fixed; right: 24px; bottom: 24px; z-index: 50;
  background: var(--text); color: #fff; padding: 12px 18px; border-radius: 8px;
  opacity: 0; transform: translateY(10px); transition: all .25s; pointer-events: none; max-width: 420px;
}
.toast.show { opacity: 1; transform: none; }
.toast.error { background: var(--red); }

.modal-bg { position: fixed; inset: 0; background: rgba(15, 25, 40, .45); display: none; align-items: center; justify-content: center; z-index: 40; padding: 16px; }
.modal-bg.show { display: flex; }
.modal { background: #fff; border-radius: var(--radius); width: 100%; max-width: 460px; padding: 22px; }
.modal h3 { margin: 0 0 14px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.modal .field { margin-bottom: 12px; }

/* ----- Login ----- */
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 16px;
  background: linear-gradient(160deg, var(--navy) 0 45%, var(--bg) 45%);
}
.login-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(10, 40, 80, .15);
  width: 100%;
  max-width: 400px;
  padding: 32px 30px 22px;
  text-align: center;
}
.login-logo { width: 150px; margin-bottom: 8px; }
.login-card h1 { font-size: 22px; margin: 6px 0 4px; }
.login-card form { display: flex; flex-direction: column; gap: 14px; text-align: left; margin-top: 18px; }
.login-card .btn { width: 100%; margin-top: 4px; }
.login-error { color: var(--red); font-size: 13.5px; min-height: 18px; }
.login-foot { margin-top: 20px; padding-top: 14px; border-top: 1px solid var(--line); font-size: 12.5px; color: var(--muted); }

.logout-btn { border: 1px solid var(--line); background: #fff; color: var(--muted); border-radius: 6px; padding: 7px 12px; font: inherit; font-size: 13px; cursor: pointer; }
.logout-btn:hover { color: var(--red); border-color: #f3c4c4; }

/* ----- Responsive ----- */
@media (max-width: 1000px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; }
  .main { margin-left: 0; }
  .menu-btn { display: block; }
  .topbar { padding: 16px; }
  .content { padding: 16px; }
  .kpis, .grid-3 { grid-template-columns: 1fr; }
  .user-area { display: none; }
}
