:root {
  --bg: #0f1318;
  --bg-elevated: #151b22;
  --bg-soft: #1a222b;
  --line: #283341;
  --line-strong: #334155;
  --text: #d8dee7;
  --text-muted: #8d99a8;
  --accent: #5fa8ff;
  --accent-soft: rgba(95, 168, 255, 0.14);
  --success: #45b780;
  --success-soft: rgba(69, 183, 128, 0.16);
  --danger: #e27070;
  --danger-soft: rgba(226, 112, 112, 0.16);
  --warning: #d1a85f;
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.22);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: dark;
}

body {
  margin: 0;
  min-height: 100vh;
  font: 12px/1.35 "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top right, rgba(95, 168, 255, 0.07), transparent 22%),
    linear-gradient(180deg, #0c1014 0%, #10151b 100%);
}

a {
  color: inherit;
}

.app-shell {
  padding: 10px 12px;
}

.shell-layout {
  width: min(1880px, calc(100vw - 24px));
  min-height: calc(100vh - 20px);
  margin: 0 auto;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 8px;
}

.shell-header,
.shell-footer,
.panel {
  border: 1px solid var(--line);
  background: var(--bg-elevated);
  box-shadow: var(--shadow);
}

.shell-header {
  display: grid;
  grid-template-columns: minmax(220px, 320px) minmax(260px, 420px) 1fr;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
}

.brand-block h1,
.section-heading h3,
.page-banner-title h2,
.docs-sidebar h3 {
  margin: 0;
}

.eyebrow {
  margin: 0 0 4px;
  font-size: 9px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.shell-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.header-metrics {
  display: flex;
  align-items: stretch;
  justify-content: center;
  gap: 6px;
  min-width: 0;
  min-height: 26px;
}

.header-metrics--empty {
  visibility: hidden;
  pointer-events: none;
}

.header-metric {
  display: grid;
  grid-template-columns: auto auto;
  align-items: baseline;
  gap: 5px;
  min-height: 26px;
  padding: 0 8px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  border-radius: 4px;
  white-space: nowrap;
}

.header-metric-label {
  color: var(--text-muted);
  font-size: 10px;
}

.header-metric strong {
  font-size: 12px;
  font-weight: 600;
}

.shell-nav a {
  text-decoration: none;
  color: var(--text-muted);
  padding: 4px 7px;
  border: 1px solid transparent;
  border-radius: 4px;
  font-size: 11px;
}

.shell-nav a:hover,
.shell-nav a.is-active {
  color: var(--text);
  border-color: var(--line-strong);
  background: var(--bg-soft);
}

.shell-main {
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.shell-footer {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 10px;
  color: var(--text-muted);
  font-size: 10px;
}

.page-grid,
.settings-grid,
.docs-grid {
  display: grid;
  gap: 8px;
}

.page-grid {
  grid-template-columns: 1fr;
}

.panel {
  border-radius: var(--radius);
  padding: 10px 12px;
}

.page-banner {
  display: grid;
  gap: 8px;
}

.page-banner-row {
  display: grid;
  grid-template-columns: minmax(360px, auto) minmax(320px, 1fr);
  gap: 10px;
  align-items: center;
}

.page-banner-title {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.section-tag {
  display: inline-flex;
  align-items: center;
  height: 18px;
  padding: 0 6px;
  border: 1px solid var(--line-strong);
  background: var(--bg-soft);
  color: var(--text-muted);
  border-radius: 3px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.page-banner-text,
.section-hint {
  color: var(--text-muted);
  margin: 0;
  text-align: right;
  font-size: 11px;
}

.metric-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.metric-card {
  padding: 8px 9px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  border-radius: 4px;
}

.metric-card strong {
  display: block;
  margin-top: 2px;
  font-size: 14px;
  font-weight: 600;
}

.metric-label {
  color: var(--text-muted);
  font-size: 10px;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 8px;
}

.section-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 6px;
}

.compact-input {
  min-height: 24px;
  padding: 0 8px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--text);
  border-radius: 4px;
  font: inherit;
}

.compact-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(95, 168, 255, 0.18);
}

.table-panel {
  overflow: hidden;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.data-table-completed {
  table-layout: auto;
}

.data-table-completed .col-index {
  width: 36px;
}

.data-table-completed .col-file {
  width: 280px;
}

.data-table-completed .col-id {
  width: 320px;
}

.data-table-completed .col-status {
  width: 92px;
}

.data-table-completed .col-points {
  width: 72px;
}

.data-table-completed .col-progress {
  width: 170px;
}

.data-table-completed .col-area {
  width: 130px;
}

.data-table-completed .col-duration {
  width: 128px;
}

.data-table-completed .col-finished {
  width: 160px;
}

.data-table-completed .col-actions {
  width: 180px;
}

.data-table th,
.data-table td {
  padding: 6px 7px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 11px;
}

.data-table th {
  color: var(--text-muted);
  font-weight: 600;
}

.mono-cell {
  font-family: "Consolas", "SFMono-Regular", monospace;
  font-size: 10px;
  color: #c3d0dd;
  word-break: break-all;
}

.data-table-completed .mono-cell {
  word-break: normal;
  overflow-wrap: normal;
  white-space: nowrap;
}

.data-table-catalog {
  table-layout: auto;
}

.table-subtext {
  color: var(--text-muted);
  font-size: 10px;
}

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

.datetime-cell {
  white-space: nowrap;
}

.duration-cell {
  white-space: nowrap;
  color: var(--text-muted);
}

.data-table-completed td {
  padding-right: 10px;
}

.data-table-completed .cell-file {
  min-width: 220px;
  max-width: 320px;
  overflow-wrap: anywhere;
}

.data-table-completed .cell-error {
  min-width: 220px;
  max-width: 420px;
  color: var(--text-muted);
  overflow-wrap: anywhere;
}

.table-empty {
  text-align: center;
  color: var(--text-muted);
  padding: 10px 8px;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 18px;
  padding: 0 6px;
  border-radius: 3px;
  border: 1px solid transparent;
  font-size: 10px;
  font-weight: 600;
}

.status.pending {
  color: var(--warning);
  background: rgba(209, 168, 95, 0.12);
  border-color: rgba(209, 168, 95, 0.2);
}

.status.running,
.status.succeeded {
  color: var(--success);
  background: var(--success-soft);
  border-color: rgba(69, 183, 128, 0.2);
}

.status.running {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: rgba(95, 168, 255, 0.2);
}

.status.failed {
  color: var(--danger);
  background: var(--danger-soft);
  border-color: rgba(226, 112, 112, 0.22);
}

.status.partial {
  color: var(--warning);
  background: rgba(209, 168, 95, 0.12);
  border-color: rgba(209, 168, 95, 0.2);
}

.status.partial_running,
.status.partial_failed {
  color: var(--warning);
  background: rgba(209, 168, 95, 0.12);
  border-color: rgba(209, 168, 95, 0.2);
}

.progress-cell {
  min-width: 150px;
}

.progress-text {
  margin-bottom: 4px;
  color: var(--text-muted);
  font-size: 10px;
  white-space: nowrap;
}

.progress-bar {
  height: 6px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  border-radius: 99px;
  overflow: hidden;
}

.progress-bar span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #4d8cff 0%, #45b780 100%);
}

.status.free {
  color: var(--success);
  background: var(--success-soft);
  border-color: rgba(69, 183, 128, 0.2);
}

.status.busy {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: rgba(95, 168, 255, 0.2);
}

.status.paused {
  color: var(--warning);
  background: rgba(209, 168, 95, 0.12);
  border-color: rgba(209, 168, 95, 0.2);
}

.status.offline {
  color: var(--danger);
  background: var(--danger-soft);
  border-color: rgba(226, 112, 112, 0.22);
}

.status.starting {
  color: #b9c0ca;
  background: rgba(185, 192, 202, 0.08);
  border-color: rgba(185, 192, 202, 0.18);
}

.settings-panel {
  min-height: 100%;
}

.catalog-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.catalog-panel {
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
}

.catalog-form {
  margin-bottom: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg-soft);
}

.catalog-form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 8px;
}

