/* KruxCRM design system.
 * One file so cascade order stays deterministic under propshaft.
 * Sections: tokens, base, app shell, auth pages, components, admin, utilities.
 */

/* ---------- Tokens ---------- */

:root {
  --font-sans: ui-sans-serif, -apple-system, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;

  --color-bg: #ffffff;
  --color-surface: #fafaf9;
  --color-raised: #f4f4f2;
  --color-border: #ececeb;
  --color-border-strong: #dededd;
  --color-text: #171717;
  --color-text-secondary: #52525b;
  --color-text-muted: #8f8f8f;

  --color-accent: #ff5334;
  --color-accent-soft: #fff1ec;
  --color-ink: #171717;
  --color-ink-hover: #000000;

  --color-green: #1d7d47;
  --color-green-soft: #e8f6ee;
  --color-orange: #c2410c;
  --color-orange-soft: #fff1e2;
  --color-red: #c02626;
  --color-red-soft: #fdecec;
  --color-blue: #1d4fd7;
  --color-blue-soft: #eaf0fe;
  --color-gray-soft: #f1f1f0;

  /* Deliberately tight radii — the app reads square, per the Ayro reference. */
  --radius-sm: 4px;
  --radius: 6px;
  --radius-lg: 8px;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .05);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, .08);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, .14);

  --sidebar-width: 264px;
  --topbar-height: 68px;
}

/* ---------- Base ---------- */

*, *::before, *::after { box-sizing: border-box; }

/* Keep the hidden attribute authoritative even on elements whose class sets
 * a display (e.g. .bulk-bar's flex) — author display rules beat the UA's
 * [hidden] default otherwise. */
[hidden] { display: none !important; }

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

h1, h2, h3, h4 { margin: 0 0 .5rem; font-weight: 650; letter-spacing: -0.01em; }
h1 { font-size: 28px; }
h2 { font-size: 20px; }
h3 { font-size: 16px; }
p { margin: 0 0 1rem; }
a { color: inherit; }
img { max-width: 100%; }

.icon { flex-shrink: 0; }

/* ---------- Gradient strip (Ayro signature) ---------- */

.gradient-strip {
  height: 5px;
  background: linear-gradient(90deg, #64c8bc 0%, #e8e4d8 35%, #f0b6a0 65%, #ff5334 100%);
}

/* ---------- App shell ---------- */

/* The app lives in a centered container, not full-bleed: white column on a
   soft canvas, hairline edges where it meets the background. */
body.app { background: #f3f3f1; }

/* App pages: a photographic canvas behind the centered white shell. A fixed
   pseudo-element keeps the image viewport-sized and crisp on tall, scrolling
   pages (background-attachment: fixed is unreliable on iOS). */
body.app::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background: url("/assets/app_snowymountains_bg_dark-37d66a01.png") center / cover no-repeat;
}

.shell {
  display: flex;
  min-height: calc(100vh - 29px);
  max-width: 1440px;
  margin: 24px auto 0;
  background: var(--color-bg);
  border: 1px solid var(--color-border-strong);
  border-bottom: 0;
  /* Lifted off the photo: a crisper drop shadow keeps the white column
     legible where it meets the mountains. */
  box-shadow: 0 -2px 8px rgba(20, 30, 25, .05), 0 16px 54px rgba(20, 30, 25, .22);
}

.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  padding: 20px 16px;
  border-right: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  height: calc(100vh - 5px);
  overflow-y: auto;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px 22px;
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.02em;
  text-decoration: none;
}

.brand-mark {
  width: 30px; height: 30px;
  display: grid; place-items: center;
  background: var(--color-ink);
  color: #fff;
  border-radius: 6px;
  font-size: 19px;
  font-weight: 700;
  line-height: 1;
}
img.brand-mark { background: transparent; object-fit: contain; }

.sidebar-nav { display: flex; flex-direction: column; gap: 2px; }

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border-radius: var(--radius);
  color: var(--color-text-secondary);
  text-decoration: none;
  font-size: 14.5px;
  font-weight: 500;
  border: 1px solid transparent;
}
.nav-link:hover { background: var(--color-surface); color: var(--color-text); }
.nav-link-active {
  background: var(--color-raised);
  border-color: var(--color-border);
  color: var(--color-text);
  font-weight: 600;
}
.nav-link .nav-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--color-accent);
  margin-left: auto;
}
.nav-link .nav-count {
  margin-left: auto;
  font-size: 12px;
  font-weight: 600;
  background: var(--color-accent);
  color: #fff;
  border-radius: 99px;
  padding: 1px 7px;
}

.user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
}
.user-card-info { min-width: 0; flex: 1; }
.user-card-name { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-card-role { font-size: 12.5px; color: var(--color-text-muted); text-transform: capitalize; }

.topbar-user { height: 38px; padding: 4px 6px 4px 5px; border-radius: var(--radius); }
.topbar-user .user-card-name { font-size: 13px; line-height: 1.25; }
.topbar-user .user-card-role { font-size: 11px; line-height: 1.2; }
.topbar-user .user-card-name a { text-decoration: none; }
.topbar-user .user-card-name a:hover { text-decoration: underline; }
.user-card form { display: flex; }
.user-card button {
  border: 0; background: none; padding: 6px; cursor: pointer;
  color: var(--color-text-muted); border-radius: var(--radius-sm);
}
.user-card button:hover { color: var(--color-text); background: var(--color-raised); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 28px;
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(6px);
  z-index: 20;
}

.topbar-search { flex: 1; max-width: 560px; display: flex; align-items: center; gap: 10px; color: var(--color-text-muted); }
.topbar-search input {
  border: 0; outline: 0; flex: 1;
  font: inherit; font-size: 15px;
  background: transparent;
  color: var(--color-text);
}
.topbar-search input::placeholder { color: var(--color-text-muted); }

.topbar-actions { margin-left: auto; display: flex; gap: 8px; }

.icon-button {
  display: grid; place-items: center;
  width: 38px; height: 38px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: #fff;
  color: var(--color-text-secondary);
  cursor: pointer;
  text-decoration: none;
  position: relative;
}
.icon-button:hover { background: var(--color-surface); color: var(--color-text); }
.row-actions { display: inline-flex; gap: 6px; align-items: center; }
.row-actions .row-action-form { display: inline-flex; }
.icon-button-sm { width: 30px; height: 30px; border-radius: var(--radius-sm); }
.icon-button-danger:hover { color: var(--color-red); background: var(--color-red-soft); border-color: #f3c8c8; }

.icon-button .badge-dot {
  position: absolute; top: 7px; right: 7px;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--color-accent);
}

.content { padding: 28px 32px 48px; max-width: 1280px; width: 100%; background: #fafafa; flex: 1; }

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.page-header h1 { margin: 0; }
.page-header .page-sub { color: var(--color-text-muted); font-size: 14px; margin-top: 2px; }
.page-actions { display: flex; gap: 10px; align-items: center; }

/* ---------- Auth pages ---------- */

body.auth { background: var(--color-surface); }
/* Scenic backdrop behind the auth card, rotated per page load via --auth-bg
   (set inline on <body>, see auth_background_style) — same fixed-layer
   technique as body.app (background-attachment: fixed is unreliable on iOS). */
body.auth::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background: var(--auth-bg, url("/assets/app_snowymountains_bg_dark-37d66a01.png")) center / cover no-repeat;
}

.auth-wrap {
  min-height: calc(100vh - 5px);
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  padding: 36px;
  box-shadow: var(--shadow-sm);
}
.auth-brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; margin-bottom: 24px; }
.auth-card h1 { font-size: 22px; margin-bottom: 4px; }
.auth-card .auth-sub { color: var(--color-text-muted); font-size: 14px; margin-bottom: 24px; }
.auth-links { margin-top: 18px; font-size: 14px; color: var(--color-text-muted); text-align: center; }
.auth-links a { color: var(--color-text); }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background .12s ease, border-color .12s ease;
}
.btn-primary { background: var(--color-ink); color: #fff; }
.btn-primary:hover { background: var(--color-ink-hover); }
.btn-secondary { background: #fff; border-color: var(--color-border-strong); color: var(--color-text); }
.btn-secondary:hover { background: var(--color-surface); }
.btn-accent { background: var(--color-accent); color: #fff; }
.btn-accent:hover { filter: brightness(.95); }
.btn-danger { background: #fff; border-color: var(--color-border-strong); color: var(--color-red); }
.btn-danger:hover { background: var(--color-red-soft); border-color: var(--color-red); }
.btn-ghost { background: transparent; color: var(--color-text-secondary); }
.btn-ghost:hover { background: var(--color-raised); color: var(--color-text); }
.btn-sm { padding: 5px 10px; font-size: 13px; border-radius: var(--radius-sm); }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .5; pointer-events: none; }

/* ---------- Forms ---------- */

.field { margin-bottom: 16px; }
.field label, .field .label {
  display: block;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--color-text-secondary);
  margin-bottom: 6px;
}
.field .hint { font-size: 12.5px; color: var(--color-text-muted); margin-top: 5px; }

input[type="text"], input[type="email"], input[type="password"], input[type="search"],
input[type="date"], input[type="datetime-local"], input[type="number"], input[type="tel"],
input[type="url"], select, textarea {
  width: 100%;
  padding: 9px 12px;
  font: inherit;
  font-size: 14.5px;
  color: var(--color-text);
  background: #fff;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius);
  outline: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--color-text);
  box-shadow: 0 0 0 3px rgba(23, 23, 23, .07);
}
input:disabled, select:disabled, textarea:disabled {
  background: var(--color-gray-soft);
  color: var(--color-text-secondary);
  cursor: not-allowed;
}
textarea { resize: vertical; min-height: 96px; }
select { appearance: auto; }

.checkbox-field { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; }
.checkbox-field label { margin: 0; font-weight: 500; font-size: 14px; }
input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--color-ink); }

