:root {
  --bg: #0f1117;
  --surface: #181b24;
  --surface-2: #1f2330;
  --border: #2a2f3d;
  --text: #e6e8ee;
  --muted: #8b93a7;
  --primary: #4f7cff;
  --primary-d: #3b63d6;
  --danger: #e5484d;
  --ok: #30a46c;
  --warn: #f5a524;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 60px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  background: #6366f1;
  color: #fff;
  font-weight: 700;
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 14px;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-title { font-weight: 600; }
.brand-sub { font-size: 11px; color: var(--muted); font-weight: 400; }

.tabs { display: flex; gap: 4px; }
.tab {
  background: transparent;
  border: none;
  color: var(--muted);
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
}
.tab:hover { color: var(--text); background: var(--surface-2); }
.tab.active { color: var(--text); background: var(--surface-2); }
.tab-logout { margin-left: 12px; color: var(--danger); }

.container { max-width: 920px; margin: 0 auto; padding: 24px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; }

h2 { margin: 0 0 4px; font-size: 18px; }
h3 { margin: 0 0 10px; font-size: 16px; }

.muted { color: var(--muted); font-size: 13px; }
.req { color: var(--danger); }

.auth-card { max-width: 380px; margin: 60px auto; }
.auth-card input { width: 100%; margin: 12px 0; }

input, select {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 11px;
  border-radius: 8px;
  font-size: 14px;
  width: 100%;
}
input:focus, select:focus { outline: none; border-color: var(--primary); }

label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); }
.field-label { display: block; line-height: 1.3; color: var(--muted); }
label small { font-weight: 400; }
.field-hint {
  display: block;
  min-height: 2.6em;
  line-height: 1.3;
}
.field-hint:empty::before { content: '\00a0'; }
.field-spacer { visibility: hidden; pointer-events: none; }

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 16px;
}
.span-2 { grid-column: 1 / -1; }

.products {
  grid-column: 1 / -1;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  display: flex;
  gap: 24px;
  align-items: center;
}
.products legend { color: var(--muted); font-size: 13px; padding: 0 6px; }
.checkline { flex-direction: row; align-items: center; gap: 8px; color: var(--text); }
.checkline input { width: auto; }

.btn {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
}
.btn:hover { border-color: var(--primary); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-d); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-small { padding: 5px 10px; font-size: 12px; }

.error { color: var(--danger); font-size: 13px; margin-top: 8px; display: none; white-space: pre-wrap; }
.error.show { display: block; }

.result { margin-top: 14px; padding: 10px 12px; border-radius: 8px; display: none; font-size: 14px; }
.result.show { display: block; }
.result.success { background: rgba(48,163,108,.12); color: #5fd39a; }
.result.error { background: rgba(229,72,77,.12); color: #ff8085; }

.data-table { width: 100%; border-collapse: collapse; margin-top: 12px; font-size: 14px; }
.data-table th { text-align: left; color: var(--muted); font-weight: 500; padding: 8px 10px; border-bottom: 1px solid var(--border); font-size: 12px; }
.data-table td { padding: 10px; border-bottom: 1px solid var(--border); }
.data-table tbody tr:hover { background: var(--surface-2); cursor: default; }
code { background: var(--surface-2); padding: 1px 6px; border-radius: 5px; font-size: 13px; }

.pill { font-size: 11px; padding: 2px 8px; border-radius: 20px; }
.pill-on { background: rgba(48,163,108,.15); color: #5fd39a; }
.pill-off { background: rgba(139,147,167,.15); color: var(--muted); }

.status-pill { font-size: 11px; padding: 2px 9px; border-radius: 20px; background: var(--surface-2); color: var(--muted); }
.status-running { background: rgba(79,124,255,.15); color: #88a6ff; }
.status-done { background: rgba(48,163,108,.15); color: #5fd39a; }
.status-pending { background: rgba(245,165,36,.15); color: #f7c161; }
.status-failed, .status-rolled_back { background: rgba(229,72,77,.15); color: #ff8085; }

.steps { list-style: none; padding: 0; margin: 14px 0 0; }
.step {
  display: grid;
  grid-template-columns: 200px 90px 1fr;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  align-items: center;
  font-size: 13px;
  border-left: 3px solid var(--border);
  margin-bottom: 5px;
  background: var(--surface-2);
}
.step-name { font-family: ui-monospace, monospace; }
.step-detail { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; }
.step-done { border-left-color: var(--ok); }
.step-failed { border-left-color: var(--danger); }
.step-skipped { border-left-color: var(--muted); opacity: .7; }
.step-partial { border-left-color: var(--warn); }
.step-status { font-weight: 600; }

.modal[hidden] {
  display: none !important;
}
.modal:not([hidden]) {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.6);
  display: flex; align-items: center; justify-content: center;
  z-index: 50;
}
.modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  width: 460px;
  max-width: 92vw;
}
.baja-modes { display: flex; flex-direction: column; gap: 8px; margin: 16px 0; }
.radioline { flex-direction: row; align-items: center; gap: 8px; color: var(--text); }
.radioline input { width: auto; }
#baja-confirm-code { margin-top: 6px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

.site-footer {
  text-align: center;
  padding: 20px 24px 28px;
  font-size: 12px;
}

@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }
  .field-spacer { display: none; }
}
