:root {
  --bg: #f7f6f2;
  --panel: #ffffff;
  --border: #dedbd3;
  --text: #1c1c1c;
  --muted: #6b6b6b;
  --accent: #2f2f2f;
  --chip-high: #7b1f1f;
  --chip-medium: #8a5a00;
  --chip-low: #495161;
  --chip-noise: #7f7f7f;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Helvetica Neue", "Arial", sans-serif;
  color: var(--text);
  background: var(--bg);
  overflow-x: hidden;
}

.global-header {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 24px 0;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}

.header-row {
  display: grid;
  grid-template-columns: 1fr;
  align-items: center;
  gap: 12px;
}

.header-row-nav {
  display: flex;
  gap: 8px;
  border-top: 1px solid var(--border);
  padding: 8px 0 0;
  margin-top: 6px;
}

.nav-tab {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 8px 12px;
  border: 1px solid transparent;
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  color: var(--muted);
  text-decoration: none;
}

.nav-tab.active {
  background: #f7f6f2;
  border-color: var(--border);
  color: var(--text);
  font-weight: 600;
}

.nav-cta {
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  background: #f7f6f2;
}

.header-row-nav .nav-tab:first-child {
  margin-left: 0;
}

.header-search {
  display: none;
}

.header-status {
  display: none;
}

.app-grid {
  display: grid;
  grid-template-columns: 300px 1fr 420px;
  gap: 16px;
  width: 100%;
  max-width: 1600px;
  margin: 0 auto;
  min-height: 100vh;
}

.app-grid.drawer-collapsed {
  grid-template-columns: 300px 1fr;
}

.app-grid.drawer-collapsed #drawer {
  display: none;
}

.sidebar {
  border-right: 1px solid var(--border);
  padding: 20px;
  background: var(--panel);
}

.sidebar h1 {
  font-size: 20px;
  margin: 0 0 6px 0;
}

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

.brand-title {
  font-family: "Georgia", "Times New Roman", serif;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.08em;
}

