:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --card: #fff;
  --ink: #111827;
  --muted: #667085;
  --line: #e5e7eb;
  --soft: #fff7ed;
  --accent: #ff7a1a;
  --accent-dark: #ea580c;
  --green: #059669;
  --red: #dc2626;
  --blue: #2563eb;
  --shadow: 0 18px 60px rgba(15, 23, 42, .07);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

button {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-weight: 850;
  padding: 11px 14px;
  transition: transform .16s ease, border-color .16s ease, background .16s ease;
}

button:hover {
  border-color: #fed7aa;
  transform: translateY(-1px);
}

button.primary,
.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

button.primary:hover {
  background: var(--accent-dark);
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid #dbe3ee;
  border-radius: 14px;
  background: #f8fafc;
  color: var(--ink);
  outline: 0;
  padding: 12px 13px;
}

input:focus,
textarea:focus,
select:focus {
  border-color: #93c5fd;
  box-shadow: 0 0 0 4px rgba(147, 197, 253, .28);
}

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

.admin-rail {
  position: sticky;
  top: 0;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 22px;
  border-right: 1px solid var(--line);
  background: #fff;
  padding: 22px 16px;
}

.brand {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  gap: 11px;
  align-items: center;
  color: inherit;
  text-decoration: none;
}

.brand span {
  grid-row: span 2;
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 16px;
  background: var(--accent);
  color: #fff;
  font-weight: 950;
}

.brand strong,
.brand small {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand small {
  color: var(--muted);
  font-weight: 750;
}

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

.admin-rail nav a {
  border-radius: 14px;
  color: #334155;
  padding: 12px 14px;
  text-decoration: none;
  font-weight: 900;
}

.admin-rail nav a.active,
.admin-rail nav a:hover {
  background: var(--soft);
  color: var(--accent-dark);
}

.rail-footer {
  display: grid;
  gap: 10px;
  margin-top: auto;
}

.admin-main {
  width: min(100% - 44px, 1320px);
  margin: 0 auto;
  padding: 26px 0 80px;
}

.topbar,
.section-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 520px) auto;
  gap: 18px;
  align-items: center;
}

.section-head {
  grid-template-columns: minmax(0, 1fr) auto;
  margin: 26px 0 16px;
}

.section-head.compact {
  margin: 0 0 16px;
}

.eyebrow {
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 950;
  letter-spacing: .12em;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(30px, 4vw, 46px);
  line-height: .96;
}

h2 {
  margin-bottom: 0;
  font-size: clamp(24px, 3vw, 34px);
  line-height: 1.05;
}

h3 {
  margin-bottom: 14px;
  font-size: 20px;
}

p {
  color: var(--muted);
  line-height: 1.55;
}

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

.command span,
.auth-card label span {
  color: #475467;
  font-weight: 850;
  font-size: 13px;
}

.auth-card,
.panel,
.table-card,
.list-panel,
.detail-panel {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--card);
  box-shadow: var(--shadow);
}

.auth-card {
  display: grid;
  grid-template-columns: minmax(240px, 340px) minmax(0, 1fr);
  gap: 22px;
  align-items: start;
  margin: 24px 0;
  padding: 24px;
}

.auth-card-clean {
  overflow: hidden;
}

.auth-copy {
  display: grid;
  gap: 12px;
  align-content: start;
}

.auth-copy h2 {
  max-width: 280px;
}

.auth-copy p {
  margin-bottom: 0;
  max-width: 320px;
}

.auth-form-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(220px, .8fr);
  gap: 14px;
  align-items: stretch;
}

.admin-login-card {
  display: grid;
  gap: 14px;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  background: #fff;
  padding: 16px;
}

.admin-login-card label {
  display: grid;
  gap: 8px;
}

.admin-login-card label span {
  color: #344054;
  font-size: 13px;
  font-weight: 900;
}

.admin-login-card small {
  color: var(--muted);
  font-weight: 700;
  line-height: 1.45;
}

.password-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.password-row input {
  min-width: 0;
}

.password-row button {
  height: 100%;
  min-width: 76px;
}

.field-card,
.advanced-card {
  display: grid;
  gap: 8px;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  background: #f8fafc;
  padding: 14px;
}

.field-card span,
.advanced-card span {
  color: #344054;
  font-size: 13px;
  font-weight: 900;
}

.field-card small {
  color: var(--muted);
  font-weight: 700;
  line-height: 1.4;
}

.field-card input,
.field-card textarea,
.advanced-card input {
  background: #fff;
}

.token-field {
  grid-row: span 2;
}

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

.advanced-card summary {
  cursor: pointer;
  color: #475467;
  font-weight: 900;
}

