﻿[data-bs-theme="dark"] {
  --bg: #101416;
  --surface: #171d20;
  --panel: #1c2428;
  --inset: #12181b;
  --line: #2d383e;
  --line-strong: #3d4c52;
  --nav-bg: rgba(16, 20, 22, 0.92);
  --hover-bg: #222b2f;
  --side-link: #c5d1cb;
  --side-link-active: #d9fff4;
  --ink: #e7eeea;
  --muted: #93a29a;
  --accent: #2bb89a;
  --accent-ink: #04241c;
  --accent-dim: rgba(43, 184, 154, 0.16);
  --danger: #e15d5d;
  --bs-body-bg: var(--bg);
  --bs-body-color: var(--ink);
  --bs-emphasis-color: #f5faf7;
  --bs-secondary-color: var(--muted);
  --bs-tertiary-color: #b7c4bc;
  --bs-border-color: var(--line);
  --bs-primary: var(--accent);
  --bs-primary-rgb: 43, 184, 154;
  --bs-link-color: #8edfcd;
  --bs-link-hover-color: #c6f3e8;
  --bs-secondary-bg: var(--surface);
  --bs-tertiary-bg: var(--panel);
  --bs-heading-color: var(--ink);
  --bs-focus-ring-color: rgba(43, 184, 154, 0.35);
  color-scheme: dark;
}

[data-bs-theme="light"] {
  --bg: #eef2f0;
  --surface: #f7faf8;
  --panel: #ffffff;
  --inset: #f0f4f2;
  --line: #d8e0dc;
  --line-strong: #c2ccc7;
  --nav-bg: rgba(255, 255, 255, 0.92);
  --hover-bg: #e6ece9;
  --side-link: #33413b;
  --side-link-active: #0c6b59;
  --ink: #1c2a24;
  --muted: #5c6b64;
  --accent: #12907a;
  --accent-ink: #ffffff;
  --accent-dim: rgba(18, 144, 122, 0.12);
  --danger: #c73e3e;
  --bs-body-bg: var(--bg);
  --bs-body-color: var(--ink);
  --bs-emphasis-color: #101d17;
  --bs-secondary-color: var(--muted);
  --bs-tertiary-color: #77857d;
  --bs-border-color: var(--line);
  --bs-primary: var(--accent);
  --bs-primary-rgb: 18, 144, 122;
  --bs-link-color: #0f7f6b;
  --bs-link-hover-color: #0b5f51;
  --bs-secondary-bg: var(--surface);
  --bs-tertiary-bg: var(--panel);
  --bs-heading-color: var(--ink);
  --bs-focus-ring-color: rgba(18, 144, 122, 0.3);
  color-scheme: light;
}

html, body { min-height: 100%; }

body {
  font-family: "Segoe UI", system-ui, sans-serif;
  background:
    radial-gradient(900px 420px at 10% -10%, rgba(43, 184, 154, 0.08), transparent 60%),
    var(--bg);
  letter-spacing: 0.01em;
}

h1, h2, .navbar-brand, .side-brand a {
  letter-spacing: -0.02em;
}

a { text-underline-offset: 0.15em; }

.btn {
  --bs-btn-border-radius: 0.55rem;
  font-weight: 600;
}

.btn-primary {
  --bs-btn-bg: var(--accent);
  --bs-btn-border-color: var(--accent);
  --bs-btn-color: var(--accent-ink);
  --bs-btn-hover-bg: #49c9ae;
  --bs-btn-hover-border-color: #49c9ae;
  --bs-btn-hover-color: var(--accent-ink);
  --bs-btn-active-bg: #239e84;
  --bs-btn-active-border-color: #239e84;
  --bs-btn-active-color: var(--accent-ink);
  --bs-btn-disabled-bg: #1d6f5e;
  --bs-btn-disabled-border-color: #1d6f5e;
  --bs-btn-disabled-color: rgba(4, 36, 28, 0.65);
}

.btn-outline-secondary {
  --bs-btn-color: var(--ink);
  --bs-btn-border-color: var(--line);
  --bs-btn-hover-bg: var(--hover-bg);
  --bs-btn-hover-border-color: var(--line-strong);
  --bs-btn-hover-color: var(--ink);
  --bs-btn-active-bg: var(--hover-bg);
  --bs-btn-active-color: var(--ink);
}

.btn-outline-danger {
  --bs-btn-color: #ffb4b4;
  --bs-btn-border-color: #6a3030;
  --bs-btn-hover-bg: #3a1c1c;
  --bs-btn-hover-border-color: #8a4040;
  --bs-btn-hover-color: #ffd4d4;
}

.form-control, .form-select {
  background-color: var(--inset);
  border-color: var(--line);
  color: var(--ink);
  border-radius: 0.55rem;
}

