:root {
  --bg-0: #090b10;
  --bg-1: #12151d;
  --bg-2: #1a1e28;
  --surface: rgba(255, 255, 255, 0.04);
  --surface-hover: rgba(255, 255, 255, 0.07);
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #eef0f4;
  --muted: #8992a6;
  --accent: #6ea8fe;
  --accent-strong: #4c8dfd;
  --accent-rgb: 110, 168, 254;
  --accent-contrast: #0a0e16;
  --danger: #f87171;
  --danger-rgb: 248, 113, 113;
  --ok: #4ade80;
  --ok-rgb: 74, 222, 128;
  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --shadow-card: 0 1px 0 rgba(255, 255, 255, 0.04) inset, 0 10px 30px -14px rgba(0, 0, 0, 0.6);
  --shadow-pop: 0 20px 50px -20px rgba(0, 0, 0, 0.7);
}

:root[data-accent="violet"] { --accent: #a78bfa; --accent-strong: #8b5cf6; --accent-rgb: 167, 139, 250; }
:root[data-accent="green"]  { --accent: #4ade80; --accent-strong: #22c55e; --accent-rgb: 74, 222, 128; }
:root[data-accent="amber"]  { --accent: #fbbf24; --accent-strong: #f59e0b; --accent-rgb: 251, 191, 36; --accent-contrast: #1a1200; }
:root[data-accent="rose"]   { --accent: #fb7185; --accent-strong: #f43f5e; --accent-rgb: 251, 113, 133; }

:root[data-theme="light"] {
  --bg-0: #eef0f5;
  --bg-1: #ffffff;
  --bg-2: #f6f7fa;
  --surface: rgba(20, 24, 34, 0.035);
  --surface-hover: rgba(20, 24, 34, 0.06);
  --border: rgba(20, 24, 34, 0.09);
  --border-strong: rgba(20, 24, 34, 0.18);
  --text: #171a21;
  --muted: #646d7e;
  --shadow-card: 0 1px 0 rgba(255, 255, 255, 0.6) inset, 0 10px 24px -16px rgba(20, 24, 40, 0.25);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-feature-settings: "cv11", "ss01";
  color: var(--text);
  background:
    radial-gradient(1000px circle at 10% -10%, rgba(var(--accent-rgb), 0.10), transparent 50%),
    radial-gradient(900px circle at 90% 110%, rgba(var(--accent-rgb), 0.07), transparent 50%),
    var(--bg-0);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 0.86rem; }
.error { color: var(--danger); font-size: 0.85rem; min-height: 1.2em; margin: 2px 0 0; }

h1, h2, h3 { font-family: inherit; letter-spacing: -0.01em; }

/* --- login --- */
#login-view {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: linear-gradient(180deg, var(--surface), transparent 60%), var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 36px 32px 32px;
  box-shadow: var(--shadow-pop);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.login-logo {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--accent-strong), var(--accent));
  color: var(--accent-contrast);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 18px;
  box-shadow: 0 10px 24px -8px rgba(var(--accent-rgb), 0.5);
}
.login-logo svg { width: 28px; height: 28px; }

.login-card h1 { margin: 0 0 4px; font-size: 1.3rem; font-weight: 700; }
.login-card > .muted { margin-bottom: 26px; }

#login-form { width: 100%; display: flex; flex-direction: column; gap: 16px; }
#login-form label { text-align: left; }

label {
  display: flex;
  flex-direction: column;
  gap: 7px;
  font-size: 0.83rem;
  font-weight: 500;
  color: var(--muted);
}

input[type="text"], input[type="password"], input[type="number"] {
  background: var(--bg-0);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  color: var(--text);
  font-size: 0.94rem;
  font-family: inherit;
  width: 100%;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

:root[data-theme="light"] input[type="text"],
:root[data-theme="light"] input[type="password"],
:root[data-theme="light"] input[type="number"] {
  background: var(--bg-2);
}

input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.22);
}

button {
  cursor: pointer;
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 18px;
  font-size: 0.88rem;
  font-weight: 600;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: transform 0.08s ease, box-shadow 0.18s ease, background 0.15s ease, opacity 0.15s ease;
}

button:active { transform: scale(0.97); }

button.primary {
  background: linear-gradient(135deg, var(--accent-strong), var(--accent));
  color: var(--accent-contrast);
  box-shadow: 0 6px 18px -6px rgba(var(--accent-rgb), 0.55);
}
button.primary:hover { box-shadow: 0 8px 22px -6px rgba(var(--accent-rgb), 0.7); }

button.ghost {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}
button.ghost:hover { background: var(--surface-hover); border-color: var(--border-strong); }

button.danger { color: var(--danger); border-color: rgba(var(--danger-rgb), 0.35); }
button.danger:hover { background: rgba(var(--danger-rgb), 0.1); }

button:disabled { opacity: 0.45; cursor: not-allowed; box-shadow: none; }

.full { width: 100%; justify-content: center; }
.btn-icon { width: 15px; height: 15px; flex-shrink: 0; }

/* --- shell --- */
#app-view { display: flex; min-height: 100vh; align-items: stretch; }

.sidebar {
  width: 232px;
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--surface), transparent 30%), var(--bg-1);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 22px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 26px;
  font-weight: 800;
  font-size: 1.08rem;
  letter-spacing: -0.01em;
}
.brand-icon { width: 22px; height: 22px; color: var(--accent); flex-shrink: 0; }

