:root {
  --bg: #f7f8fa;
  --panel: #ffffff;
  --ink: #1f2933;
  --muted: #667085;
  --line: #dde3ea;
  --green: #138a5b;
  --red: #c23b3b;
  --blue: #2563eb;
  --amber: #a4650b;
  --terminal: #101820;
  --terminal-soft: #d8e2ea;
  --shadow: 0 10px 24px rgba(23, 32, 42, .045);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

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

button {
  font: inherit;
}

.auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--bg);
}

.login-panel {
  width: min(420px, 100%);
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.login-brand {
  margin-bottom: 22px;
}

.login-panel h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 650;
}

.login-panel p {
  margin: 8px 0 18px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.login-panel .primary {
  width: 100%;
}

.auth-error {
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid #f0c1c1;
  border-radius: 8px;
  background: #fff0f0;
  color: #9b2525;
  font-size: 13px;
}

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

.sidebar,
.panel,
.env-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.env-card {
  box-shadow: 0 6px 16px rgba(23, 32, 42, .025);
}

.sidebar {
  min-height: calc(100vh - 48px);
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 16px;
  font-weight: 650;
}

.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: #15202b;
  color: #fff;
  font-weight: 700;
}

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

.nav button {
  min-height: 40px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  text-align: left;
  font-weight: 600;
}

.nav button.active {
  background: #eef3f8;
  color: var(--ink);
}

.sidebar-status {
  margin-top: auto;
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.sidebar-status strong {
  color: var(--ink);
}

.main {
  display: grid;
  gap: 16px;
  min-width: 0;
}

[hidden] {
  display: none !important;
}

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

.topbar h1,
.mobile-topbar h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.2;
  font-weight: 650;
}

.topbar p,
.panel-header p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.35;
}

.environment-tabs {
  width: max-content;
  max-width: 100%;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px;
  margin-top: 14px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #edf2f7;
}

.environment-tabs button {
  min-width: 128px;
  min-height: 34px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  cursor: pointer;
}

.environment-tabs button.active {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(23, 32, 42, .12);
}

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

.header-actions {
  display: none;
}

.pipeline-steps {
  display: grid;
  gap: 10px;
  padding: 14px 15px;
}

.pipeline-step {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.pipeline-step.done {
  background: #fbfefd;
  border-color: #cfe8dc;
}

.pipeline-step.current {
  background: #fbfdff;
  border-color: #c9d9f5;
}

.pipeline-step.locked {
  opacity: .66;
}

.pipeline-number {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: #eef3f8;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.pipeline-step.done .pipeline-number {
  background: #e6f5ef;
  color: var(--green);
}

.pipeline-step.current .pipeline-number {
  background: #edf4ff;
  color: var(--blue);
}

.pipeline-copy {
  min-width: 0;
}

.pipeline-copy strong {
  display: block;
  font-size: 13px;
  font-weight: 650;
}

.pipeline-copy span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.35;
}

.primary,
.secondary,
.danger {
  min-height: 38px;
  padding: 0 13px;
  border-radius: 8px;
  font-weight: 650;
  border: 1px solid transparent;
  cursor: pointer;
}

.primary {
  background: var(--blue);
  color: #fff;
}

.secondary {
  background: #f4f7fa;
  color: var(--ink);
  border-color: var(--line);
}

.danger {
  background: #fff0f0;
  color: #9b2525;
  border-color: #f0c1c1;
}

.primary:disabled,
.secondary:disabled,
.danger:disabled {
  cursor: not-allowed;
  opacity: .58;
}

.small {
  min-height: 32px;
  padding: 0 11px;
  font-size: 12px;
}

.mobile-topbar {
  display: none;
}

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

.env-card {
  min-width: 0;
  padding: 15px;
}

.env-card-header,
.panel-header,
.history-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.env-card h2,
.panel h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 650;
  line-height: 1.25;
}

.metric {
  margin-top: 14px;
  font-size: 22px;
  line-height: 1;
  font-weight: 650;
  overflow-wrap: anywhere;
}

.meta {
  margin-top: 7px;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.pill::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: currentColor;
}

.pill.success {
  background: #e6f5ef;
  color: var(--green);
}

.pill.running {
  background: #edf4ff;
  color: var(--blue);
}

.pill.warning {
  background: #fff4dd;
  color: var(--amber);
}

.pill.failed {
  background: #ffe9e9;
  color: var(--red);
}

.pill.neutral {
  background: #edf2f7;
  color: var(--muted);
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(360px, .9fr);
  gap: 18px;
  align-items: start;
}

