/* ==========================================================================
   RRISE — App layer on Appica UI
   Rules that the token set depends on and that are easy to break:
     - --primary is near-black (light) / white (dark). Text on a primary
       surface is ALWAYS var(--primary-foreground), never a hardcoded white.
     - Blue is accent only: var(--accent) / var(--secondary-*).
     - This file uses tokens, not literal colours. The four exceptions are
       marked inline.
   Component layer lifted from the Cold Call CRM (same design system).
   ========================================================================== */

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--foreground);
  background-color: var(--background);
  /* Dot-Pattern */
  background-image: radial-gradient(var(--dot) 1px, transparent 1px);
  background-size: 22px 22px;
  background-position: -1px -1px;
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

::selection { background: var(--selection-color); }

h1, h2, h3, h4 {
  margin: 0;
  color: var(--foreground-intense);
  font-weight: 600;
  letter-spacing: -0.015em;
}
h1 { font-size: 1.5rem; letter-spacing: -0.03em; }
h2 { font-size: 1.0625rem; }
h3 { font-size: 0.9375rem; }
p  { margin: 0; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

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

.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--foreground-muted); }
.subtle { color: var(--foreground-subtle); }
.strong { color: var(--foreground-intense); }
.tnum { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hidden { display: none !important; }
.right { text-align: right; }

.label {
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--foreground-subtle);
}

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

.shell {
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 20px 80px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--glass);
  backdrop-filter: blur(14px) saturate(1.6);
  -webkit-backdrop-filter: blur(14px) saturate(1.6);
  border-bottom: var(--border-width) solid var(--border);
}

.topbar-inner {
  max-width: 1240px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 650;
  color: var(--foreground-intense);
  letter-spacing: -0.02em;
  white-space: nowrap;
}
/* Das WS-Monogramm auf Waldgrün — dieselbe Datei wie das Favicon der Website.
   Als fertige Grafik statt Buchstabe auf --primary, weil --primary im Dark Mode
   auf Weiß kippt und die Marke dort ihre Farbe verlieren würde. */
.brand-mark {
  /* 28px statt 26: das Monogramm bringt eigenen Innenabstand mit und wirkt
     sonst neben der zweizeiligen Wortmarke zu zierlich. */
  width: 28px; height: 28px;
  border-radius: var(--radius-2xs);
  display: block;
  flex: none;
}
.brand small {
  display: block;
  font-size: 0.625rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--foreground-subtle);
}

/* Pill-Nav */
.nav {
  display: flex;
  gap: 2px;
  padding: 3px;
  border-radius: 999px;
  background: var(--background-muted);
  border: var(--border-width) solid var(--border-muted);
}
.nav a {
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 0.8125rem;
  font-weight: 550;
  color: var(--foreground-muted);
  text-decoration: none;
  white-space: nowrap;
  transition: color .15s, background-color .15s;
}
.nav a:hover { color: var(--foreground-intense); text-decoration: none; }
.nav a.active {
  background: var(--background);
  color: var(--foreground-intense);
  box-shadow: 0 1px 2px var(--shadow-color);
}
.nav a .cnt {
  margin-left: 6px;
  font-size: 0.6875rem;
  font-variant-numeric: tabular-nums;
  color: var(--foreground-subtle);
}

.topbar-end { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.live-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px 5px 10px;
  border-radius: 999px;
  background: var(--success-soft);
  color: var(--success-intense);
  font-size: 0.8125rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  border: var(--border-width) solid transparent;
}
.live-chip .bar {
  width: 3px; height: 12px;
  border-radius: 2px;
  background: currentColor;
  animation: pulse-bar 1.4s ease-in-out infinite;
}
@keyframes pulse-bar { 0%,100% { opacity:.35; transform: scaleY(.6);} 50% { opacity:1; transform: scaleY(1);} }
@media (prefers-reduced-motion: reduce) { .live-chip .bar { animation: none; } }

/* ---------- Page-Head --------------------------------------------------- */

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 32px 0 20px;
}
.page-head .sub { color: var(--foreground-muted); margin-top: 4px; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Card -------------------------------------------------------- */

.card {
  background: var(--glass);
  backdrop-filter: blur(10px) saturate(1.4);
  -webkit-backdrop-filter: blur(10px) saturate(1.4);
  border: var(--border-width) solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 1px 2px var(--shadow-color);
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: var(--border-width) solid var(--border-muted);
}
.card-body { padding: 18px; }
.card-body.flush { padding: 0; }

.grid { display: grid; gap: 14px; }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.split  { grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); }
.stack { display: grid; gap: 14px; }

