/* ============================================================
   Proximia Studio · Panel interno
   Sobrio y denso: es una herramienta de trabajo diario, no una landing.
   ============================================================ */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #E5E5E8;
  --border-strong: #cdd2da;
  --text: #111114;
  --text-soft: #6B6E76;
  --text-faint: #8b939e;
  --accent: #2962FA;
  --accent-soft: #EAF0FF;
  --ok: #0f8a5f;
  --ok-soft: #e6f6ef;
  --warn: #a86300;
  --warn-soft: #fdf1de;
  --bad: #c0392f;
  --bad-soft: #fdecea;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(18, 22, 28, .06), 0 4px 12px rgba(18, 22, 28, .04);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1216;
    --surface: #171b21;
    --surface-2: #1e242c;
    --border: #262d36;
    --border-strong: #3a434f;
    --text: #eef1f5;
    --text-soft: #a3adb9;
    --text-faint: #6f7986;
    --accent: #6b8dff;
    --accent-soft: #1c2540;
    --ok: #3ecf8e;
    --ok-soft: #10281f;
    --warn: #e0a458;
    --warn-soft: #2a2113;
    --bad: #f0705f;
    --bad-soft: #2d1715;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 12px rgba(0, 0, 0, .2);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

/* El manual de marca usa Poppins para títulos e Inter para texto. */
h1, h2, h3, .sidebar__brand, .login__brand, .metric__value {
  font-family: 'Poppins', var(--font);
}
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: 20px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Login ---------- */

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login__card {
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 32px;
}

.login__brand {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -.02em;
  margin-bottom: 4px;
}

.login__sub {
  color: var(--text-faint);
  font-size: 13px;
  margin-bottom: 24px;
}

/* ---------- Estructura ---------- */

.shell {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar__brand {
  font-weight: 600;
  letter-spacing: -.02em;
  padding: 0 8px;
}

.sidebar__brand small {
  display: block;
  font-weight: 400;
  color: var(--text-faint);
  font-size: 11px;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.nav { display: flex; flex-direction: column; gap: 2px; }

.nav__item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--text-soft);
  font-weight: 500;
  cursor: pointer;
  border: none;
  background: none;
  font-family: inherit;
  font-size: 14px;
  text-align: left;
  width: 100%;
}

.nav__item:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav__item.is-active { background: var(--accent-soft); color: var(--accent); }

.sidebar__foot {
  margin-top: auto;
  border-top: 1px solid var(--border);
  padding-top: 14px;
  font-size: 12px;
  color: var(--text-faint);
}

.main { padding: 24px 28px 64px; min-width: 0; }

.topbar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.topbar__sub { color: var(--text-faint); font-size: 13px; }

/* ---------- Controles ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
}

.btn:hover { background: var(--surface-2); }
.btn--primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn--primary:hover { filter: brightness(1.08); background: var(--accent); }
.btn--danger { color: var(--bad); border-color: var(--bad); background: none; }
.btn--sm { padding: 4px 10px; font-size: 13px; }
.btn--block { width: 100%; justify-content: center; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.field { margin-bottom: 14px; }

.field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-soft);
  margin-bottom: 5px;
}

input, select, textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
  border-color: var(--accent);
}

textarea { resize: vertical; min-height: 72px; }

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* ---------- Tarjetas y métricas ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  margin-bottom: 20px;
}

.metric__label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.metric__value {
  font-size: 26px;
  font-weight: 650;
  letter-spacing: -.02em;
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}

.metric__note { font-size: 12px; color: var(--text-soft); margin-top: 2px; }

/* ---------- Kanban ---------- */

.board {
  display: grid;
  grid-auto-flow: column;
  /* Las 6 etapas tienen que caber en pantalla: ver el embudo completo de un
     vistazo vale más que unos píxeles extra de ancho por tarjeta. */
  grid-auto-columns: minmax(150px, 1fr);
  gap: 10px;
  align-items: start;
  overflow-x: auto;
  padding-bottom: 12px;
}

.column {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px;
  min-height: 140px;
}

.column.is-over {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.column__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}

.column__count {
  font-size: 12px;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}

.column__hint {
  font-size: 11px;
  color: var(--text-faint);
  margin-bottom: 10px;
}

.column__total {
  font-size: 12px;
  color: var(--text-soft);
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
}

.deal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 8px;
  cursor: grab;
  box-shadow: var(--shadow);
}

.deal:hover { border-color: var(--border-strong); }
.deal.is-dragging { opacity: .4; }
.deal__name { font-weight: 600; margin-bottom: 2px; }
.deal__meta { font-size: 12px; color: var(--text-faint); }

.deal__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 8px;
  font-size: 12px;
}

.deal__amount { font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------- Píldoras ---------- */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background: var(--surface-2);
  color: var(--text-soft);
  white-space: nowrap;
}

.pill--ok { background: var(--ok-soft); color: var(--ok); }
.pill--warn { background: var(--warn-soft); color: var(--warn); }
.pill--bad { background: var(--bad-soft); color: var(--bad); }
.pill--accent { background: var(--accent-soft); color: var(--accent); }

/* ---------- Tablas ---------- */

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

table { width: 100%; border-collapse: collapse; font-size: 13px; }

th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Barra de progreso ---------- */

.bar {
  height: 6px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
  min-width: 80px;
}

.bar__fill { height: 100%; background: var(--ok); border-radius: 999px; }

/* ---------- Modal ---------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 13, 18, .5);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 50;
}

.modal {
  background: var(--surface);
  border-radius: 14px;
  border: 1px solid var(--border);
  box-shadow: 0 20px 60px rgba(0, 0, 0, .3);
  width: 100%;
  max-width: 620px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--surface);
}

.modal__body { padding: 20px; }

.modal__foot {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  gap: 10px;
  position: sticky;
  bottom: 0;
  background: var(--surface);
}

.modal__close {
  border: none;
  background: none;
  font-size: 22px;
  line-height: 1;
  color: var(--text-faint);
  cursor: pointer;
  padding: 0 4px;
}

/* ---------- Avisos y estados ---------- */

.notice {
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 16px;
}

.notice--error { background: var(--bad-soft); color: var(--bad); }
.notice--warn { background: var(--warn-soft); color: var(--warn); }
.notice--ok { background: var(--ok-soft); color: var(--ok); }

.empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--text-faint);
  font-size: 13px;
}

.section { margin-bottom: 28px; }
.section__head { margin-bottom: 12px; display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.muted { color: var(--text-faint); }
.stack { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.spinner {
  width: 18px; height: 18px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Móvil ---------- */

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
    flex-direction: row;
    align-items: center;
    gap: 12px;
    overflow-x: auto;
    padding: 12px;
  }
  .sidebar__brand small { display: none; }
  .nav { flex-direction: row; }
  .nav__item { white-space: nowrap; }
  .sidebar__foot { margin: 0; border: none; padding: 0; }
  .main { padding: 16px 14px 48px; }
  .field-row { grid-template-columns: 1fr; }
}
