/* Design tokens shared with cmit-ticketing (cross media IT): warm off-white surfaces, petrol
   as the only interface accent, DM Sans for text and Manrope for headings. Spacing on a
   4px grid. Every color has a dark value; the theme is set by theme-init.js. */

@font-face {
  font-family: "DM Sans";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/dm-sans-latin-400-normal.woff2") format("woff2");
}

@font-face {
  font-family: "DM Sans";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/fonts/dm-sans-latin-500-normal.woff2") format("woff2");
}

@font-face {
  font-family: "DM Sans";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/fonts/dm-sans-latin-600-normal.woff2") format("woff2");
}

@font-face {
  font-family: "Manrope";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/fonts/manrope-latin-600-normal.woff2") format("woff2");
}

:root {
  color-scheme: light;
  --bg: #f6f5f1;
  --surface: #ffffff;
  --surface-2: #f4f3ef;
  --line: #e6e4de;
  --line-strong: #d8d5cd;
  --line-hover: #c4c0b6;
  --heading: #101615;
  --ink: #1f2624;
  --ink-2: #47514e;
  --ink-3: #78817e;
  --accent: #0e5f70;
  --accent-hover: #0a4d5b;
  --accent-text: #0e6476;
  --accent-soft: #e5f0f2;
  --focus: #2b8a9d;
  --focus-ring: #d6eaee;
  /* Row states: petrol marks pending edits, yellow only real warnings, red errors */
  --changed: #0e6476;
  --new: #2f7d4f;
  --warning: #825c14;
  --warning-soft: #fff2ce;
  --danger: #a13b2d;
  --danger-strong: #a13b2d;
  --danger-hover: #862f24;
  --danger-soft: #fff0ed;
  --idle: #b3b8b4;
  --brand-red: #c62a42;
  --logo-text: #76777b;
  --tint-changed: rgba(14, 100, 118, 0.05);
  --tint-edited: #e5f0f2;
  --tint-new: rgba(47, 125, 79, 0.05);
  --tint-deleted: rgba(161, 59, 45, 0.05);
  --tint-selected: rgba(14, 100, 118, 0.07);
  --hover-cell: #f7f6f2;
  --shadow-card: 0 1px 2px rgb(17 24 26 / 4%), 0 10px 28px -14px rgb(17 24 26 / 12%);
  --shadow-raised: 0 2px 6px rgb(17 24 26 / 6%), 0 18px 40px -18px rgb(17 24 26 / 22%);
  --backdrop: #0b1f2459;
  --radius-card: 16px;
  --radius-control: 10px;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --font-text: "DM Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-heading: "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-family: var(--font-text);
  font-size: 14px;
  line-height: 20px;
  font-synthesis: none;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e1416;
  --surface: #151d20;
  --surface-2: #1b2529;
  --line: #263236;
  --line-strong: #33424a;
  --line-hover: #4a5c63;
  --heading: #f4f8f8;
  --ink: #e2e8e8;
  --ink-2: #bdc9ca;
  --ink-3: #8c9a9c;
  --accent: #237d90;
  --accent-hover: #2b90a5;
  --accent-text: #74c6d6;
  --accent-soft: #15333b;
  --focus: #74c6d6;
  --focus-ring: #15333b;
  --changed: #74c6d6;
  --new: #6fc79a;
  --warning: #f3cd81;
  --warning-soft: #3c3221;
  --danger: #ffb5a7;
  --danger-strong: #b4473a;
  --danger-hover: #c85546;
  --danger-soft: #3c2729;
  --idle: #4f5d62;
  --logo-text: #e2e0dd;
  --tint-changed: rgba(116, 198, 214, 0.07);
  --tint-edited: #15333b;
  --tint-new: rgba(111, 199, 154, 0.07);
  --tint-deleted: rgba(255, 181, 167, 0.06);
  --tint-selected: rgba(116, 198, 214, 0.1);
  --hover-cell: #1a2427;
  --shadow-card: 0 0 0 1px #ffffff05;
  --shadow-raised: 0 18px 50px -20px #000000aa;
  --backdrop: #02080acc;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1,
h2,
h3 {
  color: var(--heading);
  font-family: var(--font-heading);
  font-weight: 600;
}

[hidden] {
  display: none !important;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-variant-numeric: tabular-nums;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.icon {
  width: 16px;
  height: 16px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Motion stays short and is off when the system asks for it */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0s !important;
    animation-duration: 0s !important;
  }
}

/* ---- Layout ---------------------------------------------------------------- */

.app-shell {
  max-width: 1600px;
  margin: 0 auto;
  padding: 24px 32px 40px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
}

.header {
  display: flex;
  align-items: center;
  gap: 24px;
  min-height: 36px;
  margin-bottom: 24px;
}

.product {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

h1 {
  font-size: 20px;
  line-height: 28px;
  letter-spacing: -0.01em;
}

.session {
  display: flex;
  flex: 1;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  min-width: 0;
}

.auth-status {
  min-width: 0;
  color: var(--ink-2);
  text-align: right;
}

.auth-status strong {
  color: var(--ink);
  font-weight: 500;
}

.auth-status.error {
  color: var(--danger);
}

.org-field {
  display: block;
  width: 260px;
}

.language-switch {
  display: flex;
  gap: 2px;
  padding: 4px;
  border-radius: var(--radius-control);
  background: var(--surface-2);
}

.language-switch button {
  height: 24px;
  padding: 0 8px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--ink-3);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 120ms var(--ease), color 120ms var(--ease);
}

.language-switch button:hover {
  color: var(--ink);
}

.language-switch button[aria-pressed="true"] {
  background: var(--surface);
  color: var(--accent-text);
  box-shadow: 0 1px 4px rgb(17 24 26 / 8%);
}

.theme-toggle {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  background: var(--surface);
  color: var(--ink-2);
  cursor: pointer;
  transition: background-color 120ms var(--ease), color 120ms var(--ease);
}

.theme-toggle:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.theme-toggle .icon-sun,
:root[data-theme="dark"] .theme-toggle .icon-moon {
  display: none;
}

:root[data-theme="dark"] .theme-toggle .icon-sun {
  display: block;
}

.language-switch button:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
}

