/* ═══════════════════════════════════════════════════════════
   MAXILO — Clinical Design System
   ═══════════════════════════════════════════════════════════ */

/* ── 1. Variables ──────────────────────────────────────────── */
:root {
  /* Brand */
  --navy:           #1b3a5c;
  --navy-hover:     #162f4a;
  --green:          #1a7a3a;
  --green-hover:    #155f2d;

  /* Surfaces */
  --bg:             #f0f2f5;
  --card:           #ffffff;
  --border:         #dde3ea;
  --border-focus:   #b8d8f2;

  /* Accent (selected / active) */
  --accent-bg:      #eaf4fb;
  --accent-border:  #b8d8f2;

  /* Text */
  --text:           #1a2633;
  --label:          #6a8aaa;
  --muted:          #8ca3b8;

  /* Secondary button */
  --btn-sec-bg:     #ffffff;
  --btn-sec-border: #c8dae8;
  --btn-sec-color:  #2a5a8a;
}

/* ── 2. Reset + Base ───────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html { font-size: 16px; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-weight: 400;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1 { font-size: 20px; font-weight: 600; margin: 0 0 8px; color: var(--text); }
h2 { font-size: 15px; font-weight: 600; margin: 0 0 16px; color: var(--text); }
h3 { font-size: 13px; font-weight: 700; margin: 0 0 10px; color: var(--label); text-transform: uppercase; letter-spacing: 0.05em; }
p  { margin: 0; }
a  { color: var(--navy); }

/* ── 3. Navbar ─────────────────────────────────────────────── */
.site-header {
  background: var(--navy);
  height: 56px;
  display: flex;
  align-items: center;
  padding: 0 28px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 200;
  box-shadow: 0 2px 8px rgba(0,0,0,0.20);
}
.site-header .brand {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
  text-decoration: none;
}
.brand-logo {
  width: 34px;
  height: 34px;
  background: rgba(255,255,255,0.14);
  border: 1px solid rgba(255,255,255,0.20);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  color: #fff;
  letter-spacing: -0.5px;
  flex-shrink: 0;
}
.brand-name {
  font-weight: 600;
  font-size: 15px;
  color: #fff;
  line-height: 1.1;
}
.brand-sub {
  font-size: 11px;
  color: rgba(255,255,255,0.55);
  font-weight: 400;
}
.session-info {
  display: flex;
  align-items: center;
  gap: 24px;
  font-size: 12px;
  color: rgba(255,255,255,0.60);
  flex-shrink: 0;
}
.session-info .si-item { display: flex; flex-direction: column; align-items: flex-end; gap: 1px; }
.session-info .si-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em; color: rgba(255,255,255,0.40); }
.session-info .si-value { font-size: 13px; font-weight: 500; color: #fff; }

/* ── 4. Page wrapper ───────────────────────────────────────── */
.page { padding: 28px 24px; }
.wrap { max-width: 1100px; margin: 0 auto; }
.login-page {
  min-height: calc(100vh - 56px);
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at top left, rgba(184,216,242,0.55), transparent 30%),
    linear-gradient(160deg, #edf3f8 0%, #f7fafc 45%, #e7eef5 100%);
}
.login-shell {
  width: 100%;
  max-width: 520px;
}
.login-panel {
  background: rgba(255,255,255,0.92);
  border: 1px solid rgba(221,227,234,0.95);
  border-radius: 20px;
  padding: 40px;
  box-shadow: 0 20px 50px rgba(27,58,92,0.12);
}
.login-kicker {
  display: inline-block;
  margin-bottom: 14px;
  padding: 6px 10px;
  border-radius: 999px;
  background: #eaf4fb;
  color: #2a5a8a;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.login-copy {
  margin-bottom: 24px;
  color: var(--label);
  font-size: 15px;
}
.login-btn {
  min-height: 46px;
  padding: 0 24px;
}
.login-footnote {
  margin-top: 14px;
  color: var(--muted);
  font-size: 13px;
}
.login-warning {
  padding: 14px 16px;
  border-radius: 10px;
  background: #fff4e5;
  color: #8a5a15;
  border: 1px solid #f0d2a6;
  font-size: 14px;
}

.page-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.page-header h1 { margin: 0; }

/* ── 5. Botones ────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 18px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-weight: 500;
  font-size: 14px;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s, box-shadow 0.15s, border-color 0.15s;
  line-height: 1;
}
.btn.primary        { background: var(--navy);  color: #fff; }
.btn.primary:hover  { background: var(--navy-hover); box-shadow: 0 2px 8px rgba(27,58,92,0.28); }
.btn.success        { background: var(--green); color: #fff; }
.btn.success:hover  { background: var(--green-hover); box-shadow: 0 2px 8px rgba(26,122,58,0.28); }
.btn.secondary      { background: var(--btn-sec-bg); color: var(--btn-sec-color); border: 1px solid var(--btn-sec-border); }
.btn.secondary:hover{ background: var(--accent-bg); border-color: var(--accent-border); }
.btn.danger         { background: #c62828; color: #fff; }
.btn.danger:hover   { background: #a31f1f; }
.btn.ghost          { background: transparent; color: var(--label); border: 1px solid var(--border); }
.btn.ghost:hover    { background: var(--bg); }
.btn.sm             { min-height: 30px; padding: 0 12px; font-size: 13px; }
.btn.full           { width: 100%; justify-content: center; }

/* ── 6. Inputs / formularios ───────────────────────────────── */
label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--label);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}
input[type="text"],
input[type="date"],
input[type="number"],
select,
textarea {
  width: 100%;
  height: 44px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
  -webkit-appearance: none;
}
input[type="text"]:focus,
input[type="date"]:focus,
input[type="number"]:focus,
select:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(184,216,242,0.40);
}
select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%236a8aaa' d='M1 1l5 5 5-5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; }
select:disabled   { background-color: #f4f6f9; color: var(--muted); cursor: not-allowed; }
.field            { margin-bottom: 20px; }
.field-hint       { font-size: 12px; color: var(--muted); margin-top: 5px; line-height: 1.4; }

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button { opacity: 1; }

/* ── 7. Cards genéricas ────────────────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
}

/* ── 8. Tabla ──────────────────────────────────────────────── */
table               { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td              { padding: 11px 10px; border-bottom: 1px solid var(--border); text-align: left; }
th                  { background: #f4f7fa; font-size: 11px; font-weight: 600; color: var(--label); text-transform: uppercase; letter-spacing: 0.05em; }
tr:last-child td    { border-bottom: none; }
td.total            { font-weight: 700; color: var(--navy); }

/* ── 9. Modal ──────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 500;
  justify-content: center;
  align-items: center;
}
.modal-overlay.visible { display: flex; }
.modal {
  background: #fff;
  border-radius: 14px;
  padding: 28px 32px;
  max-width: 440px;
  width: 90%;
  box-shadow: 0 12px 40px rgba(0,0,0,0.20);
}
.modal h3          { font-size: 17px; font-weight: 600; margin: 0 0 8px; color: var(--text); text-transform: none; letter-spacing: 0; }
.modal p           { font-size: 14px; color: var(--label); margin: 0 0 24px; }
.modal-actions     { display: flex; gap: 10px; justify-content: flex-end; }

/* ── 10. Panels / filtros ──────────────────────────────────── */
.filters-panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px 24px;
  margin-bottom: 24px;
}
.filters-panel > h2 {
  font-size: 11px;
  font-weight: 700;
  color: var(--label);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 0 0 16px;
}
.filters-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}
.filter-group              { display: flex; flex-direction: column; }
.filter-group label        { font-size: 11px; }
.filter-group input,
.filter-group select       { height: 38px; }
.filter-actions            { display: flex; gap: 8px; margin-top: 16px; }

/* ── 11. Back link ─────────────────────────────────────────── */
a.back, button.back {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--label);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  font-family: inherit;
  transition: color 0.15s;
}
a.back:hover, button.back:hover { color: var(--navy); }

