* {
  box-sizing: border-box;
}

body {
  font-family: 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  margin: 0;
  padding: 2rem 1.5rem;
  min-height: 100vh;
  background: linear-gradient(160deg, #f0f4f8 0%, #e2e8f0 100%);
  color: #1e293b;
  line-height: 1.6;
}

.container {
  max-width: 1100px;
  margin: 0 auto;
}

/* Header */
.page-header {
  margin-bottom: 2.5rem;
  padding: 1.5rem 1.25rem 1.5rem 0;
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
}

.header-title-row {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  flex-wrap: wrap;
}

.header-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  flex-shrink: 0;
  color: #326ce5;
}

.header-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.page-header h1 {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #0f172a;
  line-height: 1.2;
}

.page-header .subtitle {
  margin: 0.5rem 0 0 3.4rem;
  color: #64748b;
  font-size: 0.95rem;
  font-weight: 500;
}

@media (max-width: 520px) {
  .page-header .subtitle {
    margin-left: 0;
  }
}

/* Auth panel — centred on viewport */
.auth-panel {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  margin: 0;
  max-width: none;
  background: rgba(15, 23, 42, 0.22);
  backdrop-filter: blur(4px);
  border: none;
  box-shadow: none;
  border-radius: 0;
}

.auth-panel[hidden] {
  display: none !important;
}

.auth-panel form {
  width: 100%;
  max-width: 380px;
  background: #fff;
  border-radius: 12px;
  padding: 1.75rem;
  box-shadow:
    0 4px 6px -1px rgba(0, 0, 0, 0.06),
    0 2px 4px -2px rgba(0, 0, 0, 0.04),
    0 25px 50px -12px rgba(15, 23, 42, 0.18);
  border: 1px solid rgba(0, 0, 0, 0.04);
}

.auth-panel h2 {
  margin: 0 0 1.25rem 0;
  font-size: 1.15rem;
  font-weight: 600;
  color: #0f172a;
}

.auth-panel label {
  display: block;
  font-weight: 500;
  margin-bottom: 0.4rem;
  font-size: 0.9rem;
  color: #475569;
}

.auth-panel input {
  width: 100%;
  padding: 0.6rem 0.85rem;
  font-size: 0.95rem;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  margin-bottom: 0.85rem;
  background: #fafafa;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.auth-panel input:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
  background: #fff;
}

.auth-panel button {
  padding: 0.6rem 1.35rem;
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: 8px;
  border: none;
  background: #2563eb;
  color: #fff;
  cursor: pointer;
  transition: background 0.15s;
}

.auth-panel button:hover {
  background: #1d4ed8;
}

.auth-panel .auth-error {
  margin: 0.75rem 0 0 0;
  color: #dc2626;
  font-size: 0.9rem;
}

/* Data panel & cards */
.config-panel,
.data-panel {
  background: #fff;
  border-radius: 12px;
  padding: 1.5rem 1.75rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.06), 0 2px 4px -2px rgba(0, 0, 0, 0.04);
  border: 1px solid rgba(0, 0, 0, 0.04);
}

.config-panel h2,
.data-panel h2 {
  margin: 0 0 1rem 0;
  font-size: 1.1rem;
  font-weight: 600;
  color: #0f172a;
}

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

.panel-header h2 {
  margin: 0;
}

.panel-header .sign-out {
  margin-left: auto;
  font-size: 0.875rem;
  font-weight: 500;
  color: #2563eb;
  text-decoration: none;
  padding: 0.35rem 0.65rem;
  border-radius: 6px;
  transition: background 0.15s, color 0.15s;
}

.panel-header .sign-out:hover {
  background: #eff6ff;
  color: #1d4ed8;
}

.meta {
  font-size: 0.875rem;
  color: #64748b;
  font-weight: 500;
}

.search-row {
  margin-bottom: 1rem;
}

.search-row input {
  width: 100%;
  max-width: 320px;
  padding: 0.5rem 0.85rem 0.5rem 2.25rem;
  font-size: 0.9rem;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #f8fafc url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E") no-repeat 0.65rem center;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.search-row input::placeholder {
  color: #94a3b8;
}

