:root {
  --bg: #ffffff;
  --bg-soft: #f6f7f9;
  --bg-card: #ffffff;
  --fg: #0a0a0a;
  --fg-muted: #5b6573;
  --border: #e5e7eb;
  --brand: #6366f1;
  --brand-soft: #eef2ff;
  --cta: #0a0a0a;
  --success: #16a34a;
  --warn: #f59e0b;
  --danger: #dc2626;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 12px 40px rgba(15, 23, 42, 0.08);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--fg);
  background: var(--bg-soft);
}

.public-body { background: var(--bg); }

.promo-bar {
  background: var(--brand);
  color: #fff;
  text-align: center;
  font-size: 0.8125rem;
  font-weight: 500;
  padding: 0.45rem 1rem;
}

.public-header {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.public-header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0.875rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.public-logo {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  color: var(--fg);
  text-decoration: none;
}

.public-nav { display: flex; align-items: center; gap: 1rem; }
.public-nav a { color: var(--fg-muted); text-decoration: none; font-weight: 500; font-size: 0.875rem; }
.public-nav a:hover { color: var(--brand); }

.public-main { max-width: 1100px; margin: 0 auto; padding: 2rem 1.5rem 4rem; }

.brand-icon-sm { width: 22px; height: 22px; border-radius: 5px; }
.brand-icon-sm svg { width: 12px; height: 12px; }

.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 220px;
  min-height: 100vh;
  background: var(--bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}

.sidebar-brand {
  padding: 1rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.625rem;
}

.brand-icon {
  width: 26px;
  height: 26px;
  background: linear-gradient(135deg, var(--brand), #818cf8);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.brand-icon svg { width: 14px; height: 14px; fill: #fff; }

.brand-text { flex: 1; min-width: 0; }
.brand-name { font-size: 0.8125rem; font-weight: 600; color: var(--fg); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-ver { font-size: 0.625rem; color: var(--fg-muted); display: block; }

.sidebar-nav { flex: 1; padding: 0.375rem 0; overflow-y: auto; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 1rem;
  color: var(--fg-muted);
  text-decoration: none;
  font-size: 0.8125rem;
  font-weight: 500;
  transition: background 0.12s, color 0.12s;
  border-right: 2px solid transparent;
}

.nav-item:hover { background: var(--bg-soft); color: var(--fg); }
.nav-item.active { background: var(--brand-soft); color: var(--brand); border-right-color: var(--brand); }

.nav-item svg { width: 15px; height: 15px; flex-shrink: 0; opacity: 0.75; }
.nav-item.active svg, .nav-item:hover svg { opacity: 1; }

.sidebar-footer { padding: 0.75rem 1rem; border-top: 1px solid var(--border); }

.main-content { margin-left: 220px; flex: 1; display: flex; flex-direction: column; min-height: 100vh; background: var(--bg-soft); }

.content-inner { width: 100%; max-width: 960px; padding: 1.75rem 2rem; }

h1 { font-size: 1.35rem; font-weight: 600; color: var(--fg); margin-bottom: 1.25rem; }
h2 { font-size: 0.9375rem; font-weight: 600; color: var(--fg); margin-bottom: 0.625rem; margin-top: 1.5rem; }
h3 { font-size: 0.875rem; font-weight: 600; color: var(--fg-muted); margin-bottom: 0.5rem; margin-top: 1.25rem; }

h1 small, h2 small, h3 small { font-size: 0.75em; color: var(--fg-muted); font-weight: 400; margin-left: 0.25rem; }

p { color: var(--fg-muted); font-size: 0.8125rem; margin-bottom: 0.625rem; }

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

code {
  font-family: Menlo, Monaco, Consolas, monospace;
  font-size: 0.75rem;
  background: var(--bg-soft);
  padding: 0.1em 0.35em;
  border-radius: 4px;
  color: var(--fg-muted);
  border: 1px solid var(--border);
}

small { font-size: 0.75rem; color: var(--fg-muted); }
strong { color: var(--fg); }

table { width: 100%; border-collapse: collapse; font-size: 0.8125rem; margin-bottom: 1.25rem; background: var(--bg); border-radius: 8px; overflow: hidden; box-shadow: var(--shadow); }

thead th {
  text-align: left;
  padding: 0.5rem 0.75rem;
  color: var(--fg-muted);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.6875rem;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border);
  background: var(--bg-soft);
}

tbody tr { border-bottom: 1px solid #f1f5f9; transition: background 0.1s; }
tbody tr:hover { background: #f9fafb; }

tbody td {
  padding: 0.45rem 0.75rem;
  color: var(--fg);
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: middle;
}

tbody td.td-wrap { white-space: normal; max-width: none; }
tbody td.td-pct { white-space: normal; min-width: 80px; max-width: 100px; }
tbody td.td-id { max-width: 110px; font-size: 0.75rem; }
tbody td.td-act { white-space: nowrap; max-width: none; width: 1%; }
tbody td.td-muted { color: var(--fg-muted); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  font-size: 0.625rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
  line-height: 1.3;
  vertical-align: middle;
  border: 1px solid var(--border);
  background: var(--bg-soft);
}

.badge-queued { color: var(--fg-muted); }
.badge-running { color: #0369a1; border-color: #bae6fd; background: #f0f9ff; }
.badge-completed { color: var(--success); border-color: #bbf7d0; background: #f0fdf4; }
.badge-failed { color: var(--danger); border-color: #fecaca; background: #fef2f2; }
.badge-info { color: var(--brand); border-color: #c7d2fe; background: var(--brand-soft); }
.badge-warn { color: #b45309; border-color: #fde68a; background: #fffbeb; }
.badge-error { color: var(--danger); border-color: #fecaca; background: #fef2f2; }
.badge-debug { color: var(--fg-muted); }

.bdot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  animation: pulse 1.5s ease-in-out infinite;
  display: inline-block;
  flex-shrink: 0;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.75); }
}

.mini-bar { height: 4px; background: var(--border); border-radius: 2px; overflow: hidden; margin-top: 3px; min-width: 50px; }
.mini-bar-fill { height: 100%; background: var(--brand); border-radius: 2px; transition: width 0.4s; }
.pct-val { font-size: 0.75rem; color: var(--fg-muted); display: block; }

.kpi-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.75rem; margin-bottom: 1rem; }

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.875rem 1rem;
  box-shadow: var(--shadow);
}

.kpi-label { font-size: 0.625rem; color: var(--fg-muted); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; margin-bottom: 0.25rem; }
.kpi-value { font-size: 1.25rem; font-weight: 700; color: var(--fg); line-height: 1.3; }
.kpi-value.kpi-sm { font-size: 0.875rem; word-break: break-all; }

.progress-bar { height: 5px; background: var(--border); border-radius: 3px; overflow: hidden; margin-bottom: 1.25rem; }
.progress-bar-fill { height: 100%; background: linear-gradient(90deg, var(--brand), #818cf8); border-radius: 3px; transition: width 0.5s; }

.form-wrap { max-width: 480px; }

label { display: block; font-size: 0.75rem; color: var(--fg-muted); font-weight: 500; margin-top: 0.75rem; margin-bottom: 0.25rem; }
label.no-mt { margin-top: 0; }

input:not([type=checkbox]):not([type=radio]),
textarea,
select {
  display: block;
  width: 100%;
  padding: 0.45rem 0.65rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--fg);
  font-size: 0.8125rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus, textarea:focus, select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

input[type=checkbox] { accent-color: var(--brand); width: 14px; height: 14px; cursor: pointer; display: inline; margin: 0; }

.chk-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  margin-top: 0.625rem;
  font-size: 0.8125rem;
  color: var(--fg-muted);
}

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

fieldset { border: 1px solid var(--border); border-radius: 8px; padding: 0.875rem; margin-top: 0.875rem; background: var(--bg); }
legend { font-size: 0.75rem; color: var(--fg-muted); font-weight: 500; padding: 0 0.375rem; }

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  padding: 0.45rem 0.875rem;
  border-radius: 8px;
  font-size: 0.8125rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  border: none;
  line-height: 1.4;
  background: var(--brand);
  color: #fff;
  transition: opacity 0.15s, transform 0.1s;
}

button:hover { opacity: 0.92; }

button.secondary {
  background: var(--bg);
  color: var(--fg-muted);
  border: 1px solid var(--border);
}

button.secondary:hover { background: var(--bg-soft); color: var(--fg); opacity: 1; }

button.danger {
  background: #fef2f2;
  color: var(--danger);
  border: 1px solid #fecaca;
}

button.danger:hover { opacity: 1; background: #fee2e2; }

.btn-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.65rem 1.25rem;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
  background: var(--cta);
  color: #fff !important;
  border: none;
  text-decoration: none !important;
}

.btn-cta:hover { opacity: 0.9; }
.btn-cta-sm { padding: 0.4rem 0.9rem; font-size: 0.8125rem; }

a[role=button] {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.45rem 0.875rem;
  border-radius: 8px;
  font-size: 0.8125rem;
  font-weight: 500;
  text-decoration: none !important;
  background: var(--brand);
  color: #fff;
  transition: opacity 0.15s;
}

a[role=button]:hover { opacity: 0.9; color: #fff; }

.act-row { display: flex; align-items: center; gap: 0.625rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.act-row h1 { margin-bottom: 0; }

.alert {
  padding: 0.625rem 0.875rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: 0.8125rem;
  line-height: 1.4;
}

.alert-error { background: #fef2f2; border: 1px solid #fecaca; color: #b91c1c; }
.alert-success { background: #f0fdf4; border: 1px solid #bbf7d0; color: #15803d; }

.key-box {
  background: var(--brand-soft);
  border: 1px solid #c7d2fe;
  border-radius: 8px;
  padding: 0.625rem 0.875rem;
  font-family: monospace;
  font-size: 0.8125rem;
  color: #4338ca;
  word-break: break-all;
  margin-top: 0.5rem;
}

.chips { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 0.875rem; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.35rem 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.75rem;
  color: var(--fg-muted);
  box-shadow: var(--shadow);
}

.chip .cdot { width: 7px; height: 7px; border-radius: 50%; background: var(--success); animation: pulse 2s ease-in-out infinite; display: inline-block; flex-shrink: 0; }
.chip-ts { color: var(--fg-muted); font-size: 0.6875rem; margin-left: 0.25rem; }

.quick-links { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 1.25rem; }

.ql-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.45rem 0.875rem;
  border-radius: 8px;
  font-size: 0.8125rem;
  font-weight: 500;
  text-decoration: none !important;
  background: var(--brand-soft);
  color: var(--brand);
  border: 1px solid #c7d2fe;
  transition: background 0.15s;
}

.ql-btn:hover { background: #e0e7ff; }

.diff-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1.25rem; }

.diff-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.25rem;
  box-shadow: var(--shadow);
}

.diff-added { border-left: 3px solid var(--success); }
.diff-removed { border-left: 3px solid var(--danger); }
.diff-count { font-size: 1.375rem; font-weight: 700; margin-bottom: 0.5rem; line-height: 1; }
.diff-added .diff-count { color: var(--success); }
.diff-removed .diff-count { color: var(--danger); }

.diff-list { list-style: none; font-size: 0.75rem; color: var(--fg-muted); max-height: 280px; overflow-y: auto; margin-top: 0.5rem; }
.diff-list li { padding: 0.1rem 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.diff-list a { color: var(--fg-muted); }

.login-wrapper {
  min-height: 100vh;
  background: var(--bg-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2rem;
  box-shadow: var(--shadow-lg);
}

.login-logo { text-align: center; margin-bottom: 1.5rem; }

.login-logo-icon {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, var(--brand), #818cf8);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 0.75rem;
}

.login-logo-icon svg { width: 22px; height: 22px; fill: #fff; }

.login-logo h1 { font-size: 1.125rem; color: var(--fg); margin: 0 0 0.25rem; }
.login-logo p { margin: 0; font-size: 0.8125rem; color: var(--fg-muted); }

.text-muted { color: var(--fg-muted); }
.mono { font-family: Menlo, Monaco, Consolas, monospace; }
.note { font-size: 0.8125rem; color: var(--fg-muted); margin-top: 0.5rem; }

.card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}

@media (max-width: 768px) {
  .sidebar { display: none; }
  .main-content { margin-left: 0; }
  .content-inner { padding: 1rem; }
  .kpi-row { grid-template-columns: repeat(2, 1fr); }
  .diff-grid { grid-template-columns: 1fr; }
}
