/* ══════════════════════════════════════════════════════════════════════════════
   Treuhand Dossier Copilot — Dual-Pane Tax & Audit Intelligence CSS
   ══════════════════════════════════════════════════════════════════════════════ */

:root {
  --bg-canvas: #080c14;
  --bg-surface: #0f1523;
  --bg-card: #151d30;
  --bg-card-hover: #1b253d;
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-medium: rgba(255, 255, 255, 0.14);
  --border-focus: #38bdf8;

  --ink-primary: #f8fafc;
  --ink-secondary: #94a3b8;
  --ink-muted: #64748b;

  --swiss-red: #da291c;
  --swiss-red-glow: rgba(218, 41, 28, 0.25);
  --emerald: #10b981;
  --emerald-bg: rgba(16, 185, 129, 0.12);
  --amber: #f59e0b;
  --amber-bg: rgba(245, 158, 11, 0.12);
  --blue: #38bdf8;
  --blue-bg: rgba(56, 189, 248, 0.12);

  --font-sans: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-heading: 'Space Grotesk', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --pane-header-height: 50px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-canvas);
  color: var(--ink-primary);
  min-height: 100vh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

/* ── Top Global Header ──────────────────────────────────────────────────────── */
.app-header {
  height: 70px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  gap: 1.5rem;
  flex-shrink: 0;
  z-index: 20;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 1.75rem;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.swiss-crest {
  font-size: 1.75rem;
  line-height: 1;
  padding: 0.4rem;
  background: rgba(218, 41, 28, 0.15);
  border: 1px solid var(--swiss-red);
  border-radius: 8px;
  box-shadow: 0 0 12px var(--swiss-red-glow);
}

.brand-text h1 {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #fff;
  margin: 0;

  span {
    color: var(--blue);
    font-weight: 400;
  }
}

.brand-tag {
  display: block;
  font-size: 0.72rem;
  color: var(--ink-secondary);
  margin-top: 2px;
}

.dossier-selector-wrap {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding-left: 1.25rem;
  border-left: 1px solid var(--border-subtle);
}

.selector-label {
  font-size: 0.75rem;
  color: var(--ink-muted);
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.05em;
}

.custom-select {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border-medium);
  border-radius: 8px;
  padding: 0.45rem 0.85rem;
  font-size: 0.825rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  user-select: none;
  transition: border-color 0.15s ease;

  &:hover {
    border-color: var(--border-focus);
  }
}

.select-arrow {
  font-size: 0.65rem;
  color: var(--ink-muted);
}

.select-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  width: 320px;
  background: var(--bg-surface);
  border: 1px solid var(--border-medium);
  border-radius: 10px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.6);
  z-index: 50;
  display: none;
  overflow: hidden;

  &.open {
    display: block;
  }
}

.dropdown-item {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: background 0.15s ease;

  &:last-child {
    border-bottom: none;
  }

  strong {
    display: block;
    font-size: 0.85rem;
    color: var(--ink-primary);
  }

  small {
    display: block;
    font-size: 0.75rem;
    color: var(--ink-secondary);
    margin-top: 2px;
  }

  &:hover {
    background: var(--bg-card);
  }

  &.active {
    background: rgba(56, 189, 248, 0.1);
    border-left: 3px solid var(--blue);
  }
}

/* Center KPI chips */
.header-center-kpi {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.kpi-chip {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 0.4rem 0.85rem;
  display: flex;
  flex-direction: column;
  position: relative;

  .chip-label {
    font-size: 0.6875rem;
    color: var(--ink-muted);
    text-transform: uppercase;
    font-weight: 600;
  }

  .chip-val {
    font-family: var(--font-mono);
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--ink-primary);
  }

  &.warning {
    border-color: rgba(245, 158, 11, 0.3);
    background: var(--amber-bg);

    .chip-val {
      color: #fbbf24;
    }
  }

  &.success {
    border-color: rgba(16, 185, 129, 0.3);
    background: var(--emerald-bg);

    .chip-val {
      color: #34d399;
    }
  }
}

.pulse-indicator {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 6px;
  height: 6px;
  background: var(--amber);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--amber);
  animation: pulse-dot 1.5s infinite;
}

