* {
  box-sizing: border-box;
  margin: 0;
  padding: 0
}

:root {
  --deep: #051e2c;
  --mid: #0a3d52;
  --teal: #1a7a8a;
  --teal-light: #5bbcd1;
  --pale: #e0f4f8;
  --sand: #f5f0e8;
  --ink: #0d1f2d;
  --muted: #4a6572;
  --faint: #8aa5b0;
  --accent: #c8543a;
  --accent-light: #f0997b;
  --green: #2d8a5e;
  --amber: #c17f24;
  --border: rgba(26, 122, 138, 0.15);
  --border-strong: rgba(26, 122, 138, 0.3);
  --surface: #ffffff;
  --surface2: #f7fbfc;
  --surface3: #eef6f8;

  /* Unified focus ring & chevron tokens used by every <select> in the app.
     Chevron is a small SVG so we get a consistent modern arrow on every
     browser, instead of mixing native chevrons with custom ones. */
  --focus-ring: 0 0 0 3px rgba(26, 122, 138, 0.15);
  --chevron-muted: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2212%22%20height%3D%2212%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22%234a6572%22%20stroke-width%3D%222.25%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpolyline%20points%3D%226%209%2012%2015%2018%209%22%3E%3C%2Fpolyline%3E%3C%2Fsvg%3E");
  --chevron-faint: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2212%22%20height%3D%2212%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22%238aa5b0%22%20stroke-width%3D%222.25%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpolyline%20points%3D%226%209%2012%2015%2018%209%22%3E%3C%2Fpolyline%3E%3C%2Fsvg%3E");
}

/* Modern baseline for every native <select> — kills the OS dropdown arrow
   and gives every dropdown the same chevron, padding scale and focus ring.
   Specific variants below (status pills, toolbar filters, edit forms)
   layer their own colour/size on top. */
select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  font-family: inherit;
  color: var(--ink);
  background-color: var(--surface);
  background-image: var(--chevron-muted);
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 12px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 7px 30px 7px 11px;
  font-size: 13px;
  line-height: 1.3;
  cursor: pointer;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

select:hover {
  border-color: var(--teal);
}

select:focus-visible {
  border-color: var(--teal);
  box-shadow: var(--focus-ring);
}

select:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

html,
body {
  height: 100%;
  font-family: 'DM Sans', sans-serif;
  color: var(--ink);
  background: var(--surface2)
}

.shell {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: 100vh
}

/* SIDEBAR */
.sidebar {
  background: var(--deep);
  padding: 0;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh
}

.sidebar-logo {
  padding: 1.75rem 1.5rem 1.25rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06)
}

.logo-mark {
  font-family: 'Playfair Display', serif;
  font-size: 17px;
  color: #fff;
  letter-spacing: -0.3px;
  line-height: 1.2
}

.logo-mark em {
  color: var(--teal-light);
  font-style: italic
}

.logo-sub {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.35);
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-top: 4px
}

.nav {
  padding: 1rem 0;
  flex: 1;
  overflow-y: auto
}

.nav-section {
  padding: 0.5rem 1.5rem 0.25rem;
  font-size: 9px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.25);
  margin-top: 0.5rem
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 1.5rem;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.55);
  cursor: pointer;
  transition: all 0.15s;
  border-left: 2px solid transparent
}

.nav-item:hover {
  color: rgba(255, 255, 255, 0.85);
  background: rgba(255, 255, 255, 0.04)
}

.nav-item.active {
  color: #fff;
  border-left-color: var(--teal-light);
  background: rgba(91, 188, 209, 0.08)
}

.nav-item svg {
  opacity: 0.6;
  flex-shrink: 0
}

.nav-item.active svg {
  opacity: 1
}

.nav-badge {
  margin-left: auto;
  font-size: 10px;
  background: var(--accent);
  color: #fff;
  padding: 1px 6px;
  border-radius: 10px
}

.sidebar-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid rgba(255, 255, 255, 0.06)
}

.sidebar-footer-text {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.25);
  line-height: 1.5
}

/* MAIN */
.main {
  overflow-y: auto
}

.topbar {
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 1rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10
}

.page-title {
  font-size: 15px;
  font-weight: 500;
  color: var(--ink)
}

.page-sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 1px
}

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

.btn {
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  border: 1px solid var(--border-strong);
  background: transparent;
  color: var(--teal);
  font-family: 'DM Sans', sans-serif;
  transition: all 0.15s;
  text-decoration: none
}

.btn:hover {
  background: var(--surface3)
}

.btn-primary {
  background: var(--teal);
  color: #fff;
  border-color: var(--teal)
}

.btn-primary:hover {
  background: var(--mid)
}

.btn-sm {
  padding: 4px 10px;
  font-size: 11px
}

.btn-danger {
  color: var(--accent);
  border-color: rgba(200, 84, 58, 0.3)
}

.btn-danger:hover {
  background: #fdf1ee
}

.content {
  padding: 1.75rem 2rem
}

/* SECTIONS */
.section {
  display: none
}

.section.active {
  display: block
}

/* METRICS ROW */
.metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 1.75rem
}

.metric {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
  box-shadow: 0 4px 20px rgba(5, 30, 44, 0.03);
  transition: box-shadow 0.2s, transform 0.2s;
}
.metric:hover {
  box-shadow: 0 8px 30px rgba(5, 30, 44, 0.06);
  transform: translateY(-2px);
}

.metric-label {
  font-size: 11px;
  color: var(--faint);
  letter-spacing: 0.3px;
  margin-bottom: 6px
}

.metric-value {
  font-family: 'Playfair Display', serif;
  font-size: 26px;
  font-weight: 600;
  color: var(--mid)
}

.metric-sub {
  font-size: 11px;
  color: var(--muted);
  margin-top: 3px
}

.metric.urgent .metric-value {
  color: var(--accent)
}

/* ALERT */
.alert {
  background: linear-gradient(135deg, #fdf1ee, #fae8e3);
  border: 1px solid rgba(200, 84, 58, 0.2);
  border-radius: 10px;
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
  display: flex;
  gap: 12px;
  align-items: flex-start
}

.alert-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
  margin-top: 4px
}

