@import url("https://fonts.googleapis.com/css2?family=Mona+Sans:ital,wght@0,200..900;1,200..900&family=JetBrains+Mono:wght@400;500&display=swap");

:root {
  --bg: #f5f5f5;
  --panel: #ffffff;
  --ink: #1a1a1a;
  --ink-secondary: #4a4a4a;
  --muted: #8a8a8a;
  --line: #e4e4e7;
  --line-soft: #f0f0f2;
  --accent: #5e6ad2;
  --accent-hover: #4e5bc2;
  --accent-soft: rgba(94, 106, 210, 0.08);
  --accent-ink: #ffffff;
  --danger: #e5484d;
  --danger-soft: rgba(229, 72, 77, 0.06);
  --success: #30a46c;
  --success-soft: rgba(48, 164, 108, 0.06);
  --sidebar-bg: #f9f9f9;
  --sidebar-ink: #1a1a1a;
  --sidebar-muted: #8a8a8a;
  --sidebar-line: #e4e4e7;
  --sidebar-hover: rgba(0, 0, 0, 0.03);
  --sidebar-active: rgba(0, 0, 0, 0.05);
  --ring: rgba(94, 106, 210, 0.2);
  --radius-sm: 0.375rem;
  --radius: 0.5rem;
  --radius-lg: 0.5rem;
  --shadow-xs: none;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.08);
  --transition: 120ms cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  box-sizing: border-box;
  margin: 0;
}
html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family:
    "Mona Sans",
    ui-sans-serif,
    system-ui,
    -apple-system,
    sans-serif;
  font-optical-sizing: auto;
  font-size: 0.875rem;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
}

a {
  color: inherit;
}
h1,
h2,
h3,
p {
  margin: 0;
}

/* ── Brand ───────────────────────────────────────── */

.brand {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  text-decoration: none;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.brand-icon {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.brand-icon svg {
  width: 22px;
  height: 22px;
}

/* ── Auth ────────────────────────────────────────── */

.auth-page {
  min-height: 100vh;
  display: flex;
  justify-content: center;
  padding: 2rem;
  padding-top: 100px;
  background: var(--bg);
}

.auth-card {
  width: 100%;
  max-width: 380px;
}

.auth-brand {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-bottom: 2.5rem;
}

.auth-card h1 {
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.025em;
  margin-bottom: 0.375rem;
}

.auth-desc {
  color: var(--muted);
  font-size: 0.875rem;
  margin-bottom: 1.75rem;
  line-height: 1.5;
}

.auth-card .field label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--ink);
}

.auth-card .field input {
  height: 2.5rem;
  border-radius: var(--radius-sm);
}

.auth-card .btn-primary {
  height: 2.5rem;
}

.auth-card .flash {
  margin-bottom: 1.25rem;
}

.auth-switch {
  margin-top: 1rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.auth-switch a {
  color: var(--ink);
  font-weight: 600;
}

.auth-turnstile {
  margin: 1rem 0 1.25rem;
  display: flex;
  justify-content: center;
}

/* ── Verify page ─────────────────────────────────── */

.verify-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background: var(--bg);
  text-align: center;
}

.verify-brand {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--muted);
  position: absolute;
  top: 2rem;
  left: 2rem;
}

.verify-card {
  width: 100%;
  max-width: 440px;
}

.verify-card h1 {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.035em;
  margin-bottom: 0.5rem;
}

.verify-desc {
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.6;
  margin-bottom: 2rem;
}

.verify-card .flash {
  margin-bottom: 1.5rem;
  text-align: left;
}

.otp-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 2rem;
}

.otp-group {
  display: flex;
  gap: 0.375rem;
  flex: 1;
}

.otp-box {
  flex: 1;
  min-width: 0;
  height: 3.25rem;
  text-align: center;
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, monospace;
  font-size: 1.25rem;
  font-weight: 600;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel);
  transition: all var(--transition);
  caret-color: var(--accent);
}

.otp-box:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--ring);
}

.otp-sep {
  width: 0.75rem;
  height: 2px;
  background: var(--line);
  border-radius: 1px;
  flex-shrink: 0;
}

.verify-meta {
  color: var(--muted);
  font-size: 0.875rem;
  line-height: 1.6;
}

.verify-meta strong {
  color: var(--ink);
}

.verify-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  margin-top: 2rem;
}

.verify-actions .btn-primary {
  width: 100%;
  height: 2.5rem;
}

.verify-back {
  color: var(--muted);
  font-size: 0.8125rem;
  text-decoration: none;
}

.verify-back:hover {
  color: var(--ink);
  text-decoration: underline;
}

/* ── App Shell ───────────────────────────────────── */

/* ── Mobile bar & drawer (hidden on desktop) ────── */

.mobile-bar {
  display: none;
}
.drawer-backdrop {
  display: none;
}
.drawer-close {
  display: none;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  background: var(--bg);
}

/* ── Sidebar ─────────────────────────────────────── */

.sidebar {
  display: flex;
  flex-direction: column;
  background: var(--sidebar-bg);
  padding: 1rem 0.75rem;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  border-right: 1px solid var(--line);
}

.sidebar-head {
  padding: 0 0.25rem;
  margin-bottom: 1rem;
}

.sidebar-copy {
  color: var(--sidebar-muted);
  font-size: 0.8125rem;
  line-height: 1.5;
  margin-top: 0.625rem;
}

/* ── Workspace switcher (sidebar header) ── */
.workspace-bar {
  display: flex;
  align-items: center;
  gap: 0;
}
.workspace-bar > .brand-icon {
  flex-shrink: 0;
}
.workspace-switcher {
  position: relative;
  flex: 1;
  min-width: 0;
}
.workspace-switcher-trigger {
  display: flex;
  align-items: center;
  gap: 0;
  cursor: pointer;
  list-style: none;
  padding: 0.25rem 0.375rem;
  border-radius: var(--radius-sm);
  transition: background var(--transition);
  user-select: none;
}
.workspace-switcher-trigger::-webkit-details-marker {
  display: none;
}
.workspace-switcher-trigger:hover {
  background: var(--line-soft);
}
.workspace-switcher-divider {
  width: 1px;
  height: 1.25rem;
  background: var(--line);
  margin: 0 0.625rem;
  flex-shrink: 0;
}
.workspace-switcher-name {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}
.workspace-switcher-chevron {
  flex-shrink: 0;
  color: var(--muted);
  margin-left: 0.375rem;
  display: flex;
  align-items: center;
  transition: transform 0.15s ease;
}
details[open] > .workspace-switcher-trigger .workspace-switcher-chevron {
  transform: rotate(180deg);
}
.workspace-switcher-dropdown {
  position: absolute;
  top: calc(100% + 0.375rem);
  left: -0.5rem;
  right: -0.5rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 0.375rem;
  z-index: 50;
}
.workspace-switcher-label {
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  padding: 0.5rem 0.5rem 0.375rem;
}
.workspace-switcher-item {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  width: 100%;
  padding: 0.5rem 0.5rem;
  border: none;
  background: none;
  font-family: inherit;
  font-size: 0.875rem;
  color: var(--ink);
  cursor: pointer;
  border-radius: var(--radius-sm);
  text-align: left;
  transition: background var(--transition);
}
.workspace-switcher-item:hover {
  background: var(--line-soft);
}
.workspace-switcher-new {
  color: var(--muted);
}
.workspace-switcher-new:hover {
  color: var(--ink);
}
.workspace-switcher-divider-line {
  height: 1px;
  background: var(--line);
  margin: 0.25rem 0;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  flex: 1;
}

