/* public/styles.css
   Relay — internal enquiry & task dashboard.
   Strict dark palette from the brief; high-density Notion-style list view. */

/* ── Tokens ────────────────────────────────────────────────────────────────── */
:root {
  /* Brief palette */
  --bg: #0f172a;
  --sidebar: #111827;
  --card: #1e293b;
  --primary: #7c3aed;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --text: #f8fafc;
  --muted: #94a3b8;

  /* Derived surfaces */
  --card-hover: #243449;
  --raised: #243449;
  --line: rgba(148, 163, 184, 0.16); /* muted @ low alpha → hairlines */
  --line-strong: rgba(148, 163, 184, 0.28);
  --primary-2: #8b5cf6;
  --primary-press: #6d28d9;
  --field-bg: #0e1626;
  --shadow-lg: 0 18px 50px -12px rgba(0, 0, 0, 0.6);
  --shadow-md: 0 10px 30px -10px rgba(0, 0, 0, 0.55);

  /* Metrics */
  --side-w: 240px;
  --radius: 10px;
  --radius-sm: 7px;
  --radius-pill: 999px;

  /* Type */
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial,
    "Apple Color Emoji", "Segoe UI Emoji", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono",
    monospace;

  /* High-density table columns (desktop). Falls back to horizontal scroll on
     narrow desktops; collapses to cards on mobile. */
  --grid: minmax(180px, 1.7fr) 88px 116px minmax(190px, 2fr) 118px 96px 126px 92px 40px;
}

/* ── Reset / base ─────────────────────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body.modal-open {
  overflow: hidden;
}

[hidden] {
  display: none !important;
}

.mono {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

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

::selection {
  background: rgba(124, 58, 237, 0.4);
}

/* Scrollbars (WebKit) */
*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
*::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.22);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
*::-webkit-scrollbar-thumb:hover {
  background: rgba(148, 163, 184, 0.34);
  background-clip: padding-box;
}

/* ── Form controls (shared) ───────────────────────────────────────────────── */
input,
textarea,
select,
button {
  font: inherit;
  color: inherit;
}

input,
textarea,
select {
  width: 100%;
  background: var(--field-bg);
  color: var(--text);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input::placeholder,
textarea::placeholder {
  color: rgba(148, 163, 184, 0.7);
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--primary-2);
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.25);
}

input:disabled,
textarea:disabled,
select:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

textarea {
  resize: vertical;
  min-height: 84px;
}

select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 16px) calc(50% - 2px), calc(100% - 11px) calc(50% - 2px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 30px;
  cursor: pointer;
}

:focus-visible {
  outline: 2px solid var(--primary-2);
  outline-offset: 2px;
}

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  font-weight: 600;
  font-size: 13.5px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease, border-color 0.15s ease, opacity 0.15s ease,
    transform 0.05s ease;
}
.btn:active {
  transform: translateY(1px);
}
.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.btn-primary:hover {
  background: var(--primary-2);
  border-color: var(--primary-2);
}
.btn-primary:active {
  background: var(--primary-press);
}

.btn-ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--line-strong);
}
.btn-ghost:hover {
  background: rgba(148, 163, 184, 0.1);
}

.btn-ghost-danger {
  background: transparent;
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.4);
}
.btn-ghost-danger:hover {
  background: rgba(239, 68, 68, 0.12);
}

.btn-block {
  width: 100%;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  transition: background 0.15s ease, color 0.15s ease;
}
.icon-btn:hover {
  background: rgba(148, 163, 184, 0.12);
  color: var(--text);
}

.link-btn {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
  font-size: 12.5px;
  transition: color 0.15s ease, background 0.15s ease;
}
.link-btn:hover {
  color: var(--text);
  background: rgba(148, 163, 184, 0.1);
}

/* ── Fields ───────────────────────────────────────────────────────────────── */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.01em;
}
.field-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

