:root {
  --ink: #17212b;
  --muted: #64717d;
  --line: #d9e1e7;
  --soft-line: #e9eef2;
  --surface: #ffffff;
  --wash: #f6f8fa;
  --teal: #006c72;
  --teal-dark: #00494f;
  --teal-soft: #e5f4f4;
  --blue: #2c6f9f;
  --amber: #b87907;
  --amber-soft: #fff5df;
  --green: #157a38;
  --green-soft: #e8f6ec;
  --red: #b3261e;
  --red-soft: #fff0ee;
  --shadow: 0 12px 28px rgba(24, 42, 54, 0.08);
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--wash);
}

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

button {
  border: 0;
  cursor: pointer;
}

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

.app-shell.sidebar-collapsed {
  grid-template-columns: 76px minmax(0, 1fr);
}

.sidebar {
  background: linear-gradient(180deg, var(--teal-dark), #003b40);
  color: #f7fbfb;
  padding: 22px 14px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.brand {
  padding: 4px 10px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.16);
}

.sidebar-collapsed .brand span,
.sidebar-collapsed .nav button span,
.sidebar-collapsed .bottom-nav button span {
  display: none;
}

.sidebar-collapsed .brand strong {
  font-size: 14px;
}

.sidebar-collapsed .nav button,
.sidebar-collapsed .bottom-nav button {
  grid-template-columns: 1fr;
  place-items: center;
}

.brand strong {
  display: block;
  font-size: 28px;
  letter-spacing: 0;
  line-height: 1;
}

.brand span {
  display: block;
  margin-top: 5px;
  color: #cce4e4;
  font-size: 13px;
}

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

.nav button,
.bottom-nav button {
  height: 42px;
  color: #e9f6f6;
  background: transparent;
  border-radius: 6px;
  display: grid;
  grid-template-columns: 24px 1fr;
  align-items: center;
  gap: 12px;
  padding: 0 10px;
  text-align: left;
  font-size: 14px;
  font-weight: 650;
}

.nav button.active,
.nav button:hover,
.bottom-nav button:hover {
  background: rgba(255,255,255,0.12);
}

.bottom-nav {
  margin-top: auto;
  display: grid;
  gap: 6px;
}

.main {
  min-width: 0;
}

.topbar {
  height: 66px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 22px;
}

.language-control {
  display: grid;
  gap: 5px;
  min-width: 128px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.language-control .input {
  height: 32px;
  min-width: 128px;
}

.top-language {
  min-width: 118px;
}

.title-lockup {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.title-lockup h1 {
  margin: 0;
  font-size: 18px;
  line-height: 1.2;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 16px;
  color: var(--muted);
  font-size: 13px;
}

.health {
  color: var(--green);
  font-weight: 750;
}

.avatar {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: white;
  background: var(--teal);
  font-weight: 800;
}

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

.metrics {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: grid;
  grid-template-columns: 1.35fr 1fr 1fr 1fr 1fr 1fr auto;
  gap: 0;
  box-shadow: 0 2px 10px rgba(24, 42, 54, 0.04);
}

.metric {
  padding: 14px 18px;
  border-right: 1px solid var(--soft-line);
}

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

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 22px;
  color: var(--teal);
}

.progress-line {
  margin-top: 10px;
  height: 8px;
  background: #d5dcdf;
  border-radius: 99px;
  overflow: hidden;
}

.progress-line span {
  display: block;
  height: 100%;
  background: var(--teal);
}

.action-area {
  display: flex;
  align-items: center;
  padding: 0 18px;
}

.primary {
  background: var(--teal);
  color: white;
  border-radius: 6px;
  min-height: 40px;
  padding: 0 16px;
  font-size: 13px;
  font-weight: 800;
}

.secondary,
.ghost,
.icon-button {
  background: var(--surface);
  color: var(--teal);
  border: 1px solid var(--line);
  border-radius: 6px;
  min-height: 36px;
  padding: 0 12px;
  font-size: 13px;
  font-weight: 750;
}

.secondary:hover,
.ghost:hover,
.icon-button:hover {
  border-color: var(--teal);
}

.grid {
  display: grid;
  grid-template-columns: 340px minmax(520px, 1fr) 390px;
  gap: 12px;
  margin-top: 14px;
}

.single-view {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 1px 2px rgba(24, 42, 54, 0.03);
  overflow: hidden;
}

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

.panel-header h2,
.panel-header h3 {
  margin: 0;
  font-size: 16px;
  line-height: 1.2;
}

.panel-header a {
  color: var(--teal);
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
}

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

.program-card {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 14px;
  background: linear-gradient(135deg, #ffffff, #f7fbfb);
}

.program-card.active {
  border-color: var(--teal);
  box-shadow: inset 4px 0 0 var(--teal);
}

.program-card.locked {
  opacity: .72;
}

.program-card .row {
  align-items: start;
}

.number {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--teal);
  color: white;
  display: grid;
  place-items: center;
  font-weight: 800;
  flex: 0 0 auto;
}

.locked .number {
  background: #9aa5ad;
}

.program-title {
  font-weight: 850;
  color: var(--teal);
}

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

.tag {
  border-radius: 5px;
  padding: 3px 7px;
  font-size: 11px;
  font-weight: 850;
  border: 1px solid currentColor;
}

.tag.ready,
.tag.verified,
.tag.effective {
  color: var(--green);
  background: var(--green-soft);
}

.tag.progress,
.tag.review,
.tag.medium {
  color: var(--amber);
  background: var(--amber-soft);
}

.tag.draft,
.tag.low {
  color: #57636d;
  background: #f0f3f5;
}

.tag.high,
.tag.overdue {
  color: var(--red);
  background: var(--red-soft);
}

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.clause-tools {
  display: grid;
  grid-template-columns: 1fr 42px;
  gap: 10px;
  width: min(420px, 100%);
}

.input {
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 11px;
  color: var(--ink);
  background: var(--surface);
}

.workflow-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

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

.workflow-table th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.workflow-table tr.selected {
  background: var(--teal-soft);
  outline: 1px solid rgba(0, 108, 114, .35);
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
}

.dot {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  display: inline-block;
  border: 2px solid currentColor;
}

.dot.completed { color: var(--green); background: var(--green); }
.dot.in-progress { color: var(--amber); }
.dot.not-started { color: #a7b0b7; }
.dot.overdue { color: var(--red); background: var(--red); }

.detail {
  margin-top: 10px;
}

.detail-grid {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  min-height: 315px;
}

.subnav {
  border-right: 1px solid var(--soft-line);
  padding: 12px 0;
}

.subnav button {
  width: 100%;
  min-height: 36px;
  background: transparent;
  text-align: left;
  padding: 0 16px;
  color: var(--ink);
  font-size: 13px;
}

.subnav button.active {
  color: var(--teal);
  background: var(--teal-soft);
  box-shadow: inset 3px 0 0 var(--teal);
  font-weight: 850;
}

.editor {
  padding: 16px;
  display: grid;
  gap: 13px;
}

.field-grid {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
}

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

.token-input {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  display: flex;
  align-items: center;
  padding: 4px 8px;
  color: var(--ink);
  background: #fbfcfd;
  font-size: 13px;
}

.notes {
  grid-column: 1 / -1;
  border-top: 1px solid var(--soft-line);
  padding: 16px;
  display: grid;
  gap: 12px;
  align-content: start;
  grid-template-columns: minmax(180px, 1fr) minmax(260px, 2fr) auto;
  align-items: start;
}

textarea {
  width: 100%;
  min-height: 104px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 11px;
  resize: vertical;
  color: var(--ink);
}

.stack {
  display: grid;
  gap: 10px;
}

.guide-body {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.guide-body strong {
  display: block;
  margin-bottom: 7px;
  font-size: 13px;
}

.guide-body ul {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.45;
}

.guide-body li + li {
  margin-top: 5px;
}

.guide-ready,
.guide-next {
  border: 1px solid var(--soft-line);
  border-radius: 6px;
  padding: 12px;
  background: #fbfcfd;
}

.guide-ready p,
.guide-next p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.settings-grid {
  display: grid;
  gap: 16px;
  padding: 16px;
  max-width: 760px;
}

.settings-grid strong {
  display: block;
  margin-bottom: 8px;
}

.settings-actions {
  justify-content: start;
}

.list-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.list-table td,
.list-table th {
  padding: 9px 10px;
  border-bottom: 1px solid var(--soft-line);
  text-align: left;
}

.list-table th {
  color: var(--muted);
  font-weight: 800;
}

.export-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 14px;
}

.export-button {
  min-height: 58px;
  border: 1px solid var(--teal);
  border-radius: 6px;
  background: #fbffff;
  color: var(--teal);
  text-align: left;
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 850;
  display: grid;
  grid-template-columns: 24px 1fr;
  align-items: center;
  gap: 10px;
}

.matrix {
  margin-top: 12px;
}

.timeline {
  padding: 14px 16px 18px;
  display: grid;
  gap: 0;
}

.activity {
  display: grid;
  grid-template-columns: 18px 1fr 24px;
  gap: 8px;
  min-height: 56px;
}

.activity .marker {
  width: 11px;
  height: 11px;
  margin-top: 4px;
  border-radius: 50%;
  border: 2px solid var(--teal);
  background: white;
  position: relative;
}

.activity:not(:last-child) .marker::after {
  content: "";
  position: absolute;
  left: 3px;
  top: 10px;
  width: 1px;
  height: 48px;
  background: var(--line);
}

.activity.done .marker {
  background: var(--green);
  border-color: var(--green);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(9, 24, 31, .36);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 22px;
  z-index: 10;
}

.modal-backdrop.open {
  display: flex;
}

.auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(135deg, #f6f8fa 0%, #e8f3f3 100%);
}

.auth-card {
  width: min(430px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
  display: grid;
  gap: 14px;
}

.auth-brand {
  color: var(--teal);
  font-size: 24px;
  letter-spacing: 0;
}

.auth-card h1 {
  margin: 0;
  font-size: 24px;
}

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

.auth-card label,
.user-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.auth-error {
  background: var(--red-soft);
  color: var(--red);
  border: 1px solid rgba(179, 38, 30, .32);
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 750;
}

.user-form {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 10px;
  align-items: end;
  margin-bottom: 16px;
}

.upload-form {
  display: grid;
  gap: 12px;
  max-width: 680px;
}

.upload-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.modal {
  width: min(920px, 96vw);
  max-height: 88vh;
  overflow: auto;
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.modal-body {
  padding: 18px;
}

.doc-preview {
  white-space: pre-wrap;
  background: #f8fafb;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 16px;
  font: 13px/1.55 ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
}

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

.source-note {
  margin-top: 12px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.empty-state {
  padding: 18px;
  color: var(--muted);
  font-size: 13px;
}

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

@media (max-width: 1220px) {
  .app-shell {
    grid-template-columns: 76px minmax(0, 1fr);
  }

  .brand strong {
    font-size: 14px;
  }

  .brand span,
  .nav button span,
  .bottom-nav button span {
    display: none;
  }

  .nav button,
  .bottom-nav button {
    grid-template-columns: 1fr;
    place-items: center;
  }

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

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

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

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

  .nav,
  .bottom-nav {
    display: none;
  }

  .brand {
    padding: 4px 6px;
    border: 0;
  }

  .topbar {
    height: auto;
    align-items: start;
    gap: 12px;
    flex-direction: column;
    padding: 14px;
  }

  .top-actions {
    flex-wrap: wrap;
  }

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

  .metric {
    border-right: 0;
    border-bottom: 1px solid var(--soft-line);
  }

  .workspace {
    padding: 12px;
  }

  .grid {
    margin-top: 10px;
  }

  .detail-grid,
  .field-grid,
  .export-grid {
    grid-template-columns: 1fr;
  }

  .notes,
  .subnav {
    border: 0;
  }

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

  .user-form {
    grid-template-columns: 1fr;
  }
}