.alert-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--accent)
}

.alert-text {
  font-size: 12px;
  color: #7a3a28;
  line-height: 1.5;
  margin-top: 2px
}

/* ACTION LIST */
.actions-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 1.75rem
}

.actions-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: 0 4px 20px rgba(5, 30, 44, 0.03);
}

.actions-title {
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--faint);
  margin-bottom: 12px
}

.action-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer
}

.action-item:last-child {
  border-bottom: none;
  padding-bottom: 0
}

.action-item:first-of-type {
  padding-top: 0
}

.action-check {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  border: 1.5px solid var(--border-strong);
  flex-shrink: 0;
  margin-top: 1px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  cursor: pointer
}

.action-check.done {
  background: var(--green);
  border-color: var(--green)
}

.action-text {
  font-size: 13px;
  color: var(--ink);
  line-height: 1.4
}

.action-text.done {
  text-decoration: line-through;
  color: var(--faint)
}

.action-who {
  font-size: 11px;
  color: var(--faint);
  margin-top: 2px
}

.action-text-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.action-status-wrap {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  margin-top: 1px;
}

.action-status-pill {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid currentColor;
  cursor: pointer;
  white-space: nowrap;
  opacity: 0.65;
  transition: opacity 0.15s, background 0.15s;
  user-select: none;
}

.action-status-pill:hover {
  opacity: 1;
}

.action-status-pill.status-this-week {
  color: var(--accent);
}

.action-status-pill.status-next-week {
  color: var(--amber);
}

.action-status-pill.status-upcoming {
  color: var(--teal);
}

.action-status-pill.status-archive {
  color: var(--faint);
  opacity: 0.5;
}

/* Pill-shaped status select — inherits base reset, then adds the
   compact uppercase pill treatment. Chevron tints to currentColor via
   a per-status background-image override so the arrow matches the
   pill's accent colour. */
.action-status-select {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  padding: 3px 22px 3px 10px;
  border-radius: 999px;
  border: 1px solid currentColor;
  background-color: var(--surface);
  background-position: right 6px center;
  background-size: 10px;
  line-height: 1.3;
}

.action-status-select:hover { border-color: currentColor; filter: brightness(0.95); }
.action-status-select:focus-visible { border-color: currentColor; box-shadow: 0 0 0 3px rgba(26, 122, 138, 0.12); }

.action-status-select.status-this-week {
  color: var(--accent);
  background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2210%22%20height%3D%2210%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22%23c8543a%22%20stroke-width%3D%222.5%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpolyline%20points%3D%226%209%2012%2015%2018%209%22%3E%3C%2Fpolyline%3E%3C%2Fsvg%3E");
}
.action-status-select.status-next-week {
  color: var(--amber);
  background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2210%22%20height%3D%2210%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22%23c17f24%22%20stroke-width%3D%222.5%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpolyline%20points%3D%226%209%2012%2015%2018%209%22%3E%3C%2Fpolyline%3E%3C%2Fsvg%3E");
}
.action-status-select.status-upcoming {
  color: var(--teal);
  background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2210%22%20height%3D%2210%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22%231a7a8a%22%20stroke-width%3D%222.5%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpolyline%20points%3D%226%209%2012%2015%2018%209%22%3E%3C%2Fpolyline%3E%3C%2Fsvg%3E");
}
.action-status-select.status-archive {
  color: var(--faint);
  background-image: var(--chevron-faint);
}

.actions-empty {
  font-size: 12px;
  color: var(--faint);
  font-style: italic;
  padding: 4px 0;
}

.actions-archive {
  background: var(--surface2);
  border-style: dashed;
}

.actions-archive-header {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}

.actions-archive-chevron {
  font-size: 9px;
  color: var(--faint);
  transition: transform 0.15s;
  display: inline-block;
}

.actions-archive.expanded .actions-archive-chevron {
  transform: rotate(90deg);
}

.actions-archive-body {
  display: none;
  margin-top: 12px;
}

.actions-archive.expanded .actions-archive-body {
  display: block;
}

.priority-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 5px
}

.p-high {
  background: var(--accent)
}

.p-med {
  background: var(--amber)
}

.p-low {
  background: var(--teal)
}

/* SITES */
.sites-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px
}

.site-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(5, 30, 44, 0.03);
  transition: all 0.2s
}

.site-card:hover {
  border-color: var(--teal);
  box-shadow: 0 8px 30px rgba(26, 122, 138, 0.08);
  transform: translateY(-2px)
}

.site-card.urgent {
  border-color: rgba(200, 84, 58, 0.3);
  background: linear-gradient(135deg, #fff, #fdf8f7)
}

.site-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 10px
}

.site-name {
  font-family: 'Playfair Display', serif;
  font-size: 17px;
  font-weight: 600;
  color: var(--mid)
}

.site-region {
  font-size: 11px;
  color: var(--faint);
  margin-top: 2px
}

.status-pill {
  font-size: 10px;
  padding: 3px 9px;
  border-radius: 20px;
  font-weight: 500;
  white-space: nowrap
}

/* Shown briefly when a site's status pill is clicked for editing —
   same pill dimensions, plus the modern chevron and an active teal ring. */
.site-status-select {
  font-size: 11px;
  font-weight: 500;
  padding: 3px 22px 3px 10px;
  border-radius: 20px;
  border: 1px solid var(--teal);
  background-position: right 6px center;
  background-size: 10px;
}

.s-urgent {
  background: #faeae5;
  color: #993c1d
}

.s-discussion {
  background: #e3f2f8;
  color: #185fa5
}

.s-monitoring {
  background: #e8f5e9;
  color: #2d6a4f
}

.s-idea {
  background: #f1efe8;
  color: #5f5e5a
}

.site-desc {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.55;
  margin-bottom: 12px
}

.site-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding-top: 10px;
  border-top: 1px solid var(--border)
}

.site-meta-item {
  font-size: 11px
}

.site-meta-label {
  color: var(--faint)
}

.site-meta-value {
  color: var(--ink);
  font-weight: 500;
  margin-top: 1px
}

