/* ── Brand tokens ─────────────────────────────────────────────── */
:root {
  --rtv-primary: #00aef1;
  --rtv-primary-dark: #0090c7;
  --rtv-primary-soft: rgba(0, 174, 241, .09);
  --rtv-primary-soft-text: #0d8dbd;
  --rtv-secondary: #003b5c;
  --rtv-bg: #f4f6f9;
  --rtv-surface: #ffffff;
  --rtv-text: #212529;
  --rtv-text-muted: #6c757d;
  --rtv-border: #dee2e6;
  --rtv-brand-text: #003b5c;
  --rtv-gradient: linear-gradient(135deg, #00aef1 0%, #003b5c 100%);
  --rtv-gradient-text: linear-gradient(120deg, #00aef1 15%, #0077b6 100%);

  --rtv-radius: .5rem;
  --rtv-radius-md: .75rem;
  --rtv-radius-lg: 1rem;
  --rtv-radius-btn: .5rem;

  --rtv-shadow: 0 1px 3px rgba(25, 42, 61, .05), 0 1px 2px rgba(25, 42, 61, .04);
  --rtv-shadow-md: 0 4px 12px rgba(25, 42, 61, .06), 0 1px 3px rgba(25, 42, 61, .05);
  --rtv-shadow-lg: 0 12px 28px rgba(25, 42, 61, .12), 0 4px 10px rgba(25, 42, 61, .06);

  --rtv-font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

[data-bs-theme="dark"] {
  --rtv-bg: #10151f;
  --rtv-surface: #1a212f;
  --rtv-text: #e6ebf2;
  --rtv-text-muted: #99a5b5;
  --rtv-border: #2b3444;
  --rtv-brand-text: #e6ebf2;
  --rtv-primary-soft: rgba(0, 174, 241, .14);
  --rtv-primary-soft-text: #6ec8ef;
  --rtv-gradient-text: linear-gradient(120deg, #4cc3f4 15%, #9fdcf5 100%);
  --rtv-shadow: 0 1px 3px rgba(0, 0, 0, .3), 0 1px 2px rgba(0, 0, 0, .25);
  --rtv-shadow-md: 0 4px 12px rgba(0, 0, 0, .35), 0 1px 3px rgba(0, 0, 0, .3);
  --rtv-shadow-lg: 0 12px 28px rgba(0, 0, 0, .45), 0 4px 10px rgba(0, 0, 0, .3);
}

body {
  background:
    radial-gradient(1100px 480px at 85% -10%, rgba(0, 174, 241, .07), transparent 60%),
    radial-gradient(800px 420px at -10% 5%, rgba(0, 59, 92, .05), transparent 55%),
    var(--rtv-bg);
  color: var(--rtv-text);
  font-family: var(--rtv-font);
  font-size: .9375rem;
  -webkit-font-smoothing: antialiased;
}

[data-bs-theme="dark"] body {
  background:
    radial-gradient(1100px 480px at 85% -10%, rgba(0, 174, 241, .1), transparent 60%),
    radial-gradient(800px 420px at -10% 5%, rgba(0, 174, 241, .04), transparent 55%),
    var(--rtv-bg);
}

/* ── Login / standalone page background ───────────────────────── */
.login-page {
  background:
    radial-gradient(900px 500px at 70% -10%, rgba(0, 174, 241, .14), transparent 60%),
    radial-gradient(700px 450px at 20% 110%, rgba(0, 59, 92, .08), transparent 55%),
    var(--rtv-bg);
}

[data-bs-theme="dark"] .login-page {
  background:
    radial-gradient(900px 500px at 70% -10%, rgba(0, 174, 241, .16), transparent 60%),
    radial-gradient(700px 450px at 20% 110%, rgba(0, 174, 241, .06), transparent 55%),
    var(--rtv-bg);
}

/* ── Navbar ───────────────────────────────────────────────────── */
.navbar {
  position: sticky;
  background: rgba(255, 255, 255, .86) !important;
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--rtv-border);
  box-shadow: 0 1px 0 rgba(0, 59, 92, .03), var(--rtv-shadow);
}

[data-bs-theme="dark"] .navbar {
  background: rgba(26, 33, 47, .86) !important;
}

.navbar::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 1px;
  background: var(--rtv-gradient);
  opacity: .35;
}

.navbar .navbar-brand img {
  height: 38px;
  width: auto;
  object-fit: contain;
  border-radius: .3rem;
}

.brand-text {
  font-size: .95rem;
  color: var(--rtv-brand-text);
}

.navbar-display-name {
  font-size: .875rem;
}

.rtv-brand-text {
  color: var(--rtv-brand-text);
}

.navbar .nav-link {
  color: var(--rtv-text-muted);
  font-weight: 500;
  padding: .5rem .75rem !important;
  border-radius: var(--rtv-radius);
  transition: color .15s, background .15s;
  font-size: .875rem;
}

.navbar .nav-link:hover {
  color: var(--rtv-primary);
  background: var(--rtv-primary-soft);
}

.navbar .nav-link.active {
  color: var(--rtv-primary);
  background: var(--rtv-primary-soft);
  font-weight: 600;
}

.navbar .dropdown-toggle::after {
  font-size: .6rem;
  vertical-align: .15em;
  margin-left: .3rem;
}

/* ── User avatar (navbar) ─────────────────────────────────────── */
.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--rtv-primary);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: .8rem;
  font-weight: 600;
  letter-spacing: .02em;
  line-height: 1;
}

