/* ═══════════════════════════════════════════════════
   RAKJO Portal de Clientes — Estilos globales
   ═══════════════════════════════════════════════════ */

/* ── Variables ───────────────────────────────────── */
:root {
  --rakjo-blue:       #1a3a5c;
  --rakjo-blue-mid:   #2c5282;
  --rakjo-blue-light: #3d72b8;
  --rakjo-accent:     #e8a020;
  --rakjo-accent-dark:#c8881a;
  --bg-page:          #f0f4f8;
  --bg-card:          #ffffff;
  --text-main:        #1a2840;
  --text-secondary:   #4a5568;
  --text-muted:       #718096;
  --border:           #d1dce8;
  --danger:           #c53030;
  --danger-bg:        #fff5f5;
  --success:          #276749;
  --success-bg:       #f0fff4;
  --shadow-sm:        0 1px 3px rgba(0,0,0,.10), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md:        0 4px 12px rgba(0,0,0,.10), 0 2px 4px rgba(0,0,0,.06);
  --shadow-lg:        0 10px 25px rgba(0,0,0,.12), 0 4px 8px rgba(0,0,0,.06);
  --radius:           10px;
  --radius-lg:        16px;
  --sidebar-w:        240px;
  --topbar-h:         62px;
}

/* ── Reset base ─────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  color: var(--text-main);
  background: var(--bg-page);
  min-height: 100vh;
}

a { color: var(--rakjo-blue-light); text-decoration: none; }
a:hover { text-decoration: underline; }

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
}

/* ════════════════════════════════════════════════════
   LAYOUT DE APLICACIÓN (sidebar + content)
   ════════════════════════════════════════════════════ */

.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ─────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--rakjo-blue);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow-y: auto;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 24px 20px 20px;
  border-bottom: 1px solid rgba(255,255,255,.12);
}

.sidebar-logo .logo-mark {
  width: 36px; height: 36px;
  background: var(--rakjo-accent);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 16px;
  color: var(--rakjo-blue);
  flex-shrink: 0;
  letter-spacing: -.5px;
}

.sidebar-logo .logo-text {
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  line-height: 1.2;
}
.sidebar-logo .logo-text small {
  display: block;
  font-weight: 400;
  font-size: 11px;
  color: rgba(255,255,255,.55);
  text-transform: uppercase;
  letter-spacing: .5px;
}

.sidebar-nav {
  padding: 16px 12px;
  flex: 1;
}

.nav-section-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: rgba(255,255,255,.35);
  padding: 8px 8px 4px;
  margin-top: 8px;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  color: rgba(255,255,255,.75);
  font-size: 14px;
  font-weight: 500;
  transition: background .15s, color .15s;
  text-decoration: none;
}

.sidebar-nav a:hover {
  background: rgba(255,255,255,.10);
  color: #fff;
  text-decoration: none;
}

.sidebar-nav a.active {
  background: rgba(255,255,255,.15);
  color: #fff;
}

.sidebar-nav a .nav-icon {
  font-size: 18px;
  width: 22px;
  text-align: center;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,.12);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-user .user-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--rakjo-accent);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  color: var(--rakjo-blue);
  font-size: 13px;
  flex-shrink: 0;
}

.sidebar-user .user-info {
  flex: 1;
  min-width: 0;
}
.sidebar-user .user-info strong {
  display: block;
  color: #fff;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-user .user-info small {
  color: rgba(255,255,255,.45);
  font-size: 11px;
}

.sidebar-user .btn-logout {
  background: none;
  border: none;
  cursor: pointer;
  color: rgba(255,255,255,.45);
  font-size: 17px;
  padding: 4px;
  border-radius: 4px;
  transition: color .15s;
  flex-shrink: 0;
}
.sidebar-user .btn-logout:hover { color: rgba(255,255,255,.85); }

/* ── Main content ─────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.main-topbar {
  height: var(--topbar-h);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 32px;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.main-topbar h1 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-main);
  flex: 1;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.page-body {
  padding: 32px;
  flex: 1;
}

/* ════════════════════════════════════════════════════
   CARDS / STATS
   ════════════════════════════════════════════════════ */

.card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.card-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.card-header h2 {
  font-size: 16px;
  font-weight: 700;
  flex: 1;
}

.card-body {
  padding: 24px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.stat-card .stat-icon {
  font-size: 26px;
  margin-bottom: 10px;
}

.stat-card .stat-value {
  font-size: 30px;
  font-weight: 800;
  color: var(--rakjo-blue);
  line-height: 1;
}

.stat-card .stat-label {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ════════════════════════════════════════════════════
   SERVICE TILES (dashboard cliente)
   ════════════════════════════════════════════════════ */

.services-section-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--text-muted);
  margin: 28px 0 14px;
}
.services-section-title:first-child { margin-top: 0; }

