:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-raised: #ffffff;
  --surface-muted: #eef2f7;
  --surface-subtle: #f8fafc;
  --text: #172033;
  --text-muted: #647084;
  --text-soft: #8b95a7;
  --border: #d9e0ea;
  --border-strong: #b8c2d1;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
  --shadow-raised: 0 8px 24px rgba(15, 23, 42, 0.10);
  --sidebar-bg: #111827;
  --sidebar-text: #dbe4f0;
  --sidebar-muted: #8ea0b8;
  --sidebar-active: #1f6feb;
  --accent: #1f6feb;
  --accent-strong: #1557c0;
  --accent-soft: #e9f1ff;
  --ok: #12805c;
  --ok-bg: #e7f7ef;
  --warn: #a16207;
  --warn-bg: #fff7db;
  --danger: #c03535;
  --danger-bg: #fff0f0;
  --info: #087ea4;
  --info-bg: #e7f7fb;
  --focus: 0 0 0 3px rgba(31, 111, 235, 0.22);
}

:root[data-color-scheme="dark"] {
  color-scheme: dark;
  --bg: #111318;
  --surface: #191d24;
  --surface-raised: #202631;
  --surface-muted: #252c38;
  --surface-subtle: #151922;
  --text: #edf1f7;
  --text-muted: #a9b4c4;
  --text-soft: #7f8b9d;
  --border: #303846;
  --border-strong: #465164;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-raised: 0 8px 24px rgba(0, 0, 0, 0.32);
  --sidebar-bg: #0d1117;
  --sidebar-text: #dbe4f0;
  --sidebar-muted: #8391a6;
  --sidebar-active: #2f81f7;
  --accent: #5aa2ff;
  --accent-strong: #7ab5ff;
  --accent-soft: #173154;
  --ok: #4ade80;
  --ok-bg: #122b22;
  --warn: #facc15;
  --warn-bg: #34290d;
  --danger: #ff7b72;
  --danger-bg: #3a1719;
  --info: #67e8f9;
  --info-bg: #102d36;
  --focus: 0 0 0 3px rgba(90, 162, 255, 0.28);
}

@media (prefers-color-scheme: dark) {
  :root[data-color-scheme="system"] {
    color-scheme: dark;
    --bg: #111318;
    --surface: #191d24;
    --surface-raised: #202631;
    --surface-muted: #252c38;
    --surface-subtle: #151922;
    --text: #edf1f7;
    --text-muted: #a9b4c4;
    --text-soft: #7f8b9d;
    --border: #303846;
    --border-strong: #465164;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-raised: 0 8px 24px rgba(0, 0, 0, 0.32);
    --sidebar-bg: #0d1117;
    --sidebar-text: #dbe4f0;
    --sidebar-muted: #8391a6;
    --sidebar-active: #2f81f7;
    --accent: #5aa2ff;
    --accent-strong: #7ab5ff;
    --accent-soft: #173154;
    --ok: #4ade80;
    --ok-bg: #122b22;
    --warn: #facc15;
    --warn-bg: #34290d;
    --danger: #ff7b72;
    --danger-bg: #3a1719;
    --info: #67e8f9;
    --info-bg: #102d36;
    --focus: 0 0 0 3px rgba(90, 162, 255, 0.28);
  }
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Malgun Gothic", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  letter-spacing: 0;
}

a {
  color: inherit;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
}

.app-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  padding: 18px 14px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 52px;
  padding: 6px 8px 18px;
  color: var(--sidebar-text);
  text-decoration: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: #1f6feb;
  color: #fff;
  font-size: 12px;
  font-weight: 800;
}