.site-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 10px;
  align-items: center
}

.tag {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--surface3);
  color: var(--muted);
  border: 1px solid var(--border)
}

.tag-remove {
  display: inline-block;
  margin-left: 4px;
  cursor: pointer;
  opacity: 0.4;
  font-size: 11px;
  font-weight: 600;
  vertical-align: middle
}

.tag-remove:hover {
  opacity: 1
}

.tag-add-btn {
  font-size: 13px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px dashed var(--border-strong);
  background: transparent;
  color: var(--faint);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s
}

.tag-add-btn:hover {
  border-color: var(--teal);
  color: var(--teal)
}

.tag-add-input {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 10px;
  border: 1px solid var(--teal);
  background: var(--surface);
  color: var(--ink);
  outline: none;
  width: 100px;
  font-family: inherit
}

.meta-remove {
  position: absolute;
  top: 2px;
  right: 2px;
  font-size: 10px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--faint);
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center
}

.site-meta-item {
  position: relative
}

.site-meta-item:hover .meta-remove {
  display: flex
}

.meta-remove:hover {
  color: var(--accent)
}

.meta-add-btn {
  font-size: 11px;
  padding: 6px 12px;
  border: 1px dashed var(--border-strong);
  border-radius: 6px;
  background: transparent;
  color: var(--faint);
  cursor: pointer;
  transition: all 0.15s;
  width: 100%
}

.meta-add-btn:hover {
  border-color: var(--teal);
  color: var(--teal)
}

.framing-item {
  position: relative
}

.framing-remove {
  position: absolute;
  top: 50%;
  right: 0;
  transform: translateY(-50%);
  font-size: 10px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--faint);
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center
}

.framing-item:hover .framing-remove {
  display: flex
}

.framing-remove:hover {
  color: var(--accent)
}

.framing-add-btn {
  font-size: 11px;
  padding: 6px 12px;
  border: 1px dashed var(--border-strong);
  border-radius: 6px;
  background: transparent;
  color: var(--faint);
  cursor: pointer;
  transition: all 0.15s;
  width: 100%;
  margin-top: 8px
}

.framing-add-btn:hover {
  border-color: var(--teal);
  color: var(--teal)
}

.meta-add-form {
  display: flex;
  gap: 6px;
  align-items: flex-end;
  grid-column: 1 / -1
}

.meta-add-form input {
  font-family: inherit;
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 4px;
  border: 1px solid var(--teal);
  background: var(--surface);
  color: var(--ink);
  outline: none;
  flex: 1
}

/* CONTACTS — modern filter bar.
   The toolbar container styling (background, border, radius, padding)
   is applied inline in the JS, so this rule only handles flex layout.
   Inner-control rules below override the generic .editable-input look
   with a softer toolbar aesthetic. */
.contacts-filters {
  display: flex;
  gap: 8px;
  margin-bottom: 1rem;
  flex-wrap: nowrap;
  align-items: center;
  overflow: visible;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
}

/* All form controls inside the filter bar share one quiet visual language:
   very soft border at rest, no harsh teal stroke, only the chevron and
   focus ring carry colour. Crucially, width: auto overrides the global
   .editable-input { width: 100% } so controls stay compact inline. */
.contacts-filters .editable-input {
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 13px;
  padding: 7px 12px;
  min-width: 0;
  width: auto;
}

.contacts-filters .editable-input:hover {
  border-color: var(--border-strong);
  background: var(--surface2);
}

.contacts-filters .editable-input:focus,
.contacts-filters .editable-input:focus-visible {
  border-color: var(--teal);
  background: var(--surface);
  box-shadow: var(--focus-ring);
}

/* Selects inside the toolbar get matching dimensions plus a slightly
   wider right-padding so the chevron never crowds the longest option label. */
.contacts-filters select.editable-input {
  padding: 7px 32px 7px 12px;
  font-weight: 500;
  border: 1px solid var(--border);
  border-radius: 8px;
  background-color: var(--surface);
  background-image: var(--chevron-muted);
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 12px;
  color: var(--ink);
  width: auto;
  min-width: 120px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

.contacts-filters select.editable-input:hover {
  border-color: var(--border-strong);
  background-color: var(--surface2);
}

.contacts-filters select.editable-input:focus,
.contacts-filters select.editable-input:focus-visible {
  border-color: var(--teal);
  background-color: var(--surface);
  box-shadow: var(--focus-ring);
}

/* Search input — magnifier icon baked in via background-image so it
   behaves like a real search field without needing a wrapper element.
   Fixed width so it doesn't shrink too small or dominate the row. */
.contacts-filters input.editable-input[type="text"] {
  width: 200px;
  flex-shrink: 1;
  background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2214%22%20height%3D%2214%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22%238aa5b0%22%20stroke-width%3D%222%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Ccircle%20cx%3D%2211%22%20cy%3D%2211%22%20r%3D%228%22%3E%3C%2Fcircle%3E%3Cline%20x1%3D%2221%22%20y1%3D%2221%22%20x2%3D%2216.65%22%20y2%3D%2216.65%22%3E%3C%2Fline%3E%3C%2Fsvg%3E");
  background-repeat: no-repeat;
  background-position: left 11px center;
  background-size: 14px;
  padding-left: 34px;
}

/* Custom checkbox so "Show archived" stops looking like Windows 95.
   Scoped to the filter bar only — the rest of the app keeps native
   checkboxes for now. */
.contacts-filters label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  padding: 7px 4px;
  user-select: none;
}

.contacts-filters label:hover {
  color: var(--ink);
}

.contacts-filters input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  background: var(--surface);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.contacts-filters input[type="checkbox"]:hover {
  border-color: var(--teal);
}

.contacts-filters input[type="checkbox"]:checked {
  background: var(--teal);
  border-color: var(--teal);
  background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2212%22%20height%3D%2212%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22%23fff%22%20stroke-width%3D%223%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpolyline%20points%3D%2220%206%209%2017%204%2012%22%3E%3C%2Fpolyline%3E%3C%2Fsvg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 11px;
}