.form-control:focus, .form-select:focus {
  background-color: var(--inset);
  border-color: #3d9d88;
  color: var(--ink);
  box-shadow: 0 0 0 0.2rem rgba(43, 184, 154, 0.18);
}

.form-control::placeholder { color: var(--muted); }

.badge.text-bg-primary {
  color: var(--accent-ink);
  background-color: var(--accent) !important;
}

.site-nav {
  background: var(--nav-bg);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

.site-nav .navbar-brand {
  font-weight: 700;
  color: var(--ink);
}

.site-footer {
  border-top: 1px solid var(--line);
  color: var(--muted);
}

.hero {
  padding: 4.5rem 0 1rem;
}

.eyebrow {
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin-bottom: 0.6rem;
}

.hero h1 {
  font-size: clamp(2rem, 4vw, 3.25rem);
  line-height: 1.1;
  max-width: 16ch;
  margin-bottom: 0.8rem;
}

.hero .lead {
  max-width: 38rem;
  color: var(--muted);
}

.feature-grid { padding-bottom: 3rem; }

.feature {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 1rem;
  padding: 1.15rem 1.2rem;
  height: 100%;
}

.feature h2 {
  font-size: 1rem;
  margin-bottom: 0.35rem;
}

.feature p { color: var(--muted); margin: 0; }

.auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.auth-card {
  width: min(100%, 26rem);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 1.1rem;
  padding: 1.6rem 1.5rem 1.4rem;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
}

.auth-card h1 {
  font-size: 1.7rem;
  margin-bottom: 0.35rem;
}

.auth-card .sub {
  color: var(--muted);
  margin-bottom: 1.25rem;
}

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

.app-side {
  background: var(--surface);
  border-right: 1px solid var(--line);
  color: var(--ink);
  display: flex;
  flex-direction: column;
  width: min(18rem, 86vw);
}

.side-brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1.1rem 1rem 0.8rem;
}

.side-brand a {
  color: var(--ink);
  font-weight: 700;
  text-decoration: none;
  font-size: 1.05rem;
}

.side-nav {
  padding: 0.4rem 0.7rem 1rem;
  overflow: auto;
}

.side-label {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin: 0.9rem 0.55rem 0.3rem;
}

.side-link {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  color: var(--side-link);
  text-decoration: none;
  border-radius: 0.65rem;
  padding: 0.48rem 0.65rem;
  margin-bottom: 0.12rem;
}

.side-link svg {
  width: 1.05rem;
  height: 1.05rem;
  flex: none;
  opacity: 0.8;
}

.side-link:hover {
  background: var(--hover-bg);
  color: var(--ink);
}

.side-link.active {
  background: var(--accent-dim);
  color: var(--side-link-active);
}

.side-link.active svg { opacity: 1; }

.side-foot {
  margin-top: auto;
  padding: 0.9rem;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.side-user {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 0.9rem;
}

.app-main { min-width: 0; }

.app-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--line);
  background: var(--nav-bg);
  position: sticky;
  top: 0;
  z-index: 20;
}

.app-bar strong { font-size: 0.95rem; }

.app-content {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
}

.page-head { margin-bottom: 1.15rem; }

.page-head h1 {
  font-size: 1.55rem;
  margin: 0 0 0.25rem;
}

.page-head p {
  color: var(--muted);
  margin: 0;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 1rem;
  padding: 1rem 1rem 1.05rem;
  margin-bottom: 1rem;
  max-width: 100%;
  overflow-x: auto;
}

.panel h2 {
  font-size: 1rem;
  margin: 0 0 0.2rem;
}

.chart-wrap {
  position: relative;
  height: 320px;
  max-width: 100%;
}

.theme-toggle-floating {
  position: fixed;
  top: 0.9rem;
  right: 0.9rem;
  z-index: 1100;
}

.panel .hint {
  color: var(--muted);
  font-size: 0.86rem;
  margin: 0 0 0.8rem;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem;
  margin-bottom: 0.75rem;
}

.stat-board {
  display: grid;
  gap: 0.8rem;
  margin-bottom: 1.5rem;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.8rem;
}

