:root {
  --navy-950: #04162f;
  --navy-900: #06234a;
  --navy-800: #0b356d;
  --blue-600: #1769e0;
  --blue-500: #2583f6;
  --blue-100: #e9f3ff;
  --cyan-400: #54c5ee;
  --ink: #122033;
  --ink-soft: #4b5d73;
  --muted: #738399;
  --line: #dfe7f0;
  --line-strong: #c9d5e4;
  --surface: #ffffff;
  --surface-subtle: #f6f8fb;
  --canvas: #edf2f7;
  --green: #14825f;
  --green-bg: #e8f7f1;
  --amber: #a96100;
  --amber-bg: #fff5df;
  --red: #b13b43;
  --red-bg: #fff0f1;
  --shadow-sm: 0 1px 2px rgba(9, 30, 66, 0.06);
  --shadow-md: 0 12px 36px rgba(9, 30, 66, 0.1);
  --radius: 14px;
  --font-ui: Inter, "Segoe UI", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  font-size: 16px;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--surface-subtle);
  color: var(--ink);
  font-family: var(--font-ui);
  line-height: 1.45;
}

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

button {
  cursor: pointer;
}

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

.sidebar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  height: 100vh;
  flex-direction: column;
  padding: 24px 16px 18px;
  color: #fff;
  background:
    radial-gradient(circle at 12% 8%, rgba(84, 197, 238, 0.16), transparent 25%),
    linear-gradient(180deg, var(--navy-900) 0%, var(--navy-950) 100%);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 8px 28px;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 12px;
  color: #fff;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.16), rgba(37, 131, 246, 0.2));
  font-size: 0.92rem;
  font-weight: 800;
  letter-spacing: -0.04em;
}

.brand strong,
.profile strong {
  display: block;
  font-size: 0.94rem;
}

.brand span,
.profile span,
.sync-card > span {
  display: block;
  margin-top: 2px;
  color: rgba(255, 255, 255, 0.62);
  font-size: 0.76rem;
}

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

.nav-item {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 11px;
  padding: 11px 12px;
  border: 0;
  border-radius: 10px;
  color: rgba(255, 255, 255, 0.72);
  background: transparent;
  text-align: left;
  font-size: 0.9rem;
  transition: 150ms ease;
}

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

.nav-item.is-active {
  box-shadow: inset 3px 0 var(--cyan-400);
}

[data-icon] {
  display: inline-flex;
}

[data-icon] svg {
  width: 19px;
  height: 19px;
}

.sidebar-bottom {
  display: grid;
  gap: 16px;
  margin-top: auto;
}

.sync-card {
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.055);
}

.sync-card-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #45d39c;
  box-shadow: 0 0 0 4px rgba(69, 211, 156, 0.13);
}

.profile {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.avatar {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 50%;
  color: var(--navy-900);
  background: #ddecff;
  font-size: 0.75rem;
  font-weight: 800;
}

.icon-button,
.mobile-menu {
  display: inline-grid;
  place-items: center;
  border: 0;
  background: transparent;
}

.icon-button {
  color: rgba(255, 255, 255, 0.68);
}

.main-shell {
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 15;
  display: flex;
  min-height: 96px;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 18px clamp(20px, 3vw, 42px);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(14px);
}

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

.eyebrow {
  margin-bottom: 3px;
  color: var(--blue-600);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

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

.topbar h1 {
  margin-bottom: 2px;
  font-size: clamp(1.35rem, 2vw, 1.7rem);
  line-height: 1.15;
  letter-spacing: -0.035em;
}

.topbar p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.84rem;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 18px;
}

.next-stage {
  display: grid;
  justify-items: end;
}

.next-stage span {
  color: var(--muted);
  font-size: 0.7rem;
  text-transform: uppercase;
}

.next-stage strong {
  font-size: 0.8rem;
}

.mobile-menu {
  display: none;
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink);
  background: #fff;
}

.button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 15px;
  border: 1px solid transparent;
  border-radius: 10px;
  font-size: 0.88rem;
  font-weight: 700;
  transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease;
}

.button:hover {
  transform: translateY(-1px);
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
  transform: none;
  box-shadow: none;
}

.button-primary {
  color: #fff;
  background: var(--blue-600);
  box-shadow: 0 7px 18px rgba(23, 105, 224, 0.2);
}