.form-errors {
  background: var(--color-red-soft);
  border: 1px solid #f3c8c8;
  color: var(--color-red);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 18px;
  font-size: 14px;
}
.form-errors ul { margin: 0; padding-left: 18px; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-actions { display: flex; gap: 10px; align-items: center; margin-top: 22px; }

/* ---------- Tables ---------- */

.table-wrap {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow-x: auto;
  background: #fff;
}
table.table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.table th {
  text-align: left;
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-muted);
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface);
  white-space: nowrap;
}
.table td { padding: 14px 16px; border-bottom: 1px solid var(--color-border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--color-surface); }
.table tbody tr[data-controller~="rowlink"] { cursor: pointer; }
.table .cell-main { display: flex; align-items: center; gap: 12px; text-decoration: none; }
.table .cell-title { font-weight: 600; color: var(--color-text); }
.table .cell-sub { font-size: 13px; color: var(--color-text-muted); }
.table .cell-muted { color: var(--color-text-muted); }
.table .cell-actions { text-align: right; white-space: nowrap; }
.row-link { text-decoration: none; }

.table-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 4px;
  color: var(--color-text-muted);
  font-size: 14px;
}
.pagination { display: flex; gap: 4px; align-items: center; }
.pagination a, .pagination .page-current, .pagination .page-gap {
  display: grid; place-items: center;
  min-width: 32px; height: 32px; padding: 0 6px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  font-size: 13.5px;
  color: var(--color-text-secondary);
}
.pagination a:hover { background: var(--color-raised); }
.pagination .page-current { background: var(--color-ink); color: #fff; font-weight: 600; }

/* ---------- Badges, tags, avatars ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12.5px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 4px;
  white-space: nowrap;
}
.badge-green { background: var(--color-green-soft); color: var(--color-green); }
.badge-orange { background: var(--color-orange-soft); color: var(--color-orange); }
.badge-red { background: var(--color-red-soft); color: var(--color-red); }
.badge-blue { background: var(--color-blue-soft); color: var(--color-blue); }
.badge-gray { background: var(--color-gray-soft); color: var(--color-text-secondary); }
.badge-accent { background: var(--color-accent-soft); color: var(--color-accent); }

.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12.5px;
  font-weight: 500;
  padding: 2px 9px;
  border-radius: 4px;
  background: var(--color-gray-soft);
  color: var(--color-text-secondary);
  text-decoration: none;
}
.tag-chip:hover { background: var(--color-border); }
.tag-chip a { color: inherit; text-decoration: none; }
.tag-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-chip-remove-form { display: contents; }
.tag-chip-remove {
  background: none;
  border: none;
  padding: 0 0 0 2px;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  color: var(--color-text-secondary);
}
.tag-chip-remove:hover { color: var(--color-red); }
.tag-add-form { display: flex; gap: 6px; }
.tag-add-form input { flex: 1; min-width: 0; }
.tag-error { color: var(--color-red); }

.avatar {
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  font-weight: 600;
  color: #fff;
  flex-shrink: 0;
  user-select: none;
}
.avatar-hue-0 { background: #6366f1; }
.avatar-hue-1 { background: #0d9488; }
.avatar-hue-2 { background: #d97706; }
.avatar-hue-3 { background: #db2777; }
.avatar-hue-4 { background: #7c3aed; }
.avatar-hue-5 { background: #059669; }
.avatar-hue-6 { background: #dc2626; }
.avatar-hue-7 { background: #2563eb; }

/* ---------- Cards & panels ---------- */

.card {
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 20px;
}
.card-title { font-size: 13px; font-weight: 600; color: var(--color-text-muted); margin-bottom: 10px; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; margin-bottom: 24px; }
/* Dashboard stat row: all five cards on one line at desktop width, folding to
   2-up then 1-up on narrower screens (base .card-grid is shared elsewhere). */
.card-grid.dashboard-stats { grid-template-columns: repeat(5, 1fr); }
@media (max-width: 1280px) { .card-grid.dashboard-stats { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px) { .card-grid.dashboard-stats { grid-template-columns: 1fr; } }
.stat-number { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }
.stat-sub { font-size: 13px; color: var(--color-text-muted); }

.panel-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; align-items: start; }
.panel-grid-wide-aside { grid-template-columns: 3fr 2fr; }
@media (max-width: 900px) { .panel-grid { grid-template-columns: 1fr; } }

.dl-grid { display: grid; grid-template-columns: auto 1fr; gap: 8px 18px; font-size: 14px; margin: 0; }
.dl-grid dt { color: var(--color-text-muted); }
.dl-grid dd { margin: 0; text-align: right; font-weight: 500; overflow-wrap: anywhere; }

.empty-state {
  text-align: center;
  padding: 56px 24px;
  color: var(--color-text-muted);
  border: 1px dashed var(--color-border-strong);
  border-radius: var(--radius-lg);
}
.empty-state .icon { margin-bottom: 10px; color: var(--color-text-muted); }
.empty-state h3 { color: var(--color-text); }

/* ---------- Flash / toasts ---------- */

.flash-stack {
  position: fixed;
  top: 16px; right: 16px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 380px;
}
.flash {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 12px 14px;
  font-size: 14px;
  box-shadow: var(--shadow-md);
}
.flash-notice { border-left: 3px solid var(--color-green); }
.flash-alert { border-left: 3px solid var(--color-red); }
.flash button { border: 0; background: none; cursor: pointer; color: var(--color-text-muted); padding: 0; margin-left: auto; }

/* ---------- Dropdown menus ---------- */

details.menu { position: relative; }
details.menu summary { list-style: none; cursor: pointer; }
details.menu summary::-webkit-details-marker { display: none; }
.menu-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 180px;
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  z-index: 50;
}
.menu-panel a, .menu-panel button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  font: inherit;
  font-size: 14px;
  color: var(--color-text);
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}
.menu-panel a:hover, .menu-panel button:hover { background: var(--color-surface); }
.menu-panel .menu-danger { color: var(--color-red); }

