/* =========================================================================
   App design system
   -------------------------------------------------------------------------
   Single source of truth for visual style. Everything is built from CSS
   custom properties so a future dark mode is one block of overrides.
   ========================================================================= */

:root {
  /* Color — neutral surface palette + one indigo accent */
  --bg:             #f7f8fa;
  --surface:        #ffffff;
  --surface-2:      #f3f4f6;
  --surface-hover:  #f9fafb;

  --border:         #e5e7eb;
  --border-strong:  #d1d5db;

  --text:           #0f172a;
  --text-muted:     #475569;
  --text-subtle:    #64748b;
  --icon-subtle:    #94a3b8;
  --text-inverse:   #ffffff;

  /* Accent — workspace can override via --brand-primary in base_workspace.html. */
  --accent:         var(--brand-primary, #4f46e5);
  --accent-hover:   var(--brand-primary-hover, #4338ca);
  --accent-soft:    #eef2ff;
  --accent-text:    #3730a3;

  --danger:         #dc2626;
  --danger-hover:   #b91c1c;
  --danger-soft:    #fee2e2;
  --danger-text:    #991b1b;

  --success:        #059669;
  --success-soft:   #d1fae5;
  --success-text:   #065f46;

  --warning:        #d97706;
  --warning-soft:   #fef3c7;
  --warning-text:   #92400e;

  /* Effects */
  --shadow-sm:  0 1px 2px rgb(15 23 42 / 0.04);
  --shadow:     0 1px 3px rgb(15 23 42 / 0.06), 0 1px 2px rgb(15 23 42 / 0.04);
  --shadow-md:  0 4px 12px rgb(15 23 42 / 0.06), 0 2px 4px rgb(15 23 42 / 0.04);
  --shadow-lg:  0 10px 24px rgb(15 23 42 / 0.08), 0 4px 8px rgb(15 23 42 / 0.04);

  --radius-sm:  6px;
  --radius:     8px;
  --radius-md:  10px;
  --radius-lg:  14px;
  --radius-xl:  20px;
  --radius-full: 9999px;

  /* Spacing scale */
  --space-1:  4px;
  --space-2:  8px;
  --space-3:  12px;
  --space-4:  16px;
  --space-5:  20px;
  --space-6:  24px;
  --space-8:  32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;

  /* Typography */
  --font-sans: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto,
               Oxygen, Ubuntu, Cantarell, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
               "Liberation Mono", monospace;

  --text-xs:   12px;
  --text-sm:   13px;
  --text-base: 15px;
  --text-md:   16px;
  --text-lg:   17px;
  --text-xl:   20px;
  --text-2xl:  24px;
  --text-3xl:  30px;
  --text-4xl:  36px;

  --leading-tight:  1.25;
  --leading-snug:   1.4;
  --leading-normal: 1.6;

  /* Transitions */
  --t-fast: 120ms cubic-bezier(0.4, 0, 0.2, 1);
  --t-med:  200ms cubic-bezier(0.4, 0, 0.2, 1);

  /* Layout */
  --nav-h:        60px;
  --container-w:  1200px;
  --container-px: var(--space-6);
}

/* =========================================================================
   Reset / base
   ========================================================================= */

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body { min-height: 100vh; display: flex; flex-direction: column; }

h1, h2, h3, h4, h5, h6 {
  margin: 0;
  font-weight: 600;
  line-height: var(--leading-tight);
  letter-spacing: -0.015em;
  color: var(--text);
}

h1 { font-size: var(--text-3xl); letter-spacing: -0.02em; }
h2 { font-size: var(--text-2xl); }
h3 { font-size: var(--text-xl); }
h4 { font-size: var(--text-lg); }

p  { margin: 0; }

a {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--t-fast);
}
a:hover { color: var(--accent-hover); }

button { font-family: inherit; }

::selection {
  background: var(--accent-soft);
  color: var(--accent-text);
}

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

/* =========================================================================
   App shell — top navbar + main container
   ========================================================================= */

.app-nav {
  height: var(--nav-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 40;
  backdrop-filter: saturate(180%) blur(8px);
}

.app-nav__inner {
  max-width: var(--container-w);
  margin: 0 auto;
  padding: 0 var(--container-px);
  height: 100%;
  display: flex;
  align-items: center;
  gap: var(--space-6);
}

.app-nav__brand {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-weight: 600;
  font-size: var(--text-md);
  color: var(--text);
  letter-spacing: -0.01em;
}

.app-nav__brand-logo {
  width: 26px;
  height: 26px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--accent) 0%, #7c3aed 100%);
  display: grid;
  place-items: center;
  color: white;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: -0.02em;
  box-shadow: var(--shadow-sm);
}

.app-nav__links {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  flex: 1;
}

.app-nav__link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 6px var(--space-3);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-weight: 500;
  font-size: var(--text-base);
  transition: background var(--t-fast), color var(--t-fast);
}

