/* =========================================================================
   Tecnovo S.A. — estilos (mockup)
   Paleta tomada del logo: azul corporativo + naranja yema.
   ========================================================================= */
:root {
  /* marca */
  --brand-900: #16263d;
  --brand-800: #1e3350;   /* azul oscuro (logo) */
  --brand-700: #284670;
  --brand-600: #335a8c;
  --brand-500: #457ac6;   /* azul medio (logo) */
  --brand-400: #6f9bd6;
  --brand-100: #e8eef7;
  --brand-50:  #f3f6fb;

  --accent-600: #e88a00;
  --accent-500: #ff9900;  /* naranja yema (logo) */
  --accent-400: #faa41e;
  --accent-100: #ffeccc;

  /* tinta / superficies */
  --ink-1: #1b2533;
  --ink-2: #5a6b80;
  --ink-3: #8b99ab;
  --line:  #e4e9f0;
  --line-2:#eef2f7;
  --bg:    #f5f7fb;
  --card:  #ffffff;

  /* estados */
  --slate:  #64748b; --slate-bg:#eef1f5;
  --blue:   #2563eb; --blue-bg:#e6efff;
  --amber:  #b45309; --amber-bg:#fef0d9;
  --violet: #6d28d9; --violet-bg:#efe7fe;
  --green:  #15803d; --green-bg:#e3f5ea;
  --red:    #dc2626; --red-bg:#fde8e8;

  --radius: 12px;
  --shadow-sm: 0 1px 2px rgba(16,32,64,.06), 0 1px 3px rgba(16,32,64,.05);
  --shadow:    0 4px 16px rgba(16,32,64,.08);
  --shadow-lg: 0 18px 50px rgba(16,32,64,.22);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink-1);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}
body.no-scroll { overflow: hidden; }
a { color: var(--brand-600); text-decoration: none; }
.icon { flex: 0 0 auto; }

/* ===================== Layout shell ===================== */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }

.sidebar {
  background: linear-gradient(180deg, var(--brand-800), var(--brand-900));
  color: #cdd8e8;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.sidebar .brand {
  display: flex; align-items: center; gap: 11px;
  margin: 14px 14px 8px; padding: 11px 14px;
  background: #fff; border-radius: 12px;
  box-shadow: 0 2px 10px rgba(0,0,0,.18);
}
.sidebar .brand img {
  width: 38px; height: 38px; object-fit: contain; flex: 0 0 auto;
}
.sidebar .brand .bname { font-weight: 800; color: var(--brand-800); font-size: 18px; letter-spacing: .2px; line-height: 1.05; }
.sidebar .brand .btag { font-size: 11px; color: var(--brand-500); font-weight: 600; margin-top: 1px; }

