:root {
  /* Primary Blue Palette */
  --primary-50: #77adf3 !important;
  --primary-100: #dbeafe;
  --primary-200: #bfdbfe;
  --primary-300: #93c5fd;
  --primary-400: #60a5fa;
  --primary-500: #3b82f6;
  --primary-600: #2563eb;
  --primary-700: #1d4ed8;
  --primary-800: #1e40af;
  --primary-900: #1e3a8a;

  /* Cobalt aliases for backward compatibility */
  --cobalt-50: var(--primary-50);
  --cobalt-100: var(--primary-100);
  --cobalt-200: var(--primary-200);
  --cobalt-300: var(--primary-300);
  --cobalt-400: var(--primary-400);
  --cobalt-500: var(--primary-500);
  --cobalt-600: var(--primary-600);
  --cobalt-700: var(--primary-700);
  --cobalt-800: var(--primary-800);
  --cobalt-900: var(--primary-900);

  /* Backward compatibility for old --blue variable */
  --blue: var(--primary-500);

  /* Neutral Palette */
  --slate-50: #f8fafc;
  --slate-100: #f1f5f9;
  --slate-200: #e2e8f0;
  --slate-300: #cbd5e1;
  --slate-400: #94a3b8;
  --slate-500: #64748b;
  --slate-600: #475569;
  --slate-700: #334155;
  --slate-800: #1e293b;
  --slate-900: #0f172a;

  /* Semantic Status Colors (Blue-based harmonious palette) */
  --success-bg: #dcfce7;
  --success-text: #166534;
  --success-light: #86efac;

  --warning-bg: #fef3c7;
  --warning-text: #92400e;
  --warning-light: #fcd34d;

  --danger-bg: #fee2e2;
  --danger-text: #991b1b;
  --danger-light: #fca5a5;

  --info-bg: #dbeafe;
  --info-text: #1e40af;
  --info-light: #93c5fd;

  /* Base colors */
  --white: #ffffff;
  --bg: var(--slate-50);
  --line: var(--slate-200);
  --shadow: 0 12px 25px rgba(15, 23, 42, 0.08);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(140deg, var(--primary-50) 0%, var(--slate-50) 45%);
  color: var(--slate-900);
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
a:hover {
  color: var(--primary-600);
}

/* Blue accent utilities */
.text-primary { color: var(--primary-600); }
.text-muted { color: var(--slate-500); }
.bg-primary-light { background: var(--primary-100); }
.border-primary { border-color: var(--primary-200); }

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 240px 1fr;
}

.sidebar {
  background: var(--primary-50);
  border-right: 1px solid var(--line);
  padding: 24px 14px;
}

.brand {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 22px;
  color: var(--primary-700);
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--primary-100);
}

/* .brand::before {
  content: '';
  display: block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--primary-500);
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.15);
} */

.nav-list { display: grid; gap: 8px; }
.nav-link {
  padding: 10px 12px;
  border-radius: var(--radius-md);
  color: var(--slate-700);
  transition: all 0.2s ease;
  /* position: relative; */
}

.nav-link.active,
.nav-link:hover {
  background: var(--primary-100);
  color: var(--primary-600);
}

.nav-link.active::before {
  content: '';
  position: absolute;
  left: -8px;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 70%;
  background: var(--primary-500);
  border-radius: 0 2px 2px 0;
}

.nav-group {
  display: grid;
  gap: 6px;
}

.nav-parent {
  font-weight: 700;
  cursor: default;
}

.nav-group.active .nav-parent {
  background: var(--primary-100);
  color: var(--primary-600);
}

.nav-submenu {
  display: grid;
  gap: 4px;
  padding-left: 12px;
}

.nav-sublink {
  display: block;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  color: var(--slate-600);
  font-size: 0.88rem;
  transition: all 0.2s ease;
}

.nav-sublink.active,
.nav-sublink:hover {
  background: var(--white);
  color: var(--primary-700);
}

.content { padding: 24px; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 2px solid var(--primary-100);
  /* position: relative; */
}