.contacts-filters input[type="checkbox"]:focus-visible {
  box-shadow: var(--focus-ring);
}

/* Make the Clear button feel like part of the bar, not an afterthought. */
.contacts-filters .btn {
  padding: 7px 14px;
  font-size: 13px;
  border-radius: 8px;
  border-color: var(--border);
  color: var(--muted);
}

.contacts-filters .btn:hover {
  border-color: var(--border-strong);
  color: var(--ink);
  background: var(--surface2);
}

.filter-btn {
  font-size: 11px;
  padding: 4px 12px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s
}

.filter-btn.active {
  background: var(--teal);
  color: #fff;
  border-color: var(--teal)
}

.contacts-list {
  display: grid;
  gap: 8px
}

.contact-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.25rem;
  cursor: pointer;
  transition: all 0.15s
}

.contact-card:hover {
  border-color: var(--teal)
}

.contact-row {
  display: flex;
  align-items: flex-start;
  gap: 12px
}

.avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 500;
  font-size: 12px;
  flex-shrink: 0;
  font-family: 'DM Mono', monospace
}

.av-teal {
  background: #e1f5ee;
  color: #0f6e56
}

.av-blue {
  background: #e6f1fb;
  color: #185fa5
}

.av-purple {
  background: #eeedfe;
  color: #534ab7
}

.av-amber {
  background: #faeeda;
  color: #854f0b
}

.av-coral {
  background: #faece7;
  color: #993c1d
}

.av-gray {
  background: #f1efe8;
  color: #5f5e5a
}

.contact-body {
  flex: 1;
  min-width: 0
}

.contact-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--ink)
}

.contact-org {
  font-size: 11px;
  color: var(--faint);
  margin-top: 1px
}

.contact-note {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.45;
  margin-top: 6px;
  font-style: italic
}

.contact-meta {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 8px;
  flex-wrap: wrap
}

.rel-badge {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 500
}

.r-warm {
  background: #faeeda;
  color: #854f0b
}

.r-cold {
  background: #f1efe8;
  color: #5f5e5a
}

.r-active {
  background: #e1f5ee;
  color: #0f6e56
}

.r-urgent {
  background: #faeae5;
  color: #993c1d;
}

.r-partner {
  background: #eeedfe;
  color: #534ab7
}

.contact-email {
  font-size: 11px;
  color: var(--teal);
  font-family: 'DM Mono', monospace
}

.contact-actions-row {
  display: flex;
  gap: 6px;
  margin-left: auto;
  flex-shrink: 0
}

/* EMAILS */
.email-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 1.25rem;
  flex-wrap: wrap
}

.email-tab {
  padding: 6px 16px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s;
  font-family: 'DM Sans', sans-serif
}

.email-tab.active {
  background: var(--surface3);
  color: var(--ink);
  border-color: var(--border-strong);
  font-weight: 500
}

.email-pane {
  display: none
}

.email-pane.active {
  display: block
}

.email-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden
}

.email-header {
  background: var(--surface3);
  border-bottom: 1px solid var(--border);
  padding: 1rem 1.25rem
}

.email-field {
  display: flex;
  gap: 8px;
  font-size: 12px;
  padding: 3px 0
}

.email-field-label {
  color: var(--faint);
  width: 100px;
  flex-shrink: 0
}

.email-field-value {
  color: var(--ink);
  font-weight: 500
}

.email-subject {
  font-family: 'Playfair Display', serif;
  font-size: 15px;
  color: var(--mid);
  margin-top: 8px
}

.email-body {
  padding: 1.25rem;
  font-size: 13px;
  color: var(--ink);
  line-height: 1.7;
  white-space: pre-wrap
}

.email-footer {
  background: var(--surface3);
  border-top: 1px solid var(--border);
  padding: 0.75rem 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center
}

.email-note {
  font-size: 11px;
  color: var(--faint);
  font-style: italic
}

/* Email upgrade — toolbar, filters, list rows, pills */
.email-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.email-filter-bar {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.email-filter-chip {
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}

.email-filter-chip:hover {
  border-color: var(--border-strong);
  color: var(--ink);
}

.email-filter-chip.active {
  background: var(--surface3);
  color: var(--ink);
  border-color: var(--teal);
}

.email-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 1.5rem;
}

.email-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 14px;
  min-height: 80px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}

.email-row:hover {
  border-color: var(--border-strong);
}