.nav-section {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  interpolate-size: allow-keywords;
}

.ready .nav-section::details-content {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  overflow: hidden;
  height: 0;
  opacity: 0;
  transition:
    height 200ms ease,
    opacity 200ms ease,
    content-visibility 200ms allow-discrete;
  content-visibility: hidden;
}

.ready .nav-section[open]::details-content {
  height: auto;
  opacity: 1;
  content-visibility: visible;
}

@starting-style {
  .ready .nav-section[open]::details-content {
    height: 0;
    opacity: 0;
  }
}

.nav-section-label {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--sidebar-muted);
  padding: 0.75rem 0.625rem 0.375rem;
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  user-select: none;
}

.nav-section-label::-webkit-details-marker {
  display: none;
}

.nav-section-label svg {
  width: 12px;
  height: 12px;
  transition: transform var(--transition);
}

.nav-section[open] > .nav-section-label svg {
  transform: rotate(90deg);
}

.nav-section-label:hover {
  color: var(--sidebar-ink);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  border-radius: var(--radius-sm);
  padding: 0.375rem 0.625rem;
  font-size: 0.8125rem;
  font-weight: 450;
  color: var(--sidebar-muted);
  transition: all var(--transition);
}

.nav-item svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  opacity: 0.5;
}

.nav-item:hover {
  color: var(--sidebar-ink);
  background: var(--sidebar-hover);
}

.nav-item:hover svg {
  opacity: 0.9;
}

.nav-item.active {
  color: var(--sidebar-ink);
  background: var(--sidebar-active);
  font-weight: 500;
}

.nav-item.active svg {
  opacity: 1;
}

.nav-badge {
  margin-left: auto;
  font-size: 0.6875rem;
  font-weight: 600;
  background: var(--sidebar-hover);
  color: var(--sidebar-muted);
  padding: 0.125rem 0.5rem;
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
}

.nav-item.active .nav-badge {
  background: rgba(255, 255, 255, 0.1);
  color: var(--sidebar-ink);
}

.sidebar-foot {
  padding-top: 0.75rem;
  border-top: 1px solid var(--sidebar-line);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.sidebar-user {
  font-size: 0.8125rem;
  color: var(--sidebar-muted);
  padding: 0 0.375rem;
  overflow-wrap: anywhere;
}

/* ── View Transitions ───────────────────────────── */

::view-transition-old(root),
::view-transition-new(root) {
  animation: none;
}

.sidebar {
  view-transition-name: sidebar;
}

.content {
  view-transition-name: content;
}

::view-transition-old(sidebar),
::view-transition-new(sidebar) {
  animation: none;
}

::view-transition-old(content) {
  animation: vt-fade 100ms ease-out forwards;
}

::view-transition-new(content) {
  animation: vt-fade 100ms ease-in reverse;
}

@keyframes vt-fade {
  to {
    opacity: 0;
  }
}

/* ── Content ─────────────────────────────────────── */

.content {
  padding: 2rem 2.5rem;
  max-width: 1500px;
}

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.page-head h1 {
  font-size: 1.375rem;
  font-weight: 600;
  letter-spacing: -0.025em;
  line-height: 1.2;
}

.page-copy {
  color: var(--muted);
  font-size: 0.875rem;
  max-width: 50rem;
  margin-top: 0.375rem;
  line-height: 1.6;
}

.page-actions {
  display: flex;
  gap: 0.5rem;
  align-items: stretch;
  flex-shrink: 0;
}

.eyebrow {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
  margin-bottom: 0.375rem;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.section-head h2 {
  font-size: 0.9375rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

/* ── Buttons ─────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.875rem;
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: all var(--transition);
  box-shadow: var(--shadow-xs);
  white-space: nowrap;
}

.btn:hover {
  border-color: var(--line);
  background: var(--line-soft);
}

.btn svg {
  width: 16px;
  height: 16px;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

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

.btn-secondary {
  background: var(--panel);
  border-color: var(--line);
  color: var(--ink);
}
.btn-secondary:hover {
  background: var(--line-soft);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  color: var(--muted);
}

.btn-ghost:hover {
  background: var(--line-soft);
  color: var(--ink);
}

.btn-sidebar {
  background: transparent;
  border-color: var(--sidebar-line);
  color: var(--sidebar-muted);
  box-shadow: none;
  width: 100%;
  font-size: 0.8125rem;
}

.btn-sidebar:hover {
  background: var(--sidebar-hover);
  color: var(--sidebar-ink);
  border-color: var(--sidebar-line);
}

.btn-full {
  width: 100%;
}

.btn-danger {
  background: var(--danger);
  border-color: var(--danger);
  color: white;
}

.btn-danger:hover {
  background: #b91c25;
  border-color: #b91c25;
}

.btn-warning {
  background: #f59e0b;
  color: white;
  border-color: #f59e0b;
}
.btn-warning:hover {
  background: #d97706;
  border-color: #d97706;
}

.btn-icon {
  padding: 0.5rem 0.625rem;
  min-width: unset;
  height: 100%;
}

/* ── Dropdown ────────────────────────────────────── */

.dropdown-wrap {
  position: relative;
}

.dropdown-menu {
  position-anchor: --link-menu-anchor;
  position: fixed;
  inset: unset;
  right: anchor(right);
  top: anchor(bottom);
  margin-top: 4px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  min-width: 180px;
  padding: 0.25rem;
}

.dropdown-wrap > [popovertarget] {
  anchor-name: --link-menu-anchor;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.5rem 0.75rem;
  font-size: 0.8125rem;
  font-family: inherit;
  color: var(--ink);
  background: none;
  border: none;
  border-radius: 0.375rem;
  cursor: pointer;
  transition: background var(--transition);
  text-align: left;
}
.dropdown-item:hover {
  background: var(--line-soft);
}
.dropdown-item svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}
.dropdown-item-danger {
  color: var(--danger);
}
.dropdown-item-danger:hover {
  background: var(--danger-soft);
}

/* ── Confirm Modal ───────────────────────────────── */

.confirm-modal-body {
  margin-bottom: 1.25rem;
}
.confirm-modal-body p {
  font-size: 0.875rem;
  color: var(--ink-secondary);
  line-height: 1.6;
}
.confirm-modal-hint {
  margin-top: 0.5rem;
  font-size: 0.8125rem;
  color: var(--muted);
}
.confirm-modal-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}
.confirm-modal-actions .btn {
  display: flex;
  justify-content: center;
}

/* ── Cards ───────────────────────────────────────── */

.card {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-xs);
}