.nav { display: flex; flex-direction: column; gap: 3px; flex: 1; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  background: transparent;
  border: 1px solid transparent;
  border-left: 3px solid transparent;
  color: var(--muted);
  text-align: left;
  padding: 10px 11px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.88rem;
  width: 100%;
}

.nav-item:hover { background: var(--surface-hover); color: var(--text); }

.nav-item.active {
  background: rgba(var(--accent-rgb), 0.12);
  border-left-color: var(--accent);
  color: var(--text);
}

.nav-icon { width: 18px; height: 18px; flex-shrink: 0; color: var(--muted); }
.nav-item.active .nav-icon, .nav-item:hover .nav-icon { color: var(--accent); }

.sidebar-footer {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 16px;
  margin-top: 8px;
  border-top: 1px solid var(--border);
}
.sidebar-footer .muted { font-size: 0.8rem; padding-left: 2px; }
.sidebar-footer button { justify-content: flex-start; }

.content {
  flex: 1;
  padding: 36px 44px 70px;
  max-width: 1040px;
  display: flex;
  flex-direction: column;
  gap: 26px;
}

.view-title { font-size: 1.5rem; font-weight: 800; margin: 0; }

.view-section { display: flex; flex-direction: column; gap: 26px; }

/* --- cards --- */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 14px;
}

.card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.card-label { color: var(--muted); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; }
.card-value { font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }

.actions { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }

.pill-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.82rem;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 7px 13px;
  border-radius: 999px;
}
.pill-status .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 0 rgba(var(--accent-rgb), 0.6);
  animation: pulse 1.6s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(var(--accent-rgb), 0.5); }
  70% { box-shadow: 0 0 0 7px rgba(var(--accent-rgb), 0); }
  100% { box-shadow: 0 0 0 0 rgba(var(--accent-rgb), 0); }
}

/* --- panels --- */
.panel {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  box-shadow: var(--shadow-card);
}

.panel h2 { margin: 0 0 16px; font-size: 0.95rem; font-weight: 700; }

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}
.panel-header h2 { margin: 0; }

.filter-input { max-width: 320px; font-size: 0.85rem; padding: 9px 13px; width: 100%; }

.list { display: flex; flex-direction: column; gap: 7px; }

.row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid transparent;
  gap: 12px;
  flex-wrap: wrap;
}

.row:hover { border-color: var(--border-strong); background: var(--surface-hover); cursor: pointer; }

.row-main { display: flex; flex-direction: column; gap: 3px; }
.row-main.row-with-icon { flex-direction: row; align-items: center; gap: 11px; }
.row-icon { width: 17px; height: 17px; flex-shrink: 0; color: var(--muted); }
.row-title { font-size: 0.89rem; font-weight: 600; }
.row-sub { font-size: 0.78rem; color: var(--muted); }