.brand-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.brand-title {
  font-size: 15px;
  font-weight: 800;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-subtitle {
  margin-top: 3px;
  color: var(--sidebar-muted);
  font-size: 12px;
}

.side-nav {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 18px 0;
  overflow-y: auto;
}

.nav-group-label {
  padding: 0 10px 7px;
  color: var(--sidebar-muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.nav-link {
  min-height: 38px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-weight: 700;
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.08);
}

.nav-link.active {
  background: rgba(31, 111, 235, 0.22);
  color: #fff;
  box-shadow: inset 3px 0 0 var(--sidebar-active);
}

.nav-icon {
  width: 24px;
  height: 24px;
  padding: 5px;
  flex: 0 0 24px;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--sidebar-text);
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.nav-link.active .nav-icon {
  background: var(--sidebar-active);
  color: #fff;
}

.sidebar-footer {
  margin-top: auto;
  min-height: 40px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px;
  border-radius: 8px;
  color: var(--sidebar-muted);
  background: rgba(255, 255, 255, 0.06);
  font-size: 12px;
}

.status-dot,
.lamp-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  display: inline-block;
  background: var(--warn);
}

.status-ok {
  background: #32d583;
}

.app-main {
  min-width: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.top-bar {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 22px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
  z-index: 5;
}

.top-bar-heading {
  min-width: 0;
}

.top-bar-heading h1 {
  margin: 2px 0 0;
  font-size: 20px;
  line-height: 1.2;
}

.eyebrow {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.top-bar-right {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

.theme-switch {
  height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-muted);
}

.theme-switch button {
  height: 26px;
  width: 30px;
  min-width: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-radius: 6px;
  color: var(--text-muted);
  background: transparent;
  cursor: pointer;
}

.theme-switch button.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}

.theme-switch svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.content-area {
  flex: 1 1 auto;
  min-width: 0;
  padding: 22px;
}

body.page-jobs {
  height: 100vh;
  overflow: hidden;
}

body.page-jobs .app-shell,
body.page-jobs .app-main {
  height: 100vh;
  min-height: 0;
}

body.page-jobs .content-area {
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 14px;
  overflow: hidden;
}

body.page-history {
  height: 100vh;
  overflow: hidden;
}

body.page-history .app-shell,
body.page-history .app-main {
  height: 100vh;
  min-height: 0;
}

body.page-history .content-area {
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 14px;
  overflow: hidden;
}

.smg-top-lamps {
  min-width: 0;
  max-width: min(52vw, 760px);
}

.smg-top-lamps-inner {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: thin;
}

.smg-top-lamp-chip {
  height: 28px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-subtle);
  color: var(--text);
  white-space: nowrap;
  font-size: 12px;
  font-weight: 800;
}

.smg-top-lamp-chip.status-online .lamp-dot {
  background: var(--ok);
}

.smg-top-lamp-chip.status-offline .lamp-dot {
  background: var(--danger);
}

.smg-top-lamp-chip.status-unknown .lamp-dot {
  background: var(--warn);
}

.page-header,
.section-header,
.table-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.page-header {
  min-height: 58px;
}

.page-header h2,
.section-header h2,
.table-header h3,
.form-section h3,
.card > h3 {
  margin: 0;
  color: var(--text);
  line-height: 1.2;
}

.page-header h2 {
  font-size: 22px;
}

.section-header h2,
.table-header h3,
.card > h3 {
  font-size: 16px;
}

.muted,
.status-text,
.timestamp,
.metric-label {
  color: var(--text-muted);
}

.muted {
  margin: 5px 0 0;
  font-size: 13px;
}

.header-actions,
.section-controls,
.section-heading,
.filter-actions,
.form-actions,
.actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-actions,
.form-actions,
.actions {
  flex-wrap: wrap;
}

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

.watch-controls,
.smg-controls {
  align-items: start;
  margin-bottom: 16px;
}

.card,
.history-filters,
.jobs-page [data-split-pane] {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.card {
  padding: 16px;
}

.form-section + .form-section {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.form-section h3 {
  margin-bottom: 12px;
}

.form-card,
.settings-form,
.db-form,
.db-tool-card,
.db-import-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.form-card label,
.settings-form label,
.db-form label,
.db-import-form label,
.history-filters label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  padding: 7px 10px;
  background: var(--surface);
  color: var(--text);
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible,
a:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

.inline-fields,
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.option-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.checkbox-field {
  width: auto;
  display: inline-flex !important;
  flex-direction: row !important;
  align-items: center;
  gap: 8px;
}

.checkbox-field input {
  width: 16px;
  min-height: 16px;
}

button,
.btn,
.button-link {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 7px 12px;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  font-weight: 800;
  font-size: 13px;
}

button,
.btn.primary {
  background: var(--accent);
  color: #fff;
}

button:hover,
.btn.primary:hover {
  background: var(--accent-strong);
}

.btn.secondary {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: rgba(31, 111, 235, 0.24);
}

.btn.ghost,
.button-link {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}

.btn.danger {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: rgba(192, 53, 53, 0.24);
}

.btn:hover,
.button-link:hover {
  transform: translateY(-1px);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(112px, 1fr));
  gap: 10px;
}

.metric-card {
  min-height: 80px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-subtle);
}

.metric-value {
  display: block;
  font-size: 28px;
  line-height: 1;
  font-weight: 900;
}

.metric-label {
  display: block;
  margin-top: 8px;
  font-size: 12px;
  font-weight: 800;
}

.table-card {
  overflow: hidden;
}

.table-scroll,
.pane-scroll {
  width: 100%;
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--surface);
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-muted);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 900;
}