@keyframes pulse-dot {
  0% { transform: scale(0.9); opacity: 0.8; }
  50% { transform: scale(1.3); opacity: 1; }
  100% { transform: scale(0.9); opacity: 0.8; }
}

/* Header Actions */
.header-right-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.header-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-card);
  color: var(--ink-primary);
  border: 1px solid var(--border-medium);
  border-radius: 8px;
  padding: 0.55rem 1rem;
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;

  &:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-focus);
  }

  &.primary {
    background: var(--swiss-red);
    border-color: var(--swiss-red);
    color: #fff;
    box-shadow: 0 2px 10px rgba(218, 41, 28, 0.35);

    &:hover {
      background: #b82216;
      box-shadow: 0 4px 16px rgba(218, 41, 28, 0.5);
    }
  }
}

/* ── Dual-Pane Workspace ────────────────────────────────────────────────────── */
.dual-pane-workspace {
  display: grid;
  grid-template-columns: 1fr 1fr;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  background: var(--bg-canvas);
}

.pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.left-pane {
  border-right: 1px solid var(--border-subtle);
  background: #090e18;
}

.right-pane {
  background: var(--bg-surface);
}

/* ── Left Pane: Document Canvas Toolbar ─────────────────────────────────────── */
.pane-toolbar {
  height: var(--pane-header-height);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
  flex-shrink: 0;
}

.doc-tabs {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.doc-tab {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.4rem 0.8rem;
  background: transparent;
  color: var(--ink-secondary);
  border: 1px solid transparent;
  border-radius: 6px;
  font-size: 0.775rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;

  &:hover {
    color: var(--ink-primary);
    background: rgba(255, 255, 255, 0.04);
  }

  &.active {
    color: var(--ink-primary);
    background: var(--bg-card);
    border-color: var(--border-medium);
  }
}

.tab-badge {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.1rem 0.4rem;
  border-radius: 999px;

  &.error {
    background: rgba(239, 68, 68, 0.2);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.35);
  }

  &.warning {
    background: rgba(245, 158, 11, 0.2);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.35);
  }

  &.success {
    background: rgba(16, 185, 129, 0.2);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.35);
  }
}

.doc-controls {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.ctrl-btn {
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--ink-secondary);
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;

  &:hover {
    color: #fff;
    border-color: var(--border-medium);
  }
}

.zoom-level {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--ink-muted);
  min-width: 40px;
  text-align: center;
}

/* ── Left Pane: Document Viewport & Swiss Form ──────────────────────────────── */
.document-viewport {
  flex: 1;
  overflow-y: auto;
  overflow-x: auto;
  padding: 1.5rem;
  display: flex;
  justify-content: center;
  background: #060910;
}

.sheet-document {
  display: none;
  width: 100%;
  max-width: 780px;
  background: #ffffff;
  color: #1a1e29;
  border-radius: 6px;
  padding: 2.25rem 2.5rem;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
  font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
  transition: transform 0.15s ease;
  transform-origin: top center;

  &.active {
    display: block;
  }
}

.sheet-header {
  border-bottom: 2px solid #000;
  padding-bottom: 1rem;
  margin-bottom: 1.5rem;
}

.sheet-logo-group {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.75rem;

  .federal-cross {
    font-size: 2.2rem;
    line-height: 1;
  }

  h3 {
    font-size: 1.05rem;
    font-weight: 700;
    color: #000;
    margin: 0;
  }

  p {
    font-size: 0.75rem;
    color: #4b5563;
    margin: 2px 0 0;
  }
}

.sheet-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;

  .form-title {
    font-size: 1.2rem;
    font-weight: 800;
    color: #000;
    letter-spacing: -0.01em;
  }

  .form-id, .form-uid {
    font-size: 0.78rem;
    font-family: var(--font-mono);
    color: #374151;
  }
}

.form-section {
  margin-bottom: 1.25rem;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  overflow: hidden;

  .section-title {
    background: #f3f4f6;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    padding: 0.4rem 0.75rem;
    border-bottom: 1px solid #d1d5db;
    letter-spacing: 0.05em;
    color: #111827;
  }
}