.card + .card {
  margin-top: 1.5rem;
}

.card-form {
  max-width: 860px;
}

.card-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
}
.card-title + .card-subtitle {
  margin-top: -0.5rem;
}
.card-subtitle {
  font-size: 0.8125rem;
  color: var(--muted);
  line-height: 1.5;
  margin-bottom: 0.75rem;
}
.card-subtitle:last-child {
  margin-bottom: 0;
}

.onboarding-done-icon {
  color: var(--success, #16a34a);
  margin-bottom: 0.5rem;
}
.onboarding-done-icon svg {
  width: 40px;
  height: 40px;
}
.onboarding-done-url {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin: 0 0 1rem;
  padding: 0.625rem 1rem;
  background: var(--bg-soft, #f5f5f7);
  border-radius: var(--radius);
}
.onboarding-done-url code {
  font-size: 0.875rem;
  font-weight: 600;
  word-break: break-all;
}
.onboarding-done-qr {
  display: block;
  margin: 0 auto 3rem;
}

.onboarding-skip {
  display: inline-block;
  margin-top: 0.75rem;
  background: none;
  border: none;
  font-family: inherit;
  font-size: 0.8125rem;
  color: var(--muted);
  cursor: pointer;
  padding: 0;
  text-decoration: none;
}
.onboarding-skip:hover {
  color: var(--ink);
}

.onboarding-step-number {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  background: var(--ink);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
}

/* ── Invite link row ── */
.invite-link-row {
  display: flex;
  gap: 0.5rem;
  align-items: stretch;
  margin-bottom: 0.375rem;
}
.invite-link-input {
  flex: 1;
  min-width: 0;
  font-family: var(--font-mono, monospace);
  font-size: 0.8125rem;
}
.invite-link-row .btn {
  flex-shrink: 0;
  white-space: nowrap;
}

/* ── Forms ───────────────────────────────────────── */

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.field-span-2 {
  grid-column: span 2;
}

label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--ink-secondary);
}

input,
select,
textarea {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem;
  font: inherit;
  font-size: 0.875rem;
  width: 100%;
  transition: all var(--transition);
}

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

input::placeholder,
textarea::placeholder {
  color: var(--muted);
  opacity: 0.6;
}

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

.field:has(input:disabled) label,
.field:has(select:disabled) label,
.field:has(textarea:disabled) label,
.field:has(input:disabled) .field-help,
.field:has(select:disabled) .field-help,
.field:has(textarea:disabled) .field-help {
  opacity: 0.55;
}

.field-help {
  color: var(--muted);
  font-size: 0.8rem;
}

.field-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.375rem;
}

.field-label-row label {
  margin-bottom: 0;
}

.field-link {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.75rem;
  font-weight: 500;
}

.field-link:hover {
  text-decoration: underline;
}

.tag-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.tag-option {
  position: relative;
  display: inline-flex;
  cursor: pointer;
}

.tag-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.tag-option .tag {
  opacity: 0.55;
  transition:
    opacity var(--transition),
    transform var(--transition),
    box-shadow var(--transition);
}

.tag-option input:checked + .tag {
  opacity: 1;
  transform: translateY(-1px);
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.08);
}

.tag-option:hover .tag {
  opacity: 0.9;
}

.color-option .tag {
  text-transform: capitalize;
  min-width: 5.75rem;
  justify-content: center;
}

.form-disclosure {
  margin-top: 1.25rem;
  border-top: 1px solid var(--line-soft);
  padding-top: 1rem;
}

.form-disclosure-summary {
  list-style: none;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.25rem 1rem;
  align-items: center;
  cursor: pointer;
}

.form-disclosure-summary::-webkit-details-marker {
  display: none;
}

.form-disclosure-title {
  font-size: 0.9375rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.form-disclosure-copy {
  grid-column: 1 / 2;
  color: var(--muted);
  font-size: 0.8125rem;
  line-height: 1.55;
}

.form-disclosure-icon {
  grid-row: 1 / span 2;
  grid-column: 2 / 3;
  color: var(--muted);
}

.form-disclosure-icon svg {
  transition: transform var(--transition);
}

.form-disclosure[open] .form-disclosure-icon svg {
  transform: rotate(180deg);
}

.form-disclosure-body {
  padding-top: 1rem;
}

.form-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-top: 1.25rem;
}

/* ── Tables ──────────────────────────────────────── */

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

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th,
.table td {
  padding: 0.75rem 0.75rem;
  text-align: left;
  vertical-align: middle;
  font-size: 0.875rem;
}

.table th {
  color: var(--muted);
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--line);
  padding-bottom: 0.625rem;
}

.table td {
  border-bottom: 1px solid var(--line-soft);
}

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

.table tr:hover td {
  background: rgba(0, 0, 0, 0.015);
}

.table a {
  color: var(--accent);
  text-decoration: none;
}

.table a:hover {
  text-decoration: underline;
}

/* ── Tags ───────────────────────────────────────── */

.tag {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.7rem;
  font-weight: 500;
  padding: 0.1875rem 0.5rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-soft);
  background: var(--surface-secondary);
  color: var(--ink-secondary);
}

.tag::before {
  content: "";
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--ink-muted);
  flex-shrink: 0;
}

