:root {
  color-scheme: light;
  --ink: #17202a;
  --muted: #667085;
  --line: #d9e0e8;
  --panel: #ffffff;
  --page: #f7f8fa;
  --navy: #15283b;
  --teal: #0f766e;
  --teal-soft: #e6f4f1;
  --red: #c2413d;
  --red-soft: #fae8e7;
  --amber: #b7791f;
  --amber-soft: #fff4dc;
  --blue: #315f9f;
  --blue-soft: #eaf0fb;
  --shadow: 0 18px 50px rgba(23, 32, 42, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--page);
  color: var(--ink);
  font-family:
    Inter, "Noto Sans JP", "Hiragino Sans", system-ui, -apple-system,
    BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.auth-loading .app-shell,
.auth-required .app-shell {
  display: none;
}

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(18, 26, 36, 0.94), rgba(15, 118, 110, 0.8)),
    #121a24;
}

.auth-required .login-screen {
  display: grid;
}

.login-panel {
  display: grid;
  gap: 18px;
  width: min(440px, 100%);
  padding: 28px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 10px;
  background: #ffffff;
  box-shadow: var(--shadow);
}

.login-brand {
  color: var(--ink);
}

.login-panel h1 {
  margin-top: 6px;
  font-size: 28px;
  letter-spacing: 0;
}

.login-panel label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.login-panel input {
  min-height: 46px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  font: inherit;
  font-size: 14px;
}

.login-error {
  min-height: 20px;
  color: var(--red);
  font-size: 13px;
  font-weight: 800;
}

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

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 24px;
  height: 100vh;
  padding: 22px 16px;
  background: #121a24;
  color: #eef5f5;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: #edf7f4;
  color: var(--teal);
  font-weight: 900;
}

.brand-name,
.brand-sub,
.eyebrow,
.metric-label,
.metric-value,
h1,
h2,
p {
  margin: 0;
}

.brand-name {
  font-size: 17px;
  font-weight: 800;
}

.brand-sub {
  color: #9fb2bd;
  font-size: 12px;
}

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

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px;
  border-radius: 8px;
  background: transparent;
  color: #c3d1d8;
  text-align: left;
}

.nav-item span {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
}

.nav-item.active,
.nav-item:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

.login-card {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
}

.login-card label,
.login-card span {
  color: #d8e4e8;
  font-size: 12px;
  font-weight: 800;
}

.login-card select {
  width: 100%;
  min-height: 38px;
  padding: 0 10px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: #203345;
  color: white;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
}

.login-card strong {
  font-size: 14px;
}

.logout-button {
  min-height: 34px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font-size: 12px;
  font-weight: 900;
}

.system-card,
.source-card {
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
}

.system-card h2 {
  margin-top: 8px;
  font-size: 14px;
  line-height: 1.45;
}

.source-card ul {
  display: grid;
  gap: 8px;
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
  color: #c7d6dc;
  font-size: 13px;
  line-height: 1.45;
}

.source-card li {
  position: relative;
  padding-left: 14px;
}

.source-card li::before {
  position: absolute;
  left: 0;
  color: #70d8cb;
  content: "•";
}

.eyebrow {
  color: var(--teal);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.sidebar .eyebrow {
  color: #70d8cb;
}

.sync-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
  color: #bfd5d7;
  font-size: 12px;
}

.pulse {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #38b2ac;
  box-shadow: 0 0 0 5px rgba(56, 178, 172, 0.18);
}

.metric-stack {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: auto;
}

.metric-stack div {
  padding: 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
}

.metric-value {
  display: block;
  color: #ffffff;
  font-size: 22px;
  font-weight: 800;
}

.metric-label {
  color: #adc1c9;
  font-size: 12px;
}

.workspace {
  display: grid;
  gap: 14px;
  width: auto;
  margin: 0;
  padding: 22px;
  align-content: start;
}

.page-view {
  display: none;
}

.page-view.active {
  display: grid;
  gap: 14px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 66px;
  padding: 14px 18px;
  border: 1px solid rgba(217, 224, 232, 0.9);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.8) inset;
}

h1 {
  max-width: 980px;
  margin-top: 4px;
  font-size: clamp(20px, 1.6vw, 24px);
  line-height: 1.28;
  letter-spacing: 0;
}

