/* ==========================================================================
   Gamet Studios Team Weiterleitungsmanager — UI Styles
   Basiert auf WARP Engine Design Tokens (/assets/css/tokens.css)
   ========================================================================== */

body.rm-body {
  min-height: 100dvh;
  background: var(--bg);
  background-image: var(--gradient-hero);
  background-attachment: fixed;
  color: var(--fg);
  font-family: var(--font-sans);
  line-height: var(--lh-normal);
}

.rm-hidden {
  display: none !important;
}

.rm-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* --- Login / Gate View --- */
.rm-gate {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: var(--space-6) var(--space-4);
}

.rm-gate-card {
  width: min(460px, 100%);
  padding: var(--space-7);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-strong);
  background: var(--bg-elev);
  box-shadow: var(--shadow-lg);
}

.rm-brand-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-strong);
  background: var(--accent-muted-soft);
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: var(--fs-2xs);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  margin-bottom: var(--space-5);
}

.rm-brand-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
}

.rm-gate-title {
  font-family: var(--font-display);
  font-size: var(--fs-2xl);
  font-weight: 700;
  letter-spacing: var(--tracking-tight);
  line-height: var(--lh-snug);
  margin-bottom: var(--space-3);
}

.rm-gate-desc {
  color: var(--fg-muted);
  font-size: var(--fs-sm);
  margin-bottom: var(--space-6);
}

.rm-alert {
  padding: 0.85rem 1rem;
  border-radius: var(--radius-sm);
  font-size: var(--fs-xs);
  margin-bottom: var(--space-5);
  border: 1px solid var(--border-strong);
  background: var(--surface);
}

.rm-alert--error {
  border-color: rgba(239, 68, 68, 0.45);
  background: rgba(239, 68, 68, 0.12);
  color: #fecaca;
}

:root[data-theme="light"] .rm-alert--error {
  color: #991b1b;
}

.rm-alert--warn {
  border-color: rgba(245, 158, 11, 0.45);
  background: rgba(245, 158, 11, 0.12);
  color: #fde68a;
}

:root[data-theme="light"] .rm-alert--warn {
  color: #92400e;
}

.rm-gate-actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.rm-gate-foot {
  margin-top: var(--space-6);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: var(--fs-2xs);
  color: var(--fg-subtle);
  font-family: var(--font-mono);
}

/* --- Main Shell --- */
.rm-shell {
  max-width: 1240px;
  margin: 0 auto;
  padding: var(--space-5) var(--container-pad) var(--space-8);
}

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

.rm-topbar-left {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.rm-logo {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--fs-lg);
  letter-spacing: var(--tracking-snug);
  color: var(--fg);
  text-decoration: none;
}

.rm-logo-mark {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  background: var(--gradient-accent);
  color: var(--accent-fg);
  display: grid;
  place-items: center;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  font-weight: 700;
  box-shadow: var(--shadow-sm);
}

.rm-host-pill {
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--fg-muted);
  font-family: var(--font-mono);
  font-size: var(--fs-2xs);
}

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

.rm-user-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: var(--fs-xs);
  color: var(--fg-muted);
}

.rm-role-tag {
  padding: 0.1rem 0.45rem;
  border-radius: var(--radius-full);
  background: var(--accent-muted);
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  text-transform: uppercase;
  font-weight: 600;
}

/* --- Buttons --- */
.rm-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.55rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-family: var(--font-sans);
  font-size: var(--fs-xs);
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background var(--dur-fast) ease, border-color var(--dur-fast) ease, color var(--dur-fast) ease, transform var(--dur-fast) ease;
}

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

.rm-btn--primary {
  background: var(--accent);
  color: var(--accent-fg);
}

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

.rm-btn--lg {
  padding: 0.8rem 1.25rem;
  font-size: var(--fs-sm);
  width: 100%;
}

.rm-btn--secondary {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--fg);
}

.rm-btn--secondary:hover {
  background: var(--surface-hover);
}

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

.rm-btn--ghost:hover {
  background: var(--surface-hover);
  color: var(--fg);
}

.rm-btn--danger {
  background: rgba(239, 68, 68, 0.14);
  border-color: rgba(239, 68, 68, 0.35);
  color: #f87171;
}

.rm-btn--danger:hover {
  background: var(--danger);
  border-color: var(--danger);
  color: #ffffff;
}

.rm-btn--icon {
  padding: 0.42rem 0.6rem;
  font-size: var(--fs-xs);
}

/* --- KPI Grid --- */
.rm-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.rm-kpi {
  padding: var(--space-5);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-elev);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.rm-kpi-label {
  font-size: var(--fs-2xs);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wider);
  color: var(--fg-subtle);
  font-weight: 600;
}

