:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-muted: #f8fafb;
  --text: #17202a;
  --muted: #63707d;
  --border: #d9e0e6;
  --border-strong: #bdc8d1;
  --primary: #176b50;
  --primary-hover: #12563f;
  --primary-soft: #e8f4ef;
  --danger: #b33a3a;
  --danger-soft: #fbecec;
  --warning: #a56513;
  --warning-soft: #fff3df;
  --info: #29678e;
  --info-soft: #eaf3f9;
  --shadow: 0 12px 34px rgba(25, 36, 47, 0.14);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.45;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); }
button, input, textarea { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.55; }
svg { width: 18px; height: 18px; stroke-width: 1.9; flex: 0 0 auto; }

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: 58px;
  padding: 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(14px);
}

.brand-lockup { display: flex; align-items: center; gap: 13px; }
.brand-lockup img { display: block; border-radius: 7px; }
.brand-lockup h1, .brand-lockup p, .brand-lockup strong, .brand-lockup span { margin: 0; letter-spacing: 0; }
.brand-lockup h1 { font-size: 1.35rem; line-height: 1.2; }
.brand-lockup p { margin-top: 3px; color: var(--muted); }
.brand-lockup.compact strong { display: block; font-size: 0.98rem; }
.brand-lockup.compact span { display: block; color: var(--muted); font-size: 0.76rem; }
.header-actions { display: flex; align-items: center; gap: 8px; }

.app-main { width: min(1440px, 100%); margin: 0 auto; padding: 28px; }
.summary-band {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 28px;
  padding: 6px 0 24px;
}
.summary-band h1 { margin: 0 0 5px; font-size: 1.65rem; line-height: 1.2; letter-spacing: 0; }
.summary-band p { margin: 0; color: var(--muted); }
.summary-metrics { display: grid; grid-template-columns: repeat(4, minmax(78px, 1fr)); border: 1px solid var(--border); background: var(--surface); }
.summary-metrics > div { min-width: 92px; padding: 11px 15px; border-right: 1px solid var(--border); }
.summary-metrics > div:last-child { border-right: 0; }
.summary-metrics span { display: block; color: var(--muted); font-size: 0.74rem; }
.summary-metrics strong { display: block; margin-top: 2px; font-size: 1.18rem; font-variant-numeric: tabular-nums; }

.toolbar-band { min-height: 48px; display: flex; align-items: center; justify-content: space-between; border-top: 1px solid var(--border); }
.segmented { display: inline-flex; height: 32px; padding: 2px; background: #e7ebee; border-radius: 6px; }
.segmented button { min-width: 74px; border: 0; border-radius: 4px; background: transparent; color: var(--muted); font-size: 0.82rem; }
.segmented button.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(20, 30, 40, 0.12); }