.button-primary:hover {
  background: #115cc8;
}

.button-secondary {
  border-color: var(--line-strong);
  color: var(--ink);
  background: #fff;
}

.button-ghost {
  color: var(--blue-600);
  background: var(--blue-100);
}

.button-danger {
  color: var(--red);
  background: var(--red-bg);
}

.button-sm {
  min-height: 34px;
  padding: 7px 11px;
  font-size: 0.78rem;
}

.app-view {
  padding: clamp(20px, 3vw, 42px);
}

.content-stack {
  display: grid;
  gap: 24px;
  max-width: 1440px;
  margin: 0 auto;
}

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

.metric-card,
.card {
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.metric-card {
  position: relative;
  overflow: hidden;
  padding: 19px;
  border-radius: var(--radius);
}

.metric-card::after {
  position: absolute;
  right: -22px;
  bottom: -28px;
  width: 84px;
  height: 84px;
  border: 14px solid var(--blue-100);
  border-radius: 50%;
  content: "";
}

.metric-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.metric-icon {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 9px;
  color: var(--blue-600);
  background: var(--blue-100);
}

.metric-value {
  position: relative;
  z-index: 1;
  display: block;
  margin-top: 13px;
  font-size: 1.8rem;
  line-height: 1;
  letter-spacing: -0.05em;
}

.metric-foot {
  position: relative;
  z-index: 1;
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.76rem;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(300px, 0.75fr);
  gap: 20px;
  align-items: start;
}

.card {
  border-radius: var(--radius);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 22px 17px;
  border-bottom: 1px solid var(--line);
}

.card-header h2,
.section-heading h2 {
  margin-bottom: 3px;
  font-size: 1rem;
  letter-spacing: -0.02em;
}

.card-header p,
.section-heading p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.card-body {
  padding: 22px;
}

.quick-import {
  position: relative;
  overflow: hidden;
  padding: 25px;
  border: 1px solid #bddbff;
  border-radius: var(--radius);
  color: #fff;
  background:
    radial-gradient(circle at 90% 0, rgba(84, 197, 238, 0.32), transparent 34%),
    linear-gradient(125deg, var(--navy-900), var(--navy-800));
  box-shadow: var(--shadow-md);
}

.quick-import::after {
  position: absolute;
  right: -42px;
  bottom: -70px;
  width: 190px;
  height: 190px;
  border: 28px solid rgba(255, 255, 255, 0.06);
  border-radius: 50%;
  content: "";
}

.quick-import-content {
  position: relative;
  z-index: 1;
  max-width: 720px;
}

.quick-import h2 {
  margin-bottom: 7px;
  font-size: 1.2rem;
}

.quick-import p {
  max-width: 620px;
  margin-bottom: 17px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.84rem;
}

.url-composer {
  display: flex;
  gap: 9px;
  padding: 7px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(8px);
}

.url-composer input {
  min-width: 0;
  flex: 1;
  padding: 8px 10px;
  border: 0;
  outline: 0;
  color: #fff;
  background: transparent;
  font-size: 0.84rem;
}

.url-composer input::placeholder {
  color: rgba(255, 255, 255, 0.58);
}

.url-composer .button {
  color: var(--navy-900);
  background: #fff;
}

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

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.data-table th {
  padding: 11px 13px;
  color: var(--muted);
  background: #f9fbfd;
  text-align: left;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.035em;
  text-transform: uppercase;
}

.data-table td {
  padding: 14px 13px;
  border-top: 1px solid var(--line);
  vertical-align: middle;
}

.data-table tbody tr:hover {
  background: #f9fbfe;
}

.data-table strong {
  display: block;
  margin-bottom: 2px;
  font-size: 0.83rem;
}

.subtext {
  color: var(--muted);
  font-size: 0.74rem;
}

.status-pill,
.source-pill,
.confidence {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 800;
  white-space: nowrap;
}

.status-pill {
  padding: 5px 9px;
}

.status-blue {
  color: #145aaf;
  background: var(--blue-100);
}

.status-green {
  color: var(--green);
  background: var(--green-bg);
}

.status-amber {
  color: var(--amber);
  background: var(--amber-bg);
}

.status-gray {
  color: #596b80;
  background: #edf1f5;
}

.source-pill {
  padding: 4px 8px;
  color: #315578;
  background: #edf4fb;
}

.source-pill svg,
.confidence svg {
  width: 14px;
  height: 14px;
}

.pending-list,
.attachment-list,
.check-list,
.timeline,
.section-list {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.pending-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 11px;
  align-items: start;
  padding-bottom: 13px;
  border-bottom: 1px solid var(--line);
}

.pending-item:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.pending-icon {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 9px;
  color: var(--amber);
  background: var(--amber-bg);
}

.pending-item strong {
  display: block;
  font-size: 0.8rem;
}

.pending-item p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.74rem;
}