.tiles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 18px;
}

.tile {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .2s, transform .2s;
  position: relative;
  overflow: hidden;
  text-decoration: none;
  color: inherit;
}

/* Enlace principal que cubre todo el tile */
.tile-main-link {
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-decoration: none;
  color: inherit;
  flex: 1;
}
.tile-main-link:hover { text-decoration: none; }

/* Botón "abrir en nueva ventana" — esquina superior derecha */
.tile-newwin-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  font-size: 14px;
  text-decoration: none;
  color: var(--text-secondary);
  background: transparent;
  opacity: 0;
  transition: opacity .15s, background .15s, color .15s;
}
.tile.active:hover .tile-newwin-btn {
  opacity: 1;
}
.tile-newwin-btn:hover {
  background: var(--stripe-color, var(--rakjo-blue-mid));
  color: #fff !important;
  opacity: 1 !important;
}

.tile.active:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
  text-decoration: none;
}

.tile.upcoming {
  opacity: .65;
  cursor: default;
}

.tile-stripe {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: var(--stripe-color, var(--rakjo-blue-mid));
}

.tile-icon {
  font-size: 36px;
  line-height: 1;
}

.tile-name {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-main);
}

.tile-desc {
  font-size: 13.5px;
  color: var(--text-secondary);
  line-height: 1.5;
  flex: 1;
}

.tile-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--stripe-color, var(--rakjo-blue-mid));
  margin-top: 4px;
}

.tile-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
  background: #edf2f7;
  color: var(--text-muted);
  width: fit-content;
}

/* ════════════════════════════════════════════════════
   BOTONES
   ════════════════════════════════════════════════════ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  border: 1.5px solid transparent;
  transition: background .15s, border-color .15s, box-shadow .15s, opacity .15s;
  text-decoration: none;
  white-space: nowrap;
  line-height: 1.3;
}

.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn:hover { text-decoration: none; }

.btn-primary {
  background: var(--rakjo-blue);
  color: #fff;
  border-color: var(--rakjo-blue);
}
.btn-primary:hover:not(:disabled) {
  background: var(--rakjo-blue-mid);
  border-color: var(--rakjo-blue-mid);
}

.btn-accent {
  background: var(--rakjo-accent);
  color: var(--rakjo-blue);
  border-color: var(--rakjo-accent);
}
.btn-accent:hover:not(:disabled) {
  background: var(--rakjo-accent-dark);
  border-color: var(--rakjo-accent-dark);
}

.btn-outline {
  background: transparent;
  color: var(--rakjo-blue);
  border-color: var(--border);
}
.btn-outline:hover:not(:disabled) {
  background: var(--bg-page);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}
.btn-danger:hover:not(:disabled) { background: #9b2c2c; }

.btn-sm {
  padding: 5px 12px;
  font-size: 13px;
}

.btn-icon {
  width: 34px; height: 34px;
  padding: 0;
  border-radius: 8px;
}

/* ════════════════════════════════════════════════════
   FORMULARIOS
   ════════════════════════════════════════════════════ */

.form-group {
  margin-bottom: 18px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  padding: 9px 13px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  background: var(--bg-card);
  color: var(--text-main);
  font-size: 14.5px;
  transition: border-color .15s, box-shadow .15s;
  appearance: none;
}

.form-control:focus {
  outline: none;
  border-color: var(--rakjo-blue-light);
  box-shadow: 0 0 0 3px rgba(61,114,184,.15);
}

.form-control::placeholder { color: #b0bec5; }

/* Aliases usados en templates RAIE (form-input / form-label / form-grid) */
.form-input {
  width: 100%;
  padding: 9px 13px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  background: var(--bg-card);
  color: var(--text-main);
  font-size: 14.5px;
  transition: border-color .15s, box-shadow .15s;
  appearance: none;
  box-sizing: border-box;
}
.form-input:focus {
  outline: none;
  border-color: var(--rakjo-blue-light);
  box-shadow: 0 0 0 3px rgba(61,114,184,.15);
}
.form-input::placeholder { color: #b0bec5; }
.form-input[readonly] { background: #f7f7f7; cursor: default; }

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px 24px;
}
@media (max-width: 700px) { .form-grid { grid-template-columns: 1fr; } }

/* Ocupa las dos columnas del grid */
.form-grid .full-width { grid-column: 1 / -1; }

.form-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 5px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

@media (max-width: 600px) { .form-row { grid-template-columns: 1fr; } }

.form-check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}

.form-check:hover { border-color: var(--rakjo-blue-light); background: #f7faff; }
.form-check input[type="checkbox"] { margin-top: 3px; flex-shrink: 0; accent-color: var(--rakjo-blue); }
.form-check .check-label { font-size: 14px; font-weight: 500; }
.form-check .check-hint { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.services-checkboxes {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
}

/* ════════════════════════════════════════════════════
   TABLA DE USUARIOS (admin)
   ════════════════════════════════════════════════════ */

.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--bg-card);
  box-shadow: var(--shadow-sm);
}

table {
  width: 100%;
  border-collapse: collapse;
}

thead th {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-muted);
  padding: 12px 16px;
  background: #f7f9fc;
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background .12s;
}

tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: #f7f9fc; }

tbody td {
  padding: 13px 16px;
  font-size: 14px;
  vertical-align: middle;
}

.td-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

/* ── Badges ─────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11.5px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 20px;
  white-space: nowrap;
}

.badge-green  { background: #c6f6d5; color: #22543d; }
.badge-red    { background: #fed7d7; color: #742a2a; }
.badge-blue   { background: #bee3f8; color: #1a365d; }
.badge-gray   { background: #edf2f7; color: #4a5568; }
.badge-amber  { background: #fefcbf; color: #744210; }

/* ── Toggle switch ──────────────────────────────── */
.toggle-wrap {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}

.toggle {
  width: 40px; height: 22px;
  background: #cbd5e0;
  border-radius: 11px;
  position: relative;
  transition: background .2s;
  flex-shrink: 0;
}

.toggle::after {
  content: '';
  position: absolute;
  width: 16px; height: 16px;
  background: #fff;
  border-radius: 50%;
  top: 3px; left: 3px;
  transition: left .2s;
  box-shadow: 0 1px 3px rgba(0,0,0,.25);
}

.toggle.on {
  background: var(--rakjo-blue-light);
}

.toggle.on::after { left: 21px; }

/* ════════════════════════════════════════════════════
   PÁGINA DE LOGIN / SETUP
   ════════════════════════════════════════════════════ */

.auth-layout {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--rakjo-blue) 0%, var(--rakjo-blue-mid) 60%, #4a7fc1 100%);
  padding: 24px;
}

.auth-box {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 420px;
  padding: 40px 36px;
}

.auth-logo {
  text-align: center;
  margin-bottom: 28px;
}

.auth-logo .logo-circle {
  width: 60px; height: 60px;
  background: var(--rakjo-accent);
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 24px;
  color: var(--rakjo-blue);
  margin-bottom: 12px;
  letter-spacing: -1px;
}

.auth-logo h1 {
  font-size: 20px;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.2;
}

.auth-logo p {
  font-size: 13.5px;
  color: var(--text-muted);
  margin-top: 4px;
}

.auth-divider {
  height: 1px;
  background: var(--border);
  margin: 24px 0;
}

.auth-footer {
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 20px;
}

/* ── Toast / Alert ──────────────────────────────── */
.alert {
  padding: 11px 14px;
  border-radius: 8px;
  font-size: 14px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 16px;
}