.email-row.active {
  border-color: var(--teal);
  border-left-color: var(--teal);
  background: var(--surface3);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.email-row-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.email-row-badges {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-shrink: 0;
}

.email-row-date {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.email-row-body {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.email-row-org {
  font-family: 'Playfair Display', serif;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.email-row-subject {
  font-size: 12px;
  color: var(--ink);
  font-weight: 500;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.email-row-contact {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.email-row-next {
  font-size: 11px;
  color: var(--faint);
  font-style: italic;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: 2px;
}

/* Status + priority pills (shared shape) */
.email-status-wrap,
.email-priority-wrap {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}

.email-status-pill,
.email-priority-pill {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid currentColor;
  cursor: pointer;
  white-space: nowrap;
  opacity: 0.75;
  transition: opacity 0.15s;
  user-select: none;
}

.email-status-pill:hover,
.email-priority-pill:hover {
  opacity: 1;
}

/* Email pill selects — same family as .action-status-select, just
   tighter for the denser email list. Chevron colour follows the pill
   accent via per-status background-image overrides defined below. */
.email-status-select,
.email-priority-select {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  padding: 2px 20px 2px 9px;
  border-radius: 999px;
  border: 1px solid currentColor;
  background-color: var(--surface);
  background-position: right 5px center;
  background-size: 9px;
  line-height: 1.3;
}

.email-status-select:hover,
.email-priority-select:hover { filter: brightness(0.95); }

.email-status-select:focus-visible,
.email-priority-select:focus-visible { box-shadow: 0 0 0 3px rgba(26, 122, 138, 0.12); }

/* Status colours + matching chevrons */
.status-draft     { color: var(--muted); }
.status-ready     { color: var(--teal); }
.status-sent      { color: var(--green); }
.status-archived  { color: var(--faint); opacity: 0.6; }

.email-status-select.status-draft {
  background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%229%22%20height%3D%229%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22%234a6572%22%20stroke-width%3D%222.5%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpolyline%20points%3D%226%209%2012%2015%2018%209%22%3E%3C%2Fpolyline%3E%3C%2Fsvg%3E");
}
.email-status-select.status-ready {
  background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%229%22%20height%3D%229%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22%231a7a8a%22%20stroke-width%3D%222.5%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpolyline%20points%3D%226%209%2012%2015%2018%209%22%3E%3C%2Fpolyline%3E%3C%2Fsvg%3E");
}
.email-status-select.status-sent {
  background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%229%22%20height%3D%229%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22%232d8a5e%22%20stroke-width%3D%222.5%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpolyline%20points%3D%226%209%2012%2015%2018%209%22%3E%3C%2Fpolyline%3E%3C%2Fsvg%3E");
}
.email-status-select.status-archived {
  background-image: var(--chevron-faint);
}

/* Priority colours + matching chevrons */
.priority-high    { color: var(--accent); }
.priority-medium  { color: var(--amber); }
.priority-low     { color: var(--faint); }

.email-priority-select.priority-high {
  background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%229%22%20height%3D%229%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22%23c8543a%22%20stroke-width%3D%222.5%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpolyline%20points%3D%226%209%2012%2015%2018%209%22%3E%3C%2Fpolyline%3E%3C%2Fsvg%3E");
}
.email-priority-select.priority-medium {
  background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%229%22%20height%3D%229%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22%23c17f24%22%20stroke-width%3D%222.5%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpolyline%20points%3D%226%209%2012%2015%2018%209%22%3E%3C%2Fpolyline%3E%3C%2Fsvg%3E");
}
.email-priority-select.priority-low {
  background-image: var(--chevron-faint);
}

/* Two-column split: list left, active pane right */
.email-split {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: 1.5rem;
  align-items: start;
}

.email-split-list {
  min-width: 0;
}

.email-split-pane {
  position: sticky;
  top: 1rem;
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
  min-width: 0;
}

.email-split-placeholder {
  padding: 2rem 1.25rem;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: 10px;
  text-align: center;
  color: var(--faint);
  font-size: 12px;
  font-style: italic;
}

/* Slightly tighter cards when the list lives in the narrower left column.
   Cards stay vertical and keep the full hierarchy (subject / org /
   contact / next) — only padding and subject size are tuned. */
@media (min-width: 1151px) {
  .email-split .email-row {
    padding: 11px 12px;
    min-height: 76px;
    gap: 5px;
  }
  .email-split .email-row-org {
    font-size: 13px;
  }
}

/* Narrow viewport: stack to single column, list above pane */
@media (max-width: 1150px) {
  .email-split {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
  .email-split-pane {
    position: static;
    max-height: none;
    overflow: visible;
  }
}

/* Email-pane mid row — body (left) + linked notes (right) at wide widths,
   stacked vertically below the breakpoint. */
.email-card-mid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 340px);
  gap: 1.25rem;
  align-items: start;
  margin-top: 0;
}

@media (max-width: 1299px) {
  .email-card-mid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
}

/* Linked Notes panel — lives in the right column of .email-card-mid */
.linked-notes-panel {
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  min-width: 0;
}

.linked-notes-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.linked-notes-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--muted);
}

.linked-notes-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

/* Picker variant — inherits the base modern select reset; just
   constrains width and dials font size down for inline placement. */
.linked-notes-picker {
  font-size: 12px;
  padding: 5px 26px 5px 10px;
  min-width: 180px;
  max-width: 240px;
}

.linked-notes-empty {
  font-size: 12px;
  color: var(--faint);
  font-style: italic;
  padding: 4px 0 2px;
}

.linked-notes-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.linked-notes-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  background: var(--surface3);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.linked-notes-row:hover {
  border-color: var(--border-strong);
}

.linked-notes-row.expanded {
  flex-direction: column;
  align-items: stretch;
  padding: 12px;
  background: var(--surface);
  cursor: default;
  gap: 8px;
}

.linked-notes-row.expanded .linked-notes-row-actions {
  align-self: flex-end;
  padding-top: 0;
}

.linked-notes-row-title-edit {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.3;
}

.linked-notes-row-date {
  font-size: 11px;
  color: var(--muted);
}

.linked-notes-row-text-edit {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
}

.linked-notes-row-main {
  min-width: 0;
  flex: 1;
}

.linked-notes-row-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.linked-notes-row-excerpt {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.4;
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.linked-notes-row-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
  align-items: center;
  padding-top: 1px;
}

.linked-notes-link {
  background: none;
  border: none;
  font-family: inherit;
  font-size: 11px;
  color: var(--teal);
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  text-decoration: underline;
  text-decoration-color: transparent;
  transition: text-decoration-color 0.15s, color 0.15s;
}

.linked-notes-link:hover {
  text-decoration-color: currentColor;
}

/* Backlink line on a Note showing which email(s) link to it */
.note-backlink {
  font-size: 11px;
  color: var(--faint);
  font-style: italic;
  margin-top: 8px;
  padding-top: 6px;
  border-top: 1px dashed var(--border);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.version-toggle {
  display: flex;
  gap: 6px
}

.vtab {
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  cursor: pointer
}

.vtab.active {
  background: var(--teal);
  color: #fff;
  border-color: var(--teal)
}

/* REFERENCE */
.ref-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 1.25rem
}

.ref-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: 0 4px 20px rgba(5, 30, 44, 0.03);
  transition: box-shadow 0.2s, transform 0.2s;
}
.ref-card:hover {
  box-shadow: 0 8px 30px rgba(5, 30, 44, 0.06);
  transform: translateY(-2px);
}

.ref-title {
  font-size: 12px;
  font-weight: 500;
  color: var(--mid);
  letter-spacing: 0.2px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px
}

.ref-title-icon {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--teal)
}

.ref-item {
  font-size: 12px;
  color: var(--muted);
  padding: 5px 0;
  border-bottom: 1px solid var(--border);
  line-height: 1.45
}

.ref-item:last-child {
  border-bottom: none;
  padding-bottom: 0
}

.ref-item strong {
  color: var(--ink);
  font-weight: 500
}

.risk-high {
  border-left: 3px solid var(--accent);
  padding-left: 10px;
  border-radius: 0
}

.risk-med {
  border-left: 3px solid var(--amber);
  padding-left: 10px;
  border-radius: 0
}

.ref-section-item {
  position: relative;
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 2px;
  padding-right: 20px
}

.ref-level-badge {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  padding: 2px 5px;
  border-radius: 3px;
  border: 1px solid currentColor;
  cursor: pointer;
  user-select: none;
  flex-shrink: 0;
  opacity: 0.5;
  transition: opacity 0.15s;
  margin-right: 6px;
  align-self: center
}

.ref-level-badge:hover {
  opacity: 1
}

.ref-level-badge.level-none {
  color: var(--faint);
  border-color: var(--border)
}

.ref-level-badge.level-med {
  color: var(--amber)
}

.ref-level-badge.level-high {
  color: var(--accent)
}

.ref-item-remove {
  position: absolute;
  top: 50%;
  right: 0;
  transform: translateY(-50%);
  font-size: 10px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--faint);
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center
}

