:root {
  --ink: #102a33;
  --ink-muted: #557078;
  --paper: #f5f2e9;
  --panel: #fffdf8;
  --line: #d9ded8;
  --line-strong: #b9c6c3;
  --coral: #f15b45;
  --coral-dark: #cf402c;
  --sea: #0f6666;
  --sea-soft: #d9efea;
  --gold-soft: #f4e8bf;
  --shadow: 0 18px 60px rgba(16, 42, 51, .09);
  --radius: 16px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 1180px; background: var(--paper); }
button, input, select, textarea { font: inherit; }
button { color: inherit; }

.app-shell { min-height: 100vh; }
.topbar {
  height: 86px;
  padding: 0 28px;
  background: var(--ink);
  color: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 4px solid var(--coral);
}
.brand-lockup, .topbar-actions, .detail-heading, .draft-footer, .draft-action, .panel-heading, .list-header, .settings-header, .settings-footer { display: flex; align-items: center; }
.logout-form { margin: 0; }
.brand-lockup { gap: 14px; }
.brand-mark, .empty-monogram {
  width: 46px; height: 46px; border-radius: 50%;
  background: var(--coral); color: white; display: grid; place-items: center;
  font: 700 24px Georgia, serif;
}
.brand-lockup h1 { font: 500 25px Georgia, serif; margin: 2px 0 0; letter-spacing: -.02em; }
.eyebrow { font-size: 10px; font-weight: 800; letter-spacing: .18em; text-transform: uppercase; }
.topbar .eyebrow { color: #b8cbc9; }
.topbar-actions { gap: 16px; }
.connection-state { font-size: 13px; display: flex; align-items: center; gap: 8px; color: #cfdbda; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #a7b4b4; }
.connection-state.connected .status-dot { background: #70d5a3; box-shadow: 0 0 0 4px rgba(112, 213, 163, .12); }

.metric-strip {
  height: 88px; display: grid; grid-template-columns: repeat(4, 170px) 1fr;
  gap: 1px; padding: 0 28px; align-items: stretch; background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.metric { border: 0; background: transparent; text-align: left; padding: 14px 16px; cursor: pointer; border-right: 1px solid var(--line); }
.metric:hover { background: #f9f7f0; }
.metric span { display: block; font: 500 26px Georgia, serif; }
.metric small { color: var(--ink-muted); font-size: 11px; }
.draft-safety { justify-self: end; align-self: center; display: flex; flex-direction: column; text-align: right; }
.draft-safety strong { color: var(--sea); font-size: 11px; letter-spacing: .13em; }
.draft-safety span { color: var(--ink-muted); font-size: 11px; margin-top: 4px; }

.workspace { display: grid; grid-template-columns: 246px 390px minmax(500px, 1fr); gap: 12px; padding: 12px; height: calc(100vh - 174px); }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: 0 4px 18px rgba(16, 42, 51, .035); }
.filters { padding: 18px; overflow-y: auto; }
.panel-heading, .list-header, .detail-heading, .settings-header { justify-content: space-between; }
.text-button { border: 0; padding: 0; background: transparent; color: var(--coral-dark); font-size: 12px; cursor: pointer; }
.field-label, .editor-field > span, .editor-grid label > span { display: block; font-size: 11px; font-weight: 700; margin: 17px 0 7px; color: var(--ink-muted); }
.input { width: 100%; border: 1px solid var(--line-strong); background: white; color: var(--ink); padding: 10px 11px; border-radius: 8px; outline: none; }
.input:focus { border-color: var(--sea); box-shadow: 0 0 0 3px rgba(15, 102, 102, .1); }
fieldset { border: 0; border-top: 1px solid var(--line); margin: 18px 0 0; padding: 16px 0 0; }
legend { font-size: 11px; font-weight: 800; color: var(--ink-muted); padding: 0 8px 0 0; }
fieldset label { display: flex; align-items: center; gap: 8px; padding: 6px 0; font-size: 12px; cursor: pointer; }
input[type="radio"] { accent-color: var(--coral); }
.rank-fields { display: grid; grid-template-columns: 1fr .8fr; gap: 8px; }
.shortcut-card { margin-top: 20px; padding: 14px; background: var(--ink); color: white; border-radius: 10px; }
.shortcut-card .eyebrow { color: #a9c5c3; }
.shortcut-card dl { margin: 10px 0 0; }
.shortcut-card dl div { display: flex; justify-content: space-between; gap: 12px; font-size: 10px; padding: 4px 0; color: #d6e0df; }
.shortcut-card dt { color: white; font-weight: 800; }
.shortcut-card dd { margin: 0; text-align: right; }

.contact-panel { display: flex; flex-direction: column; }
.list-header { padding: 18px; border-bottom: 1px solid var(--line); }
.list-header h2 { font: 500 20px Georgia, serif; margin: 3px 0 0; }
.count-badge { min-width: 34px; height: 25px; padding: 0 9px; display: grid; place-items: center; border-radius: 999px; background: var(--sea-soft); color: var(--sea); font-weight: 800; font-size: 11px; }
.contact-list { flex: 1; overflow-y: auto; }
.contact-row { display: grid; grid-template-columns: 42px 1fr auto; gap: 11px; padding: 14px 16px; border: 0; border-bottom: 1px solid var(--line); background: transparent; width: 100%; text-align: left; cursor: pointer; }
.contact-row:hover { background: #faf8f2; }
.contact-row.active { background: #fff2ed; box-shadow: inset 3px 0 var(--coral); }
.contact-row .avatar { width: 39px; height: 39px; border-radius: 10px; display: grid; place-items: center; background: var(--sea-soft); color: var(--sea); font: 700 14px Georgia, serif; }
.contact-row.active .avatar { background: var(--coral); color: white; }
.contact-name { font-size: 13px; font-weight: 800; line-height: 1.2; }
.contact-role, .contact-meta { color: var(--ink-muted); font-size: 10px; margin-top: 4px; line-height: 1.35; }
.row-score { font: 600 17px Georgia, serif; color: var(--sea); }
.row-score small { display: block; font: 700 8px Inter, sans-serif; letter-spacing: .08em; color: var(--ink-muted); }
.mini-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 7px; }
.mini-tag { padding: 2px 5px; border-radius: 3px; background: #eef2ef; color: var(--ink-muted); font-size: 8px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; }
.mini-tag.daf { background: var(--gold-soft); color: #715714; }
.mini-tag.warm { background: var(--sea-soft); color: var(--sea); }
.load-more { margin: 12px; }

.review-panel { padding: 22px; overflow-y: auto; }
.review-panel.empty { display: grid; place-items: center; }
.empty-state { max-width: 360px; text-align: center; color: var(--ink-muted); }
.empty-monogram { margin: 0 auto 16px; width: 64px; height: 64px; font-size: 32px; box-shadow: 0 10px 30px rgba(241, 91, 69, .22); }
.empty-state h2 { color: var(--ink); font: 500 26px Georgia, serif; margin: 0; }
.empty-state p { font-size: 13px; line-height: 1.55; }
.detail-heading { align-items: flex-start; }
.detail-heading h2 { font: 500 30px Georgia, serif; margin: 3px 0 0; }
.detail-role { margin: 7px 0 0; color: var(--ink-muted); font-size: 13px; }
.button { border-radius: 8px; border: 1px solid transparent; padding: 9px 13px; cursor: pointer; text-decoration: none; font-size: 12px; font-weight: 800; }
.button.secondary { background: transparent; border-color: var(--line-strong); color: inherit; }
.topbar .button.secondary { border-color: #597279; color: white; }
.button.primary { background: var(--coral); color: white; border-color: var(--coral); box-shadow: 0 5px 16px rgba(241, 91, 69, .22); }
.button.primary:hover { background: var(--coral-dark); }
.button:disabled { opacity: .5; cursor: not-allowed; }
.badges { display: flex; gap: 6px; flex-wrap: wrap; margin: 16px 0; }
.badge { padding: 5px 8px; border-radius: 4px; background: #edf1ef; color: var(--ink-muted); font-size: 9px; font-weight: 900; text-transform: uppercase; letter-spacing: .08em; }
.badge.portfolio { background: #e5e9f7; color: #42508b; }
.badge.coinvestor { background: var(--sea-soft); color: var(--sea); }
.badge.private { background: var(--gold-soft); color: #715714; }
.evidence-card { padding: 13px 15px; border: 1px solid var(--line); border-left: 3px solid var(--sea); border-radius: 8px; background: #fbfcf8; }
.enrichment-card { margin-top: 9px; padding: 13px 15px; border: 1px solid var(--line); border-left: 3px solid var(--coral); border-radius: 8px; background: #fffaf6; }
.enrichment-card p { margin: 8px 0 0; font-size: 12px; line-height: 1.45; }
.enrichment-card dl { margin: 8px 0 0; }
.enrichment-card dl div { display: grid; grid-template-columns: 64px 1fr; gap: 8px; padding-top: 6px; font-size: 10px; line-height: 1.45; }
.enrichment-card dt { font-weight: 800; color: var(--ink-muted); }
.enrichment-card dd { margin: 0; max-height: 7.2em; overflow: auto; }
.card-title { display: flex; justify-content: space-between; font-size: 11px; font-weight: 800; }
.card-title strong { color: var(--sea); }
.evidence-card ul { margin: 8px 0 0; padding-left: 17px; color: var(--ink-muted); font-size: 11px; line-height: 1.55; }
.tier-tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 18px 0 8px; }
.tier-tabs button { border: 1px solid var(--line); border-radius: 8px; padding: 10px 7px; background: white; font-size: 10px; font-weight: 800; cursor: pointer; }
.tier-tabs button.active { border-color: var(--coral); background: #fff2ed; color: var(--coral-dark); }
kbd { font: 800 9px Inter, sans-serif; border: 1px solid currentColor; border-radius: 3px; padding: 1px 4px; opacity: .75; }
.tier-tabs kbd { margin-right: 4px; }
.editor-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.editor-field { display: block; }
textarea.input { resize: vertical; line-height: 1.5; }
.draft-body { min-height: 230px; }
.editor-warning { padding: 8px 10px; margin: 9px 0 0; background: #fff1dc; color: #80541e; border-radius: 6px; font-size: 11px; }
.draft-footer { justify-content: space-between; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.draft-action { gap: 10px; }
.draft-action > span { color: var(--ink-muted); font-size: 10px; }

dialog { border: 0; padding: 0; border-radius: 16px; width: min(760px, calc(100vw - 50px)); max-height: 88vh; color: var(--ink); background: var(--panel); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(16, 42, 51, .56); backdrop-filter: blur(2px); }
.settings-shell { padding: 24px; max-height: 88vh; overflow-y: auto; }
.settings-header h2 { font: 500 27px Georgia, serif; margin: 4px 0 0; }
.icon-button { width: 34px; height: 34px; border: 1px solid var(--line); background: white; border-radius: 50%; font-size: 21px; cursor: pointer; }
.settings-note { margin: 16px 0; padding: 11px 13px; background: var(--gold-soft); color: #6c551e; font-size: 11px; line-height: 1.45; border-radius: 7px; }
.template-setting { border-top: 1px solid var(--line); margin-top: 18px; padding-top: 14px; }
.template-setting h3 { font: 500 18px Georgia, serif; margin: 0; }
.settings-footer { justify-content: flex-end; gap: 9px; margin-top: 22px; }

.toast { position: fixed; right: 22px; bottom: 22px; max-width: 360px; padding: 12px 15px; border-radius: 8px; background: var(--ink); color: white; font-size: 12px; opacity: 0; transform: translateY(8px); pointer-events: none; transition: .2s ease; box-shadow: var(--shadow); }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: #922f26; }

@media (max-width: 1280px) {
  .workspace { grid-template-columns: 220px 350px minmax(500px, 1fr); }
  .metric-strip { grid-template-columns: repeat(4, 155px) 1fr; }
}

.login-page { min-width: 0; min-height: 100vh; background: var(--paper); }
.login-layout { min-height: 100vh; display: grid; grid-template-columns: minmax(460px, 1.1fr) minmax(420px, .9fr); }
.login-story { position: relative; overflow: hidden; padding: 46px 58px; background: var(--ink); color: white; display: flex; flex-direction: column; justify-content: space-between; }
.login-story::after { content: ""; position: absolute; width: 540px; height: 540px; right: -220px; bottom: -260px; border: 1px solid rgba(255,255,255,.12); border-radius: 50%; box-shadow: 0 0 0 90px rgba(241,91,69,.06), 0 0 0 180px rgba(255,255,255,.025); }
.login-brand { position: relative; z-index: 1; display: flex; align-items: center; gap: 13px; font-size: 10px; font-weight: 800; letter-spacing: .18em; color: #b8cbc9; }
.login-copy { position: relative; z-index: 1; max-width: 620px; }
.login-copy .eyebrow { color: #e7bdb5; }
.login-copy h1 { margin: 16px 0 20px; font: 500 clamp(46px, 5.4vw, 76px)/.98 Georgia, serif; letter-spacing: -.045em; }
.login-copy > p:last-child { max-width: 540px; color: #c7d6d4; font-size: 16px; line-height: 1.65; }
.login-guardrail { position: relative; z-index: 1; display: flex; gap: 9px; font-size: 12px; }
.login-guardrail strong { color: #ff8a76; text-transform: uppercase; letter-spacing: .11em; }
.login-guardrail span { color: #a9bfbd; }
.login-panel { padding: 40px; display: grid; place-items: center; }
.login-card { width: min(420px, 100%); padding: 42px; background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow); border-radius: 18px; }
.login-card .eyebrow { color: var(--coral-dark); }
.login-card h2 { margin: 9px 0 8px; font: 500 36px Georgia, serif; letter-spacing: -.025em; }
.login-instruction { margin: 0 0 26px; color: var(--ink-muted); font-size: 13px; }
.login-field { display: block; margin-top: 16px; }
.login-field > span { display: block; margin-bottom: 7px; color: var(--ink-muted); font-size: 11px; font-weight: 800; }
.login-field .input { padding: 12px; }
.login-submit { width: 100%; margin-top: 22px; padding: 12px; }
.login-error { margin: 18px 0 0; padding: 10px 12px; border-left: 3px solid var(--coral); background: #fff0eb; color: #8d3024; font-size: 12px; }
.login-footnote { margin: 18px 0 0; text-align: center; color: var(--ink-muted); font-size: 10px; }
@media (max-width: 820px) {
  .login-layout { grid-template-columns: 1fr; }
  .login-story { min-height: 42vh; padding: 30px; }
  .login-copy h1 { font-size: clamp(38px, 10vw, 56px); }
  .login-copy > p:last-child { font-size: 14px; }
  .login-panel { padding: 24px; }
  .login-card { padding: 30px; }
}