.app-nav__link:hover {
  background: var(--surface-2);
  color: var(--text);
}

.app-nav__link.is-active {
  background: var(--accent-soft);
  color: var(--accent-text);
}

.app-nav__right {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-left: auto;
}

/* Active-tenant chip in the navbar */
.nav-tenant-form { margin: 0; }
.nav-tenant {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 4px 10px 4px 4px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  color: var(--text);
  font-family: inherit;
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  transition: background var(--t-fast), border-color var(--t-fast);
  max-width: 220px;
}
.nav-tenant:hover {
  background: var(--surface);
  border-color: var(--border-strong);
}
.nav-tenant__logo {
  width: 22px;
  height: 22px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, #6366f1, #a855f7);
  color: white;
  font-size: 11px;
  font-weight: 700;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  letter-spacing: -0.02em;
}
.nav-tenant__name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.nav-tenant__chev {
  width: 14px;
  height: 14px;
  color: var(--icon-subtle);
  flex-shrink: 0;
}

.app-nav__user {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 4px var(--space-2) 4px 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  background: var(--surface);
  color: var(--text);
  font-size: var(--text-sm);
  font-weight: 500;
  transition: background var(--t-fast), border-color var(--t-fast);
}
.app-nav__user:hover {
  background: var(--surface-2);
  border-color: var(--border-strong);
  color: var(--text);
}

/* avatar circle */
.avatar {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, #6366f1, #a855f7);
  color: white;
  font-weight: 600;
  font-size: var(--text-xs);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  letter-spacing: -0.01em;
}
.avatar--lg { width: 40px; height: 40px; font-size: var(--text-base); }

/* =========================================================================
   Container + page header
   ========================================================================= */

.app-main {
  flex: 1;
  width: 100%;
  max-width: var(--container-w);
  margin: 0 auto;
  padding: var(--space-10) var(--container-px) var(--space-16);
}

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-6);
  flex-wrap: wrap;
  margin-bottom: var(--space-8);
  padding-bottom: var(--space-6);
  border-bottom: 1px solid var(--border);
}

.page-header__titles { min-width: 0; }

.page-title {
  font-size: var(--text-3xl);
  letter-spacing: -0.025em;
  margin-bottom: var(--space-2);
}

.page-subtitle {
  color: var(--text-muted);
  font-size: var(--text-md);
  max-width: 64ch;
}

.page-actions {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

/* =========================================================================
   Card / panel
   ========================================================================= */

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

.card__header {
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
}

.card__title {
  font-size: var(--text-lg);
  font-weight: 600;
}

.card__body { padding: var(--space-6); }

.card__footer {
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* tight card variant for auth screens */
.card--auth {
  width: 100%;
  max-width: 420px;
  margin: var(--space-12) auto;
  border-radius: var(--radius-lg);
}
.card--auth .card__body { padding: var(--space-8); }

/* =========================================================================
   Buttons
   ========================================================================= */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 0 var(--space-4);
  height: 36px;
  border-radius: var(--radius);
  font-size: var(--text-base);
  font-weight: 500;
  font-family: inherit;
  line-height: 1;
  cursor: pointer;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  transition: background var(--t-fast), border-color var(--t-fast),
              color var(--t-fast), box-shadow var(--t-fast),
              transform var(--t-fast);
  white-space: nowrap;
  user-select: none;
}

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

.btn:active { transform: translateY(1px); }
.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn--primary {
  background: var(--accent);
  color: var(--text-inverse);
  border-color: var(--accent);
  box-shadow: var(--shadow-sm);
}
.btn--primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: var(--text-inverse);
}