.alert-error   { background: var(--danger-bg); color: var(--danger); border: 1px solid #fed7d7; }
.alert-success { background: var(--success-bg); color: var(--success); border: 1px solid #c6f6d5; }
.alert-info    { background: #ebf8ff; color: #2a4365; border: 1px solid #bee3f8; }

/* ── Toast popup ────────────────────────────────── */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 360px;
}

.toast {
  background: var(--text-main);
  color: #fff;
  padding: 13px 18px;
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  font-size: 14px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  animation: slideIn .25s ease;
}

.toast.toast-error   { background: var(--danger); }
.toast.toast-success { background: var(--success); }

@keyframes slideIn {
  from { transform: translateX(110%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* ── Modal ──────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn .15s ease;
}

.modal-box {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 28px;
  max-width: 420px;
  width: 100%;
}

.modal-box h3 { font-size: 17px; font-weight: 700; margin-bottom: 10px; }
.modal-box p  { font-size: 14px; color: var(--text-secondary); margin-bottom: 22px; }

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ── Spinner ─────────────────────────────────────── */
.spinner {
  display: inline-block;
  width: 18px; height: 18px;
  border: 2.5px solid rgba(255,255,255,.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .6s linear infinite;
  flex-shrink: 0;
}

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

/* ── Empty state ─────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 24px;
  color: var(--text-muted);
}

.empty-state .empty-icon { font-size: 48px; margin-bottom: 14px; }
.empty-state h3 { font-size: 17px; font-weight: 700; color: var(--text-secondary); margin-bottom: 6px; }
.empty-state p  { font-size: 14px; }

/* ── Misc ─────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

.page-header h2 {
  font-size: 20px;
  font-weight: 800;
  flex: 1;
}

.text-muted { color: var(--text-muted); }
.text-sm    { font-size: 13px; }
.mt-4       { margin-top: 16px; }
.mt-8       { margin-top: 32px; }
.mb-4       { margin-bottom: 16px; }
.gap-2      { gap: 8px; }
.flex       { display: flex; }
.items-center { align-items: center; }
.flex-1     { flex: 1; }

/* ── Loading overlay ─────────────────────────────── */
.loading-overlay {
  position: fixed; inset: 0;
  background: rgba(255,255,255,.7);
  display: flex; align-items: center; justify-content: center;
  z-index: 300;
}

.loading-overlay .spin-big {
  width: 44px; height: 44px;
  border: 4px solid var(--border);
  border-top-color: var(--rakjo-blue);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

/* ── Responsive ──────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); transition: transform .25s; }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .page-body { padding: 20px 16px; }
  .tiles-grid { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }

  /* Tabla de usuarios: forzar scroll horizontal en lugar de colapsar */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* Columna de acciones: los toggles van en varias filas */
  .td-actions { max-width: 160px; }
}

/* ── Secciones colapsables ───────────────────────────────────────── */
.collapsible-header {
  cursor: pointer;
  user-select: none;
}
.collapsible-header:hover {
  background: #f0f4f8;
}
.collapse-arrow {
  font-size: .7rem;
  color: var(--text-muted);
  transition: transform .2s ease;
  display: inline-block;
  width: 14px;
}
.collapsible-card.open .collapse-arrow {
  transform: rotate(90deg);
}
.collapsible-body {
  overflow: hidden;
}

/* ── Claves API de servicios ─────────────────────────────────────── */
.api-keys-grid {
  display: flex; flex-direction: column; gap: 0;
}
.api-key-row {
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  padding: .9rem 1.25rem;
  border-bottom: 1px solid var(--border);
}
.api-key-row:last-child { border-bottom: none; }
.api-key-info {
  display: flex; align-items: center; gap: .65rem; min-width: 200px; flex: 1;
}
.api-key-icon { font-size: 1.4rem; }
.api-key-label { font-size: .78rem; color: var(--text-muted); margin-top: .1rem; }
.api-key-status {
  font-size: .83rem; font-weight: 600; min-width: 160px;
  display: flex; align-items: center; gap: .4rem; flex-wrap: wrap;
}
.api-key-status.status-ok     { color: #276749; }
.api-key-status.status-missing { color: #b45309; }
.key-hint {
  font-size: .75rem; font-weight: 400; color: var(--text-muted);
  font-family: monospace; letter-spacing: .05em;
}
.api-key-action {
  display: flex; align-items: center; gap: .5rem;
}

/* ── Selector de idioma ──────────────────────────────────────────── */
.lang-switcher {
  display: flex;
  align-items: center;
  gap: .4rem;
  padding: .5rem 1rem;
  font-size: .82rem;
  color: var(--text-muted);
}
.lang-switcher select {
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font-size: .82rem;
  padding: .2rem .4rem;
  cursor: pointer;
  outline: none;
}
.lang-switcher select:focus {
  border-color: var(--primary);
}

/* Variante en pantalla de login (centrada debajo del formulario) */
.lang-switcher-auth {
  justify-content: center;
  margin-top: 1rem;
  padding: 0;
}

/* ════════════════════════════════════════════════════
   PANEL (usado en RAIE Admin y Portal Empresa)
   ════════════════════════════════════════════════════ */

.panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.panel-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: #f7f9fc;
}

.panel-header h3 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-main);
}

.panel-body {
  padding: 20px;
}

.table-wrapper {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table thead th {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-muted);
  padding: 12px 16px;
  background: #f7f9fc;
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
}

.data-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background .12s;
}
.data-table tbody tr:last-child { border-bottom: none; }
.data-table tbody tr:hover { background: #f7f9fc; }
.data-table tbody td {
  padding: 13px 16px;
  font-size: 14px;
  vertical-align: middle;
}

.badge-active   { background: #c6f6d5; color: #22543d; }
.badge-warn     { background: #fefcbf; color: #744210; }
.badge-inactive { background: #edf2f7; color: #4a5568; }
.badge-danger   { background: #fed7d7; color: #742a2a; }
.badge-info     { background: #bee3f8; color: #1a365d; }
.badge-draft    { background: #edf2f7; color: #4a5568; }
.badge-issued   { background: #bee3f8; color: #1a365d; }
.badge-sent     { background: #c6f6d5; color: #22543d; }
.badge-paid     { background: #c6f6d5; color: #22543d; font-weight: 700; }
.badge-overdue  { background: #fed7d7; color: #742a2a; }
.badge-cancelled { background: #edf2f7; color: #718096; text-decoration: line-through; }

.input-sm {
  padding: 6px 10px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  background: var(--bg-card);
  color: var(--text-main);
}
.input-sm:focus {
  outline: none;
  border-color: var(--rakjo-blue-light);
  box-shadow: 0 0 0 3px rgba(61,114,184,.15);
}

.prefs-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 5px;
}

/* ════════════════════════════════════════════════════
   PROGRESS BAR (Fase 2 — Consumo)
   ════════════════════════════════════════════════════ */

.progress-group {
  margin-bottom: 16px;
}

.progress-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 6px;
}

.progress-label-text {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

.progress-label-value {
  font-size: 12px;
  color: var(--text-muted);
}

.progress-bar-track {
  width: 100%;
  height: 10px;
  background: #e2e8f0;
  border-radius: 5px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  border-radius: 5px;
  transition: width .4s ease;
  background: var(--rakjo-blue-light);
}

.progress-bar-fill.warn   { background: #d69e2e; }
.progress-bar-fill.danger { background: var(--danger); }
.progress-bar-fill.ok     { background: var(--success); }

/* ════════════════════════════════════════════════════
   TABS (Fase 2)
   ════════════════════════════════════════════════════ */

.tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: 24px;
}

.tab-btn {
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  transition: color .15s, border-color .15s;
}

.tab-btn:hover { color: var(--text-main); }
.tab-btn.active {
  color: var(--rakjo-blue);
  border-bottom-color: var(--rakjo-blue);
}

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ════════════════════════════════════════════════════
   CHART CONTAINER (Fase 2)
   ════════════════════════════════════════════════════ */

.chart-container {
  position: relative;
  width: 100%;
  max-width: 700px;
  height: 300px;
  margin: 0 auto;
}

.chart-container canvas {
  width: 100% !important;
  height: 100% !important;
}

/* ════════════════════════════════════════════════════
   INVOICE DETAIL
   ════════════════════════════════════════════════════ */

.invoice-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 24px;
  border-bottom: 1px solid var(--border);
}

.invoice-meta {
  font-size: 13px;
  color: var(--text-secondary);
}

.invoice-meta strong {
  display: block;
  font-size: 22px;
  color: var(--text-main);
  margin-bottom: 4px;
}

.invoice-total-box {
  text-align: right;
  background: var(--bg-page);
  padding: 16px 20px;
  border-radius: var(--radius);
}

.invoice-total-box .total-amount {
  font-size: 28px;
  font-weight: 800;
  color: var(--rakjo-blue);
}

.invoice-total-box .total-label {
  font-size: 12px;
  color: var(--text-muted);
}

/* ════════════════════════════════════════════════════
   ALERTS LIST (Fase 2 — Consumo)
   ════════════════════════════════════════════════════ */

.alert-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.alert-item {
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.alert-item.alert-overdue {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid #fed7d7;
}

.alert-item.alert-usage_warning {
  background: #fffff0;
  color: #744210;
  border: 1px solid #fefcbf;
}

/* ════════════════════════════════════════════════════
   GRID LAYOUTS (Fase 2)
   ════════════════════════════════════════════════════ */

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
}

@media (max-width: 768px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

/* ── Stat card RAIE gold variant ──────────────────── */
.stat-card.gold .stat-value {
  color: #c47f00;
}

.stat-card.gold {
  border-top: 3px solid #e8a020;
}

/* ════════════════════════════════════════════════════
   SERVICES GRID (dashboard portal cliente)
   ════════════════════════════════════════════════════ */

.services-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 20px;
  margin-top: 12px;
}

.service-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: box-shadow .15s, transform .15s;
}

.service-card:hover {
  box-shadow: 0 6px 20px rgba(0,0,0,.12);
  transform: translateY(-2px);
}

.service-icon {
  font-size: 32px;
  line-height: 1;
}

.service-badge-code {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: .5px;
  text-transform: uppercase;
}

.service-card h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}

.service-card p {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.45;
  flex: 1;
}

.service-card .btn {
  align-self: flex-start;
  margin-top: 8px;
}

.section-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

@media (max-width: 640px) {
  .services-grid {
    grid-template-columns: 1fr;
  }
}
