:root {
  color-scheme: dark;
  --bg: #0d1117;
  --surface: #151b23;
  --surface-2: #1c242f;
  --border: #2a3442;
  --text: #e5edf7;
  --muted: #94a3b8;
  --teal: #24c8a6;
  --teal-strong: #14b89a;
  --amber: #f2b84b;
  --danger: #ef6b73;
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.25);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

a {
  color: var(--teal);
}

button,
input,
select,
textarea {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  min-height: 100vh;
}

.auth-body {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 18px;
}

.auth-shell {
  width: min(100%, 460px);
}

.wide-auth-shell {
  width: min(100%, 720px);
}

.auth-panel {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 22px;
}

.compact-brand {
  margin-bottom: 20px;
}

.muted-text,
.auth-switch {
  color: var(--muted);
  line-height: 1.6;
}

.auth-switch {
  margin: 18px 0 0;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  border-right: 1px solid var(--border);
  background: #0b0f15;
  padding: 22px 18px;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  min-height: 48px;
  margin-bottom: 26px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: var(--teal);
  color: #07110f;
  font-weight: 800;
}

.brand strong,
.brand span {
  display: block;
}

.brand span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.nav-list {
  display: grid;
  gap: 8px;
}

.nav-link {
  display: block;
  padding: 11px 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--muted);
  text-decoration: none;
}

.nav-link:hover,
.nav-link.active {
  border-color: var(--border);
  background: var(--surface);
  color: var(--text);
}

.disabled-link {
  cursor: not-allowed;
  opacity: 0.58;
}

.workspace {
  padding: 28px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  margin-bottom: 18px;
}

.eyebrow,
.section-label {
  margin: 0 0 4px;
  color: var(--teal);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(26px, 4vw, 38px);
}

h2 {
  font-size: 18px;
}

.session-pill,
.table-chip {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 11px;
  color: var(--muted);
  background: var(--surface);
  font-size: 13px;
  white-space: nowrap;
}

.session-pill.online {
  border-color: rgba(36, 200, 166, 0.5);
  color: var(--teal);
}

.session-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.status-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  padding: 14px;
}

.status-card span,
label {
  color: var(--muted);
  font-size: 13px;
}

.status-card strong {
  display: block;
  margin-top: 5px;
  overflow-wrap: anywhere;
}

.alert {
  border: 1px solid rgba(36, 200, 166, 0.55);
  border-radius: 8px;
  background: rgba(36, 200, 166, 0.1);
  color: var(--text);
  margin: 14px 0;
  padding: 12px 14px;
}

.alert.error {
  border-color: rgba(239, 107, 115, 0.65);
  background: rgba(239, 107, 115, 0.1);
}

.hidden {
  display: none;
}

.panel-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.panel {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 18px;
}

.wide-panel {
  grid-column: 1 / -1;
}

.debug-panel {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  margin: 14px 0;
  padding: 18px;
}

.compact-debug .debug-log {
  max-height: 160px;
}

.debug-log {
  display: block;
  width: 100%;
  min-height: 140px;
  max-height: 260px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #070b10;
  color: #c8d3df;
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 12px;
  line-height: 1.55;
  margin: 0;
  padding: 12px;
  white-space: pre-wrap;
  resize: vertical;
}

.preview-summary {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #0d131b;
  color: var(--muted);
  padding: 11px 12px;
  font-size: 13px;
}

.progress-shell {
  height: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #080c12;
}

.progress-bar {
  width: 0%;
  height: 100%;
  background: var(--teal);
  transition: width 160ms ease;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #080c12;
  max-height: 360px;
}

.preview-table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  font-size: 12px;
}

.preview-table th,
.preview-table td {
  border-bottom: 1px solid var(--border);
  padding: 9px 10px;
  text-align: left;
  vertical-align: top;
}

.preview-table th {
  position: sticky;
  top: 0;
  background: #111821;
  color: var(--text);
}

.preview-table td {
  color: #cbd5e1;
}

.preview-table .muted-cell {
  color: var(--muted);
}

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

.form-stack {
  display: grid;
  gap: 13px;
}

label {
  display: grid;
  gap: 7px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #0d131b;
  color: var(--text);
  outline: none;
  padding: 11px 12px;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(36, 200, 166, 0.16);
}

.split-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.button-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.primary-link,
.secondary-link {
  display: inline-grid;
  min-height: 42px;
  place-items: center;
  border-radius: 8px;
  font-weight: 700;
  padding: 0 15px;
  text-decoration: none;
}

.primary-link {
  background: var(--teal);
  color: #07110f;
}

.secondary-link {
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
}

.primary-button,
.secondary-button,
.icon-button {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 700;
}

.primary-button {
  background: var(--teal);
  color: #07110f;
  padding: 0 15px;
}

.primary-button:hover {
  background: var(--teal-strong);
}

.secondary-button {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--text);
  padding: 0 15px;
}

.icon-button {
  width: 42px;
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--text);
}

.profile-list {
  display: grid;
  gap: 12px;
  margin: 0;
}

.profile-list div {
  display: grid;
  gap: 4px;
}

.profile-list dt {
  color: var(--muted);
  font-size: 13px;
}

.profile-list dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.phase-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.phase-button {
  min-height: 82px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #0d131b;
  color: var(--text);
  font-weight: 800;
  text-align: left;
  padding: 13px;
}

.phase-button span {
  display: inline-block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.phase-button:disabled {
  cursor: not-allowed;
  opacity: 0.72;
}

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

  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .nav-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .workspace {
    padding: 18px;
  }

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

@media (max-width: 560px) {
  .topbar,
  .panel-header {
    align-items: stretch;
    flex-direction: column;
  }

  .nav-list,
  .split-fields,
  .phase-grid {
    grid-template-columns: 1fr;
  }

  .auth-panel {
    padding: 18px;
  }
}