.search-row input:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
  background-color: #fff;
}

.env-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.env-btn {
  padding: 0.45rem 0.9rem;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  color: #475569;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.env-btn:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
  color: #0f172a;
}

.env-btn.active {
  background: #2563eb;
  border-color: #2563eb;
  color: #fff;
}

.env-btn.active:hover {
  background: #1d4ed8;
  border-color: #1d4ed8;
  color: #fff;
}

/* Table */
.table-wrapper {
  overflow-x: auto;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  overflow: hidden;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

thead {
  background: #f8fafc;
  position: sticky;
  top: 0;
}

th {
  text-align: left;
  padding: 0.75rem 1rem;
  font-weight: 600;
  color: #475569;
  border-bottom: 2px solid #e2e8f0;
  white-space: nowrap;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

td {
  padding: 0.65rem 1rem;
  border-bottom: 1px solid #f1f5f9;
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
}

tbody tr {
  transition: background 0.1s;
}

tbody tr:hover {
  background: #f8fafc;
}

tbody tr.expiring-soon {
  background: #fffbeb;
}

tbody tr.expiring-soon:hover {
  background: #fef3c7;
}

tbody tr.expired {
  background: #fef2f2;
}

tbody tr.expired:hover {
  background: #fee2e2;
}

td.cell-warning {
  font-weight: 600;
  color: #c2410c;
}

td.cell-expired {
  font-weight: 600;
  color: #b91c1c;
}

td.cell-multiple-secrets {
  font-weight: 600;
  color: #b91c1c;
}

/* Form elements (legacy) */
.form-row {
  margin-bottom: 1rem;
}

.form-row label {
  display: block;
  font-weight: 500;
  margin-bottom: 0.35rem;
  font-size: 0.9rem;
}

.form-row input {
  width: 100%;
  max-width: 480px;
  padding: 0.5rem 0.75rem;
  font-size: 0.95rem;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
}

.form-row input:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.form-row small {
  display: block;
  margin-top: 0.35rem;
  color: #64748b;
  font-size: 0.8rem;
}

.form-actions {
  margin-top: 1.25rem;
}

.form-actions button {
  padding: 0.5rem 1.25rem;
  font-size: 0.95rem;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  margin-right: 0.5rem;
}

#tableTitle {
  font-weight: 700;
  color: #2563eb;
}

.error {
  color: #dc2626;
  margin: 1rem 0 0 0;
  font-size: 0.9rem;
}

/* Loading state */
.loading-state {
  background: #fff;
  border-radius: 12px;
  padding: 3rem 2rem;
  text-align: center;
  color: #64748b;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.06), 0 2px 4px -2px rgba(0, 0, 0, 0.04);
  border: 1px solid rgba(0, 0, 0, 0.04);
}

.loading-state p {
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  font-weight: 500;
}

.loading-state p::before {
  content: '';
  width: 20px;
  height: 20px;
  border: 2px solid #e2e8f0;
  border-top-color: #2563eb;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Error state */
.error-state {
  background: #fff;
  border-radius: 12px;
  padding: 1.75rem 2rem;
  color: #64748b;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.06), 0 2px 4px -2px rgba(0, 0, 0, 0.04);
  border: 1px solid rgba(0, 0, 0, 0.04);
}

.error-state p {
  margin: 0;
}

.error-state .hint {
  margin-top: 1rem;
  font-size: 0.85rem;
  color: #94a3b8;
}

.error-state .error {
  color: #dc2626;
  text-align: left;
  font-weight: 500;
}

.cors-origin-hint {
  margin-top: 0.75rem;
  font-size: 0.9rem;
  text-align: left;
  color: #475569;
}

.cors-origin-hint code.origin-value {
  display: inline-block;
  margin-top: 0.35rem;
  padding: 0.4rem 0.6rem;
  background: #f1f5f9;
  border-radius: 6px;
  font-size: 0.8rem;
  word-break: break-all;
  user-select: all;
  border: 1px solid #e2e8f0;
}