.rm-kpi-val {
  font-family: var(--font-display);
  font-size: var(--fs-2xl);
  font-weight: 700;
  letter-spacing: var(--tracking-tight);
  line-height: 1.15;
}

.rm-kpi-val--mono {
  font-family: var(--font-mono);
  font-size: var(--fs-lg);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rm-kpi-sub {
  font-size: var(--fs-2xs);
  color: var(--fg-muted);
}

/* --- Toolbar --- */
.rm-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.rm-toolbar-left {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  flex: 1 1 360px;
}

.rm-search {
  position: relative;
  flex: 1 1 240px;
  max-width: 380px;
}

.rm-input,
.rm-select,
.rm-textarea {
  width: 100%;
  padding: 0.6rem 0.85rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: var(--fs-xs);
  transition: border-color var(--dur-fast) ease, background var(--dur-fast) ease;
}

.rm-input--mono {
  font-family: var(--font-mono);
}

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

.rm-filter-group {
  display: inline-flex;
  padding: 3px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
}

.rm-filter-btn {
  padding: 0.38rem 0.75rem;
  border-radius: calc(var(--radius-sm) - 2px);
  border: 0;
  background: transparent;
  color: var(--fg-muted);
  font-size: var(--fs-2xs);
  font-weight: 600;
  cursor: pointer;
}

.rm-filter-btn[aria-pressed="true"] {
  background: var(--accent);
  color: var(--accent-fg);
}

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

.rm-toolbar-right .rm-select {
  width: auto;
  min-width: 170px;
}

/* --- Responsive Data Table (Modern Web Guidance: container queries + sticky headers) --- */
.rm-table-wrap {
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-elev);
  overflow: auto;
  max-inline-size: 100%;
  max-block-size: min(680px, 72vh);
  container-type: inline-size;
}

.rm-table-wrap:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}

.rm-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: var(--fs-xs);
  --label-2: "Ziel-URL";
  --label-3: "Status";
  --label-4: "Klicks";
  --label-5: "Aktionen";
}

.rm-table thead {
  position: sticky;
  inset-block-start: 0;
  z-index: 2;
  background: var(--bg-elev-2);
}

.rm-table thead th {
  text-align: left;
  padding: 0.85rem 1rem;
  font-size: var(--fs-2xs);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wider);
  color: var(--fg-subtle);
  font-weight: 600;
  border-bottom: 1px solid var(--border-strong);
  white-space: nowrap;
}

.rm-table tbody tr {
  transition: background var(--dur-fast) ease;
}

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

.rm-table tbody th,
.rm-table tbody td {
  padding: 0.9rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.rm-table tbody tr:last-child th,
.rm-table tbody tr:last-child td {
  border-bottom: 0;
}

.rm-table tbody th {
  text-align: left;
  font-weight: 500;
  position: sticky;
  inset-inline-start: 0;
  background: var(--bg-elev);
  z-index: 1;
}

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

.rm-slug-cell {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 180px;
}

.rm-slug-row {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.rm-slug-link {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--fg);
  text-decoration: none;
}

.rm-slug-link:hover {
  color: var(--accent);
  text-decoration: underline;
}

.rm-label-sub {
  font-size: var(--fs-2xs);
  color: var(--fg-muted);
}

.rm-target-cell {
  max-width: 360px;
}

.rm-target-url {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--fg-muted);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  text-decoration: none;
}

.rm-target-url:hover {
  color: var(--fg);
  text-decoration: underline;
}

.rm-note-sub {
  font-size: var(--fs-2xs);
  color: var(--fg-subtle);
  margin-top: 0.15rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rm-badges {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: nowrap;
}

.rm-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.22rem 0.6rem;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
}

.rm-badge--active {
  background: rgba(34, 197, 94, 0.14);
  color: #4ade80;
  border: 1px solid rgba(34, 197, 94, 0.3);
}

:root[data-theme="light"] .rm-badge--active {
  color: #15803d;
}

.rm-badge--paused {
  background: rgba(245, 158, 11, 0.14);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

:root[data-theme="light"] .rm-badge--paused {
  color: #b45309;
}

.rm-badge--code {
  background: var(--surface);
  color: var(--fg-muted);
  border: 1px solid var(--border);
  font-family: var(--font-mono);
}

.rm-hits {
  font-family: var(--font-mono);
  font-weight: 600;
  white-space: nowrap;
}

.rm-hits-sub {
  display: block;
  font-family: var(--font-sans);
  font-size: 0.7rem;
  font-weight: 400;
  color: var(--fg-subtle);
}

.rm-row-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  white-space: nowrap;
}

