:root {
  --bg-page: #0d1a13;
  --bg-card: #13241b;
  --bg-kpi: #16302a;
  --bg-console: #0a140f;
  --border: #234032;
  --text: #e7f1ea;
  --muted: #9db3a5;
  --accent: #2fa86a;
  --accent-hover: #38bc78;
  --mint: #55de93;
  --wheat: #e3b34a;
  --wheat-hover: #f0c96f;
  --wheat-text: #0f1f1a;
  --btn-sec: #1a3125;
  --btn-sec-hover: #234032;
  --danger: #d94a4a;
  --danger-hover: #b83535;
  --ok-bg: #0f2e1f;
  --ok-fg: #55de93;
  --warn-bg: #2e2511;
  --warn-fg: #e3b34a;
  --err-bg: #331616;
  --err-fg: #f87171;
  --radius: 12px;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
}

[data-theme="light"] {
  --bg-page: #f0f5f2;
  --bg-card: #ffffff;
  --bg-kpi: #e6efea;
  --bg-console: #f5f9f7;
  --border: #d8e3dc;
  --text: #14231b;
  --muted: #526158;
  --accent: #17794a;
  --accent-hover: #0f5233;
  --mint: #17794a;
  --wheat: #d49f2a;
  --wheat-hover: #bc8a1f;
  --wheat-text: #0f1f1a;
  --btn-sec: #e6efea;
  --btn-sec-hover: #d4e4dc;
  --danger: #c83737;
  --danger-hover: #a62828;
  --ok-bg: #dcfce7;
  --ok-fg: #0f5233;
  --warn-bg: #fef3c7;
  --warn-fg: #925f0a;
  --err-bg: #fee2e2;
  --err-fg: #991b1b;
  --shadow: 0 6px 18px rgba(15, 31, 26, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  background: var(--bg-page);
  color: var(--text);
  line-height: 1.45;
  min-height: 100vh;
}

/* Header */
.topbar {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 40;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand img {
  width: 40px;
  height: 40px;
  border-radius: 10px;
}

.brand-kicker {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--mint);
  text-transform: uppercase;
}

.brand-title {
  font-size: 18px;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-sub {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  background: var(--bg-kpi);
  color: var(--text);
  border: 1px solid var(--border);
  white-space: nowrap;
}

.pill.ok {
  background: var(--ok-bg);
  color: var(--ok-fg);
  border-color: transparent;
}

.pill.warn {
  background: var(--warn-bg);
  color: var(--warn-fg);
  border-color: transparent;
}

.pill.err {
  background: var(--err-bg);
  color: var(--err-fg);
  border-color: transparent;
}

.project-bar {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-kpi);
  border: 1px solid var(--wheat);
  border-radius: 10px;
  padding: 3px 6px 3px 10px;
}

.project-bar label {
  font-size: 11px;
  font-weight: 700;
  color: var(--wheat);
}

.project-bar select {
  background: transparent;
  color: var(--text);
  border: none;
  font-weight: 700;
  font-size: 13px;
  padding: 4px 6px;
  outline: none;
  cursor: pointer;
}

.project-bar select option {
  background: var(--bg-card);
  color: var(--text);
}

/* Main shell */
.shell {
  max-width: 1440px;
  margin: 0 auto;
  padding: 16px 20px 36px;
}

/* Global activity banner */
.activity-banner {
  background: var(--bg-kpi);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 14px;
  display: none;
  flex-direction: column;
  gap: 8px;
  box-shadow: var(--shadow);
}

.activity-banner.visible {
  display: flex;
}

.activity-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.activity-title {
  font-weight: 700;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.pulse-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--mint);
  animation: pulse 1.4s infinite ease-in-out;
}

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

.progress-track {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: var(--bg-console);
  border: 1px solid var(--border);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--mint));
  transition: width 0.35s ease;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.tab-btn {
  background: var(--bg-card);
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
}

.tab-btn:hover {
  background: var(--btn-sec-hover);
  color: var(--text);
}

.tab-btn.active {
  background: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

/* Grid & Cards */
.grid-2 {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 16px;
  align-items: start;
}

.grid-2-eq {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  align-items: start;
}

.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 12px;
}

@media (max-width: 980px) {
  .grid-2,
  .grid-2-eq {
    grid-template-columns: 1fr;
  }
}

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

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.card-title {
  font-size: 15px;
  font-weight: 800;
  margin: 0;
}