/* .topbar::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 100px;
  height: 2px;
  background: var(--primary-500);
  border-radius: 2px;
} */

.topbar h1 {
  margin: 0;
  font-size: 1.35rem;
  color: var(--slate-800);
  font-weight: 700;
}

.topbar p {
  margin: 4px 0 0;
  color: var(--slate-500);
  font-size: 0.9rem;
}

.topbar-actions { display: flex; align-items: center; gap: 10px; }

.site-switcher-form select {
    padding: 6px 10px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: var(--white);
    font-size: 0.85rem;
    min-width: 140px;
    cursor: pointer;
    transition: border-color 0.2s ease;
}
.site-switcher-form select:focus {
    outline: none;
    border-color: var(--primary-500);
    box-shadow: 0 0 0 3px var(--primary-100);
}
.current-site-label {
    font-weight: 500;
    color: var(--slate-700);
    margin-right: 8px;
}

.bell {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--white);
  border: 1px solid var(--line);
  padding: 8px 12px;
  border-radius: 999px;
  box-shadow: var(--shadow);
  transition: all 0.2s ease;
}
.bell:hover {
  border-color: var(--primary-300);
  box-shadow: 0 8px 20px rgba(59, 130, 246, 0.12);
}
.bell svg {
  width: 18px;
  height: 18px;
  stroke: var(--slate-600);
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.bell span {
  font-weight: 700;
  color: var(--primary-600);
  background: var(--primary-100);
  padding: 2px 6px;
  border-radius: 999px;
  font-size: 0.75rem;
  min-width: 18px;
  text-align: center;
  display: inline-block;
}

.user-menu {
  position: relative;
}

.user-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--white);
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: all 0.2s ease;
}

.user-icon-btn:hover {
  border-color: var(--primary-300);
  box-shadow: 0 8px 20px rgba(59, 130, 246, 0.12);
}

.user-icon-btn svg {
  width: 20px;
  height: 20px;
  stroke: var(--slate-600);
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.user-menu-list {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 140px;
  border: 1px solid var(--line);
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 6px;
  display: none;
  z-index: 9999;
}

.user-menu-list.open {
  display: block;
}

.user-menu-list a {
  display: block;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  color: var(--slate-700);
  transition: all 0.2s ease;
  text-decoration: none;
}

.user-menu-list a:hover {
  background: var(--primary-100);
  color: var(--primary-700);
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}
.kpi-card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  padding: 16px;
  box-shadow: var(--shadow);
  transition: all 0.2s ease;
}

.kpi-card:hover {
  border-color: var(--primary-200);
  box-shadow: 0 8px 20px rgba(59, 130, 246, 0.1);
  transform: translateY(-2px);
  transition: all 0.2s ease;
}

.kpi-card p {
  margin: 0;
  font-size: .9rem;
  color: var(--slate-500);
}

.kpi-card h3 { margin: 8px 0 0; font-size: 1.3rem; color: var(--slate-800); }

.panel {
  background: var(--white);
  border: 1px solid var(--line);
  border-top: 3px solid var(--primary-500);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
  transition: border-color 0.2s ease;
}

.panel:hover {
  border-top-color: var(--primary-600);
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.panel-head h2 {
  margin: 0;
  font-size: 1.05rem;
  color: var(--slate-800);
}

.grid-form {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  max-width: 560px;
}

.inline-form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.inline-form input,
.inline-form select {
  width: auto;
  min-width: 90px;
  padding: 6px 10px;
}

.chip {
  display: inline-flex;
  padding: 6px 12px;
  font-size: 0.75rem;
  font-weight: 700;
  border-radius: 999px;
}

.chip.good {
  color: var(--success-text);
  background: var(--success-bg);
}

.chip.watch {
  color: var(--warning-text);
  background: var(--warning-bg);
}

.chip.risk {
  color: var(--danger-text);
  background: var(--danger-bg);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.85rem;
  border-radius: var(--radius-sm);
}

label { font-size: .86rem; color: var(--slate-700); font-weight: 500; }

input, select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  font: inherit;
  background: var(--white);
  transition: all 0.2s ease;
  color: var(--slate-900);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary-400);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