/* The vector logo; the grey lettering follows the theme */
.brand-logo {
  display: block;
  height: 22px;
  width: auto;
}

.brand-logo .logo-text {
  fill: var(--logo-text);
}

/* ---- Controls -------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  background: var(--surface);
  color: var(--ink-2);
  font-weight: 500;
  text-decoration: none;
  box-shadow: 0 1px 2px rgb(17 24 26 / 5%);
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 120ms var(--ease), border-color 120ms var(--ease), color 120ms var(--ease);
}

.btn .icon {
  color: var(--ink-3);
}

.btn:hover {
  background: var(--surface-2);
  border-color: var(--line-hover);
}

.btn:active:not(:disabled) {
  transform: scale(0.98);
}

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
  font-weight: 600;
}

.btn.primary .icon {
  color: #ffffff;
}

.btn.primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn .count {
  padding: 0 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.18);
  font-size: 12px;
  line-height: 20px;
}

.btn.quiet-danger {
  border-color: transparent;
  background: none;
  color: var(--danger);
}

.btn.quiet-danger:hover {
  background: var(--danger-soft);
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.btn.quiet-danger:disabled {
  color: var(--ink-3);
}

/* A disabled primary action drops the accent so it never competes with an active one */
.btn.primary:disabled {
  border-color: var(--line-strong);
  background: var(--surface-2);
  color: var(--ink-3);
}

.btn.primary:disabled .icon {
  color: var(--ink-3);
}

.text-button {
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink-2);
  cursor: pointer;
  transition: color 120ms var(--ease);
}

.text-button:hover {
  color: var(--ink);
}

.field {
  display: grid;
  gap: 4px;
}

.field > span {
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 600;
  line-height: 16px;
}

.field-hint {
  color: var(--ink-3);
}

.input {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  background: var(--surface);
  color: var(--ink);
  transition: border-color 120ms var(--ease), background-color 120ms var(--ease), box-shadow 120ms var(--ease);
}

.input.compact {
  height: 34px;
}

.input::placeholder {
  color: var(--ink-3);
}

select.input {
  appearance: none;
  padding-right: 28px;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-3) 50%), linear-gradient(135deg, var(--ink-3) 50%, transparent 50%);
  background-position: calc(100% - 14px) 50%, calc(100% - 10px) 50%;
  background-size: 4px 4px;
  background-repeat: no-repeat;
}

a:focus-visible,
.btn:focus-visible,
.text-button:focus-visible,
.theme-toggle:focus-visible,
.check input:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.input:focus {
  border-color: var(--focus);
  outline: none;
  box-shadow: 0 0 0 4px var(--focus-ring);
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  color: var(--ink-2);
  white-space: nowrap;
}