.pending-item time {
  color: var(--muted);
  font-size: 0.7rem;
}

.flow-shell {
  max-width: 1240px;
  margin: 0 auto;
}

.stepper {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  margin-bottom: 24px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.step {
  position: relative;
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 9px;
  padding: 13px 15px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
}

.step:not(:last-child)::after {
  position: absolute;
  top: 0;
  right: 0;
  width: 1px;
  height: 100%;
  background: var(--line);
  content: "";
}

.step-number {
  display: grid;
  width: 25px;
  height: 25px;
  flex: 0 0 25px;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  font-size: 0.68rem;
}

.step.is-active {
  color: var(--blue-600);
  background: #f6faff;
}

.step.is-active .step-number {
  border-color: var(--blue-600);
  color: #fff;
  background: var(--blue-600);
}

.step.is-done {
  color: var(--green);
}

.step.is-done .step-number {
  border-color: var(--green);
  color: #fff;
  background: var(--green);
}

.flow-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(290px, 0.7fr);
  gap: 20px;
  align-items: start;
}

.field-label {
  display: block;
  margin-bottom: 7px;
  color: #31465f;
  font-size: 0.76rem;
  font-weight: 800;
}

.text-input,
.select-input,
.text-area,
.cell-input {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  outline: none;
  color: var(--ink);
  background: #fff;
  transition: border 120ms ease, box-shadow 120ms ease;
}

.text-input,
.select-input {
  min-height: 44px;
  padding: 9px 12px;
}

.text-area {
  min-height: 92px;
  padding: 10px 12px;
  resize: vertical;
}

.text-input:focus,
.select-input:focus,
.text-area:focus,
.cell-input:focus {
  border-color: var(--blue-500);
  box-shadow: 0 0 0 3px rgba(37, 131, 246, 0.12);
}

.helper-text {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 0.72rem;
}

.separator-text {
  display: flex;
  align-items: center;
  gap: 11px;
  margin: 22px 0;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
}

.separator-text::before,
.separator-text::after {
  height: 1px;
  flex: 1;
  background: var(--line);
  content: "";
}

.upload-zone {
  display: grid;
  min-height: 158px;
  place-items: center;
  padding: 20px;
  border: 1.5px dashed #b9c9db;
  border-radius: 12px;
  background: #f9fbfd;
  text-align: center;
}

.upload-zone span[data-icon] {
  display: grid;
  width: 42px;
  height: 42px;
  margin: 0 auto 9px;
  place-items: center;
  border-radius: 11px;
  color: var(--blue-600);
  background: var(--blue-100);
}

.upload-zone strong {
  display: block;
  font-size: 0.84rem;
}

.upload-zone p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 0.73rem;
}

.info-list {
  display: grid;
  gap: 14px;
  margin: 0;
}

.info-row {
  display: grid;
  grid-template-columns: 115px 1fr;
  gap: 13px;
}

.info-row dt {
  color: var(--muted);
  font-size: 0.74rem;
}

.info-row dd {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 700;
}

.flow-actions {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 22px;
}

.analysis-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 20px;
}

.analysis-hero {
  padding: 28px;
  border-radius: var(--radius);
  color: #fff;
  background: linear-gradient(130deg, var(--navy-900), #0e4d91);
}

.analysis-hero h2 {
  margin-bottom: 8px;
  font-size: 1.3rem;
}

.analysis-hero p {
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.82rem;
}

.progress-track {
  height: 8px;
  margin: 24px 0 10px;
  overflow: hidden;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.15);
}

.progress-bar {
  width: 16%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--cyan-400), #fff);
  transition: width 500ms ease;
}

.progress-copy {
  display: flex;
  justify-content: space-between;
  color: rgba(255, 255, 255, 0.75);
  font-size: 0.72rem;
}

