/* =============================================================================
   Revenax Pulse — web app design system
   Dark-first, brand indigo→violet gradient, "live" green for unread state.
   Mirrors the Flutter app's tokens (see app/lib/theme.dart) so the two clients
   read as one product. No framework, no build step.
   ========================================================================== */

@font-face {
  font-family: "Outfit";
  src: url("/fonts/Outfit.ttf") format("truetype");
  font-weight: 100 900;
  font-display: swap;
}

/* --- Tokens: light is the base, dark overrides ---------------------------- */
:root {
  --brand-1: #6366f1;
  --brand-2: #8b5cf6;
  --brand-soft: rgba(99, 102, 241, 0.12);
  --live: #22c55e;
  --danger: #ef4444;
  --warn: #f59e0b;

  --bg: #fcfcff;
  --bg-wash: radial-gradient(1200px 600px at 50% -220px, rgba(99, 102, 241, 0.16), transparent 70%);
  --surface: #ffffff;
  --surface-2: #f6f6fb;
  --surface-3: #ececf6;
  --border: rgba(16, 16, 40, 0.09);
  --border-strong: rgba(16, 16, 40, 0.16);

  --text: #14152a;
  --text-dim: #4b4c66;
  --text-mute: #7a7b95;

  --radius-sm: 12px;
  --radius-md: 16px;
  --radius-lg: 20px;
  --radius-xl: 28px;

  --shadow-1: 0 1px 2px rgba(16, 16, 40, 0.06), 0 4px 16px rgba(16, 16, 40, 0.06);
  --shadow-2: 0 8px 40px rgba(16, 16, 40, 0.14);

  --gradient: linear-gradient(135deg, var(--brand-1), var(--brand-2));
  --font: "Outfit", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;

  --sidebar-w: 260px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1018;
    --bg-wash: radial-gradient(
      1200px 600px at 50% -240px,
      rgba(139, 92, 246, 0.18),
      transparent 70%
    );
    --surface: #14151f;
    --surface-2: #171826;
    --surface-3: #212234;
    --border: rgba(255, 255, 255, 0.08);
    --border-strong: rgba(255, 255, 255, 0.16);
    --text: #edeef7;
    --text-dim: #b6b8cf;
    --text-mute: #83859f;
    --brand-soft: rgba(139, 92, 246, 0.18);
    --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.28);
    --shadow-2: 0 12px 48px rgba(0, 0, 0, 0.5);
  }
}

:root[data-theme="dark"] {
  --bg: #0f1018;
  --bg-wash: radial-gradient(1200px 600px at 50% -240px, rgba(139, 92, 246, 0.18), transparent 70%);
  --surface: #14151f;
  --surface-2: #171826;
  --surface-3: #212234;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #edeef7;
  --text-dim: #b6b8cf;
  --text-mute: #83859f;
  --brand-soft: rgba(139, 92, 246, 0.18);
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.28);
  --shadow-2: 0 12px 48px rgba(0, 0, 0, 0.5);
}

/* --- Reset --------------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}
* {
  margin: 0;
}
html,
body {
  height: 100%;
}
body {
  font-family: var(--font);
  background: var(--bg-wash), var(--bg);
  background-attachment: fixed;
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img,
svg {
  display: block;
  max-width: 100%;
}
/* Default icon size; component rules below override where needed. */
.icon {
  width: 20px;
  height: 20px;
  flex: none;
}
button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}
a {
  color: inherit;
  text-decoration: none;
}
:focus-visible {
  outline: 2px solid var(--brand-1);
  outline-offset: 2px;
  border-radius: 6px;
}
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  padding: 12px 18px;
  background: var(--surface);
  border-radius: 0 0 var(--radius-sm) 0;
}
.skip-link:focus {
  left: 0;
}