.check input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--accent);
}

/* ---- Toolbar ---------------------------------------------------------------- */

.toolbar {
  margin-bottom: 16px;
}

.query {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) auto auto;
  gap: 12px;
  align-items: end;
  padding: 16px;
}

.edit {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
}

.edit .grow {
  flex: 1 1 0;
}

#toggleCsv .chevron {
  transition: transform 160ms var(--ease);
}

#toggleCsv[aria-expanded="true"] {
  background: var(--surface-2);
  border-color: var(--line-hover);
}

#toggleCsv[aria-expanded="true"] .chevron {
  transform: rotate(180deg);
}

.contact-search {
  position: relative;
  flex: 1 1 200px;
  min-width: 180px;
  max-width: 320px;
  margin-left: 8px;
}

.contact-search > .icon {
  position: absolute;
  top: 10px;
  left: 12px;
  color: var(--ink-3);
  pointer-events: none;
}

.contact-search .input {
  padding: 0 36px;
}

.contact-search .input::-webkit-search-cancel-button {
  display: none;
}

.clear-filter {
  position: absolute;
  top: 6px;
  right: 6px;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: none;
  color: var(--ink-3);
  cursor: pointer;
}

.clear-filter:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.contact-search:has(.input:placeholder-shown) .clear-filter {
  display: none;
}

/* ---- CSV import ------------------------------------------------------------- */

.csv-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 24px;
  align-items: center;
  padding: 16px;
  border-top: 1px solid var(--line);
  border-radius: 0 0 12px 12px;
  background: var(--surface-2);
}

.csv-copy h2 {
  margin-bottom: 4px;
  font-size: 14px;
  font-weight: 600;
}

.csv-copy p {
  color: var(--ink-2);
  font-size: 13px;
}

.csv-columns {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 8px;
}

.csv-columns span {
  padding: 0 6px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
  color: var(--ink-2);
  font-size: 12px;
  line-height: 20px;
}

.csv-columns span.required {
  border-color: var(--line-strong);
  color: var(--ink);
}

.csv-columns span.required::after {
  content: " required";
  color: var(--ink-3);
}