.btn--secondary {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}
.btn--secondary:hover {
  background: var(--surface-2);
  border-color: var(--border-strong);
}

.btn--ghost {
  background: transparent;
  color: var(--text-muted);
}
.btn--ghost:hover {
  background: var(--surface-2);
  color: var(--text);
}

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

.btn--danger-outline {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--danger);
}
.btn--danger-outline:hover {
  background: var(--danger-soft);
  border-color: var(--danger);
  color: var(--danger-text);
}

.btn--sm   { height: 30px; padding: 0 var(--space-3); font-size: var(--text-sm); border-radius: var(--radius-sm); }
.btn--lg   { height: 44px; padding: 0 var(--space-5); font-size: var(--text-md); }
.btn--icon { padding: 0; width: 36px; }
.btn--full { width: 100%; }

.btn svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* =========================================================================
   Forms
   ========================================================================= */

.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.field + .field { margin-top: var(--space-4); }

.label {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text);
}

.input,
.select,
.textarea {
  width: 100%;
  padding: 0 var(--space-3);
  height: 38px;
  font-family: inherit;
  font-size: var(--text-base);
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  transition: border-color var(--t-fast), box-shadow var(--t-fast),
              background var(--t-fast);
  appearance: none;
}

.textarea {
  height: auto;
  padding: var(--space-3);
  line-height: var(--leading-normal);
  resize: vertical;
  min-height: 96px;
}

.input::placeholder { color: var(--text-subtle); }

.input:hover,
.select:hover,
.textarea:hover { border-color: var(--text-subtle); }

.input:focus,
.select:focus,
.textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  outline: none;
}

.input:disabled,
.select:disabled,
.textarea:disabled {
  background: var(--surface-2);
  color: var(--text-muted);
  cursor: not-allowed;
}

.select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='none' stroke='%2394a3b8' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round' d='M1 1.5l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.field-help {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.field-error { color: var(--danger-text); }

/* horizontal form row (label left, input right) — for detail/edit pages */
.form-grid {
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr);
  column-gap: var(--space-6);
  row-gap: var(--space-5);
  align-items: center;
}

.form-grid > .label { justify-self: end; text-align: right; }

@media (max-width: 720px) {
  .form-grid {
    grid-template-columns: 1fr;
    row-gap: var(--space-2);
  }
  .form-grid > .label { justify-self: start; text-align: left; }
}

/* search-style input with leading icon */
.input-search {
  position: relative;
  display: flex;
  align-items: center;
}
.input-search svg {
  position: absolute;
  left: 12px;
  width: 16px;
  height: 16px;
  color: var(--icon-subtle);
  pointer-events: none;
}
.input-search .input {
  padding-left: 36px;
}

/* =========================================================================
   Tables
   ========================================================================= */

.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-base);
}

.table thead th {
  text-align: left;
  padding: var(--space-3) var(--space-4);
  background: var(--surface-2);
  color: var(--text-muted);
  font-weight: 500;
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.table tbody td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  color: var(--text);
}

.table tbody tr:last-child td { border-bottom: none; }

.table tbody tr {
  transition: background var(--t-fast);
}

.table tbody tr:hover { background: var(--surface-hover); }

.table a {
  color: var(--text);
  font-weight: 500;
}
.table a:hover { color: var(--accent); }

.table .col-actions {
  width: 1%;
  white-space: nowrap;
  text-align: right;
}

/* =========================================================================
   Badges / status pills
   ========================================================================= */

.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 2px var(--space-2);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 500;
  background: var(--surface-2);
  color: var(--text-muted);
  border: 1px solid var(--border);
  line-height: 1.4;
}