.catalog-form label {
  display: grid;
  gap: 4px;
}

.catalog-form label > span {
  color: var(--text-muted);
  font-size: 10px;
}

.catalog-field-wide {
  grid-column: span 2;
}

.catalog-checkbox {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 24px;
  padding-top: 16px;
}

.catalog-checkbox input {
  margin: 0;
}

.catalog-table-wrap {
  min-height: 0;
  overflow: auto;
}

.settings-card-list {
  display: grid;
  gap: 12px;
}

.settings-form-shell {
  display: grid;
  gap: 12px;
}

.settings-toolbar {
  grid-column: 1 / -1;
}

.settings-card {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg-soft);
}

.settings-card-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 8px;
}

.settings-card-head h4 {
  margin: 0;
  font-size: 14px;
}

.settings-value {
  color: var(--accent);
  font-size: 12px;
  white-space: nowrap;
}

.settings-description,
.settings-details {
  margin: 0;
  color: var(--text-muted);
}

.settings-input-wrap {
  margin-bottom: 8px;
}

.settings-input {
  width: 100%;
  min-height: 26px;
  padding: 0 8px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: #0f141a;
  color: var(--text);
  font: inherit;
}

.settings-input:focus {
  outline: none;
  border-color: var(--accent);
}

.settings-details {
  margin-top: 6px;
}

