@import url('https://fonts.googleapis.com/css2?family=Lexend:wght@300;400;500;600;700&display=swap');

:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --surface-3: #e2e8f0;
  --border: #e2e8f0;
  --border-light: #f1f5f9;
  --text: #0f172a;
  --text-light: #475569;
  --muted: #64748b;
  --primary: #3b82f6;
  --primary-dark: #2563eb;
  --primary-light: #dbeafe;
  --success: #10b981;
  --success-light: #d1fae5;
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --danger: #ef4444;
  --danger-light: #fee2e2;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  --radius: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: 'Lexend', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "Apple Color Emoji", "Segoe UI Emoji";
  color: var(--text);
  background: var(--bg);
}

.button {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  font-weight: 500;
  font-size: 0.875rem;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}
.button:hover {
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}
.button:active {
  transform: translateY(0);
  box-shadow: var(--shadow-sm) inset;
  filter: brightness(0.98);
}
.button.is-primary {
  border-color: var(--primary);
  background: var(--primary);
  color: white;
}
.button.is-primary:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
}
.button.is-primary:active {
  transform: translateY(0);
  box-shadow: var(--shadow-sm) inset;
}

.icon-button {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  width: 40px;
  height: 40px;
  display: inline-grid;
  place-items: center;
  border-radius: 10px;
  cursor: pointer;
}

.layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 100vh;
  background: var(--bg);
}

.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 1.5rem;
  gap: 1rem;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  z-index: 10;
}
.sidebar__brand {
  display: grid;
  grid-template-columns: 40px 1fr;
  gap: 0.75rem;
  align-items: center;
}
.sidebar__close { display: none; }
.brand__logo {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--primary), var(--success));
  border: 1px solid var(--border);
  font-size: 20px;
  box-shadow: var(--shadow-sm);
}
.brand__name { font-weight: 700; letter-spacing: .2px; }

.sidebar__nav { display: grid; gap: 6px; }
.nav__item {
  display: grid;
  grid-template-columns: 24px 1fr;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: var(--text);
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-weight: 500;
  transition: all 0.2s ease;
}
.nav__icon {
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 16px;
}
.nav__item:hover {
  background: var(--surface-2);
  border-color: var(--border);
  transform: translateX(2px);
}
.nav__item.is-active {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary-dark);
}
.nav__item.is-active .nav__icon {
  color: var(--primary);
}

.sidebar__footer { margin-top: auto; }
.user { display: grid; grid-template-columns: 36px 1fr; gap: 10px; align-items: center; }
.user__avatar {
  width: 36px; height: 36px;
  border-radius: 9px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, rgba(255,255,255,.08), rgba(255,255,255,.02));
  border: 1px solid var(--border);
  color: var(--muted);
  font-weight: 700;
}
.user__name { font-size: .95rem; }
.user__role { color: var(--muted); font-size: .8rem; }

.content {
  display: grid;
  grid-template-rows: 64px 1fr;
  background: var(--bg);
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 1.5rem;
  padding: 1rem 2rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  z-index: 5;
}
.topbar #openSidebar { display: none; }
.topbar__search {
  max-width: 400px;
}
.topbar__search input {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  transition: all 0.2s ease;
}
.topbar__search input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
  background: var(--surface);
}
.topbar__actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}
.avatar { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 9px; background: var(--surface); border: 1px solid var(--border); color: var(--muted); font-weight: 700; }

.main {
  padding: 2rem;
  display: grid;
  gap: 2rem;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}

.cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  transition: all 0.2s ease;
}
.card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}
.card__label { color: var(--muted); font-size: .9rem; }
.card__value { font-size: 1.7rem; font-weight: 800; margin-top: .35rem; }
.card__delta { margin-top: .7rem; font-size: .9rem; color: var(--muted); }
.card__delta.is-up { color: var(--success); }
.card__delta.is-down { color: var(--danger); }

.panels { display: grid; grid-template-columns: 2fr 1fr; gap: 1rem; }

/* Dashboard metrics sizing overrides */
#metricTotalCalls { font-size: 2.6rem; font-weight: 800; line-height: 1.1; }

#metricSuccessCalls,
#metricFailedCalls,
#metricBlockedCalls,
#metricAvgLatency,
#metricApiSecrets,
#metricModels,
#metricKeysGenerated { font-size: 1.6rem; font-weight: 700; line-height: 1.15; }

#metricSuccessCallsPct,
#metricFailedCallsPct,
#metricBlockedCallsPct { font-size: 1rem; font-weight: 700; }

