:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-soft: #f2f6f9;
  --line: #dce3ea;
  --text: #1e2933;
  --muted: #667789;
  --graphite: #505252;
  --graphite-dark: #071827;
  --cyan: #0984e3;
  --cyan-soft: #e4f3ff;
  --green: #1f8a5b;
  --green-soft: #e5f5ee;
  --amber: #b7791f;
  --amber-soft: #fff4dc;
  --red: #c84646;
  --red-soft: #fae7e7;
  --blue: #2764a7;
  --blue-soft: #e6f0fb;
  --shadow: 0 1px 2px rgba(16, 34, 48, 0.04);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

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

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 22px 18px;
  background: linear-gradient(180deg, #071827 0%, #0b2230 100%);
  color: #f7fbfc;
}

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

.brand img {
  width: 64px;
  height: auto;
  display: block;
  filter: brightness(0) invert(1);
}

.brand strong {
  display: block;
  font-size: 21px;
  line-height: 1.05;
}

.brand span {
  display: block;
  color: #c7d4da;
  font-size: 12px;
  margin-top: 4px;
}

.main-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 38px;
  padding: 0 11px;
  color: #e7eef1;
  background: transparent;
  border: 0;
  border-radius: var(--radius);
  text-align: left;
}

.nav-item:hover,
.nav-item.active {
  background: rgba(9, 132, 227, 0.92);
}

.nav-item.active {
  color: #ffffff;
}

.nav-icon {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  color: #b7c8d4;
  font-size: 15px;
  line-height: 1;
}

.nav-icon::before {
  content: "";
}

.nav-item[data-view="dashboard"] .nav-icon::before {
  content: "⌂";
}

.nav-item[data-view="contract"] .nav-icon::before {
  content: "▤";
}

.nav-item[data-view="equipment"] .nav-icon::before {
  content: "▦";
}

.nav-item[data-view="watch"] .nav-icon::before {
  content: "◈";
}

.nav-item[data-view="interventions"] .nav-icon::before {
  content: "✓";
}

.nav-item[data-view="reports"] .nav-icon::before {
  content: "▧";
}

.nav-item[data-view="admin"] .nav-icon::before {
  content: "◌";
}

.nav-item.active .nav-icon {
  color: #ffffff;
}

.sidebar-note {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: auto;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--radius);
  color: #dce8ec;
  font-size: 12px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--cyan);
  flex: 0 0 auto;
}

.workspace {
  min-width: 0;
  padding: 22px 26px 34px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-start;
  margin: -22px -26px 16px;
  padding: 18px 26px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

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

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

h1 {
  margin-bottom: 0;
  color: var(--graphite-dark);
  font-size: 26px;
  line-height: 1.12;
}

h2 {
  margin-bottom: 8px;
  color: var(--graphite-dark);
  font-size: 20px;
  line-height: 1.2;
}

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

.topbar-controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.field {
  display: grid;
  gap: 5px;
  min-width: 180px;
}

.field.small {
  min-width: 132px;
}

.field.full {
  min-width: 100%;
}

.field.is-hidden,
[hidden] {
  display: none !important;
}

.field span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

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

select:disabled,
button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.primary-action,
.ghost-action,
.subtle-action {
  min-height: 38px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  padding: 0 13px;
  font-weight: 700;
}

.primary-action {
  color: #ffffff;
  background: var(--cyan);
  align-self: end;
}

.primary-action:hover {
  background: #0674c9;
}

.ghost-action {
  color: var(--graphite-dark);
  background: var(--surface);
  border-color: var(--line);
}

.subtle-action {
  color: var(--blue);
  background: var(--blue-soft);
}

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

.context-strip {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  margin-bottom: 18px;
  color: var(--graphite-dark);
  background: #f8fbfd;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

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

.context-strip strong {
  color: var(--text);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.grid {
  display: grid;
  gap: 14px;
}

.grid.two {
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.65fr);
}

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

.surface {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--line);
}

.section-head p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.45;
}

.section-body {
  padding: 16px 18px 18px;
}

.kpi-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  margin-bottom: 14px;
}

.kpi {
  min-height: 92px;
  padding: 15px;
  background: var(--surface);
  border-right: 1px solid var(--line);
}

.kpi-button {
  display: block;
  width: 100%;
  border-top: 0;
  border-bottom: 0;
  border-left: 0;
  border-radius: 0;
  color: inherit;
  text-align: left;
}

.kpi-button:hover {
  background: #f8fbfd;
}

.kpi:last-child {
  border-right: 0;
}

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

.kpi strong {
  display: block;
  margin-top: 7px;
  font-size: 25px;
  line-height: 1;
  color: var(--graphite-dark);
}

.kpi em {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.contract-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(330px, 0.75fr);
  gap: 14px;
  margin-bottom: 14px;
}

.client-summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: start;
}

.summary-title {
  margin-bottom: 8px;
  font-size: 22px;
}

.summary-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
}

.badge,
.chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 9px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.badge.cyan {
  color: #087a9b;
  background: var(--cyan-soft);
}