.ref-section-item:hover .ref-item-remove {
  display: flex
}

.ref-item-remove:hover {
  color: var(--accent)
}

.ref-group-remove {
  margin-left: auto;
  flex-shrink: 0;
  font-size: 10px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--faint);
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center
}

.ref-card:hover .ref-group-remove {
  display: flex
}

.ref-group-remove:hover {
  color: var(--accent)
}

.ref-empty-items {
  font-size: 11px;
  color: var(--faint);
  padding: 8px 0;
  font-style: italic
}

/* MISC */
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem
}

.section-title {
  font-family: 'Playfair Display', serif;
  font-size: 20px;
  font-weight: 600;
  color: var(--mid)
}

.section-desc {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px
}

.divider {
  height: 1px;
  background: var(--border);
  margin: 1.5rem 0
}

.empty-state {
  text-align: center;
  padding: 2rem;
  color: var(--faint);
  font-size: 13px
}

.copy-btn {
  font-size: 11px;
  padding: 4px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: transparent;
  color: var(--teal);
  cursor: pointer;
  font-family: 'DM Sans', sans-serif
}

.copy-btn:hover {
  background: var(--surface3)
}

/* UPDATES */
.update-list {
  display: grid;
  gap: 8px
}

.update-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.25rem;
  display: flex;
  gap: 12px
}

.update-line {
  width: 2px;
  background: var(--teal-light);
  border-radius: 2px;
  flex-shrink: 0
}

.update-line.urgent {
  background: var(--accent)
}

.update-content {
  flex: 1
}

.update-date {
  font-size: 10px;
  color: var(--faint);
  letter-spacing: 0.5px;
  text-transform: uppercase;
  margin-bottom: 4px;
  font-family: 'DM Mono', monospace
}

.update-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
  margin-bottom: 3px
}

.update-text {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5
}

/* LOADING */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: var(--surface2);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  z-index: 9998
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--teal);
  border-radius: 50%;
  animation: spin 0.8s linear infinite
}

@keyframes spin {
  to {
    transform: rotate(360deg)
  }
}

.loading-text {
  font-size: 13px;
  color: var(--muted)
}

/* TOAST */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--deep);
  color: #fff;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 13px;
  z-index: 10000;
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.3s;
  pointer-events: none
}

.toast.show {
  opacity: 1;
  transform: translateY(0)
}

.toast.error {
  background: var(--accent)
}

.toast.undo {
  display: flex;
  align-items: center;
  gap: 12px;
  pointer-events: auto;
}

.toast-undo-btn {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.3);
  padding: 3px 10px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}

.toast-undo-btn:hover {
  background: rgba(255, 255, 255, 0.35);
}

.toast-countdown {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 2px;
  background: rgba(255, 255, 255, 0.5);
  border-radius: 0 0 8px 8px;
  animation: toast-countdown 5s linear forwards;
}

@keyframes toast-countdown {
  from {
    width: 100%;
  }

  to {
    width: 0%;
  }
}

/* EDITABLE */
.editable-field {
  cursor: text;
  border-radius: 4px;
  transition: background 0.15s;
  padding: 1px 4px;
  margin: -1px -4px;
  min-width: 3em;
}

.editable-field:empty::after {
  content: '—';
  color: #666;
  opacity: 0.5;
  pointer-events: none;
}

.editable-field:hover {
  background: var(--surface3)
}

/* Inline edit input — soft border at rest (so it doesn't shout
   against everything around it), teal focus ring when actually being
   edited. 8px radius and more generous padding match modern form UI. */
.editable-input {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  font-weight: inherit;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 7px 11px;
  outline: none;
  width: 100%;
  background-color: var(--surface);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

.editable-input:hover {
  border-color: var(--teal);
}

.editable-input:focus,
.editable-input:focus-visible {
  border-color: var(--teal);
  box-shadow: var(--focus-ring);
}

.editable-input::placeholder {
  color: var(--faint);
}

/* Canonical "form select" — used by toolbar filters and inline edit
   forms. Inherits the base modern select reset; just bumps font-weight
   and pads slightly more to feel like a form control rather than a chip. */
select.editable-input {
  padding: 6px 28px 6px 10px;
  font-weight: 500;
  background-size: 13px;
}

select.editable-input:focus-visible {
  box-shadow: var(--focus-ring);
}

.editable-textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  border: 1px solid var(--teal);
  border-radius: 4px;
  padding: 4px 6px;
  outline: none;
  width: 100%;
  min-height: 60px;
  resize: vertical;
  background: var(--surface);
  line-height: 1.5
}

.edit-actions {
  display: flex;
  gap: 6px;
  margin-top: 6px
}

/* PHASE PLACEHOLDER */
.phase-placeholder {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 3rem 2rem;
  text-align: center
}

