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

:root {
  --clr-bg: #0d1117;
  --clr-surface: #161b22;
  --clr-surface-2: #1c2129;
  --clr-border: #30363d;
  --clr-text: #e6edf3;
  --clr-muted: #7d8590;
  --clr-primary: #238636;
  --clr-primary-hover: #2ea043;
  --clr-accent: #1f6feb;
  --clr-danger: #da3633;
  --clr-warning: #d29922;
  --clr-success: #238636;
  --clr-info: #1f6feb;
  --font-body: 'Inter', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.4);
  --shadow-md: 0 4px 12px rgba(0,0,0,.5);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; }

body {
  font-family: var(--font-body);
  background: var(--clr-bg);
  color: var(--clr-text);
  min-height: 100vh;
  line-height: 1.6;
}

a { color: var(--clr-accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Layout ─────────────────────────────────────────────────────────────── */

.platform-shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.platform-sidebar {
  background: var(--clr-surface);
  border-right: 1px solid var(--clr-border);
  display: flex;
  flex-direction: column;
  padding: 1.5rem 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.platform-logo {
  padding: 0 1.25rem 1.5rem;
  border-bottom: 1px solid var(--clr-border);
  margin-bottom: 1rem;
}

.platform-logo h1 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--clr-text);
  letter-spacing: -0.02em;
}

.platform-logo .tagline {
  font-size: 0.75rem;
  color: var(--clr-muted);
  margin-top: 2px;
}

.sidebar-nav {
  list-style: none;
  flex: 1;
  padding: 0 0.5rem;
}

.sidebar-nav li a {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  color: var(--clr-muted);
  font-size: 0.875rem;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
}

.sidebar-nav li a:hover,
.sidebar-nav li a.active {
  background: var(--clr-surface-2);
  color: var(--clr-text);
  text-decoration: none;
}

.sidebar-nav li a.active { color: var(--clr-primary-hover); }

.sidebar-footer {
  padding: 1rem 1.25rem 0;
  border-top: 1px solid var(--clr-border);
  margin-top: auto;
}

.sidebar-footer .user-info {
  font-size: 0.75rem;
  color: var(--clr-muted);
  margin-bottom: 0.75rem;
}

.platform-main {
  padding: 2rem;
  overflow-y: auto;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.page-header h2 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.page-header .subtitle {
  font-size: 0.875rem;
  color: var(--clr-muted);
  margin-top: 0.25rem;
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  text-decoration: none;
}

.btn-primary {
  background: var(--clr-primary);
  border-color: var(--clr-primary);
  color: #fff;
}
.btn-primary:hover { background: var(--clr-primary-hover); border-color: var(--clr-primary-hover); text-decoration: none; color: #fff; }

.btn-secondary {
  background: var(--clr-surface-2);
  border-color: var(--clr-border);
  color: var(--clr-text);
}
.btn-secondary:hover { background: var(--clr-border); text-decoration: none; color: var(--clr-text); }

.btn-danger {
  background: transparent;
  border-color: var(--clr-danger);
  color: var(--clr-danger);
}
.btn-danger:hover { background: var(--clr-danger); color: #fff; text-decoration: none; }

.btn-sm { padding: 0.3rem 0.625rem; font-size: 0.8125rem; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--clr-muted); }
.btn-ghost:hover { color: var(--clr-text); background: var(--clr-surface-2); text-decoration: none; }

/* ── Cards & panels ─────────────────────────────────────────────────────── */

.card {
  background: var(--clr-surface);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.card-title {
  font-size: 0.875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--clr-muted);
}

/* ── Stats row ──────────────────────────────────────────────────────────── */

.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--clr-surface);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
}

.stat-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--clr-muted);
  margin-bottom: 0.375rem;
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

/* ── Tenant table ───────────────────────────────────────────────────────── */

.tenant-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-md);
}