.form-row {
  display: grid;
  grid-template-columns: 50px 1fr 140px;
  align-items: center;
  padding: 0.45rem 0.75rem;
  border-bottom: 1px solid #e5e7eb;
  font-size: 0.8125rem;
  position: relative;

  &:last-child {
    border-bottom: none;
  }

  &.sum {
    background: #f9fafb;
    font-weight: 700;
  }

  &.grand-total {
    background: #fee2e2;
    padding: 0.75rem;

    .cell-amount.grand {
      font-size: 1.05rem;
      font-weight: 800;
      color: #b91c1c;
    }
  }

  .cell-code {
    font-family: var(--font-mono);
    font-weight: 700;
    color: #374151;
    font-size: 0.8rem;
  }

  .cell-desc {
    color: #1f2937;
    padding-right: 1rem;
    display: flex;
    flex-direction: column;
    gap: 4px;
  }

  .cell-sub {
    font-size: 0.75rem;
    color: #6b7280;
    font-family: var(--font-mono);
  }

  .cell-amount {
    text-align: right;
    font-family: var(--font-mono);
    font-weight: 600;
    color: #111827;

    &.bold {
      font-weight: 800;
    }
  }
}

/* Citation Pins & Flagged Targets on Left Sheet */
.form-row.flagged, .receipt-card.flagged {
  background: #fffbeb !important;
  border-left: 4px solid var(--amber) !important;
  transition: all 0.25s ease;
  cursor: pointer;

  &.active-citation {
    background: #fef3c7 !important;
    border-left: 4px solid #d97706 !important;
    box-shadow: 0 0 0 2px rgba(217, 119, 6, 0.4);
    transform: translateX(4px);
  }

  .flagged-val {
    color: #b45309;
    font-weight: 700;
    text-decoration: underline wavy #f59e0b;
  }
}

.citation-pin-badge {
  position: absolute;
  left: -14px;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  background: var(--amber);
  color: #000;
  font-weight: 800;
  font-size: 0.75rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  animation: pulse-pin 2s infinite;
  z-index: 5;
}

@keyframes pulse-pin {
  0% { transform: translateY(-50%) scale(1); box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.7); }
  70% { transform: translateY(-50%) scale(1.1); box-shadow: 0 0 0 8px rgba(245, 158, 11, 0); }
  100% { transform: translateY(-50%) scale(1); box-shadow: 0 0 0 0 rgba(245, 158, 11, 0); }
}

.flag-pill {
  display: inline-block;
  font-size: 0.6875rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  width: fit-content;

  &.high {
    background: #fee2e2;
    color: #991b1b;
  }

  &.medium {
    background: #fef3c7;
    color: #92400e;
  }
}

.sheet-footer {
  margin-top: 2rem;
  border-top: 1px solid #d1d5db;
  padding-top: 1rem;
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: #6b7280;

  .footer-sign, .footer-official {
    display: flex;
    flex-direction: column;
    gap: 4px;
  }
}

/* Receipt Card & QR Bill Styles */
.receipt-card {
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  padding: 1.25rem;
  margin-bottom: 1.25rem;
  position: relative;

  .receipt-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.75rem;

    h4 {
      font-size: 0.95rem;
      color: #111827;
      margin: 0;
    }

    small {
      color: #6b7280;
    }

    .amount-tag {
      font-family: var(--font-mono);
      font-weight: 700;
      color: #111827;
      font-size: 0.95rem;
    }
  }

  .receipt-body {
    font-size: 0.8125rem;
    color: #374151;

    p {
      margin-bottom: 0.35rem;
    }
  }

  .receipt-flag {
    margin-top: 0.75rem;
    padding: 0.5rem 0.75rem;
    background: #fef2f2;
    border-radius: 4px;
    color: #991b1b;
    font-size: 0.78rem;
  }
}

