/* ============================================================
   Portal Mayorista Solar — Sistema de diseño
   Negro · Naranja · Blanco
   ============================================================ */

:root {
  /* Acento */
  --orange:      #FF6A00;
  --orange-600:  #E85F00;
  --orange-700:  #C24F00;
  --orange-050:  #FFF1E6;
  --orange-100:  #FFE0C7;

  /* Neutros / negro */
  --black:   #0E0E11;
  --ink:     #141418;   /* sidebar */
  --ink-2:   #1D1D23;   /* sidebar elevado */
  --ink-line:#2A2A31;

  /* Superficies claras */
  --bg:        #F4F4F2;
  --surface:   #FFFFFF;
  --surface-2: #FAFAF8;
  --border:    #E7E7E2;
  --border-2:  #EFEFEA;

  /* Texto */
  --text:        #18181B;
  --text-muted:  #6B6B73;
  --text-faint:  #9A9AA2;
  --on-dark:     #F5F5F3;
  --on-dark-dim: #9C9CA6;

  /* Estados */
  --green:   oklch(0.60 0.13 150);
  --green-bg:oklch(0.95 0.04 150);
  --red:     oklch(0.56 0.19 27);
  --red-bg:  oklch(0.95 0.05 27);
  --amber:   oklch(0.66 0.14 65);
  --amber-bg:oklch(0.95 0.06 75);
  --blue:    oklch(0.55 0.12 250);
  --blue-bg: oklch(0.95 0.04 250);

  /* Radios y sombras */
  --r-sm: 6px;
  --r:    9px;
  --r-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(16,16,18,0.05), 0 1px 3px rgba(16,16,18,0.04);
  --shadow:    0 2px 6px rgba(16,16,18,0.06), 0 8px 24px rgba(16,16,18,0.06);
  --shadow-lg: 0 18px 50px rgba(16,16,18,0.16);

  --sidebar-w: 248px;
  --topbar-h: 64px;

  --font: "Helvetica Neue", Helvetica, Arial, "Segoe UI", sans-serif;
  --mono: "SF Mono", ui-monospace, "Roboto Mono", Menlo, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  letter-spacing: -0.006em;
}

#root { height: 100%; }

button { font-family: inherit; }
input, select { font-family: inherit; }

::selection { background: var(--orange-100); }

/* tabular numbers everywhere data shows */
.tnum { font-variant-numeric: tabular-nums; }

/* ============================================================
   Botones
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 42px;
  padding: 0 18px;
  border-radius: var(--r);
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
  cursor: pointer;
  transition: background .14s ease, border-color .14s ease, color .14s ease, transform .04s ease, box-shadow .14s ease;
  white-space: nowrap;
  user-select: none;
}
.btn:active { transform: translateY(0.5px); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--orange-100); }

.btn-primary {
  background: var(--orange);
  color: #fff;
  box-shadow: 0 1px 2px rgba(255,106,0,0.30);
}
.btn-primary:hover { background: var(--orange-600); }
.btn-primary:active { background: var(--orange-700); }

.btn-dark {
  background: var(--black);
  color: #fff;
}
.btn-dark:hover { background: #25252b; }

.btn-ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}
.btn-ghost:hover { background: var(--surface-2); border-color: #d9d9d2; }

.btn-quiet {
  background: transparent;
  color: var(--text-muted);
  height: 36px;
  padding: 0 12px;
}
.btn-quiet:hover { background: var(--surface-2); color: var(--text); }

.btn-sm { height: 34px; padding: 0 13px; font-size: 13px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ============================================================
   Inputs
   ============================================================ */
.field { display: flex; flex-direction: column; gap: 7px; }
.field > label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.005em;
}
.input-wrap { position: relative; display: flex; align-items: center; }
.input-wrap > svg { position: absolute; left: 13px; color: var(--text-faint); pointer-events: none; }
.input-wrap.has-icon input { padding-left: 40px; }

