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

:root {
  --brand-color: #0a2540;
  --bg: #f6f9fc;
  --surface: #ffffff;
  --border: #e5e7eb;
  --text: #1a1a2e;
  --text-muted: #6b7280;
  --sidebar-width: 260px;
}

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

/* ── Sidebar ── */
.sidebar {
  position: fixed; top: 0; left: 0; height: 100vh; width: var(--sidebar-width);
  background: var(--brand-color); display: flex; flex-direction: column;
  padding: 20px 0; z-index: 100;
}
.sidebar__brand {
  position: absolute; top: 40px; left: 20px;
  display: flex; flex-direction: row; align-items: center; gap: 10px;
}
.sidebar__logo { width: 36px; height: 36px; object-fit: contain; border-radius: 6px; flex-shrink: 0; }
.sidebar__brand-name {
  color: rgba(255,255,255,0.95); font-size: 15px; font-weight: 700;
  letter-spacing: -0.01em; line-height: 1.3; white-space: nowrap;
}
.sidebar #langSwitcherSidebar { display: none; }

/* ── Main content ── */
.main { margin-left: var(--sidebar-width); padding: 28px 32px; min-height: 100vh; }

/* ── Top bar ── */
.topbar { display: flex; justify-content: flex-end; margin-bottom: 24px; }
.lang-switcher { display: flex; gap: 4px; }
.lang-switcher button {
  background: none; border: 1px solid var(--border); border-radius: 4px;
  padding: 4px 10px; font-size: 12px; font-weight: 600; cursor: pointer; color: var(--text-muted);
}
.lang-switcher button.active { border-color: var(--brand-color); color: var(--brand-color); }

/* ── Cards ── */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 24px; margin-bottom: 24px;
}
.card__title { font-size: 15px; font-weight: 700; padding-bottom: 16px; margin-bottom: 16px; border-bottom: 1px solid var(--border); }