.tag-rose::before {
  background: #e11d48;
}
.tag-amber::before {
  background: #d97706;
}
.tag-yellow::before {
  background: #ca8a04;
}
.tag-lime::before {
  background: #65a30d;
}
.tag-emerald::before {
  background: #059669;
}
.tag-teal::before {
  background: #0d9488;
}
.tag-cyan::before {
  background: #0891b2;
}
.tag-sky::before {
  background: #0284c7;
}
.tag-blue::before {
  background: #2563eb;
}
.tag-indigo::before {
  background: #4f46e5;
}
.tag-violet::before {
  background: #7c3aed;
}
.tag-fuchsia::before {
  background: #c026d3;
}
.tag-pink::before {
  background: #db2777;
}
.tag-slate::before {
  background: #64748b;
}

.link-filters {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.link-search {
  flex: 1;
  min-width: 0;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel);
  font: inherit;
  font-size: 0.875rem;
  color: var(--ink);
}

.link-search:focus {
  outline: none;
  border-color: var(--accent);
}

/* ── Customizable tag select ─────────────────────── */

.tag-select,
.tag-select::picker(select) {
  appearance: base-select;
}

.tag-select {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel);
  padding: 0.5rem 0.75rem;
  font: inherit;
  font-size: 0.875rem;
  color: var(--ink);
  cursor: pointer;
  flex-shrink: 0;
  width: auto;
  min-width: 240px;
}

.tag-select:focus {
  outline: none;
  border-color: var(--accent);
}

.tag-select > button {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  color: inherit;
  cursor: pointer;
}

.tag-select selectedcontent {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.tag-select-icon {
  display: flex;
  color: var(--muted);
  flex-shrink: 0;
}

.tag-select::picker-icon {
  display: none;
}

.tag-select::picker(select) {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 0.25rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  opacity: 0;
  transition: opacity 0.15s;
}

:open.tag-select::picker(select) {
  opacity: 1;
}

@starting-style {
  :open.tag-select::picker(select) {
    opacity: 0;
  }
}

.tag-select option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  cursor: pointer;
}

.tag-select option:hover {
  background: var(--line-soft);
}

.tag-select option:checked {
  font-weight: 600;
}

.tag-dot {
  display: inline-block;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--ink-muted);
}

.tag-dot.tag-rose {
  background: #e11d48;
}
.tag-dot.tag-amber {
  background: #d97706;
}
.tag-dot.tag-yellow {
  background: #ca8a04;
}
.tag-dot.tag-lime {
  background: #65a30d;
}
.tag-dot.tag-emerald {
  background: #059669;
}
.tag-dot.tag-teal {
  background: #0d9488;
}
.tag-dot.tag-cyan {
  background: #0891b2;
}
.tag-dot.tag-sky {
  background: #0284c7;
}
.tag-dot.tag-blue {
  background: #2563eb;
}
.tag-dot.tag-indigo {
  background: #4f46e5;
}
.tag-dot.tag-violet {
  background: #7c3aed;
}
.tag-dot.tag-fuchsia {
  background: #c026d3;
}
.tag-dot.tag-pink {
  background: #db2777;
}
.tag-dot.tag-slate {
  background: #64748b;
}

.tag-select option::checkmark {
  display: none;
}

/* ── Badges ──────────────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.6875rem;
  font-weight: 600;
  padding: 0.1875rem 0.5rem;
  border-radius: 999px;
  letter-spacing: 0.01em;
}

.badge-success {
  background: var(--success-soft);
  color: var(--success);
}

.badge-warning {
  background: rgba(245, 158, 11, 0.08);
  color: #b45309;
}

.badge-muted {
  background: var(--line-soft);
  color: var(--muted);
}

.badge-type {
  background: var(--accent-soft);
  color: var(--accent);
}

/* ── Toasts ─────────────────────────────────────── */

.toasts {
  position: fixed;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 300;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 1rem;
  border-radius: var(--radius);
  font-size: 0.8125rem;
  font-weight: 500;
  min-width: 260px;
  max-width: 420px;
  pointer-events: auto;
  background: #1a1a1a;
  color: #fff;
  border: none;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.16);
  animation: toast-in 0.2s ease-out forwards;
}

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

.toast span {
  flex: 1;
  min-width: 0;
}

.toast-close {
  background: none;
  border: none;
  color: inherit;
  opacity: 0.5;
  cursor: pointer;
  font-size: 1.125rem;
  line-height: 1;
  padding: 0 0.125rem;
  flex-shrink: 0;
  transition: opacity var(--transition);
}

.toast-close:hover {
  opacity: 1;
}

.toast-out {
  animation: toast-out 0.25s ease-in forwards;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes toast-out {
  from {
    opacity: 1;
    transform: none;
  }
  to {
    opacity: 0;
    transform: translateY(-8px);
  }
}

/* ── Inline flash (status indicators, not toasts) ── */

.flash {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border-radius: var(--radius-sm);
  padding: 0.625rem 0.875rem;
  margin-bottom: 1.5rem;
  font-size: 0.8125rem;
  font-weight: 500;
}

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

.flash-warning {
  background: rgba(245, 158, 11, 0.06);
  color: #b45309;
  border: 1px solid rgba(245, 158, 11, 0.15);
}

/* ── Billing banner (sidebar) ────────────────────── */

.banner {
  margin-top: auto;
  margin-bottom: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--sidebar-line);
  background: var(--panel);
  padding: 0.75rem;
  font-size: 0.75rem;
  line-height: 1.45;
  box-shadow: var(--shadow-xs);
}

.banner-head {
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

.banner-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  flex-shrink: 0;
}

.banner-title {
  font-weight: 600;
  font-size: 0.75rem;
  color: var(--sidebar-ink);
}

.banner-msg {
  color: var(--sidebar-muted);
  font-weight: 400;
}

.banner-action {
  font-weight: 600;
  font-size: 0.75rem;
  text-decoration: none;
  margin-top: 0.125rem;
}

.banner-action:hover {
  text-decoration: underline;
}

.banner-danger .banner-dot {
  background: var(--danger);
}
.banner-danger .banner-action {
  color: var(--danger);
}

.banner-ok .banner-dot {
  background: var(--success);
}
.banner-ok .banner-action {
  color: var(--success);
}

.banner-warning .banner-dot {
  background: #d97706;
}
.banner-warning .banner-action {
  color: #b45309;
}

/* ── Utility ─────────────────────────────────────── */

.muted {
  color: var(--muted);
}
.code {
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, monospace;
  font-size: 0.8125rem;
}

/* ── Billing ─────────────────────────────────────── */