/* --- Typography ---------------------------------------------------------- */
h1,
h2,
h3 {
  letter-spacing: -0.02em;
  line-height: 1.2;
  font-weight: 700;
}
h1 {
  font-size: clamp(1.5rem, 1.2rem + 1.2vw, 2rem);
}
h2 {
  font-size: 1.25rem;
}
h3 {
  font-size: 1.02rem;
  font-weight: 600;
}
.muted {
  color: var(--text-mute);
}
.dim {
  color: var(--text-dim);
}
.mono {
  font-family: var(--mono);
  font-size: 0.86em;
}
.eyebrow {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-mute);
}
.gradient-text {
  background: var(--gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* --- Boot splash --------------------------------------------------------- */
.boot {
  min-height: 100dvh;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 18px;
}
.boot-mark {
  width: 64px;
  height: 64px;
  border-radius: 20px;
  background: var(--gradient);
  box-shadow: var(--shadow-2);
  animation: pulse 1.6s var(--ease) infinite;
}
.boot-text {
  color: var(--text-mute);
  letter-spacing: 0.02em;
}
@keyframes pulse {
  0%,
  100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(0.9);
    opacity: 0.7;
  }
}

/* --- App shell ----------------------------------------------------------- */
.shell {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 22px 16px;
  border-right: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 70%, transparent);
  backdrop-filter: blur(12px);
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 8px 18px;
}
.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 11px;
  background: var(--gradient);
  display: grid;
  place-items: center;
  flex: none;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.35);
}
.brand-mark svg {
  width: 20px;
  height: 20px;
}
.brand-name {
  font-weight: 700;
  letter-spacing: -0.02em;
}
.brand-sub {
  font-size: 0.72rem;
  color: var(--text-mute);
  margin-top: -3px;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.nav-label {
  padding: 16px 12px 6px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-weight: 500;
  transition:
    background 0.18s var(--ease),
    color 0.18s var(--ease);
}
.nav-item:hover {
  background: var(--surface-2);
  color: var(--text);
}
.nav-item.active {
  background: var(--brand-soft);
  color: var(--text);
  font-weight: 600;
}
.nav-item .icon {
  width: 20px;
  height: 20px;
  flex: none;
  opacity: 0.9;
}
.nav-item .count {
  margin-left: auto;
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--gradient);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  display: grid;
  place-items: center;
}
.sidebar-foot {
  margin-top: auto;
  display: grid;
  gap: 10px;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: var(--radius-md);
  background: var(--surface-2);
  border: 1px solid var(--border);
  width: 100%;
  text-align: left;
  cursor: pointer;
}
.user-chip:hover {
  border-color: var(--border-strong);
}
.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  flex: none;
  display: grid;
  place-items: center;
  font-size: 0.8rem;
  font-weight: 700;
  color: #fff;
  background: var(--gradient);
}
.avatar.lg {
  width: 56px;
  height: 56px;
  font-size: 1.1rem;
}
.user-meta {
  min-width: 0;
}
.user-meta strong {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.user-meta span {
  font-size: 0.75rem;
  color: var(--text-mute);
}

.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.page {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 100%;
}
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 26px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(14px);
}
.topbar h1 {
  font-size: 1.3rem;
}
.topbar .spacer {
  flex: 1;
}
.content {
  padding: 26px;
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  flex: 1;
}
.content.narrow {
  max-width: 760px;
}
.view-enter {
  animation: rise 0.32s var(--ease) both;
}
@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

/* Mobile: top bar + bottom tabs, no sidebar. */
.tabbar {
  display: none;
}
@media (max-width: 899px) {
  .shell {
    grid-template-columns: 1fr;
  }
  .sidebar {
    display: none;
  }
  .content {
    padding: 18px 16px calc(96px + env(safe-area-inset-bottom));
  }
  .topbar {
    padding: 12px 16px;
    padding-top: calc(12px + env(safe-area-inset-top));
  }
  .tabbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 30;
    display: grid;
    grid-auto-flow: column;
    gap: 4px;
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    backdrop-filter: blur(16px);
    border-top: 1px solid var(--border);
  }
  .tab {
    display: grid;
    justify-items: center;
    gap: 3px;
    padding: 7px 4px;
    border-radius: var(--radius-sm);
    color: var(--text-mute);
    font-size: 0.68rem;
    font-weight: 600;
    position: relative;
  }
  .tab .icon {
    width: 22px;
    height: 22px;
  }
  .tab.active {
    color: var(--brand-1);
  }
  .tab .count {
    position: absolute;
    top: 2px;
    right: calc(50% - 20px);
    min-width: 17px;
    height: 17px;
    padding: 0 5px;
    border-radius: 999px;
    background: var(--danger);
    color: #fff;
    font-size: 0.62rem;
    display: grid;
    place-items: center;
  }
}