h2 {
  font-size: 16px;
}

.top-actions,
.panel-header,
.filter-row,
.editor-footer,
.status-strip,
.bottom-grid {
  display: flex;
  align-items: center;
}

.top-actions {
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.primary-button,
.ghost-button,
.filter,
.segment,
.icon-button {
  min-height: 38px;
  border-radius: 8px;
  transition:
    transform 120ms ease,
    background 120ms ease,
    border-color 120ms ease;
}

.primary-button {
  padding: 0 16px;
  background: var(--teal);
  color: white;
  font-size: 13px;
  font-weight: 800;
}

.ghost-button {
  padding: 0 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
}

.primary-button:hover,
.ghost-button:hover,
.filter:hover,
.segment:hover,
.icon-button:hover {
  transform: translateY(-1px);
}

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

.intake-panel,
.status-item,
.editor-panel,
.insight-panel,
.clause-panel,
.audit-panel,
.radar-panel,
.negotiation-panel {
  border: 1px solid rgba(217, 224, 232, 0.9);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.8) inset;
}

.intake-panel {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(260px, 0.7fr);
  gap: 10px;
  padding: 12px;
}

.drop-zone {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 4px 12px;
  align-items: center;
  min-height: 78px;
  padding: 14px;
  border: 1px dashed rgba(15, 118, 110, 0.45);
  border-radius: 8px;
  background: #f8fcfb;
  cursor: pointer;
}

.drop-zone:hover,
.drop-zone.dragging {
  border-color: var(--teal);
  background: var(--teal-soft);
}

.drop-zone input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
  pointer-events: none;
}

.drop-icon {
  display: grid;
  grid-row: span 2;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--teal-soft);
  color: var(--teal);
  font-size: 18px;
  font-weight: 900;
}

.drop-zone strong {
  font-size: 14px;
}

.lawyer-summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 180px 160px;
  gap: 12px;
}

.summary-card {
  display: grid;
  align-content: center;
  gap: 6px;
  min-height: 112px;
  padding: 18px;
  border: 1px solid rgba(217, 224, 232, 0.9);
  border-radius: 10px;
  background: white;
}

.summary-card h2 {
  font-size: 18px;
  line-height: 1.45;
}

.summary-card p,
.summary-card span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.summary-card .legal-source-status {
  padding-top: 8px;
  color: var(--teal);
  font-size: 12px;
  font-weight: 800;
}

.summary-card strong {
  font-size: 24px;
}

.main-summary {
  background: #f8fcfb;
  border-color: rgba(15, 118, 110, 0.22);
}

.opinion-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-top: 14px;
}

.opinion-grid div {
  display: grid;
  gap: 4px;
  padding: 10px;
  border: 1px solid rgba(15, 118, 110, 0.16);
  border-radius: 8px;
  background: white;
}

.opinion-grid strong {
  color: var(--teal);
  font-size: 12px;
}

.opinion-grid span {
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.45;
}

.lawyer-summary {
  order: 4;
}

.intake-panel {
  order: 2;
}

.status-strip {
  order: 4;
}

.review-grid {
  order: 3;
}

.contract-edit-panel {
  order: 4;
}

.radar-panel {
  order: 6;
}

.bottom-grid {
  order: 5;
}

.negotiation-panel {
  order: 6;
}

.drop-zone small,
.file-meta span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.file-meta {
  display: grid;
  align-content: center;
  gap: 6px;
  padding: 14px;
  border-radius: 8px;
  background: #f5f8fa;
}

.file-meta strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-item {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  padding: 12px;
}

.status-item strong {
  display: block;
  font-size: 13px;
}

.status-item small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex: 0 0 auto;
}

.green {
  background: var(--teal);
}

.amber {
  background: var(--amber);
}

.red {
  background: var(--red);
}

.blue {
  background: var(--blue);
}

.review-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(360px, 0.9fr);
  gap: 14px;
  align-items: stretch;
}

