/* ============================================================
   TecnoServicio · Taller v2 — sistema de diseño
   Paleta: grafito + ámbar (automotriz). UI densa y profesional.
   ============================================================ */
:root {
  --bg: #0f1217;
  --bg-2: #161b22;
  --surface: #1c222c;
  --surface-2: #232b37;
  --border: #2b3441;
  --border-2: #374252;
  --text: #e6edf3;
  --text-dim: #9aa7b6;
  --text-mut: #6b7785;
  --accent: #f59e0b;
  --accent-2: #fbbf24;
  --accent-dim: rgba(245, 158, 11, 0.12);
  --green: #34d399;
  --green-dim: rgba(52, 211, 153, 0.13);
  --red: #f87171;
  --red-dim: rgba(248, 113, 113, 0.13);
  --blue: #60a5fa;
  --blue-dim: rgba(96, 165, 250, 0.13);
  --purple: #a78bfa;
  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;
}

/* ── Tema claro ── */
[data-theme="light"] {
  --bg: #eef1f6;
  --bg-2: #ffffff;
  --surface: #ffffff;
  --surface-2: #f3f5f9;
  --border: #e4e8ef;
  --border-2: #d3dae3;
  --text: #1a2230;
  --text-dim: #4d5a6b;
  --text-mut: #8794a3;
  --accent: #d97706;
  --accent-2: #b45309;
  --accent-dim: rgba(217, 119, 6, 0.12);
  --green: #059669;
  --green-dim: rgba(5, 150, 105, 0.12);
  --red: #dc2626;
  --red-dim: rgba(220, 38, 38, 0.10);
  --blue: #2563eb;
  --blue-dim: rgba(37, 99, 235, 0.10);
  --shadow: 0 8px 30px rgba(40, 60, 90, 0.15);
}
[data-theme="light"] .login-wrap { background: radial-gradient(1200px 600px at 50% -10%, #dde6f5 0%, var(--bg) 60%); }
[data-theme="light"] .login-logo-img img { filter: none; }
[data-theme="light"] .demo-banner { background: var(--accent-dim); }

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 5px; }
::-webkit-scrollbar-track { background: transparent; }

/* ── Utilidades ── */
.hidden { display: none !important; }
.row { display: flex; align-items: center; gap: 10px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.col { display: flex; flex-direction: column; gap: 10px; }
.grow { flex: 1; }
.mut { color: var(--text-mut); }
.dim { color: var(--text-dim); }
.right { text-align: right; }
.center { text-align: center; }
.mono { font-family: var(--mono); }
.nowrap { white-space: nowrap; }

/* ── Login ── */
.login-wrap {
  min-height: 100vh; display: grid; place-items: center;
  background: radial-gradient(1200px 600px at 50% -10%, #1b2330 0%, var(--bg) 60%);
  padding: 24px;
}
.login-card {
  width: 100%; max-width: 380px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 16px; padding: 36px 32px;
  box-shadow: var(--shadow);
}
.login-logo {
  width: 56px; height: 56px; border-radius: 14px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), #d97706); margin: 0 auto 18px;
  font-size: 28px; box-shadow: 0 6px 20px rgba(245, 158, 11, 0.35);
}
.login-card h1 { font-size: 20px; text-align: center; margin-bottom: 4px; }
.login-card .sub { text-align: center; color: var(--text-mut); font-size: 13px; margin-bottom: 26px; }
.login-logo-img { display: flex; justify-content: center; }
.login-logo-img img { max-width: 220px; width: 100%; height: auto; filter: drop-shadow(0 4px 14px rgba(0,0,0,.4)); }
.brand-logo { width: 100%; max-width: 180px; height: auto; display: block; margin: 2px auto 4px; }

/* ── Formularios ── */
label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; font-size: 12px; color: var(--text-dim); margin-bottom: 6px; font-weight: 500; }
input, select, textarea {
  width: 100%; background: var(--bg-2); border: 1px solid var(--border);
  color: var(--text); padding: 10px 12px; border-radius: var(--radius-sm);
  font-size: 14px; font-family: inherit; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
textarea { resize: vertical; min-height: 70px; }
input::placeholder { color: var(--text-mut); }

/* ── Botones ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  background: var(--surface-2); border: 1px solid var(--border-2); color: var(--text);
  padding: 9px 15px; border-radius: var(--radius-sm); font-size: 13.5px; font-weight: 500;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: #2a3340; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #1a1206; font-weight: 600; }
.btn-primary:hover { background: var(--accent-2); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-dim); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-danger { background: var(--red-dim); border-color: transparent; color: var(--red); }
.btn-danger:hover { background: rgba(248, 113, 113, 0.22); }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 10px; font-size: 12.5px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── Layout app ── */
.app { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--bg-2); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 16px 12px; position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 6px 8px 18px; }
.brand .logo {
  width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), #d97706); font-size: 18px; flex-shrink: 0;
}
.brand .name { font-weight: 700; font-size: 15px; line-height: 1.1; }
.brand .tag { font-size: 11px; color: var(--text-mut); }
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.nav-section { font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-mut); padding: 14px 10px 6px; font-weight: 600; }
.nav-item {
  display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: var(--radius-sm);
  color: var(--text-dim); font-size: 13.5px; font-weight: 500; transition: background .12s, color .12s;
}
.nav-item:hover { background: var(--surface); color: var(--text); }
.nav-item.active { background: var(--accent-dim); color: var(--accent-2); }
.nav-item .ico { width: 18px; text-align: center; font-size: 15px; }
.nav-item .badge { margin-left: auto; background: var(--red); color: #fff; font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 10px; }
.sidebar-foot { border-top: 1px solid var(--border); padding-top: 12px; margin-top: 8px; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-sm); }
.user-chip .av { width: 30px; height: 30px; border-radius: 50%; background: var(--surface-2); display: grid; place-items: center; font-weight: 600; font-size: 13px; color: var(--accent-2); }