.csv-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.file-name {
  max-width: 240px;
  margin-right: 4px;
  overflow: hidden;
  color: var(--ink-3);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.csv-conflicts {
  grid-column: 1 / -1;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.csv-conflicts strong {
  color: var(--danger);
  font-weight: 500;
}

.csv-conflict-item {
  margin-top: 4px;
  color: var(--ink-2);
  font-size: 13px;
}

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

/* ---- Contacts --------------------------------------------------------------- */

.contacts {
  overflow: hidden;
}

.contacts-head {
  position: relative;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}

.operation-status {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.operation-status.success .dot {
  background: var(--new);
}

.operation-status.busy .dot {
  background: var(--changed);
}

.operation-status.error .dot {
  background: var(--danger);
}

.operation-status.error .operation-message {
  color: var(--danger);
}

/* Notes about the loaded list that stay until the next load (e.g. not all contacts loaded),
   apart from the status of the last operation */
.list-notice {
  margin: 0;
  padding: 8px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--warning-soft);
  color: var(--warning);
  font-size: 13px;
  line-height: 20px;
}

.counts {
  margin-left: auto;
  color: var(--ink-3);
  font-size: 13px;
  white-space: nowrap;
}

.counts b {
  color: var(--ink-2);
  font-weight: 500;
}

/* Determinate progress for pushes and detail refreshes, on the header's bottom edge */
.progress {
  position: absolute;
  right: 0;
  bottom: -1px;
  left: 0;
  height: 2px;
  overflow: hidden;
  background: var(--line);
}

.progress-bar {
  height: 100%;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 200ms var(--ease);
}

/* Status dot: the one signature detail, used for operations and rows */
/* Status markers are small flat-top hexagons, the shape of the cross media IT honeycomb */
.dot {
  width: 10px;
  height: 9px;
  flex: none;
  background: var(--idle);
  clip-path: polygon(25% 0, 75% 0, 100% 50%, 75% 100%, 25% 100%, 0 50%);
}

.table-wrap {
  max-height: calc(100vh - 300px);
  overflow: auto;
}

table {
  width: 100%;
  min-width: 1600px;
  border-collapse: collapse;
  table-layout: fixed;
}

.col-status { width: 152px; }
.col-id { width: 160px; }
.col-name { width: 180px; }
.col-first { width: 120px; }
.col-last { width: 130px; }
.col-company { width: 200px; }
.col-email { width: 240px; }
.col-type { width: 136px; }
.col-phone { width: 160px; }
.col-action { width: 136px; }

th {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
  box-shadow: inset -1px 0 0 var(--line);
  color: var(--ink-3);
  font-size: 12px;
  font-weight: 600;
  line-height: 16px;
  text-align: left;
  white-space: nowrap;
}

/* The table is a spreadsheet grid: every cell has a line on its right; editable cells
   have no padding so their input fills the whole cell. */
td {
  padding: 4px 10px;
  border-bottom: 1px solid var(--line);
  background-color: var(--surface);
  box-shadow: inset -1px 0 0 var(--line);
  vertical-align: middle;
}

td:has(> .input) {
  padding: 0;
}

td.sticky-1 {
  padding-right: 8px;
}

th:last-child,
td:last-child {
  box-shadow: none;
}

/* Status and display name stay visible while the table scrolls sideways */
.sticky-1,
.sticky-2 {
  position: sticky;
  z-index: 1;
}

.sticky-1 {
  left: 0;
}

.sticky-2 {
  left: 152px;
  box-shadow: inset -1px 0 0 var(--line-strong);
}

th.sticky-1,
th.sticky-2 {
  z-index: 3;
}

.status-head {
  display: flex;
  align-items: center;
  gap: 8px;
}

input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 0;
  flex: none;
  accent-color: var(--accent);
}

.sort {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.sort:hover {
  color: var(--ink);
}

.sort-icon {
  width: 12px;
  height: 12px;
  opacity: 0;
  transition: opacity 120ms var(--ease);
}

.sort:hover .sort-icon {
  opacity: 0.6;
}

th[aria-sort="ascending"] .sort,
th[aria-sort="descending"] .sort {
  color: var(--ink);
}

th[aria-sort="ascending"] .sort-icon,
th[aria-sort="descending"] .sort-icon {
  opacity: 1;
}

th[aria-sort="ascending"] .sort-icon path:last-child,
th[aria-sort="descending"] .sort-icon path:first-child {
  display: none;
}

.sort:focus-visible,
input[type="checkbox"]:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

th:first-child,
td:first-child {
  padding-left: 16px;
}

th:last-child,
td:last-child {
  padding-right: 16px;
}

tbody tr:last-child td {
  border-bottom: 0;
}

/* Editable cells: the input fills the cell; hover lightens it, the active cell gets a
   petrol frame like the selected cell in Excel */
td .input {
  height: 40px;
  padding: 0 10px;
  border: 2px solid transparent;
  border-radius: 0;
  background-color: transparent;
  box-shadow: none;
  cursor: text;
}

td select.input {
  cursor: pointer;
}

td .input:hover {
  border-color: transparent;
  background-color: var(--hover-cell);
}

td .input:focus {
  border-color: var(--accent-text);
  background-color: var(--surface);
  outline: none;
  box-shadow: none;
}

td select.input {
  padding-right: 28px;
  background-position: calc(100% - 16px) 50%, calc(100% - 12px) 50%;
}

td .input.readonly {
  color: var(--ink-3);
  font-size: 12px;
  text-overflow: ellipsis;
}

/* Not editable: the contact ID and the fields of deleted rows read as plain text */
td .input.readonly,
td .input.readonly:hover,
td .input:disabled,
td .input:disabled:hover {
  border-color: transparent;
  background-color: transparent;
  cursor: default;
}

.row-status {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink-2);
  font-size: 13px;
  white-space: nowrap;
}

tr.dirty td {
  background-image: linear-gradient(var(--tint-changed), var(--tint-changed));
}

tr.dirty td:first-child {
  box-shadow: inset 2px 0 0 var(--changed), inset -1px 0 0 var(--line);
}

tr:has(.row-select:checked) td {
  background-image: linear-gradient(var(--tint-selected), var(--tint-selected));
}

tr.dirty .dot {
  background: var(--changed);
}

td .input.edited,
td .input.edited:hover {
  background-color: var(--tint-edited);
}

tr.new td {
  background-image: linear-gradient(var(--tint-new), var(--tint-new));
}

tr.new td:first-child {
  box-shadow: inset 2px 0 0 var(--new), inset -1px 0 0 var(--line);
}

tr.new .dot {
  background: var(--new);
}

tr.incomplete .dot {
  background: var(--danger);
}

/* Missing or wrong values: a line under the cell, like an error marker in a spreadsheet */
td .input.required-missing,
td .input.invalid {
  box-shadow: inset 0 -2px 0 var(--danger);
}

td .input.warning {
  box-shadow: inset 0 -2px 0 var(--warning);
}

td .input.required-missing:focus,
td .input.invalid:focus {
  border-color: var(--danger);
}

tr.deleted td {
  background-image: linear-gradient(var(--tint-deleted), var(--tint-deleted));
}

tr.deleted td:first-child {
  box-shadow: inset 2px 0 0 var(--danger), inset -1px 0 0 var(--line);
}

tr.deleted .dot {
  background: var(--danger);
}

tr.deleted td .input {
  color: var(--ink-3);
  text-decoration: line-through;
}

.row-actions {
  white-space: nowrap;
}

.row-actions .text-button + .text-button {
  margin-left: 12px;
}

.delete-row,
.revert-row {
  color: var(--ink-3);
}

.revert-row:hover {
  color: var(--ink);
}

.delete-row:hover {
  color: var(--danger);
}

tr.deleted .delete-row:hover {
  color: var(--ink);
}

.empty {
  height: 160px;
  color: var(--ink-3);
  text-align: center;
}

/* A single honeycomb ring above the empty-state text */
.empty::before {
  content: "";
  display: block;
  width: 28px;
  height: 24px;
  margin: 0 auto 12px;
  background: var(--line-strong);
  clip-path: path(evenodd, "M7 0H21L28 12L21 24H7L0 12Z M8.2 2H19.8L25.6 12L19.8 22H8.2L2.4 12Z");
}

.bulk-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}