/* ── Fiscal data ── */
.fiscal-data { font-size: 13px; line-height: 1.9; }
.fiscal-data__name { font-weight: 600; }
.fiscal-data__cif { color: var(--text-muted); margin-top: 4px; }
.fiscal-data__cif strong { color: var(--text); }
.btn-outline {
  display: inline-block; margin-top: 12px; padding: 7px 16px;
  border: 1.5px solid var(--brand-color); color: var(--brand-color);
  border-radius: 5px; font-size: 12px; font-weight: 600; letter-spacing: 0.05em;
  cursor: pointer; background: none; transition: background 0.15s, color 0.15s;
}
.btn-outline:hover { background: var(--brand-color); color: #fff; }

/* ── Popup blocked banner ── */
.popup-blocked-banner {
  display: flex; align-items: flex-start; gap: 10px;
  background: #fffbeb; border: 1px solid #fcd34d; border-radius: 6px;
  padding: 10px 14px; margin-bottom: 16px; font-size: 13px; color: #92400e; line-height: 1.5;
}
.popup-blocked-banner::before { content: "⚠"; font-size: 15px; flex-shrink: 0; margin-top: 1px; }

/* ── Invoice table ── */
.invoice-table { width: 100%; border-collapse: collapse; }
.invoice-table thead tr { background: #f9fafb; border-bottom: 1px solid var(--border); }
.invoice-table th {
  padding: 10px 16px; text-align: left; font-size: 11px; font-weight: 700;
  color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.07em;
}
.invoice-table td { padding: 13px 16px; font-size: 13px; border-bottom: 1px solid #f9fafb; }
.invoice-table tbody tr { cursor: pointer; transition: background 0.12s; }
.invoice-table tbody tr:hover { background: color-mix(in srgb, var(--brand-color) 6%, transparent); }
.invoice-table tbody tr:active { background: color-mix(in srgb, var(--brand-color) 12%, transparent); }
.invoice-table .col-amount { font-weight: 500; }
.invoice-table .col-right { text-align: right; }
.invoice-table .col-action { text-align: right; color: var(--brand-color); font-weight: 600; font-size: 12px; white-space: nowrap; }
.invoice-table .col-action--generating { color: var(--text-muted); display: inline-flex; align-items: center; gap: 6px; }
.invoice-table .col-action--ready { color: #059669; font-weight: 600; }
.invoice-table .col-action--error { color: #dc2626; font-weight: 600; }

/* ── Spinner ── */
@keyframes spin { to { transform: rotate(360deg); } }
.spinner { width: 13px; height: 13px; border: 2px solid var(--text-muted); border-top-color: transparent; border-radius: 50%; animation: spin 0.8s linear infinite; }

/* ── Pagination ── */
.pagination { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border-top: 1px solid var(--border); background: #f9fafb; border-radius: 0 0 10px 10px; margin-top: -1px; }
.pagination__info { font-size: 12px; color: var(--text-muted); }
.pagination__controls { display: flex; gap: 6px; }
.btn-page {
  border: 1px solid var(--border); border-radius: 5px; padding: 5px 12px;
  font-size: 12px; cursor: pointer; background: #fff; color: var(--text);
}
.btn-page:disabled { color: var(--text-muted); cursor: not-allowed; }
.btn-page--active { border-color: var(--brand-color); background: var(--brand-color); color: #fff; font-weight: 600; }

/* ── Login page ── */
.login-page { min-height: 100vh; display: flex; }
.login-page__brand {
  width: var(--sidebar-width);
  background: var(--brand-color);
  position: relative;
  flex-shrink: 0;
}
.login-page__brand-header {
  position: absolute; top: 40px; left: 20px;
  display: flex; flex-direction: row; align-items: center; gap: 10px;
}
.login-page__brand-logo {
  width: 36px; height: 36px; border-radius: 6px; object-fit: contain;
}
.login-page__brand-name {
  color: rgba(255,255,255,0.95); font-size: 15px; font-weight: 700;
  letter-spacing: -0.01em; line-height: 1.3;
}
.login-page__powered {
  position: absolute; bottom: 20px; left: 0; right: 0;
  text-align: center; font-size: 11px; color: rgba(255,255,255,0.6);
  text-decoration: none; letter-spacing: 0.02em;
}
.login-page__powered:hover { color: rgba(255,255,255,0.9); }
.login-page__content { flex: 1; display: flex; align-items: center; justify-content: center; }
.login-box { width: 100%; max-width: 400px; padding: 16px; }
.login-title { text-align: center; font-size: 20px; font-weight: 600; margin-bottom: 6px; }
.login-subtitle { text-align: center; font-size: 13px; color: var(--text-muted); margin-bottom: 24px; }
.login-form { background: var(--surface); border-radius: 10px; padding: 28px; box-shadow: 0 2px 12px rgba(0,0,0,0.08); }
.login-form label { display: block; font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 8px; }
.login-form input[type="email"] {
  width: 100%; border: 2px solid var(--border); border-radius: 6px; padding: 14px 16px;
  font-size: 15px; outline: none; transition: border-color 0.15s; margin-bottom: 16px;
}
.login-form input[type="email"]:focus { border-color: var(--brand-color); }
.btn-primary {
  width: 100%; background: var(--brand-color); color: #fff; border: none;
  border-radius: 6px; padding: 13px; font-weight: 600; font-size: 14px;
  letter-spacing: 0.02em; cursor: pointer; transition: opacity 0.15s;
}
.btn-primary:hover { opacity: 0.9; }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }
.alert { padding: 12px 16px; border-radius: 6px; font-size: 13px; margin-top: 16px; }
.alert--info { background: #eff6ff; color: #1d4ed8; }
.alert--error { background: #fef2f2; color: #dc2626; }

/* ── Verify page ── */
.verify-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.verify-box { max-width: 440px; text-align: center; }
.verify-icon { font-size: 48px; margin-bottom: 16px; }
.verify-title { font-size: 22px; font-weight: 700; margin-bottom: 8px; }
.verify-text { font-size: 14px; color: var(--text-muted); line-height: 1.6; }

/* ── Mobile ── */
@media (max-width: 640px) {
  :root { --sidebar-width: 0px; }
  .sidebar { position: static; width: 100%; height: 56px; flex-direction: row; padding: 0 16px; }
  .sidebar__brand { position: static; }
  .sidebar__logout { margin-top: 0; margin-left: auto; }
  .sidebar #langSwitcherSidebar { display: block; }
  .topbar { display: none; }
  .main { margin-left: 0; padding: 16px; }
  .invoice-table th:nth-child(2), .invoice-table td:nth-child(2) { display: none; }
  .col-action { display: block !important; }
  .login-page__brand { display: none; }
}

/* ── Multi-entity selector ── */
.entity-list { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.entity-list li a { display: block; padding: 12px 16px; border: 1px solid var(--border); border-radius: 8px; text-decoration: none; color: var(--brand-color, #0a2540); font-size: 14px; font-weight: 500; transition: background 0.15s, border-color 0.15s; }
.entity-list li a:hover { background: #f0f4f8; border-color: var(--brand-color, #0a2540); }