.settings-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.settings-list {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 10px 14px;
  margin: 0;
}

.settings-list dt {
  color: var(--text-muted);
}

.settings-list dd {
  margin: 0;
  word-break: break-word;
}

.docs-grid {
  grid-template-columns: 220px minmax(0, 1fr);
  align-items: start;
}

.docs-sidebar {
  position: sticky;
  top: 10px;
}

.docs-nav {
  display: grid;
  gap: 6px;
  margin-top: 8px;
}

.docs-nav a {
  text-decoration: none;
  color: var(--text-muted);
  padding: 5px 6px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--bg-soft);
  font-size: 11px;
}

.docs-nav a:hover {
  color: var(--text);
  border-color: var(--line-strong);
}

.docs-content {
  display: grid;
  gap: 8px;
}

.docs-content .panel {
  scroll-margin-top: 18px;
}

.docs-page {
  display: flex;
  min-height: 100%;
  position: relative;
  border: 1px solid var(--line);
  background: var(--bg-elevated);
  box-shadow: var(--shadow);
}

.docs-page-sidebar {
  width: 260px;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  align-self: flex-start;
  height: calc(100vh - 132px);
  overflow-y: auto;
  border-right: 1px solid var(--line);
  background: #121821;
}

.docs-page-sidebar-inner {
  padding: 16px 0;
}

.docs-page-toc-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 0 14px 10px;
}

.docs-page-toc {
  display: flex;
  flex-direction: column;
}

.docs-page-toc-item {
  display: block;
  padding: 4px 14px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 12px;
  border-left: 2px solid transparent;
  line-height: 1.35;
}

.docs-page-toc-item:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.03);
}

.docs-page-toc-item.is-active {
  color: var(--accent);
  border-left-color: var(--accent);
  background: rgba(95, 168, 255, 0.08);
}

.docs-page-toc-h1 {
  font-weight: 600;
}

.docs-page-toc-h2 {
  padding-left: 22px;
}

.docs-page-toc-h3 {
  padding-left: 34px;
  font-size: 11px;
}

.docs-page-sidebar-toggle {
  display: none;
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 40;
  width: 42px;
  height: 42px;
  border: none;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.docs-page-main {
  flex: 1;
  min-width: 0;
  padding: 28px 34px 64px;
}

.docs-page-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 28px;
}

.docs-page-title-block h2,
.docs-page-title-block p {
  margin: 0;
}

.docs-page-kicker {
  margin-bottom: 6px;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.docs-page-title-block h2 {
  font-size: 26px;
  line-height: 1.1;
}

.docs-page-title-block p {
  margin-top: 8px;
  color: var(--text-muted);
  max-width: 760px;
}

.docs-page-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.docs-page-content {
  max-width: 920px;
}

.docs-page-loading {
  color: var(--text-muted);
  padding: 30px 0;
}

.docs-page-error {
  padding: 14px 16px;
  color: #ffb4b4;
  border: 1px solid rgba(226, 112, 112, 0.28);
  background: rgba(226, 112, 112, 0.08);
  border-radius: 6px;
}

.docs-page-content h1 {
  font-size: 28px;
  font-weight: 700;
  margin: 0 0 10px;
}

.docs-page-content h2 {
  font-size: 20px;
  font-weight: 600;
  margin: 42px 0 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
  scroll-margin-top: 16px;
}

.docs-page-content h3 {
  font-size: 16px;
  font-weight: 600;
  margin: 28px 0 10px;
  scroll-margin-top: 16px;
}

.docs-page-content h4 {
  font-size: 13px;
  font-weight: 600;
  margin: 24px 0 8px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.docs-page-content p {
  margin: 0 0 14px;
}

.docs-page-content ul,
.docs-page-content ol {
  margin: 0 0 14px 20px;
}

.docs-page-content li {
  margin-bottom: 4px;
}

.docs-page-content a {
  color: var(--accent);
  text-decoration: none;
}

.docs-page-content a:hover {
  text-decoration: underline;
}

.docs-page-content hr {
  border: none;
  border-top: 1px solid var(--line);
  margin: 28px 0;
}

.docs-page-content blockquote {
  margin: 0 0 14px;
  padding: 12px 16px;
  border-left: 3px solid var(--accent);
  background: var(--bg-soft);
  border-radius: 0 6px 6px 0;
  color: var(--text-muted);
}

.docs-page-content code {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1px 5px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 12px;
  color: #ff9aa5;
}

.docs-page-content pre {
  margin: 0 0 18px;
  border-radius: 6px;
  border: 1px solid var(--line);
  overflow-x: auto;
  position: relative;
}

.docs-page-content pre code {
  display: block;
  padding: 16px 18px;
  border: none;
  border-radius: 0;
  background: transparent;
  color: inherit;
}

.docs-page-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 18px;
  font-size: 12px;
}

.docs-page-content th {
  background: var(--bg-soft);
  font-weight: 600;
  text-align: left;
  padding: 8px 12px;
  border: 1px solid var(--line);
  color: var(--text-muted);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.docs-page-content td {
  padding: 8px 12px;
  border: 1px solid var(--line);
  vertical-align: top;
}

.docs-page-content tr:nth-child(even) td {
  background: rgba(255, 255, 255, 0.02);
}

.prose {
  overflow: hidden;
}

.prose h1,
.prose h2,
.prose h3 {
  color: var(--text);
}

.prose p,
.prose li,
.prose td,
.prose th {
  color: #c8d0db;
  font-size: 11px;
}

.prose pre {
  overflow-x: auto;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #0b0f13;
}

.prose code {
  font-family: "Consolas", "SFMono-Regular", monospace;
  font-size: 10px;
}

.action-button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 0 8px;
  border: 1px solid var(--line-strong);
  background: var(--bg-soft);
  color: var(--text);
  border-radius: 4px;
  font: inherit;
  cursor: pointer;
}

.icon-action-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid var(--line-strong);
  background: var(--bg-soft);
  color: var(--text);
  border-radius: 4px;
  cursor: pointer;
  flex: 0 0 auto;
}