.badge {
  font-size: 0.7rem;
  padding: 4px 10px;
  border-radius: 999px;
  font-weight: 700;
  white-space: nowrap;
  letter-spacing: 0.01em;
}

.badge-success { background: rgba(var(--ok-rgb), 0.14); color: var(--ok); }
.badge-failed { background: rgba(var(--danger-rgb), 0.14); color: var(--danger); }
.badge-tag { background: rgba(var(--accent-rgb), 0.14); color: var(--accent); }

/* --- settings subnav --- */
.subnav {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 5px;
  border-radius: 999px;
  width: fit-content;
}

.subnav-item {
  background: transparent;
  border: none;
  color: var(--muted);
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 0.83rem;
  font-weight: 600;
}

.subnav-item:hover { color: var(--text); }

.subnav-item.active {
  background: linear-gradient(135deg, var(--accent-strong), var(--accent));
  color: var(--accent-contrast);
}

.subview { display: flex; flex-direction: column; gap: 18px; }

/* --- forms --- */
form { display: flex; flex-direction: column; gap: 18px; }

.field-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.field { flex: 1 1 200px; display: flex; flex-direction: column; gap: 7px; }
.field-tight { flex: 0 1 100px; }

.field-label-standalone {
  display: block;
  font-size: 0.83rem;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 10px;
}

.checkbox-field {
  flex-direction: row;
  align-items: center;
  gap: 10px;
  font-size: 0.89rem;
  font-weight: 500;
  color: var(--text);
}
.checkbox-field input { width: auto; accent-color: var(--accent); width: 17px; height: 17px; }

.next-run-hint { align-self: center; margin-left: 4px; }

.form-footer {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-top: 4px;
  border-top: 1px solid var(--border);
  margin-top: 2px;
}

/* --- design settings --- */
.field + .field { margin-top: 4px; }

.swatch-row { display: flex; gap: 10px; flex-wrap: wrap; }

.swatch-option {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
}
.swatch-option svg { width: 15px; height: 15px; }
.swatch-option.selected { border-color: var(--accent); color: var(--accent); background: rgba(var(--accent-rgb), 0.1); }

.swatch-color {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--sw);
  padding: 0;
  box-shadow: 0 4px 10px -4px rgba(0,0,0,0.4);
}
.swatch-color.selected { border-color: var(--text); box-shadow: 0 0 0 3px var(--bg-1), 0 0 0 5px var(--sw); }

/* --- modals --- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(5, 6, 10, 0.65);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 50;
}

.modal-box {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 760px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-pop);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 { margin: 0; font-size: 1rem; font-weight: 700; }
.modal-header-actions { display: flex; gap: 10px; }

.modal-sub {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 8px;
  background: var(--surface);
}

.breadcrumb { font-size: 0.82rem; color: var(--accent); font-weight: 500; }
.breadcrumb span { cursor: pointer; }
.breadcrumb span:hover { text-decoration: underline; }

.browser { padding: 14px 20px; overflow-y: auto; }
.browser .row-sub { font-size: 0.72rem; }

#log-modal-content {
  margin: 0;
  padding: 18px 20px;
  overflow: auto;
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.78rem;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--muted);
  background: var(--bg-0);
}

@media (max-width: 860px) {
  #app-view { flex-direction: column; }
  .sidebar {
    position: static;
    height: auto;
    width: 100%;
    flex-direction: row;
    align-items: center;
    padding: 12px 16px;
    gap: 12px;
    overflow-x: auto;
  }
  .brand { padding: 0; }
  .nav { flex-direction: row; flex: none; }
  .nav-item { border-left: none; border-bottom: 3px solid transparent; }
  .nav-item.active { border-bottom-color: var(--accent); }
  .sidebar-footer { flex-direction: row; align-items: center; border-top: none; margin-top: 0; padding-top: 0; margin-left: auto; }
  .sidebar-footer .muted { display: none; }
  .content { padding: 22px 16px 40px; }
  .view-title { font-size: 1.3rem; }
}
