:root {
  --bs-font-sans-serif: 'Roboto', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --bs-body-font-family: var(--bs-font-sans-serif);
  --bm-ink: #172033;
  --bm-muted: #64748b;
  --bm-border: rgba(148, 163, 184, 0.22);
  --bm-surface: rgba(255, 255, 255, 0.92);
  --bm-primary: #1d4ed8;
  --bm-primary-soft: rgba(29, 78, 216, 0.1);
  --bm-success: #047857;
  --bm-warning: #b45309;
  --bm-danger: #dc2626;
  --bm-shadow: 0 22px 60px rgba(15, 23, 42, 0.08);
}

html {
  font-size: 14px;
}

@media (min-width: 768px) {
  html {
    font-size: 16px;
  }
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
  box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}

html {
  position: relative;
  min-height: 100%;
}

body {
  margin-bottom: 60px;
  font-family: var(--bs-body-font-family);
}

.auth-page {
  min-height: 100vh;
  margin-bottom: 0;
  background: linear-gradient(135deg, #eef4ff 0%, #f8fafc 45%, #e0f2fe 100%);
}

.auth-shell {
  display: flex;
  min-height: 100vh;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 440px;
  padding: 40px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(16px);
}

.auth-logo {
  display: flex;
  width: 64px;
  height: 64px;
  align-items: center;
  justify-content: center;
  border-radius: 18px;
  background: linear-gradient(135deg, #0d6efd, #0ea5e9);
  color: #fff;
  font-size: 1.35rem;
  font-weight: 700;
}

.auth-submit {
  border-radius: 12px;
  font-weight: 700;
}

.auth-card .form-control {
  border-radius: 12px;
}

.admin-body {
  min-height: 100vh;
  margin-bottom: 0;
  background:
    radial-gradient(circle at 16% 8%, rgba(59, 130, 246, 0.12), transparent 28%),
    radial-gradient(circle at 88% 0%, rgba(20, 184, 166, 0.1), transparent 24%),
    linear-gradient(180deg, #f7faff 0%, #edf2f7 100%);
  color: var(--bm-ink);
}

.admin-layout {
  min-height: 100vh;
}

.admin-sidebar {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 1030;
  width: 260px;
  padding: 24px 18px;
  overflow-y: auto;
  background:
    linear-gradient(180deg, rgba(15, 23, 42, 0.98) 0%, rgba(17, 24, 39, 0.98) 100%),
    radial-gradient(circle at top left, rgba(59, 130, 246, 0.32), transparent 38%);
  color: #fff;
  box-shadow: 18px 0 50px rgba(15, 23, 42, 0.12);
}

.admin-sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1025;
  border: 0;
  background: rgba(15, 23, 42, 0.48);
}

.admin-brand {
  display: flex;
  align-items: center;
  min-height: 48px;
  padding: 0 14px;
  color: #fff;
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  text-decoration: none;
}

.admin-brand:hover {
  color: #fff;
}

.admin-menu {
  display: grid;
  gap: 8px;
  margin-top: 32px;
}

.admin-menu-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 14px;
  border: 1px solid transparent;
  border-radius: 14px;
  color: #a8b3c7;
  font-weight: 700;
  text-decoration: none;
  transition: background-color 0.18s ease, border-color 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

.admin-menu-link:hover,
.admin-menu-link.active {
  border-color: rgba(147, 197, 253, 0.18);
  color: #fff;
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.95), rgba(14, 165, 233, 0.82));
  box-shadow: 0 16px 36px rgba(37, 99, 235, 0.22);
  transform: translateX(2px);
}

.admin-menu-icon {
  display: inline-flex;
  width: 22px;
  height: 22px;
}

.admin-menu-icon svg,
.admin-icon-button svg {
  width: 100%;
  height: 100%;
  fill: currentColor;
}

.admin-panel {
  display: flex;
  min-height: 100vh;
  flex-direction: column;
  margin-left: 260px;
}

.admin-header {
  position: sticky;
  top: 0;
  z-index: 1020;
  display: flex;
  min-height: 72px;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.2);
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(18px);
  box-shadow: 0 12px 36px rgba(15, 23, 42, 0.04);
}

.admin-header-title {
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.admin-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

.admin-mobile-menu {
  display: none;
  width: 42px;
  height: 42px;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 14px;
  background: #fff;
  color: #0f172a;
}

.admin-mobile-menu svg {
  width: 24px;
  height: 24px;
  fill: currentColor;
}

.admin-icon-button {
  display: inline-flex;
  width: 42px;
  height: 42px;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 14px;
  background: #fff;
  color: #475569;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, color 0.18s ease;
}

.admin-icon-button:hover,
.admin-icon-button:focus {
  border-color: rgba(13, 110, 253, 0.42);
  color: #0d6efd;
  box-shadow: 0 10px 25px rgba(15, 23, 42, 0.08);
}

.admin-notification {
  position: relative;
}

.admin-notification-toggle {
  position: relative;
}

.admin-notification-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border: 2px solid #fff;
  border-radius: 999px;
  background: #dc2626;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 16px;
  text-align: center;
}