.avatar-text {
  line-height: 1;
}

.avatar-sm {
  width: 26px;
  height: 26px;
  font-size: .7rem;
}

.avatar-xl {
  width: 88px;
  height: 88px;
}

.avatar-xl .avatar-text {
  font-size: 1.9rem;
}

.dropdown-menu.user-menu {
  border: 1px solid var(--rtv-border);
  border-radius: var(--rtv-radius-md);
  box-shadow: var(--rtv-shadow-md);
  padding: .5rem 0;
  min-width: 220px;
}

.dropdown-menu.user-menu .dropdown-header {
  font-size: .8rem;
  font-weight: 600;
  color: var(--rtv-text-muted);
  padding: .5rem 1rem .25rem;
}

.dropdown-menu.user-menu .dropdown-item {
  font-size: .875rem;
  padding: .45rem 1rem;
  transition: background .12s;
}

.dropdown-menu.user-menu .dropdown-item:hover {
  background: var(--rtv-primary-soft);
}

.dropdown-menu.user-menu .dropdown-item.text-danger:hover {
  background: rgba(220, 53, 69, .06);
}

/* ── Theme toggle ─────────────────────────────────────────────── */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: none;
  border-radius: var(--rtv-radius);
  background: transparent;
  color: var(--rtv-text-muted);
  transition: color .15s, background .15s, transform .15s;
}

.theme-toggle:hover {
  color: var(--rtv-primary);
  background: var(--rtv-primary-soft);
}

.theme-toggle svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.icon-moon { display: none; }
[data-bs-theme="dark"] .icon-sun { display: none; }
[data-bs-theme="dark"] .icon-moon { display: inline-block; }

.theme-toggle-float {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 1030;
  background: var(--rtv-surface);
  border: 1px solid var(--rtv-border);
  box-shadow: var(--rtv-shadow-md);
}

/* ── Login card ───────────────────────────────────────────────── */
.login-card {
  max-width: 400px;
  position: relative;
  overflow: hidden;
  border: 1px solid var(--rtv-border) !important;
  border-radius: var(--rtv-radius-lg) !important;
  box-shadow: var(--rtv-shadow-lg) !important;
}

.login-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--rtv-gradient);
  pointer-events: none;
}

.login-card .card-body {
  padding: 2.5rem 2rem;
}