/* ---------- Stat -------------------------------------------------------- */

/* The CRM builds these from <div>s, so it never needed a display rule. RRISE
   builds them from <span>s, which are inline — without this the label, value
   and detail all flow into one line. Grid makes the tag irrelevant. */
.stat { padding: 16px 18px; display: grid; align-content: start; }
.stat .k {
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--foreground-subtle);
}
.stat .v {
  margin-top: 6px;
  font-size: 1.875rem;
  font-weight: 600;
  letter-spacing: -0.035em;
  color: var(--foreground-intense);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.stat .v small { font-size: 0.9375rem; font-weight: 500; color: var(--foreground-subtle); letter-spacing: 0; }
.stat .d {
  margin-top: 6px;
  font-size: 0.75rem;
  color: var(--foreground-muted);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.meter {
  height: 4px;
  margin-top: 12px;
  border-radius: 999px;
  background: var(--background-strong);
  overflow: hidden;
}
.meter i { display: block; height: 100%; border-radius: 999px; background: var(--primary); }
.meter i.acc { background: var(--accent); }
.meter i.ok  { background: var(--success-emphasis); }

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 14px;
  border-radius: var(--radius-2xs);
  border: var(--border-width) solid var(--border);
  background: var(--background);
  color: var(--foreground-strong);
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 550;
  line-height: 1.2;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color .14s, border-color .14s, color .14s, transform .06s;
}
.btn:hover { background: var(--background-muted); color: var(--foreground-intense); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: var(--opacity-disabled); cursor: not-allowed; }

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

.btn-accent {
  background: var(--accent);
  border-color: var(--accent);
  color: oklch(1 0 0);
}
.btn-accent:hover { background: var(--secondary-intense); border-color: var(--secondary-intense); color: oklch(1 0 0); }

.btn-ghost { background: transparent; border-color: transparent; color: var(--foreground-muted); }
.btn-ghost:hover { background: var(--background-muted); }

.btn-danger { color: var(--error-intense); border-color: var(--error-muted); background: var(--error-subtle); }
.btn-danger:hover { background: var(--error-soft); color: var(--error-intense); }

/* Blau wie .outcome.keep — für Dranbleiben-Ergebnisse in der zweiten Reihe. */
.btn.keep { color: var(--info-intense); border-color: var(--info-muted); background: var(--info-subtle); }
.btn.keep:hover { background: var(--info-soft); color: var(--info-intense); }

.btn-lg { padding: 11px 18px; font-size: 0.875rem; border-radius: var(--radius-xs); }
.btn-sm { padding: 5px 10px; font-size: 0.75rem; border-radius: var(--radius-3xs); }
.btn-icon { padding: 7px; width: 32px; height: 32px; }

.btn-group { display: inline-flex; gap: 6px; flex-wrap: wrap; }

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

.field { display: grid; gap: 5px; }
.field > span {
  font-size: 0.75rem;
  font-weight: 550;
  color: var(--foreground-muted);
}

/* Häkchen-Feld: der Text sitzt neben dem Kästchen, nicht darüber. */
.field-check > span {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--foreground);
  cursor: pointer;
}
.field-check input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; }

input[type=text], input[type=search], input[type=tel], input[type=email], input[type=date],
input[type=time], input[type=number], select, textarea {
  width: 100%;
  padding: 8px 11px;
  border-radius: var(--radius-2xs);
  border: var(--border-width) solid var(--border);
  background: var(--background);
  color: var(--foreground-intense);
  font: inherit;
  font-size: 0.8125rem;
  transition: border-color .14s, box-shadow .14s;
}
textarea { resize: vertical; min-height: 64px; line-height: 1.5; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--border-emphasis);
  box-shadow: 0 0 0 3px var(--focus-ring-input);
}
input::placeholder, textarea::placeholder { color: var(--foreground-subtle); }
select {
  appearance: none;
  padding-right: 30px;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: right 13px center, right 8px center;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  cursor: pointer;
}

.toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  padding: 14px 18px;
  border-bottom: var(--border-width) solid var(--border-muted);
}
.toolbar .grow { flex: 1 1 220px; min-width: 180px; }
.toolbar select { width: auto; min-width: 130px; }

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

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.6875rem;
  font-weight: 600;
  white-space: nowrap;
  border: var(--border-width) solid transparent;
}
.badge::before {
  content: '';
  width: 5px; height: 5px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}