tbody tr {
  background: var(--surface);
}

tbody tr:nth-child(even) {
  background: var(--surface-subtle);
}

tbody tr:hover {
  background: var(--accent-soft);
}

.job-table tbody tr.status-transfer,
.job-table tbody tr.status-transfer:nth-child(even) {
  background: var(--accent-soft);
}

.job-table tbody tr.status-transfer td {
  color: var(--accent);
  font-weight: 800;
}

.job-table tbody tr.status-pending td {
  color: var(--text);
  font-weight: 400;
}

.job-table tbody tr.status-end,
.job-table tbody tr.status-end:nth-child(even) {
  background: var(--surface-muted);
}

.job-table tbody tr.status-end td {
  color: var(--text-soft);
}

.job-table tbody tr.status-end:hover {
  background: var(--surface-muted);
}

.compact-table {
  font-size: 12px;
  line-height: 1.3;
}

.compact-table th,
.compact-table td {
  padding: 6px 8px;
  white-space: nowrap;
}

.job-table {
  table-layout: auto;
}

.job-table.compact-table {
  font-size: 12px;
  line-height: 1.2;
}

.job-table.compact-table th,
.job-table.compact-table td {
  height: 30px;
  padding: 4px 8px;
  vertical-align: middle;
}

.job-table td:nth-child(7) {
  width: 70px;
}

.job-table td:nth-child(7) form {
  display: flex;
  align-items: center;
  margin: 0;
}

.job-table td:nth-child(7) select {
  width: 56px;
  min-height: 26px;
  height: 26px;
  padding: 2px 4px 2px 8px;
  border-radius: 6px;
  font-size: 12px;
  line-height: 1;
  text-align: center;
  text-align-last: center;
}

.compact-table td:nth-child(2),
.compact-table td:nth-last-child(2),
.compact-table td:last-child {
  white-space: normal;
}

.data-table .actions,
.compact-table .actions {
  align-items: flex-start;
}

.data-table .actions form,
.compact-table .actions form {
  display: inline-flex;
}

.path-cell,
.policy-list {
  max-width: 420px;
  word-break: break-all;
}

.policy-list,
.status-text,
.timestamp {
  font-size: 12px;
}

.empty,
.table-card .empty {
  text-align: center;
  padding: 28px 12px;
  color: var(--text-soft);
}

.badge {
  min-height: 22px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 7px;
  border-radius: 999px;
  background: var(--surface-muted);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 900;
}

.status-badge.status-online,
.badge.status-online,
.status-badge.status-active {
  background: var(--ok-bg);
  color: var(--ok);
}

.status-badge.status-offline,
.status-badge.status-disabled,
.badge-error,
.badge-fail {
  background: var(--danger-bg);
  color: var(--danger);
}

.status-badge.status-unknown,
.badge-abort {
  background: var(--warn-bg);
  color: var(--warn);
}

.badge-som {
  background: #fce7f3;
  color: #be185d;
}

:root[data-color-scheme="dark"] .badge-som {
  background: #3a1830;
  color: #f9a8d4;
}

.badge-ndf {
  background: var(--info-bg);
  color: var(--info);
}

.badge-overwrite {
  background: #fff7ed;
  color: #c2410c;
}

:root[data-color-scheme="dark"] .badge-overwrite {
  background: #3b1d0b;
  color: #fdba74;
}