.billing-status-card {
  padding: 0;
  margin-bottom: 1.5rem;
}

.billing-status-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 1.25rem 1.5rem;
}

.billing-status-text {
  min-width: 0;
}

.billing-status-title {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.billing-status-desc {
  color: var(--muted);
  font-size: 0.8125rem;
  margin-top: 0.25rem;
  line-height: 1.5;
}

.billing-stats-row {
  display: flex;
  border-top: 1px solid var(--line-soft);
}

.billing-stat {
  flex: 1;
  padding: 1rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.billing-stat + .billing-stat {
  border-left: 1px solid var(--line-soft);
}

.billing-stat-label {
  font-size: 0.75rem;
  color: var(--muted);
}

.billing-stat-value {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.billing-portal-hint {
  font-size: 0.8125rem;
  color: var(--muted);
}

/* ── Plan cards ── */

.billing-plan-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.billing-plan-grid > .card + .card {
  margin-top: 0;
}

.plan-card {
  padding: 1.5rem;
  border: 1px solid var(--line);
  display: flex;
  flex-direction: column;
}

.plan-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.plan-price {
  display: flex;
  align-items: baseline;
  gap: 0.25rem;
  margin-top: 0.25rem;
}

.plan-amount {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1;
}

.plan-interval {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--muted);
}

.plan-card-copy {
  color: var(--muted);
  font-size: 0.8125rem;
  margin-bottom: 1rem;
}

.plan-features {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  margin-bottom: 1.25rem;
  flex: 1;
}

.plan-features li {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.8125rem;
  color: var(--ink-secondary);
}

.plan-features li svg {
  flex-shrink: 0;
  color: var(--success);
}

.plan-card-current {
  border-color: rgba(0, 102, 255, 0.3);
  box-shadow:
    0 0 0 1px rgba(0, 102, 255, 0.08),
    var(--shadow-sm);
}

.plan-card-recommended {
  border-color: var(--accent);
  box-shadow:
    0 0 0 1px rgba(0, 102, 255, 0.1),
    var(--shadow-sm);
}

.badge-save {
  background: var(--accent-soft);
  color: var(--accent);
  margin-left: 0.375rem;
}

.btn-outline {
  background: var(--panel);
  border-color: var(--line);
  color: var(--ink);
  box-shadow: var(--shadow-xs);
}

.btn-outline:hover {
  background: var(--line-soft);
  border-color: var(--line);
}

.btn-disabled {
  background: var(--line-soft);
  border-color: var(--line);
  color: var(--muted);
  cursor: default;
  box-shadow: none;
}

.btn-disabled:hover {
  background: var(--line-soft);
  border-color: var(--line);
}

.billing-locked-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
}

.billing-locked-card h2 {
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.3;
}

.billing-locked-card p {
  color: var(--muted);
  font-size: 0.8125rem;
  margin-top: 0.125rem;
  line-height: 1.4;
}

.billing-locked-card .form-actions {
  margin-top: 0;
  margin-left: auto;
  flex-shrink: 0;
}

/* ── Link List ───────────────────────────────────── */

.link-list {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--panel);
  overflow: hidden;
}

.link-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.25rem;
  text-decoration: none;
  color: inherit;
  transition: background var(--transition);
  border-bottom: 1px solid var(--line-soft);
}

.link-row:last-child {
  border-bottom: none;
}

.link-row:hover {
  background: rgba(0, 0, 0, 0.015);
}

.favicon-circle {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  background: var(--line-soft);
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  overflow: hidden;
}

.favicon-circle img {
  display: block;
  border-radius: 2px;
}

.link-info {
  flex: 1;
  min-width: 0;
}

.link-primary {
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

.link-short {
  font-weight: 600;
  color: var(--ink);
  font-size: 0.875rem;
}

.copy-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  padding: 0.125rem;
  cursor: pointer;
  color: var(--muted);
  opacity: 0;
  transition: all var(--transition);
  border-radius: 4px;
}

.copy-btn svg {
  width: 13px;
  height: 13px;
}

.link-row:hover .copy-btn {
  opacity: 0.5;
}
.copy-btn:hover {
  opacity: 1 !important;
  color: var(--ink);
  background: var(--line-soft);
}
.copy-btn.copied {
  opacity: 1 !important;
  color: var(--success);
}

.qr-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  padding: 0.125rem;
  cursor: pointer;
  color: var(--muted);
  opacity: 0;
  transition: all var(--transition);
  border-radius: 4px;
}
.qr-btn svg {
  width: 13px;
  height: 13px;
}
.link-row:hover .qr-btn {
  opacity: 0.5;
}
.qr-btn:hover {
  opacity: 1 !important;
  color: var(--ink);
  background: var(--line-soft);
}

/* ── QR Modal ────────────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}
.modal-box {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  width: 420px;
  padding: 1.25rem;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}
.modal-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--ink);
}
.modal-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  padding: 0.25rem;
  cursor: pointer;
  color: var(--muted);
  border-radius: 4px;
  transition: all var(--transition);
}
.modal-close:hover {
  color: var(--ink);
  background: var(--line-soft);
}
.qr-modal-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}
.qr-modal-img {
  width: 256px;
  height: 256px;
  object-fit: contain;
  border-radius: var(--radius-sm);
}

.link-dest-row {
  font-size: 0.8125rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 480px;
  margin-top: 0.125rem;
}

.link-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  margin-left: auto;
  flex-shrink: 0;
}

.link-tags-more {
  display: none;
  align-items: center;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--muted);
  white-space: nowrap;
}

.link-stats {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex-shrink: 0;
  margin-left: auto;
}

.link-clicks {
  font-size: 0.8125rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.link-clicks strong {
  color: var(--ink);
  font-weight: 600;
}

.link-time {
  font-size: 0.8125rem;
  color: var(--muted);
  white-space: nowrap;
  min-width: 5.5rem;
}

.link-arrow {
  color: var(--muted);
  opacity: 0;
  transition: all var(--transition);
  flex-shrink: 0;
  display: flex;
}

.link-row:hover .link-arrow {
  opacity: 0.5;
}

.short-url-label {
  color: var(--muted);
  font-size: 0.875rem;
}

.short-url-label a {
  color: var(--accent);
  text-decoration: none;
}

.short-url-label a:hover {
  text-decoration: underline;
}

.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--muted);
}

.empty-state svg {
  width: 40px;
  height: 40px;
  margin-bottom: 0.75rem;
  opacity: 0.3;
}

.empty-state p {
  font-size: 0.875rem;
}

.edit-form-wrap {
  max-width: 520px;
}

.input-disabled {
  background: var(--line-soft);
  color: var(--muted);
  cursor: not-allowed;
  border-color: var(--line);
}

/* ── Domain List ─────────────────────────────────── */