.panels { display: grid; grid-template-columns: 2fr 1fr; gap: 1rem; }
.panel {
  background: linear-gradient(180deg, rgba(255,255,255,.04), rgba(255,255,255,.015)), var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  display: grid;
  grid-template-rows: auto 1fr;
}
.panel__header {
  display: flex; align-items: center; justify-content: space-between;
  padding: .9rem 1rem; border-bottom: 1px solid var(--border);
}
.panel__title { margin: 0; font-size: 1rem; }
.panel__body { padding: 1rem; overflow: auto; }
.panel__body.is-placeholder {
  height: 260px; display: grid; place-items: center; color: var(--muted);
  background: repeating-linear-gradient(
    -45deg,
    rgba(255,255,255,.02),
    rgba(255,255,255,.02) 10px,
    rgba(255,255,255,.01) 10px,
    rgba(255,255,255,.01) 20px
  );
  border-bottom-left-radius: 16px;
  border-bottom-right-radius: 16px;
}

.chip {
  display: inline-flex;
  align-items: center;
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 0 .35rem;
  border-radius: 999px;
  cursor: pointer;
  font-size: .72rem;
  line-height: 1;
  height: auto;
  transition: all 0.2s ease;
  user-select: none;
}
.chip:hover {
  background: rgba(79,70,229,.06);
  border-color: rgba(79,70,229,.25);
}
.chip.is-active {
  background: rgba(79,70,229,.12);
  border-color: rgba(79,70,229,.45);
  color: rgba(79,70,229,1);
  font-weight: 600;
}
.chip.is-active:hover {
  background: rgba(79,70,229,.18);
  border-color: rgba(79,70,229,.6);
}
.chip .chip-close {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 0 .25rem;
  margin-left: .15rem;
  line-height: 1;
  font-size: .9em;
  cursor: pointer;
}

/* Small badge-style button (e.g., floating copy) */
.btn-badge {
  font-size: .75rem;
  padding: .2rem .4rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
}
.btn-badge:hover { box-shadow: var(--shadow); }
.btn-badge:active { transform: scale(0.96); box-shadow: var(--shadow-sm) inset; }

.table-section { background: transparent; }
.table-header { display: flex; align-items: center; justify-content: space-between; padding: 0 .2rem; }
.table-wrapper {
  background: linear-gradient(180deg, rgba(255,255,255,.04), rgba(255,255,255,.015)), var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: .9rem 1rem; border-bottom: 1px solid var(--border); }
.table thead th { font-size: .85rem; color: var(--muted); background: var(--surface-2); }
.table tbody tr:hover { background: var(--surface-2); }

