:root {
  --bg: #f5f7f8;
  --panel: #ffffff;
  --panel-soft: #f9fbfb;
  --text: #17211f;
  --muted: #64716d;
  --line: #dce4e1;
  --accent: #0f766e;
  --accent-dark: #0b5f59;
  --blue: #2563eb;
  --green: #15803d;
  --amber: #b45309;
  --red: #b42318;
  --code-bg: #111817;
  --code-text: #d9eee8;
  --shadow: 0 12px 30px rgba(15, 35, 31, 0.08);
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

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

.brand-row,
.topbar,
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  color: white;
  background: var(--accent);
  border-radius: 8px;
  font-weight: 800;
}

.login-panel h1 {
  margin: 18px 0 8px;
  font-size: 28px;
  line-height: 1.15;
  letter-spacing: 0;
}

.login-panel p {
  margin: 0 0 24px;
  color: var(--muted);
  line-height: 1.6;
}

.field {
  display: grid;
  gap: 7px;
  margin-bottom: 14px;
}

.field label,
.advanced-toggle,
.table-label {
  font-size: 13px;
  font-weight: 650;
  color: #34433f;
}

.field input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 12px;
  color: var(--text);
  background: #fff;
  outline: none;
}

.field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
}

.primary-btn,
.ghost-btn,
.icon-btn,
.danger-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  border-radius: 7px;
  font-size: 14px;
  font-weight: 700;
  transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.primary-btn {
  width: 100%;
  color: white;
  background: var(--accent);
  padding: 0 16px;
}

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

.ghost-btn,
.icon-btn {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--line);
  padding: 0 12px;
}

.danger-btn {
  color: #fff;
  background: var(--red);
  padding: 0 14px;
}

.danger-btn:hover {
  background: #8f1c14;
}

button:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.28);
  outline-offset: 2px;
}

.ghost-btn:hover,
.icon-btn:hover {
  border-color: #b8c7c3;
  background: #f7faf9;
}

.error-text {
  min-height: 20px;
  color: var(--red);
  font-size: 13px;
  line-height: 1.5;
}

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

.sidebar {
  background: #111817;
  color: white;
  padding: 22px 18px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.sidebar .brand-mark {
  background: #19a196;
}

.sidebar-brand strong {
  font-size: 17px;
}

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

.nav-item {
  width: 100%;
  min-height: 38px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 11px;
  border-radius: 7px;
  color: #b7c8c3;
  font-size: 14px;
  font-weight: 650;
  text-align: left;
  background: transparent;
}

.nav-item:hover,
.nav-item.active {
  color: white;
  background: rgba(255, 255, 255, 0.1);
}

.sidebar-note {
  margin-top: auto;
  color: #8ca09a;
  font-size: 12px;
  line-height: 1.5;
}

.main {
  min-width: 0;
  display: grid;
  grid-template-rows: 64px 1fr;
}

.topbar {
  justify-content: space-between;
  padding: 0 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.84);
  backdrop-filter: blur(10px);
}

.topbar h1 {
  margin: 0;
  font-size: 19px;
  letter-spacing: 0;
}

.user-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.content {
  padding: 24px 28px 32px;
  display: grid;
  gap: 18px;
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(360px, 1.35fr) minmax(300px, 0.9fr);
  gap: 18px;
  align-items: start;
}

#deploySection,
#historySection,
#logsSection {
  scroll-margin-top: 82px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 22px rgba(18, 40, 35, 0.05);
}