.domain-add {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.domain-add-input {
  flex: 1;
  max-width: 360px;
  height: 2.5rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0 0.75rem;
  font: inherit;
  font-size: 0.875rem;
  background: var(--panel);
  transition: all var(--transition);
}

.domain-add-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--ring);
}

.domain-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.875rem 1.25rem;
  border-bottom: 1px solid var(--line-soft);
}

.domain-row:last-child {
  border-bottom: none;
}

.domain-icon {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  background: var(--line-soft);
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  color: var(--muted);
}

.domain-info {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}

.domain-host {
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--ink);
}

.domain-status {
  display: flex;
  gap: 0.375rem;
  flex-shrink: 0;
}

.domain-action {
  flex-shrink: 0;
  display: flex;
  gap: 0.375rem;
  align-items: center;
  justify-content: flex-end;
}

.btn-icon-text {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.375rem 0.5rem;
  cursor: pointer;
  color: var(--muted);
  font: inherit;
  font-size: 0.75rem;
  font-weight: 500;
  transition: all var(--transition);
}

.btn-icon-text svg {
  width: 14px;
  height: 14px;
}

.btn-icon-text:hover {
  color: var(--ink);
  background: var(--line-soft);
}

.tag-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--line-soft);
}

.tag-row:last-child {
  border-bottom: none;
}

.tag-row-main {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  min-width: 0;
  flex-shrink: 0;
}

.tag-row-count {
  color: var(--muted);
  font-size: 0.8125rem;
  white-space: nowrap;
}

.tag-row-meta {
  font-size: 0.8125rem;
  color: var(--muted);
  line-height: 1.45;
  flex: 1;
  min-width: 0;
}

.tag-row-action {
  margin-left: auto;
  flex-shrink: 0;
}

.btn-danger-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 0.375rem;
  cursor: pointer;
  color: var(--muted);
  transition: all var(--transition);
  box-shadow: none;
}

.btn-danger-ghost svg {
  width: 14px;
  height: 14px;
}

.btn-danger-ghost:hover {
  color: var(--danger);
  background: var(--danger-soft);
  border-color: rgba(229, 72, 77, 0.15);
}

.tag-modal-box {
  width: min(560px, calc(100vw - 2rem));
}

.tag-modal-title {
  font-family: inherit;
  font-size: 1rem;
}

.tag-delete-form {
  display: flex;
  justify-content: flex-start;
}

.tag-modal-footer {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--line-soft);
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}

.tag-modal-footer-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* ── Responsive ──────────────────────────────────── */

@media (max-width: 960px) {
  /* ── Mobile top bar ── */
  .mobile-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.625rem 1rem;
    margin: 0.625rem;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
  }
  .mobile-menu-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    padding: 0.25rem;
    cursor: pointer;
    color: var(--muted);
    border-radius: var(--radius-sm);
    transition: color var(--transition);
  }
  .mobile-menu-btn:hover {
    color: var(--ink);
  }

  /* ── Drawer backdrop ── */
  .drawer-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 149;
  }
  .drawer-open .drawer-backdrop {
    display: block;
  }
  .drawer-open {
    overflow: hidden;
  }

  /* ── Sidebar as drawer ── */
  .app-shell {
    display: block;
    padding: 0;
    gap: 0;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 260px;
    height: 100vh;
    z-index: 150;
    border-radius: 0;
    border: none;
    border-right: 1px solid var(--line);
    box-shadow: var(--shadow-md);
    transform: translateX(-100%);
    transition: transform 250ms cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
  }
  .drawer-open .sidebar {
    transform: translateX(0);
  }

  .sidebar-head {
    position: relative;
  }
  .drawer-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    top: 0;
    right: 0;
    background: none;
    border: none;
    padding: 0.25rem;
    cursor: pointer;
    color: var(--muted);
    border-radius: var(--radius-sm);
    transition: all var(--transition);
  }
  .drawer-close:hover {
    color: var(--ink);
    background: var(--line-soft);
  }

  .content {
    padding: 1.5rem;
  }

  .page-head {
    flex-direction: column;
    gap: 1rem;
  }
  .flash {
    align-items: flex-start;
  }
  .flash-link {
    margin-left: 0;
  }
  .billing-plan-grid {
    grid-template-columns: 1fr;
  }
  .billing-stats-row {
    flex-wrap: wrap;
  }
  .billing-stat {
    min-width: 50%;
  }
  .billing-stat:nth-child(odd) {
    border-left: none;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }
  .field-span-2 {
    grid-column: auto;
  }

  .link-row {
    flex-wrap: wrap;
    gap: 0.75rem;
  }
  .link-dest-row {
    max-width: 100%;
  }
  .link-tags {
    margin-left: 0;
  }
  .link-stats {
    margin-left: 0;
  }
  .copy-btn,
  .qr-btn {
    opacity: 0.5;
  }
}

@media (max-width: 640px) {
  .content {
    padding: 1rem;
  }

  .page-head h1 {
    font-size: 1.375rem;
  }
  .page-actions {
    width: 100%;
  }
  .page-actions .btn {
    width: 100%;
    justify-content: center;
  }

  .link-filters {
    flex-direction: column;
    align-items: stretch;
  }

  .link-row {
    padding: 0.875rem 1rem;
  }
  .link-info {
    width: calc(100% - 36px - 0.75rem);
    flex: none;
  }
  .link-tags {
    order: 3;
    flex: 1;
    min-width: 0;
    flex-wrap: nowrap;
    overflow: hidden;
  }
  .link-tags > span:nth-child(n + 3) {
    display: none;
  }
  .link-tags-more {
    display: inline-flex;
  }
  .link-stats {
    order: 4;
    margin-left: auto;
    flex-shrink: 0;
  }
  .link-arrow {
    display: none;
  }

  .modal-box {
    width: calc(100vw - 2rem);
    max-width: 320px;
  }
  .qr-modal-img {
    width: 100%;
    height: auto;
  }

  .form-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .tag-modal-footer {
    flex-direction: row;
    align-items: center;
  }

  .tag-modal-footer-actions {
    margin-left: auto;
  }

  .tag-row-action {
    margin-left: auto;
  }
}

/* ── Analytics ──────────────────────────────────── */