textarea { resize: vertical; }

.btn {
  border: none;
  border-radius: var(--radius-md);
  padding: 10px 18px;
  background: var(--primary-600);
  color: #fff;
  cursor: pointer;
  width: fit-content;
  font-weight: 600;
  transition: all 0.2s ease;
  box-shadow: 0 2px 4px rgba(59, 130, 246, 0.2);
}

.btn:hover {
  background: var(--primary-700);
  box-shadow: 0 4px 8px rgba(59, 130, 246, 0.3);
  transform: translateY(-1px);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
  background: var(--slate-400);
}

.btn:active {
  background: var(--primary-800);
  transform: translateY(0);
}

.btn-outline {
  border: 1px solid var(--line);
  background: var(--white);
  color: var(--slate-700);
  box-shadow: none;
}

.btn-outline:hover {
  border-color: var(--primary-300);
  background: var(--primary-50);
  color: var(--primary-700);
  box-shadow: none;
}

.btn-danger {
  background: var(--danger-text);
  box-shadow: 0 2px 4px rgba(153, 27, 27, 0.2);
}

.btn-danger:hover {
  background: var(--danger-text);
  box-shadow: 0 4px 8px rgba(153, 27, 27, 0.3);
}

.table-wrap { overflow: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  min-width: 820px;
}
th, td {
  text-align: left;
  vertical-align: middle;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  font-size: .9rem;
}
thead th {
  font-size: .78rem;
  color: var(--slate-500);
  text-transform: uppercase;
  font-weight: 700;
  background: var(--primary-50);
  letter-spacing: 0.5px;
}

.row-unread {
  background: var(--primary-100);
  transition: background-color 0.2s ease;
}

.row-unread:hover {
  background: var(--primary-200);
}

.row-unread td:first-child {
  box-shadow: inset 3px 0 0 var(--primary-400);
}

.status-approved {
  color: var(--success-text);
  font-weight: 700;
  padding: 4px 10px;
  background: var(--success-bg);
  border-radius: 999px;
  display: inline-block;
}

.status-rejected {
  color: var(--danger-text);
  font-weight: 700;
  padding: 4px 10px;
  background: var(--danger-bg);
  border-radius: 999px;
  display: inline-block;
}

.status-pending {
  color: var(--info-text);
  font-weight: 600;
  padding: 4px 10px;
  background: var(--info-bg);
  border-radius: 999px;
  display: inline-block;
}

.alert {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  margin-bottom: 16px;
  border-left: 4px solid;
  font-weight: 500;
}

.alert-success {
  background: var(--success-bg);
  color: var(--success-text);
  border-left-color: var(--success-light);
}

.alert-error {
  background: var(--danger-bg);
  color: var(--danger-text);
  border-left-color: var(--danger-light);
}

.alert-warning {
  background: var(--warning-bg);
  color: var(--warning-text);
  border-left-color: var(--warning-light);
}

.alert-info {
  background: var(--info-bg);
  color: var(--info-text);
  border-left-color: var(--info-light);
}

.muted { color: var(--slate-500); }

.tabs {
  display: flex;
  gap: 8px;
  margin: 14px 0;
}

.tab-btn {
  border: 1px solid var(--line);
  background: var(--white);
  color: var(--slate-600);
  border-radius: 999px;
  padding: 8px 16px;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.2s ease;
}

.tab-btn:hover {
  border-color: var(--primary-300);
  color: var(--primary-600);
  background: var(--primary-50);
}

.tab-btn.active {
  background: var(--primary-600);
  color: var(--white);
  border-color: var(--primary-600);
  box-shadow: 0 2px 6px rgba(59, 130, 246, 0.3);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

/* Blue accent utilities */
.brand-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
  text-align: center;
}

.brand-header h1 {
  margin: 0;
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--primary-700);
  letter-spacing: -0.5px;
}

