:root {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --border: #e5e7eb;
  --primary: #2563eb;
  --success: #15803d;
  --warn: #b45309;
  --error: #b91c1c;
  --radius-lg: 12px;
  --radius-md: 8px;
  --shadow: 0 8px 24px rgba(17, 24, 39, 0.06);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Inter", sans-serif;
  font-size: 15px;
  color: var(--text);
  background: var(--bg);
}
h1, h2, h3, p { margin: 0; }
.muted { color: var(--muted); font-size: 14px; }

.auth-body { background: #eef2ff; }
.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 24px;
}
.auth-header { margin-bottom: 20px; }
.auth-header h1 { font-size: 24px; margin-bottom: 8px; }
.auth-header p { color: var(--muted); }

.form-grid { display: grid; gap: 14px; }
.form-group { display: grid; gap: 8px; }
label { font-weight: 500; font-size: 14px; }

.input, .select, .textarea {
  width: 100%;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: var(--radius-md);
  padding: 10px 12px;
  outline: none;
  transition: border-color .2s ease, box-shadow .2s ease;
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}
.input.is-locked {
  background: #f3f4f6;
  color: #4b5563;
}

.btn {
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  padding: 10px 14px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
}
.btn:focus {
  outline: 2px solid rgba(37, 99, 235, .35);
  outline-offset: 1px;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-secondary { background: #fff; border-color: var(--border); color: var(--text); }
.btn-ghost { background: transparent; color: var(--text); border-color: transparent; }
.btn-danger { background: #fff; border-color: #fecaca; color: var(--error); }
.btn-sm { padding: 8px 12px; font-size: 13px; }
.btn-block { width: 100%; }
.btn-icon {
  width: 32px;
  height: 32px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.btn-icon i {
  font-size: 13px;
  line-height: 1;
  pointer-events: none;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 250px 1fr;
}
.sidebar {
  background: #fff;
  border-right: 1px solid var(--border);
  padding: 20px 16px;
}
.brand {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 24px;
}
.brand-mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  color: #fff;
  background: var(--primary);
  font-weight: 600;
}
.brand-title { font-weight: 600; }
.brand-subtitle { font-size: 12px; color: var(--muted); }

.menu { display: grid; gap: 6px; }
.menu-group { display: grid; gap: 4px; }
.menu-group-main { display: inline-flex; align-items: center; gap: 8px; }
.menu-group-toggle {
  width: 100%;
  text-align: left;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  padding: 10px 12px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  font-size: 15px;
  font-family: inherit;
}
.menu-group-toggle:hover { background: #f3f4f6; }
.menu-group-toggle.is-active { background: #e0e7ff; color: #1e40af; }
.menu-caret {
  font-size: 11px;
  color: #6b7280;
  transition: transform .2s ease;
}
.menu-group.is-open .menu-caret { transform: rotate(180deg); }
.submenu {
  display: none;
  gap: 4px;
  margin: 0 0 6px 24px;
  padding-left: 4px;
  border-left: 1px solid #e5e7eb;
}
.menu-group.is-open .submenu { display: grid; }
.submenu-item {
  display: block;
  text-decoration: none;
  color: #4b5563;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 13px;
}
.submenu-item:hover { background: #f3f4f6; color: #111827; }
.submenu-item.is-active { background: #eef2ff; color: #1d4ed8; }
.menu-item {
  text-decoration: none;
  color: var(--text);
  padding: 10px 12px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.menu-item:hover { background: #f3f4f6; }
.menu-item.is-active { background: #e0e7ff; color: #1e40af; }
.menu-icon { font-size: 10px; opacity: .8; }

.main-panel { display: grid; grid-template-rows: auto 1fr; }
.topbar {
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 12px 20px;
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
}
.search-wrap { width: min(520px, 100%); }
.topbar-actions { display: flex; gap: 8px; }

.content {
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
  padding: 20px;
  display: grid;
  gap: 18px;
}

/* Panel Superadmin: barra superior + menú lateral colapsable */
.platform-admin-app.content {
  max-width: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  gap: 0;
}
.platform-admin-app {
  --platform-topnav-height: 56px;
}
.platform-topnav {
  position: sticky;
  top: 0;
  z-index: 400;
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.06), 0 4px 18px rgba(15, 23, 42, 0.05);
}
.platform-topnav-inner {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: var(--platform-topnav-height);
  padding: 0 16px;
  max-width: 1680px;
  margin: 0 auto;
}
.platform-nav-toggle {
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}
.platform-nav-toggle:hover {
  background: #f3f4f6;
  border-color: #d1d5db;
}
.platform-nav-toggle:focus {
  outline: 2px solid rgba(37, 99, 235, 0.35);
  outline-offset: 2px;
}
.platform-nav-toggle-bars,
.platform-nav-toggle-bars::before,
.platform-nav-toggle-bars::after {
  display: block;
  width: 18px;
  height: 2px;
  background: #374151;
  border-radius: 1px;
  position: relative;
  transition: transform 0.2s ease, opacity 0.2s ease, background 0.2s ease;
}
.platform-nav-toggle-bars::before,
.platform-nav-toggle-bars::after {
  content: "";
  position: absolute;
  left: 0;
}
.platform-nav-toggle-bars::before { top: -6px; }
.platform-nav-toggle-bars::after { top: 6px; }
.platform-layout:not(.is-sidebar-collapsed) .platform-nav-toggle .platform-nav-toggle-bars {
  background: transparent;
}
.platform-layout:not(.is-sidebar-collapsed) .platform-nav-toggle .platform-nav-toggle-bars::before {
  transform: translateY(6px) rotate(45deg);
}
.platform-layout:not(.is-sidebar-collapsed) .platform-nav-toggle .platform-nav-toggle-bars::after {
  transform: translateY(-6px) rotate(-45deg);
}
.platform-topnav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.platform-topnav-logo {
  font-weight: 700;
  font-size: 1.125rem;
  letter-spacing: -0.02em;
  color: var(--text);
}
.platform-topnav-badge {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #4338ca;
  background: #eef2ff;
  border: 1px solid #c7d2fe;
  padding: 4px 9px;
  border-radius: 999px;
}
.platform-topnav-spacer {
  flex: 1;
  min-width: 8px;
}
.platform-topnav-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.platform-topnav-action .fa-solid {
  font-size: 14px;
}
.platform-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.platform-layout {
  flex: 1;
  display: flex;
  align-items: stretch;
  gap: 0;
  min-height: 0;
  position: relative;
}
.platform-sidebar-backdrop {
  display: none;
}
.platform-sidebar-backdrop.is-visible {
  display: block;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  top: var(--platform-topnav-height);
  background: rgba(15, 23, 42, 0.48);
  z-index: 280;
  backdrop-filter: blur(2px);
}
.platform-sidebar {
  flex: 0 0 264px;
  width: 264px;
  background: #0f172a;
  color: #e2e8f0;
  display: flex;
  flex-direction: column;
  padding: 20px 0 24px;
  border-right: 1px solid #1e293b;
  transition: flex-basis 0.28s ease, transform 0.28s ease, opacity 0.22s ease, border-color 0.2s ease, width 0.28s ease;
  z-index: 290;
}
.platform-sidebar-heading {
  margin: 0 0 12px;
  padding: 0 20px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #64748b;
}
.platform-menu {
  list-style: none;
  margin: 0;
  padding: 0 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.platform-menu-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  margin: 0;
  border: none;
  border-radius: var(--radius-md);
  background: transparent;
  color: #cbd5e1;
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}
.platform-menu-item:hover {
  background: rgba(255, 255, 255, 0.07);
  color: #fff;
}
.platform-menu-item.is-active {
  background: rgba(37, 99, 235, 0.25);
  color: #fff;
  box-shadow: inset 0 0 0 1px rgba(96, 165, 250, 0.4);
}
.platform-menu-icon {
  width: 1.2rem;
  text-align: center;
  opacity: 0.9;
  flex-shrink: 0;
}
.platform-menu-label {
  flex: 1;
  line-height: 1.35;
}
.platform-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px 22px 28px;
  background: var(--bg);
  overflow-x: auto;
}
.platform-page-header.page-header {
  display: block;
}
.platform-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}
@media (min-width: 992px) {
  .platform-layout.is-sidebar-collapsed .platform-sidebar {
    flex: 0 0 0;
    width: 0;
    min-width: 0;
    opacity: 0;
    padding-left: 0;
    padding-right: 0;
    overflow: hidden;
    border-right-width: 0;
    pointer-events: none;
  }
  .platform-sidebar-backdrop.is-visible {
    display: none !important;
  }
}
@media (max-width: 991px) {
  .platform-topnav-action-text {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }
  .platform-topnav-action {
    padding: 8px 12px;
  }
  .platform-sidebar {
    position: fixed;
    left: 0;
    top: var(--platform-topnav-height);
    bottom: 0;
    width: min(288px, 88vw);
    flex: none;
    transform: translateX(0);
    box-shadow: 8px 0 28px rgba(0, 0, 0, 0.18);
  }
  .platform-layout.is-sidebar-collapsed .platform-sidebar {
    transform: translateX(-108%);
    opacity: 1;
    pointer-events: none;
  }
  .platform-main {
    padding: 16px 14px 24px;
    width: 100%;
  }
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}
.page-header h1 { font-size: 22px; margin-bottom: 6px; }

.cards-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(180px, 1fr));
  gap: 14px;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: var(--shadow);
}
.card-label { color: var(--muted); font-size: 13px; margin-bottom: 8px; }
.card h2 { font-size: 28px; margin-bottom: 12px; }

.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  font-size: 12px;
  border-radius: 999px;
  border: 1px solid transparent;
}
.badge-draft { background: #f3f4f6; color: #374151; border-color: #e5e7eb; }
.badge-queued { background: #fff7ed; color: var(--warn); border-color: #fed7aa; }
.badge-approved { background: #f0fdf4; color: var(--success); border-color: #bbf7d0; }
.badge-rejected { background: #fef2f2; color: var(--error); border-color: #fecaca; }

.panel {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}
.panel-head {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.panel-body { padding: 16px; }

/* Acordeón pasos DGII e-CF (platform admin) */
.dgii-cert-accordion-item:not(.is-open) .dgii-cert-accordion-body {
  display: none;
}
button.panel-head.dgii-cert-accordion-toggle {
  width: 100%;
  text-align: left;
  cursor: pointer;
  background: #fff;
  font: inherit;
  color: inherit;
  margin: 0;
  justify-content: flex-start;
  gap: 10px;
}
.dgii-cert-accordion-chevron {
  display: inline-flex;
  width: 1.35em;
  justify-content: center;
  align-items: center;
  flex-shrink: 0;
  font-size: 0.75rem;
  line-height: 1;
  opacity: 0.65;
  transition: transform 0.18s ease;
}
.dgii-cert-accordion-item.is-open .dgii-cert-accordion-chevron {
  transform: rotate(90deg);
}
.dgii-cert-accordion-title {
  flex: 1;
  margin: 0;
  font-size: inherit;
  font-weight: 600;
}

.table-wrap { overflow: auto; }
.table {
  width: 100%;
  border-collapse: collapse;
}
.table th, .table td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}
.table th {
  position: sticky;
  top: 0;
  background: #fafafa;
  font-weight: 600;
  font-size: 13px;
  color: #374151;
}
.table tbody tr:hover { background: #fafafa; }
.text-right { text-align: right; }

.empty-state {
  padding: 24px 12px;
  display: grid;
  gap: 10px;
  place-items: center;
  color: var(--muted);
}

.inline-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.pager {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
  margin-top: 10px;
}
.pager .muted { font-size: 12px; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, .25);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-backdrop.is-open { display: flex; }
.modal {
  width: min(520px, 100%);
  background: #fff;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.modal-header, .modal-body { padding: 16px; }
.modal-header {
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.toast-root {
  position: fixed;
  right: 16px;
  bottom: 16px;
  display: grid;
  gap: 8px;
  z-index: 1000;
}
.toast {
  background: #111827;
  color: #fff;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
}

@media (max-width: 1024px) {
  .app-shell { grid-template-columns: 220px 1fr; }
  .cards-grid { grid-template-columns: repeat(2, minmax(180px, 1fr)); }
}
@media (max-width: 720px) {
  .topbar, .page-header { flex-direction: column; align-items: stretch; }
  .cards-grid { grid-template-columns: 1fr; }
}