.phase-placeholder-title {
  font-family: 'Playfair Display', serif;
  font-size: 18px;
  color: var(--mid);
  margin-bottom: 8px
}

.phase-placeholder-text {
  font-size: 13px;
  color: var(--faint)
}

/* CONFIRM DIALOG */
.confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 30, 44, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999
}

.confirm-box {
  background: var(--surface);
  border-radius: 12px;
  padding: 1.5rem;
  max-width: 360px;
  width: 90%
}

.confirm-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  margin-bottom: 8px
}

.confirm-text {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
  margin-bottom: 16px
}

.confirm-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end
}

/* LOGOUT */
.logout-btn {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.35);
  cursor: pointer;
  background: none;
  border: none;
  padding: 4px 0;
  font-family: 'DM Sans', sans-serif;
  transition: color 0.15s
}

.logout-btn:hover {
  color: rgba(255, 255, 255, 0.7)
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 2rem;
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: 12px;
  color: var(--faint);
  font-size: 13px;
  text-align: center;
  margin-top: 1rem;
  background-image: linear-gradient(180deg, rgba(255,255,255,0) 0%, rgba(26,122,138,0.03) 100%);
  box-shadow: 0 4px 20px rgba(5, 30, 44, 0.02);
}

.empty-state::before {
  content: "✦";
  font-size: 24px;
  color: var(--border-strong);
  margin-bottom: 12px;
  display: block;
}

/* Legacy 768px block — kept for the layout grid collapse only.
   Sidebar display rule is REMOVED here: on mobile the sidebar becomes an
   off-canvas drawer (see the RESPONSIVE block at the bottom of this file),
   not hidden outright. */
@media(max-width:768px) {
  .shell {
    grid-template-columns: 1fr
  }

  .metrics {
    grid-template-columns: 1fr 1fr
  }

  .actions-grid,
  .sites-grid,
  .ref-grid {
    grid-template-columns: 1fr
  }
}
  
/* Shared dashboard split layout (Master-Detail).
   Mirrors the Email Drafts .email-split concept: a flexible list column on
   the left, a flexible detail pane on the right, collapsing to a single
   column below 1150px. Column widths match .email-split so both pages share
   one visual model. */
.dashboard-split {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: 1.5rem;
  align-items: start;
}

.dashboard-split-list {
  min-width: 0;
}

.dashboard-split-pane {
  position: sticky;
  top: 1rem;
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
  min-width: 0;
  align-self: start;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.5rem;
}

.dashboard-split-placeholder {
  text-align: center;
  color: var(--faint);
  font-size: 12px;
  font-style: italic;
}

/* When the pane only contains a placeholder (nothing selected), hide the card
   box so we don't get a tiny white box floating in a large empty column.
   The pane keeps its position/width — we just strip the visible chrome. */
.dashboard-split-pane:has(> .dashboard-split-placeholder) {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
}

@media (max-width: 1150px) {
  .dashboard-split { grid-template-columns: 1fr; gap: 1rem; }
  .dashboard-split-pane { position: static; max-height: none; overflow: visible; }
}

.rel-pill {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid currentColor;
  background: var(--surface);
}
.rel-pill.status { color: var(--teal); }
.rel-pill.priority { color: var(--amber); }
.rel-pill.warmth { color: var(--accent); }

.rel-list-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  cursor: pointer;
  margin-bottom: 0;
  transition: all 0.15s;
}
.rel-list-card:hover {
  border-color: var(--teal-light);
}
.rel-list-card.active {
  border-color: var(--teal);
  background: var(--surface3);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

/* =========================================================================
   RELATIONSHIPS DROPDOWN CONSISTENCY
   Matches Email Drafts visual treatment for all selects in this section.
   ========================================================================= */

/* Detail pane selects (Category, Status, Priority, Warmth) */
.dashboard-split-pane select.editable-input {
  font-size: 13px;
  padding: 7px 28px 7px 10px;
  font-weight: 500;
  border: 1px solid var(--border);
  border-radius: 8px;
  background-color: var(--surface);
  background-image: var(--chevron-muted);
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 12px;
  color: var(--ink);
  width: 100%;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.dashboard-split-pane select.editable-input:hover {
  border-color: var(--teal);
}
.dashboard-split-pane select.editable-input:focus,
.dashboard-split-pane select.editable-input:focus-visible {
  border-color: var(--teal);
  box-shadow: var(--focus-ring);
  outline: none;
}

/* Prevent content area from clipping dropdowns */
#section-relationships .content {
  overflow: visible;
}

/* =========================================================================
   RESPONSIVE GRID HELPERS — used by the relationship detail and edit form
   grids so they collapse to 1 column when the pane is narrow rather than
   overflowing.
   ========================================================================= */

/* 2-col grid that wraps to 1 col once a column would be narrower than 160px */
.rel-meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  background: var(--surface2);
  padding: 16px;
  border-radius: 8px;
  margin-bottom: 20px;
}

/* Same treatment for the edit form's name/org and other paired fields */
.rel-edit-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

/* =========================================================================
   ADD FORM STYLING
   Make the add form look like part of the pane, not a floating card.
   ========================================================================= */
.rel-add-form {
  background: var(--surface);
  border: 1px solid var(--teal-light);
  border-radius: 10px;
  padding: 1.25rem;
  margin-bottom: 1rem;
}

/* =========================================================================
   CLOSE BUTTONS
   rel-close-x  — × icon in the detail pane header, always visible
   rel-detail-close — "← Back" text button, mobile/stacked layout only
   ========================================================================= */

/* × icon button sits in the header row next to Edit Details */
.rel-close-x {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: none;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s;
  flex-shrink: 0;
  margin-left: 4px;
}
.rel-close-x:hover {
  background: var(--surface3);
  border-color: var(--border-strong);
  color: var(--ink);
}

/* ← Back button: hidden on desktop, shown when the layout stacks */
.rel-detail-close {
  display: none;
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
  font-family: inherit;
  margin-bottom: 12px;
  transition: all 0.15s;
}
.rel-detail-close:hover {
  background: var(--surface3);
  border-color: var(--border-strong);
  color: var(--ink);
}

