:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --panel-alt: #f8fafc;
  --text: #172033;
  --muted: #647084;
  --line: #dde3ea;
  --nav: #101725;
  --nav-soft: #1b2536;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --success: #16815f;
  --warning: #b7791f;
  --danger: #c2413b;
  --radius: 8px;
  --shadow: 0 18px 50px rgba(18, 28, 45, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  letter-spacing: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

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

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

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 24px 18px;
  background: var(--nav);
  color: #ecf2ff;
}

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

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: var(--radius);
  background: #ffffff;
  color: var(--nav);
  font-weight: 800;
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  margin-top: 2px;
  color: #98a6bd;
}

.nav {
  display: grid;
  gap: 6px;
}

.nav a {
  padding: 12px 12px;
  border-radius: var(--radius);
  color: #b8c4d8;
}

.nav a:hover,
.nav a.active {
  background: var(--nav-soft);
  color: #ffffff;
}

.sidebar-footer {
  margin-top: auto;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.04);
}

.sidebar-footer .label,
.eyebrow {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 24px 32px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 5;
}

.topbar h1,
.panel h2,
.detail-head h2 {
  margin: 0;
  line-height: 1.15;
}

.topbar h1 {
  font-size: 26px;
}

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

.content {
  display: grid;
  gap: 24px;
  padding: 28px 32px 48px;
}

.messages {
  display: grid;
  gap: 10px;
  padding: 16px 32px 0;
}

.message,
.form-errors,
.field-error {
  border-radius: var(--radius);
  padding: 11px 12px;
  background: #edf7f3;
  color: #0f5e47;
}

.message.error,
.form-errors,
.field-error {
  background: #fff1f0;
  color: #a1302b;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(140px, 1fr));
  gap: 14px;
}

.stat-card,
.panel,
.object-card,
.run-card,
.event-item {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.stat-card {
  padding: 18px;
}

.stat-card span {
  color: var(--muted);
}

.stat-card strong {
  display: block;
  margin-top: 10px;
  font-size: 32px;
}

.stat-card.warning strong {
  color: var(--warning);
}

.two-column,
.split-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(300px, 0.65fr);
  gap: 24px;
  align-items: start;
}

.split-layout {
  grid-template-columns: minmax(0, 1fr) minmax(330px, 420px);
}

.panel {
  padding: 20px;
  min-width: 0;
}

.panel.narrow {
  max-width: 760px;
}

.panel-header,
.detail-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  margin-bottom: 18px;
}