.analytics-filters {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.range-toggle {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--panel);
}

.range-btn {
  padding: 0.375rem 0.75rem;
  font-size: 0.8125rem;
  font-weight: 500;
  text-decoration: none;
  color: var(--muted);
  border-right: 1px solid var(--line);
  transition: all var(--transition);
}

.range-btn:last-child {
  border-right: none;
}

.range-btn:hover {
  background: var(--line-soft);
  color: var(--ink);
}

.range-btn.active {
  background: var(--accent);
  color: var(--accent-ink);
}

.custom-range {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.custom-range.hidden {
  display: none;
}

.date-input {
  width: auto;
  height: 2rem;
  padding: 0 0.5rem;
  font-size: 0.8125rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--panel);
}

.date-sep {
  color: var(--muted);
  font-size: 0.8125rem;
}

.btn-sm {
  padding: 0.25rem 0.625rem;
  font-size: 0.75rem;
  height: 2rem;
}

.stat-card {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-bottom: 1.5rem;
}

.stats-row .stat-card {
  margin-bottom: 0;
}

.stat-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

.analytics-chart-card {
  margin-bottom: 1.5rem;
}

.analytics-chart-card h2 {
  font-size: 0.9375rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
}

#analytics-chart svg {
  display: block;
  width: 100%;
}

.analytics-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.analytics-grid > .card + .card,
.stats-row > .card + .card {
  margin-top: 0;
}

.breakdown-panel h3 {
  font-size: 0.8125rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 0.75rem;
}

.breakdown-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.breakdown-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.375rem 0.75rem;
  align-items: center;
  font-size: 0.8125rem;
}

.breakdown-name {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.breakdown-clicks {
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  text-align: right;
}

.breakdown-bar-track {
  grid-column: 1 / -1;
  height: 4px;
  background: var(--line-soft);
  border-radius: 2px;
  overflow: hidden;
}

.breakdown-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width var(--transition);
}

/* ── Link Show ──────────────────────────────────── */

.link-detail-card {
  margin-bottom: 1.5rem;
}

.link-detail-row {
  display: flex;
  gap: 1rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--line-soft);
  align-items: baseline;
}

.link-detail-row:last-child {
  border-bottom: none;
}

.link-detail-label {
  width: 120px;
  flex-shrink: 0;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--muted);
}

.link-detail-value {
  font-size: 0.875rem;
  display: flex;
  align-items: center;
  gap: 0.375rem;
  flex-wrap: wrap;
  min-width: 0;
}

.link-dest-overflow {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
  max-width: 500px;
}

.link-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
}

/* ── Link Page Grid ────────────────────────────── */

.link-page-grid {
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
}

.link-page-main {
  flex: 1;
  min-width: 0;
}

.link-page-aside {
  flex-shrink: 0;
  width: 160px;
  position: sticky;
  top: 1.5rem;
}

.qr-card {
  width: 100%;
  display: flex;
  padding: 0.75rem;
  overflow: hidden;
}

.qr-card-inner {
  position: relative;
  width: 100%;
}

.qr-code-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.qr-actions {
  position: absolute;
  bottom: 0.5rem;
  right: 0.5rem;
  display: flex;
  gap: 0.25rem;
  opacity: 0;
  transition: opacity var(--transition);
}

.qr-card:hover .qr-actions {
  opacity: 1;
}

.qr-download-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: var(--radius-sm);
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--muted);
  transition: all var(--transition);
  box-shadow: var(--shadow-sm);
}

.qr-download-btn svg {
  width: 14px;
  height: 14px;
}

.qr-download-btn:hover {
  color: var(--ink);
  background: var(--line-soft);
}

.qr-copy-btn .icon-check {
  display: none;
}
.qr-copy-btn.copied .icon-copy {
  display: none;
}
.qr-copy-btn.copied .icon-check {
  display: inline-flex;
}
.qr-copy-btn.copied {
  color: var(--success);
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
  margin-top: 1.5rem;
  margin-bottom: 1.5rem;
}

.stat-mini {
  text-align: center;
  padding: 1rem;
}

.stat-mini-label {
  display: block;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 0.25rem;
}

.stat-mini-value {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

/* ── Stats strip ────────────────────────────────── */

.stats-strip {
  display: flex;
  gap: 0;
  padding: 0;
  margin-bottom: 1.5rem;
}

.stats-strip-item {
  flex: 1;
  padding: 1.25rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.stats-strip-item + .stats-strip-item {
  border-left: 1px solid var(--line-soft);
}

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

.stats-strip-value {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

.stats-strip-row {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}

.change-badge {
  font-size: 0.6875rem;
  font-weight: 600;
  padding: 0.125rem 0.375rem;
  border-radius: 999px;
  white-space: nowrap;
  line-height: 1.4;
}

.change-up {
  background: var(--success-soft);
  color: var(--success);
}

.change-down {
  background: var(--danger-soft);
  color: var(--danger);
}

/* ── Analytics / Show responsive ────────────────── */

@media (max-width: 960px) {
  .analytics-grid {
    grid-template-columns: 1fr;
  }
  .stats-row {
    grid-template-columns: repeat(2, 1fr);
  }
  .stats-strip {
    flex-direction: column;
  }
  .stats-strip-item + .stats-strip-item {
    border-left: none;
    border-top: 1px solid var(--line-soft);
  }
  .link-page-grid {
    flex-direction: column;
  }
  .link-page-aside {
    width: 160px;
    position: static;
    align-self: center;
  }
}

@media (max-width: 640px) {
  .stats-row {
    grid-template-columns: 1fr;
  }
}

/* ── API Keys ──────────────────────────────────── */

.api-key-result-box {
  width: 460px;
  max-width: calc(100vw - 2rem);
}

.api-key-result-actions {
  padding-top: 0.75rem;
}

.api-key-result-box .modal-title,
.api-key-create-box .modal-title {
  font-family: inherit;
  font-size: 1rem;
}

.api-key-result-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 1rem 0 0.5rem;
  gap: 0.5rem;
}

.api-key-result-icon {
  color: var(--success);
  margin-bottom: 0.25rem;
}

.api-key-result-name {
  font-size: 1rem;
  font-weight: 600;
  color: var(--ink);
}

.api-key-result-hint {
  font-size: 0.8125rem;
  color: var(--muted);
  margin-bottom: 0.25rem;
}

.api-key-token-row {
  width: 100%;
}

.api-key-token {
  display: block;
  width: 100%;
  font-family: "JetBrains Mono", monospace;
  font-size: 0.8125rem;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.625rem 0.75rem;
  word-break: break-all;
  user-select: all;
  text-align: left;
}

/* ─── Routing rules builder ─── */
.rr-rules {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}
.rr-rule {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: var(--radius);
}
.rr-rule-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.875rem;
  cursor: pointer;
  user-select: none;
  transition: background var(--transition);
}
.rr-rule-title {
  font-weight: 600;
  font-size: 0.8125rem;
  color: var(--muted);
}
.rr-rule-chevron {
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  transition: transform var(--transition);
}
.rr-rule-chevron svg {
  display: block;
}
.rr-rule.is-collapsed .rr-rule-chevron {
  transform: rotate(-90deg);
}
.rr-rule-body {
  padding: 0.875rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.rr-rule.is-collapsed .rr-rule-body {
  display: none;
}
.rr-rule-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.rr-remove-rule {
  min-width: auto;
  color: var(--muted);
  font-size: 0.75rem;
}
.rr-remove-rule:hover {
  color: var(--danger);
}

.rr-cond-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}
@media (max-width: 640px) {
  .rr-cond-grid {
    grid-template-columns: 1fr;
  }
}
.rr-cond-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.rr-field-label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--ink-secondary);
}

