:root {
  --bg: #0b0f14;
  --panel: #121821;
  --panel-border: #1f2a37;
  --text: #e5eef7;
  --muted: #8fa3b8;
  --accent: #ff9900;
  --accent-soft: rgba(255, 153, 0, 0.15);
  --ok: #3ddc97;
  --warn: #ffb020;
  --danger: #ff6b6b;
  --info: #5eb3ff;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --sans: "IBM Plex Sans", system-ui, sans-serif;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

[hidden] {
  display: none !important;
}

body[data-view="login"] #dashboardRoot {
  display: none !important;
}

body[data-view="login"] #loginRoot {
  display: flex !important;
}

body[data-view="dashboard"] #loginRoot {
  display: none !important;
}

body[data-view="dashboard"] #dashboardRoot {
  display: block !important;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--sans);
  color: var(--text);
  background: radial-gradient(circle at top, #15202b 0%, var(--bg) 45%);
}

.bg-grid {
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 32px 32px;
  mask-image: radial-gradient(circle at center, black, transparent 80%);
  pointer-events: none;
}

.app {
  position: relative;
  max-width: 1280px;
  margin: 0 auto;
  padding: 32px 20px 64px;
}

.login-app {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-panel {
  width: min(100%, 420px);
}

.login-panel form {
  display: grid;
  gap: 16px;
  margin-top: 20px;
}

.login-error {
  margin: 0;
  color: var(--danger);
  font-size: 0.92rem;
  min-height: 1.25rem;
}

.login-status {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  min-height: 1.25rem;
}

.header-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.poc-note {
  margin: 0 0 16px;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--panel-border);
  background: var(--accent-soft);
  color: var(--muted);
  font-size: 0.9rem;
}

.btn.loading {
  opacity: 0.7;
  pointer-events: none;
}

.header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 600;
}

h1 {
  margin: 0;
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  line-height: 1.1;
}

.subtitle {
  margin: 10px 0 0;
  color: var(--muted);
  max-width: 640px;
}

.status-pill {
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px solid var(--panel-border);
  background: var(--panel);
  font-weight: 600;
  white-space: nowrap;
}

.status-pill[data-state="idle"] { color: var(--muted); }
.status-pill[data-state="running"] { color: var(--info); border-color: rgba(94, 179, 255, 0.35); }
.status-pill[data-state="ok"] { color: var(--ok); border-color: rgba(61, 220, 151, 0.35); }
.status-pill[data-state="partial"] { color: var(--warn); border-color: rgba(255, 176, 32, 0.35); }
.status-pill[data-state="blocked"] { color: var(--danger); border-color: rgba(255, 107, 107, 0.35); }
.status-pill[data-state="error"] { color: var(--danger); }

.panel {
  background: rgba(18, 24, 33, 0.92);
  border: 1px solid var(--panel-border);
  border-radius: 18px;
  padding: 20px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}

.controls { margin-bottom: 20px; }

.field-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 0.92rem;
}

.field span { color: var(--muted); font-weight: 500; }

input, select, textarea {
  width: 100%;
  border: 1px solid var(--panel-border);
  background: #0d131a;
  color: var(--text);
  border-radius: 12px;
  padding: 12px 14px;
  font: inherit;
}

textarea { resize: vertical; min-height: 84px; }

.checkbox-row {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  margin: 14px 0 18px;
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
}

.actions { display: flex; gap: 12px; }

.btn {
  border: none;
  border-radius: 12px;
  padding: 12px 18px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.btn.primary {
  background: linear-gradient(135deg, #ff9900, #ffb84d);
  color: #1a1200;
}

.btn.primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn.ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--panel-border);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  padding: 16px;
}

.stat-card.ok { border-color: rgba(61, 220, 151, 0.25); }
.stat-card.warn { border-color: rgba(255, 176, 32, 0.25); }
.stat-card.info { border-color: rgba(94, 179, 255, 0.25); }
.stat-card.danger { border-color: rgba(255, 107, 107, 0.25); }

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

.stat-value {
  margin: 8px 0 0;
  font-size: 1.8rem;
  font-weight: 700;
}

.progress-panel { margin-bottom: 20px; }

.progress-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 12px;
}

.progress-header.compact { margin-top: 18px; }

.progress-header h2,
.progress-header h3,
.panel-head h2,
.exports h2 {
  margin: 0;
  font-size: 1.05rem;
}

.progress-header p,
.kms-block p,
.live-line {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.progress-track {
  height: 12px;
  background: #0a1017;
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--panel-border);
}

.progress-track.sub { height: 8px; }

.progress-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #ff9900, #ffb84d);
  transition: width 0.25s ease;
}

.progress-fill.kms {
  background: linear-gradient(90deg, #5eb3ff, #8fd0ff);
}

.live-line {
  margin-top: 16px;
  padding: 12px 14px;
  background: #0a1017;
  border-radius: 12px;
  border: 1px solid var(--panel-border);
  min-height: 44px;
}

.lists-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 28px;
  padding: 0 8px;
  border-radius: 999px;
  background: #0a1017;
  border: 1px solid var(--panel-border);
  font-size: 0.82rem;
  font-weight: 600;
}

.badge.warn { color: var(--warn); }
.badge.ok { color: var(--ok); }
.badge.danger { color: var(--danger); }

.bucket-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 320px;
  overflow: auto;
}

.bucket-list li {
  display: grid;
  gap: 4px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  animation: fadeIn 0.25s ease;
}

.bucket-list li:last-child { border-bottom: none; }

.bucket-name {
  font-weight: 600;
  word-break: break-all;
}

.bucket-meta {
  color: var(--muted);
  font-size: 0.82rem;
  font-family: var(--mono);
}

.tag {
  display: inline-block;
  margin-top: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.tag.unencrypted { background: rgba(255, 176, 32, 0.12); color: var(--warn); }
.tag.sse { background: rgba(61, 220, 151, 0.12); color: var(--ok); }
.tag.kms { background: rgba(94, 179, 255, 0.12); color: var(--info); }
.tag.denied { background: rgba(255, 107, 107, 0.12); color: var(--danger); }

.empty {
  color: var(--muted);
  font-size: 0.92rem;
  padding: 8px 0;
}

.exports { margin-top: 20px; }

.code-block {
  margin: 12px 0 0;
  padding: 16px;
  background: #0a1017;
  border-radius: 12px;
  border: 1px solid var(--panel-border);
  overflow: auto;
  font-family: var(--mono);
  font-size: 0.86rem;
  line-height: 1.5;
}

.mono { font-family: var(--mono); }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 720px) {
  .header { flex-direction: column; }
  .actions { flex-direction: column; }
  .btn { width: 100%; }
}