.detail-head {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.detail-head p {
  margin: 8px 0 0;
  color: var(--muted);
}

.site-action-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.site-action-bar h2 {
  margin: 0;
}

.action-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.action-form {
  scroll-margin-top: 110px;
}

.modal {
  width: min(680px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  padding: 0;
  overflow: hidden;
  border: 1px solid rgba(221, 227, 234, 0.9);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 28px 90px rgba(10, 18, 32, 0.28);
}

.modal[open] {
  animation: modal-enter 180ms cubic-bezier(0.2, 0.9, 0.2, 1);
}

.modal.is-closing {
  animation: modal-exit 150ms cubic-bezier(0.4, 0, 1, 1) forwards;
}

.modal::backdrop {
  background: rgba(16, 23, 37, 0.62);
  backdrop-filter: blur(4px);
}

.modal[open]::backdrop {
  animation: backdrop-enter 180ms ease-out;
}

.modal.is-closing::backdrop {
  animation: backdrop-exit 150ms ease-in forwards;
}

.modal-header,
.modal-actions {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.modal-header {
  align-items: center;
  padding: 22px 24px;
  border-bottom: 1px solid var(--line);
  background: #f8fafc;
}

.modal-header h2 {
  margin: 0;
  font-size: 22px;
}

.modal-header p {
  margin: 7px 0 0;
  color: var(--muted);
}

.modal-body {
  max-height: calc(100vh - 190px);
  overflow: auto;
  padding: 22px 24px 20px;
}

.modal-body .field {
  gap: 8px;
}

.modal-body .field label {
  color: #263247;
}

.modal-actions {
  justify-content: flex-end;
  margin: 4px -24px -20px;
  padding: 16px 24px;
  border-top: 1px solid var(--line);
  background: #f8fafc;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #ffffff;
  color: var(--muted);
  cursor: pointer;
  font-size: 24px;
  line-height: 1;
}

.icon-button:hover,
.icon-button:focus-visible {
  color: var(--text);
  border-color: #b9c4d2;
  outline: none;
}

.form-control:focus,
.login-panel input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
  outline: none;
}

@keyframes modal-enter {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes modal-exit {
  from {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  to {
    opacity: 0;
    transform: translateY(10px) scale(0.985);
  }
}

@keyframes backdrop-enter {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes backdrop-exit {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .modal[open],
  .modal.is-closing,
  .modal[open]::backdrop,
  .modal.is-closing::backdrop {
    animation: none;
  }
}

.back-link {
  display: inline-block;
  margin-bottom: 10px;
  color: var(--primary);
  font-weight: 700;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  color: var(--text);
  cursor: pointer;
  font-weight: 700;
  white-space: nowrap;
}

.button.primary {
  border-color: var(--primary);
  background: var(--primary);
  color: #ffffff;
}

.button.primary:hover {
  background: var(--primary-dark);
}

.button.ghost {
  background: transparent;
}

.button.small {
  min-height: 32px;
  padding: 0 10px;
  font-size: 13px;
}

.button.wide {
  width: 100%;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

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

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

td a {
  color: var(--primary);
  font-weight: 700;
}

.status,
.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  background: #eef2f7;
  color: #39465a;
  font-size: 12px;
  font-weight: 800;
}

.status.completed,
.status.active,
.status.ok,
.status.low {
  background: #e8f6ef;
  color: var(--success);
}

.status.running,
.status.planned,
.status.normal {
  background: #eaf1ff;
  color: var(--primary);
}

.status.late,
.status.paused,
.status.high {
  background: #fff5df;
  color: var(--warning);
}

.status.missed,
.status.issue,
.status.incident {
  background: #fff1f0;
  color: var(--danger);
}

.progress {
  width: 120px;
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e9eef5;
}

.progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
}

.list,
.checkpoint-list,
.accordion-list,
.stacked-form,
.definition-list {
  display: grid;
  gap: 12px;
}

.list-row,
.checkpoint-row,
.area-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-alt);
}

.list-row.plain {
  color: inherit;
}

.list-row small,
.checkpoint-row small,
.object-card small,
.object-card span,
.run-card p,
.event-item p,
.muted {
  display: block;
  margin-top: 4px;
  color: var(--muted);
}

.event-grid,
.object-grid,
.run-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.event-item,
.object-card,
.run-card {
  padding: 16px;
}

.event-item h3,
.run-card h3 {
  margin: 10px 0 0;
}

.run-card .progress {
  width: 100%;
  margin: 14px 0 8px;
}

.area-block {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.area-title {
  border: 0;
  border-radius: 0;
  background: #f1f5f9;
}

.checkpoint-list {
  padding: 12px;
}

.number {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: var(--nav);
  color: #ffffff;
  font-weight: 800;
}

.field {
  display: grid;
  gap: 7px;
}

.field label {
  font-weight: 750;
}

.form-control {
  width: 100%;
  min-height: 42px;
  padding: 10px 11px;
  border: 1px solid #cfd7e3;
  border-radius: var(--radius);
  background: #ffffff;
  color: var(--text);
}

textarea.form-control {
  resize: vertical;
}

.checkbox-input {
  width: 18px;
  height: 18px;
}

.choice-list {
  display: grid;
  max-height: 260px;
  overflow: auto;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-alt);
}

.choice-list label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}

.definition-list {
  grid-template-columns: 140px 1fr;
  margin: 0;
}

.definition-list dt {
  color: var(--muted);
  font-weight: 800;
}

.definition-list dd {
  margin: 0;
}

.empty {
  color: var(--muted);
  padding: 18px 0;
}

.empty.compact {
  padding: 4px 0;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: #eef2f7;
}

.login-shell {
  width: min(440px, calc(100vw - 32px));
}

.login-panel {
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  box-shadow: var(--shadow);
}

.login-brand {
  margin-bottom: 28px;
}

.login-brand .brand-mark {
  background: var(--nav);
  color: #ffffff;
}

.login-panel h1 {
  margin: 0 0 8px;
}

.login-panel input {
  width: 100%;
  min-height: 42px;
  padding: 10px 11px;
  border: 1px solid #cfd7e3;
  border-radius: var(--radius);
  background: #ffffff;
  color: var(--text);
}

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

  .two-column,
  .split-layout,
  .event-grid,
  .object-grid,
  .run-grid {
    grid-template-columns: 1fr;
  }
}

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

  .sidebar {
    position: static;
    padding: 16px;
  }

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

  .topbar {
    position: static;
    align-items: flex-start;
    flex-direction: column;
    padding: 20px;
  }

  .content,
  .messages {
    padding-left: 20px;
    padding-right: 20px;
  }

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

  .panel-header,
  .detail-head,
  .site-action-bar,
  .modal-header {
    flex-direction: column;
    align-items: stretch;
  }

  .action-buttons,
  .action-buttons .button,
  .modal-actions,
  .modal-actions .button {
    width: 100%;
  }

  .modal-actions {
    flex-direction: column-reverse;
  }
}