.login-brand {
  width: 96px;
  height: 96px;
  border-radius: var(--rtv-radius-md);
  object-fit: contain;
  margin-bottom: .75rem;
  box-shadow: 0 4px 14px rgba(0, 174, 241, .18);
}

/* ── Icon circles ─────────────────────────────────────────────── */
.icon-circle {
  width: 46px;
  height: 46px;
  border-radius: .95rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: var(--rtv-primary-soft);
  color: var(--rtv-primary-soft-text);
}

.icon-circle svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

.icon-circle-danger {
  background: rgba(220, 53, 69, .1);
  color: #dc3545;
}

[data-bs-theme="dark"] .icon-circle-danger {
  background: rgba(220, 53, 69, .16);
  color: #f0697a;
}

/* ── Item cards (accent bar + hover lift) ─────────────────────── */
.item-card {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--rtv-border) !important;
  border-radius: var(--rtv-radius-lg) !important;
  background: var(--rtv-surface);
  box-shadow: var(--rtv-shadow) !important;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}

.item-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--rtv-gradient);
  pointer-events: none;
}

.item-card:hover {
  transform: translateY(-3px);
  border-color: rgba(0, 174, 241, .35) !important;
  box-shadow: var(--rtv-shadow-lg) !important;
}

/* ── General cards ────────────────────────────────────────────── */
.card {
  border: 1px solid var(--rtv-border);
  border-radius: var(--rtv-radius-md);
  background: var(--rtv-surface);
  box-shadow: var(--rtv-shadow);
}

.card-header {
  border-bottom: 1px solid var(--rtv-border);
  background: var(--rtv-surface);
  font-weight: 600;
  font-size: .875rem;
  padding: .9rem 1.25rem;
}

/* ── Tag badge ────────────────────────────────────────────────── */
.tag-badge {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .3rem .7rem;
  border-radius: 2rem;
  font-size: .75rem;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: .01em;
  background: var(--rtv-primary-soft);
  color: var(--rtv-primary-soft-text);
  white-space: nowrap;
}

.tag-badge.tag-private {
  background: var(--bs-secondary-bg);
  color: var(--bs-secondary-color);
}

/* ── Tables ───────────────────────────────────────────────────── */
.table th {
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--rtv-text-muted);
  font-weight: 600;
}

.table td {
  vertical-align: middle;
}

/* ── Buttons ──────────────────────────────────────────────────── */
.btn {
  border-radius: var(--rtv-radius-btn);
}

.btn-primary {
  background: var(--rtv-primary);
  border-color: var(--rtv-primary);
  box-shadow: 0 2px 8px rgba(0, 174, 241, .25);
}

.btn-primary:hover,
.btn-primary:active {
  background: var(--rtv-primary-dark);
  border-color: var(--rtv-primary-dark);
}

.btn:focus-visible,
.form-control:focus,
.form-select:focus {
  border-color: var(--rtv-primary);
  box-shadow: 0 0 0 .2rem rgba(0, 174, 241, .18);
}

.btn-outline-secondary {
  font-size: .875rem;
}

/* ── Icon buttons ─────────────────────────────────────────────── */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  padding: 0;
  min-width: 1.75rem;
  min-height: 1.75rem;
  aspect-ratio: 1 / 1;
  vertical-align: middle;
}

.icon-btn svg {
  width: 1rem;
  height: 1rem;
  fill: currentColor;
}

.icon-btn .icon-feedback { display: none; }

.icon-btn.is-copied .icon-default,
.icon-btn.is-manual .icon-default,
.icon-btn.is-error .icon-default { display: none; }

.icon-btn.is-copied .icon-check { display: inline-block; }
.icon-btn.is-manual .icon-keyboard { display: inline-block; }
.icon-btn.is-error .icon-alert { display: inline-block; }

/* Ghost icon buttons (card actions) — Carbon/Material-style, quiet until hover */
.btn-ghost {
  color: var(--bs-secondary-color);
  background: transparent;
  border: 1px solid transparent;
}