/* --- Buttons ------------------------------------------------------------- */
.btn {
  --btn-bg: var(--surface-2);
  --btn-fg: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--btn-bg);
  color: var(--btn-fg);
  font-weight: 600;
  font-size: 0.94rem;
  cursor: pointer;
  transition:
    transform 0.12s var(--ease),
    filter 0.18s var(--ease),
    background 0.18s var(--ease);
  white-space: nowrap;
}
.btn:hover:not(:disabled) {
  filter: brightness(1.06);
}
.btn:active:not(:disabled) {
  transform: scale(0.975);
}
.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.btn .icon {
  width: 18px;
  height: 18px;
}
.btn-primary {
  --btn-bg: var(--gradient);
  --btn-fg: #fff;
  border-color: transparent;
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.3);
}
.btn-danger {
  --btn-fg: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 40%, transparent);
  background: color-mix(in srgb, var(--danger) 12%, transparent);
}
.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-dim);
}
.btn-ghost:hover:not(:disabled) {
  background: var(--surface-2);
  color: var(--text);
}
.btn-sm {
  padding: 7px 12px;
  font-size: 0.84rem;
  border-radius: var(--radius-sm);
}
.btn-icon {
  padding: 9px;
  border-radius: 50%;
}
.btn-block {
  width: 100%;
}
.btn-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.fab {
  position: fixed;
  right: 20px;
  bottom: calc(84px + env(safe-area-inset-bottom));
  z-index: 25;
  box-shadow: var(--shadow-2);
}
@media (min-width: 900px) {
  .fab {
    display: none;
  }
}

/* --- Forms --------------------------------------------------------------- */
.field {
  display: grid;
  gap: 7px;
  margin-bottom: 16px;
}
.field label {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-dim);
}
.field .hint {
  font-size: 0.78rem;
  color: var(--text-mute);
}
.input,
.select,
.textarea {
  width: 100%;
  padding: 13px 15px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface-2);
  transition:
    border-color 0.16s var(--ease),
    background 0.16s var(--ease);
}
.input::placeholder,
.textarea::placeholder {
  color: var(--text-mute);
}
.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: var(--brand-1);
  background: var(--surface);
}
.textarea {
  min-height: 116px;
  resize: vertical;
  line-height: 1.55;
}
.select {
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--text-mute) 50%),
    linear-gradient(135deg, var(--text-mute) 50%, transparent 50%);
  background-position:
    right 20px center,
    right 14px center;
  background-size:
    6px 6px,
    6px 6px;
  background-repeat: no-repeat;
  padding-right: 40px;
}
.field-error {
  color: var(--danger);
  font-size: 0.84rem;
}
.search {
  position: relative;
  flex: 1;
  max-width: 420px;
}
.search .input {
  padding-left: 42px;
  border-radius: 999px;
}
.search .icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--text-mute);
  pointer-events: none;
}

.switch {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 0;
}
.switch-track {
  width: 48px;
  height: 28px;
  border-radius: 999px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  position: relative;
  cursor: pointer;
  flex: none;
  transition: background 0.2s var(--ease);
}
.switch-track[aria-checked="true"] {
  background: var(--gradient);
  border-color: transparent;
}
.switch-track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  transition: transform 0.2s var(--ease);
}
.switch-track[aria-checked="true"]::after {
  transform: translateX(20px);
}

.segmented {
  display: inline-flex;
  padding: 4px;
  gap: 2px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
}
.segmented button {
  padding: 7px 15px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text-mute);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition:
    background 0.18s var(--ease),
    color 0.18s var(--ease);
}
.segmented button.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-1);
}