.bulk-count {
  margin-right: 8px;
  font-weight: 500;
}

.bulk-field {
  width: 160px;
}

.bulk-value {
  width: 280px;
}

.bulk-bar .text-button {
  margin-left: 8px;
}

.btn.compact {
  height: 32px;
}

.table-hint {
  padding: 8px 16px;
  border-top: 1px solid var(--line);
  color: var(--ink-3);
  font-size: 12px;
}

/* ---- Footer ------------------------------------------------------------------ */

.site-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 24px;
  margin-top: 32px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  color: var(--ink-3);
  font-size: 12px;
}

.footer-links {
  display: flex;
  gap: 20px;
}

.header-link {
  white-space: nowrap;
}

/* ---- Start page ------------------------------------------------------------- */

.landing {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 48px;
  align-items: center;
  min-height: calc(100vh - 160px);
  padding: 24px 0 48px;
}

.landing h2 {
  max-width: 560px;
  font-size: 36px;
  line-height: 44px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.landing-lead {
  max-width: 520px;
  margin-top: 16px;
  color: var(--ink-2);
  font-size: 16px;
  line-height: 24px;
}

.landing-notice {
  max-width: 520px;
  margin-top: 16px;
  padding: 8px 12px;
  border-radius: var(--radius-control);
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink-2);
}

.landing-notice.error {
  border-color: var(--danger);
  background: var(--danger-soft);
  color: var(--danger);
}

.landing-actions {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-top: 32px;
}

.btn.large {
  height: 44px;
  padding: 0 20px;
  font-size: 15px;
}

.text-link {
  color: var(--accent-text);
  text-decoration: none;
}

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

.landing-points {
  display: grid;
  gap: 16px;
  max-width: 520px;
  margin: 40px 0 0;
  padding: 24px 0 0;
  border-top: 1px solid var(--line-strong);
  list-style: none;
}

.landing-points li {
  display: grid;
  gap: 2px;
}

.landing-points strong {
  font-weight: 500;
}

.landing-points span {
  color: var(--ink-2);
}

.landing-access {
  max-width: 520px;
  margin-top: 24px;
  padding: 16px 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  background: var(--surface);
}

.landing-access h3 {
  font-size: 15px;
  font-weight: 500;
}

.landing-access ol {
  display: grid;
  gap: 8px;
  margin: 8px 0 0;
  padding-left: 20px;
  color: var(--ink-2);
}

.landing-access p {
  margin-top: 8px;
  color: var(--ink-2);
}