/* ---------- Filter bar ---------- */

.filter-bar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.filter-bar input[type="search"].filter-q { flex: 1; min-width: 200px; }
.filter-bar select { width: auto; }

/* ---------- Timeline ---------- */

.timeline { display: flex; flex-direction: column; }
.timeline-item {
  display: flex;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--color-border);
}
.timeline-item:last-child { border-bottom: 0; }
.timeline-icon {
  width: 30px; height: 30px;
  display: grid; place-items: center;
  flex-shrink: 0;
  border: 1px solid var(--color-border);
  border-radius: 50%;
  background: #fff;
  color: var(--color-text-secondary);
}
.timeline-body { flex: 1; min-width: 0; }
.timeline-text { font-size: 14.5px; }
.timeline-note {
  margin-top: 8px;
  background: #fffbeb;
  border: 1px solid #f3e8c0;
  border-radius: var(--radius);
  padding: 12px 14px;
  font-size: 14.5px;
}
.timeline-note .trix-content p:last-of-type, .timeline-note p:last-of-type { margin-bottom: 0; }
.timeline-note form { margin-top: 6px; }

/* ---------- Lexxy editor fit ---------- */

lexxy-editor {
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius);
  font-size: 14.5px;
}
lexxy-editor:focus-within {
  border-color: var(--color-text);
  box-shadow: 0 0 0 3px rgba(23, 23, 23, .07);
}

/* ---------- Tabs ---------- */

.tab-bar {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 18px;
}
.tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 14px;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text-muted);
  text-decoration: none;
  border: 0;
  background: none;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tab:hover { color: var(--color-text); }
.tab-active { color: var(--color-text); border-bottom-color: var(--color-ink); }

/* ---------- Inbox list ---------- */

.convo-list {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: #fff;
  overflow: hidden;
}
.convo-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 14px 18px 14px 12px;
  border-bottom: 1px solid var(--color-border);
  text-decoration: none;
}
.convo-row:last-child { border-bottom: 0; }
.convo-row:hover { background: var(--color-surface); }
.convo-row.kbd-focus { background: var(--color-raised); box-shadow: inset 3px 0 0 var(--color-accent); }
.convo-link { display: flex; gap: 14px; align-items: flex-start; flex: 1; min-width: 0; text-decoration: none; }
.convo-check { display: flex; align-items: center; padding-top: 9px; }

.bulk-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  margin-bottom: 10px;
  background: var(--color-raised);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
}
.bulk-count { font-size: 13.5px; font-weight: 600; }
.table .cell-check { width: 1%; }
.cell-check label { display: flex; padding: 6px; margin: -6px; cursor: pointer; }
.bulk-sep { width: 1px; height: 22px; background: var(--color-border-strong); }
.bulk-bar select { width: auto; padding: 5px 8px; font-size: 13px; }

