/* PayTrack — estética Twenty CRM. Oscuro por defecto, claro con [data-theme="light"] */
:root {
  --bg: #141414;
  --panel: #1b1b1b;
  --panel-hover: #222;
  --border: #333;
  --text: #ebebeb;
  --text-muted: #999;
  --accent: #1961ed;
  --accent-soft: rgba(25, 97, 237, .15);
  --green: #2a9d63;
  --green-soft: rgba(42, 157, 99, .15);
  --red: #e5484d;
  --red-soft: rgba(229, 72, 77, .14);
  --gray-pill: #2a2a2a;
  --input-bg: #171717;
}
:root[data-theme="light"] {
  --bg: #fff;
  --panel: #fafafa;
  --panel-hover: #f0f0f0;
  --border: #e0e0e0;
  --text: #333;
  --text-muted: #888;
  --accent: #1961ed;
  --accent-soft: rgba(25, 97, 237, .1);
  --green: #1f7d4d;
  --green-soft: rgba(42, 157, 99, .12);
  --red: #d33d42;
  --red-soft: rgba(229, 72, 77, .1);
  --gray-pill: #ececec;
  --input-bg: #fff;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg); color: var(--text);
  font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 14px; line-height: 1.5;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code { background: var(--panel-hover); padding: 2px 6px; border-radius: 4px; }

/* topbar */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px; height: 52px;
  border-bottom: 1px solid var(--border); background: var(--bg);
  position: sticky; top: 0; z-index: 10;
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 14px; }
.brand { font-weight: 700; font-size: 15px; color: var(--text); display: flex; align-items: center; gap: 8px; }
.brand:hover { text-decoration: none; }
.brand-dot { width: 10px; height: 10px; border-radius: 3px; background: var(--accent); display: inline-block; }
.tenant-label {
  font-size: 12px; color: var(--text-muted);
  border: 1px solid var(--border); border-radius: 6px; padding: 2px 8px;
}
.nav-link { color: var(--text-muted); font-size: 13px; font-weight: 500; }
.nav-link:hover { color: var(--text); text-decoration: none; }
.inline-form { display: inline; }
.btn-plain { background: none; border: none; cursor: pointer; font: inherit; padding: 0; }
.theme-toggle {
  background: none; border: 1px solid var(--border); border-radius: 6px;
  cursor: pointer; padding: 3px 8px; font-size: 13px; line-height: 1;
}
:root:not([data-theme="light"]) .icon-moon { display: none; }
:root[data-theme="light"] .icon-sun { display: none; }

/* layout */
.container { max-width: 1200px; margin: 0 auto; padding: 24px 20px 60px; }
.page-title { font-size: 20px; font-weight: 600; margin-bottom: 18px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.page-head .page-title { margin-bottom: 4px; }
.back-link { font-size: 12px; color: var(--text-muted); display: inline-block; margin-bottom: 6px; }
.muted { color: var(--text-muted); }
.small { font-size: 12px; }

/* cards */
.card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 8px; padding: 16px;
}
.card-title { font-size: 14px; font-weight: 600; margin-bottom: 12px; }

.stat-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px; margin-bottom: 20px;
}
.stat-label { font-size: 12px; color: var(--text-muted); margin-bottom: 6px; }
.stat-value { font-size: 22px; font-weight: 600; }
.stat-value.accent { color: var(--green); }
.stat-value.danger { color: var(--red); }

.two-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 860px) { .two-cols { grid-template-columns: 1fr; } }