#reviewPage .system-card,
#reviewPage .source-card,
#reviewPage .metric-stack,
#reviewPage .status-strip,
#reviewPage .radar-panel,
#reviewPage .negotiation-panel,
#reviewPage .summary-card:not(.main-summary),
#reviewPage .segmented,
#reviewPage .score-card,
#reviewPage .filter-row,
#reviewPage .bottom-grid,
#reviewPage .bottom-grid .approval-panel {
  display: none;
}

#reviewPage.has-review .bottom-grid {
  display: grid;
  grid-template-columns: 1fr;
}

#reviewPage .lawyer-summary {
  grid-template-columns: 1fr;
}

#reviewPage .main-summary {
  min-height: auto;
  padding: 16px;
}

#reviewPage .main-summary h2 {
  font-size: 17px;
}

#reviewPage .review-grid {
  grid-template-columns: minmax(500px, 1.08fr) minmax(420px, 0.92fr);
}

#reviewPage .editor-panel,
#reviewPage .insight-panel,
#reviewPage .clause-panel {
  padding: 18px;
}

#reviewPage .insight-panel {
  display: block;
}

#reviewPage textarea {
  min-height: clamp(720px, 78vh, 1120px);
}

#reviewPage #contractInput {
  min-height: clamp(760px, 80vh, 1180px);
}

.simple-result-header {
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.simple-result-header span {
  padding: 6px 10px;
  border-radius: 999px;
  background: #f0f5f5;
  color: var(--teal);
  font-size: 12px;
  font-weight: 900;
}

.editor-panel,
.insight-panel,
.clause-panel,
.audit-panel {
  padding: 16px;
}

.panel-header {
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.panel-header.compact {
  margin-bottom: 12px;
}

.segmented {
  display: flex;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafb;
}

.segment {
  min-height: 32px;
  padding: 0 10px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.segment.active {
  background: var(--navy);
  color: white;
}

textarea {
  width: 100%;
  min-height: 420px;
  resize: vertical;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
  background: #fbfcfd;
  color: var(--ink);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 13px;
  line-height: 1.7;
}

textarea:focus {
  border-color: rgba(15, 118, 110, 0.55);
  box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.1);
}

.document-preview {
  display: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #ffffff;
}

.document-preview.active {
  display: block;
}

#reviewPage.has-review #contractInput {
  display: none;
}

.document-preview-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: #f8fafb;
}

.document-preview-bar strong {
  font-size: 13px;
}

.document-preview-bar span {
  color: var(--muted);
  font-size: 12px;
}

.document-text {
  min-height: clamp(760px, 80vh, 1180px);
  max-height: none;
  overflow: visible;
  padding: 18px;
  color: #243142;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 13px;
  line-height: 1.8;
  white-space: pre-wrap;
}

.document-highlight {
  position: relative;
  display: inline;
  padding: 2px 4px;
  border-radius: 5px;
  background: #ffe1df;
  color: var(--red);
  font-weight: 900;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

.document-highlight span {
  display: inline-grid;
  place-items: center;
  min-width: 18px;
  height: 18px;
  margin-right: 4px;
  border-radius: 999px;
  background: var(--red);
  color: white;
  font-family: inherit;
  font-size: 11px;
  line-height: 1;
}

.editor-footer {
  justify-content: space-between;
  gap: 10px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
}

.insight-panel {
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: 14px;
}

.clause-draft-panel {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
  padding: 14px;
  border: 1px solid rgba(15, 118, 110, 0.22);
  border-radius: 8px;
  background: #f8fcfb;
}

#reviewPage .contract-edit-panel {
  margin-bottom: 0;
  padding: 18px;
}

#reviewPage .clause-memo {
  min-height: 150px;
  resize: vertical;
  background: white;
  font-family: inherit;
}

.clause-output {
  display: grid;
  gap: 10px;
}

.clause-draft-result {
  display: grid;
  gap: 10px;
}

.clause-draft-result > div:first-child {
  display: grid;
  gap: 4px;
}

.clause-draft-result strong {
  font-size: 13px;
}

.clause-draft-result p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.before-box {
  display: grid;
  gap: 5px;
  padding: 10px;
  border: 1px dashed rgba(194, 65, 61, 0.28);
  border-radius: 8px;
  background: #fff8f7;
}

.before-box span {
  color: var(--red);
  font-size: 12px;
  font-weight: 900;
}

