/* Evita el flash de contenido de Alpine antes de que inicialice */
[x-cloak] { display: none !important; }

:root {
  --bg: #F1F5F9;
  --bg-soft: #F8FAFC;
  --surface: #FFFFFF;
  --surface-soft: #F8FAFC;
  --border: #E2E8F0;
  --border-soft: #F1F5F9;
  --text: #0F172A;
  --muted: #475569;
  --muted-2: #94A3B8;
  --primary: #3B82F6;
  --primary-dark: #2563EB;
  --primary-2: #0EA5E9;
  --success: #16A34A;
  --warning: #D97706;
  --danger: #DC2626;
  --purple: #7C3AED;
  --warm: #EA580C;
  --sidebar-w: 260px;
  --topbar-h: 60px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,.08), 0 2px 4px rgba(0,0,0,.04);
  --shadow-lg: 0 10px 30px rgba(0,0,0,.10), 0 4px 8px rgba(0,0,0,.06);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
}

/* ── BRAND / LOGO ────────────────────────────────────────────── */
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}
.logoMark {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #EFF6FF;
  border: 1px solid #DBEAFE;
  box-shadow: 0 2px 8px rgba(59,130,246,.15);
  overflow: hidden;
  padding: 4px;
}
.logoMark img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.logoText {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text);
  line-height: 1;
}
.logoText span { color: var(--primary); }
.logo-sub {
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: .5px;
  text-transform: uppercase;
  color: var(--muted-2);
  margin-top: 2px;
}

/* ── SIDEBAR ─────────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 50;
  transition: transform .25s ease;
}

.sidebar-logo {
  padding: 16px 16px 14px;
  border-bottom: 1px solid var(--border-soft);
}

.sidebar-nav {
  flex: 1;
  padding: 12px 10px;
  overflow-y: auto;
}
.sidebar-section {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .8px;
  color: var(--muted-2);
  text-transform: uppercase;
  padding: 12px 10px 6px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 12px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 500;
  text-decoration: none;
  transition: all .12s ease;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  margin-bottom: 1px;
}
.nav-item:hover {
  color: var(--text);
  background: var(--bg);
}
.nav-item.active {
  color: var(--primary-dark);
  background: #EFF6FF;
  font-weight: 600;
}
.nav-item.active .nav-icon { color: var(--primary); }
.nav-icon {
  width: 16px;
  text-align: center;
  flex-shrink: 0;
  font-size: 14px;
}

.sidebar-footer {
  padding: 12px 10px;
  border-top: 1px solid var(--border-soft);
}
.nav-item.nav-logout {
  color: var(--muted-2);
}
.nav-item.nav-logout:hover {
  color: var(--danger);
  background: #FEF2F2;
}

/* ── TOPBAR ──────────────────────────────────────────────────── */
.topbar {
  position: fixed;
  top: 0; left: var(--sidebar-w); right: 0;
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 40;
}
.topbar-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}
.user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 4px 5px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 40px;
  font-size: 13px;
}
.user-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--purple));
  display: flex; align-items: center; justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  overflow: hidden;
  flex-shrink: 0;
}
.user-avatar img { width: 100%; height: 100%; object-fit: cover; }
.user-name { color: var(--muted); font-size: 13px; font-weight: 500; }

/* ── MAIN CONTENT ────────────────────────────────────────────── */
.main-area {
  margin-left: var(--sidebar-w);
  padding-top: var(--topbar-h);
  min-height: 100vh;
}
.page-content {
  padding: 28px 28px 40px;
  max-width: 1280px;
}

/* ── PAGE HEADER ─────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}
.page-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -.4px;
}
.page-subtitle {
  font-size: 13px;
  color: var(--muted-2);
  margin-top: 3px;
}

/* ── STAT CARDS ──────────────────────────────────────────────── */
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px 22px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--accent-color, var(--primary));
  opacity: .7;
}
.stat-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .5px;
  text-transform: uppercase;
  color: var(--muted-2);
  margin-bottom: 10px;
}
.stat-value {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -1px;
  line-height: 1;
}
.stat-icon {
  position: absolute;
  top: 18px; right: 18px;
  font-size: 20px;
  opacity: .12;
  color: var(--text);
}

/* ── TABLE CARDS ─────────────────────────────────────────────── */
.table-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
}
.card-padded { padding: 20px 22px; }

