:root {
  --bg: #f5f7f8;
  --surface: #ffffff;
  --surface-soft: #eef3f5;
  --line: #dce4e7;
  --line-strong: #c3d0d6;
  --text: #172126;
  --muted: #64727a;
  --blue: #2563eb;
  --blue-soft: #e8f0ff;
  --green: #15803d;
  --green-soft: #e8f7ee;
  --amber: #a16207;
  --amber-soft: #fff3d7;
  --orange: #c2410c;
  --orange-soft: #ffede3;
  --red: #b91c1c;
  --red-soft: #fee2e2;
  --violet: #6d28d9;
  --violet-soft: #f0e9ff;
  --shadow: 0 18px 45px rgba(25, 36, 42, 0.08);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
}

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

button {
  min-height: 38px;
  border: 0;
  border-radius: var(--radius);
  padding: 0 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  white-space: nowrap;
}

button svg {
  width: 17px;
  height: 17px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 11px;
  color: var(--text);
  background: #fff;
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

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

.hidden {
  display: none !important;
}

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

.eyebrow {
  margin: 0 0 7px;
  font-size: 11px;
  font-weight: 800;
  color: var(--blue);
  text-transform: uppercase;
}

.primary {
  color: #fff;
  background: var(--blue);
}

.primary:hover {
  background: #1d4ed8;
}

.ghost {
  color: var(--text);
  background: var(--surface-soft);
}

.ghost:hover {
  background: #e2eaee;
}

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

.full {
  width: 100%;
}

.error-text {
  min-height: 18px;
  margin: 0;
  color: var(--red);
  font-size: 13px;
}

.login-shell,
.public-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel,
.public-card {
  width: min(440px, 100%);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 28px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.login-panel h1,
.public-card h1 {
  margin: 0;
  font-size: 30px;
  line-height: 1.1;
}

.form-grid {
  display: grid;
  gap: 14px;
  margin-top: 22px;
}

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

.full-field {
  display: block;
  margin-top: 14px;
}

.app-shell {
  width: min(1480px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 22px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 6px 0 18px;
}

.topbar h1,
.partners-layout h2 {
  margin: 0;
  font-size: 28px;
}

.top-actions,
.tabs,
.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-badge {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 12px;
  color: var(--muted);
  background: var(--surface);
  font-size: 13px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.stat {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  background: var(--surface);
}

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

.stat strong {
  display: block;
  margin-top: 6px;
  font-size: 28px;
}

.tabs {
  margin-bottom: 14px;
}

.tab {
  border: 1px solid var(--line);
  color: var(--muted);
  background: var(--surface);
}

.tab.active {
  border-color: var(--blue);
  color: var(--blue);
  background: var(--blue-soft);
}

.workspace {
  display: grid;
  grid-template-columns: 210px minmax(340px, 1fr) minmax(360px, 440px);
  gap: 14px;
  align-items: start;
}

.stage-rail,
.list-panel,
.details-panel,
.partners-layout {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 10px 28px rgba(25, 36, 42, 0.04);
}

.stage-rail {
  padding: 10px;
  display: grid;
  gap: 6px;
  position: sticky;
  top: 16px;
}

.stage-filter {
  justify-content: flex-start;
  width: 100%;
  color: var(--muted);
  background: transparent;
}

.stage-filter.active {
  color: var(--blue);
  background: var(--blue-soft);
}

.list-panel {
  min-height: 620px;
  padding: 12px;
}

.toolbar {
  justify-content: space-between;
  margin-bottom: 12px;
}

.search-wrap {
  flex: 1;
  min-width: 220px;
  position: relative;
}

.search-wrap svg {
  position: absolute;
  top: 10px;
  left: 10px;
  width: 18px;
  height: 18px;
  color: var(--muted);
}

.search-wrap input {
  padding-left: 36px;
}

.case-list {
  display: grid;
  gap: 8px;
}

.case-row {
  width: 100%;
  min-height: 86px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background: #fff;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  text-align: left;
}

.case-row:hover,
.case-row.active {
  border-color: var(--blue);
  box-shadow: 0 8px 20px rgba(37, 99, 235, 0.08);
}

.case-main h3,
.partner-card h3 {
  margin: 0 0 6px;
  font-size: 16px;
}

.case-meta,
.partner-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.stage-chip {
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.tone-blue { color: var(--blue); background: var(--blue-soft); }
.tone-green { color: var(--green); background: var(--green-soft); }
.tone-amber { color: var(--amber); background: var(--amber-soft); }
.tone-orange { color: var(--orange); background: var(--orange-soft); }
.tone-red { color: var(--red); background: var(--red-soft); }
.tone-violet { color: var(--violet); background: var(--violet-soft); }

.details-panel {
  min-height: 620px;
  padding: 16px;
  position: sticky;
  top: 16px;
}

.details-panel.empty {
  display: grid;
  place-items: center;
  color: var(--muted);
}

.empty-state {
  text-align: center;
}

.empty-state svg {
  width: 36px;
  height: 36px;
}

.details-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.details-head h2 {
  margin: 0 0 6px;
  font-size: 20px;
}

.details-section {
  border-top: 1px solid var(--line);
  padding-top: 14px;
  margin-top: 14px;
}

.details-section h3 {
  margin: 0 0 10px;
  font-size: 14px;
}

.doc-list,
.task-list,
.event-list {
  display: grid;
  gap: 8px;
}

.doc-line,
.task-line,
.event-line {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  background: #fbfcfc;
}

.doc-line {
  display: flex;
  align-items: center;
  gap: 8px;
}

.doc-line input {
  width: 18px;
  height: 18px;
}

.task-line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.task-line.done {
  opacity: 0.65;
}

.event-line p,
.task-line p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.partners-layout {
  padding: 16px;
}

.partner-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}

.partner-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  background: #fff;
}

.link-box {
  margin-top: 10px;
  display: grid;
  gap: 8px;
}

.link-copy {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
}

.link-copy input {
  font-size: 12px;
}

.modal {
  width: min(680px, calc(100% - 28px));
  border: 0;
  border-radius: 12px;
  padding: 0;
  box-shadow: var(--shadow);
}

.modal::backdrop {
  background: rgba(20, 31, 37, 0.35);
}

.modal-body {
  margin: 0;
  padding: 18px;
}

.modal-body header,
.modal-body footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.modal-body header h2 {
  margin: 0;
}

.modal-body footer {
  margin-top: 18px;
  justify-content: flex-end;
}

@media (max-width: 1080px) {
  .workspace {
    grid-template-columns: 180px minmax(320px, 1fr);
  }

  .details-panel {
    grid-column: 1 / -1;
    position: static;
    min-height: auto;
  }
}

@media (max-width: 760px) {
  .app-shell {
    padding: 14px;
  }

  .topbar,
  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .stats-grid,
  .workspace,
  .form-grid.two {
    grid-template-columns: 1fr;
  }

  .stage-rail {
    position: static;
  }
}