.advanced-card label {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.auth-actions {
  justify-content: end;
  align-self: end;
}

.access-state {
  grid-column: 1 / -1;
  border: 1px solid #fed7aa;
  border-radius: 14px;
  background: #fff7ed;
  color: #9a3412;
  padding: 12px 14px;
  font-weight: 850;
}

.access-state.ok {
  border-color: #bbf7d0;
  background: #ecfdf5;
  color: var(--green);
}

.locked-panel {
  display: none;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: linear-gradient(135deg, #fff, #fff7ed);
  box-shadow: var(--shadow);
  margin-top: 24px;
  padding: 34px;
}

.locked-panel.active {
  display: block;
}

.locked-panel h2 {
  margin-bottom: 14px;
}

.unlock-steps {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.unlock-steps span {
  border: 1px solid #fed7aa;
  border-radius: 14px;
  background: #fff;
  color: #475467;
  font-weight: 800;
  line-height: 1.4;
  padding: 14px;
}

.button-row,
.queue-toolbar,
.two-col,
.inline-form {
  display: flex;
  gap: 10px;
  align-items: center;
}

.button-row {
  flex-wrap: wrap;
}

.panel-section {
  display: none;
}

.panel-section.active {
  display: block;
}

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

.metric-card {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
  padding: 18px;
}

.metric-card span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
}

.metric-card strong {
  display: block;
  margin-top: 8px;
  font-size: 30px;
  line-height: 1;
}

.metric-card em {
  display: block;
  margin-top: 8px;
  color: var(--green);
  font-style: normal;
  font-weight: 850;
}

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

.panel,
.table-card,
.list-panel,
.detail-panel {
  padding: 20px;
}

.danger-panel {
  margin-top: 16px;
  border-color: #fecaca;
  background: linear-gradient(180deg, #fff, #fff7f7);
}

.danger-button {
  border-color: var(--red);
  background: var(--red);
  color: #fff;
}

.danger-button:hover {
  border-color: #991b1b;
  background: #b91c1c;
}

.status-list,
.checklist,
.action-grid,
.form-grid {
  display: grid;
  gap: 12px;
}

.status-row,
.entity-row,
.report-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  border: 1px solid #eef2f7;
  border-radius: 14px;
  background: #f8fafc;
  padding: 13px;
}

.status-row strong,
.entity-row strong,
.report-row strong {
  display: block;
}

.status-row small,
.entity-row small,
.report-row small {
  display: block;
  color: var(--muted);
  margin-top: 3px;
}

.pill {
  border-radius: 999px;
  background: var(--soft);
  color: var(--accent-dark);
  font-weight: 950;
  padding: 8px 10px;
  white-space: nowrap;
}

.pill.ok {
  background: #ecfdf5;
  color: var(--green);
}

.pill.bad {
  background: #fef2f2;
  color: var(--red);
}

.queue-toolbar {
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.queue-toolbar button.active {
  border-color: #fed7aa;
  background: var(--soft);
  color: var(--accent-dark);
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(260px, 360px) minmax(0, 1fr);
  gap: 16px;
}

.list-panel {
  display: grid;
  align-content: start;
  gap: 12px;
  min-height: 520px;
}

.detail-panel {
  min-height: 520px;
}

.entity-row {
  cursor: pointer;
  text-align: left;
}

.entity-row:hover {
  border-color: #fed7aa;
  background: #fff7ed;
}

.detail-hero {
  display: grid;
  gap: 8px;
  border-radius: 18px;
  background: linear-gradient(135deg, #fff7ed, #f8fafc);
  padding: 20px;
}

.detail-hero h3 {
  margin: 0;
  font-size: 32px;
}

.plain-list {
  display: grid;
  gap: 10px;
  padding-left: 20px;
  color: var(--muted);
}

code {
  border-radius: 8px;
  background: #f1f5f9;
  color: #0f172a;
  padding: 2px 6px;
}

.log-panel {
  display: grid;
  gap: 8px;
  max-height: 360px;
  overflow: auto;
  border-radius: 14px;
  background: #0f172a;
  color: #dbeafe;
  padding: 14px;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 13px;
}

.toast-region {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 30;
  display: grid;
  gap: 10px;
}

.toast {
  width: min(360px, calc(100vw - 32px));
  border: 1px solid #fed7aa;
  border-radius: 16px;
  background: #fff;
  box-shadow: var(--shadow);
  padding: 13px 15px;
  font-weight: 850;
}

.soft-state {
  border: 1px dashed #fed7aa;
  border-radius: 16px;
  background: #fff7ed;
  color: #9a3412;
  padding: 16px;
  font-weight: 850;
}

.danger {
  color: var(--red);
}

hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 18px 0;
}

@media (max-width: 1100px) {
  .admin-shell {
    grid-template-columns: 86px minmax(0, 1fr);
  }

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

  .brand strong,
  .brand small,
  .admin-rail nav a {
    font-size: 0;
  }

  .admin-rail nav a::first-letter {
    font-size: 18px;
  }

  .topbar,
  .auth-card,
  .auth-form-grid,
  .metric-grid,
  .split-grid {
    grid-template-columns: 1fr;
  }

  .auth-actions {
    justify-content: start;
  }
}

@media (max-width: 760px) {
  .admin-shell {
    display: block;
  }

  .admin-rail {
    position: static;
    height: auto;
    flex-direction: row;
    overflow-x: auto;
  }

  .admin-rail nav {
    display: flex;
    min-width: max-content;
  }

  .rail-footer {
    display: none;
  }

  .admin-main {
    width: min(100% - 20px, 720px);
    padding-top: 18px;
  }

  .workspace-grid,
  .section-head,
  .topbar {
    grid-template-columns: 1fr;
  }
}
