:root {
  --bg: #f7f9fc;
  --surface: #ffffff;
  --surface-2: #eef3f8;
  --ink: #111827;
  --muted: #637083;
  --line: #dbe3ee;
  --brand: #2fa8df;
  --brand-strong: #17213a;
  --brand-soft: #e6f5fc;
  --brand-ink: #0d1425;
  --gold: #d7a329;
  --gold-soft: #fff4d3;
  --red: #b74a48;
  --red-soft: #fae7e6;
  --blue: #2fa8df;
  --blue-soft: #e6f5fc;
  --violet: #7357a4;
  --violet-soft: #eee9f8;
  --shadow: 0 14px 36px rgba(23, 33, 58, 0.09);
  --radius: 8px;
  color-scheme: light;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(180deg, #f7f9fc 0%, #eef3f8 100%);
  color: var(--ink);
}

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

button {
  cursor: pointer;
}

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

.app-shell {
  min-height: 100vh;
}

.boot-panel {
  display: grid;
  min-height: 100vh;
  place-content: center;
  gap: 16px;
  color: var(--brand-strong);
  text-align: center;
}

.boot-panel img {
  width: min(280px, 72vw);
  margin: 0 auto;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  background: #111a2f;
  padding: 18px 14px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  padding: 4px 6px 18px;
}

.brand img {
  width: 50px;
  height: 50px;
  border-radius: 8px;
  background: #fff;
  object-fit: cover;
}

.brand strong {
  display: block;
  color: #fff;
  font-size: 15px;
  line-height: 1.2;
}

.brand span {
  color: #a9b7c9;
  font-size: 12px;
}

.nav-group-title {
  margin: 18px 8px 8px;
  color: #8292a8;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.nav-button {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 40px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: #d7e0ec;
  padding: 9px 10px;
  text-align: left;
}

.nav-button:hover,
.nav-button.active {
  background: rgba(47, 168, 223, 0.16);
  color: #fff;
}

.nav-button.active {
  box-shadow: inset 3px 0 0 var(--brand);
}

.nav-button .left {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.icon {
  display: inline-grid;
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
  place-items: center;
  color: currentColor;
}

.nav-count {
  min-width: 22px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  color: #d7e0ec;
  font-size: 12px;
  line-height: 22px;
  text-align: center;
}

.nav-button.active .nav-count {
  background: #fff;
  color: var(--brand);
}

.main {
  display: grid;
  grid-template-rows: auto 1fr;
  min-width: 0;
}

.topbar {
  position: sticky;
  z-index: 10;
  top: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  padding: 14px 24px;
  backdrop-filter: blur(12px);
}

.page-title h1 {
  margin: 0;
  color: var(--brand-strong);
  font-size: 22px;
  line-height: 1.25;
}

.page-title p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

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

.segmented {
  display: inline-flex;
  overflow: hidden;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.segmented button {
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  padding: 8px 12px;
}

.segmented button:last-child {
  border-right: 0;
}

.segmented button.active {
  background: var(--brand-strong);
  color: white;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  padding: 8px 12px;
  text-decoration: none;
}

.button:hover {
  border-color: #b8c7d8;
  box-shadow: 0 8px 18px rgba(23, 33, 58, 0.08);
}

.button.primary {
  border-color: var(--brand);
  background: var(--brand);
  color: white;
}

.button.primary:hover {
  border-color: #218fc2;
  background: #218fc2;
}

.button.warning {
  border-color: var(--gold);
  background: var(--gold-soft);
  color: #6b4300;
}

.button.danger {
  border-color: var(--red);
  background: var(--red-soft);
  color: #7e2927;
}

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

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

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

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

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

.panel.flat {
  box-shadow: none;
}

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

.panel-header h2,
.panel-header h3 {
  margin: 0;
  color: var(--brand-strong);
  font-size: 15px;
}

.panel-header p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.panel-body {
  padding: 16px;
}

.metric {
  position: relative;
  padding: 16px;
}

.metric::before {
  content: "";
  position: absolute;
  top: 16px;
  bottom: 16px;
  left: 0;
  width: 3px;
  border-radius: 999px;
  background: var(--brand);
}

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

.metric .value {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-top: 8px;
  color: var(--brand-strong);
  font-size: 30px;
  font-weight: 760;
  line-height: 1;
}

.metric .trend {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

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

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

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

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

td {
  font-size: 13px;
}

tr.clickable:hover {
  background: #f4f8fc;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  min-height: 24px;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 12px;
  white-space: nowrap;
}

.chip.green {
  background: var(--brand-soft);
  color: var(--brand-strong);
}

.chip.gold {
  background: var(--gold-soft);
  color: #704700;
}

.chip.red {
  background: var(--red-soft);
  color: #842b29;
}

.chip.blue {
  background: var(--blue-soft);
  color: #234c6b;
}

.chip.violet {
  background: var(--violet-soft);
  color: #563783;
}

.chip.gray {
  background: var(--surface-2);
  color: var(--muted);
}

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

.case-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.case-heading h2 {
  margin: 0;
  font-size: 20px;
}

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

.small {
  font-size: 12px;
}

.status-timeline {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.stage-row {
  display: grid;
  grid-template-columns: 116px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}

.stage-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.stage-track {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.status-dot {
  width: 16px;
  height: 16px;
  border: 1px solid #bccac2;
  border-radius: 50%;
  background: white;
}

.status-dot.done {
  border-color: var(--brand);
  background: var(--brand);
}

.status-dot.current {
  border-color: var(--gold);
  background: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-soft);
}

.status-dot.blocked {
  border-color: var(--red);
  background: var(--red-soft);
}

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

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

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

.field label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

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

.field textarea {
  min-height: 96px;
  resize: vertical;
}

.check-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.check-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: white;
  padding: 7px 9px;
  font-size: 13px;
}

.notice {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  padding: 12px;
}

.notice.critical {
  border-color: #e2b7b5;
  background: var(--red-soft);
}

.notice.good {
  border-color: #b8dff1;
  background: var(--brand-soft);
}

.doc-grid {
  display: grid;
  gap: 10px;
}

.doc-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: white;
  padding: 12px;
}

.doc-card.active {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}

.doc-card h4 {
  margin: 0 0 4px;
  font-size: 14px;
}

.doc-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

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

.viewer-page {
  min-height: 420px;
  border: 1px solid #cfd8d3;
  border-radius: var(--radius);
  background:
    linear-gradient(90deg, rgba(47, 168, 223, 0.08) 1px, transparent 1px) 0 0 / 34px 34px,
    linear-gradient(rgba(47, 168, 223, 0.08) 1px, transparent 1px) 0 0 / 34px 34px,
    #fff;
  padding: 30px;
  position: relative;
}

.viewer-page.watermark::after {
  content: "5UP PORTAL VIEW ONLY";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: rgba(47, 168, 223, 0.12);
  font-size: 32px;
  font-weight: 800;
  transform: rotate(-24deg);
  pointer-events: none;
}

.viewer-document {
  max-width: 430px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.85);
  padding: 22px;
}

.viewer-document h3 {
  margin: 0 0 12px;
  color: var(--brand-strong);
  font-size: 18px;
}

.viewer-line {
  height: 10px;
  margin: 9px 0;
  border-radius: 999px;
  background: #dfe7e2;
}

.viewer-line.short {
  width: 62%;
}

.viewer-line.medium {
  width: 78%;
}

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

.kanban-column {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfa;
  padding: 10px;
}

.kanban-column h3 {
  margin: 0 0 10px;
  font-size: 13px;
}

.task {
  display: grid;
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: white;
  padding: 10px;
  margin-bottom: 8px;
}

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

.modal {
  width: min(680px, 100%);
  max-height: calc(100vh - 40px);
  overflow: auto;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.25);
}

.modal .panel-header {
  position: sticky;
  z-index: 1;
  top: 0;
  background: var(--surface);
}

.empty-state {
  display: grid;
  min-height: 180px;
  place-content: center;
  color: var(--muted);
  text-align: center;
}

.toast-stack {
  position: fixed;
  z-index: 70;
  right: 18px;
  bottom: 18px;
  display: grid;
  width: min(420px, calc(100vw - 36px));
  gap: 8px;
}

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

.progress-bar {
  overflow: hidden;
  height: 8px;
  border-radius: 999px;
  background: var(--surface-2);
}

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

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

  .brand div,
  .nav-group-title,
  .nav-label,
  .nav-count {
    display: none;
  }

  .brand {
    justify-content: center;
  }

  .nav-button {
    justify-content: center;
  }

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

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

@media (max-width: 720px) {
  .layout {
    display: block;
  }

  .sidebar {
    position: static;
    display: flex;
    height: auto;
    gap: 8px;
    overflow-x: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 10px;
  }

  .brand {
    min-width: 48px;
    margin: 0;
  }

  .nav-stack {
    display: flex;
    gap: 6px;
  }

  .nav-button {
    min-width: 44px;
  }

  .topbar {
    grid-template-columns: 1fr;
    padding: 14px;
  }

  .toolbar {
    justify-content: flex-start;
  }

  .content {
    padding: 14px;
  }

  .grid.two,
  .grid.three,
  .grid.four,
  .form-grid,
  .kanban {
    grid-template-columns: 1fr;
  }

  .stage-row {
    grid-template-columns: 1fr;
  }

.viewer-page {
    min-height: 320px;
    padding: 16px;
  }
}

.invite-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(180deg, #ffffff 0%, #eef5fb 100%);
}

.invite-card {
  width: min(760px, 100%);
  overflow: hidden;
}

.invite-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  background: #fff;
  padding: 20px;
  border-bottom: 1px solid var(--line);
}

.invite-brand img {
  width: 92px;
  height: 92px;
  border-radius: 8px;
  object-fit: cover;
}

.invite-brand h1 {
  margin: 0;
  color: var(--brand-strong);
  font-size: 22px;
}

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

#invite-status {
  margin: 18px;
}

#invite-form {
  padding: 0 18px 18px;
}
