:root {
  --bg: #f6f8fb;
  --panel: #ffffff;
  --line: #d7dce5;
  --text: #111827;
  --muted: #5b6472;
  --brand: #0f766e;
  --brand-2: #115e59;
  --warn: #b45309;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", "Ubuntu", sans-serif;
  background: linear-gradient(160deg, #f8fafc, #eef6f8 55%, #f4f7ff);
  color: var(--text);
}
.wrap { max-width: 1100px; margin: 0 auto; padding: 24px; }
h1 { margin: 0 0 4px; font-size: 24px; letter-spacing: 0.2px; }
.sub { color: var(--muted); margin-bottom: 24px; font-size: 13px; }

.grid { display: grid; grid-template-columns: 1fr; gap: 16px; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 2px 6px rgba(16,24,40,0.04);
}
.card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.step-badge {
  width: 26px; height: 26px; border-radius: 50%;
  background: #111827; color: #fff;
  font-size: 12px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.card-header h2 { margin: 0; font-size: 15px; color: #0f172a; font-weight: 700; }
.card-header .hint { margin-left: auto; font-size: 11px; color: var(--muted); }

.row   { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 8px; }
.row-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 8px; }
.row-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 8px; }

label { display: block; font-size: 11px; color: var(--muted); margin-bottom: 3px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.3px; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 7px 9px;
  font-size: 13px;
  background: #fff;
  transition: border-color 0.15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: #0f766e; box-shadow: 0 0 0 2px rgba(15,118,110,0.12); }
textarea { min-height: 80px; font-family: ui-monospace, Menlo, Consolas, monospace; resize: vertical; }
textarea.plain { font-family: inherit; }
select[multiple] { height: 110px; }

.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 4px; }

button {
  border: 1px solid var(--brand);
  background: var(--brand);
  color: #fff;
  border-radius: 7px;
  padding: 7px 13px;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  transition: opacity 0.15s;
  white-space: nowrap;
}
button:hover { opacity: 0.88; }
button:disabled { opacity: 0.5; cursor: not-allowed; }
button.secondary { background: #fff; color: var(--brand-2); }
button.warn { border-color: var(--warn); color: var(--warn); background: #fff; font-weight: 500; }
button.pdf-btn { border-color: #2563eb; background: #2563eb; font-size: 14px; padding: 9px 18px; }
button.icon-btn { padding: 5px 9px; font-size: 12px; }

.pill {
  display: inline-block;
  background: #ecfeff; color: #0f766e;
  border: 1px solid #a5f3fc;
  border-radius: 999px; padding: 2px 8px; font-size: 11px;
  margin-right: 4px; margin-bottom: 4px;
}

.item {
  border: 1px dashed #cdd5e1;
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 10px;
  background: #fcfdff;
}
.item:last-child { margin-bottom: 0; }

.pkg-header {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 10px; padding-bottom: 8px;
  border-bottom: 1px solid #e2e8f0;
}
.pkg-num {
  width: 22px; height: 22px; border-radius: 50%;
  background: #e2e8f0; color: #334155;
  font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.pkg-name-input {
  flex: 1;
  border: 1px solid transparent;
  background: transparent;
  font-size: 14px; font-weight: 600; color: #0f172a;
  padding: 3px 6px; border-radius: 5px;
}
.pkg-name-input:focus { border-color: var(--line); background: #fff; }

.muted { color: var(--muted); font-size: 12px; }
.ok { color: #047857; font-size: 12px; }
.err { color: #b91c1c; font-size: 12px; }

.routing-notice {
  margin-top: 10px;
  background: #fffbeb; border: 1px solid #fcd34d;
  border-radius: 8px; padding: 10px 12px;
  font-size: 12px; color: #92400e;
}
.routing-ok {
  margin-top: 8px;
  background: #f0fdf4; border: 1px solid #86efac;
  border-radius: 6px; padding: 6px 10px;
  font-size: 12px; color: #166534;
}

.contract-preview { margin-top: 12px; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.cp-header { background: #111827; color: #fff; padding: 12px 14px; }
.cp-title { font-size: 18px; font-weight: 700; margin: 0; }
.cp-sub { font-size: 12px; color: #93c5fd; margin-top: 3px; }
.cp-body { padding: 14px; }
.cp-section { margin-bottom: 14px; }
.cp-section h3 { margin: 0 0 8px; font-size: 11px; letter-spacing: 0.6px; text-transform: uppercase; color: #334155; border-bottom: 1px solid #e2e8f0; padding-bottom: 4px; }
.cp-row { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; padding: 2px 0; }
.cp-row .k { color: #475569; }
.cp-row .v { color: #0f172a; font-weight: 600; }
.cp-list { margin: 0; padding-left: 18px; font-size: 12px; color: #334155; }

.arr-box {
  background: linear-gradient(135deg, #ecfdf5, #d1fae5);
  border: 2px solid #6ee7b7; border-radius: 10px;
  padding: 12px 16px; margin-bottom: 14px;
  display: flex; justify-content: space-between; align-items: center;
}
.arr-label { font-size: 13px; color: #065f46; font-weight: 600; }
.arr-value { font-size: 22px; font-weight: 800; color: #047857; }
.arr-sub { font-size: 11px; color: #6b7280; }

.kpi-table { width: 100%; border-collapse: collapse; font-size: 12px; margin-top: 6px; }
.kpi-table th { background: #0f172a; color: #93c5fd; padding: 4px 8px; text-align: left; font-size: 11px; }
.kpi-table td { padding: 4px 8px; border-bottom: 1px solid #e2e8f0; }
.kpi-table tr:last-child td { border-bottom: none; }
.kpi-table td:last-child { text-align: right; font-weight: 600; color: #2563eb; }

.period-row { display: flex; justify-content: space-between; font-size: 12px; padding: 3px 0; border-bottom: 1px solid #f1f5f9; }
.period-row:last-child { border-bottom: none; }
.period-total { display: flex; justify-content: space-between; font-size: 13px; font-weight: 700; margin-top: 6px; padding-top: 6px; border-top: 2px solid #0f172a; }

.sim-out {
  margin-top: 10px; border: 1px solid #d1d5db; border-radius: 8px;
  background: #f8fafc; padding: 10px; max-height: 260px; overflow: auto;
  font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; white-space: pre-wrap;
}

.org-banner {
  background: #f0fdf4; border: 1px solid #86efac; border-radius: 8px;
  padding: 10px 14px; margin-top: 10px;
  display: flex; align-items: center; gap: 10px;
}
.org-name { font-size: 15px; font-weight: 700; color: #065f46; }
.org-id { font-size: 11px; color: #6b7280; }

.template-preview-text {
  background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 6px;
  padding: 10px; font-size: 11px; white-space: pre-wrap; color: #334155;
  max-height: 200px; overflow: auto; margin-top: 6px;
}
details summary { cursor: pointer; color: var(--brand-2); font-size: 12px; font-weight: 600; user-select: none; }

.sep { height: 1px; background: var(--line); margin: 12px 0; }

.price-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.price-item { position: relative; }
.price-item .currency-tag {
  position: absolute; right: 9px; top: 50%; transform: translateY(-50%);
  font-size: 11px; color: var(--muted); pointer-events: none;
}
.price-item input { padding-right: 36px; }

.mode-toggle {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  cursor: pointer;
  flex-shrink: 0;
}
.mode-toggle input[type="checkbox"] {
  width: auto;
  cursor: pointer;
  accent-color: var(--brand);
}

.static-project-row {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-bottom: 6px;
}
.static-project-row input { margin-bottom: 0; }

/* Download warning banner */
.warn-banner {
  background: #fef3c7;
  border: 1px solid #f59e0b;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px;
  color: #92400e;
  margin-bottom: 16px;
}

/* Deals file manager */
.deal-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 8px;
  overflow: hidden;
}
.deal-row--current {
  border-color: var(--brand);
  box-shadow: 0 0 0 2px rgba(15,118,110,0.12);
}
.deal-row-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg);
  cursor: pointer;
  user-select: none;
}
.deal-row-header:hover { background: #edf2f7; }
.deal-row-title {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
}
.deal-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.deal-chevron {
  font-size: 12px;
  color: var(--muted);
  flex-shrink: 0;
}
.deal-versions {
  border-top: 1px solid var(--line);
  padding: 8px 12px;
  background: var(--panel);
}
.version-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 0;
  border-bottom: 1px solid var(--line);
}
.version-row:last-child { border-bottom: none; }
.version-label {
  font-size: 12px;
  color: var(--text);
  flex: 1;
  min-width: 0;
}

/* Badges */
.badge-downloaded {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  background: #d1fae5;
  color: #065f46;
  border: 1px solid #6ee7b7;
  border-radius: 4px;
  padding: 1px 5px;
  flex-shrink: 0;
}
.badge-current {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  background: #dbeafe;
  color: #1e40af;
  border: 1px solid #93c5fd;
  border-radius: 4px;
  padding: 1px 5px;
  flex-shrink: 0;
}

/* ─── Change Notice / Diff ─────────────────────────────────────────────── */

.cn-baseline-status {
  font-size: 11px;
  color: var(--muted);
  margin-top: 6px;
  min-height: 16px;
}

/* Modal backdrop */
.cn-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 1000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 32px 16px;
  overflow-y: auto;
}
.cn-modal {
  background: #fff;
  border-radius: 14px;
  width: 100%;
  max-width: 820px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.22);
  overflow: hidden;
  flex-shrink: 0;
}
.cn-modal-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.cn-content {
  padding: 20px 24px;
}

/* Document header */
.cn-header {
  background: #111827;
  color: #fff;
  border-radius: 10px;
  padding: 18px 22px;
  margin-bottom: 16px;
}
.cn-header-brand {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 2.5px;
  color: #6ee7b7;
  text-transform: uppercase;
  margin-bottom: 6px;
}
.cn-header-title {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.3px;
}
.cn-header-meta {
  margin-top: 8px;
  font-size: 12px;
  color: #94a3b8;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.cn-meta-sep {
  opacity: 0.4;
}

/* Summary banner */
.cn-summary {
  display: flex;
  align-items: center;
  gap: 16px;
  background: #f0f9ff;
  border: 2px solid #7dd3fc;
  border-radius: 10px;
  padding: 14px 18px;
  margin-bottom: 18px;
}
.cn-summary--single {
  background: #fff7ed;
  border-color: #fb923c;
}
.cn-summary-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #0ea5e9;
  color: #fff;
  font-size: 18px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.cn-summary--single .cn-summary-icon {
  background: #f97316;
  font-size: 24px;
}
.cn-summary-title {
  font-size: 17px;
  font-weight: 700;
  color: #0f172a;
}
.cn-summary-detail {
  font-size: 12px;
  color: #64748b;
  margin-top: 3px;
}

/* Section grouping */
.cn-section {
  margin-bottom: 18px;
}
.cn-section-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: #64748b;
  border-bottom: 1px solid #e2e8f0;
  padding-bottom: 5px;
  margin-bottom: 8px;
}

/* Individual change item */
.cn-change {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 8px;
  background: #fafafa;
}
.cn-change--prominent {
  border-width: 2px;
  border-color: #f97316;
  background: #fff7ed;
  padding: 20px 22px;
  margin-bottom: 16px;
  border-radius: 10px;
}
.cn-change-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.cn-change-label {
  font-weight: 600;
  font-size: 13px;
  color: #0f172a;
}
.cn-change-section-tag {
  font-size: 10px;
  color: #94a3b8;
  margin-left: auto;
  white-space: nowrap;
}

/* Type badges */
.cn-badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  flex-shrink: 0;
}
.cn-badge--added   { background: #dcfce7; color: #166534; }
.cn-badge--removed { background: #fee2e2; color: #991b1b; }
.cn-badge--changed { background: #fef3c7; color: #92400e; }

/* Value rows for simple changes */
.cn-values {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.cn-value {
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  line-height: 1.4;
}
.cn-value--removed { background: #fef2f2; border: 1px solid #fecaca; }
.cn-value--added   { background: #f0fdf4; border: 1px solid #bbf7d0; }
.cn-value-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-right: 8px;
  color: #94a3b8;
}

/* Text block diff (for large text like contract terms) */
.cn-text-diff {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.cn-text-block {
  border-radius: 6px;
  overflow: hidden;
}
.cn-text-block--removed { border: 1px solid #fecaca; }
.cn-text-block--added   { border: 1px solid #bbf7d0; }
.cn-text-block-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 5px 10px;
}
.cn-text-block--removed .cn-text-block-label { background: #fef2f2; color: #991b1b; }
.cn-text-block--added   .cn-text-block-label { background: #f0fdf4; color: #166534; }
.cn-text-pre {
  margin: 0;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 12px;
  line-height: 1.65;
  white-space: pre-wrap;
  max-height: 360px;
  overflow-y: auto;
}
.cn-text-block--removed .cn-text-pre { background: #fff5f5; color: #7f1d1d; }
.cn-text-block--added   .cn-text-pre { background: #f0fdf4; color: #14532d; }

/* Footer disclaimer */
.cn-footer {
  margin-top: 22px;
  padding: 12px 16px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-size: 12px;
  color: #475569;
  line-height: 1.6;
}

/* No changes state */
.cn-no-changes {
  text-align: center;
  padding: 40px 24px;
  color: #047857;
}
.cn-no-changes-icon { font-size: 36px; margin-bottom: 10px; }
.cn-no-changes-text { font-size: 14px; font-weight: 500; }

/* Print — show only the modal content */
@media print {
  body > .wrap { display: none; }
  .cn-modal-backdrop { position: static; padding: 0; background: none; }
  .cn-modal { box-shadow: none; border-radius: 0; max-width: 100%; }
  .cn-modal-toolbar { display: none; }
  .cn-text-pre { max-height: none; }
}