.admin-notification-menu {
  width: min(360px, calc(100vw - 32px));
  padding: 0;
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, 0.24);
  border-radius: 18px;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.18);
}

.admin-notification-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.18);
}

.admin-notification-item {
  display: block;
  padding: 12px 16px;
  color: #0f172a;
  text-decoration: none;
  border-bottom: 1px solid rgba(148, 163, 184, 0.14);
}

.admin-notification-item:hover,
.admin-notification-item:focus {
  background: #f8fafc;
  color: #0d6efd;
}

.admin-notification-item span {
  display: block;
  font-weight: 700;
}

.admin-notification-item small {
  display: block;
  margin-top: 4px;
  color: #64748b;
  line-height: 1.35;
}

.admin-notification-item.unread {
  background: #eff6ff;
}

.admin-notification-empty {
  padding: 18px 16px;
  color: #64748b;
  text-align: center;
}

.admin-main {
  flex: 1;
  padding: 28px;
}

.admin-page-title {
  margin-bottom: 6px;
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.admin-page-subtitle {
  margin-bottom: 24px;
  color: #64748b;
}

.admin-dashboard-card {
  position: relative;
  overflow: hidden;
  padding: 22px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 22px;
  background: linear-gradient(180deg, #fff 0%, #f8fbff 100%);
  box-shadow: var(--bm-shadow);
  transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.admin-dashboard-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 4px;
  background: linear-gradient(90deg, #2563eb, #14b8a6);
  opacity: 0.78;
}

.admin-dashboard-card:hover {
  border-color: rgba(37, 99, 235, 0.28);
  box-shadow: 0 28px 70px rgba(15, 23, 42, 0.11);
  transform: translateY(-2px);
}

.admin-footer {
  padding: 18px 28px;
  border-top: 1px solid rgba(148, 163, 184, 0.22);
  color: #64748b;
  text-align: center;
  background: #fff;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 18px;
}

.settings-card {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  padding: 24px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 22px;
  background: #fff;
  color: #172033;
  text-decoration: none;
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.06);
  transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.settings-card:hover {
  border-color: rgba(13, 110, 253, 0.36);
  color: #172033;
  box-shadow: 0 22px 55px rgba(15, 23, 42, 0.1);
  transform: translateY(-2px);
}

.settings-card-icon {
  display: inline-flex;
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  border-radius: 16px;
  background: rgba(13, 110, 253, 0.1);
  color: #0d6efd;
}

.settings-card-icon svg {
  width: 26px;
  height: 26px;
  fill: currentColor;
}

.settings-card-title,
.settings-card-description {
  display: block;
}

.settings-card-title {
  margin-bottom: 6px;
  font-size: 1.05rem;
  font-weight: 800;
}

.settings-card-description {
  color: #64748b;
  line-height: 1.5;
}

.settings-form-card {
  max-width: 620px;
  padding: 28px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 22px;
  background: #fff;
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.06);
}

.settings-form-card .form-control {
  border-radius: 12px;
}

.misa-hero {
  position: relative;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
  padding: 28px;
  overflow: hidden;
  border: 1px solid rgba(147, 197, 253, 0.35);
  border-radius: 28px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.96), rgba(239, 246, 255, 0.88)),
    radial-gradient(circle at 84% 18%, rgba(20, 184, 166, 0.18), transparent 34%);
  box-shadow: var(--bm-shadow);
}

.misa-hero::after {
  content: "";
  position: absolute;
  right: -52px;
  bottom: -76px;
  width: 220px;
  height: 220px;
  border: 34px solid rgba(37, 99, 235, 0.06);
  border-radius: 50%;
}

.misa-hero > * {
  position: relative;
  z-index: 1;
}

.misa-hero .admin-page-subtitle {
  max-width: 780px;
  margin-bottom: 0;
}

.misa-hero-badge {
  flex: 0 0 auto;
  padding: 10px 14px;
  border: 1px solid rgba(37, 99, 235, 0.18);
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.08);
  color: var(--bm-primary);
  font-size: 0.82rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.misa-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.misa-summary-card {
  position: relative;
  overflow: hidden;
  padding: 22px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--bm-shadow);
}

.misa-summary-card::after {
  content: "";
  position: absolute;
  right: -28px;
  bottom: -34px;
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: rgba(37, 99, 235, 0.08);
}