.nav-section { padding: 6px 12px; }
.nav-section .nav-title {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .12em;
  color: #7d90ab; padding: 14px 10px 6px; font-weight: 700;
}
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 11px; border-radius: 9px; cursor: pointer;
  color: #c4d0e2; font-weight: 500; margin: 1px 0;
  transition: background .12s, color .12s;
}
.nav-item:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav-item.active { background: var(--brand-500); color: #fff; box-shadow: var(--shadow-sm); }
.nav-item .count {
  margin-left: auto; background: var(--accent-500); color: #3d2600;
  font-size: 11px; font-weight: 800; border-radius: 999px; padding: 1px 7px;
}
.nav-item.active .count { background: #fff; color: var(--brand-700); }

.sidebar .spacer { flex: 1; }
.sidebar .side-foot { padding: 14px; border-top: 1px solid rgba(255,255,255,.08); }

/* ===================== Topbar ===================== */
.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex; align-items: center; gap: 16px;
  background: var(--card); border-bottom: 1px solid var(--line);
  padding: 12px 26px; position: sticky; top: 0; z-index: 20;
}
.topbar .page-title { font-size: 18px; font-weight: 700; }
.topbar .page-sub { font-size: 12.5px; color: var(--ink-3); margin-top: 1px; }
.topbar .grow { flex: 1; }

.role-switch {
  display: flex; align-items: center; gap: 8px;
  background: var(--brand-50); border: 1px solid var(--line);
  border-radius: 10px; padding: 5px 10px 5px 12px;
}
.role-switch .avatar {
  width: 30px; height: 30px; border-radius: 50%; flex: 0 0 auto;
  display: grid; place-items: center; font-weight: 700; font-size: 12px; color: #fff;
}
.role-switch select {
  border: none; background: transparent; font-family: inherit; font-size: 13px;
  font-weight: 600; color: var(--ink-1); cursor: pointer; outline: none;
}
.role-pill {
  font-size: 10.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .04em;
  padding: 2px 8px; border-radius: 999px;
}
.role-pill.admin { background: var(--brand-100); color: var(--brand-700); }
.role-pill.comprador { background: var(--accent-100); color: var(--accent-600); }

.content { padding: 24px 26px 60px; max-width: 1280px; width: 100%; }

/* ===================== Botones ===================== */
.btn {
  display: inline-flex; align-items: center; gap: 7px; justify-content: center;
  border: 1px solid transparent; border-radius: 9px; cursor: pointer;
  font-family: inherit; font-size: 13px; font-weight: 600; padding: 9px 14px;
  transition: background .12s, border-color .12s, box-shadow .12s, transform .05s;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand-500); color: #fff; }
.btn-primary:hover { background: var(--brand-600); }
.btn-accent { background: var(--accent-500); color: #3d2600; }
.btn-accent:hover { background: var(--accent-600); color: #fff; }
.btn-ghost { background: #fff; border-color: var(--line); color: var(--ink-1); }
.btn-ghost:hover { background: var(--brand-50); border-color: var(--brand-400); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-sm { padding: 6px 10px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.icon-btn {
  display: inline-grid; place-items: center; width: 32px; height: 32px;
  border: 1px solid transparent; background: transparent; border-radius: 8px;
  cursor: pointer; color: var(--ink-2);
}
.icon-btn:hover { background: var(--brand-50); color: var(--brand-600); }

/* ===================== Cards / grid ===================== */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
}
.card-pad { padding: 18px; }
.section-head {
  display: flex; align-items: center; gap: 12px; margin-bottom: 16px;
}
.section-head h2 { font-size: 16px; margin: 0; font-weight: 700; }
.section-head .grow { flex: 1; }

.grid { display: grid; gap: 16px; }
.grid-cards { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px,1fr)); gap: 14px; margin-bottom: 22px; }
.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow-sm); display: flex; flex-direction: column; gap: 2px;
}
.stat .v { font-size: 26px; font-weight: 800; line-height: 1; color: var(--brand-800); }
.stat .l { font-size: 12px; color: var(--ink-3); font-weight: 600; }
.stat .ic { width: 36px; height: 36px; border-radius: 9px; display: grid; place-items: center; margin-bottom: 8px; }

/* ===================== Tablas ===================== */
.table-wrap { overflow: auto; border-radius: var(--radius); border: 1px solid var(--line); background: #fff; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tbl th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--ink-3); font-weight: 700; padding: 11px 14px; background: var(--brand-50);
  border-bottom: 1px solid var(--line); white-space: nowrap;
}
table.tbl td { padding: 12px 14px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
table.tbl tr:last-child td { border-bottom: none; }
table.tbl tbody tr.clickable { cursor: pointer; }
table.tbl tbody tr.clickable:hover { background: var(--brand-50); }
.t-mono { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--brand-700); white-space: nowrap; }
.t-muted { color: var(--ink-3); }
.t-right { text-align: right; }

/* ===================== Badges ===================== */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; font-weight: 700; padding: 3px 9px; border-radius: 999px;
  background: var(--slate-bg); color: var(--slate); white-space: nowrap;
}
.badge .icon { width: 13px; height: 13px; }
.badge-slate  { background: var(--slate-bg);  color: var(--slate); }
.badge-blue   { background: var(--blue-bg);   color: var(--blue); }
.badge-amber  { background: var(--amber-bg);  color: var(--amber); }
.badge-violet { background: var(--violet-bg); color: var(--violet); }
.badge-green  { background: var(--green-bg);  color: var(--green); }
.badge-red    { background: var(--red-bg);    color: var(--red); }
.chip {
  display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 600;
  padding: 3px 9px; border-radius: 999px; background: var(--brand-100); color: var(--brand-700);
}

