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

:root {
  --void: #101218;
  --bay: #181c26;
  --bay-2: #1f2430;
  --rule: #2c3342;
  --bone: #e8e6e0;
  --mute: #8b90a0;
  --leader: #f2c41a;
  --leader-ink: #1a1500;
  --grade: #3db89a;
  --cut: #e85a5a;
  --warn: #e2a54a;
  --focus: #f2c41a;
  --radius: 10px;
  --font-display: 'Syne', system-ui, sans-serif;
  --font-ui: 'Manrope', system-ui, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background:
    radial-gradient(900px 420px at 10% -10%, #2a2410 0%, transparent 55%),
    var(--void);
  color: var(--bone);
  font: 15px/1.5 var(--font-ui);
}
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, p { margin: 0; }
[hidden] { display: none !important; }
:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}

.admin-shell { min-height: 100vh; }

/* Login: film bay split */
.login-screen {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(240px, 0.9fr) minmax(320px, 1.1fr);
}
.login-bay {
  position: relative;
  background: linear-gradient(160deg, #1a1c12 0%, #12141c 55%, #0e1016 100%);
  padding: 48px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
}
.login-bay::before {
  content: '';
  position: absolute;
  inset: 0 auto 0 0;
  width: 14px;
  background: repeating-linear-gradient(
    180deg,
    var(--leader) 0 28px,
    #111 28px 40px,
    #fff 40px 44px,
    #111 44px 56px
  );
}
.login-bay h1 {
  font-family: var(--font-display);
  font-size: clamp(40px, 5vw, 64px);
  line-height: 0.95;
  letter-spacing: -0.04em;
  max-width: 8ch;
}
.login-bay p {
  color: var(--mute);
  max-width: 28ch;
  margin-top: 18px;
}
.login-mark {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 22px;
}
.login-mark img {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  object-fit: contain;
}
.login-panel {
  display: grid;
  place-items: center;
  padding: 40px 28px;
  background: var(--bay);
}
.login-card {
  width: min(400px, 100%);
}
.login-card h2 {
  font-family: var(--font-display);
  font-size: 28px;
  letter-spacing: -0.03em;
  margin-bottom: 8px;
}
.login-card > p {
  color: var(--mute);
  margin-bottom: 28px;
}
.login-links {
  margin-top: 22px;
  display: flex;
  gap: 18px;
  color: var(--mute);
  font-size: 14px;
}
.login-links a:hover { color: var(--bone); }

/* Left sidebar */
.admin-layout {
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
  min-height: 100vh;
}
.admin-sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 28px 18px;
  background: var(--bay);
  border-right: 1px solid var(--rule);
}
.admin-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 18px;
  white-space: nowrap;
  padding: 0 8px;
}
.admin-brand img {
  width: 32px;
  height: 32px;
  border-radius: 8px;
}
.admin-brand em {
  font-style: normal;
  color: var(--leader);
  font-size: 12px;
  margin-left: 4px;
  font-family: var(--font-ui);
  font-weight: 600;
}
.admin-nav {
  display: grid;
  gap: 6px;
  flex: 1;
  align-content: start;
}
.nav-button {
  border: 0;
  background: transparent;
  color: var(--mute);
  border-radius: 10px;
  padding: 12px 14px;
  text-align: left;
  white-space: nowrap;
  transition: color .15s, background .15s;
}
.nav-button:hover { color: var(--bone); background: var(--bay-2); }
.nav-button.active {
  color: var(--leader-ink);
  background: var(--leader);
  font-weight: 600;
}
.rail-actions {
  display: grid;
  gap: 10px;
  margin-top: auto;
  padding: 0 4px 4px;
}
.rail-actions a {
  color: var(--mute);
  font-size: 13px;
}
.rail-actions a:hover { color: var(--bone); }
.rail-actions .secondary-button {
  width: 100%;
}

