:root {
  --ink: #102a43;
  --paper: #f5f7fa;
  --line: #d9e2ec;
  --red: #d64545;
  --teal: #56a3a6;
  --yellow: #d7a84e;
  --white: #ffffff;
  --muted: #627d98;
  --shadow: 0 24px 80px rgba(16, 42, 67, 0.16);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: "Arial Narrow", "Roboto Condensed", "Segoe UI", Arial, sans-serif;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(90deg, rgba(16, 42, 67, 0.035) 1px, transparent 1px) 0 0 / 36px 36px,
    linear-gradient(180deg, #f5f7fa 0%, #edf2f7 100%);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.rail {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 18px 12px;
  background: var(--ink);
  color: var(--paper);
  display: flex;
  flex-direction: column;
  gap: 26px;
}

.brand {
  color: inherit;
  text-decoration: none;
  display: grid;
  gap: 9px;
  justify-items: center;
  font-weight: 800;
  line-height: 0.95;
  letter-spacing: 0;
  text-align: center;
}

.brand img {
  width: 46px;
  height: 46px;
}

.rail-nav {
  display: grid;
  gap: 10px;
}

.rail-button {
  min-height: 70px;
  border: 0;
  border-radius: 8px;
  background: rgba(245, 247, 250, 0.07);
  color: rgba(245, 247, 250, 0.74);
  display: grid;
  place-items: center;
  gap: 4px;
  padding: 9px 4px;
  transition: background 160ms ease, color 160ms ease, transform 160ms ease;
}

.rail-button:hover,
.rail-button.active {
  background: var(--paper);
  color: var(--ink);
  transform: translateX(2px);
}

.rail-mark {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--teal);
  color: var(--ink);
  font-size: 12px;
  font-weight: 900;
}

.rail-button span:last-child {
  font-size: 11px;
  text-transform: uppercase;
}

.workspace {
  min-width: 0;
  padding: 24px clamp(16px, 3vw, 38px) 38px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 18px;
}

.kicker {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  font-weight: 800;
  letter-spacing: 0.08em;
}

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

h1 {
  max-width: 760px;
  margin-bottom: 0;
  font-size: clamp(30px, 4.1vw, 58px);
  line-height: 0.98;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: clamp(22px, 2.2vw, 34px);
  line-height: 1.05;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.top-actions button,
.action-grid button,
#refreshButton {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  padding: 0 14px;
  background: var(--ink);
  color: var(--paper);
  font-weight: 800;
}

.metric-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 1px;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  background: var(--line);
  box-shadow: var(--shadow);
}

.metric {
  min-height: 82px;
  padding: 15px;
  background: var(--white);
  display: grid;
  align-content: space-between;
}

.metric span {
  color: var(--muted);
  font-size: 13px;
}

.metric strong {
  font-size: clamp(24px, 3vw, 40px);
  line-height: 1;
}

.filters {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 180px 180px;
  gap: 12px;
  margin-bottom: 18px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  font-weight: 800;
}

input,
select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  color: var(--ink);
  padding: 0 12px;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(86, 163, 166, 0.2);
}

.screen {
  display: none;
}

.screen.active {
  display: block;
  animation: reveal 260ms ease both;
}

.split-dashboard {
  display: grid;
  grid-template-columns: minmax(280px, 0.95fr) minmax(300px, 1.05fr) minmax(280px, 0.75fr);
  gap: 18px;
  align-items: start;
}

.portfolio-wall,
.contract-list,
.detail-sheet,
.history-layout > section,
.history-layout > aside,
.workflow-layout > section,
.workflow-layout > aside,
.team-layout > section,
.handoff-note {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.portfolio-wall,
.contract-list,
.detail-sheet {
  min-height: 620px;
}

.wall-head,
.sheet-head {
  min-height: 86px;
  padding: 18px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  border-bottom: 1px solid var(--line);
}

.wall-head > strong,
#itemsCount {
  min-width: 70px;
  min-height: 34px;
  border-radius: 999px;
  background: rgba(86, 163, 166, 0.16);
  color: var(--ink);
  display: grid;
  place-items: center;
  padding: 0 10px;
}

.drawer-grid {
  padding: 18px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.drawer {
  min-height: 168px;
  border: 1px solid #c6d4df;
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(245, 247, 250, 0.82), rgba(255, 255, 255, 0.98)),
    repeating-linear-gradient(90deg, rgba(16, 42, 67, 0.05) 0 1px, transparent 1px 12px);
  color: var(--ink);
  text-align: left;
  padding: 14px;
  display: grid;
  align-content: space-between;
  gap: 8px;
  transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.drawer:hover {
  transform: translateY(-3px);
  border-color: var(--teal);
  box-shadow: 0 16px 40px rgba(16, 42, 67, 0.12);
}

.drawer-code {
  width: max-content;
  padding: 4px 8px;
  background: var(--ink);
  color: var(--paper);
  border-radius: 4px;
  font-weight: 900;
}

.drawer strong {
  font-size: 24px;
  line-height: 1;
}

.drawer small,
.item-meta,
.muted {
  color: var(--muted);
}

.drawer-fill,
.quality-board div,
.load {
  height: 8px;
  border-radius: 999px;
  overflow: hidden;
  background: #e6edf3;
}

.drawer-fill i,
.quality-board i,
.load i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--teal), var(--red));
}

.items {
  padding: 12px;
  display: grid;
  gap: 10px;
  max-height: 536px;
  overflow: auto;
}

.item {
  width: 100%;
  border: 1px solid transparent;
  border-radius: 8px;
  background: #f8fafc;
  color: var(--ink);
  text-align: left;
  padding: 13px;
  display: grid;
  gap: 7px;
  transition: background 150ms ease, border-color 150ms ease, transform 150ms ease;
}