.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: 58px; border-bottom: 1px solid var(--border); display: flex; align-items: center;
  justify-content: space-between; padding: 0 24px; background: var(--bg); position: sticky; top: 0; z-index: 10;
}
.topbar h2 { font-size: 17px; font-weight: 650; }
.content { padding: 24px; flex: 1; }

/* Reloj del topbar */
.clock { display: flex; align-items: baseline; gap: 8px; padding: 5px 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 20px; font-size: 12.5px; white-space: nowrap; }
.clock-day { color: var(--accent-2); font-weight: 600; text-transform: capitalize; }
.clock-date { color: var(--text-dim); }
.clock-time { color: var(--text); font-weight: 600; font-size: 13px; }
@media (max-width: 640px) { .clock-date { display: none; } }

/* ── Cards / KPIs ── */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 22px; }
.kpi {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; position: relative; overflow: hidden;
}
.kpi .label { font-size: 12px; color: var(--text-dim); margin-bottom: 8px; display: flex; align-items: center; gap: 7px; }
.kpi .val { font-size: 28px; font-weight: 700; letter-spacing: -.02em; }
.kpi .ico { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; font-size: 15px; }
.kpi.accent .ico { background: var(--accent-dim); color: var(--accent-2); }
.kpi.green .ico { background: var(--green-dim); color: var(--green); }
.kpi.blue .ico { background: var(--blue-dim); color: var(--blue); }
.kpi.red .ico { background: var(--red-dim); color: var(--red); }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  margin-bottom: 18px; overflow: hidden;
}
.card-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.card-head h3 { font-size: 14.5px; font-weight: 600; }
.card-body { padding: 18px; }
.card-body.flush { padding: 0; }

/* ── Tablas ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--text-mut); font-weight: 600; padding: 11px 16px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
tbody td { padding: 12px 16px; border-bottom: 1px solid var(--border); }
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background .1s; }
tbody tr:hover { background: var(--surface-2); }
.table-clickable tbody tr { cursor: pointer; }

/* ── Badges de estado ── */
.badge-st { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 600; padding: 3px 9px; border-radius: 20px; white-space: nowrap; }
.badge-st::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.st-pendiente { background: var(--accent-dim); color: var(--accent-2); }
.st-en_proceso { background: var(--blue-dim); color: var(--blue); }
.st-listo { background: var(--green-dim); color: var(--green); }
.st-entregado { background: rgba(154,167,182,.14); color: var(--text-dim); }
.st-anulado, .st-rechazada { background: var(--red-dim); color: var(--red); }
.st-emitida, .st-recibida, .st-aprobada, .st-enviada { background: var(--green-dim); color: var(--green); }

.stock-pill { font-family: var(--mono); font-weight: 600; }
.stock-low { color: var(--red); }
.stock-ok { color: var(--text); }

/* ── Toolbar / búsqueda ── */
.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.search { position: relative; flex: 1; max-width: 340px; }
.search input { padding-left: 34px; }
.search .ico { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-mut); pointer-events: none; }

/* ── Modal ── */
.modal-back { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: grid; place-items: center; z-index: 100; padding: 24px; backdrop-filter: blur(3px); }
.modal { background: var(--surface); border: 1px solid var(--border-2); border-radius: 14px; width: 100%; max-width: 560px; max-height: 88vh; display: flex; flex-direction: column; box-shadow: var(--shadow); }
.modal.lg { max-width: 760px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.modal-head h3 { font-size: 16px; }
.modal-body { padding: 22px; overflow-y: auto; }
.modal-foot { padding: 16px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }

/* ── Toast ── */
.toasts { position: fixed; bottom: 22px; right: 22px; display: flex; flex-direction: column; gap: 10px; z-index: 200; }
.toast { background: var(--surface-2); border: 1px solid var(--border-2); border-left: 3px solid var(--accent); padding: 12px 16px; border-radius: var(--radius-sm); box-shadow: var(--shadow); font-size: 13.5px; min-width: 240px; animation: slidein .2s; }
.toast.ok { border-left-color: var(--green); }
.toast.err { border-left-color: var(--red); }
@keyframes slidein { from { transform: translateX(20px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ── Empty / loading ── */
.empty { text-align: center; padding: 48px 20px; color: var(--text-mut); }
.empty .ico { font-size: 36px; margin-bottom: 12px; opacity: .5; }
.spinner { width: 22px; height: 22px; border: 2.5px solid var(--border-2); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-wrap { display: grid; place-items: center; padding: 60px; }

/* línea de items en formularios (OT, cotización, etc.) */
.item-line { display: grid; grid-template-columns: 1fr 80px 110px 90px 30px; gap: 8px; align-items: center; margin-bottom: 8px; }
.item-line .x { color: var(--text-mut); text-align: center; cursor: pointer; font-size: 18px; }
.item-line .x:hover { color: var(--red); }
.demo-banner { background: var(--accent-dim); color: var(--accent-2); text-align: center; font-size: 12px; padding: 5px; font-weight: 600; }

@media (max-width: 720px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}