.table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-soft);
  background: var(--bg-soft);
}
.table-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
.data-table thead tr {
  border-bottom: 1px solid var(--border);
  background: var(--bg-soft);
}
.data-table thead th {
  padding: 10px 18px;
  text-align: left;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .5px;
  text-transform: uppercase;
  color: var(--muted-2);
}
.data-table tbody tr {
  border-bottom: 1px solid var(--border-soft);
  transition: background .1s;
}
.data-table tbody tr:last-child { border-bottom: none; }
.data-table tbody tr:hover { background: #F8FAFC; }
.data-table td {
  padding: 13px 18px;
  color: var(--muted);
  vertical-align: middle;
}
.data-table td.text-main { color: var(--text); font-weight: 500; }
.data-table td.mono { font-family: 'SF Mono', 'Fira Code', monospace; font-size: 12px; }

.empty-state {
  text-align: center;
  padding: 52px 20px;
  color: var(--muted-2);
  font-size: 13.5px;
}
.empty-state-icon { font-size: 28px; margin-bottom: 10px; opacity: .4; }

/* ── BADGES ──────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .1px;
}
.badge-success { background: #DCFCE7; color: #15803D; border: 1px solid #BBF7D0; }
.badge-danger  { background: #FEE2E2; color: #B91C1C; border: 1px solid #FECACA; }
.badge-warning { background: #FEF3C7; color: #B45309; border: 1px solid #FDE68A; }
.badge-blue    { background: #DBEAFE; color: #1D4ED8; border: 1px solid #BFDBFE; }
.badge-purple  { background: #EDE9FE; color: #6D28D9; border: 1px solid #DDD6FE; }
.badge-gray    { background: #F1F5F9; color: #475569; border: 1px solid #E2E8F0; }

.dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}
.dot-success { background: #22C55E; }
.dot-danger  { background: #EF4444; }
.dot-warning { background: #F59E0B; animation: pulse-dot 1.5s infinite; }
.dot-gray    { background: #CBD5E1; }

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: .35; }
}

/* ── BUTTONS ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: all .12s ease;
  white-space: nowrap;
  line-height: 1;
}
.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 1px 3px rgba(59,130,246,.3);
}
.btn-primary:hover { background: var(--primary-dark); box-shadow: 0 2px 8px rgba(59,130,246,.35); }

.btn-ghost {
  background: var(--surface);
  color: var(--muted);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--bg); color: var(--text); }

.btn-danger {
  background: #FEE2E2;
  color: #B91C1C;
  border: 1px solid #FECACA;
}
.btn-danger:hover { background: #FECACA; }

.btn-run {
  background: #DBEAFE;
  color: #1D4ED8;
  border: 1px solid #BFDBFE;
}
.btn-run:hover { background: #BFDBFE; }

.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 6px; }

/* ── FORMS ───────────────────────────────────────────────────── */
.form-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px 26px;
  box-shadow: var(--shadow-sm);
}
.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .2px;
  color: var(--muted);
  margin-bottom: 6px;
  text-transform: uppercase;
}
.form-input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  color: var(--text);
  font-size: 13.5px;
  transition: border-color .12s, box-shadow .12s;
  outline: none;
}
.form-input::placeholder { color: var(--muted-2); }
.form-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59,130,246,.12);
}
.form-input.mono { font-family: 'SF Mono', 'Fira Code', monospace; }

select.form-input { background: var(--surface); }

.form-hint {
  font-size: 11.5px;
  color: var(--muted-2);
  margin-top: 5px;
}
.form-hint code {
  color: var(--muted);
  background: var(--bg);
  padding: 1px 5px;
  border-radius: 4px;
  border: 1px solid var(--border);
}

.form-group { margin-bottom: 20px; }
.form-actions { display: flex; gap: 10px; padding-top: 8px; }

/* ── LOGIN PAGE ──────────────────────────────────────────────── */
.login-bg {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg);
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 40px 36px;
  box-shadow: var(--shadow-lg);
  text-align: center;
}
.login-logo {
  margin: 0 auto 20px;
}
.login-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -.4px;
  margin-bottom: 6px;
}
.login-sub {
  font-size: 13px;
  color: var(--muted-2);
  margin-bottom: 32px;
  line-height: 1.5;
}
.btn-google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  padding: 12px 20px;
  border-radius: 10px;
  border: 1px solid var(--border);
  cursor: pointer;
  text-decoration: none;
  transition: all .12s;
  box-shadow: var(--shadow-sm);
}
.btn-google:hover { background: var(--bg); box-shadow: var(--shadow-md); }

/* ── LINKS ───────────────────────────────────────────────────── */
a.link { color: var(--primary); text-decoration: none; font-weight: 500; }
a.link:hover { color: var(--primary-dark); text-decoration: underline; }

/* ── GRID HELPERS ────────────────────────────────────────────── */
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.grid-2-1 { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; }

@media (max-width: 1024px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-2-1 { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .topbar { left: 0; }
  .main-area { margin-left: 0; }
}

/* ── MISC ────────────────────────────────────────────────────── */
.truncate-url { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-block; vertical-align: middle; }
.spacer { flex: 1; }
.divider { height: 1px; background: var(--border-soft); margin: 6px 0; }