/* ── Auth screen ──────────────────────────────────────────────────────────── */
.auth {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(1100px 520px at 50% -10%, rgba(124, 58, 237, 0.16), transparent 70%),
    var(--bg);
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 30px 28px 28px;
  box-shadow: var(--shadow-lg);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
}
.auth-mark,
.brand-mark {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: linear-gradient(140deg, var(--primary-2), var(--primary-press));
  box-shadow: 0 4px 14px -4px rgba(124, 58, 237, 0.7);
  flex: none;
}
.auth-name {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.auth-title {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.auth-sub {
  margin: 4px 0 22px;
  color: var(--muted);
  font-size: 13px;
}
.auth-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.auth-form .btn {
  margin-top: 4px;
  padding: 10px 14px;
}
.auth-error {
  color: var(--danger);
  font-size: 13px;
  min-height: 0;
}
.auth-error:not(:empty) {
  min-height: 18px;
}

/* ── App layout ───────────────────────────────────────────────────────────── */
.app {
  display: grid;
  grid-template-columns: var(--side-w) 1fr;
  height: 100vh;
  height: 100dvh;
}

/* ── Sidebar ──────────────────────────────────────────────────────────────── */
.sidebar {
  background: var(--sidebar);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 16px 14px;
  min-width: 0;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px 16px;
}
/*.brand-logo {
  width: 26px;
  height: 26px;
  border-radius: 6px; 
  object-fit: contain; 
  margin-right: 12px; 
}*/
.brand-name {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  transition: background 0.15s ease, color 0.15s ease;
}
.nav-item:hover {
  background: rgba(148, 163, 184, 0.08);
  color: var(--text);
}
.nav-item.active {
  background: rgba(124, 58, 237, 0.16);
  color: var(--text);
}
.nav-item.active .nav-ico {
  color: var(--primary-2);
}
.nav-ico {
  font-size: 14px;
  width: 16px;
  text-align: center;
  color: var(--muted);
}

.sidebar-foot {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.who {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 6px 10px;
}
.who-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(140deg, var(--primary-2), var(--primary-press));
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
  flex: none;
}
.who-meta {
  min-width: 0;
}
.who-name {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.who-role {
  font-size: 11.5px;
  color: var(--muted);
}
.foot-actions {
  display: flex;
  gap: 6px;
}

/* ── Scrim (mobile drawer backdrop) ───────────────────────────────────────── */
.scrim {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.6);
  z-index: 40;
  border: none;
  padding: 0;
}

/* ── Main / topbar ────────────────────────────────────────────────────────── */
.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}
.menu-toggle {
  display: none;
}
.title-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.page-title {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.new-btn {
  margin-left: auto;
}

.conn {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--warning);
  box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.5);
  flex: none;
}
.conn.live {
  background: var(--success);
  animation: pulse 2.4s ease-out infinite;
}
@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.5);
  }
  70% {
    box-shadow: 0 0 0 6px rgba(16, 185, 129, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
  }
}

/* ── Summary chips ────────────────────────────────────────────────────────── */
.summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 14px 20px 4px;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 11px;
  border-radius: var(--radius-pill);
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--muted);
  cursor: pointer;
  font-size: 12.5px;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}
.chip:hover {
  border-color: var(--line-strong);
  color: var(--text);
}
.chip-active {
  background: var(--raised);
  border-color: var(--primary-2);
  color: var(--text);
}
.chip-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: none;
}
.chip-count {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--text);
}