.landing-provider {
  max-width: 520px;
  margin-top: 24px;
  color: var(--ink-3);
  font-size: 13px;
}

.landing-notice code {
  font-size: 13px;
  word-break: break-all;
}

/* The one rich moment: the product's own table, as a quiet preview */
/* The honeycomb sits behind the preview card and peeks out at the top right */
.landing-visual {
  position: relative;
}

.honeycomb {
  position: absolute;
  top: -132px;
  right: -16px;
  width: 480px;
  height: auto;
  pointer-events: none;
}

.honeycomb .hc {
  fill: none;
  stroke: var(--line-strong);
  stroke-width: 1.5;
}

.honeycomb .accent {
  stroke: var(--accent-text);
  opacity: 0.45;
}

.honeycomb .faint {
  opacity: 0.5;
}

.honeycomb .brand {
  stroke: var(--brand-red);
  stroke-width: 2;
  opacity: 0.55;
}

.landing-preview {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow-raised);
  font-size: 13px;
}

.preview-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}

.preview-meta {
  margin-left: auto;
  color: var(--ink-3);
}

.preview-row {
  display: grid;
  grid-template-columns: 8px 80px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}

.preview-row .dot,
.preview-head .dot {
  align-self: center;
}

.preview-status {
  color: var(--ink-3);
}

.preview-row .mono {
  color: var(--ink-2);
  font-size: 12px;
}

.preview-row del {
  margin-right: 4px;
  color: var(--ink-3);
}

.preview-row.changed {
  background: var(--tint-changed);
  box-shadow: inset 2px 0 0 var(--changed);
}

.preview-row.deleted {
  background: var(--tint-deleted);
  box-shadow: inset 2px 0 0 var(--danger);
}

.preview-row.deleted span:nth-child(n + 3) {
  color: var(--ink-3);
  text-decoration: line-through;
}

.dot.ok,
.dot.new { background: var(--new); }
.dot.changed { background: var(--changed); }
.dot.deleted { background: var(--danger); }

.preview-foot {
  display: flex;
  justify-content: flex-end;
  padding: 12px 16px;
  background: var(--surface-2);
}

.preview-button {
  padding: 6px 12px;
  border-radius: var(--radius-control);
  background: var(--accent);
  color: #ffffff;
  font-weight: 600;
}

/* ---- Setup help ---------------------------------------------------------------- */

.setup-help {
  max-width: 720px;
  padding: 24px;
}

.setup-help h2 {
  font-size: 16px;
  line-height: 24px;
  font-weight: 600;
}

.setup-help p {
  margin-top: 4px;
  color: var(--ink-2);
}

.setup-help ol {
  margin: 12px 0 0;
  padding-left: 20px;
  color: var(--ink);
}

.setup-help li + li {
  margin-top: 4px;
}

.setup-help-actions {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-top: 20px;
}

/* ---- Support page --------------------------------------------------------------- */

.doc-shell {
  max-width: 880px;
}

.product-link {
  color: inherit;
  text-decoration: none;
}

.doc {
  padding: 32px 40px 40px;
}

.doc h2 {
  font-size: 24px;
  line-height: 32px;
  font-weight: 600;
}

.doc-lead {
  margin-top: 8px;
  color: var(--ink-2);
  font-size: 15px;
  line-height: 24px;
}

.doc section {
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}

.doc h3 {
  margin: 0 0 8px;
  font-size: 15px;
  font-weight: 600;
}

.doc p,
.doc li {
  color: var(--ink-2);
  line-height: 22px;
}

.doc p + p,
.doc ul + p,
.doc ol + p {
  margin-top: 8px;
}

.doc ol,
.doc ul {
  margin: 8px 0 0;
  padding-left: 20px;
}

.doc a {
  color: var(--accent-text);
}

.doc-toc {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  margin-top: 20px;
}

.doc-toc a {
  color: var(--accent-text);
  font-size: 13px;
  text-decoration: none;
}

.doc-toc a:hover {
  text-decoration: underline;
}

.doc section {
  scroll-margin-top: 24px;
}

.doc ul.doc-states {
  padding-left: 0;
  list-style: none;
}

.doc-states li {
  display: flex;
  align-items: center;
  gap: 10px;
}

.doc-states li + li {
  margin-top: 4px;
}

.doc code {
  padding: 0 4px;
  border-radius: 4px;
  background: var(--surface-2);
  font-size: 12px;
}