.before-box p {
  color: #7f1d1d;
  white-space: pre-wrap;
}

.clause-variant-grid .apply-button {
  width: max-content;
  margin-top: 4px;
}

.score-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px;
  border-radius: 8px;
  background: #f7faf9;
}

.score-card strong {
  display: block;
  margin-top: 4px;
  font-size: 28px;
}

.score-ring {
  display: none;
  place-items: center;
  width: 82px;
  height: 82px;
  border-radius: 50%;
  background: conic-gradient(var(--teal) 0deg, #e5eaf0 0deg);
}

.score-ring span {
  display: grid;
  place-items: center;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: white;
  font-weight: 900;
}

.filter-row {
  gap: 8px;
}

.filter {
  flex: 1;
  border: 1px solid var(--line);
  background: white;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.filter.active {
  border-color: var(--navy);
  background: var(--navy);
  color: white;
}

.issue-list,
.proposal-list,
.timeline {
  display: grid;
  gap: 10px;
}

.issue-list {
  align-content: start;
  max-height: none;
  overflow: visible;
  padding-right: 0;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 240px;
  padding: 24px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

.empty-state span {
  color: var(--teal);
  font-size: 38px;
  font-weight: 900;
}

.issue-card,
.proposal-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  overflow: hidden;
}

.issue-card {
  padding: 16px;
}

.issue-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.issue-number {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--teal-soft);
  color: var(--teal);
  font-size: 13px;
  font-weight: 900;
}

.badge {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

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

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

.badge.low {
  background: var(--blue-soft);
  color: var(--blue);
}

.issue-title {
  font-weight: 900;
  line-height: 1.45;
}

.issue-body {
  margin-top: 7px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.problem-box {
  display: grid;
  gap: 7px;
  margin-top: 12px;
  padding: 12px;
  border: 1px solid rgba(194, 65, 61, 0.24);
  border-left: 4px solid var(--red);
  border-radius: 8px;
  background: #fff8f7;
}

.problem-box strong {
  color: var(--red);
  font-size: 12px;
}

.problem-box p {
  margin: 0;
  color: #7f1d1d;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.7;
  white-space: pre-wrap;
}

.problem-box small {
  color: #9f2f2b;
  font-size: 12px;
  line-height: 1.55;
}

.problem-mark {
  padding: 1px 3px;
  border-radius: 4px;
  background: #ffe1df;
  color: var(--red);
  font-weight: 900;
}

.advice-box {
  display: grid;
  gap: 4px;
  margin-top: 10px;
  padding: 10px;
  border-radius: 8px;
  background: #f8fafb;
}

.advice-box strong {
  color: var(--ink);
  font-size: 12px;
}

.advice-box span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.legal-basis-box {
  display: grid;
  gap: 8px;
  margin-top: 10px;
  padding: 12px;
  border: 1px solid rgba(59, 103, 171, 0.18);
  border-radius: 8px;
  background: #f6f9fe;
}

.legal-basis-box strong {
  color: #244878;
  font-size: 13px;
}

.legal-basis-box ul {
  display: grid;
  gap: 6px;
  margin: 0;
  padding-left: 18px;
}

.legal-basis-box li {
  color: #3d4d63;
  font-size: 13px;
  line-height: 1.65;
}

.issue-variants {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.issue-variants > strong {
  font-size: 12px;
}

.variant-grid {
  display: grid;
  gap: 8px;
}

@media (min-width: 1280px) {
  .variant-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.variant-option {
  display: grid;
  gap: 5px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.variant-option span {
  font-size: 12px;
  font-weight: 900;
}

.variant-option p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.variant-option.strict {
  border-color: rgba(194, 65, 61, 0.24);
  background: #fff8f7;
}

.variant-option.standard {
  border-color: rgba(15, 118, 110, 0.22);
  background: #f8fcfb;
}

.variant-option.soft {
  border-color: rgba(49, 95, 159, 0.22);
  background: #f7faff;
}

.basis-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}

.basis {
  padding: 5px 8px;
  border-radius: 6px;
  background: #eef3f6;
  color: #465565;
  font-size: 12px;
}

.basis.strong {
  background: #e6f4f1;
  color: var(--teal);
  font-weight: 900;
}

.radar-panel {
  padding: 16px;
}

.utility-panel {
  display: block;
}

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

.angle-item {
  display: grid;
  gap: 8px;
  min-height: 74px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.angle-item strong {
  font-size: 13px;
}

.angle-item span {
  align-self: end;
  color: var(--muted);
  font-size: 12px;
}

.angle-item.flagged {
  border-color: rgba(15, 118, 110, 0.28);
  background: var(--teal-soft);
}

.bottom-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(340px, 0.8fr);
  gap: 14px;
  align-items: start;
}

.audit-panel {
  display: none;
}

.proposal-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  padding: 12px;
}

.tone-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.tone-button {
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.tone-button.active {
  border-color: var(--teal);
  background: var(--teal-soft);
  color: var(--teal);
}

.approval-panel {
  padding: 16px;
  border: 1px solid rgba(217, 224, 232, 0.9);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.8) inset;
}

.approval-page-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.45fr);
  gap: 14px;
  align-items: start;
}

.approval-panel-large {
  min-height: 520px;
}

.approval-side-panel {
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid rgba(217, 224, 232, 0.9);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.88);
}

.approval-side-panel h2 {
  font-size: 24px;
}

.approval-side-panel p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.approval-meta,
.approval-waiting {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border-radius: 8px;
  background: #f5f8fa;
}

.approval-meta span,
.approval-waiting span {
  color: var(--muted);
  font-size: 12px;
}

.approval-meta strong,
.approval-waiting strong {
  font-size: 18px;
}

.approval-waiting {
  border: 1px solid rgba(15, 118, 110, 0.22);
  background: var(--teal-soft);
}

.approval-history {
  display: grid;
  gap: 10px;
  margin-top: 4px;
}

.approval-history ol {
  display: grid;
  gap: 8px;
  max-height: 260px;
  margin: 0;
  padding-left: 20px;
  overflow: auto;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.approval-history strong {
  color: var(--ink);
  font-size: 12px;
}

.approval-history span {
  color: var(--muted);
}

.approval-panel select {
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  font-weight: 800;
}

.history-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(360px, 0.92fr);
  gap: 14px;
  align-items: start;
}

.history-panel {
  display: grid;
  gap: 14px;
  padding: 18px;
  border: 1px solid rgba(217, 224, 232, 0.9);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.9);
}