.badge.bare::before { display: none; }

.t-neutral { background: var(--background-muted); color: var(--foreground-muted); border-color: var(--border); }
.t-success { background: var(--success-subtle); color: var(--success-intense); }
.t-error   { background: var(--error-subtle);   color: var(--error-intense); }
.t-warning { background: var(--warning-subtle); color: var(--warning-intense); }
.t-info    { background: var(--info-subtle);    color: var(--info-intense); }
.t-accent  { background: var(--secondary-subtle); color: var(--secondary-intense); }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--background-muted);
  border: var(--border-width) solid var(--border-muted);
  color: var(--foreground-muted);
  font-size: 0.75rem;
  font-weight: 500;
}

/* ---------- Tabellen (native) ------------------------------------------- */

.table-wrap { overflow-x: auto; }

table.native {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
}
table.native th {
  position: sticky;
  top: 0;
  z-index: 1;
  text-align: left;
  padding: 10px 14px;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--foreground-subtle);
  background: var(--background-subtle);
  border-bottom: var(--border-width) solid var(--border);
  white-space: nowrap;
}
table.native th.sortable { cursor: pointer; user-select: none; }
table.native th.sortable:hover { color: var(--foreground-intense); }
table.native th .arrow { opacity: .5; font-size: 0.625rem; }
table.native td {
  padding: 11px 14px;
  border-bottom: var(--border-width) solid var(--border-muted);
  vertical-align: middle;
  color: var(--foreground-strong);
}
table.native td select { min-width: 148px; }
/* Mailspalte in der Terminliste — Eingabefeld und Mail-Button nebeneinander. */
table.native td.mail-cell { min-width: 210px; }
table.native td.mail-cell .wrap { display: flex; align-items: center; gap: 4px; }
table.native td.mail-cell input { padding: 5px 8px; font-size: 0.75rem; }
table.native td.mono { white-space: nowrap; }
table.native tbody tr { transition: background-color .12s; }
/* Ganze Zeile öffnet den Lead — Eingabefelder und Buttons darin fangen den
   Klick vorher ab, weil der Handler mit closest() das nächste data-act nimmt. */
table.native tbody tr.clickable { cursor: pointer; }
table.native tbody tr:hover { background: var(--background-subtle); }
table.native tbody tr:last-child td { border-bottom: 0; }
table.native td.name { color: var(--foreground-intense); font-weight: 550; }
table.native .row-actions { display: flex; gap: 4px; justify-content: flex-end; }

.empty {
  padding: 48px 24px;
  text-align: center;
  color: var(--foreground-muted);
}
.empty h3 { color: var(--foreground-strong); margin-bottom: 6px; }

/* ---------- Charts ------------------------------------------------------ */