/* --- Surfaces ------------------------------------------------------------ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-1);
  overflow: hidden;
}
.card-pad {
  padding: 22px;
}
.card-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
}
.card-head h2,
.card-head h3 {
  margin-right: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}
.card-head .icon {
  color: var(--text-mute);
}
.stack {
  display: grid;
  gap: 18px;
}
.row-between {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: space-between;
}
.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

/* --- Badges, chips ------------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 600;
  background: var(--surface-3);
  color: var(--text-dim);
  white-space: nowrap;
}
.badge-live {
  background: color-mix(in srgb, var(--live) 16%, transparent);
  color: var(--live);
}
.badge-brand {
  background: var(--brand-soft);
  color: var(--brand-1);
}
.badge-danger {
  background: color-mix(in srgb, var(--danger) 15%, transparent);
  color: var(--danger);
}
.badge-warn {
  background: color-mix(in srgb, var(--warn) 16%, transparent);
  color: var(--warn);
}
.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--live);
  flex: none;
}
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.chip {
  padding: 7px 13px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-dim);
  font-size: 0.84rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.16s var(--ease);
}
.chip[aria-pressed="true"] {
  background: var(--brand-soft);
  border-color: color-mix(in srgb, var(--brand-1) 40%, transparent);
  color: var(--text);
  font-weight: 600;
}

/* --- Lists (inbox) ------------------------------------------------------- */
.list {
  display: grid;
  gap: 10px;
}
.item {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 14px;
  align-items: start;
  padding: 16px 18px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border);
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition:
    transform 0.14s var(--ease),
    border-color 0.18s var(--ease),
    box-shadow 0.18s var(--ease);
  animation: rise 0.3s var(--ease) both;
}
.item:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-1);
}
.item:active {
  transform: scale(0.995);
}
.item.unread {
  background: linear-gradient(90deg, var(--brand-soft), transparent 46%), var(--surface);
}
.item-icon {
  width: 40px;
  height: 40px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  background: var(--surface-3);
  color: var(--text-dim);
  flex: none;
}
.item.unread .item-icon {
  background: var(--gradient);
  color: #fff;
}
.item-icon .icon {
  width: 20px;
  height: 20px;
}
.item-body {
  min-width: 0;
}
.item-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.item-title {
  align-items: flex-start;
}
.item-title .dot {
  margin-top: 8px;
}
/* Titles wrap to at most two lines instead of truncating mid-word. */
.item-title .text {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
@media (max-width: 899px) {
  .search {
    max-width: none;
    flex: 1 1 100%;
  }
}
.item-text {
  color: var(--text-dim);
  font-size: 0.92rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-top: 2px;
}
.item-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  font-size: 0.76rem;
  color: var(--text-mute);
  flex-wrap: wrap;
}
.item-side {
  display: grid;
  justify-items: end;
  gap: 8px;
  font-size: 0.76rem;
  color: var(--text-mute);
}
.item-actions {
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.18s var(--ease);
}
.item:hover .item-actions,
.item:focus-within .item-actions {
  opacity: 1;
}
@media (max-width: 899px) {
  .item-actions {
    opacity: 1;
  }
}

/* --- Stats & charts ------------------------------------------------------ */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(168px, 1fr));
  gap: 12px;
}
.stat {
  padding: 18px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border);
}
.stat .label {
  font-size: 0.78rem;
  color: var(--text-mute);
  font-weight: 500;
}
.stat .value {
  font-size: 1.9rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
  margin-top: 4px;
}
.stat .sub {
  font-size: 0.76rem;
  color: var(--text-mute);
  margin-top: 2px;
}
.spark {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 84px;
  padding-top: 8px;
}
.spark div {
  flex: 1;
  min-height: 3px;
  border-radius: 4px 4px 2px 2px;
  background: var(--gradient);
  opacity: 0.85;
  transition: height 0.4s var(--ease);
}
.spark div.empty {
  background: var(--surface-3);
}
.spark-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  color: var(--text-mute);
  margin-top: 8px;
}
.meter {
  height: 8px;
  border-radius: 999px;
  background: var(--surface-3);
  overflow: hidden;
}
.meter > div {
  height: 100%;
  border-radius: 999px;
  background: var(--gradient);
}

/* --- Tables (admin) ------------------------------------------------------ */
.table-wrap {
  overflow-x: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}
