/* Control de Souvenirs · Tubos y Barras Huecas
   Paleta tomada del logotipo: azul TBH #093B59, grises acero y blanco. */
:root {
  --navy: #093B59;
  --navy-900: #062A40;
  --navy-700: #0E4C72;
  --navy-100: #E3ECF2;
  --steel-800: #26333D;
  --steel-600: #4F5E6A;
  --steel-400: #8A97A2;
  --steel-200: #D3DAE0;
  --steel-100: #E9EDF0;
  --paper: #F3F5F7;
  --white: #FFFFFF;
  --ok: #2E7250;
  --ok-bg: #E3F1E8;
  --warn: #8A5A12;
  --warn-bg: #FBF0DC;
  --bad: #9C3434;
  --bad-bg: #F8E4E4;
  --display: "Barlow Condensed", "Arial Narrow", "Roboto Condensed", sans-serif;
  --body: "Barlow", "Segoe UI", Roboto, Arial, sans-serif;
  --radius: 4px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--body); font-size: 16px; line-height: 1.5; color: var(--steel-800); background: var(--paper); }
img { max-width: 100%; }
a { color: var(--navy-700); }
:focus-visible { outline: 3px solid #5FA4D6; outline-offset: 2px; }
h1, h2, h3 { font-family: var(--display); color: var(--navy); line-height: 1.15; margin: 0; }
.tnum, td.num, th.num, .data th.num { font-variant-numeric: tabular-nums; text-align: right; }

/* ---------- Estructura ---------- */
.app { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--navy-900); color: #CFDCE6; padding: 28px 0 20px;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.brand { display: block; padding: 0 28px; }
.brand img { width: 150px; display: block; }
.brand-sub { font-family: var(--display); font-weight: 500; font-size: 1.05rem; letter-spacing: .02em; color: #8FB0C7; margin: 10px 28px 28px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  position: relative; display: block; padding: 10px 28px; color: #DCE6EE; text-decoration: none;
  font-family: var(--display); font-weight: 500; font-size: 1.2rem; letter-spacing: .01em;
}
.nav a:hover { background: rgba(255,255,255,.06); color: var(--white); }
.nav a.active { color: var(--white); background: rgba(255,255,255,.08); }
/* marca inclinada como el paralelogramo del logotipo */
.nav a.active::before {
  content: ""; position: absolute; left: 10px; top: 9px; bottom: 9px; width: 7px;
  background: var(--white); transform: skewX(-18deg);
}
.me { margin-top: auto; padding: 18px 28px 0; border-top: 1px solid rgba(255,255,255,.1); display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; align-items: center; }
.me img { width: 36px; height: 36px; border-radius: 50%; }
.me strong { display: block; color: var(--white); font-weight: 500; font-size: .95rem; line-height: 1.25; }
.me span { font-size: .82rem; color: #8FB0C7; }
.me form { grid-column: 1 / -1; }
.link-btn { background: none; border: 0; padding: 4px 0; color: #A9C2D4; font: inherit; font-size: .9rem; text-decoration: underline; cursor: pointer; }
.link-btn:hover { color: var(--white); }

.main { padding: 32px clamp(18px, 4vw, 48px) 64px; min-width: 0; max-width: 1280px; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 24px; margin-bottom: 24px; }
.page-head h1 { font-size: 2.3rem; font-weight: 600; }
.page-actions { display: flex; gap: 10px; flex-wrap: wrap; }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; padding: 14px 0 0; }
  .brand { padding: 0 18px; }
  .brand img { width: 120px; }
  .brand-sub { display: none; }
  .nav { flex-direction: row; overflow-x: auto; margin-top: 12px; }
  .nav a { padding: 10px 16px; white-space: nowrap; font-size: 1.05rem; }
  .nav a.active::before { left: 16px; right: 16px; top: auto; bottom: 0; width: auto; height: 4px; }
  .me { display: none; }
  .page-head h1 { font-size: 1.9rem; }
}

/* ---------- Superficies ---------- */
.panel { background: var(--white); border: 1px solid var(--steel-200); border-radius: var(--radius); }
.panel + .panel, .panel + .grid-2, .grid-2 + .panel { margin-top: 24px; }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--steel-100); }
.panel-head h2 { font-size: 1.35rem; font-weight: 600; }
.panel-head a { font-size: .92rem; }
.panel-body { padding: 20px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; align-items: start; }
.grid-2 > .panel { margin-top: 0; }
@media (max-width: 1050px) { .grid-2 { grid-template-columns: 1fr; } }

