/* Control Plane — misma identidad que el CRM (carbón/grafito + lima Club Fortuna), densidad de panel administrativo. */
:root {
  --bg: #0b0d0c; --line: #242a28; --line-soft: #1c211f; --field: #151918; --field-strong: #181d1b;
  --text: #eef1ee; --text-soft: #98a29c; --text-mute: #707a76;
  --tenant-accent: #a7d65b; --accent: var(--tenant-accent); --accent-strong: #93c94a;
  --accent-soft: rgba(167,214,91,.12); --accent-line: rgba(167,214,91,.45); --accent-text: #d3ecab; --on-accent: #182008;
  --success: #8fd19a; --warning: #e0c36a; --danger: #e08a92; --info: #8ab4e8;
  --radius-sm: 10px; --radius-md: 14px; --radius-lg: 18px; --shadow: 0 10px 22px rgba(0,0,0,.28);
  /* El control plane se distingue del CRM por un acento frío secundario, no por cambiar la marca. */
  --control: #8ab4e8; --control-soft: rgba(138,180,232,.12); --control-line: rgba(138,180,232,.4);
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
svg { display: block; }
.svg-sprite, [hidden] { display: none !important; }
.icon { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--accent-line); outline-offset: 2px; }
.muted { color: var(--text-mute); font-size: 13px; }
.num { text-align: right; }

/* ---------- botones ---------- */
.btn { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: var(--field);
  color: var(--text); padding: 9px 14px; border-radius: var(--radius-sm); font-weight: 500; font-size: 14px; transition: background .15s, border-color .15s; }
.btn:hover { background: var(--field-strong); border-color: #2f3634; }
.btn-sm { padding: 6px 11px; font-size: 13px; }
.btn-accent { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }
.btn-accent:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn-ghost { background: transparent; }
.btn-danger { color: var(--danger); border-color: rgba(224,138,146,.35); }
.btn:disabled { opacity: .55; cursor: wait; }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(380px, 100%); background: var(--field); border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 28px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 8px; }
.login-brand, .sidebar-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.login-brand strong, .sidebar-brand strong { display: block; font-size: 15px; letter-spacing: .01em; }
.login-brand span:not(.brand-mark), .sidebar-brand span:not(.brand-mark) { display: block; font-size: 12px; color: var(--control); letter-spacing: .08em; text-transform: uppercase; }
.brand-mark { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 11px; background: var(--accent);
  color: var(--on-accent); font-weight: 700; font-size: 15px; letter-spacing: .02em; }
.login-hint { color: var(--text-mute); font-size: 13px; margin: 0 0 12px; }
.login-card label, .modal-card label { font-size: 12px; color: var(--text-soft); margin-top: 6px; }
input, select, textarea { width: 100%; background: var(--bg); border: 1px solid var(--line); color: var(--text);
  border-radius: var(--radius-sm); padding: 10px 12px; }
input::placeholder { color: var(--text-mute); }
.login-card .btn { margin-top: 16px; justify-content: center; }
.form-error { color: var(--danger); font-size: 13px; margin: 8px 0 0; }

/* ---------- layout ---------- */
.app { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.sidebar { border-right: 1px solid var(--line); background: #0d100f; padding: 20px 14px; display: flex; flex-direction: column; gap: 22px; position: sticky; top: 0; height: 100vh; }
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-item { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; background: transparent; border: 0;
  color: var(--text-soft); padding: 9px 11px; border-radius: var(--radius-sm); font-size: 14px; }
.nav-item:hover { background: var(--field); color: var(--text); }
.nav-item.is-active { background: var(--control-soft); color: var(--text); box-shadow: inset 2px 0 0 var(--control); }
.sidebar-foot { border-top: 1px solid var(--line-soft); padding-top: 14px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.who span { display: block; font-size: 13px; }
.who small { color: var(--text-mute); font-size: 11px; }
.content { min-width: 0; padding: 24px 28px 48px; }
.topbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.topbar h1 { margin: 0 0 2px; font-size: 21px; font-weight: 600; }
.topbar p { margin: 0; }
.banner { border: 1px solid var(--accent-line); background: var(--accent-soft); color: var(--accent-text);
  padding: 10px 14px; border-radius: var(--radius-sm); margin-bottom: 16px; font-size: 14px; }
.banner.is-error { border-color: rgba(224,138,146,.4); background: rgba(224,138,146,.1); color: var(--danger); }

/* ---------- paneles / tablas ---------- */
.panel { background: var(--field); border: 1px solid var(--line); border-radius: var(--radius-md); margin-bottom: 18px; overflow: hidden; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line-soft); }
.panel-head h2 { margin: 0; font-size: 15px; font-weight: 600; }
.filters { display: flex; gap: 8px; }
.filters select { width: auto; padding: 6px 10px; font-size: 13px; }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 640px; }
.table th { text-align: left; font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--text-mute); padding: 10px 16px; border-bottom: 1px solid var(--line-soft); white-space: nowrap; }
.table td { padding: 11px 16px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--field-strong); }
.table .row-link { color: var(--text); font-weight: 500; background: none; border: 0; padding: 0; text-align: left; }
.table .row-link:hover { color: var(--accent-text); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; color: var(--text-soft); }
.empty { padding: 26px 16px; text-align: center; color: var(--text-mute); font-size: 14px; }