.qr-bill-mockup {
  display: grid;
  grid-template-columns: 200px 1fr;
  border: 1px dashed #9ca3af;
  border-radius: 6px;
  overflow: hidden;
  font-family: Arial, sans-serif;
  margin-top: 1.5rem;

  .qr-left {
    padding: 1rem;
    background: #f9fafb;
    border-right: 1px solid #e5e7eb;
    font-size: 0.75rem;

    h5 {
      margin-bottom: 0.5rem;
      font-size: 0.8rem;
    }

    p {
      margin-bottom: 0.4rem;
      line-height: 1.3;
    }
  }

  .qr-right {
    padding: 1rem;
    display: flex;
    gap: 1.25rem;

    .qr-code-box {
      width: 90px;
      height: 90px;
      background: #000;
      display: flex;
      align-items: center;
      justify-content: center;
      position: relative;
      flex-shrink: 0;

      .qr-swiss-symbol {
        width: 24px;
        height: 24px;
        background: #da291c;
        color: #fff;
        font-size: 1.2rem;
        font-weight: 800;
        display: flex;
        align-items: center;
        justify-content: center;
      }
    }

    .qr-data {
      font-size: 0.78rem;

      h5 {
        margin-bottom: 0.4rem;
      }

      p {
        margin-bottom: 0.35rem;
        color: #4b5563;
      }
    }
  }
}

/* FIBU Table Mockup */
.fibu-table-wrap {
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  overflow: hidden;
}

.fibu-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;

  th {
    background: #f3f4f6;
    padding: 0.6rem 0.75rem;
    text-align: left;
    font-size: 0.72rem;
    color: #4b5563;
    text-transform: uppercase;
    border-bottom: 1px solid #d1d5db;
  }

  td {
    padding: 0.55rem 0.75rem;
    border-bottom: 1px solid #f3f4f6;
    color: #1f2937;

    &:nth-child(3), &:nth-child(4) {
      font-family: var(--font-mono);
      text-align: right;
    }
  }

  tr.highlighted-row {
    background: #fffbeb;
  }
}

.code-pill {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 700;
  background: #e0e7ff;
  color: #3730a3;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
}

/* ── RIGHT PANE: Copilot Executive Intelligence ─────────────────────────────── */
.intel-nav-strip {
  height: var(--pane-header-height);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  padding: 0 1rem;
  gap: 0.5rem;
  flex-shrink: 0;
}

.intel-nav-tab {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.9rem;
  background: transparent;
  color: var(--ink-secondary);
  border: none;
  border-bottom: 2px solid transparent;
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;

  &:hover {
    color: var(--ink-primary);
  }

  &.active {
    color: var(--blue);
    border-bottom-color: var(--blue);
  }
}

.intel-content-viewport {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
}

.intel-view {
  display: none;

  &.active {
    display: block;
  }
}

/* Audit Score Banner */
.score-banner {
  background: var(--bg-card);
  border: 1px solid var(--border-medium);
  border-radius: 10px;
  padding: 1.15rem 1.25rem;
  margin-bottom: 1.5rem;

  .banner-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;

    .label {
      font-size: 0.72rem;
      color: var(--ink-muted);
      text-transform: uppercase;
      font-weight: 700;
      letter-spacing: 0.05em;
    }

    .score-val {
      font-family: var(--font-mono);
      font-size: 0.85rem;
      font-weight: 800;

      &.warning {
        color: #fbbf24;
      }
    }
  }

  .banner-desc {
    font-size: 0.825rem;
    color: var(--ink-secondary);
    line-height: 1.45;
  }
}

/* Finding Cards */
.finding-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 1.25rem;
  margin-bottom: 1.25rem;
  position: relative;
  transition: all 0.2s ease;

  &:hover {
    border-color: var(--border-medium);
    transform: translateY(-2px);
  }

  &.active-card {
    border-color: var(--amber);
    box-shadow: 0 0 20px rgba(245, 158, 11, 0.15);
  }

  &.resolved {
    opacity: 0.5;
    border-color: rgba(16, 185, 129, 0.3);
  }
}

.card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.card-badge-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.pin-indicator {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 800;
  background: var(--amber);
  color: #000;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
}

.severity-pill {
  font-size: 0.6875rem;
  font-weight: 800;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;

  &.high {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.3);
  }

  &.medium {
    background: var(--amber-bg);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.3);
  }

  &.low {
    background: var(--blue-bg);
    color: #38bdf8;
    border: 1px solid rgba(56, 189, 248, 0.3);
  }
}