.chart { display: flex; align-items: flex-end; gap: 6px; min-height: 148px; padding-top: 8px; }
.chart .col {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 2px;
  position: relative;
  min-width: 0;
}
.chart .col .b {
  border-radius: var(--radius-4xs) var(--radius-4xs) 0 0;
  background: var(--primary-soft);
  transition: opacity .14s;
  min-height: 2px;
}
.chart .col .b.t { background: var(--success-emphasis); }
.chart .col:hover .b { opacity: .78; }
.chart .col .x {
  margin-top: 8px;
  text-align: center;
  font-size: 0.625rem;
  color: var(--foreground-subtle);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
}
.chart-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 0.75rem; color: var(--foreground-muted); }
.chart-legend i { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

.dist { display: flex; height: 10px; border-radius: 999px; overflow: hidden; background: var(--background-strong); }
.dist i { height: 100%; }
.dist-legend { display: grid; gap: 8px; margin-top: 16px; }
.dist-legend .row { display: flex; align-items: center; gap: 10px; font-size: 0.8125rem; }
.dist-legend .row .sw { width: 9px; height: 9px; border-radius: 3px; flex: none; }
.dist-legend .row .nm { flex: 1; color: var(--foreground-strong); }
.dist-legend .row .n { font-variant-numeric: tabular-nums; color: var(--foreground-intense); font-weight: 600; }
.dist-legend .row .p { font-variant-numeric: tabular-nums; color: var(--foreground-subtle); width: 42px; text-align: right; }

/* ---------- Drawer / Modal ---------------------------------------------- */

.scrim {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: oklch(0.13 0.028 261.692 / 40%);
  backdrop-filter: blur(2px);
  display: flex;
  justify-content: flex-end;
  animation: fade .18s ease;
}
.scrim.center { align-items: center; justify-content: center; padding: 20px; }
@keyframes fade { from { opacity: 0; } }

.drawer {
  width: min(520px, 100%);
  height: 100%;
  overflow-y: auto;
  background: var(--background);
  border-left: var(--border-width) solid var(--border);
  animation: slide-in .22s cubic-bezier(.32,.72,0,1);
}
@keyframes slide-in { from { transform: translateX(24px); opacity: .6; } }

.modal {
  width: min(460px, 100%);
  /* Auf die Sichthöhe begrenzen und innen scrollen. Ohne das wächst ein langes
     Modal über den zentrierten Scrim hinaus und sein oberer Teil — beim
     Composer die Vorlagenauswahl — ist nicht mehr erreichbar. */
  max-height: calc(100dvh - 40px);
  display: flex;
  flex-direction: column;
  background: var(--background);
  border: var(--border-width) solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 48px -12px var(--shadow-color);
  animation: pop .18s cubic-bezier(.32,.72,0,1);
}
.modal > .modal-body { overflow-y: auto; min-height: 0; }
.modal > .modal-head, .modal > .modal-foot { flex: none; }
@keyframes pop { from { transform: scale(.97); opacity: 0; } }

.drawer-head, .modal-head {
  position: sticky;
  top: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px;
  background: var(--background);
  border-bottom: var(--border-width) solid var(--border-muted);
}
.drawer-body, .modal-body { padding: 20px; display: grid; gap: 18px; }
.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 20px;
  border-top: var(--border-width) solid var(--border-muted);
}

.kv { display: grid; grid-template-columns: 110px 1fr; gap: 8px 14px; font-size: 0.8125rem; }
.kv dt { color: var(--foreground-subtle); }
.kv dd { margin: 0; color: var(--foreground-intense); }

.timeline { display: grid; gap: 0; }
.timeline .e {
  display: grid;
  grid-template-columns: 12px 1fr;
  gap: 12px;
  padding-bottom: 14px;
}
.timeline .e .dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--border-intense);
  margin-top: 5px;
  position: relative;
}
.timeline .e:not(:last-child) .dot::after {
  content: '';
  position: absolute;
  left: 50%; top: 12px;
  width: 1px; height: calc(100% + 14px);
  background: var(--border);
  transform: translateX(-50%);
}
.timeline .e .t { font-size: 0.8125rem; color: var(--foreground-strong); }
.timeline .e .d { font-size: 0.6875rem; color: var(--foreground-subtle); font-variant-numeric: tabular-nums; }

/* ---------- Toast ------------------------------------------------------- */

.toasts {
  position: fixed;
  bottom: 20px; left: 50%;
  transform: translateX(-50%);
  z-index: 80;
  display: grid;
  gap: 8px;
  justify-items: center;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--background-inverse);
  color: var(--foreground-inverse);
  font-size: 0.8125rem;
  font-weight: 500;
  box-shadow: 0 8px 24px -6px var(--shadow-color);
  animation: toast-in .22s cubic-bezier(.32,.72,0,1);
  pointer-events: auto;
}
.toast .u {
  color: inherit;
  opacity: .75;
  text-decoration: underline;
  cursor: pointer;
  font-weight: 600;
}
.toast .u:hover { opacity: 1; }
@keyframes toast-in { from { transform: translateY(10px); opacity: 0; } }

/* ---------- Reveal ------------------------------------------------------ */

.reveal { opacity: 0; transform: translateY(14px); }
.reveal.in {
  opacity: 1;
  transform: none;
  transition: opacity .5s cubic-bezier(.32,.72,0,1), transform .5s cubic-bezier(.32,.72,0,1);
}
@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; }
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}


/* ==========================================================================
   RRISE-specific components
   ========================================================================== */

/* ---------- Login ------------------------------------------------------- */