.badge-confirmation-count {
  min-height: 20px;
  padding: 2px 7px;
  background: var(--warn-bg);
  color: var(--warn);
}

.badge-default {
  background: var(--surface-muted);
  color: var(--text-muted);
}

.badge-external {
  background: var(--warn-bg);
  color: var(--warn);
}

.external-job td {
  color: var(--warn);
  font-weight: 700;
}

.alert {
  padding: 12px;
  border-radius: 8px;
  margin-top: 14px;
  border: 1px solid transparent;
}

.alert-error {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: rgba(192, 53, 53, 0.2);
}

.alert-success {
  background: var(--ok-bg);
  color: var(--ok);
  border-color: rgba(18, 128, 92, 0.22);
}

.db-tools {
  margin-top: 16px;
}

.jobs-page,
#jobs-fragment {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.jobs-page[data-split-container] {
  height: 100%;
}

.jobs-page [data-split-pane] {
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 12px;
  overflow: hidden;
}

.jobs-page [data-split-handle] {
  height: 7px;
  flex: 0 0 7px;
  margin: 5px 0;
  border-radius: 999px;
  background: var(--border-strong);
  cursor: row-resize;
  touch-action: none;
}

.jobs-page [data-split-handle].dragging {
  background: var(--accent);
}

.pane-scroll {
  flex: 1 1 auto;
  min-height: 0;
}

.jobs-zoom-target {
  width: 100%;
  transform-origin: 0 0;
}

.smg-lamp-source {
  display: none;
}

.auto-refresh-control,
.job-view-toggle,
.zoom-controls {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-subtle);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 800;
}

.job-view-toggle {
  gap: 2px;
  padding: 3px;
}

.job-view-toggle button {
  min-height: 26px;
  padding: 0 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
}

.job-view-toggle button.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}

.auto-refresh-control select {
  min-height: 26px;
  width: 64px;
  padding: 2px 6px;
}

.zoom-controls button {
  width: 26px;
  min-height: 26px;
  padding: 0;
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}

.zoom-display {
  min-width: 42px;
  text-align: center;
}

.smg-workload-strip {
  display: flex;
  align-items: stretch;
  gap: 10px;
  margin: -2px 0 12px;
  min-height: 48px;
}

.workload-total,
.workload-card {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-subtle);
}

.workload-total {
  flex: 0 0 auto;
  padding: 8px 12px;
}

.workload-total strong {
  font-size: 20px;
  line-height: 1;
}

.workload-cards {
  min-width: 0;
  display: flex;
  align-items: stretch;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: thin;
}

.workload-card {
  flex: 0 0 auto;
  padding: 8px 10px;
  white-space: nowrap;
  font-size: 12px;
}

.assignment-toggle-form {
  display: inline-flex;
  margin: 0;
}

.assignment-toggle-button {
  width: 26px;
  min-width: 26px;
  height: 26px;
  min-height: 26px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 900;
  line-height: 1;
}

.assignment-toggle-button:hover {
  border-color: var(--warn);
  color: var(--warn);
}

.assignment-toggle-button.is-paused {
  border-color: var(--ok);
  color: var(--ok);
}

.workload-card.assignment-paused {
  border-color: var(--warn);
  background: var(--warn-bg);
}

.workload-paused-label {
  color: var(--warn);
  font-size: 11px;
  font-weight: 900;
}

.smg-top-lamp-chip.assignment-paused {
  border-color: var(--warn);
  opacity: 0.72;
}

.workload-card strong {
  color: var(--text);
  font-size: 18px;
  line-height: 1;
}

.workload-card.status-online .status-dot,
.job-group.status-online .status-dot {
  background: var(--ok);
}

.workload-card.status-offline .status-dot,
.job-group.status-offline .status-dot {
  background: var(--danger);
}

.workload-card.status-unknown .status-dot,
.job-group.status-unknown .status-dot {
  background: var(--warn);
}

.workload-name {
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
  font-weight: 800;
}

.workload-capacity {
  color: var(--text-muted);
  font-weight: 800;
}

.jobs-view[hidden] {
  display: none;
}