table.tenant-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.tenant-table th {
  background: var(--clr-surface);
  padding: 0.75rem 1rem;
  text-align: left;
  font-weight: 600;
  color: var(--clr-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--clr-border);
  white-space: nowrap;
}

.tenant-table td {
  padding: 0.875rem 1rem;
  border-bottom: 1px solid var(--clr-border);
  vertical-align: middle;
}

.tenant-table tr:last-child td { border-bottom: none; }

.tenant-table tr:hover td {
  background: var(--clr-surface-2);
}

.tenant-domain {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  color: var(--clr-accent);
  font-weight: 500;
}

.tenant-domain a { color: inherit; }
.tenant-domain a:hover { text-decoration: underline; }

/* ── Status pills ───────────────────────────────────────────────────────── */

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.625rem;
  border-radius: 100px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: capitalize;
}

.status-pill::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.status-active { background: rgba(35, 134, 54, 0.15); color: #3fb950; }
.status-provisioning { background: rgba(210, 153, 34, 0.15); color: #d29922; animation: pulse-status 1.5s ease-in-out infinite; }
.status-failed { background: rgba(218, 54, 51, 0.15); color: #f85149; }
.status-pending { background: rgba(110, 118, 129, 0.15); color: #8b949e; }

@keyframes pulse-status {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* ── Theme grid ─────────────────────────────────────────────────────────── */

.theme-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
}

.theme-card {
  border: 2px solid var(--clr-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.15s;
  background: var(--clr-surface);
}

.theme-card:hover,
.theme-card.selected {
  border-color: var(--clr-primary);
}

.theme-preview {
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 0.875rem;
  font-weight: 600;
}

.theme-info { padding: 0.75rem; }
.theme-info h4 { font-size: 0.875rem; font-weight: 600; margin-bottom: 0.25rem; }
.theme-info p { font-size: 0.75rem; color: var(--clr-muted); }
.theme-fonts { font-size: 0.6875rem; color: var(--clr-muted); margin-top: 0.375rem; font-family: var(--font-mono); }

/* ── Forms ──────────────────────────────────────────────────────────────── */

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

@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }

.form-field { display: flex; flex-direction: column; gap: 0.375rem; }
.form-field.full-width { grid-column: 1 / -1; }

.form-label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--clr-text);
}

.form-label .required { color: var(--clr-danger); margin-left: 2px; }
.form-hint { font-size: 0.75rem; color: var(--clr-muted); }

.form-control {
  background: var(--clr-bg);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-sm);
  color: var(--clr-text);
  font-family: var(--font-body);
  font-size: 0.875rem;
  padding: 0.5rem 0.75rem;
  width: 100%;
  transition: border-color 0.15s;
  outline: none;
}

.form-control:focus { border-color: var(--clr-accent); box-shadow: 0 0 0 2px rgba(31,111,235,.3); }
.form-control.mono { font-family: var(--font-mono); }

textarea.form-control { resize: vertical; min-height: 80px; }

/* ── Alerts ─────────────────────────────────────────────────────────────── */

.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  border: 1px solid transparent;
  margin-bottom: 1rem;
}

.alert-error { background: rgba(218,54,51,.12); border-color: rgba(218,54,51,.4); color: #f85149; }
.alert-success { background: rgba(35,134,54,.12); border-color: rgba(35,134,54,.4); color: #3fb950; }
.alert-info { background: rgba(31,111,235,.12); border-color: rgba(31,111,235,.4); color: #58a6ff; }

/* ── Login page ─────────────────────────────────────────────────────────── */

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.login-box {
  background: var(--clr-surface);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-lg);
  padding: 2.5rem;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow-md);
}

.login-box h1 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.375rem;
  letter-spacing: -0.02em;
}

.login-box .tagline {
  color: var(--clr-muted);
  font-size: 0.875rem;
  margin-bottom: 2rem;
}

/* ── Provision log ──────────────────────────────────────────────────────── */

.log-list { list-style: none; }

.log-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.625rem 0;
  border-bottom: 1px solid var(--clr-border);
  font-size: 0.8125rem;
}

