:root {
  --bg: #f7f7f5;
  --surface: rgba(255, 255, 255, 0.92);
  --surface-strong: #ffffff;
  --surface-soft: #f0f2f4;
  --line: rgba(22, 42, 63, 0.08);
  --text: #1a1d22;
  --muted: #68707d;
  --brand: #0f4c81;
  --brand-strong: #1b69ab;
  --accent: #d73f36;
  --good: #16915f;
  --warn: #b98310;
  --bad: #bf3b34;
  --shadow: 0 18px 50px rgba(15, 76, 129, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Manrope, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(15, 76, 129, 0.08), transparent 22%),
    linear-gradient(180deg, #fbfbfa 0%, #f2f4f6 100%);
}

button,
input,
select {
  font: inherit;
}

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

.side-nav {
  position: sticky;
  top: 0;
  display: grid;
  gap: 24px;
  align-content: start;
  height: 100vh;
  padding: 28px 18px;
  background: rgba(255, 255, 255, 0.72);
  border-right: 1px solid var(--line);
  backdrop-filter: blur(18px);
}

.brand-lockup {
  display: flex;
  align-items: center;
  min-height: 58px;
}

.brand-image {
  display: block;
  width: 100%;
  max-width: 182px;
  height: auto;
  object-fit: contain;
}

.nav-stack {
  display: grid;
  gap: 6px;
}

.nav-item {
  text-align: left;
  padding: 12px 14px;
  border: 0;
  border-radius: 14px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.nav-item.primary {
  background: var(--surface-strong);
  color: var(--brand);
  box-shadow: var(--shadow);
}

.nav-item:disabled {
  opacity: 1;
  cursor: default;
}

.side-plan {
  margin-top: auto;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface-strong);
  box-shadow: var(--shadow);
}

.mini-progress {
  margin: 12px 0 8px;
}

.main-stage {
  padding: 20px 22px 36px;
}

body.auth-only .workspace {
  grid-template-columns: 1fr;
}

body.auth-only .side-nav,
body.auth-only .top-bar {
  display: none;
}

body.auth-only .main-stage {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

body.auth-only .hero {
  width: min(540px, 100%);
  grid-template-columns: 1fr;
  margin: 0;
}

body.auth-only .auth-card {
  padding: 24px;
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.search-shell {
  width: min(420px, 100%);
}

.search-shell input {
  width: 100%;
  padding: 12px 16px;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.85);
  color: var(--muted);
  box-shadow: inset 0 0 0 1px var(--line);
}

.top-actions,
.actions,
.panel-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.7fr);
  gap: 16px;
  margin-bottom: 16px;
}

.auth-hero {
  grid-template-columns: 1fr;
}

.panel,
.auth-card,
.stat-card,
.side-plan,
dialog {
  border: 1px solid var(--line);
  border-radius: 26px;
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.eyebrow {
  margin: 0 0 10px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.72rem;
  font-weight: 800;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  max-width: 11ch;
  font-size: clamp(2.1rem, 4vw, 3.7rem);
  line-height: 0.95;
}

h2 {
  font-size: 1.2rem;
}

.subcopy,
.service-copy,
.stat-foot {
  color: var(--muted);
}

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

.auth-head {
  display: grid;
  gap: 8px;
}

.auth-logo {
  width: min(220px, 100%);
  height: auto;
  object-fit: contain;
  margin-bottom: 4px;
}

.auth-title {
  max-width: none;
  font-size: clamp(1.7rem, 3vw, 2.4rem);
  line-height: 1.05;
}

.auth-card,
.stack {
  display: grid;
  gap: 12px;
}

.auth-tabs-minimal {
  display: flex;
  justify-content: flex-end;
}

.oauth-block {
  display: grid;
  gap: 10px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.oauth-block-primary {
  padding-top: 0;
  border-top: 0;
}

.oauth-block-primary .actions {
  justify-content: stretch;
}

.oauth-block-primary .actions button {
  width: 100%;
}

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

.stat-card {
  display: grid;
  gap: 8px;
  padding: 18px;
}

.stat-label {
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.stat-card strong {
  font-size: 1.55rem;
}

.control-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.28fr) minmax(340px, 0.92fr);
  gap: 16px;
  margin-bottom: 16px;
}

.reports-strip {
  margin-bottom: 16px;
}

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

.preview-topline,
.health-row,
.health-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.copy-grid,
.outputs,
.events,
.admin-users,
.history-grid,
.report-grid {
  display: grid;
  gap: 12px;
}

.copy-grid {
  grid-template-columns: 1fr;
}

.copy-card {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface-soft);
}

