/* ─── Variables ─────────────────────────────────────────────────────────────── */
:root {
  --bg:             #0A0A0A;
  --surface-1:      #141414;
  --surface-2:      #1C1C1C;
  --border:         #2A2A2A;
  --text-primary:   #F0F0F0;
  --text-secondary: #888888;
  --accent:         #0066FF;
  --green:          #00CC66;
  --amber:          #FF9900;
  --red:            #FF3333;
  --font-mono:      'JetBrains Mono', monospace;
  --font-sans:      -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ─── Reset ─────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { background: var(--bg); color: var(--text-primary); font-family: var(--font-sans); font-size: 14px; line-height: 1.5; }
a { color: inherit; text-decoration: none; }
button { cursor: pointer; border: none; background: none; font: inherit; color: inherit; }
input, select, textarea { font: inherit; color: inherit; }

/* ─── Nav ───────────────────────────────────────────────────────────────────── */
.nav {
  position: fixed; top: 0; left: 0; right: 0; height: 48px; z-index: 100;
  background: var(--bg); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px;
}
.nav-brand { font-family: var(--font-mono); font-size: 13px; font-weight: 500; color: var(--accent); letter-spacing: 0.05em; }
.nav-links { display: flex; align-items: center; gap: 24px; }
.nav-link { font-family: var(--font-mono); font-size: 11px; font-weight: 500; color: var(--text-secondary); letter-spacing: 0.1em; text-transform: uppercase; transition: color 150ms ease; }
.nav-link:hover { color: var(--text-primary); }
.nav-link.active { color: var(--text-primary); border-bottom: 1px solid var(--accent); padding-bottom: 2px; }
.nav-logout { font-family: var(--font-mono); font-size: 11px; color: var(--text-secondary); letter-spacing: 0.08em; transition: color 150ms ease; }
.nav-logout:hover { color: var(--text-primary); }

/* ─── Page ──────────────────────────────────────────────────────────────────── */
.page { padding-top: 48px; min-height: 100vh; }
.page-content { padding: 32px 24px; max-width: 1200px; margin: 0 auto; }
.loading { color: var(--text-secondary); font-family: var(--font-mono); font-size: 12px; padding: 24px 0; }

/* ─── Login ─────────────────────────────────────────────────────────────────── */
.login-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-title { font-family: var(--font-mono); font-size: 18px; font-weight: 500; letter-spacing: 0.1em; margin-bottom: 32px; }
.login-form { display: flex; gap: 8px; }
.login-form input {
  background: var(--surface-1); border: 1px solid var(--border);
  color: var(--text-primary); font-family: var(--font-mono); font-size: 13px;
  padding: 10px 16px; outline: none; width: 240px;
}
.login-form input:focus { border-color: var(--accent); }
.login-form button { background: var(--accent); color: #fff; font-family: var(--font-mono); font-size: 11px; font-weight: 500; letter-spacing: 0.1em; padding: 10px 20px; }
.login-form button:hover { background: #0052cc; }
.login-error { color: var(--red); font-family: var(--font-mono); font-size: 12px; margin-top: 12px; min-height: 20px; }

/* ─── Tags ──────────────────────────────────────────────────────────────────── */
.tag { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; padding: 2px 6px; border-radius: 2px; font-weight: 500; white-space: nowrap; flex-shrink: 0; }
.tag-customer    { background: var(--accent); color: #fff; }
.tag-vc          { background: var(--green); color: #000; }
.tag-stakeholder { background: var(--amber); color: #000; }

/* ─── Section labels ────────────────────────────────────────────────────────── */
.section-label { font-family: var(--font-mono); font-size: 11px; font-weight: 500; color: var(--text-secondary); letter-spacing: 0.1em; text-transform: uppercase; margin-bottom: 12px; }
.section-none  { color: var(--text-secondary); font-family: var(--font-mono); font-size: 12px; padding: 8px 0; }

/* ─── Stat cards ────────────────────────────────────────────────────────────── */
.stat-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 40px; }
.stat-card { background: var(--surface-1); border: 1px solid var(--border); padding: 20px; }
.stat-card-label { font-family: var(--font-mono); font-size: 10px; font-weight: 500; color: var(--text-secondary); letter-spacing: 0.1em; text-transform: uppercase; margin-bottom: 12px; }
.stat-card-value { font-family: var(--font-mono); font-size: 28px; font-weight: 500; color: var(--text-primary); line-height: 1; margin-bottom: 8px; }
.stat-card-value.danger { color: var(--red); }
.stat-card-sub { font-family: var(--font-mono); font-size: 11px; color: var(--text-secondary); }

/* ─── Action sections ───────────────────────────────────────────────────────── */
.section { margin-bottom: 40px; }
.action-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-bottom: 1px solid var(--border); cursor: pointer; transition: background 150ms ease; }
.action-row:first-of-type { border-top: 1px solid var(--border); }
.action-row:hover { background: var(--surface-2); }
.action-name    { font-size: 14px; min-width: 180px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.action-company { font-size: 13px; color: var(--text-secondary); min-width: 160px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.action-meta    { font-family: var(--font-mono); font-size: 11px; color: var(--text-secondary); }
.action-arrow   { margin-left: auto; color: var(--text-secondary); font-size: 12px; }
.section-more   { font-family: var(--font-mono); font-size: 11px; color: var(--text-secondary); padding: 8px 12px; cursor: pointer; }
.section-more:hover { color: var(--accent); }

/* ─── Filter bar ────────────────────────────────────────────────────────────── */
.filter-bar { position: sticky; top: 48px; z-index: 90; background: var(--bg); border-bottom: 1px solid var(--border); padding: 12px 24px; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.filter-group { display: flex; gap: 4px; }
.filter-btn { font-family: var(--font-mono); font-size: 11px; font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase; padding: 4px 10px; border: 1px solid var(--border); color: var(--text-secondary); background: none; transition: all 150ms ease; }
.filter-btn:hover { border-color: var(--text-secondary); color: var(--text-primary); }
.filter-btn.active { border-color: var(--accent); color: var(--accent); background: rgba(0,102,255,0.08); }
.filter-search { flex: 1; min-width: 160px; max-width: 240px; background: var(--surface-1); border: 1px solid var(--border); color: var(--text-primary); font-size: 13px; padding: 4px 10px; outline: none; }
.filter-search:focus { border-color: var(--accent); }
.filter-sort { font-family: var(--font-mono); font-size: 11px; color: var(--text-secondary); display: flex; align-items: center; gap: 6px; margin-left: auto; }
.filter-sort select { background: var(--surface-1); border: 1px solid var(--border); color: var(--text-primary); font-family: var(--font-mono); font-size: 11px; padding: 4px 8px; outline: none; cursor: pointer; }

/* ─── Contacts table ────────────────────────────────────────────────────────── */
.table-wrap { padding: 0 24px 48px; }
.contacts-table { width: 100%; border-collapse: collapse; }
.contacts-table th { font-family: var(--font-mono); font-size: 10px; font-weight: 500; color: var(--text-secondary); letter-spacing: 0.1em; text-transform: uppercase; padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
.contacts-table th.right { text-align: right; }
.contacts-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 13px; vertical-align: middle; }
.contacts-table td.dim  { color: var(--text-secondary); }
.contacts-table td.mono { font-family: var(--font-mono); font-size: 12px; }
.contacts-table td.right { text-align: right; font-family: var(--font-mono); font-size: 12px; }
.contacts-table tbody tr { cursor: pointer; transition: background 150ms ease; }
.contacts-table tbody tr:hover { background: var(--surface-2); }
.empty-cell { color: var(--text-secondary); opacity: 0.5; }

/* ─── Priority dot ──────────────────────────────────────────────────────────── */
.priority { display: flex; align-items: center; gap: 6px; font-family: var(--font-mono); font-size: 11px; }
.dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.dot-high   { background: var(--red); }
.dot-medium { background: var(--amber); }
.dot-low    { background: var(--text-secondary); }

/* ─── Mobile cards ──────────────────────────────────────────────────────────── */
.contact-card { background: var(--surface-1); border: 1px solid var(--border); padding: 14px 16px; margin-bottom: 8px; cursor: pointer; transition: background 150ms ease; }
.contact-card:hover { background: var(--surface-2); }
.contact-card-top  { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.contact-card-name { font-size: 14px; font-weight: 500; }
.contact-card-meta { font-size: 12px; color: var(--text-secondary); }

/* ─── Panel overlay ─────────────────────────────────────────────────────────── */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 200; opacity: 0; pointer-events: none; transition: opacity 200ms ease; }
.overlay.visible { opacity: 1; pointer-events: all; }

/* ─── Panel ─────────────────────────────────────────────────────────────────── */
.panel { position: fixed; top: 0; right: 0; bottom: 0; width: 480px; z-index: 201; background: var(--surface-1); border-left: 1px solid var(--border); overflow-y: auto; transform: translateX(100%); transition: transform 200ms ease; }
.panel.open { transform: translateX(0); }
.panel-header { display: flex; align-items: center; justify-content: space-between; padding: 14px 20px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface-1); z-index: 10; }
.panel-close { font-family: var(--font-mono); font-size: 11px; font-weight: 500; color: var(--text-secondary); letter-spacing: 0.08em; text-transform: uppercase; transition: color 150ms ease; }
.panel-close:hover { color: var(--text-primary); }
.panel-body { padding: 20px; }
.panel-name { font-size: 20px; font-weight: 500; margin: 8px 0 4px; }
.panel-meta { font-family: var(--font-mono); font-size: 12px; color: var(--text-secondary); margin-bottom: 20px; }
.panel-divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }

/* ─── Panel fields ──────────────────────────────────────────────────────────── */
.field-row { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; position: relative; }
.field-label { font-family: var(--font-mono); font-size: 10px; font-weight: 500; color: var(--text-secondary); letter-spacing: 0.1em; text-transform: uppercase; width: 80px; flex-shrink: 0; }
.field-input { flex: 1; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-primary); font-size: 13px; padding: 5px 8px; outline: none; transition: border-color 150ms ease; }
.field-input:focus { border-color: var(--accent); }
.field-select { flex: 1; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-primary); font-family: var(--font-mono); font-size: 12px; padding: 5px 8px; outline: none; cursor: pointer; }
.field-select:focus { border-color: var(--accent); }
.field-saved { font-family: var(--font-mono); font-size: 10px; color: var(--green); opacity: 0; transition: opacity 300ms ease; }
.field-saved.error { color: var(--red); }
.field-saved.show  { opacity: 1; }

/* ─── Context ───────────────────────────────────────────────────────────────── */
.context-view { font-size: 13px; color: var(--text-secondary); line-height: 1.6; cursor: pointer; padding: 4px 0; border-bottom: 1px solid transparent; transition: border-color 150ms ease; white-space: pre-wrap; }
.context-view:hover { border-bottom-color: var(--border); }
.context-view.empty::after { content: 'click to add context'; opacity: 0.5; }
.context-textarea { width: 100%; background: var(--surface-2); border: 1px solid var(--accent); color: var(--text-primary); font-size: 13px; line-height: 1.6; padding: 8px; outline: none; resize: vertical; min-height: 80px; }
.context-saved { font-family: var(--font-mono); font-size: 10px; color: var(--green); opacity: 0; transition: opacity 300ms ease; display: block; margin-top: 4px; }
.context-saved.show { opacity: 1; }

/* ─── Notes ─────────────────────────────────────────────────────────────────── */
.notes-list { margin: 8px 0 12px; }
.note-item { font-size: 13px; line-height: 1.6; color: var(--text-secondary); padding: 6px 0; border-bottom: 1px solid var(--border); white-space: pre-wrap; }
.note-add { width: 100%; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-primary); font-size: 13px; line-height: 1.5; padding: 8px; outline: none; resize: vertical; min-height: 60px; transition: border-color 150ms ease; }
.note-add:focus { border-color: var(--accent); }
.note-hint { font-family: var(--font-mono); font-size: 10px; color: var(--text-secondary); text-align: right; margin-top: 4px; }

/* ─── History ───────────────────────────────────────────────────────────────── */
.history-list { display: flex; flex-direction: column; gap: 12px; margin-top: 8px; }
.history-entry-header { display: flex; align-items: center; gap: 8px; margin-bottom: 2px; }
.history-date    { font-family: var(--font-mono); font-size: 11px; color: var(--text-secondary); flex-shrink: 0; }
.history-summary { font-size: 13px; }
.history-preview { font-size: 12px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.history-preview.expanded { white-space: pre-wrap; overflow: visible; text-overflow: initial; }
.history-expand  { font-family: var(--font-mono); font-size: 10px; color: var(--accent); cursor: pointer; margin-top: 2px; display: inline-block; }
.history-expand:hover { opacity: 0.8; }

/* ─── Badges ────────────────────────────────────────────────────────────────── */
.badge { font-family: var(--font-mono); font-size: 9px; font-weight: 500; letter-spacing: 0.08em; padding: 2px 5px; border-radius: 2px; flex-shrink: 0; }
.badge-email-in  { background: rgba(0,102,255,0.25); color: #80aaff; }
.badge-email-out { background: rgba(0,60,180,0.25);  color: #6699ee; }
.badge-meeting   { background: rgba(0,204,102,0.2);  color: var(--green); }
.badge-note      { background: var(--surface-2); color: var(--text-secondary); }

/* ─── Mobile ────────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .stat-cards { grid-template-columns: repeat(2, 1fr); }
  .panel { width: 100%; }
  .contacts-table { display: none; }
  .action-name { min-width: 120px; }
  .action-company { display: none; }
}
@media (min-width: 769px) {
  .contacts-cards { display: none; }
}