.badge { padding: .2rem .45rem; border-radius: 8px; border: 1px solid var(--border); font-size: .8rem; }
.badge.is-success { background: rgba(16,185,129,.15); border-color: rgba(16,185,129,.4); color: #34d399; }
.badge.is-warning { background: rgba(245,158,11,.15); border-color: rgba(245,158,11,.4); color: #fbbf24; }
.badge.is-danger  { background: rgba(239,68,68,.15); border-color: rgba(239,68,68,.4); color: #f87171; }

.filters { display: grid; gap: .6rem; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: .9rem 1rem; }
.filters__title { font-weight: 700; }
.filters__controls { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; }
.filters__controls select { appearance: none; background: var(--surface-2); border: 1px solid var(--border); color: var(--text); padding: .5rem .6rem; border-radius: 10px; }
.filters__actions { margin-left: auto; display: flex; gap: .5rem; }

.panel-single { grid-template-columns: 1fr; }

.footer { margin: 1rem; padding: 1rem; color: var(--muted); border-top: 1px solid var(--border); display: flex; justify-content: space-between; }

.quota-list { display: grid; gap: .8rem; }
.quota-item { display: grid; gap: .4rem; }
.quota-head { display: flex; justify-content: space-between; align-items: center; font-size: .9rem; color: var(--muted); }
.progress { width: 100%; height: 10px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: linear-gradient(90deg, #22c55e, #16a34a); }
.progress.is-warning > span { background: linear-gradient(90deg, #f59e0b, #d97706); }
.progress.is-danger > span { background: linear-gradient(90deg, #ef4444, #dc2626); }

.alerts { list-style: none; padding: 0; margin: 0; display: grid; gap: .6rem; }
.alert { display: grid; gap: .2rem; padding: .6rem .8rem; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.alert strong { color: var(--text); }
.alert .meta { color: var(--muted); font-size: .85rem; }
#alertsList { max-height: 160px; overflow-y: auto; }

/* Auth */
.auth {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem 1rem;
  background: var(--bg);
}
.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 1.2rem;
  display: grid;
  gap: 1rem;
}
.auth-brand { display: flex; gap: .8rem; align-items: center; }
.auth-logo { width: 36px; height: 36px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2); }
.auth-company { font-weight: 700; }
.auth-title { color: var(--muted); font-size: .95rem; }
.auth-form { display: grid; gap: .8rem; }
.form-control { display: grid; gap: .35rem; }
.form-label { color: var(--muted); font-size: .85rem; }
.input { width: 100%; padding: .6rem .75rem; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); color: var(--text); }
.form-row { display: flex; align-items: center; justify-content: space-between; }
.checkbox { display: inline-flex; align-items: center; gap: .4rem; color: var(--muted); }
.link { color: var(--primary); text-decoration: none; }
.link:hover { text-decoration: underline; }
.auth-submit { width: 100%; margin-top: .2rem; }
.auth-footer { display: flex; justify-content: center; gap: .35rem; color: var(--muted); }
.auth-legal { text-align: center; color: var(--muted); font-size: .85rem; }

/* Responsive */
@media (max-width: 1200px) {
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .panels { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: 280px; height: 100vh; z-index: 20;
    transform: translateX(-100%);
    transition: transform .25s ease;
  }
  body.sidebar-open .sidebar { transform: translateX(0); }
  .sidebar__close { display: inline-grid; }
  .topbar #openSidebar { display: inline-grid; }
  .content { grid-template-rows: 56px 1fr; }
  .filters__actions { margin-left: 0; width: 100%; }
}

@media (max-width: 640px) {
  .cards { grid-template-columns: 1fr; }
  .providers-grid { grid-template-columns: 1fr; }
  .main { padding: 1rem; }
  .topbar { padding: 1rem; }
  .page-title { font-size: 1.5rem; }
}

/* Dashboard Styles */
.dashboard {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.dashboard-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow);
}

.dashboard-brand {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.dashboard-logo {
  width: 40px;
  height: 40px;
}

.dashboard-brand-text {
  display: flex;
  flex-direction: column;
}

.dashboard-company {
  font-weight: 700;
  font-size: 1.125rem;
  color: var(--text);
}

.dashboard-title {
  font-size: 0.875rem;
  color: var(--muted);
}

.dashboard-user {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.user-welcome {
  font-size: 0.875rem;
  color: var(--muted);
}

.dashboard-main {
  flex: 1;
  padding: 2rem;
  background: var(--surface-2);
}

.dashboard-content {
  max-width: 1200px;
  margin: 0 auto;
}

.dashboard-section h2 {
  margin: 0 0 1rem 0;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
}

.dashboard-section p {
  margin: 0 0 2rem 0;
  color: var(--muted);
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  margin-bottom: 1.5rem;
}

.card-header {
  padding: 1.5rem 1.5rem 0 1.5rem;
}

.card-header h3 {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text);
}

.card-content {
  padding: 1.5rem;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1.5rem;
}

.stat-item {
  text-align: center;
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 0.25rem;
}

.stat-label {
  font-size: 0.875rem;
  color: var(--muted);
}

.text-muted {
  color: var(--muted);
  font-style: italic;
}

.dashboard-footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 1rem 2rem;
  text-align: center;
}

.dashboard-legal {
  font-size: 0.875rem;
  color: var(--muted);
}

.button.is-secondary {
  border-color: var(--border);
  background: var(--surface);
  color: var(--text);
}

.button.is-secondary:hover {
  background: var(--surface-2);
}

/* Database Management Styles */
.data-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1rem;
}

.data-table th,
.data-table td {
  padding: 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.data-table th {
  background: var(--surface-2);
  font-weight: 600;
  color: var(--text);
}

.data-table tr:hover {
  background: var(--surface-2);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.form-control {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.form-label {
  font-weight: 600;
  color: var(--text);
  font-size: 0.875rem;
}

.input {
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.875rem;
}

.input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem 1.5rem 0 1.5rem;
}

.dashboard-user {
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* Professional Page Layout */
.main {
  padding: 2rem;
  max-width: 1400px;
  margin: 0 auto;
}

.page-header {
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.page-header__content {
  max-width: none;
}

.page-title {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 0.5rem 0;
  line-height: 1.2;
}

.page-description {
  font-size: 1rem;
  color: var(--muted);
  margin: 0;
  line-height: 1.5;
}

.page-content {
  margin-top: 2rem;
}

/* Provider Cards */
.providers-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
  gap: 1.5rem;
}

.provider-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  transition: all 0.2s ease;
}

.provider-card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
  border-color: var(--primary);
}

.provider-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.provider-icon {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-2);
  border-radius: var(--radius);
  font-size: 24px;
}

.provider-info {
  flex: 1;
}

.provider-name {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 0.25rem 0;
}

.provider-url {
  font-size: 0.875rem;
  color: var(--muted);
  margin: 0;
  font-family: monospace;
}

.provider-status {
  font-size: 1.25rem;
}

.provider-status.active {
  color: var(--success);
}

.provider-status.inactive {
  color: var(--muted);
}

.provider-details {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.detail-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.detail-label {
  font-size: 0.875rem;
  color: var(--muted);
  font-weight: 500;
}

.detail-value {
  font-size: 0.875rem;
  color: var(--text);
  font-weight: 500;
  background: var(--surface-2);
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius);
}

.detail-link {
  font-size: 0.875rem;
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
}

.detail-link:hover {
  text-decoration: underline;
}

/* Loading and Empty States */
.loading-card {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  color: var(--muted);
}

.loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--surface-2);
  border-top: 3px solid var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 1rem;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.empty-state,
.error-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 3rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  color: var(--muted);
}

/* Additional Professional Touches */
.icon-button {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  width: 40px;
  height: 40px;
  display: inline-grid;
  place-items: center;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 16px;
}

.icon-button:hover {
  background: var(--surface-2);
  color: var(--text);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

/* Improved form styling */
.form-control {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.form-label {
  font-weight: 600;
  color: var(--text);
  font-size: 0.875rem;
}

.input, select.input {
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 0.875rem;
  transition: all 0.2s ease;
}

.input:focus, select.input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
  background: var(--surface);
}

/* Status badges */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.75rem;
  border-radius: var(--radius);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.025em;
}

.status-badge.active {
  background: var(--success-light);
  color: var(--success);
}

.status-badge.inactive {
  background: var(--surface-2);
  color: var(--muted);
}

/* Smooth transitions for all interactive elements */
* {
  transition: color 0.2s ease, background-color 0.2s ease, border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

/* Focus styles for accessibility */
*:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* Inline action icons */
.action-icons { display: inline-flex; align-items: center; gap: 6px; }
.icon-btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  width: 34px; height: 34px;
  display: inline-grid; place-items: center;
  border-radius: 8px;
  cursor: pointer;
}
.icon-btn:hover { filter: brightness(1.05); }
.icon-btn svg { width: 18px; height: 18px; stroke: currentColor; }
.icon-btn.is-primary { border-color: rgba(37,99,235,.5); background: rgba(37,99,235,.08); color: #2563eb; }
.icon-btn.is-danger  { border-color: rgba(220,38,38,.5); background: rgba(220,38,38,.08); color: #dc2626; }
.icon-btn.is-muted   { color: var(--muted); }
.icon-btn.icon-decrypt { border-color: rgba(2,132,199,.5); background: rgba(2,132,199,.08); color: #0284c7; }

/* Data table polishing */
.table th:last-child, .table td:last-child { text-align: right; }
.table td .input { width: 100%; }

/* Nav icon SVG sizing */
.nav__icon svg { width: 18px; height: 18px; stroke-width: 2; }

/* Status badges */
.status-badge { display: inline-block; padding: .2rem .5rem; border-radius: 999px; font-size: .78rem; border: 1px solid var(--border); }
.status-badge.success { background: rgba(16,185,129,.12); color: #16a34a; border-color: rgba(16,185,129,.4); }
.status-badge.warning { background: rgba(245,158,11,.12); color: #b45309; border-color: rgba(245,158,11,.4); }
.status-badge.danger  { background: rgba(220,38,38,.12); color: #dc2626; border-color: rgba(220,38,38,.4); }

/* Code text & links */
.code-text { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; font-size: .9rem; color: var(--text); }
.code-link { color: var(--primary-dark); text-decoration: none; border-bottom: 1px dashed var(--primary); }
.code-link:hover { color: var(--primary); border-bottom-style: solid; }

/* JSON syntax highlighting */
.json-block {
  margin: 0;
  padding: .5rem .6rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: .85rem;
  line-height: 1.35;
  white-space: pre-wrap;
  word-break: break-word;
}
.json-key { color: #1f759d; }
.json-string { color: #036d19; }
.json-number { color: #7c3aed; }
.json-boolean { color: #b45309; }
.json-null { color: #64748b; font-style: italic; }
.json-punc { color: #334155; }

/* Table hover refinement */
.table tbody tr { transition: background .15s ease; }
.table tbody tr:hover { background: var(--surface-2); }

/* Settings panel */
.settings-item { display: grid; gap: .8rem; }
.settings-head { display: flex; gap: .8rem; align-items: flex-start; }
.settings-icon { font-size: 20px; line-height: 1; padding: .45rem; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); }
.settings-title { font-weight: 700; }
.settings-desc { color: var(--muted); font-size: .9rem; margin-top: .15rem; max-width: 60ch; }
.settings-form { display: grid; gap: .9rem; align-items: start; }
.settings-form .form-row { display: grid; gap: .25rem; align-items: start; justify-content: initial; }
.settings-form .form-row label { display: block; }
.settings-current { color: var(--muted); font-size: .85rem; }

/* Settings form sizing overrides */
.settings-form .input,
.settings-form input[type="text"],
.settings-form input[type="password"],
.settings-form input[type="number"],
.settings-form input[type="email"],
.settings-form select,
.settings-form textarea {
  width: auto;
  max-width: 420px;
}

.settings-form .button { width: auto; justify-self: start; }

#masterKeyInput { width: auto; max-width: 480px; }

/* Caution warning banner */
.warning-banner { display: flex; gap: .6rem; align-items: flex-start; padding: .8rem; border: 1px solid rgba(245,158,11,.4); background: rgba(245,158,11,.12); border-radius: 12px; color: #b45309; }
.warning-icon { font-size: 18px; line-height: 1; }

/* Table cell overflow so focused fields can expand */
.table td { overflow: visible; }

/* Magnify inputs/textareas on focus for better UX */
.expand-on-focus:focus {
  position: relative;
  z-index: 20;
  transform: scale(1.05);
  box-shadow: 0 0 0 2px rgba(37,99,235,.2), 0 12px 32px rgba(16,24,40,.22);
}

/* Smooth transform */
.input, textarea.input { transition: transform .12s ease, box-shadow .12s ease; }

/* Popover editor for focused fields */
.cell-editor { position: relative; }
.cell-editor .input, .cell-editor textarea.input { width: 100%; }
.cell-editor textarea.input { min-height: 40px; resize: vertical; }
.cell-editor .input:focus, .cell-editor textarea.input:focus {
  position: absolute;
  top: -8px;
  left: -8px;
  width: 520px;
  max-width: 72vw;
  background: var(--surface);
  border: 1px solid rgba(37,99,235,.5);
  box-shadow: 0 0 0 2px rgba(37,99,235,.2), 0 18px 42px rgba(16,24,40,.28);
  z-index: 30;
  transform: none;
}
.cell-editor textarea.input:focus { min-height: 180px; }

/* Advanced editor row */
.advanced-editor-row td { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; }
.advanced-editor { display: grid; gap: .8rem; padding: .8rem; }
.advanced-grid { display: grid; gap: .6rem; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.advanced-grid .form-control { display: grid; gap: .3rem; }
.advanced-grid .form-label { color: var(--muted); font-size: .85rem; }
.advanced-grid textarea.input { min-height: 90px; }
@media (max-width: 900px) { .advanced-grid { grid-template-columns: 1fr; } }

/* Modal */
.modal { position: fixed; inset: 0; display: none; place-items: center; z-index: 80; }
.modal.is-open { display: grid; }
.modal__backdrop { position: absolute; inset: 0; background: rgba(2,6,23,.55); backdrop-filter: blur(2px); }
.modal__dialog { position: relative; width: min(1100px, 96vw); max-height: 90vh; overflow: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow); }
.modal__header { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1rem .5rem; border-bottom: 1px solid var(--border); }
.modal__title { margin: 0; font-size: 1.05rem; }
.modal__body { padding: 1rem; display: grid; gap: .9rem; }
.modal__footer { display: flex; gap: .6rem; justify-content: flex-end; padding: .75rem 1rem; border-top: 1px solid var(--border); }

/* Form grid */
.form-grid { display: grid; gap: .8rem; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid .form-control { display: grid; gap: .35rem; }
.form-grid .form-label { color: var(--muted); font-size: .85rem; }
@media (max-width: 900px) { .form-grid { grid-template-columns: 1fr; } }