/* tablas */
.table-card { padding: 0; overflow: hidden; }
.table-card .card-title { padding: 14px 16px 0; }
.table-toolbar { display: flex; gap: 10px; padding: 14px 16px; flex-wrap: wrap; }
.table-scroll { overflow-x: auto; }
.tabla { width: 100%; border-collapse: collapse; }
.tabla th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--text-muted); font-weight: 500;
  padding: 10px 16px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.tabla td { padding: 11px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tabla tbody tr:last-child td { border-bottom: none; }
.tabla tbody tr.row-link { cursor: pointer; }
.tabla tbody tr.row-link:hover { background: var(--panel-hover); }
.td-strong { font-weight: 500; }
.td-progress { min-width: 160px; }
.empty { text-align: center; color: var(--text-muted); padding: 28px 16px !important; }

/* pills */
.pill {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 500; white-space: nowrap;
}
.pill-AL_DIA { background: var(--green-soft); color: var(--green); }
.pill-ATRASADO { background: var(--red-soft); color: var(--red); }
.pill-COMPLETADO, .pill-CANCELADO, .pill-NA { background: var(--gray-pill); color: var(--text-muted); }

/* progress */
.progress { height: 6px; background: var(--gray-pill); border-radius: 999px; overflow: hidden; }
.progress-lg { height: 10px; }
.progress-fill { height: 100%; background: var(--accent); border-radius: 999px; transition: width .3s; }

/* forms */
label { display: block; font-size: 12px; color: var(--text-muted); margin: 12px 0 4px; font-weight: 500; }
input, select {
  width: 100%; padding: 8px 10px; border-radius: 6px;
  border: 1px solid var(--border); background: var(--input-bg); color: var(--text);
  font: inherit; font-size: 14px;
}
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
input[readonly] { color: var(--text-muted); }
.input-search, .input-select { width: auto; min-width: 200px; }
.form-card { max-width: 640px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.form-card .btn-primary { margin-top: 18px; }

/* buttons */
.btn {
  display: inline-block; padding: 8px 16px; border-radius: 6px; cursor: pointer;
  border: 1px solid var(--border); background: var(--panel); color: var(--text);
  font: inherit; font-size: 13px; font-weight: 500;
}
.btn:hover { background: var(--panel-hover); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: #2e70f0; }
.btn-primary:disabled { opacity: .6; cursor: default; }
.btn-block { width: 100%; margin-top: 16px; }

/* alerts */
.alert {
  background: var(--red-soft); color: var(--red);
  border: 1px solid var(--red); border-radius: 8px;
  padding: 10px 14px; margin-bottom: 16px; font-size: 13px;
}

/* login */
.login-wrap { display: flex; justify-content: center; padding-top: 8vh; }
.login-card { width: 100%; max-width: 360px; text-align: center; padding: 28px; }
.login-card h1 { font-size: 22px; margin-bottom: 6px; }
.login-card form { text-align: left; margin-top: 14px; }

/* modal */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.55);
  display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px;
}
.modal-backdrop[hidden] { display: none; }
.modal { width: 100%; max-width: 400px; padding: 22px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.modal-error { margin-top: 14px; margin-bottom: 0; }

@media (max-width: 640px) {
  .topbar { padding: 0 12px; }
  .container { padding: 16px 12px 40px; }
  .tenant-label { display: none; }
  .stat-value { font-size: 18px; }
  .input-search, .input-select { min-width: 0; flex: 1; }
}

/* quién está conectado (barra superior) — mismo bloque que PayTrack */
.usuario-actual { display: inline-flex; align-items: center; gap: 7px; margin: 0 4px; }
.usuario-avatar {
  width: 24px; height: 24px; border-radius: 50%; background: #355272; color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; flex: none;
}
.usuario-nombre { font-size: 13px; font-weight: 600; }
.usuario-rol {
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  padding: 2px 7px; border-radius: 999px; background: rgba(53,82,114,.12); color: #355272;
}
@media (max-width: 720px) { .usuario-nombre, .usuario-rol { display: none; } }
.login-nota { font-size: 12px; line-height: 1.45; margin-top: 10px; }
.login-sep { position: relative; margin: 20px 0 4px; text-align: center;
  border-top: 1px solid rgba(105,117,134,.28); }
.login-sep span { position: relative; top: -10px; background: #fff; padding: 0 10px;
  color: #697586; font-size: 12px; }