.panel-header {
  padding: 18px 18px 12px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.panel-header > div {
  min-width: 0;
}

.panel-title {
  margin: 0;
  font-size: 18px;
  line-height: 1.3;
}

.panel-desc {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.upload-form {
  padding: 0 18px 18px;
}

.drop-zone {
  min-height: 128px;
  border: 1.5px dashed #adc0bb;
  border-radius: 8px;
  background: var(--panel-soft);
  display: grid;
  place-items: center;
  text-align: center;
  padding: 18px;
  margin-bottom: 16px;
}

.drop-zone.dragging {
  border-color: var(--accent);
  background: rgba(15, 118, 110, 0.07);
}

.drop-zone input {
  display: none;
}

.drop-icon {
  width: 40px;
  height: 40px;
  margin: 0 auto 9px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #e6f4f2;
  color: var(--accent);
}

.file-name {
  margin-top: 7px;
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.advanced {
  margin: 2px 0 16px;
}

.advanced-toggle {
  width: 100%;
  background: transparent;
  padding: 8px 0;
  color: var(--accent-dark);
  text-align: left;
}

.status-panel {
  padding-bottom: 16px;
}

.status-body {
  padding: 0 18px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  gap: 7px;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.status-pill.ready,
.dot.ready {
  color: var(--green);
  background: #eaf8ef;
}

.status-pill.running,
.status-pill.queued,
.dot.running,
.dot.queued {
  color: var(--blue);
  background: #eef4ff;
}

.status-pill.failed,
.dot.failed {
  color: var(--red);
  background: #fff0ee;
}

.status-pill.empty {
  color: var(--muted);
  background: #eef2f1;
}

.timeline {
  display: grid;
  gap: 9px;
  margin: 16px 0;
}

.step {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  font-size: 13px;
}

.step-marker {
  width: 17px;
  height: 17px;
  border-radius: 50%;
  border: 2px solid #c8d4d1;
  background: #fff;
}

.step.done .step-marker {
  border-color: var(--green);
  background: var(--green);
}

.step.active .step-marker {
  border-color: var(--blue);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

.result-box {
  display: grid;
  gap: 10px;
  padding: 12px;
  background: #f3faf7;
  border: 1px solid #cbe9d6;
  border-radius: 8px;
}

.link-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.link-row input {
  flex: 1;
  min-width: 0;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 10px;
  color: var(--accent-dark);
  background: white;
}

.history-panel,
.logs-panel {
  overflow: hidden;
}

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

.history-table th,
.history-table td {
  padding: 12px 14px;
  border-top: 1px solid var(--line);
  text-align: left;
  font-size: 13px;
  vertical-align: middle;
}

.history-table th {
  color: var(--muted);
  font-weight: 750;
  background: #fbfcfc;
}

.history-table .col-project {
  width: 30%;
}

.history-table .col-status,
.history-table .col-actions {
  width: 16%;
}

.history-table .col-created {
  width: 20%;
}

.history-table .col-link {
  width: 18%;
}

.history-table .col-actions {
  text-align: right;
}

.history-table td {
  color: #293632;
}

.history-table tr.selected {
  background: #f1f8f6;
}

.status-cell {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 750;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
}

.row-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.icon-btn {
  min-width: 36px;
  width: 36px;
  padding: 0;
}

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

.danger-icon:hover {
  color: #8f1c14;
  border-color: #e5b4af;
  background: #fff7f6;
}

.logs {
  margin: 0;
  min-height: 260px;
  max-height: 420px;
  overflow: auto;
  padding: 16px;
  background: var(--code-bg);
  color: var(--code-text);
  font-family: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 12px;
  line-height: 1.6;
  white-space: pre-wrap;
}

.empty-state {
  padding: 24px 18px;
  color: var(--muted);
  font-size: 14px;
}

.dialog-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(10, 18, 16, 0.52);
}

.dialog {
  width: min(440px, 100%);
  display: grid;
  gap: 18px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 24px 70px rgba(7, 20, 17, 0.26);
}

.dialog h2 {
  margin: 0;
  font-size: 20px;
}

.dialog p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 60;
  max-width: min(360px, calc(100vw - 32px));
  padding: 11px 14px;
  border: 1px solid #b8dfc6;
  border-radius: 7px;
  color: #135c2d;
  background: #effaf3;
  box-shadow: var(--shadow);
  font-size: 13px;
  font-weight: 700;
}

.toast.error {
  color: var(--red);
  border-color: #efc5c1;
  background: #fff4f3;
}

.muted {
  color: var(--muted);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

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

  .sidebar {
    display: none;
  }

  .workspace-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .content,
  .topbar {
    padding-left: 16px;
    padding-right: 16px;
  }

  .topbar {
    gap: 12px;
  }

  .topbar h1 {
    font-size: 17px;
  }
}

@media (max-width: 680px) {
  .history-table thead {
    display: none;
  }

  .history-table,
  .history-table tbody,
  .history-table tr,
  .history-table td {
    display: block;
    width: 100%;
  }

  .history-table td {
    border-top: 0;
    padding: 8px 14px;
  }

  .history-table tr {
    border-top: 1px solid var(--line);
    padding: 8px 0;
  }

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

  .dialog-actions {
    flex-direction: column-reverse;
  }

  .dialog-actions .ghost-btn,
  .dialog-actions .danger-btn {
    width: 100%;
  }

  .toast {
    right: 16px;
    bottom: 16px;
  }
}