/* ── 12. Badge ─────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  line-height: 1.6;
}
.badge.blue   { background: var(--accent-bg); color: var(--navy); border: 1px solid var(--accent-border); }
.badge.green  { background: #e8f5ee; color: var(--green); border: 1px solid #a8d5b8; }

/* ── 13. Helpers ───────────────────────────────────────────── */
.results-count { font-size: 13px; color: var(--muted); margin-bottom: 16px; }
.empty         { color: var(--muted); text-align: center; padding: 40px 0; font-size: 14px; }
.muted         { color: var(--label); font-size: 13px; }
.error-msg {
  background: #fff5f5;
  border: 1px solid #fdc5c5;
  border-radius: 8px;
  padding: 12px 16px;
  color: #c62828;
  font-size: 14px;
  margin-bottom: 20px;
}


/* ════════════════════════════════════════════════════
   PAGE: INICIO
   ════════════════════════════════════════════════════ */
.inicio-wrap  { max-width: 900px; margin: 0 auto; }
.inicio-intro { font-size: 14px; color: var(--label); margin-bottom: 32px; }

.inicio-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}
@media (max-width: 680px) { .inicio-grid { grid-template-columns: 1fr; } }

.inicio-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: box-shadow 0.15s, border-color 0.15s;
}
.inicio-card:hover {
  border-color: var(--accent-border);
  box-shadow: 0 4px 16px rgba(27,58,92,0.08);
}
.inicio-card h2    { font-size: 16px; font-weight: 600; color: var(--text); margin: 0; text-transform: none; letter-spacing: 0; }
.inicio-card p     { font-size: 13px; color: var(--label); flex: 1; }
.inicio-card .btn  { align-self: flex-start; margin-top: 12px; }