.login-wrap {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: min(380px, 100%);
  background: var(--glass);
  backdrop-filter: blur(10px) saturate(1.4);
  border: var(--border-width) solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 48px -20px var(--shadow-color);
  padding: 28px;
  display: grid;
  gap: 18px;
}
.login-card .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: center;
  margin-bottom: 2px;
}
.login-card .brand-mark { width: 30px; height: 30px; border-radius: var(--radius-2xs); }
.login-card h1 { font-size: 1.125rem; text-align: center; }
.login-card .sub { text-align: center; color: var(--foreground-muted); font-size: 0.8125rem; }
.login-err {
  padding: 9px 12px;
  border-radius: var(--radius-2xs);
  background: var(--error-subtle);
  border: 1px solid var(--error-muted);
  color: var(--error-intense);
  font-size: 0.8125rem;
}

/* ---------- Status LED --------------------------------------------------- */

/* One dot, four meanings. Colour alone is never the only signal — every use
   pairs it with a title attribute, because a red/green pair is the single
   most common accessibility failure in a dashboard. */
.led {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--border-emphasis);
  flex: none;
}
.led.ok    { background: var(--success-emphasis); }
.led.warn  { background: var(--warning-emphasis); }
.led.err   { background: var(--error-emphasis); }
.led.pulse { animation: led-pulse 2s ease-in-out infinite; }
@keyframes led-pulse { 0%,100% { opacity: 1 } 50% { opacity: .35 } }

/* ---------- Form rows in drawers ---------------------------------------- */

.form-grid { display: grid; gap: 14px; }
.form-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-row { display: grid; gap: 5px; }
.form-row > .label { margin-bottom: 1px; }
.form-row .hint { font-size: 0.75rem; color: var(--foreground-subtle); }
.form-row.err input,
.form-row.err select,
.form-row.err textarea { border-color: var(--error-emphasis); }
.form-row .err-msg { font-size: 0.75rem; color: var(--error-intense); }

/* A secret that is already stored: the value is never sent to the browser, so
   the field shows state instead of content and only writes when typed into. */
.secret-set {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--success-emphasis);
}

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

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-muted);
  flex-wrap: wrap;
}
.toolbar .spacer { margin-left: auto; }
.toolbar input[type="search"],
.toolbar input[type="text"] { width: auto; min-width: 200px; }

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

.skeleton {
  border-radius: var(--radius-2xs);
  background: linear-gradient(90deg,
    var(--background-muted) 25%,
    var(--background-strong) 37%,
    var(--background-muted) 63%);
  background-size: 400% 100%;
  animation: skeleton 1.4s ease infinite;
}
@keyframes skeleton { 0% { background-position: 100% 50% } 100% { background-position: 0 50% } }
.skeleton-row { height: 38px; margin: 6px 0; }

/* ---------- Responsive --------------------------------------------------- */

@media (max-width: 980px) {
  .grid.cols-4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .grid.split, .grid.cols-3 { grid-template-columns: minmax(0, 1fr); }
  .form-grid.two { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 640px) {
  .shell { padding: 0 14px 60px; }
  .topbar-inner { padding: 10px 14px; gap: 10px; }
  .nav { width: 100%; overflow-x: auto; }
  .topbar-end { margin-left: 0; }
  .grid.cols-4, .grid.cols-2 { grid-template-columns: minmax(0,1fr); }
  .drawer { width: 100%; }
  .toolbar input[type="search"] { min-width: 0; width: 100%; }
}

@media print {
  .topbar, .toasts, .btn { display: none !important; }
  body { background: none; }
}

/* ---------- Custom checkbox (lifted verbatim: the ::after tick geometry is
   fiddly and there is no reason to re-derive it) -------------------------- */

.check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 0.8125rem;
  color: var(--foreground-muted);
  user-select: none;
}
.check input[type=checkbox] {
  appearance: none;
  width: 17px; height: 17px;
  flex: none;
  margin: 0;
  border-radius: var(--radius-4xs);
  border: var(--border-width) solid var(--border-emphasis);
  background: var(--background);
  cursor: pointer;
  position: relative;
  transition: background-color .14s, border-color .14s;
}
.check input[type=checkbox]:checked {
  background: var(--success-emphasis);
  border-color: var(--success-emphasis);
}
.check input[type=checkbox]:checked::after {
  content: '';
  position: absolute;
  left: 5px; top: 1px;
  width: 4px; height: 9px;
  border: solid oklch(1 0 0);
  border-width: 0 2px 2px 0;
  transform: rotate(43deg);
}
.check input[type=checkbox]:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.check input[type=checkbox]:checked + span { color: var(--success-intense); font-weight: 550; }

/* ---------- Key/value list ---------------------------------------------- */