.log-item:last-child { border-bottom: none; }

.log-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 5px;
  flex-shrink: 0;
}

.log-dot-success { background: var(--clr-success); }
.log-dot-error { background: var(--clr-danger); }
.log-dot-info { background: var(--clr-info); }

.log-step { font-weight: 600; color: var(--clr-text); }
.log-message { color: var(--clr-muted); font-family: var(--font-mono); font-size: 0.75rem; margin-top: 2px; }
.log-time { color: var(--clr-muted); font-size: 0.6875rem; white-space: nowrap; }

/* ── Detail page ────────────────────────────────────────────────────────── */

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 1.5rem;
  align-items: start;
}

@media (max-width: 900px) { .detail-grid { grid-template-columns: 1fr; } }

.detail-dl { display: grid; grid-template-columns: 140px 1fr; gap: 0.5rem 1rem; font-size: 0.875rem; }
.detail-dt { color: var(--clr-muted); font-weight: 500; padding-top: 2px; }
.detail-dd { color: var(--clr-text); }
.detail-dd.mono { font-family: var(--font-mono); font-size: 0.8125rem; }

/* ── Empty state ────────────────────────────────────────────────────────── */

.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--clr-muted);
}

.empty-state h3 { font-size: 1rem; margin-bottom: 0.5rem; color: var(--clr-text); }
.empty-state p { font-size: 0.875rem; }

/* ── Misc ───────────────────────────────────────────────────────────────── */

.section-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--clr-border);
}

.spinner-inline {
  width: 14px; height: 14px;
  border: 2px solid var(--clr-border);
  border-top-color: var(--clr-primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}

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

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.flex { display: flex; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.text-muted { color: var(--clr-muted); }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.mono { font-family: var(--font-mono); }
.hidden { display: none !important; }

@media (max-width: 768px) {
  .platform-shell { grid-template-columns: 1fr; }
  .platform-sidebar { display: none; }
  .platform-main { padding: 1rem; }
  .stats-row { grid-template-columns: 1fr 1fr; }
}

/* ── Reports page ───────────────────────────────────────────────────────── */

.report-grid {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 1.5rem;
  align-items: start;
}

@media (max-width: 1000px) { .report-grid { grid-template-columns: 1fr; } }

.report-col-main { min-width: 0; }
.report-col-side { min-width: 0; }

/* Inline bar used in step outcomes and theme distribution */
.step-bar-wrap {
  height: 6px;
  background: var(--clr-surface-2);
  border-radius: 100px;
  overflow: hidden;
  margin-bottom: 2px;
}

.step-bar {
  height: 100%;
  border-radius: 100px;
  transition: width 0.3s ease;
}

/* Theme distribution list */
.theme-dist-list { list-style: none; display: flex; flex-direction: column; gap: 0.875rem; }
.theme-dist-item {}

/* Audit event list */
.audit-list { list-style: none; }

.audit-item {
  display: flex;
  align-items: flex-start;
  gap: 0.625rem;
  padding: 0.625rem 0;
  border-bottom: 1px solid var(--clr-border);
  font-size: 0.8125rem;
}

.audit-item:last-child { border-bottom: none; }

.audit-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 4px;
  flex-shrink: 0;
}

.audit-dot-success { background: var(--clr-success); }
.audit-dot-error   { background: var(--clr-danger); }
.audit-dot-muted   { background: var(--clr-muted); }

.audit-action  { font-weight: 600; color: var(--clr-text); }
.audit-domain  { font-size: 0.75rem; color: var(--clr-muted); margin-top: 1px; }
.audit-meta    { margin-top: 2px; }
.audit-date    { white-space: nowrap; margin-left: auto; padding-left: 0.5rem; }

/* deprovisioning status pill */
.status-deprovisioning { background: rgba(210, 153, 34, 0.15); color: #d29922; animation: pulse-status 1.5s ease-in-out infinite; }