.article-cite {
  font-size: 0.72rem;
  color: var(--ink-muted);
}

.financial-impact {
  text-align: right;

  .impact-label {
    font-size: 0.6875rem;
    color: var(--ink-muted);
    margin-right: 4px;
  }

  .impact-val {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    font-weight: 700;
    color: #f87171;
  }
}

.card-title {
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 700;
  color: #fff;
  margin: 0 0 0.5rem;
}

.card-body-text {
  font-size: 0.825rem;
  color: var(--ink-secondary);
  line-height: 1.5;
  margin-bottom: 0.85rem;

  strong {
    color: var(--ink-primary);
  }
}

.card-evidence-snippet {
  background: rgba(0, 0, 0, 0.3);
  border-left: 3px solid var(--blue);
  padding: 0.6rem 0.85rem;
  border-radius: 0 6px 6px 0;
  font-size: 0.775rem;
  color: var(--ink-secondary);
  margin-bottom: 1rem;

  code {
    font-family: var(--font-mono);
    color: #38bdf8;
  }
}

.card-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.action-btn-sm {
  padding: 0.45rem 0.85rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 6px;
  border: 1px solid var(--border-medium);
  background: var(--bg-card-hover);
  color: var(--ink-primary);
  cursor: pointer;
  transition: all 0.15s ease;

  &:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--border-focus);
  }

  &.primary {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
    border-color: rgba(16, 185, 129, 0.35);

    &:hover {
      background: rgba(16, 185, 129, 0.25);
    }
  }

  &.secondary {
    background: rgba(56, 189, 248, 0.15);
    color: #38bdf8;
    border-color: rgba(56, 189, 248, 0.35);
  }
}

/* Advisory Letter Tab */
.letter-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;

  .letter-meta-badge {
    font-size: 0.78rem;
    color: var(--ink-secondary);
  }

  .letter-actions {
    display: flex;
    gap: 0.5rem;
  }
}

.letter-preview {
  background: #ffffff;
  color: #111827;
  padding: 2.25rem;
  border-radius: 8px;
  font-size: 0.85rem;
  line-height: 1.6;
  box-shadow: 0 4px 25px rgba(0, 0, 0, 0.4);

  .letter-header {
    border-bottom: 2px solid #000;
    padding-bottom: 0.75rem;
    margin-bottom: 1.25rem;
    font-size: 0.8rem;
    color: #374151;
  }

  .letter-date {
    text-align: right;
    color: #6b7280;
    margin-bottom: 1.25rem;
    font-size: 0.8rem;
  }

  .letter-recipient {
    margin-bottom: 1.5rem;
    line-height: 1.4;
  }

  .letter-subject {
    font-size: 0.95rem;
    border-bottom: 1px solid #e5e7eb;
    padding-bottom: 0.5rem;
    margin-bottom: 1rem;
    color: #000;
  }

  .letter-body {
    p {
      margin-bottom: 1rem;
    }

    ol {
      padding-left: 1.25rem;
      margin-bottom: 1.25rem;

      li {
        margin-bottom: 0.75rem;
      }
    }
  }

  .letter-signature {
    margin-top: 2rem;
    line-height: 1.4;
  }
}

/* Abacus Matrix Tab */
.matrix-header {
  margin-bottom: 1rem;

  h4 {
    font-family: var(--font-heading);
    font-size: 1rem;
    color: #fff;
    margin-bottom: 4px;
  }

  p {
    font-size: 0.8rem;
    color: var(--ink-secondary);
  }
}

.matrix-table-wrap {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 1.25rem;
}

.matrix-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;

  th {
    background: rgba(0, 0, 0, 0.3);
    padding: 0.65rem 0.85rem;
    text-align: left;
    font-size: 0.72rem;
    color: var(--ink-muted);
    text-transform: uppercase;
    border-bottom: 1px solid var(--border-subtle);
  }

  td {
    padding: 0.7rem 0.85rem;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--ink-primary);

    code {
      font-family: var(--font-mono);
      color: #38bdf8;
    }

    &:nth-child(4) {
      font-family: var(--font-mono);
      font-weight: 700;
      color: #34d399;
    }
  }
}