/* The CRM's .kv is a <dl>. RRISE builds these from spans, so both shapes are
   supported rather than forcing one markup style on every caller. */
.kv > .k, .kv dt { color: var(--foreground-subtle); }
.kv > .v, .kv dd { margin: 0; color: var(--foreground-intense); }
.kv > .v .subtle { color: var(--foreground-subtle); }

/* ---------- 2FA cell ----------------------------------------------------- */

.totp { display: grid; gap: 5px; min-width: 104px; }

/* The code is a button because it does something. Monospace and letter-spaced
   so 0/O and 1/l are unambiguous while someone reads it aloud or types it. */
.totp-code {
  justify-content: center;
  padding: 4px 9px;
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
  color: var(--foreground-intense);
}
.totp-code:hover { background: var(--background-muted); }
.totp-code.copied {
  background: var(--success-subtle);
  border-color: var(--success-muted);
  color: var(--success-intense);
}
.totp .meter { margin-top: 0; height: 3px; }
/* Below five seconds the bar drops out of success into the default primary
   fill — a code that is about to expire should not look ready to use. */
.totp .meter i { transition: width 1s linear, background-color .2s; }

/* ---------- Clickable rows ---------------------------------------------- */

/* The whole row is the affordance — there is no Edit button. Cells that do
   something of their own carry data-act="no-row-click". */
tr.row-link { cursor: pointer; }
tr.row-link:hover { background: var(--background-subtle); }
tr.row-link:active { background: var(--background-muted); }

/* ---------- Media library ------------------------------------------------ */

/* A folder rail beside the grid, rather than the two-state "folder grid, then
   file grid" of the system this replaces. That design hid the folder list the
   moment you opened a folder, so filing a loose file meant navigating back out
   first — which is why the old page grew a drag-and-drop path that only worked
   in one of its two states. */
/* The account picker sits in the page head next to the buttons, so it must not
   take the full-width sizing every other select gets. */
.page-head select, .btn-group select { width: auto; min-width: 168px; }
.toolbar h2 { font-size: 1rem; margin: 0; }
.toolbar input[type=search] { width: auto; min-width: 200px; flex: 0 1 260px; }

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

.folder-rail { display: flex; flex-direction: column; gap: 2px; }
.folder-rail .rail-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 2px 8px 6px; color: var(--foreground-muted);
  font-size: 0.75rem; letter-spacing: .06em; text-transform: uppercase;
}
.folder-item {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 7px 9px; border: 0; border-radius: var(--radius-sm);
  background: transparent; color: var(--foreground); cursor: pointer;
  font: inherit; font-size: 0.9375rem; text-align: left;
}
.folder-item:hover { background: var(--background-subtle); }
.folder-item.active { background: var(--background-muted); color: var(--foreground-intense); font-weight: 600; }
.folder-item .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder-item .count { color: var(--foreground-subtle); font-variant-numeric: tabular-nums; font-size: 0.8125rem; }
/* The type dot says what the badge on the folder header says, so the rail needs
   no second line of text per row. */
.folder-item .dot { width: 7px; height: 7px; border-radius: 50%; flex: none; background: var(--border-intense); }
.folder-item .dot.ppv { background: var(--primary); }
.folder-item .dot.teaser { background: var(--warning); }
/* A priced folder with nothing in it cannot be sold. Worth seeing in the list,
   not only after opening it. */
.folder-item .dot.empty { background: var(--error); }

