:root {
  color-scheme: light;
  --bg: #f3f4f1;
  --surface: #ffffff;
  --surface-muted: #f7f8f4;
  --line: #d8ddd2;
  --text: #17201c;
  --muted: #647069;
  --green: #1f6b45;
  --green-strong: #144d32;
  --blue: #285f9f;
  --amber: #a06d18;
  --red: #ab3b33;
  --navy: #19273a;
  --gold: #d8b334;
  --ink: #111612;
  --shadow: 0 16px 40px rgba(27, 38, 49, 0.1);
  --soft-shadow: 0 8px 22px rgba(27, 38, 49, 0.06);
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background:
    linear-gradient(180deg, #eef1ed 0, #f6f7f4 220px, var(--bg) 100%);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 14px;
}

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

button {
  cursor: pointer;
}

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

.sidebar {
  background: var(--navy);
  color: #f9fbf7;
  padding: 22px 18px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  position: sticky;
  top: 0;
  height: 100vh;
  box-shadow: inset -1px 0 0 rgba(255, 255, 255, 0.08);
}

.brand {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  min-height: 48px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--gold);
  color: var(--navy);
  font-weight: 800;
}

.brand strong,
.brand span,
.sidebar-foot strong,
.sidebar-foot span {
  display: block;
}

.brand strong {
  font-size: 15px;
  line-height: 1.2;
}

.brand span,
.sidebar-foot span {
  color: #b8c7bd;
  font-size: 12px;
  margin-top: 3px;
}

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

.nav-item {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  padding: 0 12px;
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  color: #dfe8e1;
  background: transparent;
  text-align: left;
  transition: background 140ms ease, color 140ms ease, transform 140ms ease;
}

.nav-item:hover,
.nav-item.is-active {
  background: rgba(255, 255, 255, 0.11);
}

.nav-item.is-active {
  color: #ffffff;
  box-shadow: inset 3px 0 0 var(--gold);
}

.sidebar-foot {
  margin-top: auto;
  min-height: 58px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  padding: 12px;
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #e4c33b;
}

.status-dot.is-online {
  background: #42c178;
}

.status-dot.is-error {
  background: #e45b52;
}

.main {
  min-width: 0;
  padding: 22px 24px 32px;
}

.topbar {
  min-height: 86px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 14px;
  padding: 0 2px;
}

.title-block {
  min-width: 0;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 28px;
  line-height: 1.1;
}

.view-subtitle {
  margin: 7px 0 0;
  max-width: 720px;
  color: var(--muted);
}

h2 {
  font-size: 20px;
  margin-bottom: 14px;
}

h3 {
  font-size: 15px;
  margin-bottom: 10px;
}

.topbar-actions,
.row-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.period-pill {
  min-height: 32px;
  border-radius: 999px;
  display: inline-grid;
  place-items: center;
  padding: 0 12px;
  background: #fff3ca;
  color: #6c4a08;
  border: 1px solid #ead58d;
  font-weight: 700;
}

.period-pill.is-closed {
  background: #e6edf7;
  border-color: #c9d8ec;
  color: var(--blue);
}

.button,
.icon-button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  display: inline-grid;
  grid-auto-flow: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--soft-shadow);
}

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

.button.secondary {
  background: #f5f7f3;
}

.button.danger {
  background: #f7e8e6;
  border-color: #efc6c1;
  color: var(--red);
}

.icon-button {
  width: 38px;
  padding: 0;
}

.button:hover,
.icon-button:hover {
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}

.toolbar {
  min-height: 74px;
  display: grid;
  grid-template-columns: 240px minmax(240px, 1fr) 180px 170px;
  gap: 10px;
  align-items: center;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 16px;
  box-shadow: var(--soft-shadow);
}

.toolbar.is-hidden {
  display: none;
}

.toolbar-title {
  display: grid;
  gap: 4px;
}

.toolbar-title strong {
  font-size: 13px;
}

.toolbar-title span {
  color: var(--muted);
  font-size: 12px;
}

.search-field,
.select-field,
.field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.search-field {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-muted);
  grid-template-columns: 20px minmax(0, 1fr);
  align-items: center;
  padding: 0 12px;
}

.search-field input {
  border: 0;
  outline: 0;
  min-width: 0;
  background: transparent;
  color: var(--text);
}

.select-field select,
.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-muted);
  color: var(--text);
  padding: 0 10px;
}

.field textarea {
  min-height: 92px;
  resize: vertical;
  padding: 10px;
}

.view {
  display: grid;
  gap: 18px;
}

.process-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 10px;
}

.process-step {
  min-height: 76px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 12px;
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 4px 8px;
  align-items: center;
  box-shadow: var(--soft-shadow);
}

.process-step strong {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #ffffff;
  background: var(--green);
  grid-row: span 2;
}

.process-step span {
  font-weight: 700;
}

.process-step small {
  color: var(--muted);
}

.process-step.attention strong {
  background: var(--amber);
}

.process-step.critical strong {
  background: var(--red);
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(150px, 1fr));
  gap: 10px;
}

.kpi {
  min-height: 104px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 14px 12px;
  display: grid;
  align-content: space-between;
  box-shadow: var(--soft-shadow);
  position: relative;
  overflow: hidden;
}

.kpi::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--green);
}

.kpi span {
  color: var(--muted);
  font-size: 12px;
}

.kpi strong {
  font-size: 21px;
  letter-spacing: 0;
}