.button, .icon-button, .text-button, .field-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid transparent;
  border-radius: 6px;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
}
.button { min-height: 36px; padding: 7px 13px; font-weight: 650; font-size: 0.86rem; }
.button.primary { color: #fff; background: var(--primary); border-color: var(--primary); }
.button.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.button.secondary { background: var(--surface); border-color: var(--border-strong); color: var(--text); }
.button.secondary:hover { background: var(--surface-muted); }
.button.danger { background: var(--surface); border-color: #d7aaaa; color: var(--danger); }
.button.danger:hover { background: var(--danger-soft); }
.button.full { width: 100%; }
.icon-button { width: 36px; height: 36px; padding: 0; background: transparent; border-color: var(--border); color: var(--muted); }
.icon-button:hover { background: var(--surface-muted); color: var(--text); border-color: var(--border-strong); }
.icon-button.small { width: 30px; height: 30px; }
.text-button { min-height: 30px; padding: 3px 0; color: var(--primary); background: transparent; border: 0; font-size: 0.82rem; font-weight: 600; }
.text-button:hover { color: var(--primary-hover); }
.field-icon { width: 34px; height: 34px; border: 0; background: transparent; color: var(--muted); }
.field-icon:hover { color: var(--text); background: #edf1f3; }

.task-table-wrap { min-height: 360px; background: var(--surface); border: 1px solid var(--border); overflow: hidden; }
.task-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.task-table th { height: 42px; padding: 0 14px; color: var(--muted); background: var(--surface-muted); border-bottom: 1px solid var(--border); text-align: left; font-size: 0.76rem; font-weight: 650; }
.task-table td { height: 64px; padding: 10px 14px; border-bottom: 1px solid #e8ecef; vertical-align: middle; }
.task-table tr:last-child td { border-bottom: 0; }
.task-table tbody tr:hover { background: #fbfcfd; }
.task-table th:nth-child(1) { width: 160px; }
.task-table th:nth-child(2) { width: 105px; }
.task-table th:nth-child(3) { width: 120px; }
.task-table th:nth-child(4) { width: 30%; }
.task-table th:nth-child(5) { width: 140px; }
.task-table th:nth-child(6) { width: 64px; }
.action-column { text-align: right !important; }
.table-actions { display: flex; justify-content: flex-end; }
.date-primary { display: block; font-variant-numeric: tabular-nums; font-size: 0.84rem; }
.date-secondary { display: block; color: var(--muted); font-size: 0.72rem; }
.result-counts { display: flex; gap: 9px; font-size: 0.8rem; }
.result-counts .ok { color: var(--primary); }
.result-counts .fail { color: var(--danger); }
.progress-cell { min-width: 0; }
.progress-line { display: flex; align-items: center; gap: 10px; }
.progress-track { position: relative; height: 7px; flex: 1; min-width: 80px; background: #e7ecef; overflow: hidden; border-radius: 3px; }
.progress-fill { height: 100%; width: 0; background: var(--primary); transition: width 220ms ease; }
.progress-value { width: 40px; color: var(--muted); text-align: right; font-size: 0.75rem; font-variant-numeric: tabular-nums; }
.progress-copy { display: block; margin-top: 4px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 0.73rem; }

.status-badge { display: inline-flex; align-items: center; gap: 6px; min-height: 25px; padding: 3px 8px; border-radius: 5px; font-size: 0.76rem; font-weight: 650; white-space: nowrap; }
.status-badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status-running, .status-queued { color: var(--info); background: var(--info-soft); }
.status-success { color: var(--primary); background: var(--primary-soft); }
.status-finished, .status-failed, .status-interrupted { color: var(--danger); background: var(--danger-soft); }
.status-cancelled { color: var(--warning); background: var(--warning-soft); }
.status-running::before { animation: pulse 1.2s ease infinite; }
@keyframes pulse { 50% { opacity: 0.35; } }

.empty-state { min-height: 340px; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--muted); text-align: center; }
.empty-state svg { width: 38px; height: 38px; margin-bottom: 12px; }
.empty-state strong { color: var(--text); }
.empty-state span { margin-top: 4px; font-size: 0.82rem; }

.dialog { width: min(760px, calc(100vw - 36px)); max-height: calc(100vh - 36px); padding: 0; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--surface); color: var(--text); box-shadow: var(--shadow); overflow: hidden; }
.dialog.wide { width: min(940px, calc(100vw - 36px)); }
.dialog.log-dialog { width: min(900px, calc(100vw - 36px)); }
.dialog::backdrop { background: rgba(20, 29, 37, 0.46); backdrop-filter: blur(2px); }
.dialog-header { min-height: 66px; padding: 14px 18px; display: flex; align-items: center; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--border); }
.dialog-header h2, .dialog-header p { margin: 0; }
.dialog-header h2 { font-size: 1.05rem; }
.dialog-header p { margin-top: 3px; color: var(--muted); font-size: 0.78rem; }
.dialog-body { padding: 18px; overflow: auto; max-height: calc(100vh - 170px); }
.dialog-footer { min-height: 60px; padding: 11px 18px; display: flex; align-items: center; justify-content: space-between; gap: 18px; background: var(--surface-muted); border-top: 1px solid var(--border); }
.dialog-footer > span { color: var(--muted); font-size: 0.77rem; }
.dialog-footer > div { display: flex; gap: 8px; }

.deploy-layout { display: flex; flex-direction: column; gap: 18px; }
.form-section { padding-bottom: 17px; border-bottom: 1px solid var(--border); }
.form-section:last-of-type { padding-bottom: 0; border-bottom: 0; }
.form-section h3 { margin: 0 0 11px; font-size: 0.88rem; }
.form-section.grow { min-height: 250px; }
.section-heading { display: flex; justify-content: space-between; align-items: center; }
.section-heading span { color: var(--muted); font-size: 0.78rem; }
.field-grid { display: grid; gap: 12px; }
.field-grid.three { grid-template-columns: 110px minmax(150px, 1fr) minmax(220px, 1.4fr); }
.field-grid.two { grid-template-columns: minmax(160px, 0.7fr) minmax(240px, 1.3fr); }
label > span:first-child, .textarea-label > span:first-child { display: block; margin-bottom: 6px; color: var(--muted); font-size: 0.76rem; font-weight: 600; }
input, textarea { width: 100%; border: 1px solid var(--border-strong); border-radius: 5px; outline: none; background: var(--surface); color: var(--text); }
input { height: 36px; padding: 7px 9px; }
textarea { min-height: 190px; padding: 10px; resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.78rem; line-height: 1.55; tab-size: 4; }
input:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(23, 107, 80, 0.13); }
.password-field { position: relative; display: block; }
.password-field input { padding-right: 40px; }
.password-field .field-icon { position: absolute; right: 1px; top: 1px; }
.format-row { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 8px; }
.format-row code { padding: 3px 6px; border: 1px solid var(--border); border-radius: 4px; background: var(--surface-muted); color: var(--muted); font-size: 0.71rem; overflow-wrap: anywhere; }
.alert { padding: 9px 11px; border: 1px solid; border-radius: 5px; font-size: 0.82rem; }
.alert.error { color: #8e2929; background: var(--danger-soft); border-color: #efcaca; }

.detail-body { padding: 0; }
.credential-strip { min-height: 52px; padding: 9px 18px; display: flex; align-items: center; flex-wrap: wrap; gap: 9px; background: #f4f8f6; border-bottom: 1px solid var(--border); }
.credential-strip > span { color: var(--muted); font-size: 0.76rem; }
.credential-strip code { padding: 4px 7px; background: var(--surface); border: 1px solid var(--border); border-radius: 4px; font-size: 0.78rem; overflow-wrap: anywhere; }
.credential-copy { min-height: 30px; padding: 4px 9px; font-size: 0.78rem; }
.target-list { min-height: 230px; }
.target-row { padding: 15px 18px; border-bottom: 1px solid var(--border); }
.target-row:last-child { border-bottom: 0; }
.target-top { display: grid; grid-template-columns: minmax(160px, 1.1fr) minmax(130px, 0.8fr) 115px 138px; align-items: center; gap: 14px; }
.target-identity { min-width: 0; }
.target-identity strong, .target-identity span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.target-identity strong { font-size: 0.88rem; }
.target-identity span { margin-top: 2px; color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.72rem; }
.target-stage { min-width: 0; }
.target-stage strong, .target-stage span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.target-stage strong { font-size: 0.8rem; }
.target-stage span { color: var(--muted); font-size: 0.72rem; }
.target-actions { display: flex; justify-content: flex-end; gap: 6px; }
.target-progress { margin-top: 10px; }
.target-progress .progress-track { height: 5px; }
.log-content { margin: 0; min-height: 360px; max-height: calc(100vh - 160px); padding: 16px; overflow: auto; background: #17202a; color: #dbe5ec; white-space: pre-wrap; overflow-wrap: anywhere; font: 0.76rem/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

.toast-region { position: fixed; z-index: 100; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast { width: min(340px, calc(100vw - 36px)); padding: 10px 12px; border: 1px solid var(--border-strong); border-left: 4px solid var(--info); border-radius: 5px; background: var(--surface); box-shadow: var(--shadow); font-size: 0.82rem; animation: toast-in 160ms ease; }
.toast.error { border-left-color: var(--danger); }
.toast.success { border-left-color: var(--primary); }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } }

.login-page { background: #eef2f4; }
.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 22px; }
.login-panel { width: min(400px, 100%); padding: 28px; background: var(--surface); border: 1px solid var(--border-strong); box-shadow: 0 16px 42px rgba(27, 38, 49, 0.11); }
.login-panel .brand-lockup { padding-bottom: 21px; margin-bottom: 20px; border-bottom: 1px solid var(--border); }
.login-form { display: flex; flex-direction: column; gap: 14px; }
.login-form .button { margin-top: 5px; }

@media (max-width: 850px) {
  .app-header { padding: 0 16px; }
  .app-main { padding: 18px 14px 28px; }
  .summary-band { align-items: stretch; flex-direction: column; gap: 17px; }
  .summary-metrics { width: 100%; grid-template-columns: repeat(4, 1fr); }
  .summary-metrics > div { min-width: 0; padding: 9px; }
  .task-table, .task-table tbody, .task-table tr, .task-table td { display: block; }
  .task-table thead { display: none; }
  .task-table tbody tr { position: relative; padding: 13px 48px 13px 13px; border-bottom: 1px solid var(--border); }
  .task-table td { height: auto; padding: 3px 0; border: 0; }
  .task-table td:nth-child(1), .task-table td:nth-child(2), .task-table td:nth-child(3), .task-table td:nth-child(5) { display: inline-block; margin-right: 9px; }
  .task-table td:nth-child(4) { margin-top: 8px; }
  .task-table td:nth-child(6) { position: absolute; top: 13px; right: 10px; }
  .date-secondary { display: none; }
  .target-top { grid-template-columns: 1fr auto; }
  .target-stage { grid-column: 1 / -1; grid-row: 2; }
  .target-actions { grid-column: 2; grid-row: 1; }
  .target-top > .status-badge { grid-column: 2; grid-row: 2; }
  .field-grid.three, .field-grid.two { grid-template-columns: 1fr; }
}

@media (max-width: 520px) {
  .brand-lockup.compact span { display: none; }
  .app-header .button { width: 36px; padding: 0; }
  .app-header .button svg { margin: 0; }
  .app-header .button { font-size: 0; gap: 0; }
  .summary-band h1 { font-size: 1.35rem; }
  .summary-band p { font-size: 0.82rem; }
  .summary-metrics { grid-template-columns: repeat(2, 1fr); }
  .summary-metrics > div:nth-child(2) { border-right: 0; }
  .summary-metrics > div:nth-child(-n+2) { border-bottom: 1px solid var(--border); }
  .segmented { width: calc(100% - 48px); }
  .segmented button { flex: 1; min-width: 0; }
  .dialog, .dialog.wide, .dialog.log-dialog { width: 100vw; max-width: none; height: 100dvh; max-height: none; border: 0; border-radius: 0; }
  .dialog-body { max-height: calc(100dvh - 128px); }
  .dialog-footer { min-height: 62px; }
  .dialog-footer > span { display: none; }
  .dialog-footer > div { width: 100%; }
  .dialog-footer .button { flex: 1; }
  .credential-strip { align-items: flex-start; }
  .credential-strip code { width: calc(100% - 44px); }
  .target-row { padding: 14px; }
  .target-top { grid-template-columns: minmax(0, 1fr) auto; gap: 9px; }
  .format-row { display: none; }
  .login-panel { padding: 22px; }
}