.jobs-grouped-view {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.job-group {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  overflow: hidden;
}

.job-group-header {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-subtle);
}

.job-group-header h3 {
  margin: 0;
  color: var(--text);
  font-size: 14px;
  line-height: 1.2;
}

.job-group-status {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.job-group-metrics {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 800;
}

.job-group-metrics strong {
  color: var(--text);
  font-size: 15px;
}

#jobs-fragment.is-refreshing {
  opacity: 0.58;
  pointer-events: none;
}

.status-indicator {
  width: 12px;
  height: 12px;
  margin-left: 6px;
  display: inline-block;
  border: 2px solid transparent;
  border-top-color: var(--accent);
  border-right-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

body.split-resizing {
  cursor: row-resize;
  user-select: none;
}

.history-page {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.history-fixed {
  flex: 0 0 auto;
  min-width: 0;
}

.pagination-summary {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-subtle);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.history-filters {
  padding: 14px;
  margin-bottom: 12px;
}

.history-filters .filter-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
  align-items: end;
}

.history-table-panel {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.history-table-scroll {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  overflow: auto;
}

.history-table {
  min-width: 1280px;
}

.pagination-bar {
  flex: 0 0 auto;
  min-height: 50px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 12px;
  border-top: 1px solid var(--border);
  background: var(--surface-subtle);
}

.pagination-info {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.pagination-actions {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  flex-wrap: wrap;
}

.page-link,
.page-gap {
  min-width: 32px;
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 5px 9px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 800;
  text-decoration: none;
}

.page-link {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}

.page-link:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.page-link.active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

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

.page-link.disabled:hover {
  border-color: var(--border);
  color: var(--text);
}

.page-gap {
  color: var(--text-soft);
}

.debug-log {
  margin-top: 16px;
  padding: 12px;
  border-radius: 8px;
  background: #111827;
  color: #f8fafc;
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
  max-height: 220px;
  overflow-y: auto;
}

.debug-log div {
  margin-bottom: 4px;
}

.smg-pill-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.smg-pill,
.legend-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 5px 10px;
  color: #fff;
  background: var(--text-soft);
  font-weight: 800;
}

.smg-pill.status-online,
.legend-pill.ok {
  background: var(--ok);
}

.smg-pill.status-offline,
.legend-pill.err {
  background: var(--danger);
}

.smg-pill.status-unknown {
  background: var(--warn);
}

.smg-pill.empty {
  background: transparent;
  border: 1px dashed var(--border);
  color: var(--text-soft);
}

.smg-legend {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

footer {
  display: none;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .app-sidebar {
    position: static;
    height: auto;
    padding: 10px;
  }

  .brand {
    padding-bottom: 10px;
  }

  .side-nav {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 10px;
    padding: 10px 0;
  }

  .sidebar-footer {
    display: none;
  }

  .top-bar {
    align-items: stretch;
    flex-direction: column;
  }

  .top-bar-right {
    justify-content: space-between;
  }

  .smg-top-lamps {
    max-width: 100%;
  }

  .smg-workload-strip {
    flex-direction: column;
  }

  .workload-cards {
    width: 100%;
  }

  body.page-jobs {
    height: auto;
    overflow: auto;
  }

  body.page-jobs .app-shell,
  body.page-jobs .app-main {
    height: auto;
  }

  body.page-jobs .content-area {
    overflow: visible;
  }

  body.page-history .app-shell {
    grid-template-rows: auto minmax(0, 1fr);
  }

  body.page-history .app-main {
    height: auto;
  }
}

@media (max-width: 640px) {
  .content-area {
    padding: 14px;
  }

  .page-header,
  .section-header,
  .table-header {
    flex-direction: column;
    align-items: stretch;
  }

  .section-controls {
    flex-wrap: wrap;
  }

  .job-view-toggle,
  .auto-refresh-control {
    width: 100%;
  }

  .job-view-toggle button {
    flex: 1 1 0;
  }

  .theme-switch {
    width: 100%;
  }

  .theme-switch button {
    flex: 1 1 0;
  }

  .job-group-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .pagination-bar {
    align-items: stretch;
    flex-direction: column;
  }

  .pagination-actions {
    justify-content: flex-start;
  }
}