.history-panel .panel-header > span {
  padding: 7px 11px;
  border-radius: 999px;
  background: #f0f5f5;
  color: var(--teal);
  font-size: 12px;
  font-weight: 900;
}

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

.history-empty {
  padding: 24px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

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

.history-card-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.history-card-head span {
  color: var(--muted);
  font-size: 12px;
}

.history-card-head h3 {
  margin: 3px 0 0;
  font-size: 17px;
}

.history-card-head strong {
  align-self: start;
  flex: 0 0 auto;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--teal-soft);
  color: var(--teal);
  font-size: 12px;
}

.history-meta-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
}

.history-meta-row div {
  padding: 10px;
  border-radius: 8px;
  background: #f5f8fa;
}

.history-meta-row dt {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.history-meta-row dd {
  margin: 4px 0 0;
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
}

.history-diff {
  padding: 12px;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.75;
}

.history-diff span {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 900;
}

.history-diff p {
  margin: 0;
  white-space: pre-wrap;
}

.history-diff.before {
  border: 1px solid #f3c6c1;
  background: #fff7f6;
  color: #8f1d1d;
}

.history-diff.after {
  border: 1px solid rgba(15, 118, 110, 0.2);
  background: #f8fcfb;
  color: #243142;
}

.account-issue-panel {
  display: grid;
  gap: 12px;
  margin-bottom: 14px;
  padding: 14px;
  border: 1px solid rgba(15, 118, 110, 0.22);
  border-radius: 8px;
  background: #f8fcfb;
}

.account-admin-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(420px, 1.05fr);
  gap: 14px;
  align-items: start;
}

.account-issue-page {
  margin-bottom: 0;
}

.account-issue-panel h3 {
  margin: 2px 0 0;
  font-size: 18px;
}

.account-issue-panel h2 {
  margin: 2px 0 0;
  font-size: 24px;
}