.misa-summary-card span {
  position: relative;
  z-index: 1;
  display: block;
  color: var(--bm-muted);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.misa-summary-card strong {
  position: relative;
  z-index: 1;
  display: block;
  margin-top: 10px;
  color: var(--bm-primary);
  font-size: 2.15rem;
  font-weight: 900;
  line-height: 1;
}

.misa-summary-card.connected::after {
  background: rgba(4, 120, 87, 0.1);
}

.misa-summary-card.connected strong {
  color: var(--bm-success);
}

.misa-summary-card.pending::after {
  background: rgba(100, 116, 139, 0.1);
}

.misa-summary-card.pending strong {
  color: #475569;
}

.misa-summary-card.expired::after {
  background: rgba(180, 83, 9, 0.12);
}

.misa-summary-card.expired strong {
  color: var(--bm-warning);
}

.misa-table-card {
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 26px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--bm-shadow);
}

.misa-table-card > .row {
  padding: 0 24px 24px;
}

.misa-table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 24px;
  margin-bottom: 16px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.14);
  background: linear-gradient(180deg, rgba(248, 250, 252, 0.92), rgba(255, 255, 255, 0.82));
}

.misa-table-header h2 {
  margin: 0 0 4px;
  font-size: 1.1rem;
  font-weight: 800;
}

.misa-table-header p {
  margin: 0;
  color: #64748b;
}

.misa-table {
  --bs-table-bg: transparent;
}

.misa-table thead th {
  border-bottom: 1px solid rgba(148, 163, 184, 0.16);
  background: #f8fafc;
}

.misa-table th {
  padding: 14px 24px;
  color: var(--bm-muted);
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.misa-table td {
  padding: 18px 24px;
  border-color: rgba(148, 163, 184, 0.13);
}

.misa-table tbody tr {
  transition: background-color 0.16s ease;
}

.misa-table tbody tr:hover {
  background: rgba(239, 246, 255, 0.72);
}

.misa-tax-code {
  display: inline-flex;
  padding: 7px 10px;
  border: 1px solid rgba(37, 99, 235, 0.12);
  border-radius: 12px;
  background: #eff6ff;
  color: #1e40af;
  font-weight: 900;
  letter-spacing: 0.03em;
}

.misa-company-name {
  font-weight: 800;
}

.misa-muted {
  margin-top: 3px;
  color: #64748b;
  font-size: 0.88rem;
}

.misa-error-note {
  max-width: 260px;
  margin-top: 6px;
  color: #dc3545;
  font-size: 0.78rem;
  line-height: 1.35;
}

.misa-empty-state {
  display: grid;
  gap: 6px;
  padding: 34px 24px;
  color: #64748b;
  text-align: center;
}

.misa-empty-state strong {
  color: #172033;
}

.misa-sync-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 8px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 14px 34px rgba(15, 23, 42, 0.05);
}

.misa-sync-nav .btn {
  border-radius: 13px;
  font-weight: 800;
}