/* ── Controls ─────────────────────────────────────────────────────────────── */
.controls {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 20px;
  flex-wrap: wrap;
}
.search {
  position: relative;
  flex: 1;
  min-width: 200px;
  max-width: 420px;
}
.search-ico {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 15px;
  pointer-events: none;
}
.search input {
  padding-left: 32px;
}
.control-group {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.ctl {
  display: flex;
  align-items: center;
  gap: 7px;
}
.ctl-label {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}
.ctl select {
  width: auto;
  min-width: 116px;
  padding-top: 7px;
  padding-bottom: 7px;
}

.seg {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 3px;
}
.seg-label {
  padding: 0 6px 0 4px;
}
.seg-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 5px 11px;
  border-radius: 5px;
  font-size: 12.5px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.seg-btn:hover {
  color: var(--text);
}
.seg-btn.active {
  background: var(--primary);
  color: #fff;
}

/* ── List / table ─────────────────────────────────────────────────────────── */
.list-wrap {
  flex: 1;
  overflow: auto;
  padding: 6px 20px 28px;
}
.table {
  min-width: 940px; /* keep columns aligned; horizontal scroll if narrower */
}

.thead {
  display: grid;
  grid-template-columns: var(--grid);
  gap: 0 10px;
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--bg);
  padding: 8px 12px;
  border-bottom: 1px solid var(--line-strong);
}
.thead .cell {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.group {
  margin-top: 10px;
}
.group-head {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  background: transparent;
  border: none;
  color: var(--text);
  cursor: pointer;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  text-align: left;
}
.group-head:hover {
  background: rgba(148, 163, 184, 0.06);
}
.caret {
  font-size: 11px;
  color: var(--muted);
  transition: transform 0.15s ease;
  width: 12px;
}
.caret.is-collapsed {
  transform: rotate(-90deg);
}
.group-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex: none;
}
.group-label {
  font-size: 13px;
  font-weight: 600;
}
.group-count {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  padding: 1px 8px;
}

.group-rows {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 4px;
}

.trow {
  display: grid;
  grid-template-columns: var(--grid);
  gap: 0 10px;
  align-items: center;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background-color: var(--card);
  background-image: linear-gradient(var(--tint, transparent), var(--tint, transparent));
  box-shadow: inset 3px 0 0 0 var(--edge, transparent);
  cursor: pointer;
  transition: background-color 0.12s ease;
}
.trow:hover {
  background-color: var(--card-hover);
}
.trow.is-canceled .tname,
.trow.is-canceled .desc {
  text-decoration: line-through;
  text-decoration-color: rgba(148, 163, 184, 0.5);
  color: var(--muted);
}

.cell {
  min-width: 0;
}

.c-name {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.tname {
  font-weight: 600;
  font-size: 13.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tcode {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tag {
  display: inline-block;
  font-size: 11.5px;
  color: var(--text);
  background: rgba(148, 163, 184, 0.14);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 1px 8px;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.c-contact {
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.desc {
  display: block;
  color: var(--muted);
  font-size: 12.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.c-due {
  font-size: 12.5px;
  color: var(--text);
  white-space: nowrap;
}
.c-due.overdue {
  color: var(--danger);
}
.overdue-flag {
  display: inline-block;
  font-family: var(--sans);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--danger);
  background: rgba(239, 68, 68, 0.14);
  border-radius: 4px;
  padding: 0 5px;
  margin-left: 4px;
  vertical-align: 1px;
}

.c-updated {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.c-actions {
  display: flex;
  justify-content: flex-end;
}
.row-more {
  width: 28px;
  height: 28px;
  font-size: 16px;
}

/* Pills */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  padding: 3px 9px;
  white-space: nowrap;
  max-width: 100%;
}
.pill-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}
.pill-btn {
  cursor: pointer;
  transition: filter 0.15s ease;
}
.pill-btn:hover {
  filter: brightness(1.15);
}
.pill-caret {
  font-size: 9px;
  opacity: 0.8;
  margin-left: 1px;
}

/* Empty state */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
  padding: 64px 20px;
  color: var(--muted);
}
.empty-mark {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  background: var(--card);
  border: 1px solid var(--line-strong);
  position: relative;
}
.empty-mark::before {
  content: "▤";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 20px;
}
.empty-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}
.empty-body {
  font-size: 13px;
  max-width: 320px;
}
.empty .btn {
  margin-top: 6px;
}

/* Row flash on live update */
.trow.flash {
  animation: rowflash 1.4s ease-out;
}
@keyframes rowflash {
  0% {
    background-color: rgba(124, 58, 237, 0.32);
  }
  100% {
    background-color: var(--card);
  }
}

/* ── Popover menus ────────────────────────────────────────────────────────── */
.popover {
  position: fixed;
  z-index: 60;
  min-width: 184px;
  background: var(--raised);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 5px;
  animation: pop 0.12s ease-out;
}
@keyframes pop {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.pop-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  background: transparent;
  border: none;
  color: var(--text);
  cursor: pointer;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 13px;
  text-align: left;
}
.pop-item:hover {
  background: rgba(148, 163, 184, 0.12);
}
.pop-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: none;
}
.pop-check {
  margin-left: auto;
  color: var(--primary-2);
  font-size: 12px;
}
.pop-item.is-current {
  color: var(--text);
}
.pop-danger {
  color: var(--danger);
}
.pop-danger:hover {
  background: rgba(239, 68, 68, 0.12);
}

/* ── Modals ───────────────────────────────────────────────────────────────── */
#modal-root {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 20px;
}
.modal-scrim {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.66);
  backdrop-filter: blur(2px);
}
.modal {
  position: relative;
  width: 100%;
  max-width: 600px;
  max-height: calc(100dvh - 40px);
  overflow: auto;
  background: var(--card);
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  animation: modalin 0.16s ease-out;
}
.modal-sm {
  max-width: 420px;
}
@keyframes modalin {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.99);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}
.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px 12px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: var(--card);
  z-index: 1;
}
.modal-title {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.01em;
  word-break: break-word;
}
.modal-sub {
  display: block;
  margin-top: 3px;
  font-size: 12px;
  color: var(--muted);
}
.modal-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px 20px 20px;
}
.modal-error {
  color: var(--danger);
  font-size: 13px;
  min-height: 0;
}
.modal-error:not(:empty) {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 7px;
  padding: 8px 10px;
}
.modal-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 4px;
}
.foot-right {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

/* ── Toasts ───────────────────────────────────────────────────────────────── */
.toast-root {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: min(360px, calc(100vw - 36px));
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--raised);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 11px 14px 11px 12px;
  font-size: 13px;
  color: var(--text);
  overflow: hidden;
  opacity: 0;
  transform: translateX(16px);
  transition: opacity 0.22s ease, transform 0.22s ease;
}
.toast.show {
  opacity: 1;
  transform: translateX(0);
}
.toast-bar {
  width: 3px;
  align-self: stretch;
  border-radius: 3px;
  flex: none;
}