.badge--accent  { background: var(--accent-soft);  color: var(--accent-text);  border-color: transparent; }
.badge--success { background: var(--success-soft); color: var(--success-text); border-color: transparent; }
.badge--warning { background: var(--warning-soft); color: var(--warning-text); border-color: transparent; }
.badge--danger  { background: var(--danger-soft);  color: var(--danger-text);  border-color: transparent; }

.badge::before {
  content: "";
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: var(--radius-full);
  background: currentColor;
  opacity: 0.65;
}

/* =========================================================================
   Alerts (flash messages)
   ========================================================================= */

.alert {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius);
  font-size: var(--text-base);
  border: 1px solid transparent;
}

.alert + .alert { margin-top: var(--space-2); }

.alert--info    { background: var(--accent-soft);  color: var(--accent-text);  }
.alert--success { background: var(--success-soft); color: var(--success-text); }
.alert--warning { background: var(--warning-soft); color: var(--warning-text); }
.alert--danger  { background: var(--danger-soft);  color: var(--danger-text);  }

.alert svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }

.flash-stack {
  margin-bottom: var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

/* =========================================================================
   Stat cards (admin dashboards)
   ========================================================================= */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--space-4);
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.stat-card__label {
  font-size: var(--text-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}

.stat-card__value {
  font-size: var(--text-3xl);
  font-weight: 600;
  letter-spacing: -0.025em;
  color: var(--text);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.stat-card__sub {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-top: var(--space-1);
}

/* =========================================================================
   Empty states + utility
   ========================================================================= */

.empty-state {
  text-align: center;
  padding: var(--space-12) var(--space-6);
  color: var(--text-muted);
}

.empty-state h3 { margin-bottom: var(--space-2); color: var(--text); }

.divider {
  height: 1px;
  background: var(--border);
  border: none;
  margin: var(--space-6) 0;
}

.muted   { color: var(--text-muted); }
.subtle  { color: var(--text-subtle); }
.mono    { font-family: var(--font-mono); }
.text-sm { font-size: var(--text-sm); }
.text-xs { font-size: var(--text-xs); }
.text-lg { font-size: var(--text-lg); }

.stack > * + *      { margin-top: var(--space-4); }
.stack-sm > * + *   { margin-top: var(--space-2); }
.stack-lg > * + *   { margin-top: var(--space-6); }

.cluster {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
}

.cluster--end { justify-content: flex-end; }

/* =========================================================================
   Hero / landing
   ========================================================================= */

.hero-landing {
  padding: var(--space-16) 0 var(--space-12);
  text-align: center;
}

.hero-landing__eyebrow {
  display: inline-block;
  padding: 4px var(--space-3);
  border-radius: var(--radius-full);
  background: var(--accent-soft);
  color: var(--accent-text);
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: 0.02em;
  margin-bottom: var(--space-6);
}

.hero-landing__title {
  font-size: var(--text-4xl);
  letter-spacing: -0.03em;
  margin-bottom: var(--space-4);
  background: linear-gradient(180deg, var(--text) 0%, #475569 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero-landing__lede {
  font-size: var(--text-lg);
  color: var(--text-muted);
  max-width: 56ch;
  margin: 0 auto var(--space-8);
}

/* =========================================================================
   Confirm-destruction screen
   ========================================================================= */

.confirm-card {
  border-color: var(--danger-soft);
  background: linear-gradient(180deg, #fff 0%, var(--danger-soft) 240%);
}

.confirm-card .card__body {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

/* =========================================================================
   Responsive tweaks
   ========================================================================= */

@media (max-width: 720px) {
  :root { --container-px: var(--space-4); }
  .app-nav__links { gap: 0; }
  .app-nav__link { padding: 6px var(--space-2); }
  .page-title { font-size: var(--text-2xl); }
  .hero-landing__title { font-size: var(--text-3xl); }
  /* Prevent iOS auto-zoom on input focus (triggered when font-size < 16px). */
  .input, .select, .textarea { font-size: 16px; }
}

/* =========================================================================
   Workspace shell extras — admin subnav, footer, brand logo image
   ========================================================================= */

.app-nav__brand-logo-img {
  width: 26px;
  height: 26px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  box-shadow: var(--shadow-sm);
}

.logout-form { margin: 0; }

.app-subnav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: var(--nav-h);
  z-index: 30;
}
.app-subnav__inner {
  max-width: var(--container-w);
  margin: 0 auto;
  padding: 0 var(--container-px);
  display: flex;
  gap: var(--space-1);
  overflow-x: auto;
}
.app-subnav__link {
  display: inline-flex;
  align-items: center;
  padding: var(--space-3) var(--space-3);
  color: var(--text-muted);
  font-size: var(--text-sm);
  font-weight: 500;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color var(--t-fast), border-color var(--t-fast);
  white-space: nowrap;
}
.app-subnav__link:hover { color: var(--text); }
.app-subnav__link.is-active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.workspace-footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: var(--space-5) 0;
  font-size: var(--text-sm);
  color: var(--text-muted);
}
.workspace-footer__inner {
  max-width: var(--container-w);
  margin: 0 auto;
  padding: 0 var(--container-px);
  text-align: center;
}

/* =========================================================================
   Utilities (recurring inline-style patterns)
   ========================================================================= */

.text-right  { text-align: right; }
.text-center { text-align: center; }
.nowrap      { white-space: nowrap; }
.tabular     { font-variant-numeric: tabular-nums; }
.w-num       { max-width: 160px; }

/* =========================================================================
   Modal-style action dialogs — native <dialog> popups that escape any
   ancestor overflow clipping (e.g. table-wrap with overflow:hidden).
   ========================================================================= */

.action-dialog {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-lg);
  min-width: 360px;
  max-width: 480px;
  background: var(--surface);
  color: var(--text);
}
.action-dialog::backdrop {
  background: rgb(15 23 42 / 0.35);
  backdrop-filter: blur(2px);
}
.action-dialog .label { margin-top: var(--space-2); }
.action-dialog .cluster--end { margin-top: var(--space-3); }

/* =========================================================================
   Attachments — gallery of image thumbnails + click-to-zoom viewer
   ========================================================================= */

.attachments { margin-top: var(--space-8); }
.attachments__title {
  font-size: var(--text-lg);
  margin-bottom: var(--space-3);
}

.attachments__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.att-card {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.att-card__thumb {
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: zoom-in;
}
.att-card__thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.att-card__del {
  position: absolute;
  top: 4px;
  right: 4px;
  margin: 0;
}
.att-card__del button {
  width: 24px;
  height: 24px;
  border-radius: var(--radius-full);
  background: rgb(15 23 42 / 0.7);
  color: white;
  border: 0;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  display: grid;
  place-items: center;
}
.att-card__del button:hover { background: var(--danger); }

.att-upload {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface-2);
  flex-wrap: wrap;
}
.att-upload__label {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex: 1;
  flex-wrap: wrap;
}

/* Full-size viewer */
.att-viewer {
  border: 0;
  padding: 0;
  background: transparent;
  max-width: 90vw;
  max-height: 90vh;
  overflow: visible;
}
.att-viewer::backdrop {
  background: rgb(15 23 42 / 0.85);
}
.att-viewer img {
  display: block;
  max-width: 90vw;
  max-height: 80vh;
  object-fit: contain;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
}
.att-viewer__close {
  position: absolute;
  top: -36px;
  right: 0;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  background: rgb(255 255 255 / 0.15);
  color: white;
  border: 0;
  cursor: pointer;
  font-size: 16px;
}
.att-viewer__meta {
  background: rgb(15 23 42 / 0.8);
  color: white;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius);
  margin-top: var(--space-2);
}
.att-viewer__meta.muted { color: rgb(255 255 255 / 0.8); }

/* =========================================================================
   Reduced motion — respect OS preference
   ========================================================================= */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0ms !important;
    animation-duration: 0ms !important;
    animation-iteration-count: 1 !important;
  }
  .home-tile:hover { transform: none; }
  .btn:active { transform: none; }
}