.site-initials {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 80px;
  height: 80px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--primary-500), var(--primary-700));
  color: white;
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: 2px;
  box-shadow: 0 4px 12px rgba(47, 130, 246, 0.25);
}

/* Interactive table rows */
tbody tr {
  transition: background-color 0.15s ease;
}

tbody tr:hover {
  background-color: var(--primary-50);
  /* position: relative; */
}

/* tbody tr:hover::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--primary-300);
} */

/* Accessibility */
:focus-visible {
  outline: 2px solid var(--primary-500);
  outline-offset: 2px;
}

/* Blue gradient utility */
.gradient-blue {
  background: linear-gradient(135deg, var(--primary-400), var(--primary-600));
  color: white;
}

/* Custom scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--slate-100);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb {
  background: var(--primary-300);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--primary-400);
}

/* Divider */
hr {
  border: 0;
  height: 1px;
  background: var(--line);
  margin: 20px 0;
}

.pagination-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 10px;
}

.pagination-controls button {
  border: 1px solid var(--line);
  background: var(--white);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  color: var(--slate-700);
}

.pagination-controls button:hover:not(:disabled) {
  border-color: var(--primary-300);
  color: var(--primary-600);
  background: var(--primary-50);
}

.pagination-controls button:disabled {
  opacity: .5;
  cursor: not-allowed;
  background: var(--slate-100);
}

.guest-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--primary-50) 0%, var(--slate-50) 100%);
}

.auth-card {
  width: min(420px, 92vw);
  background: var(--white);
  border-radius: var(--radius-xl);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  padding: 22px;
  overflow: hidden;
}

.auth-card:has(.workspace-picker) {
  width: min(540px, 92vw);
}

.workspace-picker {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.workspace-option {
  display: block;
  cursor: pointer;
}

.workspace-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.workspace-card {
  display: block;
  padding: 16px 18px;
  border: 2px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--white);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.workspace-option input:focus + .workspace-card {
  outline: 2px solid var(--primary-300);
  outline-offset: 2px;
}

.workspace-option input:checked + .workspace-card {
  border-color: var(--primary-500);
  box-shadow: 0 0 0 3px var(--primary-100);
}

.workspace-title {
  display: block;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--slate-900);
  margin-bottom: 4px;
}

.workspace-desc {
  display: block;
  font-size: 0.9rem;
  color: var(--slate-600);
}

.workspace-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--primary-100);
  color: var(--primary-800);
  vertical-align: middle;
}

.workspace-switch-btn {
  margin-right: 8px;
  white-space: nowrap;
}

.auth-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--primary-400), var(--primary-600), var(--primary-400));
}

.link-btn {
  border: 0;
  background: transparent;
  color: var(--primary-600);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: color 0.2s ease;
}

.link-btn:hover {
  color: var(--primary-800);
}

.site-logo {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border: 2px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--white);
  transition: all 0.2s ease;
}

.site-logo:hover {
  border-color: var(--primary-300);
  box-shadow: 0 0 0 3px var(--primary-100);
}

.email-cell .text-truncate {
  display: block;
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Interactive table rows */
.clickable-row {
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.clickable-row:hover {
  background-color: var(--primary-50);
}

.clickable-row a {
  color: var(--primary-700);
  text-decoration: underline;
  font-weight: 500;
}

.clickable-row a:hover {
  color: var(--primary-900);
}

/* Goto button (notifications) */
.btn-goto {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 8px;
  font-size: 1rem;
  color: var(--primary-700);
  text-decoration: none;
  border-radius: var(--radius-sm);
  transition: all 0.2s ease;
  border: 1px solid transparent;
}

.btn-goto:hover {
  background-color: var(--primary-100);
  color: var(--primary-900);
  border-color: var(--primary-200);
}

/* Media queries */
@media (max-width: 1100px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 820px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--line); }
  .topbar { flex-direction: column; align-items: flex-start; gap: 8px; }
  .kpi-grid { grid-template-columns: 1fr; }
}