.stage-title {
  font-size: 12px;
  font-weight: 800;
  color: var(--wheat);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 14px 0 8px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.stage-title:first-of-type {
  margin-top: 6px;
  padding-top: 0;
  border-top: none;
}

/* Forms */
.field {
  margin-bottom: 10px;
}

.field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 4px;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.field-row-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
}

@media (max-width: 640px) {
  .field-row,
  .field-row-3 {
    grid-template-columns: 1fr;
  }
}

input[type="text"],
input[type="number"],
input[type="password"],
select,
textarea {
  width: 100%;
  background: var(--bg-console);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
}

textarea {
  font-family: Consolas, "Cascadia Code", monospace;
  font-size: 12px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
}

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 0;
  font-size: 13px;
  cursor: pointer;
}

.check-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}

.hint {
  font-size: 11px;
  color: var(--muted);
}

.hint-ok {
  font-size: 11px;
  color: var(--ok-fg);
  font-weight: 600;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: 9px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: #ffffff;
}
.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-wheat {
  background: var(--wheat);
  color: var(--wheat-text);
}
.btn-wheat:hover:not(:disabled) {
  background: var(--wheat-hover);
}

.btn-sec {
  background: var(--btn-sec);
  color: var(--text);
  border-color: var(--border);
}
.btn-sec:hover:not(:disabled) {
  background: var(--btn-sec-hover);
}

.btn-danger {
  background: var(--danger);
  color: #ffffff;
}
.btn-danger:hover:not(:disabled) {
  background: var(--danger-hover);
}

.btn-sm {
  padding: 5px 10px;
  font-size: 11px;
  border-radius: 7px;
}

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

/* Project Card */
.proj-card {
  background: var(--bg-kpi);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 13px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.12s ease;
}

.proj-card:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.proj-card.active {
  border-color: var(--wheat);
  box-shadow: 0 0 0 1px var(--wheat);
}

.proj-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.proj-name {
  font-weight: 800;
  font-size: 15px;
}

.proj-metrics {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

/* Queue cards */
.queue-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.queue-item {
  background: var(--bg-kpi);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 12px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.queue-item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.queue-item-title {
  font-weight: 700;
  font-size: 13px;
}

.queue-item-summary {
  font-size: 11px;
  color: var(--muted);
}

.queue-item-detail {
  font-size: 11px;
  font-weight: 600;
}

/* Console / Logs */
.console {
  background: var(--bg-console);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-family: Consolas, "Cascadia Code", monospace;
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
  height: 290px;
  overflow-y: auto;
}

.console-sm {
  height: 140px;
}

/* Preview images */
.preview-box {
  background: var(--bg-console);
  border: 1px solid var(--border);
  border-radius: 10px;
  min-height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 6px;
}

.preview-box img {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
  display: block;
}

/* Tables */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.data-table th,
.data-table td {
  text-align: left;
  padding: 7px 9px;
  border-bottom: 1px solid var(--border);
}

.data-table th {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* KPI Row */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.kpi {
  background: var(--bg-kpi);
  border: 1px solid var(--border);
  border-top: 3px solid var(--accent);
  border-radius: 10px;
  padding: 10px 12px;
}

.kpi.wheat {
  border-top-color: var(--wheat);
}

.kpi-lbl {
  font-size: 11px;
  color: var(--muted);
}

.kpi-val {
  font-size: 18px;
  font-weight: 800;
  margin-top: 2px;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(5, 12, 8, 0.72);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 100;
}

.modal-backdrop.open {
  display: flex;
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  width: 100%;
  max-width: 600px;
  max-height: 92vh;
  overflow-y: auto;
  padding: 20px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

.modal-sm {
  max-width: 440px;
}

/* Toasts */
.toast-container {
  position: fixed;
  bottom: 18px;
  right: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 200;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--accent);
  border-left: 4px solid var(--accent);
  color: var(--text);
  padding: 10px 14px;
  border-radius: 9px;
  font-size: 12.5px;
  font-weight: 600;
  box-shadow: var(--shadow);
  max-width: 380px;
}

.toast.err {
  border-color: var(--danger);
  border-left-color: var(--danger);
}

.footer {
  max-width: 1440px;
  margin: 0 auto;
  padding: 12px 20px 24px;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 11px;
  color: var(--muted);
  border-top: 1px solid var(--border);
}

.footer a {
  color: var(--mint);
  text-decoration: none;
  font-weight: 600;
}

.footer a:hover {
  text-decoration: underline;
}