.misa-sync-nav .btn-primary {
  border-color: transparent;
  background: linear-gradient(135deg, #2563eb, #0891b2);
  box-shadow: 0 12px 24px rgba(37, 99, 235, 0.18);
}

.misa-sync-nav .btn-outline-primary {
  border-color: transparent;
  background: transparent;
  color: #475569;
}

.misa-sync-nav .btn-outline-primary:hover,
.misa-sync-nav .btn-outline-primary:focus {
  background: #eff6ff;
  color: var(--bm-primary);
}

.misa-table-card .pagination {
  justify-content: flex-end;
  gap: 8px;
  padding: 0 24px 24px;
}

.misa-table-card .page-link {
  min-width: 38px;
  padding: 7px 13px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 12px !important;
  background: #fff;
  color: #475569;
  font-weight: 800;
  text-align: center;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.04);
  transition: border-color 0.18s ease, box-shadow 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

.misa-table-card .page-link:hover,
.misa-table-card .page-link:focus {
  border-color: rgba(37, 99, 235, 0.28);
  background: #eff6ff;
  color: var(--bm-primary);
  box-shadow: 0 12px 26px rgba(37, 99, 235, 0.12);
  transform: translateY(-1px);
}

.misa-table-card .page-item.active .page-link {
  border-color: transparent;
  background: linear-gradient(135deg, #2563eb, #0891b2);
  color: #fff;
  box-shadow: 0 14px 28px rgba(37, 99, 235, 0.2);
}

.misa-table-card .page-item.disabled .page-link {
  border-color: rgba(148, 163, 184, 0.14);
  background: #f8fafc;
  color: #94a3b8;
  box-shadow: none;
  transform: none;
}

.badge.text-bg-success {
  background: rgba(4, 120, 87, 0.12) !important;
  color: #047857 !important;
}

.badge.text-bg-secondary {
  background: rgba(100, 116, 139, 0.13) !important;
  color: #475569 !important;
}

.badge.text-bg-warning {
  background: rgba(180, 83, 9, 0.14) !important;
  color: #92400e !important;
}

.btn-primary {
  border-color: transparent;
  background: linear-gradient(135deg, #2563eb, #0891b2);
  font-weight: 800;
  box-shadow: 0 10px 22px rgba(37, 99, 235, 0.18);
}

.btn-outline-primary,
.btn-outline-success,
.btn-outline-secondary {
  font-weight: 800;
}

.btn-outline-primary:hover,
.btn-outline-success:hover {
  box-shadow: 0 10px 22px rgba(15, 23, 42, 0.08);
}

.misa-modal {
  border: 0;
  border-radius: 24px;
  box-shadow: 0 30px 90px rgba(15, 23, 42, 0.28);
}

.misa-modal .modal-header,
.misa-modal .modal-footer {
  border-color: rgba(148, 163, 184, 0.18);
}

.misa-modal-subtitle {
  color: #64748b;
  font-size: 0.92rem;
}

.misa-selected-tax {
  display: grid;
  gap: 4px;
  padding: 16px;
  border: 1px dashed rgba(13, 110, 253, 0.28);
  border-radius: 18px;
  background: rgba(13, 110, 253, 0.06);
}

.misa-selected-tax span {
  color: #64748b;
  font-size: 0.82rem;
  font-weight: 700;
}

.misa-selected-tax strong {
  color: #0d6efd;
  font-size: 1.15rem;
}

.misa-selected-tax small {
  color: #475569;
}

.logout-modal .modal-content {
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 24px;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.22);
}

.logout-modal .modal-body {
  padding: 32px;
}

.logout-modal-icon {
  display: flex;
  width: 64px;
  height: 64px;
  align-items: center;
  justify-content: center;
  border-radius: 20px;
  background: rgba(220, 53, 69, 0.1);
  color: #dc3545;
}

.logout-modal-icon svg {
  width: 32px;
  height: 32px;
  fill: currentColor;
}

@media (max-width: 991.98px) {
  .admin-body.sidebar-open {
    overflow: hidden;
  }

  .admin-sidebar {
    width: min(82vw, 320px);
    transform: translateX(-105%);
    box-shadow: 22px 0 50px rgba(15, 23, 42, 0.26);
    transition: transform 0.22s ease;
  }

  .admin-body.sidebar-open .admin-sidebar {
    transform: translateX(0);
  }

  .admin-body.sidebar-open .admin-sidebar-backdrop {
    display: block;
  }

  .admin-panel {
    margin-left: 0;
  }

  .admin-header {
    min-height: 64px;
    padding: 0 16px;
  }

  .admin-mobile-menu {
    display: inline-flex;
  }

  .admin-header-actions {
    gap: 8px;
  }

  .admin-icon-button,
  .admin-mobile-menu {
    width: 40px;
    height: 40px;
    border-radius: 13px;
  }

  .admin-main {
    padding: 20px 16px;
  }

  .admin-page-title {
    font-size: 1.45rem;
  }

  .admin-page-subtitle {
    margin-bottom: 18px;
  }

  .settings-grid,
  .misa-summary-grid {
    grid-template-columns: 1fr 1fr;
  }

  .misa-hero {
    flex-direction: column;
    padding: 22px;
  }

  .settings-form-card,
  .admin-dashboard-card,
  .settings-card {
    border-radius: 18px;
  }
}

@media (max-width: 575.98px) {
  .auth-shell {
    padding: 16px;
  }

  .auth-card {
    padding: 28px 20px;
    border-radius: 20px;
  }

  .admin-sidebar {
    width: min(88vw, 300px);
    padding: 20px 14px;
  }

  .admin-brand {
    min-height: 42px;
    font-size: 1.2rem;
  }

  .admin-menu {
    gap: 6px;
    margin-top: 24px;
  }

  .admin-menu-link {
    padding: 12px;
    border-radius: 12px;
  }

  .admin-header {
    gap: 10px;
  }

  .admin-header-actions {
    margin-left: auto;
  }

  .admin-main {
    padding: 18px 14px;
  }

  .admin-dashboard-card,
  .settings-card,
  .settings-form-card {
    padding: 20px !important;
  }

  .settings-card {
    gap: 12px;
  }

  .settings-card-icon {
    width: 42px;
    height: 42px;
    border-radius: 14px;
  }

  .misa-summary-grid {
    grid-template-columns: 1fr;
  }

  .misa-table-card > .row {
    padding: 0 16px 16px;
  }

  .misa-table-header,
  .misa-table th,
  .misa-table td {
    padding-left: 16px;
    padding-right: 16px;
  }

  .misa-table-card .pagination {
    justify-content: center;
    padding: 0 16px 16px;
  }

  .misa-table-card .page-link {
    min-width: 34px;
    padding: 8px 11px;
  }

  .settings-form-card .btn {
    width: 100%;
  }

  .admin-footer {
    padding: 16px 14px;
    font-size: 0.9rem;
  }
}