.system-line {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--color-text-muted);
  padding: 2px 8px;
}
.convo-main { flex: 1; min-width: 0; }
.convo-top { display: flex; justify-content: space-between; gap: 10px; }
.convo-name { font-weight: 600; font-size: 14.5px; }
.convo-time { font-size: 12.5px; color: var(--color-text-muted); white-space: nowrap; }
.convo-subject { font-size: 14px; margin-top: 1px; }
.convo-snippet {
  font-size: 13px; color: var(--color-text-muted); margin-top: 1px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.convo-meta { display: flex; align-items: center; gap: 8px; }

/* ---------- Conversation thread ---------- */

.thread { display: flex; flex-direction: column; gap: 14px; }
.bubble-row { display: flex; gap: 10px; max-width: 85%; }
.bubble-row-out { margin-left: auto; flex-direction: row-reverse; }
.bubble {
  border-radius: var(--radius-lg);
  padding: 12px 16px;
  font-size: 14.5px;
  min-width: 0;
}
.bubble-in { background: #fff; border: 1px solid var(--color-border); }
.bubble-out { background: #f2fbff; border: 1px solid #e8e5e5; }
.bubble-head {
  display: flex; justify-content: space-between; gap: 14px;
  font-size: 12.5px; margin-bottom: 4px;
  color: var(--color-text-muted);
}
.bubble-body p { margin: 0 0 .6em; overflow-wrap: anywhere; }
.bubble-body p:last-child { margin-bottom: 0; }
.bubble-status { font-size: 12px; margin-top: 6px; color: var(--color-text-muted); }
.bubble-status-failed { color: var(--color-red); }

.bubble-quoted { margin-top: 6px; }
.bubble-quoted summary {
  cursor: pointer;
  font-size: 12.5px;
  color: var(--color-text-muted);
  user-select: none;
}
.bubble-quoted p { opacity: .75; font-size: 13.5px; }

.bubble-attachments { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.bubble-attachment {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  text-decoration: none;
  max-width: 260px;
}
.bubble-attachment span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bubble-attachment:hover { background: var(--color-raised); }

.thread-note {
  background: #fffbeb;
  border: 1px solid #f3e8c0;
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 14.5px;
  max-width: 85%;
  margin-left: auto;
}
.thread-note-head { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; font-size: 13px; }
.thread-note p:last-of-type { margin-bottom: 0; }

.composer .composer-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--color-border); margin: -6px 0 14px; }
.triage-actions { display: flex; flex-direction: column; gap: 10px; }
.triage-actions input[type="text"], .triage-actions input[type="email"] { max-width: 220px; }

/* ---------- Broadcasts ---------- */

.broadcast-body {
  font-family: var(--font-sans);
  font-size: 14.5px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin: 0;
}
.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 6px 14px;
}

/* ---------- Tasks ---------- */

.task-list {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: #fff;
  overflow: hidden;
}
.task-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--color-border);
}
.task-row:last-child { border-bottom: 0; }
.task-row:hover { background: var(--color-surface); }
.task-check button, button.task-check {
  width: 22px; height: 22px;
  border: 1.5px solid var(--color-border-strong);
  border-radius: 50%;
  background: #fff;
  cursor: pointer;
  display: grid; place-items: center;
  color: transparent;
  padding: 0;
}
button.task-check:hover { border-color: var(--color-green); color: var(--color-green); }
button.task-check-done { background: var(--color-green); border-color: var(--color-green); color: #fff; }
.task-main { flex: 1; min-width: 0; }
.task-title { font-weight: 600; font-size: 14.5px; text-decoration: none; }
.task-title-done { text-decoration: line-through; color: var(--color-text-muted); }
.task-sub { display: flex; gap: 14px; font-size: 13px; color: var(--color-text-muted); margin-top: 2px; flex-wrap: wrap; }
.task-sub span { display: inline-flex; align-items: center; gap: 4px; }
.task-overdue { color: var(--color-red); font-weight: 600; }

/* ---------- Calendar ---------- */

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--color-border);
  gap: 1px;
}
.cal-head {
  background: var(--color-surface);
  padding: 8px 10px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--color-text-muted);
}
.cal-cell { background: #fff; min-height: 108px; padding: 8px 8px 10px; }
.cal-other { background: var(--color-surface); }
.cal-other .cal-date { color: var(--color-text-muted); }
.cal-date { font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.cal-today .cal-date {
  display: inline-grid; place-items: center;
  width: 24px; height: 24px;
  background: var(--color-accent); color: #fff; border-radius: 50%;
}
.cal-task {
  display: block;
  font-size: 12px;
  padding: 2px 7px;
  margin-bottom: 3px;
  border-radius: 6px;
  background: var(--color-raised);
  text-decoration: none;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cal-task:hover { background: var(--color-border); }
.cal-task-done { text-decoration: line-through; color: var(--color-text-muted); }
.cal-task-overdue { background: var(--color-red-soft); color: var(--color-red); }

.week-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 12px;
}
.week-col {
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 12px;
  min-height: 180px;
}
.week-col.cal-today { border-color: var(--color-accent); }
.week-head { font-size: 13px; font-weight: 600; margin-bottom: 10px; color: var(--color-text-secondary); }
.week-col .cal-task { white-space: normal; margin-bottom: 8px; padding: 6px 8px; }

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

/* ---------- Embed snippets ---------- */

.embed-snippet {
  background: var(--color-ink);
  color: #e8e8e6;
  border-radius: var(--radius);
  padding: 14px 16px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.55;
  overflow-x: auto;
  margin: 0;
}

/* ---------- Billing banner ---------- */

.billing-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 28px;
  background: var(--color-orange-soft);
  color: var(--color-orange);
  font-size: 14px;
  font-weight: 500;
  border-bottom: 1px solid #f5ddc4;
}
.billing-banner a { font-weight: 600; color: inherit; margin-left: auto; white-space: nowrap; }

/* ---------- Suspended / error pages ---------- */

.suspended-page { max-width: 440px; margin: 12vh auto; text-align: center; padding: 24px; }

/* ---------- Admin panel ----------
 * Flat, high-contrast operator console (design handoff): warm-gray page,
 * white radius-16 cards, black pills, hairline borders, no shadows. Everything
 * is scoped to body.admin so the tenant app and marketing site are untouched.
 * Tokens below are the handoff's; class names are admin-* to avoid colliding
 * with the shared components the rest of the app relies on.
 */

body.admin {
  --a-page: #E7E5E0;
  --a-card: #FFFFFF;
  --a-ink: #1a1a18;
  --a-ink-2: #33322e;
  --a-muted: #6f6d66;
  --a-faint: #9b998f;
  --a-black: #141412;
  --a-black-hover: #000000;
  --a-row-hover: #FAFAF8;
  --a-light-hover: #F5F4F0;
  --a-icon-bg: #F1F0EC;
  --a-pill: rgba(255, 255, 255, .75);
  --a-border-card: rgba(0, 0, 0, .06);
  --a-border-row: rgba(0, 0, 0, .04);
  --a-border-list: rgba(0, 0, 0, .05);
  --a-border-btn: rgba(0, 0, 0, .12);
  --a-border-btn-soft: rgba(0, 0, 0, .1);
  --a-outline: rgba(0, 0, 0, .14);
  --a-destructive: #A2482A;
  --a-destructive-bg: #FBF1EC;
  --a-mono: ui-monospace, Menlo, monospace;

  background: var(--a-page);
  color: var(--a-ink);
  font-family: -apple-system, "Helvetica Neue", Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* Neutralise the base serif/heading rules the old skin leaned on. */
body.admin h1, body.admin h2, body.admin h3 {
  font-family: inherit;
  letter-spacing: normal;
  color: var(--a-ink);
  margin: 0;
}

/* ----- Shell ----- */

.admin-container {
  max-width: 1300px;
  margin: 25px auto 0;
  padding: 50px;
  background: #f4f4f4;
  min-height: 980px;
  box-shadow: 2px 4px 8px rgba(0, 0, 0, 0.1);
}
@media (max-width: 640px) { .admin-container { padding: 20px 16px; margin-top: 12px; } }
.admin-bare { min-height: 100vh; }
/* Snowy-mountains backdrop behind the admin sheet — same fixed-layer
   technique as body.app (background-attachment: fixed is unreliable on iOS). */
body.admin::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background: url("/assets/app_snowymountains_bg_dark-37d66a01.png") center / cover no-repeat;
}

.admin-topbar { display: flex; align-items: center; gap: 16px; }
.admin-logo {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  flex-shrink: 0;
  padding: 9px 18px;
  border-radius: 999px;
  background: var(--a-black);
  text-decoration: none;
}
.admin-logo-word { font-size: 15px; font-weight: 700; letter-spacing: -0.02em; color: #fff; }
.admin-logo-tag { font-size: 9px; font-weight: 600; letter-spacing: 0.12em; color: rgba(255, 255, 255, .6); }

.admin-nav { flex: 1; display: flex; justify-content: center; gap: 6px; }

.admin-pill {
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  text-decoration: none;
  color: var(--a-ink-2);
  background: var(--a-pill);
  border: 0;
  cursor: pointer;
  transition: opacity .12s ease, background .12s ease;
}
.admin-pill:hover { opacity: .85; }
.admin-pill-active { background: var(--a-black); color: #fff; }
.admin-pill-active:hover { opacity: 1; }

.admin-topbar-right { display: flex; align-items: center; gap: 12px; }
.admin-email {
  font-size: 12.5px;
  color: var(--a-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 220px;
}
.admin-logout { font-size: 13.5px; }
.admin-logout:hover { background: #fff; opacity: 1; }
body.admin .admin-topbar-right form.button_to { display: inline-flex; margin: 0; }

.admin-content { margin-top: 2px; }

/* ----- Page header ----- */

.admin-page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin: 38px 4px 22px;
  flex-wrap: wrap;
}
body.admin .admin-h1 { font-size: 30px; font-weight: 700; letter-spacing: -0.025em; line-height: 1.08; }
.admin-sub { font-size: 13.5px; color: var(--a-muted); margin-top: 6px; }

/* ----- Buttons ----- */

.admin-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 10px 18px;
  transition: background .12s ease, border-color .12s ease;
}
.admin-btn-primary { background: var(--a-black); color: #fff; }
.admin-btn-primary:hover { background: var(--a-black-hover); }
.admin-btn-secondary { background: #fff; border-color: var(--a-border-btn); color: var(--a-ink-2); padding: 10px 16px; }
.admin-btn-secondary:hover { background: var(--a-light-hover); }
.admin-btn-destructive { background: #fff; border-color: var(--a-border-btn); color: var(--a-destructive); }
.admin-btn-destructive:hover { background: var(--a-destructive-bg); border-color: rgba(162, 72, 42, .3); }
.admin-btn-sm { padding: 8px 14px; font-size: 13px; border-radius: 10px; }
.admin-btn-block { width: 100%; }
.admin-btn-plus { font-size: 15px; font-weight: 500; margin-left: 1px; }
body.admin form.button_to { display: inline-flex; margin: 0; }
.admin-btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }

/* Small pills — per-user actions, invite affordance, tab-like chips. */
.admin-pill-sm {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  list-style: none;
  background: #fff;
  border: 1px solid var(--a-border-btn);
  color: var(--a-ink-2);
}
.admin-pill-sm::-webkit-details-marker { display: none; }
.admin-pill-sm:hover { background: var(--a-light-hover); }
.admin-pill-destructive { color: var(--a-destructive); }
.admin-pill-destructive:hover { background: var(--a-destructive-bg); }

/* ----- Cards ----- */

.admin-card {
  background: var(--a-card);
  border: 1px solid var(--a-border-card);
  border-radius: 16px;
  padding: 20px 22px;
}
.admin-card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
body.admin .card-title { font-size: 15px; font-weight: 650; color: var(--a-ink); letter-spacing: -0.006em; margin: 0; }
.admin-cardlink { font-size: 12.5px; font-weight: 600; color: var(--a-muted); text-decoration: none; white-space: nowrap; }
.admin-cardlink:hover { color: var(--a-black); }
.admin-note { font-size: 13px; color: var(--a-muted); line-height: 1.5; margin: 12px 0 0; }
.admin-note:first-child { margin-top: 0; }
.admin-mono { font-family: var(--a-mono); font-size: 12.5px; word-break: break-all; }
.admin-mono-block {
  font-family: var(--a-mono);
  font-size: 12.5px;
  color: var(--a-ink-2);
  word-break: break-all;
  margin-top: 8px;
  background: var(--a-icon-bg);
  padding: 10px 12px;
  border-radius: 10px;
}
.admin-mono-block a { color: inherit; text-decoration: none; }
.admin-divider { height: 1px; background: var(--a-border-card); margin: 16px 0; }
.admin-col-stack > * + * { margin-top: 14px; }

/* ----- Metric cards (dashboard) ----- */

.admin-metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.admin-metric {
  background: var(--a-card);
  border: 1px solid var(--a-border-card);
  border-radius: 16px;
  padding: 20px 22px;
}
.admin-metric-label { font-size: 12.5px; font-weight: 500; color: var(--a-muted); }
.admin-metric-value { font-size: 28px; font-weight: 700; letter-spacing: -0.03em; color: var(--a-ink); margin-top: 8px; line-height: 1; }
body.admin .stat-sub { font-size: 11.5px; color: var(--a-faint); margin-top: 4px; }
@media (max-width: 980px) { .admin-metrics { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 520px) { .admin-metrics { grid-template-columns: 1fr; } }

/* ----- Table cards (newest accounts, accounts index) ----- */

.admin-tablecard {
  background: var(--a-card);
  border: 1px solid var(--a-border-card);
  border-radius: 16px;
  overflow: hidden;
}
.admin-tablecard-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 22px 12px; }
.admin-viewall { font-size: 12.5px; font-weight: 600; color: var(--a-muted); text-decoration: none; }
.admin-viewall:hover { color: var(--a-black); }

.admin-thead, .admin-trow { display: grid; align-items: center; gap: 12px; }
.admin-thead {
  padding: 8px 22px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--a-faint);
  border-bottom: 1px solid var(--a-border-card);
}
.admin-trow {
  padding: 12px 22px;
  border-bottom: 1px solid var(--a-border-row);
  cursor: pointer;
  text-decoration: none;
  color: inherit;
}
.admin-trow:last-child { border-bottom: 0; }
.admin-trow:hover { background: var(--a-row-hover); }

.admin-newest .admin-thead, .admin-newest .admin-trow { grid-template-columns: minmax(0, 2.2fr) 1fr 1fr 1fr; }
.admin-accounts .admin-thead, .admin-accounts .admin-trow { grid-template-columns: minmax(0, 2.2fr) 1fr 1fr 1fr 24px; }

body.admin .cell-title { font-size: 13.5px; font-weight: 600; color: var(--a-ink); text-decoration: none; }
.admin-rowlink { text-decoration: none; }
.admin-cell-sub { display: block; font-size: 12px; color: var(--a-faint); margin-top: 2px; }
.admin-account-cell { min-width: 0; }
.admin-account-cell .cell-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-plan-cell { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.admin-plan-text { font-size: 13px; color: var(--a-ink-2); }
.admin-signup { font-size: 12.5px; color: var(--a-muted); }
.admin-ralign { text-align: right; }
.admin-rowarrow { color: var(--a-faint); text-align: right; font-size: 15px; }
.admin-tfoot { display: flex; align-items: center; justify-content: space-between; padding: 14px 22px; font-size: 12.5px; color: var(--a-faint); }

/* ----- Accounts filter row ----- */

.admin-filter { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; align-items: center; }
.admin-search {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 200px;
  max-width: 420px;
  background: var(--a-pill);
  border-radius: 999px;
  padding: 10px 18px;
}
.admin-search .icon { color: var(--a-faint); flex-shrink: 0; }
body.admin .admin-search input[type="search"] {
  flex: 1;
  width: 100%;
  border: 0;
  background: none;
  padding: 0;
  margin: 0;
  font-size: 13.5px;
  color: var(--a-ink);
}
body.admin .admin-search input[type="search"]:focus { border: 0; box-shadow: none; }
body.admin .admin-filter select {
  width: auto;
  appearance: auto;
  background: var(--a-pill);
  border: 0;
  border-radius: 999px;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--a-ink-2);
  cursor: pointer;
}
body.admin .admin-filter select:hover { background: #fff; }
body.admin .admin-filter select:focus { box-shadow: none; }

/* ----- Empty state ----- */

body.admin .admin-empty {
  background: var(--a-card);
  border: 1px solid var(--a-border-card);
  border-radius: 16px;
  padding: 56px 24px;
  text-align: center;
}
body.admin .admin-empty h3 { font-size: 16px; font-weight: 600; color: var(--a-ink-2); margin-bottom: 16px; }

/* ----- Badges ----- */

.admin-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.admin-badge-active { background: #DCE9DA; color: #2E6B3F; }
.admin-badge-info { background: #E1E6F3; color: #3F5390; }
.admin-badge-attention { background: #F6E1D8; color: #A2482A; }
.admin-badge-neutral { background: #E8E6DF; color: #6f6d66; }
.admin-badge-outline { background: transparent; border: 1px solid var(--a-outline); color: var(--a-ink-2); }

/* ----- Dashboard: billing-attention card ----- */

.admin-attention-card { border-color: #E6D3C7; }
.admin-attention-rows { margin-top: 14px; }
.admin-attention-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 0;
  border-top: 1px solid var(--a-border-list);
}
.admin-attention-row:first-child { border-top: 0; }
.admin-attention-row a { font-size: 13.5px; font-weight: 600; color: var(--a-ink); text-decoration: none; }
.admin-attention-row a:hover { text-decoration: underline; }
.admin-attention-status { font-size: 12.5px; color: var(--a-muted); }

/* ----- Account detail ----- */

.admin-back { display: inline-block; font-size: 13px; font-weight: 600; color: var(--a-muted); text-decoration: none; margin: 6px 4px 14px; }
.admin-back:hover { color: var(--a-black); }
.admin-detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin: 0 4px 18px;
  flex-wrap: wrap;
}
body.admin .admin-detail-name {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.1;
}
.admin-detail-name .admin-badge { font-size: 12px; }

.admin-tabs { display: flex; gap: 8px; margin: 0 4px 16px; }
.admin-tab {
  padding: 7px 15px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  background: #fff;
  border: 1px solid var(--a-border-btn);
  color: var(--a-muted);
}
.admin-tab:hover { background: var(--a-light-hover); }
.admin-tab-active, .admin-tab-active:hover { background: var(--a-black); color: #fff; border-color: var(--a-black); }

.admin-tabpanel { display: none; }
.admin-tabpanel.is-active { display: block; }

.admin-detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 14px; align-items: start; }
@media (max-width: 900px) { .admin-detail-grid { grid-template-columns: 1fr; } }

/* Users card */
.admin-users { margin-top: 14px; }
.admin-user-head, .admin-user-row { display: grid; grid-template-columns: minmax(0, 1fr) 92px 104px; gap: 10px 12px; align-items: center; }
.admin-user-head {
  padding-bottom: 10px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--a-faint);
  border-bottom: 1px solid var(--a-border-card);
}
.admin-user-row { padding: 12px 0; border-bottom: 1px solid var(--a-border-row); }
.admin-user-row:last-of-type { border-bottom: 0; }
.admin-user-name { min-width: 0; }
.admin-user-actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 6px; }
.admin-user-empty { font-size: 13px; color: var(--a-muted); margin-top: 14px; }

/* Invite popover (details/summary, no JS) */
.admin-invite { position: relative; }
.admin-invite > summary { list-style: none; }
.admin-invite > summary::-webkit-details-marker { display: none; }
.admin-invite-body {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 10;
  width: 300px;
  background: #fff;
  border: 1px solid var(--a-border-btn);
  border-radius: 14px;
  padding: 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .12);
}
body.admin .admin-invite-body .field { margin-bottom: 10px; }
body.admin .admin-invite-body .admin-btn { width: 100%; }

/* Pending invitations */
.admin-invites { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--a-border-card); }
.admin-invites-title { font-size: 11.5px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--a-faint); margin-bottom: 6px; }
.admin-invite-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 0;
  border-top: 1px solid var(--a-border-list);
  font-size: 13px;
  color: var(--a-ink-2);
}
.admin-invite-row:first-of-type { border-top: 0; }

/* Lifecycle stacked buttons */
.admin-stack-btns { margin-top: 14px; display: flex; flex-direction: column; gap: 8px; }
.admin-stack-btn {
  display: block;
  width: 100%;
  text-align: left;
  font-family: inherit;
  font-size: 13px;
  font-weight: 550;
  padding: 10px 14px;
  border-radius: 10px;
  background: #fff;
  border: 1px solid var(--a-border-btn-soft);
  color: var(--a-ink-2);
  cursor: pointer;
  text-decoration: none;
}
.admin-stack-btn:hover { background: var(--a-light-hover); }
.admin-stack-btn-danger { color: var(--a-destructive); }
.admin-stack-btn-danger:hover { background: var(--a-destructive-bg); }
.admin-block-form { display: block; margin: 0; }
.admin-footnote { font-size: 11.5px; color: var(--a-faint); margin-top: 10px; }

/* Danger zone */
.admin-danger { margin-top: 4px; }
body.admin .admin-danger .card-title { font-size: 13px; font-weight: 700; color: var(--a-destructive); margin-bottom: 8px; }

/* Definition lists (Details, Usage, System rows) */
body.admin .admin-dl { display: grid; grid-template-columns: 1fr auto; margin: 12px 0 0; font-size: 13px; }
body.admin .admin-dl dt { color: var(--a-ink-2); padding: 9px 14px 9px 0; border-top: 1px solid var(--a-border-list); }
body.admin .admin-dl dd {
  color: var(--a-ink);
  font-weight: 600;
  text-align: right;
  padding: 9px 0;
  margin: 0;
  border-top: 1px solid var(--a-border-list);
  overflow-wrap: anywhere;
}
body.admin .admin-dl dt:first-of-type, body.admin .admin-dl dd:first-of-type { border-top: 0; }
body.admin .admin-dl .mono, body.admin .admin-dl dt.mono, body.admin .admin-dl dd.mono { font-family: var(--a-mono); font-size: 12.5px; font-weight: 500; }

/* Billing key/value grid */
.admin-kv-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px 20px; margin-top: 16px; }
@media (max-width: 640px) { .admin-kv-grid { grid-template-columns: repeat(2, 1fr); } }
.admin-kv-label { font-size: 11.5px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--a-faint); }
.admin-kv-value { font-size: 14px; font-weight: 600; color: var(--a-ink); margin-top: 5px; overflow-wrap: anywhere; }
.admin-kv-value.mono { font-family: var(--a-mono); font-size: 12.5px; font-weight: 500; }