.rm-empty {
  padding: var(--space-8) var(--space-5);
  text-align: center;
  color: var(--fg-muted);
}

@container (width < 720px) {
  .rm-table,
  .rm-table thead,
  .rm-table tbody,
  .rm-table tr,
  .rm-table th,
  .rm-table td {
    display: block;
  }

  .rm-table thead {
    display: none;
  }

  .rm-table tbody tr {
    margin: var(--space-3);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    background: var(--surface);
    overflow: hidden;
  }

  .rm-table tbody th {
    position: sticky;
    inset-block-start: 0;
    z-index: 2;
    background: var(--bg-elev-2);
    border-bottom: 1px solid var(--border);
  }

  .rm-table tbody td {
    border-bottom: 1px solid var(--border);
    padding: 0.65rem 1rem;
  }

  .rm-table tbody td::before {
    display: block;
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: var(--tracking-wider);
    color: var(--fg-subtle);
    margin-bottom: 0.25rem;
    font-weight: 600;
  }

  .rm-table tbody td:nth-child(2)::before { content: var(--label-2); }
  .rm-table tbody td:nth-child(3)::before { content: var(--label-3); }
  .rm-table tbody td:nth-child(4)::before { content: var(--label-4); }
  .rm-table tbody td:nth-child(5)::before { content: var(--label-5); }

  .rm-target-cell {
    max-width: 100%;
  }
}

/* --- Native <dialog> Modals (Modern Web Guidance) --- */
dialog.rm-dialog {
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--bg-elev);
  color: var(--fg);
  box-shadow: var(--shadow-lg);
  width: min(560px, calc(100vw - 2rem));
  max-height: calc(100dvh - 2rem);
  margin: auto;
  overflow: auto;
}

dialog.rm-dialog:modal {
  overscroll-behavior: contain;
}

dialog.rm-dialog::backdrop {
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(6px);
  overflow: hidden;
  overscroll-behavior: contain;
}

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

.rm-dialog-title {
  font-family: var(--font-display);
  font-size: var(--fs-lg);
  font-weight: 700;
  letter-spacing: var(--tracking-snug);
}

.rm-dialog-body {
  padding: var(--space-5) var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.rm-dialog-foot {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--border);
  background: var(--surface);
}

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

.rm-field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
}

@media (max-width: 560px) {
  .rm-field-row {
    grid-template-columns: 1fr;
  }
}

.rm-label {
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--fg);
}

.rm-hint {
  font-size: var(--fs-2xs);
  color: var(--fg-subtle);
}

.rm-slug-input-group {
  display: flex;
  align-items: stretch;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  overflow: hidden;
}

.rm-slug-input-group:focus-within {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-muted);
}

.rm-slug-prefix {
  display: inline-flex;
  align-items: center;
  padding: 0 0.75rem;
  background: var(--bg-elev-2);
  border-right: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: var(--fg-muted);
  white-space: nowrap;
}

.rm-slug-input-group .rm-input {
  border: 0;
  border-radius: 0;
  box-shadow: none;
  background: transparent;
}

.rm-preview-box {
  padding: 0.75rem 0.9rem;
  border-radius: var(--radius-sm);
  border: 1px dashed var(--border-strong);
  background: var(--accent-muted-soft);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--fg-muted);
  word-break: break-all;
}

.rm-preview-box strong {
  color: var(--accent);
}

.rm-checkbox-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-size: var(--fs-xs);
  cursor: pointer;
}

.rm-checkbox-row input {
  accent-color: var(--accent);
  width: 16px;
  height: 16px;
}

.rm-copy-box {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.rm-auth-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.rm-pw-group {
  display: flex;
  align-items: stretch;
  gap: 0.4rem;
}

.rm-pw-group .rm-input {
  flex: 1;
}

.rm-divider {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin: var(--space-4) 0;
  color: var(--fg-subtle);
  font-size: var(--fs-2xs);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wider);
}

.rm-divider::before,
.rm-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.rm-users-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.rm-user-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: 0.7rem 0.85rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
}

.rm-user-meta {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.rm-user-meta strong {
  font-size: var(--fs-xs);
  color: var(--fg);
}

.rm-user-meta span {
  font-size: var(--fs-2xs);
  color: var(--fg-muted);
  font-family: var(--font-mono);
  overflow: hidden;
  text-overflow: ellipsis;
}

.rm-section-sep {
  border: 0;
  border-top: 1px solid var(--border);
  margin: var(--space-2) 0;
}

.rm-footer {
  margin-top: var(--space-7);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--space-3);
  font-size: var(--fs-2xs);
  color: var(--fg-subtle);
  font-family: var(--font-mono);
}