/* Multi-select dropdown (countries + devices) */
.rr-multiselect {
  position: relative;
}
.rr-multiselect-trigger {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem;
  min-height: 2.125rem;
  padding: 0.1875rem 0.5rem;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color var(--transition);
}
.rr-multiselect-trigger:hover {
  border-color: var(--ink-secondary);
}
.rr-multiselect-placeholder {
  color: var(--muted);
  font-size: 0.8125rem;
  flex: 1;
  padding: 0.125rem 0;
}
.rr-multiselect-arrow {
  color: var(--muted);
  margin-left: auto;
  padding-left: 0.375rem;
  display: inline-flex;
  align-items: center;
  transition: transform var(--transition);
}
.rr-multiselect-arrow svg {
  display: block;
}
.rr-multiselect-pills {
  display: contents;
}
.rr-country-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.1875rem;
  font-size: 0.6875rem;
  font-weight: 500;
  padding: 0.0625rem 0.375rem 0.0625rem 0.4375rem;
  border-radius: 999px;
  background: var(--line-soft);
  color: var(--ink-secondary);
  white-space: nowrap;
}
.rr-pill-remove {
  all: unset;
  cursor: pointer;
  font-size: 0.625rem;
  line-height: 1;
  opacity: 0.4;
  color: var(--ink-secondary);
  width: 0.875rem;
  height: 0.875rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all var(--transition);
}
.rr-pill-remove:hover {
  opacity: 1;
  background: rgba(0, 0, 0, 0.06);
}
.rr-multiselect-panel {
  display: none;
  position: absolute;
  top: calc(100% + 0.25rem);
  left: 0;
  right: 0;
  z-index: 50;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}
.rr-multiselect-panel.is-open {
  display: block;
}
.rr-multiselect-search {
  display: block;
  width: 100%;
  box-sizing: border-box;
  border: none;
  border-bottom: 1px solid var(--line-soft);
  padding: 0.4375rem 0.625rem;
  font: inherit;
  font-size: 0.8125rem;
  outline: none;
  background: transparent;
}
.rr-multiselect-search:focus {
  box-shadow: none;
  border-color: var(--line-soft);
}
.rr-multiselect-search::placeholder {
  color: var(--muted);
}
.rr-multiselect-options {
  max-height: 192px;
  overflow-y: auto;
  padding: 0.25rem 0;
}
.rr-multiselect-option {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.3125rem 0.625rem;
  font-size: 0.8125rem;
  cursor: pointer;
  transition: background var(--transition);
  color: var(--ink);
}
.rr-multiselect-option:hover {
  background: var(--line-soft);
}
.rr-multiselect-option.is-selected {
  color: var(--accent);
}
.rr-multiselect-option.is-selected:hover {
  background: var(--accent-soft);
}
.rr-multiselect-check {
  width: 0.875rem;
  text-align: center;
  font-size: 0.6875rem;
  color: var(--accent);
  flex-shrink: 0;
  opacity: 0;
}
.rr-multiselect-option.is-selected .rr-multiselect-check {
  opacity: 1;
}
.rr-multiselect-option-label {
  flex: 1;
}
.rr-multiselect-option-code {
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0.02em;
  opacity: 0.7;
}

/* Destination rows */
.rr-dests {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}
.rr-dest {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}
.rr-dest-url {
  flex: 1;
  font-size: 0.8125rem;
}
.rr-dest-weight {
  width: 4.5rem;
  text-align: center;
  font-size: 0.8125rem;
}
.rr-remove-dest {
  min-width: auto;
  padding: 0.125rem 0.375rem;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1;
}
.rr-remove-dest:hover {
  color: var(--danger);
}
.rr-add-dest {
}
.rr-add-rule {
  align-self: flex-start;
}

/* Routing rules info button + help modal */
.rr-info-btn {
  all: unset;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
  color: var(--muted);
  margin-left: 0.25rem;
  border-radius: 50%;
  padding: 0.125rem;
  transition: color var(--transition);
}
.rr-info-btn:hover {
  color: var(--accent);
}
.rr-help-box {
  width: min(600px, calc(100vw - 2rem));
}
.rr-help-body {
  font-size: 0.875rem;
  line-height: 1.65;
  color: var(--ink-secondary);
  padding: 0.25rem 0;
}
.rr-help-body h4 {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--ink);
  margin: 1.25rem 0 0.375rem;
  letter-spacing: -0.01em;
}
.rr-help-body p {
  margin: 0 0 0.625rem;
}
.rr-help-body p:last-child {
  margin-bottom: 0;
}
.rr-help-body code {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.8125rem;
  padding: 0.125rem 0.375rem;
  background: var(--line-soft);
  border-radius: 4px;
}
.rr-help-example {
  background: var(--line-soft);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  margin: 0.5rem 0 0.75rem;
  font-size: 0.8125rem;
  line-height: 1.6;
}
.rr-help-example p {
  margin: 0 0 0.25rem;
}
.rr-help-example p:last-child {
  margin-bottom: 0;
}

/* Show page: routing summary */
.rr-summary {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}
.rr-summary-rule {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  align-items: center;
  font-size: 0.8125rem;
}
.rr-summary-rule .badge {
  font-size: 0.6875rem;
}
