:root {
      --bg: #0d1117;
      --surface: #161b22;
      --surface-border: #30363d;
      --surface-hover: #1f242c;
      --text-main: #e6edf3;
      --text-muted: #8b949e;
      --primary: #238636;
      --primary-hover: #2ea043;
      --accent: #58a6ff;
      --accent-hover: #79c0ff;
      --gold: #d29922;
      --danger: #f85149;
      --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
      --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
    }

    * { box-sizing: border-box; margin: 0; padding: 0; }
    body {
      background-color: var(--bg);
      color: var(--text-main);
      font-family: var(--font-sans);
      line-height: 1.5;
      padding: 24px;
    }

    header {
      display: flex;
      flex-wrap: wrap;
      justify-content: space-between;
      align-items: center;
      gap: 16px;
      margin-bottom: 24px;
      padding-bottom: 20px;
      border-bottom: 1px solid var(--surface-border);
    }

    .title-area h1 {
      font-size: 24px;
      font-weight: 700;
      display: flex;
      align-items: center;
      gap: 10px;
    }
    .title-area h1 .brand-home {
      display: inline-flex;
      align-items: center;
      gap: 10px;
      color: inherit;
      text-decoration: none;
    }
    .title-area h1 .brand-home:hover {
      color: var(--accent);
    }
    .title-area h1 .brand-mark {
      width: 40px;
      height: 40px;
      border-radius: 0;
      flex-shrink: 0;
      display: block;
    }
    .title-area p {
      color: var(--text-muted);
      font-size: 14px;
      margin-top: 4px;
    }

    .header-actions {
      display: flex;
      flex-wrap: wrap;
      gap: 8px;
      align-items: center;
    }
    .btn-quiet {
      background: transparent;
      border-color: transparent;
      color: var(--text-muted);
      font-weight: 500;
      padding: 6px 10px;
    }
    .btn-quiet:hover {
      background: var(--surface);
      border-color: var(--surface-border);
      color: var(--text-main);
    }
    .btn.btn-quiet-danger {
      background: rgba(248, 81, 73, 0.12);
      border-color: rgba(248, 81, 73, 0.4);
      color: #ff7b72;
      font-weight: 600;
      padding: 6px 10px;
    }
    .btn.btn-quiet-danger:hover {
      background: rgba(248, 81, 73, 0.22);
      border-color: rgba(248, 81, 73, 0.65);
      color: #ffb1ab;
    }
    .btn-danger {
      background: #da3633;
      border-color: rgba(248, 81, 73, 0.5);
      color: #fff;
    }
    .btn-danger:hover { background: #f85149; }
    .btn-danger:disabled {
      opacity: 0.45;
      cursor: not-allowed;
      background: #6e2b2b;
      border-color: rgba(248, 81, 73, 0.25);
    }
    .danger-modal {
      max-width: 480px;
      border-color: rgba(248, 81, 73, 0.55);
      box-shadow: 0 0 0 1px rgba(248, 81, 73, 0.2), 0 18px 50px rgba(0, 0, 0, 0.55);
    }
    .danger-banner {
      background: rgba(248, 81, 73, 0.12);
      border: 1px solid rgba(248, 81, 73, 0.45);
      border-radius: 8px;
      padding: 12px 14px;
      color: #ffb1ab;
      margin-bottom: 14px;
      font-size: 13px;
      line-height: 1.5;
    }
    .danger-banner strong { color: #ff7b72; }
    th.sortable {
      cursor: pointer;
      user-select: none;
      white-space: nowrap;
    }
    th.sortable:hover { color: var(--accent); }
    th.sortable .sort-ind {
      margin-left: 4px;
      color: var(--text-muted);
      font-size: 10px;
    }
    th.sortable.sorted .sort-ind { color: var(--accent); }

    .linkish {
      background: none;
      border: none;
      padding: 0;
      margin: 0;
      color: var(--accent);
      font: inherit;
      font-size: inherit;
      cursor: pointer;
      text-decoration: underline;
      text-underline-offset: 2px;
    }
    .linkish:hover {
      color: #79b8ff;
    }
    .btn {
      background: var(--surface);
      border: 1px solid var(--surface-border);
      color: var(--text-main);
      padding: 8px 14px;
      border-radius: 6px;
      font-size: 13px;
      font-weight: 600;
      cursor: pointer;
      display: inline-flex;
      align-items: center;
      gap: 6px;
      transition: all 0.15s ease;
      text-decoration: none;
    }
    .btn:hover { background: var(--surface-hover); border-color: #8b949e; }
    .btn-primary { background: var(--primary); border-color: rgba(240, 246, 252, 0.1); color: #fff; }
    .btn-primary:hover { background: var(--primary-hover); }
    .btn-accent { background: #1f6feb; border-color: rgba(240, 246, 252, 0.1); color: #fff; }
    .btn-accent:hover { background: #388bfd; }
    .btn-yahoo { background: rgba(163, 113, 247, 0.15); border: 1px solid rgba(163, 113, 247, 0.4); color: #d2a8ff; }
    .btn-yahoo:hover { background: rgba(163, 113, 247, 0.25); border-color: #d2a8ff; }

    /* Navigation tabs */
    .tabs {
      display: flex;
      flex-wrap: wrap;
      gap: 8px;
      margin-bottom: 20px;
    }
    .tab-btn {
      background: transparent;
      border: none;
      color: var(--text-muted);
      padding: 8px 16px;
      font-size: 14px;
      font-weight: 600;
      cursor: pointer;
      border-radius: 6px;
      transition: all 0.15s ease;
      display: inline-flex;
      align-items: center;
      gap: 8px;
      white-space: nowrap;
    }
    .tab-btn.active {
      color: var(--text-main);
      background: var(--surface);
      border: 1px solid var(--surface-border);
    }
    .tab-label {
      white-space: nowrap;
    }
    .pill-count {
      background: rgba(210, 153, 34, 0.2);
      color: var(--gold);
      border-radius: 10px;
      padding: 1px 7px;
      font-size: 11px;
      font-weight: 700;
      display: inline-block;
      white-space: nowrap;
      vertical-align: middle;
    }
    .ticker-with-meta {
      display: inline-flex;
      align-items: center;
      flex-wrap: nowrap;
      gap: 6px;
      white-space: nowrap;
      max-width: 100%;
    }

    /* Metric summary cards */
    .metrics-grid {
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
      gap: 16px;
      margin-bottom: 24px;
    }
    .metric-card {
      background: var(--surface);
      border: 1px solid var(--surface-border);
      border-radius: 8px;
      padding: 16px;
    }
    button.metric-card {
      display: block;
      width: 100%;
      text-align: left;
      font: inherit;
      color: inherit;
      cursor: default;
    }
    .metric-card-link {
      cursor: pointer;
      transition: border-color 0.15s ease, background 0.15s ease;
    }
    .metric-card-link:hover {
      border-color: var(--accent);
      background: rgba(88, 166, 255, 0.06);
    }
    .metric-card-link:focus-visible {
      outline: 2px solid var(--accent);
      outline-offset: 2px;
    }
    .metric-label {
      font-size: 12px;
      color: var(--text-muted);
      text-transform: uppercase;
      font-weight: 600;
      letter-spacing: 0.5px;
    }
    .metric-value {
      font-size: 24px;
      font-weight: 700;
      margin-top: 4px;
      font-family: var(--font-mono);
    }
    .metric-sub {
      font-size: 12px;
      color: var(--text-muted);
      margin-top: 2px;
    }

    /* Filters Bar */
    .filter-panel {
      background: var(--surface);
      border: 1px solid var(--surface-border);
      border-radius: 8px;
      padding: 16px;
      margin-bottom: 24px;
      display: flex;
      flex-wrap: wrap;
      gap: 12px;
      align-items: center;
    }
    .companies-toolbar {
      justify-content: space-between;
      gap: 12px 16px;
    }
    .companies-toolbar-primary {
      display: flex;
      flex-wrap: wrap;
      gap: 10px;
      align-items: center;
      flex: 1 1 420px;
      min-width: 0;
    }
    .companies-toolbar-primary .search-box {
      flex: 1 1 180px;
      min-width: 140px;
    }
    .companies-toolbar-secondary {
      display: flex;
      flex-wrap: wrap;
      gap: 8px;
      align-items: center;
      justify-content: flex-end;
      margin-left: auto;
    }
    .companies-credits-chip {
      margin: 0;
      white-space: nowrap;
    }
    .companies-menu-root {
      position: relative;
      display: inline-flex;
      align-items: center;
    }
    .companies-menu-popover {
      right: 0;
      left: auto;
      min-width: 280px;
      z-index: 35;
    }
    .companies-menu-popover[hidden] {
      display: none !important;
    }
    .companies-more-popover {
      min-width: 200px;
      padding: 6px;
    }
    .companies-menu-root > .btn {
      position: relative;
    }
    .companies-menu-root > .btn.has-filters {
      border-color: var(--accent);
      color: var(--accent);
    }
    .companies-menu-item {
      display: block;
      width: 100%;
      text-align: left;
      background: none;
      border: none;
      color: var(--text-main);
      font: inherit;
      font-size: 12.5px;
      padding: 8px 10px;
      border-radius: 4px;
      cursor: pointer;
    }
    .companies-menu-item:hover {
      background: rgba(88, 166, 255, 0.12);
      color: var(--accent);
    }
    .companies-menu-item-danger {
      color: var(--danger);
    }
    .companies-menu-item-danger:hover {
      background: rgba(248, 81, 73, 0.12);
      color: var(--danger);
    }
    .companies-settings-block + .companies-settings-block {
      margin-top: 12px;
      padding-top: 10px;
      border-top: 1px solid var(--surface-border);
    }
    .companies-settings-label {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 8px;
      margin-bottom: 6px;
      font-size: 12px;
      color: var(--text-muted);
    }
    .companies-settings-toggles {
      display: flex;
      flex-direction: column;
      gap: 8px;
    }
    .ignore-forms-actions {
      display: flex;
      justify-content: flex-end;
      gap: 8px;
      padding: 8px 0 0;
    }
    .ignore-forms-actions[hidden] {
      display: none !important;
    }
    @media (max-width: 900px) {
      .companies-toolbar {
        max-width: 100%;
      }
      .companies-toolbar-primary {
        flex: 1 1 auto;
        max-width: 100%;
        min-width: 0;
      }
      .companies-toolbar-primary .search-box {
        flex: 1 1 160px;
        min-width: 120px;
        max-width: 220px;
      }
      /* Keep button chrome natural — never stretch to fill the row. */
      .companies-toolbar-primary .btn,
      .companies-toolbar-secondary .btn {
        flex: 0 0 auto;
      }
      .companies-toolbar-secondary {
        margin-left: 0;
      }
    }
    @media (max-width: 640px) {
      body {
        padding: 12px 10px 24px;
      }
      .metrics-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
        margin-bottom: 14px;
      }
      .metric-card {
        padding: 10px 12px;
      }
      .metric-value {
        font-size: 18px;
      }
      .metric-sub {
        display: none;
      }
      .companies-toolbar-primary .search-box {
        flex: 1 1 100%;
        max-width: none;
      }
    }
    .auto-check-opt {
      display: inline-flex;
      align-items: center;
      gap: 6px;
      font-size: 12.5px;
      color: var(--text-muted);
      user-select: none;
      white-space: nowrap;
      cursor: pointer;
    }
    /* Win over .form-group label / input when used inside company modal. */
    .form-group label.auto-check-opt {
      display: inline-flex;
      font-weight: 500;
      margin-bottom: 0;
      width: auto;
    }
    .form-group .auto-check-opt input[type="checkbox"],
    .company-alert-opt input[type="checkbox"] {
      width: auto;
      margin: 0;
      flex: 0 0 auto;
      padding: 0;
      font-family: inherit;
    }
    .company-alert-opt {
      display: inline-flex;
      margin-top: 8px;
      font-weight: 500;
      color: var(--text-main);
    }
    .auto-check-opt input:disabled + span {
      opacity: 0.55;
    }
    .auto-check-opt .hint-inline {
      color: var(--gold);
      font-size: 11px;
    }
    .auto-check-interval {
      display: flex;
      align-items: center;
      gap: 8px;
      margin-top: 8px;
      font-size: 12.5px;
      color: var(--text-muted);
    }
    .auto-check-interval select {
      background: var(--bg);
      border: 1px solid var(--surface-border);
      color: var(--text-main);
      border-radius: 6px;
      padding: 4px 8px;
      font-size: 12px;
    }
    .auto-check-interval select:disabled {
      opacity: 0.55;
    }
    .auto-check-interval select option:disabled {
      color: var(--text-muted);
      opacity: 0.65;
    }
    .auto-check-interval .hint-inline {
      color: var(--gold);
      font-size: 11px;
    }
    .search-box {
      flex: 1 1 240px;
      background: var(--bg);
      border: 1px solid var(--surface-border);
      color: var(--text-main);
      padding: 8px 12px;
      border-radius: 6px;
      font-size: 13px;
    }
    .select-filter {
      background: var(--bg);
      border: 1px solid var(--surface-border);
      color: var(--text-main);
      padding: 8px 12px;
      border-radius: 6px;
      font-size: 13px;
      min-width: 140px;
    }
    .queue-toolbar {
      display: flex;
      justify-content: space-between;
      align-items: flex-start;
      gap: 16px;
      margin-bottom: 16px;
    }
    .queue-toolbar-actions {
      display: flex;
      align-items: center;
      gap: 8px;
      flex-shrink: 0;
      position: relative;
      flex-wrap: wrap;
      justify-content: flex-end;
    }
    .queue-ack-mode {
      display: inline-flex;
      border: 1px solid var(--surface-border);
      border-radius: 6px;
      overflow: hidden;
    }
    .queue-ack-mode-btn {
      border: none;
      border-radius: 0;
      margin: 0;
      background: transparent;
      box-shadow: none;
    }
    .queue-ack-mode-btn + .queue-ack-mode-btn {
      border-left: 1px solid var(--surface-border);
    }
    .queue-ack-mode-btn.active {
      background: var(--accent);
      color: #fff;
      border-color: var(--accent);
    }
    .queue-filter-btn {
      position: relative;
      min-width: 40px;
      padding: 8px 10px;
      line-height: 1;
    }
    .queue-filter-btn svg {
      display: block;
      width: 16px;
      height: 16px;
    }
    .queue-filter-btn.has-filters {
      border-color: var(--accent);
      color: var(--accent);
    }
    .queue-filter-badge {
      position: absolute;
      top: -5px;
      right: -5px;
      min-width: 16px;
      height: 16px;
      padding: 0 4px;
      border-radius: 999px;
      background: var(--accent);
      color: #fff;
      font-size: 10px;
      font-weight: 700;
      line-height: 16px;
      text-align: center;
    }
    .queue-filter-popover {
      display: none;
      position: absolute;
      z-index: 40;
      top: calc(100% + 6px);
      right: 0;
      width: min(320px, calc(100vw - 32px));
      background: var(--surface);
      border: 1px solid var(--surface-border);
      border-radius: 8px;
      box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
      padding: 12px;
    }
    .queue-filter-popover.open { display: block; }
    .queue-filter-popover-head {
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-bottom: 10px;
    }
    .queue-filter-popover-head strong {
      font-size: 13px;
    }
    .queue-filter-section + .queue-filter-section {
      margin-top: 8px;
    }
    .queue-filter-section-toggle {
      width: 100%;
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 8px;
      background: transparent;
      border: 1px solid var(--surface-border);
      border-radius: 6px;
      color: var(--text-main);
      padding: 8px 10px;
      cursor: pointer;
      font-size: 12px;
      font-weight: 600;
      text-align: left;
    }
    .queue-filter-section-toggle:hover {
      border-color: var(--accent);
      color: var(--accent);
    }
    .queue-filter-section-toggle .chevron {
      width: 12px;
      height: 12px;
      flex-shrink: 0;
      transition: transform 0.15s ease;
      opacity: 0.75;
    }
    .queue-filter-section.open .queue-filter-section-toggle .chevron {
      transform: rotate(90deg);
    }
    .queue-filter-section-meta {
      color: var(--text-muted);
      font-weight: 500;
      font-size: 11px;
      margin-left: auto;
      margin-right: 4px;
    }
    .queue-filter-section-toggle:hover .queue-filter-section-meta {
      color: inherit;
    }
    .queue-filter-list {
      display: none;
      max-height: 180px;
      overflow-y: auto;
      border: 1px solid var(--surface-border);
      border-top: none;
      border-radius: 0 0 6px 6px;
      background: var(--bg);
      padding: 4px;
      margin-top: -1px;
    }
    .queue-filter-section.open .queue-filter-section-toggle {
      border-radius: 6px 6px 0 0;
    }
    .queue-filter-section.open .queue-filter-list {
      display: block;
    }
    .queue-filter-list.visible {
      display: block;
      border-radius: 6px;
      margin-top: 0;
    }
    .filings-header-actions {
      display: flex;
      gap: 8px;
      flex-wrap: wrap;
      justify-content: flex-end;
      align-items: center;
      position: relative;
    }
    .multi-select-option {
      display: flex;
      align-items: center;
      gap: 8px;
      padding: 6px 8px;
      border-radius: 4px;
      cursor: pointer;
      font-size: 12px;
      color: var(--text-main);
      user-select: none;
    }
    .multi-select-option:hover { background: rgba(255, 255, 255, 0.04); }
    .multi-select-option input {
      margin: 0;
      accent-color: var(--accent);
    }
    .multi-select-option .mono {
      font-family: var(--font-mono);
      color: var(--accent);
    }
    .multi-select-empty {
      padding: 10px 8px;
      font-size: 12px;
      color: var(--text-muted);
    }
    .queue-filter-status {
      margin: -4px 0 16px;
      min-height: 1.2em;
    }
    .queue-deals-filter {
      margin: 0 0 8px;
      border: 1px solid var(--surface-border);
      border-radius: 6px;
      align-items: flex-start;
    }
    .queue-deals-filter .queue-filter-section-meta {
      display: block;
      margin-top: 2px;
      font-weight: 400;
    }

    /* Table view */
    .table-container {
      background: var(--surface);
      border: 1px solid var(--surface-border);
      border-radius: 8px;
      overflow-x: auto;
      -webkit-overflow-scrolling: touch;
    }
    table {
      width: 100%;
      border-collapse: collapse;
      text-align: left;
      font-size: 13px;
    }
    /* Prefer horizontal scroll over crushing columns; Actions stay pinned. */
    .companies-table {
      min-width: 760px;
    }
    .companies-table thead th:last-child,
    .companies-table td.companies-cell-actions {
      position: sticky;
      right: 0;
      z-index: 2;
      background: #1c2128;
      box-shadow: -8px 0 10px -8px rgba(0, 0, 0, 0.55);
    }
    .companies-table td.companies-cell-actions {
      background: var(--surface);
      white-space: nowrap;
    }
    .companies-table tbody tr:hover td.companies-cell-actions {
      background: var(--surface-hover);
    }
    /* Mid widths: denser cells, still a real table (scroll + sticky Actions). */
    @media (max-width: 1100px) {
      .companies-table th,
      .companies-table td {
        padding: 10px 10px;
      }
      .companies-table .position-input {
        width: 84px;
      }
    }
    /* Phones only: compact card rows (not stretched full-bleed buttons). */
    @media (max-width: 640px) {
      .companies-table-wrap {
        overflow: hidden;
      }
      .companies-table {
        min-width: 0;
        width: 100%;
      }
      .companies-table thead {
        display: none;
      }
      .companies-table,
      .companies-table tbody {
        display: block;
        width: 100%;
      }
      .companies-table tbody tr {
        display: grid;
        grid-template-columns: 1fr 1fr;
        column-gap: 10px;
        row-gap: 2px;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
        padding: 10px 12px;
        border-bottom: 1px solid var(--surface-border);
      }
      .companies-table tbody tr:last-child {
        border-bottom: none;
      }
      .companies-table td {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        gap: 2px;
        width: auto;
        max-width: none;
        box-sizing: border-box;
        padding: 4px 0;
        border-bottom: none;
        text-align: left;
        min-width: 0;
      }
      .companies-table td::before {
        content: attr(data-label);
        color: var(--text-muted);
        font-size: 10px;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.04em;
      }
      .companies-table td.companies-cell-lead {
        grid-column: 1 / -1;
        flex-direction: row;
        align-items: center;
        gap: 8px;
        padding: 0 0 6px;
        border-bottom: 1px solid var(--surface-border);
        margin-bottom: 2px;
      }
      .companies-table td.companies-cell-lead::before {
        display: none;
      }
      .companies-table td.companies-cell-lead .ticker-cell {
        font-size: 15px;
      }
      /* Company name sits under ticker across full width. */
      .companies-table td[data-label="Company"] {
        grid-column: 1 / -1;
        flex-direction: row;
        align-items: baseline;
        gap: 8px;
        padding-top: 0;
      }
      .companies-table td[data-label="Company"]::before {
        display: none;
      }
      .companies-table td[data-label="Company"] strong {
        font-size: 12px;
        font-weight: 500;
        color: var(--text-muted);
      }
      .companies-table thead th:last-child,
      .companies-table td.companies-cell-actions {
        grid-column: 1 / -1;
        position: static;
        flex-direction: row;
        align-items: center;
        justify-content: flex-start;
        gap: 8px;
        box-shadow: none;
        background: transparent;
        padding-top: 8px;
        margin-top: 2px;
        border-top: 1px solid var(--surface-border);
        z-index: auto;
      }
      .companies-table tbody tr:hover td.companies-cell-actions {
        background: transparent;
      }
      .companies-table td.companies-cell-actions::before {
        display: none;
      }
      .companies-table .position-input {
        width: 100%;
        max-width: 140px;
      }
      .companies-table tbody tr:has(td[colspan]) {
        display: block;
      }
      .companies-table tbody tr:has(td[colspan]) td {
        display: block;
        text-align: center;
      }
      .companies-table tbody tr:has(td[colspan]) td::before {
        display: none;
      }
    }
    th {
      background: #1c2128;
      color: var(--text-muted);
      font-weight: 600;
      padding: 12px 14px;
      border-bottom: 1px solid var(--surface-border);
      white-space: nowrap;
    }
    td {
      padding: 14px;
      border-bottom: 1px solid var(--surface-border);
      vertical-align: middle;
    }
    tbody tr {
      cursor: pointer;
      transition: background 0.12s ease;
    }
    tbody tr:hover td {
      background: var(--surface-hover);
    }

    .ticker-cell {
      font-family: var(--font-mono);
      font-weight: 700;
      color: var(--accent);
      font-size: 14px;
    }
    .badge {
      display: inline-block;
      padding: 2px 8px;
      border-radius: 12px;
      font-size: 11px;
      font-weight: 600;
      text-transform: uppercase;
      letter-spacing: 0.3px;
    }
    .badge-yes { background: rgba(35, 134, 54, 0.2); color: #3fb950; border: 1px solid rgba(35, 134, 54, 0.4); }
    .badge-no { background: rgba(248, 81, 73, 0.2); color: #ff7b72; border: 1px solid rgba(248, 81, 73, 0.4); }
    .badge-allcash { background: rgba(88, 166, 255, 0.2); color: #79c0ff; border: 1px solid rgba(88, 166, 255, 0.4); }
    .badge-imported { background: rgba(139, 148, 158, 0.2); color: var(--text-muted); border: 1px solid var(--surface-border); }
    .badge-updated { background: rgba(210, 153, 34, 0.2); color: var(--gold); border: 1px solid rgba(210, 153, 34, 0.4); }
    .badge-sec { background: rgba(31, 111, 235, 0.18); color: #58a6ff; border: 1px solid rgba(56, 139, 253, 0.4); font-size: 10px; }
    .badge-high { background: rgba(35, 134, 54, 0.2); color: #3fb950; border: 1px solid rgba(35, 134, 54, 0.45); }
    .badge-mid { background: rgba(210, 153, 34, 0.18); color: var(--gold); border: 1px solid rgba(210, 153, 34, 0.45); }
    .badge-low { background: rgba(139, 148, 158, 0.16); color: var(--text-muted); border: 1px solid var(--surface-border); }
    .badge-pr { background: rgba(163, 113, 247, 0.18); color: #d2a8ff; border: 1px solid rgba(163, 113, 247, 0.4); font-size: 10px; }
    .badge-tender { background: rgba(210, 153, 34, 0.18); color: var(--gold); border: 1px solid rgba(210, 153, 34, 0.45); }
    .badge-item {
      background: rgba(88, 166, 255, 0.14);
      color: #79c0ff;
      border: 1px solid rgba(88, 166, 255, 0.35);
      font-size: 10px;
      font-family: var(--font-mono);
      font-weight: 600;
    }
    .badge-item.hot {
      background: rgba(210, 153, 34, 0.16);
      color: var(--gold);
      border-color: rgba(210, 153, 34, 0.45);
    }
    .filing-insight-row {
      display: flex;
      flex-wrap: wrap;
      gap: 4px;
      margin-top: 4px;
    }
    .reader-highlights {
      background: var(--bg);
      border: 1px solid var(--surface-border);
      border-radius: 8px;
      padding: 12px 14px;
      margin-bottom: 12px;
    }
    .reader-highlights-details > summary {
      cursor: pointer;
      font-size: 13px;
      font-weight: 700;
      color: var(--text-main);
      list-style: none;
    }
    .reader-highlights-details > summary::-webkit-details-marker {
      display: none;
    }
    .reader-highlights-details > summary::before {
      content: "▾ ";
      color: var(--accent);
    }
    .reader-highlights-details:not([open]) > summary::before {
      content: "▸ ";
    }
    .reader-highlights-details[open] > summary {
      margin-bottom: 8px;
    }
    .reader-highlights h3 {
      margin: 0 0 8px;
      font-size: 13px;
      font-weight: 700;
    }
    .reader-highlights dl {
      margin: 0;
      display: grid;
      grid-template-columns: 120px 1fr;
      gap: 4px 10px;
      font-size: 12px;
    }
    .reader-highlights dt {
      color: var(--text-muted);
      font-weight: 600;
    }
    .reader-highlights dd {
      margin: 0;
      color: var(--text-main);
    }
    .section-pills .btn.active {
      border-color: var(--accent);
      color: var(--accent);
    }
    .quote-stack { font-family: var(--font-mono); font-size: 12px; line-height: 1.45; }
    .quote-stack .hint { font-family: var(--font-sans); }
    .tender-link-card {
      background: rgba(210, 153, 34, 0.08);
      border: 1px solid rgba(210, 153, 34, 0.35);
      border-radius: 8px;
      padding: 12px 14px;
      margin-bottom: 16px;
    }
    .research-panel {
      background: var(--surface);
      border: 1px solid var(--surface-border);
      border-radius: 8px;
      padding: 14px 16px;
      margin-bottom: 16px;
    }
    .research-panel h3 {
      font-size: 14px;
      font-weight: 700;
      margin: 0 0 4px;
    }
    .research-list {
      display: flex;
      flex-direction: column;
      gap: 8px;
      margin-top: 10px;
    }
    .research-row {
      display: flex;
      justify-content: space-between;
      gap: 12px;
      align-items: flex-start;
      flex-wrap: wrap;
      padding: 10px 12px;
      border: 1px solid var(--surface-border);
      border-radius: 6px;
      background: var(--bg);
    }
    .research-row strong {
      font-size: 13px;
    }
    .badge-research {
      background: rgba(63, 185, 80, 0.14);
      color: #3fb950;
      border: 1px solid rgba(63, 185, 80, 0.4);
      font-size: 10px;
    }

    /* Calculator Tab */
    .calc-container {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 24px;
    }
    @media (max-width: 860px) {
      .calc-container { grid-template-columns: 1fr; }
    }
    .calc-box {
      background: var(--surface);
      border: 1px solid var(--surface-border);
      border-radius: 8px;
      padding: 24px;
    }
    .calc-box h2 {
      font-size: 18px;
      font-weight: 700;
      margin-bottom: 16px;
      padding-bottom: 10px;
      border-bottom: 1px solid var(--surface-border);
    }
    .form-group {
      margin-bottom: 14px;
    }
    .form-group label {
      display: block;
      font-size: 12px;
      color: var(--text-muted);
      font-weight: 600;
      margin-bottom: 6px;
    }
    .form-group input, .form-group textarea {
      width: 100%;
      background: var(--bg);
      border: 1px solid var(--surface-border);
      color: var(--text-main);
      padding: 8px 12px;
      border-radius: 6px;
      font-size: 14px;
      font-family: var(--font-mono);
    }
    .note-list-actions {
      display: inline-flex;
      gap: 6px;
      align-items: center;
    }
    .note-textarea {
      font-family: var(--font-sans, inherit) !important;
      line-height: 1.45;
      resize: vertical;
      min-height: 4.5em;
    }
    .note-block label {
      display: block;
    }
    .reader-footer-left {
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      gap: 8px;
      margin-right: auto;
    }
    .reader-note-wrap {
      position: relative;
    }
    .reader-note-wrap[hidden] { display: none !important; }
    .reader-note-btn {
      position: relative;
      padding: 6px 8px;
      min-width: 34px;
      display: inline-flex;
      align-items: center;
      justify-content: center;
    }
    .reader-note-btn.has-note {
      color: var(--accent);
      border-color: rgba(88, 166, 255, 0.45);
    }
    .reader-note-dot {
      position: absolute;
      top: 2px;
      right: 2px;
      min-width: 14px;
      height: 14px;
      padding: 0 3px;
      border-radius: 999px;
      background: var(--accent);
      color: #0d1117;
      font-size: 9px;
      font-weight: 700;
      line-height: 14px;
      text-align: center;
    }
    .reader-note-dot:not(.reader-note-count) {
      min-width: 7px;
      width: 7px;
      height: 7px;
      padding: 0;
      top: 4px;
      right: 4px;
    }
    .reader-note-dot[hidden] { display: none !important; }
    .reader-note-popover {
      position: absolute;
      bottom: calc(100% + 8px);
      left: 0;
      width: min(320px, 78vw);
      padding: 10px;
      border: 1px solid var(--surface-border);
      border-radius: 8px;
      background: var(--surface);
      box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
      z-index: 5;
    }
    .reader-note-popover[hidden] { display: none !important; }
    .reader-note-popover .note-textarea {
      min-height: 5.5em;
      font-size: 13px;
    }
    .reader-note-popover-actions {
      display: flex;
      justify-content: flex-end;
      margin-top: 8px;
    }
    .filing-note-preview {
      margin-top: 4px;
      font-size: 12px;
      color: var(--text-muted);
      line-height: 1.4;
      white-space: pre-wrap;
    }
    .badge-note {
      background: rgba(88, 166, 255, 0.12);
      color: var(--accent);
      border: 1px solid rgba(88, 166, 255, 0.35);
      font-size: 10px;
      padding: 1px 6px;
      border-radius: 999px;
      margin-left: 6px;
      vertical-align: middle;
    }
    .note-bubble {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      min-width: 18px;
      height: 18px;
      padding: 0 5px;
      margin-left: 6px;
      border-radius: 999px;
      background: var(--accent);
      color: #0d1117;
      font-size: 10px;
      font-weight: 700;
      font-family: var(--font-mono);
      line-height: 1;
      vertical-align: middle;
    }
    .note-list {
      display: flex;
      flex-direction: column;
      gap: 8px;
      max-height: 280px;
      overflow: auto;
    }
    .note-list-compact {
      max-height: 140px;
      margin-bottom: 8px;
    }
    .note-list:empty::before {
      content: "No notes yet.";
      color: var(--text-muted);
      font-size: 13px;
    }
    .note-list-item {
      border: 1px solid var(--surface-border);
      border-radius: 8px;
      padding: 8px 10px;
      background: var(--bg);
    }
    .note-list-item-head {
      display: flex;
      justify-content: space-between;
      gap: 8px;
      align-items: center;
      margin-bottom: 4px;
    }
    .note-list-meta {
      font-size: 11px;
      color: var(--text-muted);
    }
    .note-list-body {
      font-size: 13px;
      line-height: 1.4;
      color: var(--text-main);
    }
    .note-list-edit {
      margin-top: 8px;
    }
    .note-list-edit-area {
      width: 100%;
      min-height: 180px;
      font-size: 13px;
      line-height: 1.45;
      resize: vertical;
    }
    .note-list-edit-actions {
      display: flex;
      flex-wrap: wrap;
      gap: 8px;
      margin-top: 8px;
    }
    .note-list-body.note-md p {
      margin: 0.4em 0;
    }
    .note-list-body.note-md ul {
      margin: 0.35em 0 0.35em 1.15em;
      padding-left: 1em;
    }
    .note-list-body.note-md li {
      margin: 0.15em 0;
    }
    .note-list-body.note-md h2,
    .note-list-body.note-md h3,
    .note-list-body.note-md h4,
    .note-list-body.note-md h5 {
      margin: 0.7em 0 0.3em;
      font-weight: 650;
      line-height: 1.3;
      font-size: 1em;
    }
    .note-md a {
      color: var(--accent, #2563eb);
      text-decoration: underline;
      text-underline-offset: 2px;
      word-break: break-word;
    }
    .note-md a:hover {
      opacity: 0.9;
    }
    .note-list-body.note-md strong {
      font-weight: 650;
    }
    .note-list-item .btn {
      padding: 2px 6px;
      font-size: 11px;
    }
    .calc-result-row {
      display: flex;
      justify-content: space-between;
      padding: 10px 0;
      border-bottom: 1px solid rgba(48, 54, 61, 0.5);
      font-size: 14px;
    }
    .calc-result-row.total {
      font-size: 18px;
      font-weight: 700;
      color: #3fb950;
      border-top: 1px solid var(--surface-border);
      border-bottom: none;
      padding-top: 16px;
      margin-top: 8px;
    }

    /* Modals & Drawers */
    .modal-overlay {
      position: fixed;
      inset: 0;
      background: rgba(0, 0, 0, 0.75);
      display: none;
      justify-content: center;
      align-items: center;
      z-index: 1000;
    }
    .modal-overlay.stack-front {
      z-index: 1100;
    }
    #readerModal.modal-overlay {
      z-index: 1200;
    }
    /* Above the filing reader so Share from Notes is visible. */
    #shareLinkModal.modal-overlay {
      z-index: 1350;
    }
    /* Above the filing reader so As-of from a filing is visible. */
    #asofArticleModal.modal-overlay {
      z-index: 1350;
    }
    /* Pricing must sit above Fidelity import / other modals */
    #plansModal.modal-overlay {
      z-index: 1300;
    }
    .modal {
      background: var(--surface);
      border: 1px solid var(--surface-border);
      border-radius: 8px;
      width: 90%;
      max-width: 860px;
      max-height: 90vh;
      overflow-y: auto;
      padding: 24px;
    }
    .modal-header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-bottom: 16px;
      padding-bottom: 12px;
      border-bottom: 1px solid var(--surface-border);
    }
    .modal-footer {
      display: flex;
      justify-content: space-between;
      align-items: center;
      gap: 10px;
      margin-top: 20px;
      padding-top: 16px;
      border-top: 1px solid var(--surface-border);
    }

    /* Detail View Specifics */
    .detail-grid {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 16px;
      margin-bottom: 20px;
    }
    @media (max-width: 640px) {
      .detail-grid { grid-template-columns: 1fr; }
    }
    .detail-card {
      background: rgba(22, 27, 34, 0.7);
      border: 1px solid var(--surface-border);
      border-radius: 6px;
      padding: 14px;
    }
    .detail-item {
      margin-bottom: 10px;
    }
    .detail-item:last-child { margin-bottom: 0; }
    .detail-label {
      font-size: 11px;
      text-transform: uppercase;
      color: var(--text-muted);
      font-weight: 600;
    }
    .detail-val {
      font-size: 14px;
      color: var(--text-main);
      margin-top: 2px;
    }

    /* Filings Timeline / Table */
    .filings-section {
      margin-top: 20px;
      border-top: 1px solid var(--surface-border);
      padding-top: 18px;
    }
    .filings-header {
      display: flex;
      justify-content: space-between;
      align-items: flex-start;
      gap: 12px;
      flex-wrap: wrap;
      margin-bottom: 12px;
    }
    .filings-table-wrap {
      overflow-x: auto;
      -webkit-overflow-scrolling: touch;
      border: 1px solid var(--surface-border);
      border-radius: 6px;
      background: var(--bg);
    }
    .filings-table {
      width: 100%;
      border: none;
      border-radius: 0;
      background: transparent;
      font-size: 12.5px;
    }
    .filings-table th {
      padding: 8px 12px;
      background: #1c2128;
    }
    .filings-table td {
      padding: 10px 12px;
    }
    .company-filings-table {
      min-width: 580px;
    }
    .filing-actions-row {
      display: inline-flex;
      flex-wrap: wrap;
      gap: 6px;
      align-items: center;
      justify-content: flex-end;
    }
    .company-filings-table thead th:last-child,
    .company-filings-table td.filing-cell-actions {
      position: sticky;
      right: 0;
      z-index: 2;
      background: #1c2128;
      box-shadow: -8px 0 10px -8px rgba(0, 0, 0, 0.55);
      text-align: right;
      white-space: normal;
    }
    .company-filings-table td.filing-cell-actions {
      background: var(--bg);
    }
    .company-filings-table tbody tr:hover td.filing-cell-actions {
      background: var(--surface-hover);
    }
    @media (max-width: 900px) {
      #companyModal .modal {
        width: calc(100% - 16px);
        max-width: none;
        max-height: calc(100vh - 16px);
        padding: 16px;
        margin: 8px;
      }
      #companyModal .filings-header-actions {
        justify-content: flex-start;
      }
      #companyModal .filings-header-actions .btn {
        flex: 0 0 auto;
      }
      .company-filings-table th,
      .company-filings-table td {
        padding: 8px 10px;
      }
    }
    /* Phone: compact filing cards — natural button sizes, no wide empty rows. */
    @media (max-width: 640px) {
      #companyModal .modal {
        width: 100%;
        max-height: 100vh;
        border-radius: 0;
        margin: 0;
        padding: 12px 12px 16px;
      }
      #companyModal .modal-footer {
        flex-wrap: wrap;
        gap: 8px;
      }
      .company-filings-wrap {
        overflow: hidden;
        border: none;
        background: transparent;
      }
      .company-filings-table {
        min-width: 0;
        width: 100%;
      }
      .company-filings-table thead {
        display: none;
      }
      .company-filings-table,
      .company-filings-table tbody {
        display: block;
        width: 100%;
      }
      .company-filings-table tbody tr {
        display: grid;
        grid-template-columns: 1fr auto;
        column-gap: 10px;
        row-gap: 4px;
        padding: 10px 12px;
        margin-bottom: 8px;
        border: 1px solid var(--surface-border);
        border-radius: 8px;
        background: var(--bg);
      }
      .company-filings-table td {
        padding: 0;
        border-bottom: none;
        min-width: 0;
      }
      .company-filings-table td.filing-cell-date {
        font-size: 11px;
        color: var(--text-muted);
      }
      .company-filings-table td.filing-cell-form {
        text-align: right;
      }
      .company-filings-table td.filing-cell-desc {
        grid-column: 1 / -1;
        font-size: 12px;
        line-height: 1.4;
        color: var(--text-main);
      }
      .company-filings-table td.filing-cell-desc .filing-note-preview {
        margin-top: 4px;
        max-height: 3.6em;
        overflow: hidden;
      }
      .company-filings-table thead th:last-child,
      .company-filings-table td.filing-cell-actions {
        grid-column: 1 / -1;
        position: static;
        box-shadow: none;
        background: transparent;
        text-align: left;
        padding-top: 4px;
      }
      .company-filings-table .filing-actions-row {
        justify-content: flex-start;
      }
      .company-filings-table tbody tr:hover td.filing-cell-actions {
        background: transparent;
      }
      /* Empty / filter-empty rows. */
      .company-filings-table tbody tr:has(td[colspan]) {
        display: block;
        text-align: center;
      }
    }

    /* Work Queue Container */
    .work-queue-card {
      background: var(--surface);
      border: 1px solid var(--surface-border);
      border-radius: 8px;
      padding: 18px;
      margin-bottom: 16px;
      display: flex;
      flex-wrap: wrap;
      justify-content: space-between;
      align-items: center;
      gap: 12px;
    }
    .work-queue-left {
      flex: 1 1 300px;
    }
    .work-queue-title {
      font-weight: 700;
      font-size: 15px;
      display: flex;
      align-items: center;
      gap: 8px;
    }
    .work-queue-desc {
      font-size: 13px;
      color: var(--text-muted);
      margin-top: 4px;
    }

    /* Import Dropzone & Feed List */
    .dropzone {
      border: 2px dashed var(--surface-border);
      border-radius: 8px;
      padding: 24px;
      text-align: center;
      background: rgba(22, 27, 34, 0.5);
      cursor: pointer;
      margin-bottom: 16px;
      transition: all 0.15s ease;
    }
    .dropzone:hover {
      border-color: var(--accent);
      background: rgba(31, 111, 235, 0.05);
    }
    .import-feed-list {
      max-height: 380px;
      overflow-y: auto;
      border: 1px solid var(--surface-border);
      border-radius: 6px;
      background: var(--bg);
      margin-top: 14px;
    }
    .import-item {
      display: flex;
      align-items: flex-start;
      gap: 12px;
      padding: 14px;
      border-bottom: 1px solid var(--surface-border);
      transition: background 0.1s ease;
    }
    .import-item:last-child { border-bottom: none; }
    .import-item:hover { background: rgba(255, 255, 255, 0.02); }
    .import-checkbox {
      margin-top: 4px;
      width: 16px;
      height: 16px;
      accent-color: var(--primary);
      cursor: pointer;
    }
    .import-info {
      flex: 1;
    }
    .import-topline {
      display: flex;
      justify-content: space-between;
      align-items: center;
      gap: 8px;
    }
    .import-desc {
      font-size: 12px;
      color: var(--text-muted);
      margin-top: 4px;
    }
    .import-controls-bar {
      display: flex;
      flex-wrap: wrap;
      gap: 14px;
      margin-bottom: 14px;
      align-items: center;
      background: rgba(22, 27, 34, 0.6);
      padding: 10px 14px;
      border-radius: 6px;
      border: 1px solid var(--surface-border);
    }
    .checkbox-label {
      font-size: 12px;
      color: var(--text-main);
      display: inline-flex;
      align-items: center;
      gap: 6px;
      cursor: pointer;
      user-select: none;
    }

    /* Diff box showing what changed */
    .diff-box {
      margin-top: 8px;
      background: rgba(210, 153, 34, 0.08);
      border-left: 3px solid var(--gold);
      border-radius: 4px;
      padding: 8px 12px;
      font-size: 12px;
    }
    .diff-header {
      font-weight: 700;
      color: var(--gold);
      margin-bottom: 4px;
      display: flex;
      align-items: center;
      gap: 6px;
    }
    .diff-row {
      display: flex;
      flex-wrap: wrap;
      gap: 6px;
      margin-top: 3px;
      font-family: var(--font-mono);
      font-size: 11.5px;
    }
    .diff-label {
      color: var(--text-muted);
      font-family: var(--font-sans);
      font-weight: 600;
      min-width: 90px;
    }
    .diff-old {
      color: #ff7b72;
      text-decoration: line-through;
      background: rgba(248, 81, 73, 0.1);
      padding: 0 4px;
      border-radius: 3px;
    }
    .diff-new {
      color: #3fb950;
      font-weight: 600;
      background: rgba(56, 139, 253, 0.1);
      padding: 0 4px;
      border-radius: 3px;
    }

    .hint { font-size: 12px; color: var(--text-muted); }
    .status-banner {
      border: 1px solid var(--surface-border);
      background: var(--surface);
      border-radius: 8px;
      padding: 10px 14px;
      margin-bottom: 16px;
      font-size: 13px;
    }
    .status-banner.warn { border-color: rgba(210, 153, 34, 0.6); color: var(--gold); }
    .cusip-line { font-size: 11px; color: var(--text-muted); font-weight: 600; margin-top: 2px; }
    .identity-line { font-size: 12px; color: var(--text-muted); margin-top: 6px; }
    .identity-line a { color: var(--accent); }
    .reader-modal {
      max-width: 1080px;
      width: 90%;
      max-height: 90vh;
      display: flex;
      flex-direction: column;
      overflow: hidden; /* keep footer pinned; content scrolls inside */
      transition: max-width 0.15s ease, width 0.15s ease;
    }
    .reader-modal.wide {
      max-width: min(1680px, 98vw);
      width: 98vw;
    }
    .reader-modal.has-deal-rail {
      max-width: min(1480px, 96vw);
      width: 96vw;
    }
    .reader-modal.has-deal-rail.wide {
      max-width: min(1680px, 98vw);
      width: 98vw;
    }
    .reader-modal .modal-header {
      flex-shrink: 0;
    }
    .reader-modal #readerBody {
      flex: 1 1 auto;
      min-height: 0;
      display: flex;
      flex-direction: column;
      overflow: hidden;
    }
    .reader-modal #readerBody > #readerChrome {
      flex-shrink: 0;
    }
    .reader-workspace {
      flex: 1 1 auto;
      min-height: 0;
      display: grid;
      grid-template-columns: minmax(0, 1fr);
      overflow: hidden;
    }
    .reader-modal.has-deal-rail .reader-workspace {
      grid-template-columns: minmax(0, 1fr) min(340px, 36%);
    }
    .reader-modal.has-deal-rail.deal-rail-collapsed .reader-workspace {
      grid-template-columns: minmax(0, 1fr) 36px;
    }
    .reader-main {
      min-width: 0;
      min-height: 0;
      display: flex;
      flex-direction: column;
      overflow: hidden;
    }
    .reader-modal #readerMain > .reader-highlights,
    .reader-modal #readerBody > .reader-highlights {
      flex: 0 0 auto;
      max-height: min(28vh, 12rem);
      overflow: auto;
    }
    .reader-deal-rail {
      min-width: 0;
      min-height: 0;
      overflow: auto;
      border-left: 1px solid var(--surface-border);
      background: var(--surface);
      padding: 12px 14px 16px;
      display: flex;
      flex-direction: column;
    }
    .reader-deal-rail-head {
      display: flex;
      align-items: center;
      gap: 6px;
      margin: 0 0 8px;
      flex-shrink: 0;
    }
    .reader-deal-rail-head h3,
    .reader-deal-rail h3 {
      margin: 0;
      font-size: 13px;
      font-weight: 700;
    }
    .reader-deal-rail-toggle {
      flex: 0 0 auto;
      width: 28px;
      height: 28px;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      background: transparent;
      border: 1px solid var(--surface-border);
      border-radius: 6px;
      color: var(--text-muted);
      cursor: pointer;
      padding: 0;
    }
    .reader-deal-rail-toggle:hover {
      color: var(--text-main);
      border-color: var(--accent);
    }
    .reader-deal-rail-chevron {
      display: block;
      width: 7px;
      height: 7px;
      border-right: 2px solid currentColor;
      border-bottom: 2px solid currentColor;
      transform: rotate(-45deg);
    }
    .reader-modal.deal-rail-collapsed .reader-deal-rail-chevron {
      transform: rotate(135deg);
    }
    .reader-deal-rail-body {
      min-height: 0;
      flex: 1 1 auto;
      overflow: auto;
    }
    .reader-modal.deal-rail-collapsed .reader-deal-rail {
      padding: 6px 2px;
      overflow: hidden;
      cursor: pointer;
    }
    .reader-modal.deal-rail-collapsed .reader-deal-rail-body {
      display: none;
    }
    .reader-modal.deal-rail-collapsed .reader-deal-rail-head {
      flex-direction: column;
      align-items: center;
      margin: 0;
      height: 100%;
    }
    .reader-modal.deal-rail-collapsed .reader-deal-rail-toggle {
      width: 28px;
      height: 36px;
      border-color: transparent;
    }
    .reader-modal.deal-rail-collapsed .reader-deal-rail-head h3 {
      writing-mode: vertical-rl;
      transform: rotate(180deg);
      font-size: 11px;
      font-weight: 650;
      letter-spacing: 0.04em;
      color: var(--text-muted);
      margin-top: 8px;
    }
    .reader-deal-rail .form-group {
      margin-bottom: 8px;
    }
    .reader-deal-rail label {
      font-size: 11px;
      color: var(--text-muted);
    }
    .reader-deal-rail input,
    .reader-deal-rail select,
    .reader-deal-rail textarea {
      width: 100%;
      font-size: 13px;
    }
    .reader-deal-rail-row {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 8px;
    }
    .reader-deal-hint {
      font-size: 12px;
      color: var(--text-muted);
      margin: 0 0 10px;
      line-height: 1.4;
    }
    .reader-deal-filings {
      list-style: none;
      margin: 8px 0 0;
      padding: 0;
      display: flex;
      flex-direction: column;
      gap: 4px;
    }
    .reader-deal-filing {
      display: block;
      width: 100%;
      text-align: left;
      background: var(--bg);
      border: 1px solid var(--surface-border);
      border-radius: 6px;
      padding: 7px 8px;
      cursor: pointer;
      color: inherit;
    }
    .reader-deal-filing:hover {
      border-color: var(--accent);
    }
    .reader-deal-filing.is-current {
      border-color: var(--accent);
      background: rgba(56, 139, 253, 0.08);
    }
    .reader-deal-filing-form {
      font-family: var(--font-mono);
      font-size: 12px;
      font-weight: 700;
    }
    .reader-deal-filing-meta {
      font-size: 11px;
      color: var(--text-muted);
      margin-top: 2px;
    }
    .reader-deal-actions {
      display: flex;
      flex-wrap: wrap;
      gap: 8px;
      margin: 10px 0 14px;
    }
    @media (max-width: 900px) {
      .reader-modal.has-deal-rail .reader-workspace {
        grid-template-columns: 1fr;
        overflow: auto;
      }
      .reader-modal.has-deal-rail.deal-rail-collapsed .reader-workspace {
        grid-template-columns: 1fr;
      }
      .reader-deal-rail {
        border-left: none;
        border-top: 1px solid var(--surface-border);
      }
      .reader-modal.deal-rail-collapsed .reader-deal-rail {
        max-height: 44px;
      }
      .reader-modal.deal-rail-collapsed .reader-deal-rail-head {
        flex-direction: row;
        height: auto;
      }
      .reader-modal.deal-rail-collapsed .reader-deal-rail-head h3 {
        writing-mode: horizontal-tb;
        transform: none;
        margin-top: 0;
      }
    }
    .reader-modal #readerContent {
      flex: 1 1 auto;
      min-height: min(16rem, 45vh);
      display: flex;
      flex-direction: column;
      overflow: hidden;
    }
    .reader-modal #readerContent.reader-view-stack {
      overflow: hidden;
    }
    .reader-modal #readerViewDocument {
      display: flex;
      flex-direction: column;
      flex: 1 1 auto;
      min-height: 0;
      overflow: hidden;
    }
    .reader-modal #readerViewDocument .reader-doc {
      flex: 1 1 auto;
      min-height: min(16rem, 45vh);
      overflow: auto;
    }
    .reader-modal.has-media {
      height: 90vh;
    }
    .reader-modal.has-media #readerViewDocument,
    .reader-modal.has-media .reader-media-host {
      flex: 1 1 auto;
      min-height: 0;
      display: flex;
      flex-direction: column;
      overflow: hidden;
    }
    .reader-modal.has-media-image #readerViewDocument,
    .reader-modal.has-media-image #readerContent,
    .reader-modal.has-media-image .reader-media-host {
      overflow: auto;
    }
    .reader-modal #readerViewDocument .reader-media,
    .reader-media {
      flex: 1 1 auto;
      min-height: 12rem;
      overflow: auto;
      display: flex;
      flex-direction: column;
      background: var(--bg);
      border: 1px solid var(--surface-border);
      border-radius: 6px;
    }
    .reader-modal.has-media-pdf #readerContent,
    .reader-modal.has-media-pdf #readerViewDocument,
    .reader-modal.has-media-pdf .reader-media-pdf-wrap {
      flex: 1 1 auto;
      min-height: min(20rem, 50vh);
      overflow: hidden;
    }
    .reader-media-status {
      margin: 8px 10px 0;
    }
    .reader-modal.has-media-image .reader-media-img-wrap {
      flex: 0 0 auto;
      min-height: 0;
      height: auto;
      overflow: visible;
    }
    .reader-media-img-wrap {
      align-items: center;
      justify-content: flex-start;
    }
    .reader-media-img {
      max-width: 100%;
      height: auto;
      display: block;
      margin: 0 auto;
      padding: 12px;
    }
    .reader-media-frame {
      flex: 1 1 auto;
      width: 100%;
      min-height: 24rem;
      border: 0;
      background: var(--bg);
    }
    .reader-modal.has-media .reader-media-frame {
      flex: 1 1 auto;
      min-height: min(20rem, 50vh);
      height: 100%;
    }
    .reader-modal #readerContent .reader-more {
      flex-shrink: 0;
    }
    .reader-header-actions {
      display: flex;
      align-items: center;
      gap: 8px;
    }
    .reader-footer {
      flex-shrink: 0;
      flex-wrap: wrap;
      justify-content: flex-end;
      margin-top: 12px;
    }
    .reader-queue-nav {
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      gap: 8px;
    }
    .reader-queue-nav[hidden] { display: none !important; }
    .reader-queue-pos {
      font-size: 12px;
      color: var(--text-muted);
      margin-right: 4px;
      white-space: nowrap;
    }
    .reader-footer kbd {
      font-family: var(--font-mono);
      font-size: 10px;
      font-weight: 600;
      padding: 1px 5px;
      border: 1px solid var(--surface-border);
      border-radius: 3px;
      margin-left: 4px;
      color: var(--text-muted);
      background: var(--bg);
    }
    .reader-doc {
      background: var(--bg);
      border: 1px solid var(--surface-border);
      border-radius: 6px;
      padding: 14px 16px;
      max-height: 70vh;
      overflow: auto;
      font-size: 13.5px;
      line-height: 1.45;
    }
    .reader-modal .reader-doc {
      flex: 1 1 auto;
      min-height: 12rem;
      max-height: none; /* fill remaining modal space; footer stays visible */
    }
    .reader-doc.reader-paper {
      background: #161513;
      color: #e8e2d6;
      color-scheme: dark;
      padding: 0;
      font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
      font-size: 16.5px;
      line-height: 1.55;
    }
    .reader-paper-page {
      max-width: 46rem;
      min-width: 0;
      margin: 0 auto;
      padding: 28px 32px 56px;
      background: #1c1a16;
      min-height: 100%;
      color: #e8e2d6;
      overflow-x: hidden;
      overflow-wrap: break-word;
      word-break: break-word;
    }
    .reader-modal.wide .reader-paper-page {
      max-width: 74rem;
      padding: 32px 40px 64px;
    }
    .reader-paper-page font {
      font-family: inherit;
      font-size: inherit;
      color: inherit;
    }
    .reader-paper-page p {
      margin: 0 0 0.7em;
    }
    .reader-paper-page h1,
    .reader-paper-page h2,
    .reader-paper-page h3,
    .reader-paper-page h4 {
      font-family: inherit;
      color: #f4efe6;
      line-height: 1.3;
      margin: 1.35em 0 0.45em;
      font-weight: 700;
    }
    .reader-paper-page h1 { font-size: 1.45em; }
    .reader-paper-page h2 { font-size: 1.22em; }
    .reader-paper-page h3 { font-size: 1.08em; }
    .reader-paper-page a {
      color: #8cb8ff;
    }
    .reader-paper-page hr {
      border: none;
      border-top: 1px solid #3d382f;
      margin: 1.2em 0;
    }
    .reader-paper-page img {
      max-width: 100%;
      height: auto;
      display: block;
      margin: 12px auto;
    }
    .reader-paper-page table {
      border-collapse: collapse;
      margin: 0.65em 0 1em;
      font-size: 0.86em;
      line-height: 1.35;
      width: 100%;
      max-width: 100%;
      box-sizing: border-box;
      table-layout: auto;
      background: #161412;
    }
    .reader-paper-page table table {
      margin: 0.35em 0 0;
      font-size: inherit;
      width: 100%;
      max-width: 100%;
    }
    .reader-paper-page th,
    .reader-paper-page td {
      border: 1px solid #3d382f;
      padding: 4px 8px;
      vertical-align: top;
      color: #e8e2d6;
      background: #161412;
      white-space: normal;
      overflow-wrap: anywhere;
      word-break: break-word;
    }
    .reader-paper-page td > div,
    .reader-paper-page th > div {
      white-space: normal;
      overflow-wrap: anywhere;
      word-break: break-word;
      max-width: 100%;
    }
    .reader-paper-page th {
      font-weight: 700;
      background: #2a2722;
    }
    .reader-doc.dense {
      font-size: 12.5px;
      line-height: 1.35;
      padding: 10px 12px;
    }
    .reader-doc em {
      font-style: italic;
      color: var(--text-main);
    }
    .reader-doc h1, .reader-doc h2, .reader-doc h3 { margin: 16px 0 8px; line-height: 1.3; }
    .reader-doc h1 { font-size: 22px; }
    .reader-doc h2 { font-size: 18px; }
    .reader-doc h3 { font-size: 15px; }
    .reader-doc.dense h3 {
      margin: 10px 0 4px;
      font-size: 13px;
      font-weight: 700;
      color: var(--accent);
      letter-spacing: 0.01em;
    }
    .reader-doc p { margin: 0 0 8px; }
    .reader-doc.dense p { margin: 0 0 4px; }
    .reader-doc ul, .reader-doc ol { margin: 0 0 10px 1.2em; }
    .reader-doc.dense ul, .reader-doc.dense ol { margin: 0 0 6px 1.1em; }
    .reader-doc li { margin: 2px 0; }
    .reader-doc a { color: var(--accent); }
    .reader-doc code { font-family: var(--font-mono); font-size: 12px; }
    .reader-doc hr { border: none; border-top: 1px solid var(--surface-border); margin: 14px 0; }
    .reader-doc.dense hr { margin: 6px 0; opacity: 0.55; }
    .reader-doc table { width: 100%; border-collapse: collapse; margin: 10px 0 14px; font-size: 13px; }
    .reader-doc.dense table { margin: 2px 0 8px; font-size: 12px; }
    .reader-doc th, .reader-doc td {
      border: 1px solid var(--surface-border);
      padding: 6px 8px;
      vertical-align: top;
      text-align: left;
    }
    .reader-doc th { background: #1c2128; }
    .reader-doc table.financial-table {
      font-size: 12px;
      width: max-content;
      max-width: 100%;
    }
    .reader-doc table.financial-table th,
    .reader-doc table.financial-table td {
      padding: 3px 8px;
      border-color: rgba(48, 54, 61, 0.85);
    }
    .reader-doc table.financial-table th:first-child,
    .reader-doc table.financial-table td:first-child {
      text-align: left;
      min-width: 14em;
      max-width: 28em;
    }
    .reader-doc table.financial-table th:not(:first-child) {
      text-align: right;
      font-family: var(--font-mono);
      font-variant-numeric: tabular-nums;
      white-space: normal;
      max-width: 5.75rem;
      min-width: 4.5rem;
      line-height: 1.2;
      font-size: 10.5px;
      font-weight: 650;
      vertical-align: bottom;
      hyphens: auto;
    }
    .reader-doc table.financial-table td:not(:first-child) {
      text-align: right;
      font-family: var(--font-mono);
      font-variant-numeric: tabular-nums;
      white-space: nowrap;
    }
    .reader-modal.wide .reader-doc table.financial-table th:not(:first-child) {
      max-width: 8rem;
      min-width: 5.5rem;
      font-size: 11px;
    }
    .reader-doc table.financial-table tr.section-row td {
      font-weight: 700;
      background: rgba(255, 255, 255, 0.02);
      padding-top: 10px;
    }
    .reader-doc table.financial-table tr.total-row td {
      font-weight: 700;
      border-top: 1px solid var(--text-muted);
    }
    .reader-doc.reader-paper,
    .reader-doc.reader-paper em {
      color: #e8e2d6;
    }
    .reader-doc.reader-paper a {
      color: #8cb8ff;
    }
    .reader-doc.reader-paper hr {
      border-top-color: #3d382f;
    }
    .reader-doc.reader-paper table {
      width: 100%;
      max-width: 100%;
      background: #161412;
      font-size: 0.86em;
    }
    .reader-doc.reader-paper th,
    .reader-doc.reader-paper td {
      color: #e8e2d6;
      background: #161412;
      border-color: #3d382f;
    }
    .reader-doc.reader-paper th {
      background: #2a2722;
    }
    .reader-doc.reader-paper td[align="right"],
    .reader-doc.reader-paper th[align="right"] {
      text-align: right;
    }
    .reader-doc.reader-paper td[align="center"],
    .reader-doc.reader-paper th[align="center"] {
      text-align: center;
    }
    .reader-more {
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      gap: 8px;
      margin-top: 8px;
      padding-top: 8px;
      border-top: 1px solid rgba(48, 54, 61, 0.7);
    }
    .reader-more .hint { margin: 0; flex: 1 1 200px; font-size: 11.5px; }
    .reader-more .btn { padding: 3px 8px; font-size: 11px; }
    .section-pills { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
    .section-pills .btn.active { border-color: var(--accent); color: var(--accent); }

    /* Reader chrome: Form / AI / Notes on top; sections + Attached nested under Form. */
    .reader-chrome {
      display: flex;
      flex-direction: column;
      gap: 6px;
      margin: 0 0 10px;
      min-height: 0;
    }
    .reader-chrome-top {
      display: flex;
      flex-wrap: wrap;
      gap: 6px;
      align-items: center;
      margin: 0;
    }
    .reader-form-nested {
      display: flex;
      flex-direction: column;
      gap: 6px;
      padding: 6px 0 2px 10px;
      border-left: 2px solid rgba(88, 166, 255, 0.28);
      margin-left: 4px;
    }
    .reader-form-nested[hidden] {
      display: none !important;
    }
    .reader-section-pills {
      margin: 0;
    }
    .reader-attached {
      margin: 0;
    }
    .reader-attached-details {
      border: 1px solid rgba(48, 54, 61, 0.85);
      border-radius: 6px;
      padding: 4px 8px 6px;
      background: rgba(22, 27, 34, 0.45);
    }
    .reader-attached-summary {
      cursor: pointer;
      font-size: 12px;
      color: var(--text-muted);
      user-select: none;
      list-style: none;
    }
    .reader-attached-summary::-webkit-details-marker {
      display: none;
    }
    .reader-attached-summary::before {
      content: "▸ ";
      color: var(--accent);
    }
    .reader-attached-details[open] > .reader-attached-summary::before {
      content: "▾ ";
    }
    .reader-attached-pills {
      display: flex;
      flex-direction: column;
      gap: 8px;
      margin-top: 8px;
      max-height: min(28vh, 220px);
      overflow-x: hidden;
      overflow-y: auto;
      padding-right: 2px;
    }
    .reader-attached-group {
      display: flex;
      flex-direction: column;
      gap: 4px;
    }
    .reader-attached-label {
      margin: 0;
      font-size: 11px;
    }
    .reader-attached-row {
      display: flex;
      flex-wrap: wrap;
      gap: 6px;
    }
    .reader-ibr-btn.is-disabled,
    .reader-ibr-btn:disabled {
      opacity: 0.55;
      cursor: not-allowed;
    }
    .reader-form-tab {
      position: relative;
      padding-right: 18px !important;
    }
    .reader-ai-mark {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      min-width: 8px;
      height: 8px;
      margin-left: 5px;
      border-radius: 999px;
      background: #79b8ff;
      vertical-align: middle;
      font-size: 9px;
      line-height: 1;
      color: #0d1117;
      font-weight: 700;
      padding: 0 3px;
      box-sizing: border-box;
    }
    .reader-ai-mark.has-sections {
      min-width: 14px;
      height: 14px;
      background: #1f6feb;
      color: #fff;
    }
    .reader-ai-mark.has-full:not(.has-sections) {
      width: 8px;
      padding: 0;
    }
    .reader-section-pills .btn {
      position: relative;
      padding-right: 14px !important;
    }
    .reader-ai-dot {
      display: inline-block;
      width: 6px;
      height: 6px;
      margin-left: 4px;
      border-radius: 50%;
      background: #79b8ff;
      vertical-align: middle;
    }
    .reader-edgar-wrap {
      position: relative;
      display: inline-flex;
      align-items: center;
    }
    .reader-edgar-btn {
      display: inline-flex;
      align-items: center;
      gap: 4px;
      padding: 3px 8px;
      font-size: 11px;
    }
    .reader-edgar-ext {
      font-size: 11px;
      opacity: 0.85;
    }
    .reader-edgar-menu {
      position: absolute;
      top: calc(100% + 4px);
      right: 0;
      z-index: 40;
      min-width: 140px;
      padding: 4px;
      border: 1px solid var(--surface-border);
      border-radius: 6px;
      background: var(--surface);
      box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
      display: flex;
      flex-direction: column;
      gap: 2px;
    }
    .reader-edgar-menu[hidden] {
      display: none !important;
    }
    .reader-edgar-menu-item {
      display: block;
      width: 100%;
      text-align: left;
      background: none;
      border: none;
      color: var(--text-main);
      font: inherit;
      font-size: 12px;
      padding: 6px 8px;
      border-radius: 4px;
      cursor: pointer;
    }
    .reader-edgar-menu-item:hover {
      background: rgba(88, 166, 255, 0.12);
      color: var(--accent);
    }
    .reader-ai-picker {
      position: fixed;
      inset: 0;
      /* Above #readerModal (1200) and #plansModal (1300). */
      z-index: 1400;
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 16px;
      background: rgba(1, 4, 9, 0.62);
    }
    .reader-ai-picker-card {
      width: min(560px, 100%);
      max-height: min(90vh, 820px);
      overflow: hidden;
      background: var(--surface);
      border: 1px solid var(--surface-border);
      border-radius: 8px;
      padding: 16px;
      display: flex;
      flex-direction: column;
      gap: 10px;
      box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
    }
    .reader-ai-picker-toolbar {
      display: flex;
      gap: 8px;
      flex-wrap: wrap;
    }
    .reader-ai-picker-skim {
      display: flex;
      flex-direction: column;
      gap: 6px;
      border: 1px solid var(--surface-border);
      border-radius: 8px;
      padding: 8px;
      background: var(--bg, #0d1117);
    }
    .reader-ai-picker-skim[hidden] {
      display: none !important;
    }
    .reader-ai-picker-skim-head {
      display: flex;
      align-items: center;
      gap: 8px;
    }
    .reader-ai-picker-skim-head strong {
      flex: 1;
      font-size: 13px;
    }
    .reader-ai-picker-skim-body {
      margin: 0;
      max-height: 180px;
      overflow: auto;
      white-space: pre-wrap;
      font-size: 12px;
      line-height: 1.45;
      color: var(--text-muted);
    }
    .reader-ai-picker-skim-btn {
      flex-shrink: 0;
    }
    .reader-ai-picker-guide {
      display: flex;
      flex-direction: column;
      gap: 8px;
      margin-top: 2px;
    }
    .reader-ai-picker-guide-toggle {
      align-self: flex-start;
      padding: 4px 10px;
      font-size: 12px;
    }
    .reader-ai-picker-guide-panel {
      display: flex;
      flex-direction: column;
      gap: 6px;
    }
    .reader-ai-picker-guide-panel[hidden] {
      display: none !important;
    }
    .reader-ai-picker-ask-label {
      margin: 0;
      display: block;
    }
    .reader-ai-picker-ask.summarize-input,
    .reader-ai-picker-ask {
      width: 100%;
      box-sizing: border-box;
      margin: 0;
      padding: 10px 12px;
      min-height: 72px;
      resize: vertical;
      font-size: 13px;
      line-height: 1.45;
      color: var(--text-main);
      background: var(--surface, #fff);
      border: 1px solid var(--surface-border, rgba(0, 0, 0, 0.12));
      border-radius: 10px;
      box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.03);
      transition: border-color 0.15s ease, box-shadow 0.15s ease;
    }
    .reader-ai-picker-ask:hover {
      border-color: rgba(88, 166, 255, 0.45);
    }
    .reader-ai-picker-ask:focus {
      outline: none;
      border-color: rgba(88, 166, 255, 0.75);
      box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.18);
    }
    .reader-ai-picker-options {
      display: flex;
      flex-direction: column;
      gap: 8px;
      overflow: auto;
      max-height: min(42vh, 360px);
      padding-right: 4px;
    }
    .reader-ai-picker-group-label {
      margin: 6px 0 0;
      font-size: 11px;
      text-transform: uppercase;
      letter-spacing: 0.04em;
    }
    .reader-ai-picker-title {
      margin: 0;
      font-size: 16px;
      font-weight: 600;
    }
    .reader-ai-picker-hint {
      margin: 0;
    }
    .reader-ai-picker-saved-banner {
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      gap: 8px 12px;
      padding: 8px 10px;
      border: 1px solid var(--surface-border);
      border-radius: 6px;
      background: rgba(31, 111, 235, 0.12);
    }
    .reader-ai-picker-saved-banner[hidden] {
      display: none;
    }
    .reader-ai-picker-saved-banner .hint {
      margin: 0;
      flex: 1 1 220px;
    }
    .reader-ai-picker-saved {
      display: inline-block;
      margin-left: 6px;
      padding: 1px 6px;
      border-radius: 999px;
      font-size: 10px;
      font-weight: 700;
      letter-spacing: 0.02em;
      color: #79b8ff;
      background: rgba(31, 111, 235, 0.18);
      vertical-align: middle;
    }
    .reader-ai-picker-option {
      display: flex;
      align-items: center;
      gap: 8px;
      font-size: 13px;
      cursor: pointer;
    }
    .reader-ai-picker-option[hidden] {
      display: none !important;
    }
    .reader-ai-picker-option-text {
      display: flex;
      flex-direction: column;
      gap: 2px;
      min-width: 0;
    }
    .reader-ai-picker-option-title {
      color: var(--text-main);
    }
    .reader-ai-picker-cost {
      margin: 0;
      font-size: 11.5px;
    }
    .reader-ai-picker-actions {
      display: flex;
      justify-content: flex-end;
      flex-wrap: wrap;
      gap: 8px;
      margin-top: 4px;
    }
    .edgar-grid {
      display: grid;
      grid-template-columns: minmax(260px, 340px) 1fr;
      gap: 16px;
      margin-bottom: 20px;
    }
    @media (max-width: 900px) {
      .edgar-grid { grid-template-columns: 1fr; }
    }
    .edgar-table tbody tr { cursor: default; }
    .position-input {
      width: 96px;
      background: var(--bg);
      border: 1px solid var(--surface-border);
      color: var(--text-main);
      border-radius: 4px;
      padding: 4px 6px;
      font-family: var(--font-mono);
      font-size: 12px;
    }
    .gain-up { color: #3fb950; }
    .gain-down { color: #ff7b72; }

    /* Followable ticker mentions (summaries, notes, share pages) */
    .ft-ticker {
      display: inline-flex;
      align-items: center;
      gap: 4px;
      margin: 0 1px;
      vertical-align: baseline;
    }
    .ft-ticker-sym {
      font-weight: 700;
      font-variant-numeric: tabular-nums;
      letter-spacing: 0.02em;
    }
    .ft-follow-btn {
      appearance: none;
      border: 1px solid var(--surface-border);
      background: transparent;
      color: var(--accent);
      font: inherit;
      font-size: 11px;
      font-weight: 600;
      line-height: 1.2;
      padding: 1px 6px;
      border-radius: 4px;
      cursor: pointer;
    }
    .ft-follow-btn:hover:not(:disabled) {
      border-color: var(--accent);
    }
    .ft-follow-btn:disabled {
      opacity: 0.6;
      cursor: default;
    }
    .ft-ticker-following {
      font-size: 11px;
    }
