/* ==========================================================================
   Consola de Dueño — estilo minimalista, oscuro y sobrio
   ========================================================================== */
:root {
  --bg: #0e1117;
  --surface: #161b22;
  --surface-2: #1c2230;
  --border: #2a3140;
  --text: #e6edf3;
  --muted: #8b949e;
  --accent: #4f8cff;
  --accent-soft: rgba(79, 140, 255, 0.12);
  --green: #3fb950;
  --red: #f85149;
  --amber: #d29922;
  --radius: 14px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}
.hidden { display: none !important; }
.muted { color: var(--muted); font-weight: 400; }

/* --- Marca --- */
.brand { display: flex; align-items: center; gap: 12px; }
.brand h1 { font-size: 1.25rem; font-weight: 800; letter-spacing: -0.02em; }
.brand p { color: var(--muted); font-size: 0.8rem; }
.brand-mark {
  width: 40px; height: 40px; border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), #7b5cff);
  color: #fff; display: grid; place-items: center; font-size: 1.2rem; font-weight: 900;
}
.brand.small .brand-mark { width: 32px; height: 32px; font-size: 1rem; border-radius: 8px; }
.brand.small strong { display: block; font-size: 0.9rem; }
.brand.small span { font-size: 0.72rem; }

/* --- Login --- */
.login-wrap { min-height: 100%; display: grid; place-items: center; padding: 24px; }
.login-card {
  width: 100%; max-width: 380px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 20px; padding: 32px;
  display: flex; flex-direction: column; gap: 8px;
}
.login-card .brand { margin-bottom: 20px; }
.login-card label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-top: 10px; font-weight: 700; }
.login-card input {
  background: var(--bg); border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 14px; color: var(--text); font-size: 0.95rem; outline: none;
}
.login-card input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.login-card button { margin-top: 18px; }
.error-msg { color: var(--red); font-size: 0.82rem; text-align: center; min-height: 18px; margin-top: 8px; }

/* --- Botones --- */
.btn-primary {
  background: var(--accent); color: #fff; border: none; border-radius: 10px;
  padding: 11px 18px; font-weight: 700; cursor: pointer; font-size: 0.88rem;
  transition: filter .15s;
}
.btn-primary:hover { filter: brightness(1.1); }
.btn-primary:disabled { opacity: .5; cursor: default; }
.btn-ghost {
  background: transparent; color: var(--muted); border: 1px solid var(--border);
  border-radius: 8px; padding: 7px 14px; font-weight: 600; cursor: pointer; font-size: 0.82rem;
}
.btn-ghost:hover { color: var(--text); border-color: var(--muted); }
.btn-danger { background: transparent; color: var(--red); border: 1px solid transparent; cursor: pointer; font-size: 0.8rem; padding: 6px 10px; border-radius: 8px; }
.btn-danger:hover { background: rgba(248,81,73,.1); }

/* --- Shell --- */
.shell { min-height: 100%; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 24px; background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10; flex-wrap: wrap;
}
.tabs { display: flex; gap: 4px; background: var(--bg); padding: 4px; border-radius: 12px; border: 1px solid var(--border); }
.tab {
  background: transparent; border: none; color: var(--muted); padding: 8px 18px;
  border-radius: 8px; cursor: pointer; font-weight: 600; font-size: 0.85rem;
}
.tab.active { background: var(--surface-2); color: var(--text); }
.topbar-right { display: flex; align-items: center; gap: 12px; }

/* --- Métricas --- */
.metrics { display: flex; gap: 14px; padding: 20px 24px 0; flex-wrap: wrap; }
.metric {
  flex: 1; min-width: 150px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 18px;
}
.metric .num { font-size: 1.7rem; font-weight: 800; letter-spacing: -0.02em; }
.metric .lbl { color: var(--muted); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em; }

/* --- Contenido --- */
.content { padding: 24px; flex: 1; }
.view-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.view-head h2 { font-size: 1.15rem; font-weight: 700; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }

/* --- Tarjeta --- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; display: flex; flex-direction: column; gap: 12px;
}
.card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.card-title { font-weight: 700; font-size: 1rem; }
.card-sub { color: var(--muted); font-size: 0.8rem; }
.badge { font-size: 0.68rem; padding: 3px 9px; border-radius: 20px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; }
.badge.green { background: rgba(63,185,80,.14); color: var(--green); }
.badge.red { background: rgba(248,81,73,.14); color: var(--red); }
.badge.blue { background: var(--accent-soft); color: var(--accent); }
.card-row { display: flex; justify-content: space-between; font-size: 0.85rem; padding: 6px 0; border-top: 1px solid var(--border); }
.card-row span:first-child { color: var(--muted); }
.card-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.keybox {
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 10px; font-family: ui-monospace, monospace; font-size: 0.72rem;
  color: var(--muted); word-break: break-all; cursor: pointer;
}
.keybox:hover { color: var(--text); border-color: var(--accent); }

/* --- Matriz de acceso (vendedor) --- */
.access-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 0; border-top: 1px solid var(--border);
}
.access-row .app-name { font-weight: 600; }
.access-row .app-name small { display: block; color: var(--muted); font-weight: 400; }
.access-controls { display: flex; align-items: center; gap: 10px; }
.access-controls input[type=number] {
  width: 90px; background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
  padding: 6px 8px; color: var(--text); font-size: 0.82rem;
}
/* switch */
.switch { position: relative; width: 42px; height: 24px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; inset: 0; background: var(--border); border-radius: 24px; cursor: pointer; transition: .2s; }
.slider::before { content: ""; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(18px); }

/* --- Modal --- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.6); backdrop-filter: blur(4px);
  display: grid; place-items: center; padding: 20px; z-index: 50;
}
.modal {
  background: var(--surface); border: 1px solid var(--border); border-radius: 18px;
  padding: 24px; width: 100%; max-width: 460px; max-height: 90vh; overflow-y: auto;
}
.modal h3 { font-size: 1.1rem; margin-bottom: 16px; }
.modal label { display: block; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); margin: 12px 0 4px; font-weight: 700; }
.modal input, .modal textarea {
  width: 100%; background: var(--bg); border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 12px; color: var(--text); font-size: 0.9rem; outline: none;
}
.modal input:focus, .modal textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.modal-actions { display: flex; gap: 10px; margin-top: 22px; }
.modal-actions button { flex: 1; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* --- Toast --- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  padding: 12px 20px; border-radius: 12px; font-size: 0.88rem; z-index: 100;
  box-shadow: 0 10px 30px rgba(0,0,0,.4);
}
.toast.err { border-color: var(--red); }
.empty { color: var(--muted); text-align: center; padding: 48px; grid-column: 1 / -1; }

/* --- Tabla de pagos --- */
.table-wrap { margin-top: 18px; overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
table.ledger { width: 100%; border-collapse: collapse; font-size: 0.85rem; min-width: 720px; }
table.ledger thead th {
  text-align: left; padding: 12px 14px; background: var(--surface); color: var(--muted);
  font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; border-bottom: 1px solid var(--border);
}
table.ledger tbody td { padding: 12px 14px; border-bottom: 1px solid var(--border); }
table.ledger tbody tr:last-child td { border-bottom: none; }
table.ledger tbody tr:hover { background: var(--surface); }
table.ledger .right, .ledger th.right { text-align: right; font-weight: 700; }
table.ledger .mono { font-family: ui-monospace, monospace; font-size: 0.76rem; color: var(--muted); }