.copy-card span {
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.copy-card strong,
.output-meta strong {
  overflow-wrap: anywhere;
}

.copy-card button {
  justify-self: start;
}

.icon-copy {
  width: 34px;
  height: 34px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
}

.encoder-card .encoder-meta {
  display: grid;
  gap: 6px;
}

.encoder-card .encoder-meta span {
  color: var(--muted);
  font-size: 0.84rem;
}

.side-stack {
  display: grid;
  gap: 14px;
  align-content: start;
}

.destination-library-panel {
  background: var(--surface-strong);
}

.panel-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

.outputs-compact .output-card {
  padding: 12px;
  background: #fff;
  box-shadow: none;
}

.outputs-compact .output-meta {
  margin: 10px 0;
}

.history-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.report-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 12px;
}

.report-card {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface-soft);
}

.report-card span {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.health-list {
  display: grid;
  gap: 10px;
}

.health-row {
  padding: 12px 14px;
  border-radius: 16px;
  background: var(--surface-soft);
}

.health-meta {
  justify-content: flex-end;
}

.output-card,
.event,
.admin-user-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface-strong);
}

.output-card header,
.admin-user-card header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.output-card h3,
.admin-user-card h3 {
  margin-bottom: 4px;
}

.output-meta {
  display: grid;
  gap: 6px;
  margin: 12px 0;
}

.activity-panel {
  overflow: hidden;
}

.history-table-wrap {
  margin-top: 18px;
  overflow-x: auto;
}

.history-table {
  width: 100%;
  border-collapse: collapse;
}

.history-table th,
.history-table td {
  padding: 12px 10px;
  border-top: 1px solid var(--line);
  text-align: left;
}

.history-table th {
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.history-table td {
  font-size: 0.92rem;
}

.events {
  max-height: 420px;
  overflow: auto;
}

.event {
  display: grid;
  gap: 6px;
}

.history-card {
  align-content: start;
}

.event time {
  font-size: 0.8rem;
  color: var(--muted);
}

.admin-panel {
  background:
    linear-gradient(135deg, rgba(15, 76, 129, 0.08), transparent 36%),
    rgba(255, 255, 255, 0.96);
}

.admin-totals {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 16px 0;
}

.admin-total-card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface-strong);
}

.admin-total-card strong {
  display: block;
  font-size: 1.5rem;
  margin-bottom: 6px;
}

.admin-user-card {
  display: grid;
  gap: 12px;
}

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

label {
  display: grid;
  gap: 8px;
  font-size: 0.94rem;
}

.inline {
  grid-auto-flow: column;
  justify-content: start;
  align-items: center;
}

input,
select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid rgba(22, 42, 63, 0.1);
  background: var(--surface-strong);
  color: var(--text);
}

button {
  border: 0;
  border-radius: 12px;
  padding: 10px 14px;
  background: rgba(15, 76, 129, 0.08);
  color: var(--text);
  cursor: pointer;
}

button.primary {
  color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--brand-strong));
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.badge.running {
  color: var(--good);
  background: rgba(22, 145, 95, 0.12);
}

.badge.starting {
  color: var(--warn);
  background: rgba(185, 131, 16, 0.12);
}

.badge.idle,
.badge.error {
  color: var(--bad);
  background: rgba(191, 59, 52, 0.12);
}

dialog {
  width: min(520px, calc(100% - 24px));
  padding: 0;
}

dialog::backdrop {
  background: rgba(10, 18, 30, 0.35);
}

.dialog-form {
  padding: 20px;
}

.hidden {
  display: none !important;
}

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

  .side-nav {
    position: static;
    height: auto;
  }
}

@media (max-width: 980px) {
  .hero,
  .control-grid,
  .stats-strip,
  .copy-grid,
  .admin-totals,
  .admin-user-grid,
  .history-grid,
  .report-grid {
    grid-template-columns: 1fr;
  }

  .top-bar,
  .preview-topline,
  .preview-footer,
  .top-actions {
    flex-direction: column;
    align-items: flex-start;
  }

  .main-stage {
    padding: 14px;
  }
}