/* ---- Dialog ------------------------------------------------------------------ */

.dialog {
  width: min(640px, calc(100vw - 32px));
  max-height: calc(100vh - 64px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-raised);
}

.dialog::backdrop {
  background: var(--backdrop);
}

.dialog[open] {
  animation: dialog-in 160ms var(--ease);
}

@keyframes dialog-in {
  from { opacity: 0; transform: translateY(4px); }
}

.dialog form {
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 66px);
}

.dialog h2 {
  padding: 20px 24px 8px;
  font-size: 17px;
  line-height: 24px;
  font-weight: 600;
}

.dialog-body {
  overflow: auto;
  padding: 0 24px 16px;
  color: var(--ink-2);
}

.dialog-body > p + * {
  margin-top: 12px;
}

.dialog-note {
  margin-top: 12px;
  color: var(--danger);
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 16px 24px;
  border-top: 1px solid var(--line);
}

.btn.primary.danger {
  border-color: var(--danger-strong);
  background: var(--danger-strong);
}

.btn.primary.danger:hover {
  border-color: var(--danger-hover);
  background: var(--danger-hover);
}

.dialog.wide {
  width: min(760px, calc(100vw - 32px));
}

.history-list {
  margin: 12px 0;
  padding: 0;
  list-style: none;
}

.history-day {
  padding: 16px 0 4px;
  color: var(--ink-3);
  font-size: 12px;
  font-weight: 500;
}

.history-day:first-child {
  padding-top: 0;
}

.history-entry {
  display: grid;
  grid-template-columns: 48px 8px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px solid var(--line);
}

.history-time {
  color: var(--ink-3);
  font-size: 12px;
}

.history-text {
  min-width: 0;
  color: var(--ink-2);
}

.history-text strong {
  color: var(--ink);
  font-weight: 500;
}

.history-person {
  color: var(--ink);
}

.history-id {
  font-size: 12px;
}

.history-failed {
  color: var(--danger);
}

.history-empty {
  padding: 16px 0;
  color: var(--ink-3);
}

.change-list {
  margin: 0;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  list-style: none;
}

.change {
  padding: 8px 12px;
}

.change + .change {
  border-top: 1px solid var(--line);
}

.change-head {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
}

.change-head strong {
  font-weight: 500;
}

.change-kind {
  width: 64px;
  color: var(--ink-3);
  font-size: 13px;
}

.change-create .dot { background: var(--new); }
.change-update .dot { background: var(--changed); }
.change-delete .dot { background: var(--danger); }

.change-line,
.change-warning {
  padding-left: 80px;
  font-size: 13px;
}

.change-label {
  color: var(--ink-3);
}

.change-line del {
  color: var(--ink-3);
}

.change-line ins {
  color: var(--ink);
  text-decoration: none;
}

.change-warning {
  color: var(--warning);
}

/* ---- Log -------------------------------------------------------------------- */

.log {
  margin-top: 16px;
  padding: 12px 16px;
}

.log h2 {
  margin-bottom: 8px;
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 600;
}

#logOutput {
  color: var(--ink-2);
  font-size: 12px;
  line-height: 20px;
  white-space: pre-wrap;
}

/* ---- Small screens ---------------------------------------------------------- */

@media (max-width: 920px) {
  .app-shell {
    padding: 16px 16px 32px;
  }

  .header {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .brand-logo {
    order: -1;
    align-self: flex-start;
  }

  .session {
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .auth-status {
    flex: 1 1 100%;
    text-align: left;
    overflow-wrap: anywhere;
  }

  .org-field,
  .contact-search {
    width: 100%;
    margin-left: 0;
  }

  .query,
  .csv-panel {
    grid-template-columns: 1fr;
  }

  .csv-controls {
    flex-wrap: wrap;
  }

  .edit .grow {
    display: none;
  }

  .contacts-head {
    flex-wrap: wrap;
  }

  .counts {
    margin-left: 0;
  }

  .table-wrap {
    max-height: none;
  }

  .landing {
    grid-template-columns: 1fr;
    gap: 32px;
    min-height: 0;
  }

  .honeycomb {
    display: none;
  }

  .landing h2 {
    font-size: 28px;
    line-height: 36px;
  }

  .preview-row {
    grid-template-columns: 8px 72px minmax(0, 1fr);
  }

  .preview-row .mono {
    display: none;
  }

  .doc {
    padding: 24px 20px;
  }
}