/* ===================== Forms ===================== */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink-2); margin-bottom: 5px; }
.input, select.input, textarea.input {
  width: 100%; border: 1px solid var(--line); border-radius: 9px; padding: 9px 11px;
  font-family: inherit; font-size: 13.5px; color: var(--ink-1); background: #fff; outline: none;
  transition: border-color .12s, box-shadow .12s;
}
.input:focus, select.input:focus, textarea.input:focus {
  border-color: var(--brand-400); box-shadow: 0 0 0 3px var(--brand-100);
}
textarea.input { resize: vertical; min-height: 64px; }
.qty-input { width: 92px; text-align: right; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.help { font-size: 11.5px; color: var(--ink-3); margin-top: 4px; }

/* ===================== Catálogo (cards de producto) ===================== */
.prod-card {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 15px; display: flex; flex-direction: column; gap: 8px; box-shadow: var(--shadow-sm);
  transition: border-color .12s, box-shadow .12s, transform .08s;
}
.prod-card:hover { border-color: var(--brand-400); box-shadow: var(--shadow); }
.prod-card .pthumb {
  width: 44px; height: 44px; border-radius: 10px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--brand-100), #fff); color: var(--brand-600); font-weight: 800;
  border: 1px solid var(--line);
}
.prod-card .sku { font-size: 11px; color: var(--ink-3); font-weight: 700; letter-spacing: .03em; }
.prod-card .pname { font-weight: 700; font-size: 14px; line-height: 1.25; }
.prod-card .pmeta { font-size: 12px; color: var(--ink-2); }