/* ── Responsive: tablet ───────────────────────────────────────────────────── */
@media (max-width: 1040px) {
  .field-row {
    grid-template-columns: 1fr 1fr;
  }
}

/* ── Responsive: mobile (drawer + card rows) ──────────────────────────────── */
@media (max-width: 880px) {
  .app {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 264px;
    max-width: 84vw;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open {
    transform: translateX(0);
  }

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

  .new-btn {
    padding-left: 11px;
    padding-right: 11px;
  }

  .list-wrap {
    padding: 6px 12px 24px;
  }

  /* Table → stacked cards */
  .table {
    min-width: 0;
  }
  .thead {
    display: none;
  }
  .group-rows {
    gap: 8px;
  }

  .trow {
    display: block;
    position: relative;
    padding: 12px 14px;
    box-shadow: inset 3px 0 0 0 var(--edge, transparent);
    border: 1px solid var(--line);
  }

  .cell {
    display: flex;
    align-items: baseline;
    gap: 12px;
    padding: 3px 0;
  }
  .cell[data-label]::before {
    content: attr(data-label);
    flex: none;
    width: 84px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
  }

  /* Name becomes the card title (no label, full width) */
  .c-name {
    display: block;
    padding-right: 40px;
    margin-bottom: 6px;
  }
  .tname {
    white-space: normal;
    font-size: 15px;
  }
  .tcode {
    white-space: normal;
  }

  .c-contact,
  .desc {
    white-space: normal;
  }
  .desc {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  /* Actions pinned to the card corner */
  .c-actions {
    position: absolute;
    top: 10px;
    right: 10px;
    padding: 0;
  }

  .field-row {
    grid-template-columns: 1fr;
  }

  .toast-root {
    left: 12px;
    right: 12px;
    bottom: 12px;
    max-width: none;
  }
}

@media (max-width: 420px) {
  .summary {
    padding: 12px 12px 2px;
  }
  .controls {
    padding: 12px;
  }
  .topbar {
    padding: 12px;
  }
}

/* ── Reduced motion ───────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .conn.live {
    animation: none;
  }
}