.btn-ghost:hover,
.btn-ghost:focus-visible {
  color: var(--rtv-primary);
  background: var(--bs-tertiary-bg);
}

.btn-ghost-danger:hover,
.btn-ghost-danger:focus-visible {
  color: var(--bs-danger);
  background: var(--bs-danger-bg-subtle);
}

/* ── Card footer actions (hairline divider anchors the row) ───── */
.card-actions {
  border-top: 1px solid var(--rtv-border);
  padding-top: .75rem;
}

/* Flex rows: let .text-truncate actually ellipsize (min-width:0) */
.username-row .text-truncate {
  min-width: 0;
}

/* 2-line clamp so long descriptions don't stretch one card */
.description {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ── Page header ──────────────────────────────────────────────── */
.page-header {
  border-bottom: 1px solid var(--rtv-border);
  padding-bottom: 1rem;
  margin-bottom: 1.5rem;
}

.page-header h1 {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0;
  color: var(--rtv-text);
}

/* ── Secondary brand wordmark ─────────────────────────────────── */
.secondary-brand {
  font-size: .8rem;
  font-weight: 700;
  letter-spacing: .16em;
  text-transform: uppercase;
  background: var(--rtv-gradient-text);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: var(--rtv-primary);
}

/* ── Empty state ──────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--rtv-text-muted);
  font-size: .95rem;
}

/* ── Admin panel ──────────────────────────────────────────────── */
.admin-sidebar {
  position: sticky;
  top: 1rem;
  border-radius: var(--rtv-radius-md);
}

.admin-sidebar-label {
  letter-spacing: .05em;
}

.url-cell {
  max-width: 16rem;
}

.admin-nav-link {
  display: block;
  padding: .5rem .8rem;
  margin: 2px .25rem;
  border-radius: var(--rtv-radius);
  color: var(--rtv-text);
  font-size: .875rem;
  font-weight: 500;
  text-decoration: none;
  transition: color .15s, background .15s;
}

.admin-nav-link:hover {
  color: var(--rtv-primary);
  background: var(--rtv-primary-soft);
}

.admin-nav-link.active {
  color: var(--rtv-primary);
  background: var(--rtv-primary-soft);
  font-weight: 600;
}

.admin-nav-section {
  margin: .5rem .75rem .15rem;
  padding-top: .25rem;
  color: var(--rtv-text-muted);
  font-size: .6875rem;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.admin-nav-back {
  color: var(--rtv-text-muted);
  font-size: .8125rem;
}

.admin-nav-scroll {
  display: flex;
  gap: .4rem;
  overflow-x: auto;
  padding: .25rem .125rem .5rem;
  -webkit-overflow-scrolling: touch;
}

.admin-pill {
  flex: 0 0 auto;
  padding: .4rem .85rem;
  border-radius: 2rem;
  border: 1px solid var(--rtv-border);
  background: var(--rtv-surface);
  color: var(--rtv-text);
  font-size: .8125rem;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  transition: color .15s, background .15s, border-color .15s;
}

.admin-pill:hover,
.admin-pill.active {
  color: var(--rtv-primary);
  border-color: var(--rtv-primary);
  background: var(--rtv-primary-soft);
}

.admin-pill.active {
  font-weight: 600;
}

.admin-pill-back {
  color: var(--rtv-text-muted);
}

/* ── Footer ───────────────────────────────────────────────────── */
footer {
  font-size: .8rem;
}

/* ── Form tweaks ──────────────────────────────────────────────── */
.form-label {
  font-size: .8125rem;
  font-weight: 500;
  color: var(--rtv-text-muted);
}

/* ── Flash alerts (login / flash) ─────────────────────────────── */
.alert {
  border-radius: var(--rtv-radius-md);
  font-size: .875rem;
}

/* ── Misc ─────────────────────────────────────────────────────── */
.text-primary { color: var(--rtv-primary) !important; }