.account-policy {
  margin: 0;
  padding: 12px;
  border-radius: 8px;
  background: white;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.account-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr) minmax(170px, 0.6fr) auto;
  gap: 8px;
}

.account-form input,
.account-form select {
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
}

.role-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 8px;
  min-width: 0;
}

.role-group {
  display: grid;
  gap: 6px;
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.role-group strong {
  font-size: 12px;
}

.role-group > span {
  color: var(--teal);
  font-size: 12px;
  font-weight: 900;
}

.role-group ul {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.role-group li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 46px;
  align-items: center;
  gap: 8px;
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.role-group li > div {
  min-width: 0;
}

.role-group small {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.delete-account-button {
  justify-self: end;
  width: 46px;
  min-height: 28px;
  padding: 0 8px;
  border: 1px solid #f3c6c1;
  border-radius: 999px;
  background: #fff7f6;
  color: #8f1d1d;
  font-size: 11px;
  font-weight: 900;
}

.account-card {
  display: grid;
  gap: 4px;
  margin-bottom: 12px;
  padding: 12px;
  border: 1px solid rgba(15, 118, 110, 0.22);
  border-radius: 8px;
  background: #f8fcfb;
}

.account-card span,
.account-card small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.account-card strong {
  font-size: 15px;
}

.approval-steps {
  display: grid;
  gap: 10px;
}

.approval-step {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2px 10px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.approval-step span {
  display: grid;
  grid-row: span 2;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #eef3f6;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.approval-step strong {
  font-size: 14px;
}

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

.approval-step.active {
  border-color: rgba(15, 118, 110, 0.35);
  background: var(--teal-soft);
}

.approval-step.done span {
  background: var(--teal);
  color: white;
}

.approval-action {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.approval-action p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.approval-action button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
  transform: none;
}

.approval-comment,
.message-draft {
  width: 100%;
  min-height: 92px;
  margin-top: 12px;
  resize: vertical;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
  background: #fbfcfd;
  color: var(--ink);
  font-family: inherit;
  font-size: 13px;
  line-height: 1.6;
}

.approval-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.negotiation-panel {
  padding: 16px;
}

.message-draft {
  min-height: 260px;
  margin-top: 0;
}

.proposal-card h3 {
  margin: 0 0 8px;
  font-size: 14px;
}

.proposal-card p {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.proposal-card code {
  display: block;
  margin-top: 8px;
  padding: 10px;
  border-radius: 8px;
  background: #f5f7f9;
  color: #26313d;
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.apply-button {
  align-self: start;
  min-height: 38px;
  padding: 0 12px;
  border-radius: 8px;
  background: var(--teal-soft);
  color: var(--teal);
  font-weight: 900;
}

.apply-button.applied {
  background: #eef1f3;
  color: var(--muted);
}

.icon-button {
  width: 38px;
  min-width: 38px;
  background: #eef3f6;
  color: var(--ink);
  font-size: 20px;
}

.timeline {
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

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

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

  .sidebar {
    position: static;
    display: flex;
    gap: 14px;
    height: auto;
  }

  .sidebar .system-card,
  .sidebar .source-card,
  .sidebar .metric-stack {
    display: none;
  }

  .review-grid,
  .bottom-grid,
  .intake-panel,
  .status-strip {
    grid-template-columns: 1fr 1fr;
  }

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

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

  #reviewPage .review-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .workspace {
    width: auto;
    padding: 18px;
  }

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

  .top-actions,
  .panel-header,
  .editor-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .review-grid,
  .bottom-grid,
  .intake-panel,
  .status-strip {
    grid-template-columns: 1fr;
  }

  #reviewPage .review-grid,
  #reviewPage.has-review .bottom-grid {
    grid-template-columns: 1fr;
  }

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

  .segmented {
    overflow-x: auto;
  }

  textarea {
    min-height: 70vh;
  }

  #reviewPage textarea,
  #reviewPage #contractInput,
  .document-text {
    min-height: 70vh;
  }

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

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

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

  .history-grid,
  .history-meta-row,
  .account-admin-grid,
  .account-form,
  .role-list,
  .opinion-grid {
    grid-template-columns: 1fr;
  }
}