/* ---------- KPIs ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 18px; }
.kpis-sm { margin: 0; padding: 14px 16px; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); }
.kpi { background: var(--field); border: 1px solid var(--line); border-radius: var(--radius-md); padding: 14px 16px; }
.kpis-sm .kpi { background: var(--bg); }
.kpi b { display: block; font-size: 24px; font-weight: 600; letter-spacing: -.01em; }
.kpi span { display: block; font-size: 12px; color: var(--text-mute); margin-top: 2px; }
.kpi.is-alert b { color: var(--warning); }

/* ---------- pills / kv ---------- */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px; font-size: 12px;
  border: 1px solid var(--line); color: var(--text-soft); background: var(--bg); white-space: nowrap; }
.pill.is-ok { color: var(--success); border-color: rgba(143,209,154,.35); background: rgba(143,209,154,.1); }
.pill.is-off { color: var(--danger); border-color: rgba(224,138,146,.35); background: rgba(224,138,146,.1); }
.pill.is-admin { color: var(--control); border-color: var(--control-line); background: var(--control-soft); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 8px 18px; margin: 0; padding: 16px; font-size: 14px; }
.kv dt { color: var(--text-mute); font-size: 13px; }
.kv dd { margin: 0; }
.detail-grid { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 18px; }
.detail-actions { display: flex; gap: 8px; padding: 0 16px 16px; }
.back { margin-bottom: 14px; }
.note { margin: 0; padding: 0 16px 16px; color: var(--text-mute); font-size: 13px; line-height: 1.5; }
.note code { font-family: ui-monospace, monospace; color: var(--text-soft); }
.pager { display: flex; align-items: center; justify-content: flex-end; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--line-soft); }

/* ---------- modal ---------- */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: grid; place-items: center; padding: 20px; z-index: 40; }
.modal-card { width: min(440px, 100%); background: var(--field); border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 22px; box-shadow: var(--shadow); max-height: 90vh; overflow-y: auto; }
.modal-card h2 { margin: 0 0 14px; font-size: 17px; font-weight: 600; }
.modal-card form { display: flex; flex-direction: column; gap: 4px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.field-hint { font-size: 12px; color: var(--text-mute); margin: 2px 0 0; }

/* ---------- responsive: herramienta de escritorio, pero usable en pantallas chicas ---------- */
@media (max-width: 1100px) { .detail-grid { grid-template-columns: 1fr; } }
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; align-items: center; flex-wrap: wrap; gap: 12px; padding: 12px 14px; }
  .sidebar-brand { margin: 0; }
  .nav { flex-direction: row; flex-wrap: wrap; flex: 1 1 100%; order: 3; }
  .nav-item { flex: 1 1 auto; justify-content: center; }
  .nav-item.is-active { box-shadow: inset 0 -2px 0 var(--control); }
  .sidebar-foot { border: 0; padding: 0; margin-left: auto; }
  .content { padding: 18px 16px 40px; }
  /* Las tablas anchas se vuelven tarjetas legibles en vez de un scroll infinito. */
  .table, .table thead, .table tbody, .table tr, .table td { display: block; width: 100%; min-width: 0; }
  .table thead { display: none; }
  .table tr { border: 1px solid var(--line-soft); border-radius: var(--radius-sm); margin: 10px 12px; padding: 4px 0; }
  .table td { display: flex; justify-content: space-between; gap: 14px; text-align: right; border: 0; padding: 7px 14px; }
  .table td::before { content: attr(data-th); color: var(--text-mute); font-size: 12px; text-transform: uppercase;
    letter-spacing: .04em; text-align: left; flex: 0 0 auto; }
  .table td:empty { display: none; }
}