.analysis-step {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.analysis-step:last-child {
  border-bottom: 0;
}

.analysis-step-icon {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 10px;
  color: var(--muted);
  background: #eef2f7;
}

.analysis-step.is-done .analysis-step-icon {
  color: var(--green);
  background: var(--green-bg);
}

.analysis-step.is-active .analysis-step-icon {
  color: var(--blue-600);
  background: var(--blue-100);
}

.analysis-step strong {
  display: block;
  font-size: 0.8rem;
}

.analysis-step span {
  color: var(--muted);
  font-size: 0.72rem;
}

.document-file {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.document-link {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.document-link:hover strong {
  color: var(--blue-600);
}

.file-icon {
  display: grid;
  width: 37px;
  height: 37px;
  flex: 0 0 37px;
  place-items: center;
  border-radius: 9px;
  color: var(--blue-600);
  background: var(--blue-100);
}

.document-file strong {
  display: block;
  overflow: hidden;
  max-width: 210px;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.77rem;
}

.document-file span {
  color: var(--muted);
  font-size: 0.7rem;
}

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

.summary-block {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #fff;
}

.summary-block span {
  color: var(--muted);
  font-size: 0.7rem;
}

.summary-block strong {
  display: block;
  margin-top: 4px;
  font-size: 0.85rem;
}

.field-review-table td:nth-child(2) {
  max-width: 460px;
}

.field-review-table tr.has-warning {
  background: #fffbf2;
}

.confidence {
  padding: 5px 8px;
}

.confidence.high {
  color: var(--green);
  background: var(--green-bg);
}

.confidence.review {
  color: var(--amber);
  background: var(--amber-bg);
}

.source-detail {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.warning-strip {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 14px 16px;
  border: 1px solid #efd195;
  border-radius: 11px;
  color: #744600;
  background: var(--amber-bg);
  font-size: 0.78rem;
}

.warning-strip strong {
  display: block;
  margin-bottom: 2px;
}

.items-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 17px;
  border-bottom: 1px solid var(--line);
  background: #f9fbfd;
}

.selection-summary {
  display: flex;
  align-items: center;
  gap: 14px;
  color: var(--muted);
  font-size: 0.78rem;
}

.selection-summary strong {
  color: var(--ink);
}

.items-table th:first-child,
.items-table td:first-child {
  width: 46px;
  text-align: center;
}

.items-table th:nth-child(2),
.items-table td:nth-child(2) {
  width: 54px;
  text-align: center;
}

.items-table td {
  min-width: 86px;
}

.items-table td.description-cell {
  min-width: 290px;
}

.items-table tr:not(.is-selected) {
  color: #77879a;
  background: #fafbfc;
}

.items-table input[type="checkbox"] {
  width: 17px;
  height: 17px;
  accent-color: var(--blue-600);
}

.cell-input {
  min-width: 76px;
  padding: 7px 8px;
  font-size: 0.78rem;
}

.cell-input.unit {
  min-width: 120px;
}

.cell-input.price {
  min-width: 96px;
  text-align: right;
}

.cell-description {
  min-width: 300px;
  resize: vertical;
  line-height: 1.35;
}

.table-total {
  font-weight: 800;
  white-space: nowrap;
}

.items-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 17px 20px;
  border-top: 1px solid var(--line);
}

.grand-total span {
  display: block;
  color: var(--muted);
  font-size: 0.7rem;
  text-transform: uppercase;
}

.grand-total strong {
  font-size: 1.1rem;
}

.editor-shell {
  max-width: none;
  margin: -18px;
}

.editor-stepper {
  max-width: 1240px;
  margin: 18px auto 20px;
}

.editor-toolbar {
  position: sticky;
  top: 96px;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 16px;
  border: 1px solid var(--line);
  border-radius: 12px 12px 0 0;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(12px);
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 7px;
}

.tool-button {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  gap: 6px;
  padding: 6px 9px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: #3b5068;
  background: transparent;
  font-size: 0.75rem;
}

.tool-button:hover,
.tool-button.is-active {
  border-color: var(--line);
  background: #f5f8fb;
}

.tool-button span[data-icon] svg {
  width: 16px;
  height: 16px;
}

.editor-workspace {
  display: grid;
  grid-template-columns: 148px minmax(620px, 1fr) 292px;
  min-height: calc(100vh - 196px);
  border: 1px solid var(--line);
  border-top: 0;
  background: var(--canvas);
}

.page-thumbnails,
.editor-inspector {
  position: sticky;
  top: 143px;
  align-self: start;
  max-height: calc(100vh - 160px);
  overflow-y: auto;
  background: #fff;
}

.page-thumbnails {
  height: 100%;
  padding: 16px 12px;
  border-right: 1px solid var(--line);
}

.thumb-title {
  display: block;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.page-thumb {
  width: 100%;
  margin-bottom: 14px;
  padding: 6px;
  border: 2px solid transparent;
  border-radius: 8px;
  background: transparent;
}

.page-thumb.is-active {
  border-color: var(--blue-500);
  background: var(--blue-100);
}

.page-thumb-paper {
  position: relative;
  aspect-ratio: 210 / 297;
  overflow: hidden;
  border: 1px solid #d1dae5;
  background: #fff;
  box-shadow: var(--shadow-sm);
}

.page-thumb-paper::before {
  position: absolute;
  inset: 11px;
  background: repeating-linear-gradient(to bottom, #d9e0e8 0 2px, transparent 2px 8px);
  content: "";
  opacity: 0.8;
}

.page-thumb-paper.page-two::before {
  background:
    linear-gradient(#d9e0e8 0 0) 0 0 / 100% 2px no-repeat,
    repeating-linear-gradient(to bottom, #d9e0e8 0 2px, transparent 2px 9px);
}

.page-thumb span {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.68rem;
  text-align: center;
}

.document-canvas {
  display: grid;
  justify-items: center;
  gap: 28px;
  min-width: 0;
  padding: 30px 24px 60px;
}

.paper {
  position: relative;
  width: min(100%, 760px);
  min-height: 1075px;
  padding: 52px 58px 62px;
  color: #111;
  background: #fff;
  box-shadow: 0 8px 30px rgba(27, 43, 62, 0.15);
  font-family: Arial, sans-serif;
  font-size: 12px;
  line-height: 1.45;
}

.paper-header-image {
  display: block;
  width: calc(100% + 24px);
  max-height: 126px;
  margin: -24px -12px 26px;
  object-fit: contain;
}

.paper h2 {
  margin: 0 0 20px;
  font-size: 17px;
  text-align: center;
  letter-spacing: 0.03em;
}

.paper h3 {
  margin: 20px 0 9px;
  font-size: 12px;
}

.paper p {
  margin-bottom: 9px;
  text-align: justify;
}

.paper-field {
  outline: none;
}

.paper-field:hover,
.paper-field:focus {
  background: #eef6ff;
  box-shadow: 0 0 0 2px #eef6ff;
}

.proposal-table {
  width: 100%;
  margin: 9px 0 13px;
  border-collapse: collapse;
  font-size: 9px;
}

.proposal-table th,
.proposal-table td {
  padding: 6px 5px;
  border: 1px solid #777;
  vertical-align: middle;
}

.proposal-table th {
  color: #fff;
  background: var(--navy-900);
  text-align: center;
}

.proposal-table td:nth-child(1),
.proposal-table td:nth-child(3),
.proposal-table td:nth-child(4),
.proposal-table td:nth-child(5),
.proposal-table td:nth-child(6) {
  text-align: center;
}

.paper-total {
  font-weight: 700;
}

.declaration-list {
  margin: 8px 0 0;
  padding-left: 19px;
}

.declaration-list li {
  margin-bottom: 8px;
  text-align: justify;
}

.bank-block {
  padding: 10px 12px;
  border: 1px solid #9ca6b2;
  background: #f6f8fa;
}

.signature {
  margin-top: 45px;
  text-align: center;
}

.signature-line {
  width: 310px;
  margin: 0 auto 7px;
  border-top: 1px solid #111;
}

.signature p {
  margin: 2px 0;
  text-align: center;
}

.paper-footer-image {
  position: absolute;
  right: 42px;
  bottom: 28px;
  left: 42px;
  width: calc(100% - 84px);
  height: 30px;
  object-fit: cover;
}

.page-number {
  position: absolute;
  right: 58px;
  bottom: 14px;
  color: #65717e;
  font-size: 8px;
}

.editor-inspector {
  height: 100%;
  padding: 18px;
  border-left: 1px solid var(--line);
}

.inspector-heading {
  margin-bottom: 15px;
}

.inspector-heading strong {
  display: block;
  font-size: 0.85rem;
}

.inspector-heading span {
  color: var(--muted);
  font-size: 0.72rem;
}

.section-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 9px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.drag-handle {
  color: #9aa7b6;
  font-weight: 800;
  letter-spacing: -0.12em;
}

.section-row strong {
  display: block;
  font-size: 0.76rem;
}

.section-row span {
  color: var(--muted);
  font-size: 0.68rem;
}

.switch {
  position: relative;
  display: inline-block;
  width: 34px;
  height: 20px;
}

.switch input {
  width: 0;
  height: 0;
  opacity: 0;
}

.switch span {
  position: absolute;
  inset: 0;
  border-radius: 99px;
  background: #c9d2dd;
  transition: 150ms ease;
}

.switch span::before {
  position: absolute;
  bottom: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
  content: "";
  transition: 150ms ease;
}

.switch input:checked + span {
  background: var(--blue-600);
}

.switch input:checked + span::before {
  transform: translateX(14px);
}

.source-card {
  margin-top: 18px;
  padding: 13px;
  border: 1px solid #c9e1fb;
  border-radius: 10px;
  background: #f2f8ff;
}

.source-card strong {
  display: block;
  color: #204a75;
  font-size: 0.76rem;
}

.source-card p {
  margin: 5px 0 0;
  color: #54718d;
  font-size: 0.7rem;
}

.final-review-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.65fr);
  gap: 20px;
  align-items: start;
}

.score-ring {
  display: grid;
  width: 86px;
  height: 86px;
  place-items: center;
  border-radius: 50%;
  background: conic-gradient(var(--green) 0 92%, #e6ebf1 92% 100%);
}

.score-ring::before {
  display: grid;
  width: 66px;
  height: 66px;
  place-items: center;
  border-radius: 50%;
  background: #fff;
  content: "92%";
  font-size: 1.05rem;
  font-weight: 800;
}

.review-score {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 22px;
  border-bottom: 1px solid var(--line);
}

.review-score h2 {
  margin-bottom: 4px;
  font-size: 1.05rem;
}

.review-score p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.check-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 11px;
  align-items: start;
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
}

.check-item:last-child {
  border-bottom: 0;
}

.check-symbol {
  display: grid;
  width: 26px;
  height: 26px;
  place-items: center;
  border-radius: 50%;
}

.check-symbol.ok {
  color: var(--green);
  background: var(--green-bg);
}

.check-symbol.warn {
  color: var(--amber);
  background: var(--amber-bg);
}

.check-item strong {
  display: block;
  font-size: 0.8rem;
}

.check-item p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.72rem;
}

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

.export-button {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
  width: 100%;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 11px;
  color: var(--ink);
  background: #fff;
  text-align: left;
}

.export-button:hover {
  border-color: #a9cbf2;
  background: #f7fbff;
}

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

.export-icon {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 10px;
  color: var(--blue-600);
  background: var(--blue-100);
}

.export-button strong {
  display: block;
  font-size: 0.8rem;
}

.export-button span {
  color: var(--muted);
  font-size: 0.7rem;
}

.generated-files {
  display: grid;
  gap: 8px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.generated-files > strong {
  font-size: 0.75rem;
}

.generated-file {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--ink);
  background: #fff;
  text-decoration: none;
}

.generated-file:hover {
  border-color: #a9cbf2;
  background: #f7fbff;
}

.generated-file strong,
.generated-file small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.generated-file strong {
  font-size: 0.72rem;
}

.generated-file small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.66rem;
}

.history-files {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

.timeline-item {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 13px;
  padding-bottom: 22px;
}

.timeline-item:not(:last-child)::after {
  position: absolute;
  top: 32px;
  bottom: 3px;
  left: 15px;
  width: 1px;
  background: var(--line-strong);
  content: "";
}

.timeline-avatar {
  z-index: 1;
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border: 3px solid #fff;
  border-radius: 50%;
  color: #fff;
  background: var(--navy-800);
  box-shadow: 0 0 0 1px var(--line);
  font-size: 0.65rem;
  font-weight: 800;
}

.timeline-item strong {
  display: block;
  font-size: 0.8rem;
}

.timeline-item p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 0.74rem;
}

.timeline-item time {
  color: var(--muted);
  font-size: 0.7rem;
}

.company-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 370px;
  gap: 20px;
  align-items: start;
}

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

.field-span-2 {
  grid-column: span 2;
}

.brand-preview {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.brand-preview img {
  display: block;
  width: 100%;
}

.brand-preview figcaption {
  padding: 12px 14px;
  color: var(--muted);
  font-size: 0.72rem;
}

.toast {
  position: fixed;
  z-index: 100;
  right: 26px;
  bottom: 26px;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 11px;
  min-width: 290px;
  padding: 14px 16px;
  border: 1px solid #b8dfcf;
  border-radius: 12px;
  background: #fff;
  box-shadow: var(--shadow-md);
  opacity: 0;
  transform: translateY(14px);
  pointer-events: none;
  transition: 180ms ease;
}

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

.toast-icon {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 50%;
  color: var(--green);
  background: var(--green-bg);
}

.toast strong,
.toast span {
  display: block;
}

.toast strong {
  font-size: 0.8rem;
}

.toast span {
  color: var(--muted);
  font-size: 0.72rem;
}

.empty-note {
  padding: 14px;
  border: 1px dashed var(--line-strong);
  border-radius: 10px;
  color: var(--muted);
  background: #fafcfe;
  font-size: 0.76rem;
  text-align: center;
}

.local-ai-card {
  overflow: hidden;
  border: 1px solid #b9d8fb;
  box-shadow: 0 8px 28px rgba(23, 105, 224, 0.07);
}

.local-ai-card .card-header {
  background: linear-gradient(110deg, #f7fbff, #eef6ff);
}

.local-ai-grid {
  display: grid;
  grid-template-columns: minmax(240px, 0.7fr) minmax(360px, 1.3fr);
  gap: 22px;
  padding: 22px;
}

.ai-status-stack {
  display: grid;
  align-content: start;
  gap: 9px;
}

.local-capability {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f9fbfd;
}

.capability-icon {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 9px;
  color: var(--amber);
  background: var(--amber-bg);
}

.local-capability.is-ready .capability-icon {
  color: var(--green);
  background: var(--green-bg);
}

.local-capability strong,
.local-capability span {
  display: block;
}

.local-capability strong {
  font-size: 0.78rem;
}

.local-capability div > span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.7rem;
}

.ai-action-panel {
  min-width: 0;
}

.setup-note,
.analysis-result,
.analysis-error {
  padding: 13px 15px;
  border-radius: 10px;
  font-size: 0.76rem;
}

.setup-note {
  border: 1px solid #efd195;
  color: #744600;
  background: var(--amber-bg);
}

.setup-note strong,
.analysis-result strong,
.analysis-result span,
.analysis-error strong,
.analysis-error span {
  display: block;
}

.setup-note ol {
  margin: 7px 0 0;
  padding-left: 19px;
}

.setup-note p {
  margin: 6px 0 0;
}

.setup-note code {
  padding: 2px 5px;
  border-radius: 4px;
  color: var(--navy-900);
  background: rgba(255, 255, 255, 0.72);
  font-size: 0.72rem;
}

.compact-input {
  margin-bottom: 12px;
}

.ai-progress .progress-track {
  margin-top: 8px;
  background: #dae4ef;
}

.ai-progress .progress-bar {
  background: linear-gradient(90deg, var(--blue-600), var(--cyan-400));
}

.ai-progress .progress-copy {
  color: var(--muted);
}

.analysis-result {
  border: 1px solid #a9dfca;
  color: #0f684e;
  background: var(--green-bg);
}

.analysis-error {
  border: 1px solid #f0bec2;
  color: var(--red);
  background: var(--red-bg);
}

.analysis-result span,
.analysis-error span {
  margin-top: 3px;
  font-size: 0.72rem;
}

.ai-buttons {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 14px;
}

.privacy-note {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 0.7rem;
}

.privacy-note [data-icon] {
  flex: 0 0 auto;
  color: var(--green);
}

.comparison-list {
  display: grid;
  gap: 14px;
  padding: 18px 22px 22px;
}

.comparison-item {
  padding: 16px;
  border: 1px solid #efd195;
  border-radius: 11px;
  background: #fffcf6;
}

.comparison-item.is-decided {
  border-color: #b9d8c9;
  background: #f8fcfa;
}

.comparison-heading,
.comparison-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.comparison-heading > div {
  display: flex;
  align-items: center;
  gap: 9px;
}

.comparison-heading strong {
  font-size: 0.82rem;
}

.item-number {
  padding: 4px 7px;
  border-radius: 6px;
  color: var(--navy-800);
  background: var(--blue-100);
  font-size: 0.69rem;
  font-weight: 800;
}

.source-compare-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  margin-top: 14px;
}

.compare-source {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
}

.compare-source.is-chosen {
  border-color: #77c4a6;
  box-shadow: inset 3px 0 var(--green);
}

.compare-source span,
.compare-source strong,
.compare-source small {
  display: block;
}

.compare-source span,
.compare-source small {
  color: var(--muted);
  font-size: 0.68rem;
}

.compare-source strong {
  margin: 5px 0 3px;
  font-size: 0.9rem;
}

.compare-arrow {
  color: var(--blue-600);
}

.evidence-box {
  margin: 11px 0;
  padding: 10px 12px;
  border-left: 3px solid var(--blue-500);
  border-radius: 0 8px 8px 0;
  background: #f3f7fb;
}

.evidence-box strong {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.evidence-box p {
  margin: 4px 0 0;
  color: var(--ink-soft);
  font-size: 0.74rem;
}

.decision-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  color: var(--green);
  font-size: 0.75rem;
  font-weight: 700;
}

.comparison-empty {
  padding: 24px;
}

@media (max-width: 1180px) {
  .metrics-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .editor-workspace {
    grid-template-columns: 120px minmax(570px, 1fr);
  }

  .editor-inspector {
    display: none;
  }
}

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

  .sidebar {
    position: fixed;
    left: 0;
    transform: translateX(-100%);
    width: 260px;
    transition: transform 180ms ease;
  }

  .sidebar.is-open {
    transform: translateX(0);
    box-shadow: 18px 0 50px rgba(5, 24, 49, 0.25);
  }

  .mobile-menu {
    display: inline-grid;
  }

  .dashboard-grid,
  .flow-grid,
  .analysis-layout,
  .local-ai-grid,
  .final-review-grid,
  .company-grid {
    grid-template-columns: 1fr;
  }

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

  .page-thumbnails {
    display: none;
  }

  .document-canvas {
    padding: 20px 10px 40px;
  }
}