/* Cifras del resumen: una sola franja, no tarjetas */
.figures { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); background: var(--navy); color: var(--white); border-radius: var(--radius); margin-bottom: 24px; }
.figures div { padding: 18px 22px; border-left: 1px solid rgba(255,255,255,.14); }
.figures div:first-child { border-left: 0; }
.figures b { display: block; font-family: var(--display); font-weight: 600; font-size: 2.2rem; line-height: 1.05; font-variant-numeric: tabular-nums; }
.figures span { color: #B9CEDC; font-size: .92rem; }
@media (max-width: 760px) {
  .figures { grid-template-columns: 1fr 1fr; }
  .figures div:nth-child(3) { border-left: 0; }
  .figures div:nth-child(n+3) { border-top: 1px solid rgba(255,255,255,.14); }
}

/* ---------- Tablas ---------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: .95rem; }
.data th { text-align: left; font-weight: 600; font-size: .85rem; color: var(--steel-600); background: var(--steel-100); padding: 10px 14px; white-space: nowrap; }
.data td { padding: 10px 14px; border-top: 1px solid var(--steel-100); vertical-align: middle; }
.data tbody tr:hover td { background: #F8FAFB; }
.data tfoot td { font-weight: 600; background: var(--steel-100); border-top: 1px solid var(--steel-200); }
.data .muted, .muted { color: var(--steel-400); }
.data tr.agotado td { color: var(--steel-400); }
.data tr.is-new td { background: var(--navy-100); }
.data a.row-link { color: var(--navy); font-weight: 600; text-decoration: none; }
.data a.row-link:hover { text-decoration: underline; }
.small { font-size: .85rem; }

/* ---------- Estados ---------- */
.badge { display: inline-block; padding: 2px 10px; transform: skewX(-14deg); border-radius: 2px; font-size: .82rem; font-weight: 600; white-space: nowrap; }
.badge > span { display: inline-block; transform: skewX(14deg); }
.badge-proceso { background: var(--warn-bg); color: var(--warn); }
.badge-recibido { background: var(--ok-bg); color: var(--ok); }
.badge-cancelado { background: var(--steel-100); color: var(--steel-600); }
.stock-low { color: var(--warn); font-weight: 600; }
.stock-out { color: var(--bad); font-weight: 600; }

/* ---------- Formularios ---------- */
label { font-weight: 500; font-size: .92rem; color: var(--steel-600); }
.field { display: flex; flex-direction: column; gap: 5px; }
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.input, select.input, textarea.input {
  width: 100%; font: inherit; color: var(--steel-800); background: var(--white);
  border: 1px solid var(--steel-200); border-radius: var(--radius); padding: 9px 12px; min-height: 42px;
}
.input:focus { border-color: var(--navy-700); outline: 2px solid rgba(14,76,114,.18); outline-offset: 0; }
.input.sm { min-height: 36px; padding: 6px 10px; }
.input.qty { width: 92px; text-align: right; font-variant-numeric: tabular-nums; }
.input.price { width: 110px; text-align: right; font-variant-numeric: tabular-nums; }
.input:disabled { background: var(--paper); color: var(--steel-400); }
textarea.input { min-height: 80px; resize: vertical; }
input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--navy); cursor: pointer; }
.search { max-width: 360px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; padding: 14px 20px; border-bottom: 1px solid var(--steel-100); }
.toolbar .spacer { flex: 1; }
.hint { font-size: .85rem; color: var(--steel-400); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 9px 20px;
  font: 600 1rem var(--body); color: var(--white); background: var(--navy); border: 1px solid var(--navy);
  border-radius: var(--radius); text-decoration: none; cursor: pointer;
}
.btn:hover { background: var(--navy-700); border-color: var(--navy-700); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-ghost { background: var(--white); color: var(--navy); border-color: var(--steel-200); }
.btn-ghost:hover { background: var(--navy-100); border-color: var(--navy-100); color: var(--navy); }
.btn-danger { background: var(--white); color: var(--bad); border-color: #E3BDBD; }
.btn-danger:hover { background: var(--bad-bg); border-color: var(--bad-bg); color: var(--bad); }
.btn-lg { min-height: 50px; padding: 12px 26px; font-size: 1.05rem; }
.form-foot { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: flex-end; padding: 16px 20px; border-top: 1px solid var(--steel-100); }

.alert { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 18px; border-left: 4px solid; }
.alert-success { background: var(--ok-bg); color: var(--ok); }
.alert-error { background: var(--bad-bg); color: var(--bad); }
.alert-warning { background: var(--warn-bg); color: var(--warn); }
.alert-info { background: var(--navy-100); color: var(--navy); }

.empty { padding: 36px 20px; text-align: center; color: var(--steel-600); }
.empty p { margin: 0 0 16px; }

/* ---------- Nueva entrega ---------- */
.entrega { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 24px; align-items: start; }
.summary { position: sticky; top: 24px; }
.summary dl { margin: 0; display: grid; grid-template-columns: 1fr auto; gap: 8px 12px; }
.summary dt { color: var(--steel-600); }
.summary dd { margin: 0; font-family: var(--display); font-weight: 600; font-size: 1.5rem; line-height: 1.1; color: var(--navy); text-align: right; font-variant-numeric: tabular-nums; }
.summary ul { list-style: none; margin: 16px 0 0; padding: 14px 0 0; border-top: 1px solid var(--steel-100); font-size: .9rem; max-height: 260px; overflow-y: auto; }
.summary li { display: flex; justify-content: space-between; gap: 10px; padding: 3px 0; }
.summary li b { font-variant-numeric: tabular-nums; }
@media (max-width: 1050px) { .entrega { grid-template-columns: 1fr; } .summary { position: static; } }
tr.selected td { background: var(--navy-100) !important; }
.step { font-family: var(--display); color: var(--steel-400); font-weight: 600; margin-right: 6px; }

/* ---------- Detalle ---------- */
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 18px 24px; margin: 0; }
.facts dt { font-size: .85rem; color: var(--steel-400); }
.facts dd { margin: 2px 0 0; font-weight: 500; overflow-wrap: anywhere; }
.copy-row { display: flex; gap: 8px; }
.copy-row .input { font-size: .85rem; }

/* ---------- Páginas públicas (login, confirmación) ---------- */
.public { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); background: var(--white); }
.public-brand {
  position: relative; background: var(--navy); color: var(--white); padding: clamp(28px, 6vw, 72px);
  display: flex; flex-direction: column; justify-content: space-between; overflow: hidden;
  clip-path: polygon(0 0, 100% 0, 84% 100%, 0 100%);
}
.public-brand img { width: min(240px, 60%); }
.public-brand h1 { color: var(--white); font-size: clamp(2.4rem, 5vw, 4.2rem); font-weight: 700; line-height: 1; max-width: 9ch; }
.public-brand p { color: #B9CEDC; max-width: 30ch; margin: 16px 0 0; font-size: 1.05rem; }
.public-main { display: flex; flex-direction: column; justify-content: center; padding: clamp(28px, 6vw, 80px); max-width: 620px; }
.public-main h2 { font-size: 2rem; font-weight: 600; margin-bottom: 10px; }
.public-main > p { color: var(--steel-600); margin: 0 0 24px; }
.btn-google { background: var(--white); color: var(--steel-800); border: 1px solid var(--steel-200); min-height: 52px; padding: 12px 22px; font-size: 1.02rem; }
.btn-google:hover { background: var(--paper); border-color: var(--steel-400); color: var(--steel-800); }
.btn-google svg { width: 20px; height: 20px; }
@media (max-width: 820px) {
  .public { grid-template-columns: 1fr; }
  .public-brand { clip-path: polygon(0 0, 100% 0, 100% 86%, 0 100%); padding-bottom: 56px; gap: 28px; }
}

@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; } }
@media print {
  .sidebar, .page-actions, .no-print { display: none !important; }
  .app { display: block; }
  .panel { border: 0; }
}