/* ----- System ----- */

.admin-status-pill { display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 999px; font-size: 13px; font-weight: 600; }
.admin-status-pill .admin-dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.admin-status-ok { background: #DCE9DA; color: #2E6B3F; }
.admin-status-warn { background: #F6E1D8; color: #A2482A; }
.admin-status-neutral { background: #E8E6DF; color: #6f6d66; }
.admin-system-grid { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 14px; align-items: start; }
@media (max-width: 900px) { .admin-system-grid { grid-template-columns: 1fr; } }

/* ----- Forms inside admin ----- */

body.admin .field { margin-bottom: 14px; }
body.admin .field label, body.admin .field .label { display: block; font-size: 12.5px; font-weight: 600; color: var(--a-ink-2); margin-bottom: 6px; }
body.admin .field .hint, body.admin .hint { font-size: 12px; color: var(--a-muted); margin-top: 5px; }
body.admin input[type="text"], body.admin input[type="email"], body.admin input[type="password"],
body.admin input[type="search"], body.admin input[type="url"], body.admin input[type="tel"],
body.admin select, body.admin textarea {
  width: 100%;
  font-family: inherit;
  font-size: 14px;
  color: var(--a-ink);
  background: #fff;
  border: 1px solid var(--a-border-btn);
  border-radius: 10px;
  padding: 9px 12px;
}
body.admin input:focus, body.admin select:focus, body.admin textarea:focus { border-color: var(--a-ink); box-shadow: 0 0 0 3px rgba(0, 0, 0, .06); outline: none; }
body.admin input[type="checkbox"] { accent-color: var(--a-black); }
body.admin .checkbox-field label { font-size: 13.5px; color: var(--a-ink-2); margin: 0; }
body.admin .form-errors {
  background: var(--a-destructive-bg);
  border: 1px solid rgba(162, 72, 42, .25);
  color: var(--a-destructive);
  border-radius: 10px;
  padding: 12px 16px;
  margin-bottom: 16px;
  font-size: 13.5px;
}
.admin-form-narrow { max-width: 640px; }

/* ----- Sign in ----- */

.admin-auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.admin-auth-card { width: 100%; max-width: 380px; background: #fff; border: 1px solid var(--a-border-card); border-radius: 16px; padding: 32px; }
.admin-auth-logo { display: inline-flex; align-items: baseline; gap: 6px; padding: 10px 18px; border-radius: 999px; background: var(--a-black); margin-bottom: 24px; }
.admin-auth-logo .admin-logo-word { font-size: 17px; }

/* ----- Mobile ----- */

@media (max-width: 760px) {
  .admin-topbar { flex-wrap: wrap; }
  .admin-nav { order: 3; flex-basis: 100%; justify-content: flex-start; margin-top: 4px; }
  .admin-email { max-width: 150px; }
  body.admin .admin-h1, body.admin .admin-detail-name { font-size: 25px; }
  .admin-user-actions { margin-top: 4px; }
}

/* ---------- Marketing site (Oliv-style) ---------- */

body.marketing {
  background:
    radial-gradient(600px 400px at 8% -5%, #dbeafe 0%, transparent 60%),
    radial-gradient(500px 380px at 96% 4%, #fde7e0 0%, transparent 60%),
    radial-gradient(700px 500px at 50% 108%, #d3ede8 0%, transparent 55%),
    #cfe8e2;
  min-height: 100vh;
  padding: 22px;
}

/* Marketing pages: photographic canvas behind the sheet. A fixed
   pseudo-element keeps the image viewport-sized and crisp on tall pages
   (background-attachment: fixed is unreliable on iOS). */
body.marketing::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background: url("/sunrise_bg.png") center / cover no-repeat;
}

.mk-sheet {
  max-width: 1560px;
  margin: 28px auto 0;
  background: #fff;
  border-radius: 22px;
  padding: 65px 80px 60px;
  box-shadow: 0 30px 80px rgba(30, 50, 45, .18);
}
@media (max-width: 700px) { .mk-sheet { padding: 20px 22px 40px; } }

.mk-nav {
  display: flex;
  align-items: center;
  gap: 26px;
  padding-bottom: 44px;
}
.mk-logo { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 16px; text-decoration: none; margin-right: auto; }
.mk-logo-img { height: 26px; width: auto; display: block; }
.auth-logo-img { height: 26px; width: auto; display: block; }
.mk-nav a:not(.mk-logo):not(.btn) { font-size: 14px; font-weight: 500; color: var(--color-text-secondary); text-decoration: none; }
.mk-nav a:not(.mk-logo):not(.btn):hover { color: var(--color-text); }
.mk-hero { max-width: 640px; padding: 30px 0 40px; }
.mk-hero h1 { font-size: clamp(34px, 7vw, 85px); line-height: 1.05; letter-spacing: -0.03em; margin-bottom: 18px; }
.mk-hero h1 .accent { color: var(--color-accent); }
.mk-hero p { font-size: 17px; color: var(--color-text-secondary); max-width: 480px; margin-bottom: 26px; }
.mk-hero .mk-cta-row { display: flex; gap: 12px; flex-wrap: wrap; }

/* Hero with the app screenshot up top right of the copy; the shot never
   takes more than ~half the content area. */
.mk-hero-split {
  max-width: none;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 50%);
  gap: 56px;
  align-items: center;
}
.mk-hero-shot img {
  display: block;
  width: 100%;
  max-width: 640px;
  height: auto;
  margin-inline: 0 auto; /* hug the column's left edge — whitespace stays on the right */
  border-radius: 12px;
  border: 1px solid var(--color-border);
  box-shadow: 0 12px 24px rgba(30, 50, 45, .10), 0 32px 72px rgba(30, 50, 45, .18);
}
@media (max-width: 900px) {
  .mk-hero-split { grid-template-columns: 1fr; gap: 32px; }
}

.mk-kicker {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin-bottom: 10px;
}

.mk-breadcrumb { display: flex; align-items: center; gap: 8px; }
.mk-breadcrumb a { color: inherit; text-decoration: none; }
.mk-breadcrumb a:hover { color: var(--color-text); }
.mk-breadcrumb-sep { opacity: .6; }

.mk-section { padding: 44px 0 8px; }
.mk-section h2 { font-size: clamp(24px, 4vw, 32px); letter-spacing: -0.02em; max-width: 520px; }
.mk-section .mk-lede { color: var(--color-text-secondary); max-width: 520px; }

.mk-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: 26px; }
@media (max-width: 900px) { .mk-grid-3 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 600px) { .mk-grid-3 { grid-template-columns: 1fr; } }
.mk-card {
  border: 1px solid var(--color-border);
  border-radius: 16px;
  padding: 24px;
  background: var(--color-surface);
}
.mk-card .icon { color: var(--color-text); margin-bottom: 12px; }
.mk-card h3 { font-size: 16px; margin-bottom: 6px; }
.mk-card p { font-size: 14px; color: var(--color-text-secondary); margin: 0; }

.mk-values { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-top: 26px; }
.mk-value { border-radius: 16px; padding: 26px 24px 60px; font-weight: 650; font-size: 17px; letter-spacing: -0.01em; }
.mk-value .mk-kicker { margin-bottom: 26px; }
.mk-value-blue { background: #e8effc; }
.mk-value-cream { background: #f7f3e8; }
.mk-value-peach { background: #fbeadd; }
.mk-value-mint { background: #e4f2ec; }
.mk-value-lemon { background: #faf6d8; }
.mk-value-plain { background: var(--color-surface); border: 1px solid var(--color-border); }

.mk-cta {
  margin-top: 52px;
  background: #a3bdc4;
  border-radius: 18px;
  padding: 52px 40px;
  text-align: center;
}
.mk-cta h2 { max-width: 460px; margin: 0 auto 10px; }
.mk-cta p { color: #2f3e42; margin-bottom: 22px; } /* deep slate — readable on the light-blue panel */

.mk-footer {
  display: flex;
  gap: 24px;
  align-items: center;
  padding-top: 100px;
  font-size: 13px;
  color: var(--color-text-muted);
  flex-wrap: wrap;
}
.mk-footer a { color: inherit; text-decoration: none; }
.mk-footer a:hover { color: var(--color-text); }
.mk-footer .mk-copyright { margin-left: auto; }

.mk-form { max-width: 440px; margin-top: 26px; }

.mk-text-cols {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 40px;
}
.mk-text-cols h3 { font-size: 18px; margin-bottom: 10px; letter-spacing: -0.01em; }
.mk-text-cols p { font-size: 15px; color: var(--color-text-secondary); margin: 0; }
@media (max-width: 800px) { .mk-text-cols { grid-template-columns: 1fr; gap: 28px; } }

.mk-contact-grid {
  display: grid;
  grid-template-columns: minmax(0, 480px) minmax(240px, 340px);
  gap: 48px;
  margin-top: 26px;
  align-items: start;
}
@media (max-width: 800px) { .mk-contact-grid { grid-template-columns: 1fr; gap: 24px; } }

.mk-workspace-input {
  display: flex;
  align-items: center;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius);
  background: #fff;
  overflow: hidden;
}
.mk-workspace-input:focus-within { border-color: var(--color-text); box-shadow: 0 0 0 3px rgba(23, 23, 23, .07); }
.mk-workspace-prefix {
  padding: 9px 2px 9px 12px;
  color: var(--color-text-muted);
  font-family: var(--font-mono);
  font-size: 14px;
  white-space: nowrap;
}
.mk-workspace-input input {
  border: 0;
  box-shadow: none !important;
  padding-left: 2px;
  font-family: var(--font-mono);
  font-size: 14px;
}

/* Classic docs view: sticky article menu on the left, guide text on the
   right. Collapses to a single column with the menu on top on phones. */
.mk-docs-layout {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  gap: 56px;
  align-items: start;
  padding-top: 10px;
}
.mk-docs-sidebar { position: sticky; top: 24px; }
.mk-docs-sidebar-title { margin-bottom: 14px; }
.mk-docs-sidebar-title a {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  text-decoration: none;
}
.mk-docs-sidebar-title a:hover { color: var(--color-text); }
.mk-docs-sidebar nav { display: flex; flex-direction: column; }
.mk-docs-sidebar nav a {
  font-size: 14px;
  line-height: 1.4;
  color: var(--color-text-secondary);
  text-decoration: none;
  padding: 7px 12px;
  border-left: 2px solid var(--color-border);
}
.mk-docs-sidebar nav a:hover { color: var(--color-text); }
.mk-docs-sidebar nav a.active {
  color: var(--color-accent);
  font-weight: 600;
  border-left-color: var(--color-accent);
}
@media (max-width: 800px) {
  /* minmax(0,1fr) + min-width:0 let the column shrink below its content so a
     wide code block scrolls inside .embed-snippet instead of stretching the
     whole sheet past the viewport. */
  .mk-docs-layout { grid-template-columns: minmax(0, 1fr); gap: 28px; }
  .mk-docs-layout .mk-doc, .mk-docs-layout .mk-docs-sidebar { min-width: 0; }
  .mk-docs-sidebar { position: static; }
}

.mk-docs-list { display: grid; gap: 14px; margin-top: 26px; }

/* Standalone SEO articles reuse the doc typography, centered. */
.mk-article { margin: 0 auto; }
.article-filters { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 18px; }
.article-filter {
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  color: var(--color-text-secondary);
  border: 1px solid var(--color-border);
  border-radius: 99px;
  padding: 5px 14px;
}
.article-filter:hover { color: var(--color-text); border-color: var(--color-border-strong); }
.article-filter.active { background: var(--color-ink); color: #fff; border-color: var(--color-ink); }
.article-card-meta { margin-bottom: 2px; }
.article-category { font-size: 11.5px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--color-text-muted); }

/* "And there's more…" — Basecamp-style link hub between the CTA and the
   footer; every article and guide gets a homepage link for SEO. */
.mk-more { margin-top: 56px; padding: 0 4px; }
.mk-more h2 { font-size: 24px; letter-spacing: -0.01em; margin-bottom: 18px; }
.mk-more-list { columns: 3; column-gap: 44px; padding-left: 20px; margin: 0; }
.mk-more-list li { margin-bottom: 10px; break-inside: avoid; font-size: 15px; line-height: 1.5; }
.mk-more-list a { color: var(--color-text-secondary); }
.mk-more-list a:hover { color: var(--color-text); }
@media (max-width: 900px) { .mk-more-list { columns: 2; } }
@media (max-width: 600px) { .mk-more-list { columns: 1; } }

.mk-doc { max-width: 720px; padding: 24px 0 8px; }
.mk-doc h1 { font-size: clamp(28px, 5vw, 38px); letter-spacing: -0.02em; margin: 6px 0 10px; }
.mk-doc .mk-doc-lede { font-size: 16.5px; color: var(--color-text-secondary); margin-bottom: 8px; }
.mk-doc h2 { font-size: 20px; letter-spacing: -0.01em; margin: 34px 0 10px; }
.mk-doc p, .mk-doc li { font-size: 15px; color: var(--color-text-secondary); line-height: 1.65; }
.mk-doc ul { padding-left: 22px; }
.mk-doc li { margin-bottom: 6px; }
.mk-doc strong { color: var(--color-text); }
.mk-doc .embed-snippet { margin: 12px 0 4px; }
.mk-doc-footer {
  display: flex;
  gap: 16px;
  margin-top: 44px;
  padding-top: 18px;
  border-top: 1px solid var(--color-border);
  font-size: 14px;
  color: var(--color-text-muted);
}


.mk-policy-nav { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 4px; }
.mk-policy-nav a {
  font-size: 13.5px;
  font-weight: 600;
  text-decoration: none;
  color: var(--color-text-secondary);
  border: 1px solid var(--color-border);
  border-radius: 99px;
  padding: 6px 14px;
}
.mk-policy-nav a:hover { color: var(--color-text); background: var(--color-surface); }

.mk-policy {
  max-width: 720px;
  padding: 40px 0 8px;
  scroll-margin-top: 24px;
  border-top: 1px solid var(--color-border);
  margin-top: 32px;
}
.mk-policy h2 { font-size: 26px; letter-spacing: -0.02em; margin-bottom: 18px; }
.mk-policy h3 { font-size: 16px; margin: 26px 0 8px; }
.mk-policy p { font-size: 15px; color: var(--color-text-secondary); line-height: 1.65; }

/* ---------- Marketing: phone corrections ----------
   Scoped to .mk-* classes only; the tenant app and admin panel are untouched.
   Fixes the nav row overflowing on phones, gives nav items ≥40px tap targets,
   drops the hero's desktop-only line break, and bumps small card prose. */
@media (max-width: 640px) {
  .mk-nav { flex-wrap: wrap; gap: 10px 16px; padding-bottom: 30px; }
  .mk-logo { flex-basis: 100%; margin-right: 0; }  /* brand on its own row; links group below */
  .mk-nav a { white-space: nowrap; }
  .mk-nav a:not(.mk-logo) { min-height: 40px; display: inline-flex; align-items: center; }
  .mk-nav .btn-sm { padding: 9px 14px; font-size: 14px; }

  .mk-hero-br { display: none; }        /* let the headline flow on phones */
  .mk-card p { font-size: 15px; }       /* body prose stays ≥15px */
  .mk-form .form-row { grid-template-columns: 1fr; }  /* stack name/email */
}

/* ---------- Confirm dialog ---------- */
/* One <dialog>, appended to <body>, standing in for the native confirm() behind
   every data-turbo-confirm. The base rules are the tenant app (square Ayro) look
   and double as the sane default for auth/marketing; body.admin re-skins it to
   the pill world. No entrance animation, so prefers-reduced-motion is a no-op. */

.confirm-dialog {
  padding: 0;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: min(400px, calc(100vw - 32px));
  color: var(--color-text);
  background: #fff;
}
.confirm-dialog::backdrop { background: rgba(0, 0, 0, .4); }
.confirm-dialog__panel { padding: 22px; }
.confirm-dialog__message { margin: 0 0 18px; font-size: 15px; line-height: 1.5; }
.confirm-dialog__actions { display: flex; justify-content: flex-end; gap: 8px; }
.confirm-dialog__btn {
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  padding: 9px 16px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  transition: background .12s ease, border-color .12s ease;
}
/* Cancel = secondary; Confirm mirrors .btn-danger — every confirm here is destructive. */
.confirm-dialog__cancel { background: #fff; border-color: var(--color-border-strong); color: var(--color-text); }
.confirm-dialog__cancel:hover { background: var(--color-surface); }
.confirm-dialog__accept { background: #fff; border-color: var(--color-border-strong); color: var(--color-red); }
.confirm-dialog__accept:hover { background: var(--color-red-soft); border-color: var(--color-red); }

/* Admin pill world: rounder corners and admin tokens, mirroring .admin-btn-destructive. */
body.admin .confirm-dialog {
  border-radius: 16px;
  border-color: var(--a-border-card);
  background: var(--a-card);
  color: var(--a-ink);
}
body.admin .confirm-dialog__btn { border-radius: 12px; padding: 10px 16px; }
body.admin .confirm-dialog__cancel { border-color: var(--a-border-btn); color: var(--a-ink-2); }
body.admin .confirm-dialog__cancel:hover { background: var(--a-light-hover); }
body.admin .confirm-dialog__accept { border-color: var(--a-border-btn); color: var(--a-destructive); }
body.admin .confirm-dialog__accept:hover { background: var(--a-destructive-bg); border-color: rgba(162, 72, 42, .3); }

/* ---------- Utilities ---------- */

.muted { color: var(--color-text-muted); }
.small { font-size: 13px; }
.mono { font-family: var(--font-mono); font-size: .92em; }
.flex { display: flex; align-items: center; gap: 10px; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.stack-sm > * + * { margin-top: 8px; }
.stack > * + * { margin-top: 16px; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.w-auto { width: auto; }