/* ════════════════════════════════════════════════════
   PAGE: FABRICANTES
   ════════════════════════════════════════════════════ */
.fabricantes-wrap  { max-width: 600px; margin: 0 auto; }
.fabricantes-list  { display: flex; flex-direction: column; gap: 10px; }

.fab-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 80px;
  cursor: pointer;
  text-decoration: none;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
.fab-card:hover {
  border-color: var(--accent-border);
  background: #f0f7ff;
  box-shadow: 0 2px 12px rgba(27,58,92,0.08);
}
.fab-card img  { max-height: 48px; max-width: 200px; object-fit: contain; }
.fab-card span { font-weight: 600; font-size: 16px; color: var(--text); }

@media (max-width: 720px) {
  .site-header { padding: 0 16px; }
  .page { padding: 20px 16px; }
  .session-info { gap: 12px; }
  .session-info .si-item { display: none; }
  .login-panel { padding: 28px 22px; }
}


/* ════════════════════════════════════════════════════
   PAGE: BANDEJAS
   ════════════════════════════════════════════════════ */
.bandejas-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 18px;
}
.bandeja-link { text-decoration: none; color: inherit; display: block; }
.bandeja-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  transition: border-color 0.15s, box-shadow 0.15s;
  height: 100%;
}
.bandeja-card:hover {
  border-color: var(--accent-border);
  box-shadow: 0 4px 16px rgba(27,58,92,0.10);
}
.bandeja-card-img   { width: 100%; height: 200px; object-fit: cover; background: #f0f3f7; display: block; }
.bandeja-card-body  { padding: 14px 16px; }
.bandeja-card-title { font-weight: 600; font-size: 15px; color: var(--text); margin-bottom: 4px; }
.bandeja-card-code  { font-size: 12px; color: var(--muted); }


/* ════════════════════════════════════════════════════
   PAGE: BANDEJA DETALLE
   ════════════════════════════════════════════════════ */
.detail-layout {
  display: flex;
  gap: 20px;
  align-items: flex-start;
}
.detail-main  { flex: 1; min-width: 0; }

.detail-panel {
  width: 320px;
  flex-shrink: 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: sticky;
  top: 72px;
  max-height: calc(100vh - 88px);
}
@media (max-width: 980px) {
  .detail-layout { flex-direction: column; }
  .detail-panel  { width: 100%; position: static; max-height: none; }
}

/* Tray view card */
.tray-view { background: var(--card); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.tray-header { padding: 14px 16px 0; display: flex; align-items: center; justify-content: space-between; }
.tray-title  { font-weight: 600; font-size: 14px; color: var(--text); }

/* View tabs */
.view-tabs { display: flex; border-bottom: 1px solid var(--border); }
.view-tab {
  flex: 1;
  padding: 11px 12px;
  text-align: center;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--label);
  cursor: pointer;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.15s, border-color 0.15s;
}
.view-tab.active        { color: var(--navy); border-bottom-color: var(--navy); font-weight: 600; }
.view-tab:hover:not(.active) { color: var(--text); }

/* Tray canvas */
.tray-body   { padding: 12px; }
.tray-canvas { position: relative; width: 100%; }
.tray-canvas img { width: 100%; display: block; border-radius: 8px; }
.tray-canvas svg { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }
.area-shape  { fill: transparent; stroke: transparent; cursor: pointer; }

/* Product list (listado view) */
.product-list         { display: none; flex-direction: column; gap: 6px; max-height: 560px; overflow-y: auto; padding: 12px; }
.product-list.visible { display: flex; }
.product-list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.product-list-item:hover    { border-color: var(--accent-border); background: var(--accent-bg); }
.product-list-item.selected { border-color: var(--accent-border); background: var(--accent-bg); }
.product-list-item img      { width: 44px; height: 44px; object-fit: contain; border-radius: 6px; border: 1px solid var(--border); background: #f9f9f9; flex-shrink: 0; }
.product-list-item .no-img  { width: 44px; height: 44px; border-radius: 6px; border: 1px solid var(--border); background: #f0f3f7; flex-shrink: 0; }
.product-list-info           { flex: 1; min-width: 0; }
.product-list-info .cat      { font-size: 10px; color: var(--muted); text-transform: uppercase; font-weight: 600; letter-spacing: 0.04em; }
.product-list-info .modelo   { font-size: 13px; font-weight: 600; color: var(--text); }
.product-list-info .ref      { font-size: 12px; color: var(--muted); }

/* Panel sections */
.panel-section           { padding: 14px 16px; border-bottom: 1px solid var(--border); }
.panel-section:last-child { border-bottom: none; }
.panel-section > h3      { margin-bottom: 10px; }
.panel-cart              { flex: 1; overflow-y: auto; min-height: 0; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.panel-cart > h3         { font-size: 11px; font-weight: 700; color: var(--label); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 10px; }

/* Selected product card */
.product-card {
  border: 1px solid var(--accent-border);
  background: var(--accent-bg);
  border-radius: 8px;
  padding: 12px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.product-card .pc-info  { flex: 1; min-width: 0; }
.product-card .pc-cat   { font-size: 10px; color: var(--muted); text-transform: uppercase; font-weight: 700; letter-spacing: 0.04em; margin-bottom: 3px; }
.product-card .pc-name  { font-weight: 600; font-size: 13px; color: var(--text); margin-bottom: 2px; }
.product-card .pc-ref   { font-size: 12px; color: var(--muted); }
.product-card img {
  width: 68px;
  height: 68px;
  object-fit: contain;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #fff;
  flex-shrink: 0;
}

/* Quantity row */
.qty-row       { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
.qty-row label { font-size: 11px; white-space: nowrap; margin: 0; flex-shrink: 0; }
.qty-row input[type="number"] { width: 68px; height: 36px; text-align: center; flex-shrink: 0; }

/* Cart */
.cart-list  { list-style: none; padding: 0; margin: 0; }
.cart-item  { display: flex; align-items: center; gap: 6px; padding: 7px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.cart-item:last-child  { border-bottom: none; }
.cart-name  { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.cart-qty   { font-weight: 600; color: var(--navy); min-width: 22px; text-align: center; font-size: 13px; }
.cart-btn   {
  width: 26px; height: 26px;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  font-family: inherit;
  color: var(--text);
  transition: background 0.12s, border-color 0.12s;
}
.cart-btn:hover   { background: var(--bg); }
.cart-remove      { border-color: #fdc5c5; color: #c62828; }
.cart-remove:hover { background: #fff5f5; }
.cart-empty { font-size: 13px; color: var(--muted); text-align: center; padding: 12px 0; }

/* Panel footer */
.panel-footer { padding: 14px 16px; }
.panel-footer .btn { width: 100%; justify-content: center; min-height: 40px; font-size: 14px; }


/* ════════════════════════════════════════════════════
   PAGE: HISTORIAL
   ════════════════════════════════════════════════════ */
.historial-wrap { max-width: 860px; margin: 0 auto; }

.record-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 22px;
  margin-bottom: 12px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  transition: border-color 0.3s, box-shadow 0.3s;
}
.record-info p           { margin: 3px 0; font-size: 14px; color: var(--text); }
.record-info p strong    { font-weight: 600; }
.rec-label               { color: var(--label); font-weight: 400; }
.record-actions          { display: flex; flex-direction: column; gap: 8px; flex-shrink: 0; }
.record-card.destacada   { border-color: var(--navy); box-shadow: 0 0 0 3px rgba(27,58,92,0.12); }


/* ════════════════════════════════════════════════════
   PAGE: INFORMES
   ════════════════════════════════════════════════════ */
.informes-wrap  { max-width: 940px; margin: 0 auto; }
.result-panel   { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 20px 24px; }
.result-header  { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 20px; flex-wrap: wrap; gap: 12px; }
.result-header h2 { font-size: 16px; margin: 0; text-transform: none; letter-spacing: 0; color: var(--text); font-weight: 600; }
.result-meta    { font-size: 13px; color: var(--muted); margin-top: 4px; }


/* ════════════════════════════════════════════════════
   PAGE: REGISTRO RESUMEN
   ════════════════════════════════════════════════════ */
.resumen-wrap     { max-width: 720px; margin: 0 auto; }
.resumen-data     { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 0 24px; margin-bottom: 20px; overflow: hidden; }
.resumen-field    { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.resumen-field:last-child { border-bottom: none; }
.resumen-field dt { width: 180px; flex-shrink: 0; font-size: 11px; font-weight: 700; color: var(--label); text-transform: uppercase; letter-spacing: 0.05em; padding-top: 2px; }
.resumen-field dd { margin: 0; color: var(--text); }
.resumen-table    { background: var(--card); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; margin-bottom: 24px; }
.resumen-actions  { display: flex; gap: 12px; flex-wrap: wrap; }


/* ════════════════════════════════════════════════════
   PRINT
   ════════════════════════════════════════════════════ */
@media print {
  .site-header, .resumen-actions, .btn, button { display: none !important; }
  body        { background: #fff !important; color: #000; }
  .resumen-data, .resumen-table { border: 1px solid #ddd !important; box-shadow: none; }
  table, th, td { border: 1px solid #ddd !important; }
  .page       { padding: 0 !important; }
}