.badge.green,
.chip.low,
.chip.done {
  color: var(--green);
  background: var(--green-soft);
}

.badge.amber,
.chip.medium,
.chip.waiting {
  color: var(--amber);
  background: var(--amber-soft);
}

.badge.red,
.chip.high,
.chip.critical {
  color: var(--red);
  background: var(--red-soft);
}

.badge.blue,
.chip.info {
  color: var(--blue);
  background: var(--blue-soft);
}

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

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

.metric-row span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.metric-row strong {
  font-size: 15px;
}

.progress {
  grid-column: 1 / -1;
  height: 8px;
  overflow: hidden;
  background: #e5ebef;
  border-radius: 999px;
}

.progress > i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--cyan);
}

.progress.warning > i {
  background: var(--amber);
}

.progress.danger > i {
  background: var(--red);
}

.segmented {
  display: inline-grid;
  grid-auto-flow: column;
  gap: 2px;
  padding: 3px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.segmented button {
  min-height: 30px;
  padding: 0 10px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 6px;
  font-weight: 700;
}

.segmented button.active {
  color: var(--graphite-dark);
  background: var(--surface);
}

.facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--line);
}

.fact {
  min-height: 84px;
  padding: 13px;
  background: var(--surface);
}

.fact span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.fact strong {
  display: block;
  color: var(--graphite-dark);
  font-size: 16px;
}

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

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

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

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

tbody tr:hover {
  background: #f8fbfc;
}

.row-title {
  display: grid;
  gap: 3px;
}

.row-title strong {
  color: var(--graphite-dark);
}

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

.doc-grid {
  display: grid;
  gap: 1px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--line);
  overflow: hidden;
}

.doc-row {
  display: grid;
  grid-template-columns: minmax(260px, 1.2fr) 140px minmax(170px, 0.8fr) 130px 110px;
  gap: 14px;
  align-items: center;
  padding: 13px 14px;
  background: var(--surface);
}

.doc-row.header {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  background: #f8fbfc;
}

.doc-row:not(.header):hover {
  background: #fbfdfe;
}

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

.timeline-item {
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}

.timeline-dot {
  width: 9px;
  height: 9px;
  margin-top: 5px;
  border-radius: 50%;
  background: var(--cyan);
}

.timeline-item p {
  margin: 2px 0 0;
  color: var(--muted);
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: end;
  margin-bottom: 14px;
}

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

.link-button {
  color: var(--cyan);
  background: transparent;
  border: 0;
  padding: 0;
  font-weight: 800;
  text-align: left;
}

.link-button:hover {
  text-decoration: underline;
}

.source-list {
  display: grid;
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--line);
}

.source-form {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
  padding: 12px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.source-form[hidden] {
  display: none;
}

.compact-table {
  min-width: 680px;
}

.source-item {
  display: grid;
  gap: 4px;
  padding: 12px;
  color: var(--text);
  background: var(--surface);
  text-decoration: none;
}

.source-item:hover {
  background: #f8fbfd;
}

.source-item strong {
  color: var(--cyan);
}

.source-item span {
  color: var(--muted);
}

.row-menu {
  min-width: 150px;
}

.empty-note {
  padding: 18px;
  color: var(--muted);
  background: var(--surface-soft);
  border: 1px dashed #b8cbd3;
  border-radius: var(--radius);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(24, 31, 36, 0.42);
  z-index: 20;
}

.modal-backdrop[hidden] {
  display: none;
}

.modal {
  width: min(560px, 100%);
  padding: 18px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 24px 80px rgba(20, 31, 36, 0.25);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.drop-zone {
  display: grid;
  place-items: center;
  gap: 5px;
  min-height: 112px;
  margin: 14px 0;
  color: var(--muted);
  background: var(--surface-soft);
  border: 1px dashed #9fb9c4;
  border-radius: var(--radius);
  text-align: center;
}

.drop-zone strong {
  color: var(--graphite-dark);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.notice {
  color: var(--blue);
  background: var(--blue-soft);
  border: 1px solid #bfd9f0;
  border-radius: var(--radius);
  padding: 12px;
}

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

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 10;
    padding: 14px;
  }

  .brand {
    grid-template-columns: 58px minmax(0, 1fr);
  }

  .brand img {
    width: 58px;
  }

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

  .sidebar-note {
    display: none;
  }

  .topbar,
  .contract-hero,
  .grid.two {
    grid-template-columns: 1fr;
    display: grid;
  }

  .topbar-controls {
    justify-content: start;
  }

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

@media (max-width: 720px) {
  .workspace {
    padding: 16px;
  }

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

  .nav-item {
    min-height: 34px;
  }

  .topbar-controls,
  .field,
  .field.small,
  .primary-action,
  .ghost-action {
    width: 100%;
  }

  .kpi-strip,
  .facts,
  .grid.three {
    grid-template-columns: 1fr;
  }

  .client-summary {
    grid-template-columns: 1fr;
  }

  .doc-row,
  .doc-row.header {
    grid-template-columns: 1fr;
  }

  .doc-row.header {
    display: none;
  }
}