.input {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  border-radius: var(--r);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 14.5px;
  transition: border-color .14s ease, box-shadow .14s ease;
}
.input::placeholder { color: var(--text-faint); }
.input:hover { border-color: #d6d6cf; }
.input:focus {
  outline: none;
  border-color: var(--orange);
  box-shadow: 0 0 0 3px var(--orange-100);
}
.input.error { border-color: var(--red); }
.input.error:focus { box-shadow: 0 0 0 3px var(--red-bg); }

.input-pw-toggle {
  position: absolute; right: 6px;
  background: none; border: none; cursor: pointer;
  color: var(--text-faint); padding: 8px; border-radius: 6px;
  display: inline-flex;
}
.input-pw-toggle:hover { color: var(--text); background: var(--surface-2); }

.field-hint { font-size: 12.5px; color: var(--text-muted); }
.field-error { font-size: 12.5px; color: var(--red); font-weight: 500; display:flex; gap:5px; align-items:center; }

/* select */
.select {
  appearance: none;
  height: 40px;
  padding: 0 36px 0 13px;
  border-radius: var(--r);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236B6B73' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  transition: border-color .14s ease, box-shadow .14s ease;
}
.select:hover { border-color: #d6d6cf; }
.select:focus { outline: none; border-color: var(--orange); box-shadow: 0 0 0 3px var(--orange-100); }

/* search */
.search {
  position: relative; display: flex; align-items: center;
}
.search > svg { position: absolute; left: 12px; color: var(--text-faint); pointer-events:none; }
.search > input {
  height: 40px;
  padding: 0 14px 0 38px;
  border-radius: var(--r);
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 14px;
  width: 100%;
  transition: border-color .14s ease, box-shadow .14s ease;
}
.search > input:focus { outline: none; border-color: var(--orange); box-shadow: 0 0 0 3px var(--orange-100); }
.search > input::placeholder { color: var(--text-faint); }

/* ============================================================
   Badges
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 24px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: -0.005em;
  white-space: nowrap;
}
.badge .dot { width: 7px; height: 7px; border-radius: 50%; }

.badge-green { background: var(--green-bg); color: oklch(0.42 0.12 150); }
.badge-green .dot { background: var(--green); }
.badge-red   { background: var(--red-bg);   color: oklch(0.44 0.17 27); }
.badge-red .dot { background: var(--red); }
.badge-amber { background: var(--amber-bg); color: oklch(0.46 0.12 60); }
.badge-amber .dot { background: var(--amber); }
.badge-blue  { background: var(--blue-bg);  color: oklch(0.42 0.11 250); }
.badge-blue .dot { background: var(--blue); }
.badge-gray  { background: #F0F0EC; color: var(--text-muted); }
.badge-gray .dot { background: var(--text-faint); }

.badge-solid-orange { background: var(--orange); color:#fff; }

/* qty pill (disponibilidad) */
.qty {
  display:inline-flex; align-items:center; gap:7px;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 14px;
}
.qty .bar { width: 44px; height: 5px; border-radius: 999px; background: #ECECE6; overflow:hidden; }
.qty .bar > i { display:block; height:100%; border-radius:999px; }

/* ============================================================
   Cards / paneles
   ============================================================ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.panel-head {
  display:flex; align-items:center; justify-content:space-between; gap:16px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-2);
  flex-wrap: wrap;
}
.panel-head h3 { margin:0; font-size: 15.5px; font-weight: 700; letter-spacing:-0.01em; }
.panel-head .sub { font-size: 12.5px; color: var(--text-muted); margin-top:2px; }

/* ============================================================
   Tablas
   ============================================================ */
.table-scroll { width: 100%; overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
table.tbl thead th {
  text-align: left;
  padding: 11px 16px;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  position: sticky; top: 0; z-index: 1;
}
table.tbl thead th.num, table.tbl tbody td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.tbl tbody td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border-2);
  color: var(--text);
  vertical-align: middle;
}
table.tbl tbody tr:last-child td { border-bottom: none; }
table.tbl tbody tr { transition: background .1s ease; }
table.tbl tbody tr:hover { background: var(--surface-2); }
.cell-title { font-weight: 600; letter-spacing:-0.005em; }
.cell-sub { font-size: 12.5px; color: var(--text-muted); margin-top:1px; }
.sku { font-family: var(--mono); font-size: 12px; color: var(--text-faint); }

.empty-row {
  padding: 48px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
}

/* ============================================================
   App shell (sidebar + topbar)
   ============================================================ */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: 100%;
}
.sidebar {
  background: var(--ink);
  color: var(--on-dark);
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--ink-line);
}
.sidebar-brand {
  display:flex; align-items:center; gap:11px;
  padding: 19px 20px;
  border-bottom: 1px solid var(--ink-line);
}
.sidebar-nav { padding: 14px 12px; display:flex; flex-direction:column; gap:3px; flex: 1; }
.nav-section { font-size: 10.5px; font-weight:700; text-transform:uppercase; letter-spacing:0.08em; color: #6A6A74; padding: 14px 12px 6px; }
.nav-item {
  display:flex; align-items:center; gap:12px;
  padding: 10px 12px;
  border-radius: var(--r);
  color: var(--on-dark-dim);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: none; background: none; text-align: left; width: 100%;
  transition: background .12s ease, color .12s ease;
}
.nav-item:hover { background: var(--ink-2); color: var(--on-dark); }
.nav-item.active { background: var(--ink-2); color: #fff; }
.nav-item.active .nav-ico { color: var(--orange); }
.nav-item.active { box-shadow: inset 3px 0 0 var(--orange); }
.nav-ico { display:inline-flex; color: inherit; }
.nav-badge { margin-left:auto; font-size:11px; font-weight:700; background: var(--ink-2); color:var(--on-dark-dim); padding:1px 7px; border-radius:999px; }

.sidebar-foot { padding: 12px; border-top: 1px solid var(--ink-line); }
.user-chip {
  display:flex; align-items:center; gap:11px;
  padding: 9px 10px; border-radius: var(--r);
  cursor: pointer; transition: background .12s ease;
}
.user-chip:hover { background: var(--ink-2); }
.avatar {
  width: 34px; height: 34px; border-radius: 9px;
  background: linear-gradient(135deg, var(--orange), var(--orange-700));
  color:#fff; display:flex; align-items:center; justify-content:center;
  font-weight:700; font-size:13px; flex-shrink:0;
}
.avatar.lt { background: #ECECE6; color: var(--text); }

.main { display:flex; flex-direction:column; min-width:0; height:100%; overflow:hidden; }
.topbar {
  height: var(--topbar-h);
  flex-shrink:0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display:flex; align-items:center; gap:16px;
  padding: 0 28px;
}
.topbar h1 { margin:0; font-size: 18px; font-weight: 700; letter-spacing: -0.02em; }
.topbar .crumb { font-size:12.5px; color: var(--text-muted); margin-top:1px; }
.topbar-actions { margin-left:auto; display:flex; align-items:center; gap:10px; }

.content { flex:1; overflow-y:auto; padding: 28px; }
.content-inner { max-width: 1200px; margin: 0 auto; }

/* logo mark — monograma MS (inline SVG, recoloreable vía currentColor) */
.logo-lockup { display:flex; align-items:center; gap:12px; }
.logo-word {
  font-size: 16px; font-weight: 500; letter-spacing: 0.01em; line-height:1;
  white-space: nowrap;
}
.logo-word .thin { font-weight: 400; opacity: .62; }

/* metric cards */
.metrics { display:grid; grid-template-columns: repeat(5, 1fr); gap:16px; }
.metric {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 18px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}
.metric .m-label { font-size: 12.5px; color: var(--text-muted); font-weight:600; display:flex; align-items:center; gap:7px; }
.metric .m-ico { width:30px; height:30px; border-radius:8px; display:flex;align-items:center;justify-content:center; background: var(--surface-2); border:1px solid var(--border-2); color: var(--text-muted); }
.metric .m-value { font-size: 30px; font-weight: 800; letter-spacing:-0.03em; margin-top:12px; font-variant-numeric: tabular-nums; line-height:1; }
.metric .m-foot { font-size:12px; color: var(--text-faint); margin-top:8px; }
.metric.accent { background: var(--black); color:#fff; }
.metric.accent .m-label { color: var(--on-dark-dim); }
.metric.accent .m-ico { background: var(--ink-2); border-color: var(--ink-line); color: var(--orange); }
.metric.accent .m-foot { color: var(--on-dark-dim); }

/* toolbar (filtros) */
.toolbar { display:flex; align-items:center; gap:12px; flex-wrap:wrap; }
.toolbar .search { flex: 1; min-width: 220px; max-width: 380px; }
.toolbar .spacer { flex:1; }
.filter-label { font-size:12.5px; color:var(--text-muted); font-weight:600; margin-right:-4px; }

/* sync banner */
.sync-banner {
  display:flex; align-items:center; gap:14px;
  padding: 14px 18px;
  border-radius: var(--r-lg);
  border:1px solid var(--border);
  background: var(--surface);
}
.sync-ico { width:42px;height:42px;border-radius:10px;display:flex;align-items:center;justify-content:center;flex-shrink:0; }
.sync-ico.ok { background: var(--green-bg); color: oklch(0.42 0.12 150); }
.sync-ico.err { background: var(--red-bg); color: oklch(0.44 0.17 27); }

/* segmented control */
.seg { display:inline-flex; background: var(--surface-2); border:1px solid var(--border); border-radius:var(--r); padding:3px; gap:2px; }
.seg button {
  border:none; background:none; cursor:pointer;
  padding: 6px 13px; border-radius: 6px; font-size:13px; font-weight:600; color: var(--text-muted);
  transition: background .12s, color .12s;
}
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

/* toggle switch */
.switch { position:relative; width:38px; height:22px; flex-shrink:0; border:none; cursor:pointer; padding:0; background:none; }
.switch i { position:absolute; inset:0; border-radius:999px; background:#D6D6D0; transition: background .16s; }
.switch i::after { content:""; position:absolute; top:2px; left:2px; width:18px;height:18px;border-radius:50%; background:#fff; box-shadow:0 1px 2px rgba(0,0,0,.2); transition: transform .16s; }
.switch.on i { background: var(--green); }
.switch.on i::after { transform: translateX(16px); }

/* alert */
.alert {
  display:flex; gap:11px; align-items:flex-start;
  padding: 13px 15px;
  border-radius: var(--r);
  font-size: 13.5px;
  line-height:1.45;
}
.alert-err { background: var(--red-bg); color: oklch(0.40 0.16 27); border:1px solid oklch(0.85 0.07 27); }
.alert-err strong { font-weight: 700; }
.alert-warn { background: var(--amber-bg); color: oklch(0.42 0.11 60); border:1px solid oklch(0.85 0.09 75); }
.alert-info { background: var(--blue-bg); color: oklch(0.40 0.10 250); border:1px solid oklch(0.86 0.05 250); }
.alert svg { flex-shrink:0; margin-top:1px; }

/* ============================================================
   Auth (login / reset) — split layout
   ============================================================ */
.auth {
  display:grid;
  grid-template-columns: 1.05fr 1fr;
  height:100%;
}
.auth-aside {
  background: var(--black);
  color:#fff;
  position: relative;
  overflow: hidden;
  display:flex; flex-direction:column;
  padding: 44px;
}
.auth-aside::before {
  content:""; position:absolute; inset:0;
  background:
    radial-gradient(900px 500px at 78% 8%, rgba(255,106,0,0.22), transparent 55%),
    radial-gradient(600px 600px at 10% 100%, rgba(255,106,0,0.10), transparent 60%);
}
.aside-grid {
  position:absolute; inset:0;
  background-image: linear-gradient(rgba(255,255,255,0.04) 1px, transparent 1px),
                    linear-gradient(90deg, rgba(255,255,255,0.04) 1px, transparent 1px);
  background-size: 46px 46px;
  mask-image: radial-gradient(circle at 70% 30%, black, transparent 75%);
}
.auth-aside > * { position: relative; z-index:1; }
.aside-foot { margin-top:auto; }
.aside-quote { font-size: 26px; font-weight: 700; letter-spacing:-0.02em; line-height:1.25; max-width: 16ch; }
.aside-quote .hl { color: var(--orange); }
.aside-meta { margin-top: 22px; display:flex; gap:28px; }
.aside-meta .n { font-size: 24px; font-weight:800; letter-spacing:-0.02em; }
.aside-meta .l { font-size:12px; color: var(--on-dark-dim); margin-top:2px; }

.auth-panel {
  display:flex; align-items:center; justify-content:center;
  padding: 44px; background: var(--surface);
  overflow-y:auto;
}
.auth-form { width:100%; max-width: 380px; }
.auth-form h2 { margin:0; font-size: 25px; font-weight:800; letter-spacing:-0.025em; }
.auth-form .lede { margin: 9px 0 0; color: var(--text-muted); font-size:14.5px; line-height:1.5; }
.auth-stack { display:flex; flex-direction:column; gap:16px; }
.auth-row { display:flex; align-items:center; justify-content:space-between; }
.link {
  color: var(--orange); font-weight:600; font-size:13px; cursor:pointer; text-decoration:none;
  background:none;border:none;padding:0;
}
.link:hover { color: var(--orange-600); text-decoration: underline; }
.link-muted { color: var(--text-muted); font-weight:600; font-size:13.5px; cursor:pointer; background:none;border:none; display:inline-flex; gap:6px; align-items:center; }
.link-muted:hover { color: var(--text); }

.demo-hint {
  margin-top: 22px; padding: 12px 14px;
  background: var(--surface-2); border:1px dashed var(--border);
  border-radius: var(--r); font-size:12.5px; color: var(--text-muted); line-height:1.6;
}
.demo-hint b { color: var(--text); font-weight:700; }
.demo-hint code { font-family: var(--mono); font-size:11.5px; background:#EDEDE8; padding:1px 5px; border-radius:4px; color: var(--text); }

/* stepper */
.stepper { display:flex; align-items:center; gap:0; margin-bottom: 28px; }
.step { display:flex; align-items:center; gap:10px; }
.step-dot {
  width:28px;height:28px;border-radius:50%; flex-shrink:0;
  display:flex;align-items:center;justify-content:center;
  font-size:13px;font-weight:700;
  background: var(--surface-2); color:var(--text-faint); border:1.5px solid var(--border);
}
.step.active .step-dot { background: var(--orange); color:#fff; border-color: var(--orange); }
.step.done .step-dot { background: var(--black); color:#fff; border-color: var(--black); }
.step-label { font-size:12.5px; font-weight:600; color: var(--text-faint); }
.step.active .step-label, .step.done .step-label { color: var(--text); }
.step-line { width:30px; height:2px; background: var(--border); margin: 0 10px; }
.step.done + .step-line, .step-line.done { background: var(--black); }

.success-ring {
  width: 64px; height:64px; border-radius:50%;
  background: var(--green-bg); color: oklch(0.42 0.12 150);
  display:flex;align-items:center;justify-content:center;
  margin-bottom: 22px;
}

/* pw strength */
.pw-rules { display:flex; flex-direction:column; gap:6px; margin-top:4px; }
.pw-rule { display:flex; align-items:center; gap:8px; font-size:12.5px; color: var(--text-faint); }
.pw-rule.ok { color: oklch(0.46 0.12 150); }
.pw-rule .tick { width:15px;height:15px;border-radius:50%; background:#E7E7E2; display:flex;align-items:center;justify-content:center; flex-shrink:0; }
.pw-rule.ok .tick { background: var(--green); color:#fff; }

/* responsive */
@media (max-width: 920px) {
  .auth { grid-template-columns: 1fr; }
  .auth-aside { display:none; }
  .metrics { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; z-index: 50; top:0; bottom:0; left:0; width: var(--sidebar-w);
    transform: translateX(-100%); transition: transform .2s ease;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }
  .scrim { position:fixed; inset:0; background:rgba(0,0,0,.4); z-index:49; }
  .menu-btn { display:inline-flex !important; }
}
@media (min-width: 861px) {
  .menu-btn { display:none; }
}
@media (max-width: 560px) {
  .metrics { grid-template-columns: 1fr; }
  .content { padding: 18px; }
  .topbar { padding: 0 16px; }
  .auth-panel { padding: 28px 22px; }
}

/* scrollbars */
.content::-webkit-scrollbar, .table-scroll::-webkit-scrollbar { width:10px; height:10px; }
.content::-webkit-scrollbar-thumb, .table-scroll::-webkit-scrollbar-thumb { background:#DADAD3; border-radius:999px; border:2px solid var(--bg); }
.content::-webkit-scrollbar-thumb:hover { background:#C7C7BE; }

/* fade-in for view changes */
@keyframes fadeUp { from { opacity:0; transform: translateY(6px);} to {opacity:1; transform:none;} }
.fade { animation: fadeUp .22s ease both; }
