:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --ink: #101820;
  --text: #20262b;
  --muted: #65737f;
  --line: #d8e0e6;
  --line-strong: #b9c6cf;
  --blue: #1f66ad;
  --blue-dark: #174f88;
  --green: #137a52;
  --red: #b42318;
  --amber: #a05a00;
  --sidebar: #111920;
  --sidebar-soft: #1b2631;
  --teal: #0f766e;
  --shadow: 0 1px 2px rgba(20, 28, 38, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  letter-spacing: 0;
}

a {
  color: inherit;
}

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

button,
.button-link {
  min-height: 36px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
  cursor: pointer;
  padding: 0 12px;
  text-decoration: none;
}

button:hover:not(:disabled),
.button-link:hover {
  border-color: var(--blue);
  color: var(--blue);
}

button:disabled,
.button-link.is-disabled {
  cursor: not-allowed;
  opacity: 0.55;
  pointer-events: none;
}

button.primary {
  border-color: var(--blue);
  background: var(--blue);
  color: #ffffff;
}

button.primary:hover:not(:disabled) {
  border-color: var(--blue-dark);
  background: var(--blue-dark);
  color: #ffffff;
}

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

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
  padding: 9px 10px;
}

textarea {
  min-height: 110px;
  resize: vertical;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

code,
pre {
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
}

.auth-shell {
  display: grid;
  grid-template-columns: minmax(360px, 0.86fr) minmax(440px, 1.14fr);
  min-height: 100vh;
}

.auth-brand-panel {
  display: flex;
  min-height: 100vh;
  flex-direction: column;
  justify-content: space-between;
  background: var(--sidebar);
  color: #f4f8fb;
  padding: 42px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  width: fit-content;
  color: #ffffff;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 8px;
  background: var(--teal);
  font-weight: 900;
}

.brand span:last-child {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.brand small {
  color: #a8b6c3;
  font-size: 12px;
}

.auth-copy {
  max-width: 540px;
}

.auth-copy h1 {
  margin: 8px 0 18px;
  font-size: clamp(32px, 5vw, 54px);
  line-height: 1;
}

.auth-copy p:last-child {
  color: #b8c8d5;
  font-size: 15px;
  line-height: 1.7;
}

.auth-facts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  margin: 0;
  overflow: hidden;
  border: 1px solid #34424e;
  border-radius: 8px;
  background: #34424e;
}

.auth-facts div {
  min-width: 0;
  background: #151f29;
  padding: 13px;
}

.auth-facts dt {
  color: #92a3b0;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.auth-facts dd {
  margin: 4px 0 0;
  font-size: 12px;
  font-weight: 800;
}

.auth-form-panel {
  display: grid;
  place-items: center;
  padding: 32px;
}

.auth-card,
.panel,
.metric-grid article,
.session-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

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

.auth-card h2 {
  margin: 0;
  color: var(--ink);
  font-size: 27px;
}

.auth-card p:not(.eyebrow) {
  margin: 7px 0 0;
  color: var(--muted);
}

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

.portal-sidebar {
  position: sticky;
  top: 0;
  display: flex;
  height: 100vh;
  flex-direction: column;
  gap: 18px;
  overflow-y: auto;
  background: var(--sidebar);
  color: #f4f8fb;
  padding: 18px;
}

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

.side-nav a {
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 6px;
  color: #d6e0e7;
  padding: 9px 10px;
  text-decoration: none;
  font-weight: 700;
}

.side-nav a:hover,
.side-nav a:focus-visible {
  border-color: #354554;
  background: var(--sidebar-soft);
  color: #ffffff;
  outline: none;
}

.session-card {
  display: grid;
  gap: 10px;
  margin-top: auto;
  border-color: #34424e;
  background: var(--sidebar-soft);
  color: #dbe7ee;
  padding: 12px;
}

.session-card span {
  overflow-wrap: anywhere;
  font-size: 12px;
  font-weight: 700;
}

.portal-main {
  display: grid;
  gap: 14px;
  align-content: start;
  min-width: 0;
  padding: 16px 18px 24px;
}

.topbar,
.panel-heading,
.row-actions,
.topbar-actions {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.topbar {
  min-height: 78px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
  padding: 14px;
}

.topbar h1 {
  margin: 0;
  font-size: 24px;
}

.topbar p:not(.eyebrow) {
  margin: 4px 0 0;
  color: var(--muted);
}

.topbar-actions,
.row-actions {
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.row-actions.split {
  justify-content: space-between;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.auth-copy .eyebrow {
  color: #6fd0a2;
}

.status-line {
  border: 1px solid #c8d8e4;
  border-radius: 8px;
  background: #edf5fb;
  color: var(--blue-dark);
  padding: 11px 13px;
  font-weight: 700;
}

.auth-form-panel .status-line {
  width: min(460px, 100%);
  margin-top: 12px;
}

.status-line.is-error {
  border-color: #efb6b0;
  background: #fff1f0;
  color: #8d251c;
}

.status-line.is-ok {
  border-color: #a9d8c1;
  background: #edf8f2;
  color: #116641;
}

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

.metric-grid article,
.panel {
  padding: 14px;
}

.metric-grid span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.metric-grid strong {
  display: block;
  margin-top: 8px;
  overflow-wrap: anywhere;
  font-size: 25px;
  line-height: 1.1;
}

.panel-heading {
  margin-bottom: 12px;
}

.panel-heading.compact {
  align-items: center;
}

.panel-heading h2,
.panel-heading h3 {
  margin: 0;
  color: var(--ink);
  font-size: 17px;
}

.panel-heading h3 {
  font-size: 14px;
}

.panel-heading span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.stack {
  display: grid;
  gap: 11px;
}

.grid-two,
.workbench-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
}

.inline-form {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(120px, 180px) auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 12px;
}

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

.package-card,
.empty-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 14px;
}

.package-card span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.package-card h3 {
  margin: 8px 0 10px;
  font-size: 16px;
}

.package-card strong {
  display: block;
  font-size: 22px;
}

.package-card p {
  margin: 7px 0 14px;
  color: var(--muted);
}

.segmented {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 4px;
}

.segmented button {
  min-height: 30px;
  border-color: transparent;
  background: transparent;
  font-weight: 800;
}

.segmented button.is-active {
  border-color: var(--blue);
  background: var(--blue);
  color: #ffffff;
}

.checkline {
  display: inline-flex;
  grid-template-columns: none;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
}

.checkline input {
  width: auto;
}

.code-output {
  min-height: 180px;
  max-height: 420px;
  overflow: auto;
  margin: 0;
  border: 1px solid #cfd8de;
  border-radius: 8px;
  background: #111920;
  color: #dbe7ee;
  padding: 12px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.preview-stage {
  display: grid;
  height: clamp(280px, 38vh, 520px);
  min-height: 280px;
  place-items: center;
  overflow: hidden;
  border: 1px solid #222d36;
  border-radius: 8px;
  background: #101820;
  color: #aebbc6;
  margin-bottom: 12px;
}

.preview-stage img,
.preview-stage video {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  background: #0d141a;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  min-width: 920px;
  border-collapse: collapse;
}

thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f3f7fa;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 8px;
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

td code {
  overflow-wrap: anywhere;
  font-size: 12px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 23px;
  border-radius: 999px;
  padding: 0 8px;
  font-size: 12px;
  font-weight: 800;
}

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

.pill.warn {
  background: #fff4e1;
  color: var(--amber);
}

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

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  background: rgba(12, 18, 24, 0.62);
  padding: 18px;
}

.modal-card {
  width: min(640px, 100%);
  border: 1px solid #2f3d49;
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.28);
  padding: 16px;
}

.secret-box {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #111920;
  padding: 13px;
  margin-bottom: 12px;
}

.secret-box code {
  display: block;
  min-width: 520px;
  color: #dbe7ee;
  white-space: nowrap;
}

.is-hidden {
  display: none !important;
}

@media (max-width: 1120px) {
  .portal-shell {
    grid-template-columns: 230px minmax(0, 1fr);
  }

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

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

@media (max-width: 860px) {
  .auth-shell,
  .portal-shell {
    display: block;
  }

  .auth-brand-panel,
  .portal-sidebar {
    position: static;
    height: auto;
    min-height: auto;
  }

  .auth-form-panel {
    padding: 24px;
  }

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

  .topbar,
  .panel-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .inline-form,
  .grid-two,
  .metric-grid,
  .package-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .auth-brand-panel,
  .auth-form-panel,
  .portal-sidebar,
  .portal-main {
    padding-left: 12px;
    padding-right: 12px;
  }

  .auth-facts,
  .side-nav {
    grid-template-columns: 1fr;
  }

  .row-actions,
  .topbar-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .row-actions button,
  .topbar-actions .button-link,
  .topbar-actions button {
    width: 100%;
    justify-content: center;
  }
}