.brand-tagline {
  font-size: 9px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.btn {
  border: 1px solid var(--border);
  background: #f4f3ef;
  border-radius: 6px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 12px;
}

.btn:hover {
  background: #eceae4;
}

.btn-ghost {
  background: none;
  border: none;
  padding: 4px;
}

.btn-ghost:hover {
  text-decoration: underline;
}

.btn-primary {
  background: #1f2733;
  color: #fff;
  border-color: #1f2733;
}

.btn-primary:hover {
  background: #0f141b;
}

.sidebar-header p {
  margin: 0 0 12px 0;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.watchlists {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.watchlist-item {
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border: 1px solid #e5e7eb;
  background: #fff;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
}

.watchlist-item:hover {
  background: #f7f6f2;
}

.watchlist-item.selected {
  border-color: #0b1f3a;
  box-shadow: inset 3px 0 0 #0b1f3a;
  font-weight: 600;
}

.watchlist-item .count {
  color: var(--muted);
  font-weight: 400;
}

.watchlist-actions {
  margin-top: 12px;
  display: flex;
  gap: 8px;
  position: relative;
}

.watchlist-rename {
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}

.watchlist-rename button {
  border: 1px solid var(--border);
  background: var(--panel);
  cursor: pointer;
  padding: 2px 6px;
}

.watchlist-actions input {
  flex: 1;
  padding: 6px 8px;
  border: 1px solid var(--border);
}

.sidebar-section {
  margin-top: 20px;
}

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

.typeahead {
  position: absolute;
  top: 34px;
  left: 0;
  right: 0;
  background: var(--panel);
  border: 1px solid var(--border);
  display: none;
  z-index: 5;
}

.typeahead-item {
  padding: 6px 8px;
  cursor: pointer;
  font-size: 12px;
}

.typeahead-item:hover {
  background: #efeee7;
}

.watchlist-items {
  margin-top: 12px;
  border-top: 1px solid var(--border);
  padding-top: 10px;
  font-size: 12px;
}

.watchlist-item-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
}

.watchlist-item-row button {
  border: none;
  background: none;
  color: var(--muted);
  cursor: pointer;
}

.main {
  padding: 16px 20px;
  overflow-x: auto;
}

.filters {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.filters select,
.filters button,
.filters input {
  border: 1px solid var(--border);
  padding: 6px 8px;
  background: var(--panel);
  font-size: 13px;
}

.event-types {
  position: relative;
}

.investor-mode .event-types {
  display: none;
}

.event-types-popover {
  position: absolute;
  top: 32px;
  left: 0;
  background: var(--panel);
  border: 1px solid var(--border);
  padding: 8px;
  display: none;
  z-index: 5;
  min-width: 220px;
}

.event-types-popover label {
  display: block;
  font-size: 12px;
  margin-bottom: 4px;
}

.table-wrap {
  background: var(--panel);
  border: 1px solid var(--border);
  overflow: auto;
}

.empty-state {
  display: none;
  margin-top: 16px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
  color: var(--muted);
}

.empty-state h3 {
  margin-top: 0;
  color: var(--text);
}

.empty-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.pagination {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  font-size: 12px;
  color: var(--muted);
}

.loading-row {
  text-align: left;
  color: var(--muted);
}

.digest-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  table-layout: fixed;
}

.digest-table th {
  padding: 10px;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.digest-table td {
  padding: 10px 10px;
  line-height: 1.25;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.digest-table tr:hover {
  background: #f0efe8;
}

.digest-table tbody tr {
  cursor: pointer;
}

.headline-text {
  font-weight: 600;
  color: var(--text);
}

.facts-strip {
  margin-top: 4px;
  font-size: 11px;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.facts-strip .fact {
  white-space: nowrap;
}

.facts-strip .fact button {
  border: none;
  background: none;
  color: inherit;
  cursor: pointer;
  font-size: 11px;
  padding: 0;
}

.badge-low-confidence {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;
  border-radius: 10px;
  border: 1px solid #b18b34;
  color: #7a5a19;
  font-size: 10px;
  text-transform: uppercase;
}

.digest-table tr.selected {
  background: #f1efe7;
  border-left: 3px solid var(--accent);
}

.chip {
  padding: 2px 6px;
  border-radius: 10px;
  font-size: 11px;
  color: white;
  display: inline-block;
  font-variant-numeric: tabular-nums;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chip.high { background: var(--chip-high); }
.chip.medium { background: var(--chip-medium); }
.chip.low { background: var(--chip-low); }
.chip.noise { background: var(--chip-noise); }

.subtype {
  border: 1px solid var(--border);
  padding: 2px 6px;
  border-radius: 10px;
  font-size: 11px;
  color: var(--muted);
  max-width: 100%;
  display: inline-block;
}

.badge-source {
  border: 1px solid var(--border);
  padding: 2px 6px;
  border-radius: 10px;
  font-size: 11px;
  color: var(--muted);
}

.truncate {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.col-time { width: 90px; }
.col-ticker { width: 90px; }
.col-headline { width: auto; }
.col-impact { width: 110px; }
.col-source { width: 130px; }

.company-main {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.cell-truncate {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.drawer-toggle {
  display: none;
}

.drawer {
  border-left: 1px solid var(--border);
  background: var(--panel);
  padding: 16px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
}

.drawer-hidden {
  opacity: 0.4;
}

.drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.drawer-header h2 {
  margin: 0;
  font-size: 18px;
}

.drawer-sub {
  color: var(--muted);
  font-size: 12px;
}

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

.drawer-logo {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  background: #1f2733;
  color: #f7f6f2;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12px;
  border: 1px solid var(--border);
  overflow: hidden;
}

.drawer-logo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 6px;
}

.drawer-actions {
  display: flex;
  gap: 4px;
}

.drawer-domain {
  font-size: 11px;
  color: var(--muted);
}

.drawer-meta {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-top: 4px;
}

.drawer-domain-edit {
  display: none;
  flex-direction: column;
  gap: 6px;
  padding: 8px 0;
}

.drawer-domain-edit input {
  flex: 1;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.drawer-domain-label {
  font-size: 11px;
  color: var(--muted);
}

.drawer-domain-helper {
  font-size: 11px;
  color: var(--muted);
}

.public-feed {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px;
}

.nct-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 12px;
}

.nct-brand {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.nct-id {
  font-weight: 600;
}

.nct-title {
  font-size: 18px;
  font-weight: 600;
}

.nct-company {
  font-size: 12px;
  color: var(--muted);
}

.nct-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.nct-page .nct-facts {
  font-size: 12px;
  color: var(--muted);
  margin: 8px 0 16px;
}

.nct-page .card {
  border: 1px solid var(--border);
  background: #ffffff;
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 12px;
}

.nct-page .card-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 8px;
}

.nct-page .card-body {
  font-size: 14px;
  color: var(--text);
}

.nct-page .event-row {
  grid-template-columns: 90px 1fr 110px 80px;
}

.nct-page .event-ticker {
  display: none;
}

.nct-page .event-headline .headline {
  font-weight: 600;
  font-size: 14px;
}

.nct-page .event-headline .facts {
  font-size: 12px;
  color: var(--muted);
}

.public-hero {
  margin-bottom: 24px;
}

.public-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.public-stats div {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
}

.public-stats strong {
  display: block;
  font-size: 16px;
}

.public-stats span {
  font-size: 11px;
  color: var(--muted);
}

.public-feed .event-row {
  display: grid;
  grid-template-columns: 90px 220px 1fr 110px 80px;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.public-feed .event-row:last-child {
  border-bottom: none;
}

.public-feed .event-time {
  font-size: 12px;
  color: var(--muted);
}

.public-feed .headline {
  font-weight: 600;
}

.public-feed .facts {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.35;
  margin-top: 4px;
}

.public-feed .facts a {
  color: var(--ink);
  text-decoration: none;
}

.public-feed .facts a:hover {
  text-decoration: underline;
}

.public-feed .event-ticker {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.public-feed .logo {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid var(--border);
  object-fit: cover;
}

.public-feed .logo-fallback {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #1f2733;
  color: #fff;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.public-feed .ticker {
  font-weight: 600;
}

.public-feed .company {
  font-size: 11px;
  color: var(--muted);
}

.public-feed .nct-link {
  font-weight: 600;
}

.day-section {
  margin-bottom: 24px;
}

.day-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 10px 0 16px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #ffffff;
  font-size: 12px;
  color: var(--muted);
}

.day-nav a {
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
}

.day-nav a:hover {
  text-decoration: underline;
}

.day-page {
  font-weight: 600;
  color: var(--text);
}

@media (max-width: 900px) {
  .public-stats {
    grid-template-columns: 1fr;
  }
  .public-feed .event-row {
    grid-template-columns: 80px 1fr;
  }
  .public-feed .event-impact,
  .public-feed .event-link {
    display: none;
  }
  .nct-header {
    flex-direction: column;
  }
  .nct-actions {
    width: 100%;
    justify-content: flex-start;
  }
}

.ai-block {
  border: 1px solid var(--border);
  background: #fbfaf6;
}

.ai-tags {
  margin-top: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.ai-tag {
  font-size: 10px;
  padding: 2px 6px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
}

.ai-indicator {
  font-size: 10px;
  margin-right: 6px;
  padding: 2px 6px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
}

.impact {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.impact.major {
  border-color: #7b1f1f;
  color: #7b1f1f;
}

.impact.high {
  border-color: #8a5a00;
  color: #8a5a00;
}

.impact.medium {
  border-color: #6b6b6b;
  color: #6b6b6b;
}

.impact.low {
  border-color: #9aa0a6;
  color: #9aa0a6;
}

.top-controls {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.error-banner {
  display: none;
  margin-bottom: 10px;
  padding: 10px 12px;
  border: 1px solid #7b1f1f;
  border-radius: 8px;
  color: #7b1f1f;
  background: #fbf1f1;
  font-size: 12px;
}

.drawer-links {
  margin: 8px 0;
  display: flex;
  gap: 10px;
}

.drawer-tabs {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.drawer-tabs .tab {
  border: 1px solid var(--border);
  background: var(--panel);
  padding: 4px 8px;
  cursor: pointer;
}

.drawer-tabs .tab.active {
  background: #1f2733;
  color: #fff;
}

.segmented {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.segmented .tab {
  border: none;
  background: #f4f3ef;
  padding: 6px 10px;
}

.segmented .tab.active {
  background: #1f2733;
  color: #fff;
}

.drawer-content {
  margin-top: 12px;
  font-size: 13px;
}

.drawer-block {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  margin-bottom: 8px;
}

.drawer-block ul {
  margin: 6px 0 0 18px;
  padding: 0;
}

.method-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.method-body {
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
}

.tldr-text {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.drawer-raw {
  display: none;
  background: #f2f2f2;
  padding: 8px;
  font-size: 11px;
  white-space: pre-wrap;
  border-radius: 8px;
  max-height: 420px;
  overflow: auto;
}

.inline-disclaimer {
  margin-top: 10px;
  font-size: 12px;
  color: var(--muted);
}

.link {
  color: #0b1f3a;
  text-decoration: none;
}

.link:hover {
  text-decoration: underline;
}

.footer {
  display: grid;
  grid-template-columns: 1fr 2fr 1fr;
  gap: 12px;
  padding: 12px 24px;
  border-top: 1px solid var(--border);
  background: var(--panel);
  font-size: 11px;
  color: var(--muted);
}

.footer-links {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

.page {
  max-width: 860px;
  margin: 0 auto;
  padding: 40px 24px 80px;
  font-size: 15px;
  line-height: 1.6;
}

.page h1 {
  font-size: 34px;
  letter-spacing: 0.01em;
  margin-bottom: 12px;
}

.page h2 {
  font-size: 22px;
  margin-bottom: 8px;
}

.page h3 {
  font-size: 18px;
}

.page-section {
  margin-top: 20px;
}

.page-muted {
  color: var(--muted);
}

.page ul {
  padding-left: 20px;
  color: var(--text);
}

.legal-banner {
  margin: 12px 0 18px;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #f7f6f2;
  color: var(--muted);
  font-size: 12px;
}

.policy {
  border-top: 1px solid var(--border);
  padding-top: 24px;
}

.page-hero {
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background-image:
    linear-gradient(135deg, rgba(255, 255, 255, 0.96) 0%, rgba(245, 242, 234, 0.96) 100%),
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='640' height='220' viewBox='0 0 640 220'><rect width='640' height='220' fill='%23f7f6f2'/><g fill='none' stroke='%23dedbd3' stroke-width='1'><path d='M40 160 C140 80 240 200 340 120 S540 40 600 140'/><path d='M20 120 C120 40 220 160 320 80 S520 0 620 100' opacity='0.6'/></g><g fill='%23d6c9b5' opacity='0.7'><circle cx='80' cy='60' r='2'/><circle cx='140' cy='90' r='2'/><circle cx='220' cy='70' r='2'/><circle cx='320' cy='110' r='2'/><circle cx='420' cy='80' r='2'/><circle cx='520' cy='120' r='2'/></g></svg>");
  background-size: cover;
  background-position: center;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.02);
  margin-bottom: 18px;
}

.page-hero h1 {
  margin-top: 0;
}

.policy-toc {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 12px;
  color: var(--muted);
  margin: 12px 0 20px;
}

.toc-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  background: #fbfaf6;
}

.toc-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 8px;
}

.policy-section {
  padding: 16px 0;
  border-top: 1px solid var(--border);
}

.policy-section:first-of-type {
  border-top: none;
}

.callout {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fbfaf6;
  font-size: 12px;
  color: var(--muted);
}

.policy-section.grid-two {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  align-items: start;
}

.policy-section.grid-two h2 {
  grid-column: 1 / -1;
  margin-bottom: 0;
}

.info-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #ffffff;
  padding: 12px 14px;
}

.info-card p {
  margin: 6px 0 0;
  color: var(--text);
  font-size: 14px;
}

.info-card .card-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

@media (max-width: 900px) {
  .policy-section.grid-two {
    grid-template-columns: 1fr;
  }
}

.diagram {
  width: 100%;
  max-width: 900px;
  margin-top: 8px;
}

.price-card {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #ffffff;
}

.price-cta {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-start;
}

.admin-auth {
  display: flex;
  gap: 8px;
  align-items: center;
}

.admin-auth input {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.admin-status {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
}

.admin-log {
  background: #11161c;
  color: #f3f3f3;
  padding: 12px;
  border-radius: 8px;
  min-height: 160px;
  font-size: 12px;
  overflow: auto;
}

@media (max-width: 1200px) {
  .app-grid {
    grid-template-columns: 200px 1fr;
  }
  .drawer {
    display: none;
  }
  .drawer.drawer-open {
    display: block;
    position: fixed;
    right: 0;
    top: 0;
    width: 90vw;
    max-width: 420px;
    z-index: 10;
    box-shadow: -12px 0 24px rgba(0, 0, 0, 0.1);
  }
  .drawer-toggle {
    display: block;
    position: fixed;
    bottom: 16px;
    right: 16px;
    background: var(--panel);
    border: 1px solid var(--border);
    padding: 8px 12px;
    z-index: 11;
  }
}
.col-headline {
  white-space: nowrap;
}
