:root {
  --border: #e2e6ed;
  --text: #16202e;
  --muted: #67758a;
  --navy: #0a2a52;
  --accent: #0b63c5;
  --accent-hover: #084d9a;
  --danger: #b3302f;
  --bg: #f4f6fa;
  --surface: #ffffff;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 1px rgba(16, 24, 40, 0.04);
  --shadow-md: 0 10px 24px rgba(16, 24, 40, 0.08), 0 2px 6px rgba(16, 24, 40, 0.04);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
}

h1, h2, h3 { color: var(--navy); line-height: 1.25; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.topbar-nav {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.topbar-nav .brand {
  font-weight: 700;
  color: var(--navy);
  text-decoration: none;
  margin-right: 1rem;
  letter-spacing: -0.01em;
}

.topbar-nav a {
  text-decoration: none;
  color: var(--muted);
  padding: 0.4rem 0.7rem;
  border-radius: var(--radius-sm);
  font-size: 0.925rem;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.topbar-nav a:hover { color: var(--text); background: var(--bg); text-decoration: none; }
.topbar-nav a.active { color: var(--accent); background: #e8f1fc; font-weight: 600; }
.topbar-nav .brand:hover { background: none; }

.topbar-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.link-button {
  border: none;
  background: none;
  color: var(--accent);
  cursor: pointer;
  padding: 0;
  font: inherit;
}
.link-button:hover { color: var(--accent-hover); text-decoration: underline; }
/* button[type="submit"] below outranks a plain .link-button on
   specificity, so a <button type="submit" class="link-button"> (every
   inline delete action in the app) would otherwise render as a solid
   button instead of the plain text link it's meant to be. */
button[type="submit"].link-button {
  background: none;
  color: var(--accent);
  padding: 0;
}
button[type="submit"].link-button:hover { background: none; color: var(--accent-hover); }

.content {
  max-width: 1080px;
  margin: 0 auto;
  padding: 2.25rem 1.5rem 4rem;
}

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

.error {
  color: var(--danger);
  background: #fbeaea;
  border: 1px solid #e3b8b7;
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.85rem;
}

.success {
  color: #1e6b3a;
  background: #e8f5e9;
  border: 1px solid #a8d5b5;
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.85rem;
}

.auth-card {
  max-width: 340px;
  margin: 4rem auto;
  padding: 2rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

form label {
  display: block;
  margin-bottom: 0.75rem;
  font-size: 0.9rem;
  color: var(--muted);
}

form input, form select, form textarea {
  display: block;
  width: 100%;
  margin-top: 0.3rem;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font: inherit;
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
form input:hover, form select:hover, form textarea:hover { border-color: #c3cad6; }
form input:focus, form select:focus, form textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(11, 99, 197, 0.15);
}

button[type="submit"], .button {
  display: inline-block;
  padding: 0.55rem 1.1rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font: inherit;
  font-weight: 500;
  text-decoration: none;
  transition: background-color 0.15s ease, box-shadow 0.15s ease, transform 0.05s ease;
}
button[type="submit"]:hover, .button:hover { background: var(--accent-hover); text-decoration: none; box-shadow: var(--shadow-sm); }
button[type="submit"]:active, .button:active { transform: translateY(1px); }

.button.secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}
.button.secondary:hover { background: var(--bg); border-color: #c3cad6; }

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
th, td {
  text-align: left;
  padding: 0.65rem 0.9rem;
  border-bottom: 1px solid var(--border);
}
thead th {
  background: var(--bg);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
tbody tr:last-child td, tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--bg); }

.interface-member-row { background: var(--bg); }
.interface-member-name { padding-left: 1.75rem; color: var(--muted); }

.notes-preview {
  max-width: 360px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--muted);
  font-size: 0.9rem;
}
.priority-form input {
  width: 3.5rem;
  padding: 0.3rem 0.4rem;
  text-align: center;
}

.tabs {
  display: flex;
  gap: 0.25rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.5rem;
}
.tabs a {
  padding: 0.6rem 1rem;
  text-decoration: none;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  transition: color 0.15s ease;
}
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.active {
  color: var(--text);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

.badge {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  background: #e7ecf3;
  color: var(--text);
  margin-left: 0.35rem;
}

/* Company relationship status, color-coded by pipeline stage rather than
   filtered into separate Customer/Lead lists -- see [status] values in
   web/company_status.py. */
.status-badge {
  display: inline-block;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  margin-left: 0.35rem;
  background: #e7ecf3;
  color: #334155;
}
.status-badge[data-status="Prospect"],
.status-badge[data-status="Researching"] { background: #e2e8f0; color: #475569; }
.status-badge[data-status="Contacted"],
.status-badge[data-status="Discovery"] { background: #dbeafe; color: #1d4ed8; }
.status-badge[data-status="Proposal Sent"] { background: #fef3c7; color: #b45309; }
.status-badge[data-status="Active Client"] { background: #dcfce7; color: #15803d; }
.status-badge[data-status="Past Client"] { background: #e2e8f0; color: #64748b; }
.status-badge[data-status="Partner"] { background: #ede9fe; color: #6d28d9; }
.status-badge[data-status="Do Not Pursue"] { background: #fee2e2; color: #b91c1c; }

.role-badge {
  display: inline-block;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  margin-right: 0.35rem;
  background: #e7ecf3;
  color: #334155;
}
.role-badge[data-role="Billing Contact"] { background: #fef3c7; color: #b45309; }
.role-badge[data-role="Admin"] { background: #ede9fe; color: #6d28d9; }
.role-badge[data-role="Technical POC"] { background: #dbeafe; color: #1d4ed8; }

fieldset {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
}
.checkbox-label {
  display: block;
  font-weight: normal;
  margin-bottom: 0.4rem;
}
form .checkbox-label input {
  display: inline-block;
  width: auto;
  margin-top: 0;
  margin-right: 0.4rem;
}

.kpi-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin: 1.5rem 0;
}
.kpi-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.1rem 1.25rem;
  color: inherit;
  text-decoration: none;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.15s ease, transform 0.15s ease, border-color 0.15s ease;
}
a.kpi-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
  text-decoration: none;
}
.kpi-card.active { border-color: var(--accent); background: #e8f1fc; }
.kpi-value { font-size: 1.85rem; font-weight: 700; color: var(--navy); }
.kpi-label { color: var(--muted); font-size: 0.85rem; margin-top: 0.15rem; }

.activity-feed {
  list-style: none;
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.activity-feed li {
  padding: 0.65rem 0.9rem;
  border-bottom: 1px solid var(--border);
}
.activity-feed li:last-child { border-bottom: none; }
.activity-icon { margin-right: 0.35rem; }

.list-header, .tab-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.filters {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}
.filters input[type="search"] {
  width: auto;
  min-width: 220px;
}
.filters label { display: flex; align-items: center; gap: 0.35rem; margin: 0; }

.company-header h1 { margin-bottom: 0.25rem; }
.company-actions { margin: 0.75rem 0 1.5rem; display: flex; gap: 0.5rem; align-items: center; }
.company-actions select { width: auto; margin: 0; }
.company-actions form { margin: 0; }

details summary { cursor: pointer; }
details form {
  margin-top: 0.5rem;
  padding: 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
details form textarea { min-height: 4.5rem; }

/* Work entries: a metadata line (when/who/how much) with the notes as
   their own block underneath, both in the read view and the edit form
   that expands beneath each entry. */
.entry-list { display: flex; flex-direction: column; gap: 0.65rem; }
.entry-card {
  padding: 0.85rem 1.1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}
.entry-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 1.25rem;
  color: var(--muted);
  font-size: 0.9rem;
}
.entry-notes { margin-top: 0.4rem; white-space: pre-wrap; }
.entry-footer { margin-top: 0.5rem; display: flex; flex-wrap: wrap; gap: 0.5rem 1rem; align-items: baseline; }
.entry-footer form { margin: 0; }
/* The expanded edit form needs the full card width to lay out its
   fields -- forcing details onto its own flex row (rather than letting
   it grow in place) keeps the Delete button from being shoved out to
   the far right once it expands. */
.entry-footer details { flex: 1 1 100%; }

/* One card per synced email message within an Interaction's entry-card,
   so a multi-message thread (send/receive/send) reads as a conversation
   instead of one run-on blob of text. */
.email-thread { display: flex; flex-direction: column; gap: 0.6rem; margin-top: 0.5rem; }
.email-message {
  padding: 0.65rem 0.85rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.email-message-sender {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--navy);
  margin-bottom: 0.3rem;
}
.email-message-body { white-space: pre-wrap; font-size: 0.9rem; }

.entry-meta-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.5rem;
  align-items: flex-end;
}
.entry-meta-fields label { width: auto; min-width: 140px; margin-bottom: 0; }
.entry-meta-fields input, .entry-meta-fields select { width: auto; min-width: 140px; }
details form button[type="submit"] { align-self: flex-start; }
.entry-notes-field textarea { min-height: 4.5rem; }

#topology {
  height: 70vh;
  min-height: 420px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
}
.diagram-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.25rem;
  margin: 0.5rem 0 0.75rem;
  color: var(--muted);
  font-size: 0.85rem;
}
.legend-swatch {
  display: inline-block;
  width: 1.5rem;
  height: 0;
  margin-right: 0.35rem;
  vertical-align: middle;
  border-top-width: 2px;
  border-top-style: solid;
}
.legend-lldp { border-color: #2b6cb0; }
.legend-ospf { border-color: #2f855a; border-top-style: dashed; }
.legend-mac { border-color: #718096; border-top-style: dotted; }
.legend-label { border-color: #c05621; border-top-style: dashed; }
.legend-pending {
  border-top: none;
  background: #ffffff;
  border: 1px dashed #2b6cb0;
  height: 0.8rem;
  border-radius: 2px;
}
.legend-ancillary {
  border-top: none;
  background: #faf5ff;
  border: 1px dashed #805ad5;
  height: 0.8rem;
  border-radius: 2px;
}
.diagram-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
}
.diagram-layers {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 1.25rem;
  margin: 0 0 0.75rem;
  font-size: 0.85rem;
}
.diagram-layers-label {
  color: var(--muted);
  font-weight: 600;
}