@media (max-width: 1150px) {
  /* On stacked layout: show the ← Back text button, hide the header × */
  .rel-detail-close {
    display: inline-flex;
    align-items: center;
    gap: 4px;
  }
  .rel-close-x {
    display: none;
  }
  #section-relationships .dashboard-split-pane {
    position: static;
    max-height: none;
    overflow: visible;
    margin-top: 0;
  }
}

/* List column flows naturally — the page scrolls, the sticky detail pane stays put */


/* =========================================================================
   RESPONSIVE — TABLET + MOBILE
   Strategy:
   - <=1024px: tighten paddings, drop metrics to 2 cols, allow the
     Relationships filter row to wrap (fixes the "Show archived" overflow).
   - <=768px:  the sidebar becomes an off-canvas drawer, opened by a
     hamburger button injected into every topbar; layout grids collapse to
     a single column; tap targets grow.
   ========================================================================= */

/* Hamburger lives in the topbar; hidden on desktop. .menu-toggle markup is
   added by app.js inside every .topbar render. */
.menu-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--mid);
  cursor: pointer;
  margin-right: 12px;
  flex-shrink: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  transition: border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}
.menu-toggle:hover {
  border-color: var(--teal);
  color: var(--teal);
}
.menu-toggle:focus-visible {
  outline: none;
  border-color: var(--teal);
  box-shadow: var(--focus-ring);
}

/* Full-viewport scrim behind the drawer on mobile. The element is created
   once by app.js and toggled via the .show class. */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(5, 30, 44, 0.5);
  z-index: 90;
  opacity: 0;
  transition: opacity 0.2s ease;
}
.sidebar-backdrop.show {
  display: block;
  opacity: 1;
}

/* Prevent body scroll while drawer is open on mobile */
body.sidebar-open {
  overflow: hidden;
}

/* TABLET — fits the screenshot range (~768-1024px). Tighter chrome and a
   wrapping filter bar so the "Show archived" checkbox can't get clipped. */
@media (max-width: 1024px) {
  .shell {
    grid-template-columns: 200px 1fr;
  }
  .content {
    padding: 1.5rem 1.25rem;
  }
  .topbar {
    padding: 1rem 1.25rem;
  }
  .metrics {
    grid-template-columns: repeat(2, 1fr);
  }
  /* The fix for the filter overflow: let the row wrap to a second line
     rather than clipping the last control. */
  .contacts-filters {
    flex-wrap: wrap;
    row-gap: 8px;
  }
  .contacts-filters input.editable-input[type="text"] {
    flex: 1 1 220px;
  }
}

/* MOBILE — single column, drawer sidebar, larger tap targets. */
@media (max-width: 768px) {
  /* Sidebar becomes an off-canvas drawer. The earlier 768px block above
     drops the sidebar from the grid; this rule slides it back in as a
     fixed-position drawer that toggles via a .open class. */
  .sidebar {
    display: flex;
    position: fixed;
    top: 0;
    left: 0;
    width: 260px;
    max-width: 82vw;
    height: 100vh;
    height: 100dvh;
    z-index: 100;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.25);
  }
  .sidebar.open {
    transform: translateX(0);
  }

  .menu-toggle {
    display: inline-flex;
  }

  /* Topbar tightens up; the title block flexes around the hamburger. */
  .topbar {
    padding: 0.875rem 1rem;
  }
  .topbar > div:not(.menu-toggle):not(.topbar-actions) {
    min-width: 0;
    flex: 1;
  }
  .page-title {
    font-size: 14px;
  }
  .page-sub {
    font-size: 11px;
  }
  .topbar-actions {
    gap: 6px;
  }
  .topbar-actions .btn {
    padding: 6px 10px;
  }

  .content {
    padding: 1.25rem 1rem;
  }

  /* Layout grids — single column on phones. */
  .metrics {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .actions-grid,
  .sites-grid,
  .ref-grid {
    grid-template-columns: 1fr;
  }

  /* Bigger tap targets on the drawer nav. */
  .nav-item {
    padding: 12px 1.5rem;
    font-size: 14px;
  }

  /* Filter bar restacks: search full-width on row 1, controls flow below. */
  .contacts-filters {
    padding: 10px;
    gap: 6px;
    row-gap: 6px;
  }
  .contacts-filters input.editable-input[type="text"] {
    flex: 1 1 100%;
    width: 100%;
    order: -1;
  }
  .contacts-filters select.editable-input {
    flex: 1 1 calc(50% - 3px);
    min-width: 0;
  }
  .contacts-filters label,
  .contacts-filters .btn {
    flex: 1 1 auto;
  }

  /* Horizontal scroll for chip rows rather than awkward wrap. */
  .email-tabs,
  .email-filter-bar {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .email-tabs::-webkit-scrollbar,
  .email-filter-bar::-webkit-scrollbar {
    display: none;
  }

  /* Card paddings a touch tighter, metric numbers a touch smaller. */
  .metric,
  .actions-card,
  .site-card,
  .contact-card,
  .email-card {
    padding: 1rem 1.125rem;
  }
  .metric-value {
    font-size: 22px;
  }

  /* Site meta grid stays 2-col on phones so labels/values stay paired. */
  .site-meta {
    grid-template-columns: 1fr 1fr;
  }

  /* Alert: a touch tighter. */
  .alert {
    padding: 0.875rem 1rem;
  }

  /* Wiki / Entity / Admin pages use .sidebar-left / .sidebar-right - these
     are separate shells from the main dashboard. On mobile, drop their
     fixed widths and stack the columns. */
  .sidebar-left,
  .sidebar-right {
    position: static !important;
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    max-height: none !important;
    border-right: none;
    border-left: none;
  }
}

/* Small phones - squeeze paddings further and let select pairs go to a
   single column so the labels stay readable. */
@media (max-width: 420px) {
  .content {
    padding: 1rem 0.875rem;
  }
  .topbar {
    padding: 0.75rem 0.875rem;
  }
  .contacts-filters select.editable-input {
    flex: 1 1 100%;
  }
  .metric-value {
    font-size: 20px;
  }
}