.single-view {
  min-width: 0;
}

.panel {
  min-width: 0;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.panel-header {
  padding: 14px 15px;
  border-bottom: 1px solid var(--line);
}

.filters {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.filters button {
  min-height: 31px;
  padding: 0 10px;
  border: 1px solid var(--line);
  background: #f7f9fb;
  color: var(--muted);
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.filters button.active {
  background: #15202b;
  color: #fff;
  border-color: #15202b;
}

.terminal {
  min-height: 380px;
  max-height: 58vh;
  margin: 0;
  padding: 15px;
  overflow: auto;
  background: var(--terminal);
  color: var(--terminal-soft);
  font-family: Consolas, "Courier New", monospace;
  font-size: 12.5px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.small-terminal {
  min-height: 320px;
  max-height: 460px;
}

.log-ok {
  color: #67e8a5;
}

.log-warn {
  color: #ffd166;
}

.log-error {
  color: #ff8b8b;
}

.log-command {
  color: #93c5fd;
}

.log-line {
  display: block;
  padding: 1px 0;
}

.log-time {
  color: #9ca8b4;
}

.log-badge {
  display: inline-block;
  min-width: 52px;
  margin: 0 8px;
  font-size: 11px;
  font-weight: 650;
}

.log-badge.output {
  color: #67e8a5;
}

.log-badge.error {
  color: #ff8b8b;
}

.log-badge.system {
  color: #93c5fd;
}

.console-actions {
  padding: 9px 12px;
  border-top: 1px solid var(--line);
  background: #fbfcfd;
}

.right-stack {
  display: grid;
  gap: 18px;
}

.compare-body,
.release-flow,
.history-list {
  padding: 15px 16px;
}

.compare-body {
  display: grid;
  gap: 12px;
}

.app-log-board {
  padding: 14px 16px 0;
  display: grid;
  gap: 14px;
}

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

.log-analysis {
  display: grid;
  gap: 12px;
}

.log-paths {
  display: grid;
  gap: 8px;
}

.log-path,
.error-card {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.log-path {
  align-items: center;
}

.log-path span:first-child {
  min-width: 86px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.log-path code,
.error-card code {
  color: #405266;
  font-size: 12px;
  overflow-wrap: anywhere;
}

.error-card {
  background: #fff7f7;
  border-color: #f3c5c5;
}

.error-card strong {
  display: block;
  font-size: 13px;
  font-weight: 650;
}

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

.error-card p {
  margin: 8px 0;
  color: #9b2525;
  font-size: 12.5px;
}

.app-log-timeline {
  display: grid;
  gap: 8px;
  max-height: 520px;
  overflow: auto;
  padding-right: 4px;
}

.app-log-tabs {
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  width: max-content;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #edf2f7;
}

.app-log-tabs button {
  min-width: 120px;
  min-height: 34px;
  padding: 0 12px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  cursor: pointer;
}

.app-log-tabs button.active {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(23, 32, 42, .12);
}

.log-window-note {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.app-log-time-filter {
  display: flex;
  align-items: end;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.field.compact {
  min-width: 220px;
  margin: 0;
}

.field.compact label {
  font-size: 11.5px;
}

.field.compact input {
  min-height: 34px;
  padding: 7px 9px;
  font-size: 12.5px;
}

.app-log-event {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.app-log-event.is-error {
  border-color: #f0c1c1;
}

.app-log-event summary {
  display: grid;
  grid-template-columns: 132px 64px minmax(0, 1fr) 130px;
  gap: 8px;
  align-items: center;
  padding: 10px 12px;
  cursor: pointer;
  font-size: 12.5px;
}

.app-log-event summary strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}

.app-log-event summary em {
  color: var(--muted);
  font-style: normal;
  text-align: right;
}

.app-log-event pre {
  margin: 0;
  padding: 12px;
  border-top: 1px solid var(--line);
  background: #101820;
  color: var(--terminal-soft);
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.compare-body.compact,
.release-flow.compact {
  padding: 0;
}

.two-column-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, .75fr);
  gap: 18px;
  padding: 16px;
}

.two-column-body h3,
.settings-card h3 {
  margin: 0 0 12px;
  font-size: 14px;
  font-weight: 650;
}

.section-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.section-title-row h3 {
  margin: 0;
}

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

.settings-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfcfd;
}

.settings-card p {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.settings-table {
  display: grid;
  gap: 8px;
}

.settings-row {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 10px;
  font-size: 12.5px;
}

.settings-row span:first-child {
  color: var(--muted);
}

.settings-row code {
  overflow-wrap: anywhere;
}

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

.form-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfcfd;
}

.form-card h3 {
  margin: 0 0 12px;
  font-size: 14px;
  font-weight: 650;
}

.field {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
}

.field:last-child {
  margin-bottom: 0;
}

.field label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.field input {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
}

.field small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

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

.summary-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fbfcfd;
}

.summary-item strong {
  display: block;
  font-size: 16px;
  font-weight: 650;
}

.summary-item span {
  color: var(--muted);
  font-size: 12px;
}

.commit,
.file-row,
.history-row {
  padding-bottom: 11px;
  border-bottom: 1px solid var(--line);
}

.commit:last-child,
.file-row:last-child,
.history-row:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.commit strong {
  display: block;
  font-size: 12.5px;
  font-weight: 650;
  line-height: 1.35;
}

.commit span,
.history-row span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.file-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding-top: 2px;
  font-size: 13px;
}

.file-row code {
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.diff {
  color: var(--green);
  font-weight: 650;
  white-space: nowrap;
}

.empty-state {
  padding: 12px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.release-flow {
  display: grid;
  gap: 10px;
}

.step {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}

.step-number {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: #e8eef5;
  font-weight: 650;
}

.step.done .step-number {
  background: #e6f5ef;
  color: var(--green);
}

.step.current .step-number {
  background: #edf4ff;
  color: var(--blue);
}

.history-list {
  display: grid;
  gap: 11px;
}

.history-row {
  width: 100%;
  border-left: 0;
  border-right: 0;
  border-top: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
  padding-left: 0;
  padding-right: 0;
}

.history-main strong {
  display: block;
  font-size: 12.5px;
  font-weight: 650;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 10;
  max-width: min(420px, calc(100vw - 28px));
  padding: 13px 14px;
  border-radius: 8px;
  background: #15202b;
  color: #fff;
  box-shadow: 0 14px 32px rgba(23, 32, 42, .14);
  font-size: 13px;
}

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

  .sidebar,
  .topbar {
    display: none;
  }

  .main {
    gap: 12px;
  }

  .mobile-topbar {
    display: block;
    position: sticky;
    top: 0;
    z-index: 5;
    padding: 14px 14px 12px;
    background: #fff;
    border-bottom: 1px solid var(--line);
  }

  .mobile-topbar h1 {
    margin-bottom: 11px;
    font-size: 18px;
    font-weight: 650;
  }

  .segmented {
    display: grid;
    grid-template-columns: 1fr 1fr;
    padding: 3px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #edf2f7;
  }

  .segmented button {
    min-height: 36px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--muted);
    font-weight: 600;
  }

  .segmented button.active {
    background: #fff;
    color: var(--ink);
    box-shadow: 0 1px 2px rgba(23, 32, 42, .12);
  }

  .cards-grid,
  .content-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .cards-grid,
  .content-grid,
  .single-view {
    padding: 0 12px;
  }

  .cards-grid {
    padding-top: 12px;
  }

  .metric {
    font-size: 20px;
  }

  .panel-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .filters {
    justify-content: flex-start;
  }

  .terminal {
    min-height: 338px;
    max-height: 45vh;
    font-size: 12px;
  }

  .console-actions {
    justify-content: flex-start;
  }

  .step {
    grid-template-columns: 28px 1fr;
  }

  .step .pill {
    grid-column: 2;
    width: max-content;
  }

  .pipeline-step {
    grid-template-columns: 28px minmax(0, 1fr);
  }

  .pipeline-step .primary,
  .pipeline-step .secondary,
  .pipeline-step .danger {
    grid-column: 2;
    width: 100%;
  }

  .two-column-body,
  .settings-grid,
  .settings-form {
    grid-template-columns: 1fr;
  }

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

  .log-path,
  .error-card {
    display: grid;
  }

  .app-log-event summary {
    grid-template-columns: 1fr;
  }

  .app-log-event summary em {
    text-align: left;
  }

  .app-log-time-filter {
    display: grid;
    grid-template-columns: 1fr;
  }

  .field.compact {
    min-width: 0;
  }

  .settings-row {
    grid-template-columns: 1fr;
  }
}

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

  .log-summary-grid {
    grid-template-columns: 1fr;
  }

  .top-actions,
  .console-actions {
    justify-content: stretch;
  }

  .primary,
  .secondary,
  .danger {
    flex: 1;
  }
}