.status-tag {
  font-size: 0.6875rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;

  &.ready {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
  }

  &.pending {
    background: var(--amber-bg);
    color: #fbbf24;
  }
}

.matrix-actions {
  display: flex;
  gap: 0.75rem;
}

/* Law Cards */
.law-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 1.25rem;
  margin-bottom: 1rem;

  .law-badge {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    font-weight: 700;
    color: #38bdf8;
    background: var(--blue-bg);
    border: 1px solid rgba(56, 189, 248, 0.3);
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    display: inline-block;
    margin-bottom: 0.6rem;
  }

  h5 {
    font-size: 0.9rem;
    color: #fff;
    margin-bottom: 0.5rem;
  }

  p {
    font-size: 0.825rem;
    color: var(--ink-secondary);
    line-height: 1.5;
    margin-bottom: 0.6rem;
    font-style: italic;
  }

  small {
    font-size: 0.72rem;
    color: var(--ink-muted);
  }
}

/* ── Modal Dialog ───────────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;

  &.active {
    display: flex;
  }
}

.modal-box {
  width: 90%;
  max-width: 600px;
  background: var(--bg-surface);
  border: 1px solid var(--border-medium);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8);
  animation: modal-pop 0.2s ease-out;
}

@keyframes modal-pop {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.modal-head {
  padding: 1.25rem 1.5rem;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;

  .modal-title {
    display: flex;
    align-items: center;
    gap: 0.6rem;

    span {
      font-size: 1.25rem;
    }

    h3 {
      font-family: var(--font-heading);
      font-size: 1.05rem;
      color: #fff;
      margin: 0;
    }
  }

  .modal-close {
    background: transparent;
    border: none;
    color: var(--ink-muted);
    font-size: 1.4rem;
    cursor: pointer;

    &:hover {
      color: #fff;
    }
  }
}

.modal-content {
  padding: 1.5rem;

  .modal-lead {
    font-size: 0.85rem;
    color: var(--ink-secondary);
    margin-bottom: 1.25rem;

    strong {
      color: #fff;
    }
  }
}

.software-cards {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.software-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.15rem;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;

  &:hover {
    border-color: var(--border-medium);
  }

  &.active {
    border-color: var(--blue);
    background: rgba(56, 189, 248, 0.08);

    .check-mark {
      color: var(--blue);
    }
  }

  .card-icon {
    font-size: 1.5rem;
  }

  .card-info {
    flex: 1;
    margin: 0 1rem;

    strong {
      display: block;
      font-size: 0.85rem;
      color: #fff;
    }

    small {
      color: var(--ink-muted);
      font-size: 0.72rem;
    }
  }

  .check-mark {
    font-weight: 800;
    color: transparent;
  }
}

.export-preview-box {
  background: #060910;
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 0.85rem 1rem;
  max-height: 120px;
  overflow-y: auto;

  code {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: #38bdf8;
    white-space: pre;
  }
}

.modal-foot {
  padding: 1rem 1.5rem;
  background: var(--bg-card);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;

  button {
    padding: 0.55rem 1.15rem;
    border-radius: 6px;
    font-size: 0.8125rem;
    font-weight: 600;
    cursor: pointer;
  }

  .btn-cancel {
    background: transparent;
    border: 1px solid var(--border-medium);
    color: var(--ink-secondary);

    &:hover {
      color: #fff;
    }
  }

  .btn-confirm {
    background: var(--emerald);
    border: 1px solid var(--emerald);
    color: #fff;

    &:hover {
      background: #059669;
    }
  }
}

/* Toast */
.toast-notification {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--bg-surface);
  border: 1px solid var(--emerald);
  color: #fff;
  padding: 0.75rem 1.25rem;
  border-radius: 8px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.825rem;
  font-weight: 600;
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.3s ease;
  z-index: 200;

  &.show {
    transform: translateY(0);
    opacity: 1;
  }

  .toast-icon {
    color: var(--emerald);
    font-weight: 800;
  }
}

/* Responsive */
@media (max-width: 1024px) {
  .dual-pane-workspace {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr 1fr;
  }

  .header-center-kpi {
    display: none;
  }
}