@media (max-width: 700px) {
  .topbar {
    min-height: 84px;
    padding: 14px 16px;
  }

  .topbar p,
  .next-stage {
    display: none;
  }

  .topbar-actions .button span[data-icon] {
    display: none;
  }

  .app-view {
    padding: 18px 14px;
  }

  .metrics-grid,
  .review-summary,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .field-span-2 {
    grid-column: auto;
  }

  .quick-import {
    padding: 20px;
  }

  .url-composer {
    flex-direction: column;
  }

  .stepper {
    display: flex;
    overflow-x: auto;
  }

  .step {
    min-width: 132px;
  }

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

  .compare-arrow {
    transform: rotate(90deg);
    justify-self: center;
  }

  .editor-shell {
    margin: -8px;
  }

  .editor-toolbar {
    top: 84px;
    overflow-x: auto;
  }

  .toolbar-group:first-child .tool-button:nth-child(n + 4) {
    display: none;
  }

  .paper {
    min-height: 920px;
    padding: 30px 27px 50px;
    font-size: 9px;
  }

  .paper-header-image {
    margin-top: -10px;
  }

  .proposal-table {
    font-size: 7px;
  }

  .signature-line {
    width: 230px;
  }

  .flow-actions,
  .items-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .flow-actions .button,
  .items-footer .button {
    width: 100%;
  }

  .toast {
    right: 14px;
    bottom: 14px;
    left: 14px;
    min-width: 0;
  }
}

@media print {
  .sidebar,
  .topbar,
  .editor-toolbar,
  .page-thumbnails,
  .editor-inspector,
  .stepper {
    display: none !important;
  }

  .app-shell,
  .editor-workspace {
    display: block;
  }

  .app-view,
  .document-canvas {
    padding: 0;
    background: #fff;
  }

  .paper {
    width: 210mm;
    min-height: 297mm;
    margin: 0;
    box-shadow: none;
    break-after: page;
  }
}