/* ===================== Kanban ===================== */
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(250px, 1fr); gap: 14px; overflow-x: auto; padding-bottom: 8px; }
.kcol { background: #eef1f6; border-radius: var(--radius); padding: 10px; min-height: 120px; }
.kcol .khead { display: flex; align-items: center; gap: 8px; padding: 4px 6px 10px; font-weight: 700; font-size: 12.5px; }
.kcol .khead .kc { margin-left: auto; background: #fff; border-radius: 999px; padding: 1px 8px; font-size: 11px; color: var(--ink-2); }
.kcard {
  background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 11px;
  margin-bottom: 9px; cursor: pointer; box-shadow: var(--shadow-sm);
  transition: box-shadow .12s, transform .06s, border-color .12s;
}
.kcard:hover { box-shadow: var(--shadow); border-color: var(--brand-400); transform: translateY(-1px); }
.kcard .knum { font-weight: 800; color: var(--brand-700); font-size: 12.5px; }
.kcard .kclient { font-size: 12.5px; color: var(--ink-1); font-weight: 600; margin-top: 2px; }
.kcard .kmeta { font-size: 11.5px; color: var(--ink-3); margin-top: 6px; display: flex; align-items: center; gap: 6px; }

/* ===================== Detalle de pedido ===================== */
.detail-grid { display: grid; grid-template-columns: 1fr 320px; gap: 18px; align-items: start; }
.kv { display: flex; gap: 8px; font-size: 13px; padding: 7px 0; border-bottom: 1px dashed var(--line-2); }
.kv:last-child { border-bottom: none; }
.kv .k { color: var(--ink-3); min-width: 120px; font-weight: 600; }
.kv .v { color: var(--ink-1); font-weight: 500; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 16px 24px; }
.timeline li:before {
  content: ''; position: absolute; left: 5px; top: 4px; bottom: -2px; width: 2px; background: var(--line);
}
.timeline li:last-child:before { display: none; }
.timeline .dot {
  position: absolute; left: 0; top: 3px; width: 12px; height: 12px; border-radius: 50%;
  background: var(--brand-500); border: 2px solid #fff; box-shadow: 0 0 0 2px var(--brand-100);
}
.timeline .ta { font-weight: 600; font-size: 12.5px; }
.timeline .tm { font-size: 11.5px; color: var(--ink-3); }

/* ===================== Misc ===================== */
.empty {
  text-align: center; padding: 56px 20px; color: var(--ink-3);
}
.empty .icon { width: 40px; height: 40px; margin-bottom: 10px; color: var(--brand-400); }
.empty h3 { color: var(--ink-2); margin: 0 0 4px; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.search-box { position: relative; flex: 1; min-width: 200px; max-width: 360px; }
.search-box .icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--ink-3); }
.search-box input { padding-left: 35px; }
.seg { display: inline-flex; background: #fff; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.seg button { border: none; background: transparent; padding: 7px 12px; font-family: inherit; font-size: 12.5px; font-weight: 600; color: var(--ink-2); cursor: pointer; }
.seg button.active { background: var(--brand-500); color: #fff; }
.divider { height: 1px; background: var(--line); margin: 16px 0; }
.muted-link { color: var(--ink-3); font-size: 12.5px; cursor: pointer; }
.muted-link:hover { color: var(--brand-600); }
.back-link { display: inline-flex; align-items: center; gap: 5px; color: var(--ink-2); font-weight: 600; font-size: 13px; cursor: pointer; margin-bottom: 14px; }
.back-link:hover { color: var(--brand-600); }
.flow-actions { display: flex; flex-direction: column; gap: 8px; }
.tag-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

/* ===================== Toast ===================== */
#toast-host { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 1000; }
.toast {
  display: flex; align-items: center; gap: 9px; background: var(--brand-800); color: #fff;
  padding: 11px 16px; border-radius: 10px; box-shadow: var(--shadow-lg); font-weight: 600; font-size: 13px;
  opacity: 0; transform: translateY(12px); transition: opacity .18s, transform .18s;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast-error { background: var(--red); }
.toast .icon { color: var(--accent-400); }
.toast-error .icon { color: #fff; }

/* ===================== Modal ===================== */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(16,26,45,.5); backdrop-filter: blur(2px);
  display: grid; place-items: center; padding: 20px; z-index: 500; opacity: 0; transition: opacity .18s;
}
.modal-overlay.show { opacity: 1; }
.modal {
  background: #fff; border-radius: 16px; width: 100%; max-width: 560px; box-shadow: var(--shadow-lg);
  transform: translateY(10px) scale(.99); transition: transform .18s; max-height: 90vh; display: flex; flex-direction: column;
}
.modal-overlay.show .modal { transform: none; }
.modal-head { display: flex; align-items: center; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-size: 16px; flex: 1; }
.modal-body { padding: 18px; overflow: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 18px; border-top: 1px solid var(--line); background: var(--brand-50); border-radius: 0 0 16px 16px; }

/* ===================== Responsive ===================== */
/* Hamburguesa y backdrop: ocultos en escritorio, activos en móvil. */
.nav-toggle { display: none; }
.nav-overlay { display: none; }

@media (max-width: 980px) {
  /* La barra lateral pasa a ser un cajón deslizable (off-canvas). */
  .shell { display: block; }
  .sidebar {
    position: fixed; top: 0; left: 0; z-index: 60;
    width: 270px; max-width: 84vw; height: 100vh;
    transform: translateX(-100%); transition: transform .22s ease;
    box-shadow: 6px 0 30px rgba(0,0,0,.28);
  }
  .shell.sidebar-open .sidebar { transform: none; }
  .sidebar .spacer { flex: 1; }
  .sidebar .side-foot { display: block; }

  .nav-overlay {
    display: block; position: fixed; inset: 0; z-index: 55;
    background: rgba(16,26,45,.5); opacity: 0; pointer-events: none;
    transition: opacity .22s ease;
  }
  .shell.sidebar-open .nav-overlay { opacity: 1; pointer-events: auto; }

  .nav-toggle { display: inline-grid; color: var(--ink-1); }
  .main { min-height: 100vh; }
  .topbar { padding: 10px 14px; gap: 10px; }
  .content { padding: 18px 14px 60px; }
  .detail-grid { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  body { overflow-x: hidden; }
  .topbar .page-title { font-size: 16px; }
  .topbar .page-sub { display: none; }

  /* Selector de usuario/rol más compacto. */
  .role-switch { padding: 4px 8px 4px 8px; gap: 6px; }
  .role-switch select { max-width: 38vw; font-size: 12px; }
  .role-switch .role-pill { display: none; }

  .stats { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat .v { font-size: 22px; }
  .grid-cards { grid-template-columns: 1fr; }
  .row2 { grid-template-columns: 1fr; }
  .kanban { grid-auto-columns: minmax(80vw, 1fr); }

  /* Toolbars apiladas y a lo ancho. */
  .toolbar { gap: 8px; }
  .search-box { max-width: none; min-width: 0; width: 100%; }
  .toolbar .seg, .toolbar .input, .toolbar .btn { width: 100%; }
  .toolbar select.input { width: 100% !important; min-width: 0 !important; }
  .seg { overflow-x: auto; }

  .modal { border-radius: 14px; }
  .kv { flex-direction: column; gap: 2px; }
  .kv .k { min-width: 0; }

  /* Banner de "pedido en borrador": apilado para que el botón quede a lo ancho. */
  .order-banner { flex-direction: column; align-items: stretch !important; }
  .order-banner .btn { width: 100%; }
}