.kpi small {
  color: var(--muted);
}

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

.model-card {
  min-height: 132px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  display: grid;
  gap: 6px;
  align-content: start;
  background: var(--surface-muted);
}

.model-card strong,
.model-card span,
.model-card small,
.model-card p {
  min-width: 0;
}

.model-card strong {
  color: var(--text);
}

.model-card span {
  color: var(--green-strong);
  font-size: 12px;
  font-weight: 700;
}

.model-card small {
  color: var(--muted);
  line-height: 1.35;
}

.model-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.35;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  box-shadow: var(--soft-shadow);
}

.panel-heading {
  margin-bottom: 14px;
}

.panel-heading h2 {
  margin: 0 auto 0 0;
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 0.42fr);
  gap: 16px;
  align-items: start;
}

.summary-list,
.check-list,
.schema-list,
.timeline {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.summary-list li,
.check-list li,
.schema-list li,
.timeline li {
  min-height: 38px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  padding: 8px 0;
}

.timeline li {
  grid-template-columns: 120px minmax(0, 1fr);
}

.summary-list li:last-child,
.check-list li:last-child,
.schema-list li:last-child,
.timeline li:last-child {
  border-bottom: 0;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  max-height: min(66vh, 720px);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 980px;
}

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

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #eef1ec;
  color: #39453e;
  font-size: 12px;
  text-transform: uppercase;
}

td {
  background: var(--surface);
}

tr:hover td {
  background: #fbfcfa;
}

tr.is-selected td {
  background: #eef5ed;
  box-shadow: inset 3px 0 0 var(--green);
}

.money {
  text-align: right;
  white-space: nowrap;
}

.name-cell {
  min-width: 240px;
}

.muted {
  color: var(--muted);
}

.pill {
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 9px;
  display: inline-grid;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.pill.ok {
  color: var(--green-strong);
  background: #dff1e4;
}

.pill.exception {
  color: var(--blue);
  background: #e3eef9;
}

.pill.attention {
  color: var(--amber);
  background: #fff1d6;
}

.pill.critical {
  color: var(--red);
  background: #f9dedb;
}

.bars {
  display: grid;
  gap: 12px;
}

.bar-row {
  display: grid;
  grid-template-columns: 140px minmax(0, 1fr) 110px;
  gap: 12px;
  align-items: center;
}

.bar-track {
  height: 10px;
  border-radius: 999px;
  background: #e8eee6;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: var(--green);
}

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

.field.full {
  grid-column: 1 / -1;
}

.span-2 {
  grid-column: span 2;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(12, 18, 16, 0.62);
  backdrop-filter: blur(2px);
}

.modal {
  width: min(980px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  overflow: auto;
  background: var(--surface);
  border: 1px solid #c7cec4;
  border-radius: 8px;
  box-shadow: 0 28px 70px rgba(10, 18, 15, 0.34);
}

.modal-header {
  position: sticky;
  top: 0;
  z-index: 2;
  min-height: 78px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  background: #f8faf6;
  border-bottom: 1px solid var(--line);
}

.modal-title {
  min-width: 0;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
}

.modal-icon {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: #e9f2e8;
  color: var(--green);
}

.modal-title h2 {
  margin: 0;
}

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

.modal-form {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  padding: 16px;
}

.form-section {
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.form-section:first-of-type {
  padding-top: 0;
  border-top: 0;
}

.form-section h3 {
  margin: 0;
  color: #35433b;
  text-transform: uppercase;
  font-size: 12px;
}

.summary-list.compact li {
  min-height: 32px;
  padding: 6px 0;
}

.modal-actions {
  position: sticky;
  bottom: 0;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin: 0 -16px -16px;
  padding: 12px 16px 16px;
  background: #f8faf6;
  border-top: 1px solid var(--line);
}

.empty {
  min-height: 180px;
  display: grid;
  place-items: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  min-width: 230px;
  max-width: 360px;
  min-height: 42px;
  border-radius: 8px;
  background: #17231d;
  color: #ffffff;
  padding: 12px 14px;
  box-shadow: var(--shadow);
  transform: translateY(90px);
  opacity: 0;
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.is-visible {
  transform: translateY(0);
  opacity: 1;
}

svg.icon {
  width: 18px;
  height: 18px;
  display: block;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

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

  .sidebar {
    position: static;
    height: auto;
    padding: 14px;
  }

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

  .sidebar-foot {
    display: none;
  }

  .split,
  .toolbar {
    grid-template-columns: 1fr;
  }

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

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

  .kpi-grid {
    grid-template-columns: repeat(2, minmax(150px, 1fr));
  }

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

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

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-actions {
    justify-content: flex-start;
    width: 100%;
  }

  .nav-list {
    grid-template-columns: 1fr;
  }

  .process-strip,
  .kpi-grid,
  .model-grid,
  .detail-form,
  .modal-form {
    grid-template-columns: 1fr;
  }

  .span-2 {
    grid-column: 1 / -1;
  }

  .modal-backdrop {
    align-items: start;
    padding: 10px;
  }

  .modal {
    width: 100%;
    max-height: calc(100vh - 20px);
  }

  .modal-header {
    align-items: flex-start;
    padding: 14px;
  }

  .modal-title {
    grid-template-columns: 36px minmax(0, 1fr);
  }

  .modal-icon {
    width: 36px;
    height: 36px;
  }

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

  h1 {
    font-size: 22px;
  }
}