@media (max-width: 767.98px) {
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.stat {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 7.2rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 1rem;
  padding: 1rem 1.05rem;
  text-decoration: none;
  color: inherit;
}

.stat:hover {
  border-color: #3e6f64;
  color: inherit;
}

.stat-label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.stat-value {
  font-size: 2rem;
  font-weight: 600;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.stat-sub {
  color: var(--muted);
  font-size: 0.82rem;
  margin-top: 0.45rem;
}

.list-search { max-width: 280px; }

.file-pick { max-width: 280px; }

.command {
  background: var(--inset);
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  color: var(--ink);
  padding: 0.9rem 1rem;
  margin: 0.9rem 0 0.7rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.install-tabs { gap: 0.35rem; border: 0; }

.install-tabs .nav-link {
  border: 0;
  border-radius: 999px;
  color: var(--muted);
  padding: 0.35rem 0.8rem;
}

.install-tabs .nav-link:hover { color: var(--ink); }

.install-tabs .nav-link.active {
  background: var(--accent-dim);
  color: var(--side-link-active);
}

th.pick, td.pick { width: 2.4rem; text-align: center; }
td.pick input, th.pick input { margin: 0; vertical-align: middle; }

.panel table.dataTable,
.panel table.table {
  margin-bottom: 0;
  --bs-table-bg: transparent;
  --bs-table-color: var(--ink);
  --bs-table-border-color: var(--line);
  --bs-table-hover-bg: rgba(43, 184, 154, 0.06);
  --bs-table-hover-color: var(--ink);
}

table.dataTable thead th,
.panel table thead th {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: transparent !important;
  border-bottom-color: var(--line);
}

.dt-column-header {
  display: flex !important;
  justify-content: flex-start !important;
  align-items: center;
  gap: 0.35rem;
}

.dt-column-order { margin-left: 0.25rem !important; }
.panel table th:first-child .dt-column-order,
.panel table th:last-child .dt-column-order { display: none; }

.panel table td { border-color: var(--line); vertical-align: middle; }

#agents-table tbody td.agent-working {
  --bs-table-color: #3dce7a;
  --bs-table-hover-color: #3dce7a;
  color: #3dce7a;
}
#agents-table tbody td.agent-paused {
  --bs-table-color: #5aa7ff;
  --bs-table-hover-color: #5aa7ff;
  color: #5aa7ff;
}
#agents-table tbody td.agent-dead {
  --bs-table-color: #e15d5d;
  --bs-table-hover-color: #e15d5d;
  color: #e15d5d;
}
.test-passed { color: #3dce7a; }
.test-send { color: #e2c15a; }
.test-failed { color: #e15d5d; }
.review-mark.test-passed { color: #3dce7a; border-color: #3dce7a; }
.review-mark.test-send { color: #e2c15a; border-color: #e2c15a; }
.review-mark.test-failed { color: #e15d5d; border-color: #e15d5d; }

.panel table th:last-child,
.panel table td:last-child:not([colspan]) {
  width: 1%;
  white-space: nowrap;
  text-align: right;
}

td.dt-empty {
  text-align: center !important;
  color: var(--muted);
}

.dt-container { width: 100%; color: var(--ink); }

.dt-container .dt-layout-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  margin: 0.15rem 0 0.7rem;
}

.dt-container .dt-input,
.dt-container select,
.dt-container .dt-search input {
  background: var(--inset);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  padding: 0.3rem 0.55rem;
}

.dt-container .dt-search { text-align: left; }
.dt-container .dt-search label,
.dt-container .dt-length label,
.dt-container .dt-info { color: var(--muted); }

.dt-paging .pagination { margin: 0.6rem 0 0; }
.dt-paging .page-link {
  background: transparent;
  color: var(--ink);
  border-color: var(--line);
}
.dt-paging .page-item.active .page-link {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.dt-paging .page-item.disabled .page-link { color: var(--muted); background: transparent; }

.page { display: none; }
.page.active { display: block; }

.status-line {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  white-space: nowrap;
}

.status-dot {
  width: 0.65rem;
  height: 0.65rem;
  border-radius: 50%;
  display: inline-block;
  background: var(--muted);
  flex: none;
}
.status-dot.on { background: var(--accent); }
.status-dot.off { background: var(--danger); }

@media (min-width: 992px) {
  .app-shell { display: flex; align-items: stretch; }
  .app-side {
    position: sticky;
    top: 0;
    height: 100vh;
    width: 240px;
    flex: none;
    transform: none;
  }
  .app-main { flex: 1; }
  .app-bar { display: none; }
}

@media (max-width: 991.98px) {
  .hero { padding-top: 2.5rem; }
  .app-content { padding-top: 1.1rem; }
  .app-side {
    position: fixed;
    z-index: 1040;
    top: 0;
    bottom: 0;
    left: 0;
    height: 100vh;
    transform: translateX(-105%);
    transition: transform 0.18s ease;
    box-shadow: none;
  }
  .app-side.show {
    transform: none;
    box-shadow: 12px 0 40px rgba(0, 0, 0, 0.35);
  }
  body.menu-open { overflow: hidden; }
}

.import-progress {
  height: 0.45rem;
  background: var(--inset);
  border: 1px solid var(--line);
}
.import-progress .progress-bar {
  background: var(--accent);
}

.col-num {
  width: 6rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