.media-grid {
  display: grid; gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
}
.media-card {
  position: relative; border: var(--border-width) solid var(--border);
  border-radius: var(--radius-md); overflow: hidden; background: var(--background-subtle);
  cursor: pointer; transition: border-color .15s, transform .15s;
}
.media-card:hover { border-color: var(--border-strong); transform: translateY(-1px); }
.media-card.sel { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
/* Excluded from posting: the file is still perfectly usable in chat, so it is
   dimmed rather than marked as an error. */
.media-card.excluded .thumb { opacity: .45; }
.media-card .thumb {
  aspect-ratio: 1; display: flex; align-items: center; justify-content: center;
  background: var(--background-muted); color: var(--foreground-subtle); font-size: 1.5rem;
}
.media-card .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-card .meta { padding: 6px 8px 8px; display: flex; flex-direction: column; gap: 2px; }
.media-card .meta .n {
  font-size: 0.8125rem; font-weight: 600; color: var(--foreground-strong);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.media-card .meta .d { font-size: 0.75rem; color: var(--foreground-subtle); font-variant-numeric: tabular-nums; }
.media-card .pill {
  position: absolute; top: 6px; right: 6px; padding: 1px 6px;
  border-radius: var(--radius-2xs); background: var(--background-inverse);
  color: var(--foreground-inverse); font-size: 0.6875rem; font-weight: 600;
  font-variant-numeric: tabular-nums;
}
/* Selection needs its own target: clicking the thumbnail opens the file, which
   is what people expect, so ticking cannot be the same gesture. */
.media-card .tick {
  position: absolute; top: 6px; left: 6px; width: 20px; height: 20px;
  border-radius: 50%; border: var(--border-width) solid var(--border-inverse);
  background: var(--glass); opacity: 0; transition: opacity .15s;
  display: flex; align-items: center; justify-content: center;
  color: var(--foreground-inverse); font-size: 0.75rem; line-height: 1;
}
.media-card:hover .tick, .media-card.sel .tick { opacity: 1; }
.media-card.sel .tick { background: var(--primary); border-color: var(--primary); color: var(--primary-foreground); }
/* Where a file stands with Fansly. "Not uploaded yet" is a normal state and is
   therefore silent — only progress and failure say anything. */
.media-card .cloud { position: absolute; bottom: 42px; right: 6px; font-size: 0.75rem; line-height: 1; }
.media-card .cloud.ok { color: var(--success); }
.media-card .cloud.err { color: var(--error); }
.media-card .cloud.busy { color: var(--warning); animation: cloud-pulse 1.2s ease-in-out infinite; }
@keyframes cloud-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

/* The whole grid takes a drop, so there is no small target to miss. The outline
   is drawn outside the box to keep the drag from reflowing the grid. */
.dropzone { border-radius: var(--radius-lg); outline: 2px dashed transparent; outline-offset: 6px;
  transition: outline-color .15s, background-color .15s; }
.dropzone.over { outline-color: var(--primary); background: var(--primary-subtle); }

.upload-tile {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; aspect-ratio: 1; cursor: pointer;
  border: var(--border-width) dashed var(--border-strong); border-radius: var(--radius-md);
  color: var(--foreground-muted); background: transparent;
}
.upload-tile:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-subtle); }
.upload-tile .plus { font-size: 1.5rem; line-height: 1; }
.upload-tile .lbl { font-size: 0.8125rem; font-weight: 600; }

/* Per-file progress rather than an aggregate: the old uploader reported
   "10/12 uploaded (2 failed)" and never said which two, which made a failure
   impossible to act on. */
.upload-list { display: flex; flex-direction: column; gap: 8px; }
.upload-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 10px; align-items: center; }
.upload-row .n { font-size: 0.875rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-row .s { font-size: 0.8125rem; color: var(--foreground-subtle); font-variant-numeric: tabular-nums; }
.upload-row .meter { grid-column: 1 / -1; margin: 0; }
.upload-row.failed .n { color: var(--error); }
.upload-row.done .s { color: var(--success); }

/* Selection actions, pinned to the viewport so they stay reachable after
   scrolling a long grid. */
.bulk-bar {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%);
  z-index: 60; display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border-radius: var(--radius-xl);
  border: var(--border-width) solid var(--border-strong);
  background: var(--glass); backdrop-filter: blur(12px);
  box-shadow: 0 8px 24px -8px var(--shadow-color);
}
.bulk-bar .n { font-size: 0.875rem; font-weight: 600; padding: 0 4px; }

/* The grid is the gallery, so the viewer pages through it instead of showing
   one file in isolation. */
.lightbox { position: fixed; inset: 0; z-index: 80; display: flex; align-items: center; justify-content: center;
  background: color-mix(in srgb, var(--background-inverse) 92%, transparent); }
.lightbox .stage { max-width: 88vw; max-height: 78vh; display: flex; }
.lightbox .stage img, .lightbox .stage video { max-width: 88vw; max-height: 78vh; object-fit: contain; border-radius: var(--radius-md); }
.lightbox .cap { position: absolute; bottom: 18px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 10px; color: var(--foreground-inverse); font-size: 0.875rem; }
.lightbox .arrow { position: absolute; top: 50%; transform: translateY(-50%); }
.lightbox .arrow.prev { left: 16px; }
.lightbox .arrow.next { right: 16px; }
.lightbox .x { position: absolute; top: 16px; right: 16px; }