.admin-main {
  width: min(1100px, calc(100% - 56px));
  margin: 0 auto;
  padding: 36px 0 72px;
}
.admin-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 28px;
}
.admin-header h1 {
  font-family: var(--font-display);
  font-size: clamp(28px, 4vw, 40px);
  letter-spacing: -0.03em;
  line-height: 1.05;
}
.admin-header p {
  color: var(--mute);
  margin-top: 8px;
  max-width: 48ch;
}
.filters, .server-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.btn, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 999px;
  padding: 11px 18px;
  font-weight: 600;
  background: var(--leader);
  color: var(--leader-ink);
  transition: transform .15s, filter .15s;
}
.btn:hover, .button:hover { filter: brightness(1.05); transform: translateY(-1px); }
.btn:disabled, .button:disabled, .secondary-button:disabled {
  opacity: .55;
  cursor: wait;
  transform: none;
}
.secondary-button, .btn-ghost {
  background: transparent;
  border: 1px solid var(--rule);
  color: var(--bone);
  border-radius: 999px;
  padding: 9px 14px;
}
.secondary-button:hover, .btn-ghost:hover {
  border-color: color-mix(in srgb, var(--leader) 50%, var(--rule));
  color: var(--leader);
}

select, input {
  border: 1px solid var(--rule);
  background: var(--bay);
  border-radius: 10px;
  padding: 10px 12px;
  min-width: 0;
  max-width: 100%;
}
select {
  appearance: none;
  padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='m1 1 5 5 5-5' fill='none' stroke='%238b90a0' stroke-width='2'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}

.feedback {
  min-height: 1.4em;
  margin: 0 0 22px;
  color: var(--mute);
  white-space: pre-wrap;
}
.feedback.error, .error { color: var(--cut); }

/* Metrics as open strip, not stacked SaaS cards */
.metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
  border: 1px solid var(--rule);
  border-radius: 14px;
  overflow: hidden;
  background: var(--bay);
  margin-bottom: 28px;
}
.metric {
  padding: 22px 20px;
  border-right: 1px solid var(--rule);
  position: relative;
}
.metric:last-child { border-right: 0; }
.metric span {
  display: block;
  color: var(--mute);
  font-size: 13px;
  margin-bottom: 10px;
}
.metric strong {
  display: block;
  font-family: var(--font-display);
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1;
}
.metric small {
  display: block;
  color: var(--mute);
  font-size: 12px;
  margin-top: 10px;
  line-height: 1.4;
}
.meter {
  height: 3px;
  margin-top: 16px;
  background: var(--rule);
  border-radius: 999px;
  overflow: hidden;
}
.meter > i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--leader);
  transition: width .35s ease;
}
.meter.warn > i { background: var(--warn); }
.meter.critical > i { background: var(--cut); }

.panel {
  background: var(--bay);
  border: 1px solid var(--rule);
  border-radius: 14px;
  padding: 22px 22px 18px;
  margin-bottom: 20px;
}
.panel h2 {
  font-family: var(--font-display);
  font-size: 20px;
  letter-spacing: -0.02em;
}
.panel-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 8px;
}
.legend {
  display: flex;
  gap: 14px;
  font-size: 13px;
  color: var(--mute);
}
.legend b { color: var(--leader); font-weight: 600; }
.legend span::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: #7a86c9;
  margin-right: 6px;
  vertical-align: middle;
}
.legend b::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: var(--leader);
  margin-right: 6px;
  vertical-align: middle;
}