.item:hover,
.item.active {
  background: var(--white);
  border-color: var(--teal);
  transform: translateX(2px);
}

.item-status {
  width: max-content;
  max-width: 100%;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 900;
  background: rgba(16, 42, 67, 0.08);
}

.item-status.payment_due,
.item-status.paused {
  background: rgba(215, 168, 78, 0.24);
}

.item-status.incident {
  background: rgba(214, 69, 69, 0.18);
  color: #9b2c2c;
}

.item-status.control {
  background: rgba(86, 163, 166, 0.2);
}

.item strong {
  font-size: 20px;
  line-height: 1.1;
}

.item-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
}

.detail-sheet {
  position: sticky;
  top: 24px;
  padding: 20px;
}

.detail-line {
  color: var(--muted);
  line-height: 1.55;
}

.detail-list {
  margin: 18px 0;
  display: grid;
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
}

.detail-list div {
  min-height: 54px;
  padding: 10px;
  background: var(--white);
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 10px;
}

.detail-list dt {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  font-weight: 900;
}

.detail-list dd {
  margin: 0;
  min-width: 0;
}

.workflow-track {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
  margin: 18px 0;
}

.workflow-track span {
  min-height: 38px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: #e6edf3;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.workflow-track .done {
  background: rgba(86, 163, 166, 0.22);
  color: var(--ink);
}

.workflow-track .current {
  background: var(--teal);
}

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

.action-grid button {
  min-width: 0;
  white-space: normal;
}

.action-grid button:nth-child(4) {
  background: var(--red);
}

.history-layout,
.workflow-layout,
.team-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(280px, 0.75fr);
  gap: 18px;
}

.history-layout > section,
.history-layout > aside,
.workflow-layout > section,
.workflow-layout > aside,
.team-layout > section,
.handoff-note {
  padding: 20px;
}

.timeline {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.timeline-row {
  display: grid;
  grid-template-columns: 152px minmax(0, 1fr);
  gap: 14px;
  padding: 14px 0;
  border-top: 1px solid var(--line);
}

.timeline-row time {
  color: var(--muted);
  font-size: 13px;
}

.timeline-row p {
  margin: 6px 0;
  color: var(--muted);
  line-height: 1.5;
}

.timeline-row span {
  color: var(--teal);
  font-weight: 900;
  text-transform: uppercase;
  font-size: 12px;
}

.timeline-row.critical span {
  color: var(--red);
}

.incident-panel {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.incident {
  border-left: 4px solid var(--yellow);
  padding: 12px;
  background: #fbfcfd;
}

.incident.critical {
  border-left-color: var(--red);
}

.incident span,
.incident p {
  color: var(--muted);
}

.incident strong {
  display: block;
  margin: 5px 0;
}

.workflow-list,
.quality-board,
.team-grid {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.workflow-row {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  padding: 14px;
  background: #fbfcfd;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.workflow-row p {
  margin: 5px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.toggle {
  width: 52px;
  height: 30px;
  border: 0;
  border-radius: 999px;
  background: #cbd5df;
  position: relative;
}

.toggle::after {
  content: "";
  position: absolute;
  width: 22px;
  height: 22px;
  top: 4px;
  left: 4px;
  border-radius: 50%;
  background: var(--white);
  transition: transform 160ms ease;
}

.toggle.on {
  background: var(--teal);
}

.toggle.on::after {
  transform: translateX(22px);
}

.quality-board article {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.quality-board strong {
  font-size: 28px;
}

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

.member {
  min-height: 180px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  padding: 15px;
  display: grid;
  align-content: space-between;
  gap: 8px;
}

.member span {
  width: max-content;
  border-radius: 999px;
  padding: 4px 9px;
  background: rgba(16, 42, 67, 0.08);
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.member.online span {
  background: rgba(86, 163, 166, 0.2);
  color: var(--ink);
}

.member.busy span {
  background: rgba(215, 168, 78, 0.24);
}

.member strong {
  font-size: 24px;
  line-height: 1.05;
}

.member p,
.member small,
.handoff-note p {
  color: var(--muted);
  line-height: 1.55;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(380px, calc(100vw - 36px));
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--ink);
  color: var(--paper);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

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

.empty {
  padding: 14px;
}

@keyframes reveal {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 1180px) {
  .split-dashboard,
  .history-layout,
  .workflow-layout,
  .team-layout {
    grid-template-columns: 1fr;
  }

  .portfolio-wall,
  .contract-list,
  .detail-sheet {
    min-height: auto;
  }

  .detail-sheet {
    position: static;
  }

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

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

  .rail {
    position: static;
    height: auto;
    padding: 12px;
    flex-direction: row;
    align-items: center;
    overflow-x: auto;
  }

  .brand {
    grid-template-columns: 38px max-content;
    align-items: center;
    text-align: left;
    flex: 0 0 auto;
  }

  .brand img {
    width: 38px;
    height: 38px;
  }

  .rail-nav {
    display: flex;
    gap: 8px;
  }

  .rail-button {
    min-width: 82px;
    min-height: 58px;
  }

  .workspace {
    padding: 18px 12px 28px;
  }

  .topbar,
  .top-actions {
    display: grid;
    gap: 12px;
  }

  .metric-strip,
  .filters,
  .drawer-grid,
  .team-grid {
    grid-template-columns: 1fr;
  }

  .timeline-row {
    grid-template-columns: 1fr;
    gap: 4px;
  }

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

  .workflow-track,
  .action-grid {
    grid-template-columns: 1fr 1fr;
  }
}