.icon-action-button:hover {
  border-color: var(--accent);
  color: #f4f7fb;
}

.icon-action-button svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.action-button:hover,
.icon-button:hover {
  border-color: var(--accent);
  color: #f4f7fb;
}

.action-button-danger {
  color: var(--danger);
  border-color: rgba(226, 112, 112, 0.28);
  background: rgba(226, 112, 112, 0.08);
}

.action-button-danger:hover {
  border-color: var(--danger);
  color: #ffe8e8;
  background: rgba(226, 112, 112, 0.16);
}

.modal-shell {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: stretch;
  justify-content: center;
}

.modal-shell.is-hidden {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 7, 10, 0.76);
}

.modal-panel {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: min(1640px, calc(100vw - 24px));
  min-height: 0;
  height: calc(100vh - 24px);
  margin: 12px;
  border: 1px solid var(--line);
  background: var(--bg-elevated);
  box-shadow: var(--shadow);
}

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

.modal-header-main {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.modal-header-main h3,
.modal-subtitle {
  margin: 0;
}

.modal-subtitle {
  color: var(--text-muted);
}

.modal-body {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  min-height: 0;
}

@media (max-width: 1280px) {
  .catalog-grid {
    grid-template-columns: 1fr;
  }

  .catalog-form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .docs-page-main {
    padding: 24px 24px 52px;
  }
}

@media (max-width: 900px) {
  .docs-page-sidebar {
    position: fixed;
    top: 76px;
    left: 0;
    height: calc(100vh - 76px);
    z-index: 30;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: var(--shadow);
  }

  .docs-page-sidebar.is-open {
    transform: translateX(0);
  }

  .docs-page-sidebar-toggle {
    display: block;
  }

  .docs-page-main {
    padding: 20px 18px 64px;
  }

  .docs-page-head {
    flex-direction: column;
  }
}

.map-sidepanel {
  padding: 10px 12px;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.01);
  overflow: auto;
}

.map-meta {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 8px 10px;
  margin: 0;
}

.map-meta dt {
  color: var(--text-muted);
}

.map-meta dd {
  margin: 0;
  word-break: break-word;
}

.map-canvas-wrap {
  display: block;
  min-height: 0;
}

.map-canvas {
  width: 100%;
  height: 100%;
  min-height: 0;
}

.leaflet-container {
  background: #0f1318;
  font: inherit;
}

@media (max-width: 1180px) {
  .shell-header,
  .page-banner-row,
  .settings-grid,
  .docs-grid {
    grid-template-columns: 1fr;
  }

  .shell-nav {
    justify-content: flex-start;
  }

  .header-metrics {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .page-banner-text {
    text-align: left;
  }
}

@media (max-width: 860px) {
  .app-shell {
    padding: 8px;
  }

  .shell-layout {
    width: 100%;
    min-height: calc(100vh - 16px);
  }

  .metric-strip,
  .settings-list {
    grid-template-columns: 1fr;
  }

  .shell-footer,
  .section-heading {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (max-width: 980px) {
  .modal-panel {
    width: calc(100vw - 16px);
    height: calc(100vh - 16px);
    margin: 8px;
  }

  .modal-body {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
  }

  .map-sidepanel {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
}