th {
  text-align: left;
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-mute);
  font-weight: 600;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tbody tr:last-child td {
  border-bottom: 0;
}
tbody tr:hover {
  background: var(--surface-2);
}
td .btn-row {
  justify-content: flex-end;
  flex-wrap: nowrap;
}
.cell-user {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.cell-user strong {
  font-weight: 600;
}
/* Scoped to the text column so the avatar keeps its own white type. */
.cell-user div span {
  display: block;
  font-size: 0.8rem;
  color: var(--text-mute);
}
tbody tr[data-clickable] {
  cursor: pointer;
}

/* --- Modal / sheet ------------------------------------------------------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(6, 6, 14, 0.55);
  backdrop-filter: blur(4px);
  animation: fade 0.2s var(--ease);
}
@keyframes fade {
  from {
    opacity: 0;
  }
}
.modal {
  width: min(520px, 100%);
  max-height: min(86dvh, 780px);
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-2);
  animation: rise 0.28s var(--ease) both;
}
.modal-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 22px 6px;
}
.modal-head h2 {
  margin-right: auto;
  font-size: 1.15rem;
}
.modal-body {
  padding: 14px 22px 20px;
}
.modal-foot {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding: 0 22px 22px;
}
@media (max-width: 560px) {
  .modal-backdrop {
    place-items: end center;
    padding: 0;
  }
  .modal {
    width: 100%;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    padding-bottom: env(safe-area-inset-bottom);
    animation: sheet 0.3s var(--ease) both;
  }
  @keyframes sheet {
    from {
      transform: translateY(100%);
    }
  }
}

/* --- Toasts -------------------------------------------------------------- */
.toasts {
  position: fixed;
  z-index: 80;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: grid;
  gap: 8px;
  width: min(440px, calc(100% - 32px));
}
@media (min-width: 900px) {
  .toasts {
    left: auto;
    right: 24px;
    transform: none;
  }
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 16px;
  border-radius: var(--radius-md);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-2);
  font-size: 0.92rem;
  animation: rise 0.26s var(--ease) both;
}
.toast.error {
  border-color: color-mix(in srgb, var(--danger) 55%, transparent);
}
.toast.success .dot {
  background: var(--live);
}
.toast.error .dot {
  background: var(--danger);
}

/* --- Empty / skeleton / misc -------------------------------------------- */
.empty {
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 64px 20px;
  text-align: center;
  color: var(--text-mute);
}
.empty .glyph .icon {
  width: 26px;
  height: 26px;
}
.empty .glyph {
  width: 64px;
  height: 64px;
  border-radius: 20px;
  display: grid;
  place-items: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--brand-1);
  margin-bottom: 4px;
}
.empty h3 {
  color: var(--text);
}
.skeleton {
  border-radius: var(--radius-lg);
  background: linear-gradient(
    90deg,
    var(--surface-2) 25%,
    var(--surface-3) 37%,
    var(--surface-2) 63%
  );
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
  height: 84px;
}
@keyframes shimmer {
  from {
    background-position: 100% 0;
  }
  to {
    background-position: 0 0;
  }
}
.code {
  font-family: var(--mono);
  font-size: 0.82rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  overflow-x: auto;
  white-space: pre;
  color: var(--text-dim);
}
.secret {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--mono);
  font-size: 0.88rem;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--warn) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--warn) 40%, transparent);
  word-break: break-all;
}
.divider {
  height: 1px;
  background: var(--border);
  margin: 18px 0;
}
.detail-body {
  font-size: 1.02rem;
  line-height: 1.65;
  white-space: pre-wrap;
  color: var(--text-dim);
}
.kv {
  display: grid;
  grid-template-columns: minmax(120px, auto) 1fr;
  gap: 10px 18px;
  font-size: 0.9rem;
}
.kv dt {
  color: var(--text-mute);
}
.kv dd {
  margin: 0;
  overflow-wrap: anywhere;
}
.center {
  display: grid;
  place-items: center;
  min-height: 100dvh;
  padding: 24px;
}
.auth-card {
  width: min(420px, 100%);
}
.hide-desktop {
  display: none;
}
@media (max-width: 899px) {
  .hide-desktop {
    display: inline-flex;
  }
  .hide-mobile {
    display: none !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