.chart {
  display: flex;
  align-items: end;
  gap: 4px;
  height: 180px;
  margin-top: 18px;
  padding-top: 8px;
  border-bottom: 1px solid var(--rule);
}
.chart-column {
  flex: 1;
  min-width: 0;
  height: 100%;
  display: flex;
  align-items: end;
  justify-content: center;
  gap: 2px;
}
.bar {
  width: 42%;
  min-height: 2px;
  border-radius: 3px 3px 0 0;
  background: var(--leader);
}
.bar.video { background: #7a86c9; }
.chart-dates {
  display: flex;
  justify-content: space-between;
  color: var(--mute);
  font-size: 12px;
  margin-top: 10px;
}
.fine {
  color: var(--mute);
  font-size: 13px;
  margin-top: 12px;
}

.table-scroll { overflow-x: auto; margin-top: 8px; }
table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 14px;
  white-space: nowrap;
}
th {
  font-weight: 500;
  color: var(--mute);
  font-size: 12px;
}
td, th {
  padding: 13px 10px;
  border-bottom: 1px solid var(--rule);
}
td:first-child, th:first-child { padding-left: 0; }
.empty {
  text-align: center;
  color: var(--mute);
  padding: 36px 12px;
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 12px;
  background: var(--bay-2);
  color: var(--bone);
  border: 1px solid var(--rule);
}
.badge.ready { color: var(--grade); border-color: color-mix(in srgb, var(--grade) 40%, var(--rule)); }
.badge.failed { color: var(--cut); border-color: color-mix(in srgb, var(--cut) 40%, var(--rule)); }
.badge.processing, .badge.queued {
  color: var(--leader);
  border-color: color-mix(in srgb, var(--leader) 35%, var(--rule));
}

.form-field {
  display: grid;
  gap: 8px;
  margin: 18px 0;
}
.form-field label { font-size: 14px; font-weight: 500; }
.form-field small { color: var(--mute); font-size: 12px; }
.form-field input,
.form-field textarea,
.form-field select { width: 100%; }
.form-field textarea {
  min-height: 96px;
  resize: vertical;
  font: inherit;
  color: inherit;
  background: var(--panel-2, #16121c);
  border: 1px solid color-mix(in srgb, var(--line, #3a3144) 80%, transparent);
  border-radius: 10px;
  padding: 12px 14px;
}
.settings-form { max-width: 680px; }
.settings-form .button { margin-top: 8px; }
.notice {
  padding: 14px 16px;
  border-radius: 10px;
  background: var(--bay-2);
  border: 1px solid var(--rule);
  color: var(--mute);
  font-size: 14px;
  margin: 16px 0;
}

.auto-refresh {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--mute);
  font-size: 13px;
}
.auto-refresh input { accent-color: var(--leader); }

.server-info, .server-logs {
  margin-top: 14px;
  padding: 14px 16px;
  border-radius: 10px;
  background: #0c0e14;
  border: 1px solid var(--rule);
  font: 12px/1.55 var(--font-mono);
  color: #c9cdd8;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 280px;
  overflow: auto;
}
.server-logs { max-height: 420px; }
.server-logs .log-info { color: #c9cdd8; }
.server-logs .log-warn { color: var(--warn); }
.server-logs .log-error { color: var(--cut); }

.actions-inline {
  display: inline-flex;
  gap: 8px;
  flex-wrap: wrap;
}

@keyframes bay-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
.admin-main > section:not([hidden]) {
  animation: bay-in .35s ease both;
}
@media (prefers-reduced-motion: reduce) {
  .admin-main > section:not([hidden]),
  .meter > i,
  .btn, .button { animation: none; transition: none; }
}

@media (max-width: 980px) {
  .admin-layout { grid-template-columns: 200px minmax(0, 1fr); }
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .metric:nth-child(2n) { border-right: 0; }
  .metric:nth-child(-n+2) { border-bottom: 1px solid var(--rule); }
  .login-screen { grid-template-columns: 1fr; }
  .login-bay { min-height: 280px; padding: 32px 28px 32px 42px; }
}
@media (max-width: 720px) {
  .admin-layout { display: block; }
  .admin-sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--rule);
    padding: 16px;
    gap: 14px;
  }
  .admin-nav {
    display: flex;
    gap: 6px;
    overflow-x: auto;
  }
  .nav-button { white-space: nowrap; }
  .rail-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 0;
  }
  .rail-actions .secondary-button { width: auto; }
  .admin-main { width: calc(100% - 32px); padding-top: 24px; }
  .admin-header { flex-direction: column; align-items: start; }
  .metrics { grid-template-columns: 1fr; }
  .metric { border-right: 0; border-bottom: 1px solid var(--rule); }
  .metric:last-child { border-bottom: 0; }
  .metric strong { font-size: 28px; }
}
