:root {
  --bg: #eef2f5;
  --bg-soft: rgba(255, 255, 255, 0.72);
  --panel: rgba(255, 255, 255, 0.94);
  --panel-alt: #f5f8fb;
  --panel-strong: #eaf1f5;
  --text: #122033;
  --muted: #6f7f92;
  --border: rgba(178, 191, 205, 0.55);
  --accent: #17c39b;
  --accent-strong: #0ea37f;
  --accent-secondary: #16324d;
  --danger: #d85a66;
  --success: #16956f;
  --shadow: 0 18px 44px rgba(23, 36, 51, 0.08);
}

body.theme-dark {
  --bg: #171d26;
  --bg-soft: rgba(24, 32, 42, 0.82);
  --panel: rgba(31, 40, 52, 0.96);
  --panel-alt: #25303d;
  --panel-strong: #202a36;
  --text: #f2f6fb;
  --muted: #97a7b7;
  --border: rgba(96, 113, 132, 0.42);
  --accent: #21d0a5;
  --accent-strong: #17b38d;
  --accent-secondary: #314458;
  --danger: #ff7f8d;
  --success: #56d3a6;
  --shadow: 0 24px 68px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

html {
  font-size: 95%;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  font-size: 13px;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(33, 208, 165, 0.12), transparent 24%),
    radial-gradient(circle at bottom right, rgba(22, 50, 77, 0.1), transparent 22%),
    linear-gradient(180deg, var(--bg) 0%, color-mix(in srgb, var(--bg), #000 3%) 100%);
}

input,
button,
select {
  font: inherit;
}

button {
  border: 0;
  border-radius: 14px;
  padding: 0.6rem 0.84rem;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease;
}

button:hover {
  background: var(--accent-strong);
  transform: translateY(-1px);
}

button.btn-with-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
}

button.btn-with-icon .btn-icon {
  width: 1.05rem;
  height: 1.05rem;
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
  color: currentColor;
}

button.btn-with-icon .btn-icon svg {
  width: 100%;
  height: 100%;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

button.btn-with-icon .btn-label {
  line-height: 1;
}

button.secondary {
  background: var(--accent-secondary);
}

button.secondary:hover {
  background: color-mix(in srgb, var(--accent-secondary), #fff 10%);
}

button.danger {
  background: var(--danger);
}

#logout-button {
  background: #d84d57;
  border-radius: 10px;
}

#logout-button:hover {
  background: #bb3e47;
}

input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.58rem 0.68rem;
  background: color-mix(in srgb, var(--panel-alt), #fff 12%);
  color: var(--text);
}

select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.58rem 0.68rem;
  background: color-mix(in srgb, var(--panel-alt), #fff 12%);
  color: var(--text);
}

label {
  display: block;
  color: var(--muted);
  font-size: 0.95rem;
}

label input,
label select {
  margin-top: 0.42rem;
}

code {
  background: var(--panel-alt);
  padding: 0.15rem 0.4rem;
  border-radius: 7px;
}

.auth-container {
  width: min(1120px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 2rem 0 3rem;
}

.auth-page .auth-container {
  display: grid;
  place-items: center;
  min-height: 100vh;
}

.card {
  background: var(--panel);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-radius: 26px;
  box-shadow: var(--shadow);
  padding: 1rem;
}

.auth-page .card {
  width: min(320px, calc(100% - 1rem));
  border-radius: 16px;
}

.login-card {
  max-width: 320px;
  padding: 1rem 0.95rem 0.95rem;
  border-radius: 16px;
}

.login-brand {
  text-align: center;
  margin-bottom: 0.9rem;
}

.login-logo {
  width: min(120px, 48%);
  height: auto;
  display: block;
  margin: 0 auto 0.35rem;
  filter: drop-shadow(0 16px 32px rgba(29, 205, 159, 0.2));
}

.login-brand h1 {
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.18;
}

.auth-page label {
  font-size: 0.82rem;
}

.auth-page input {
  padding: 0.58rem 0.72rem;
  font-size: 0.92rem;
  border-radius: 10px;
}

.auth-page button[type="submit"] {
  padding: 0.62rem 0.9rem;
  font-size: 0.95rem;
  border-radius: 10px;
}

.auth-page .stack {
  gap: 0.75rem;
}

.app-shell {
  display: grid;
  grid-template-columns: 252px minmax(0, 1fr);
  min-height: 100vh;
  position: relative;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  background: rgba(15, 21, 29, 0.98);
  border-right: 0;
  padding: 1rem 0.9rem 1.1rem;
  overflow-x: visible;
}

.sidebar::after {
  display: none;
}

.sidebar::before {
  display: none;
}

.mobile-menu-button,
.mobile-refresh-button,
.sidebar-overlay {
  display: none;
}

.mobile-menu-button {
  position: fixed;
  top: 0.65rem;
  left: 0.75rem;
  width: 48px;
  height: 48px;
  padding: 0;
  border-radius: 14px;
  background: rgba(24, 31, 42, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.08);
  z-index: 50;
}

.mobile-refresh-button {
  position: fixed;
  top: 0.65rem;
  left: calc(0.75rem + 48px + 0.5rem);
  width: 48px;
  height: 48px;
  padding: 0;
  border-radius: 14px;
  background: rgba(38, 94, 149, 0.96);
  border: 1px solid rgba(181, 214, 255, 0.28);
  color: #f4fff9;
  z-index: 50;
  display: none;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 24px rgba(12, 39, 72, 0.28);
}

.mobile-refresh-button:hover {
  background: rgba(48, 112, 176, 0.98);
}

.mobile-refresh-icon {
  font-size: 1.22rem;
  line-height: 1;
}

.mobile-refresh-button.loading .mobile-refresh-icon {
  animation: mobile-refresh-spin 0.9s linear infinite;
}

@keyframes mobile-refresh-spin {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

.mobile-menu-button span {
  display: block;
  width: 22px;
  height: 3px;
  margin: 4px auto;
  border-radius: 999px;
  background: #35d7aa;
}

.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 10, 18, 0.54);
  z-index: 35;
}

.mobile-topbar {
  display: none;
}

body:not(.theme-dark) .sidebar {
  background: rgba(243, 247, 250, 0.9);
}

.sidebar-brand {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 1.35rem;
  padding: 0.25rem 0 0.45rem;
}

.sidebar-logo {
  width: 108px;
  height: 108px;
  object-fit: contain;
  border-radius: 16px;
  filter: drop-shadow(0 10px 22px rgba(33, 208, 165, 0.14));
}

.sidebar-brand strong,
.sidebar-brand span {
  display: block;
}

.sidebar-brand span {
  color: #b9c7d5;
  font-size: 1rem;
  font-weight: 500;
  line-height: 1.25;
}

.sidebar-nav,
.sidebar-links {
  display: grid;
  gap: 0.7rem;
}

.sidebar-section {
  margin-top: 1.5rem;
}

.sidebar-main {
  display: grid;
  gap: 0.15rem;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 1.2rem;
}

.sidebar-section-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--muted);
  font-size: 0.92rem;
  margin-bottom: 0.78rem;
}

.sidebar-badge {
  min-width: 28px;
  padding: 0.18rem 0.5rem;
  border-radius: 999px;
  background: rgba(56, 71, 89, 0.96);
  color: #dce8f5;
  text-align: center;
}

.sidebar-link {
  width: 100%;
  text-align: left;
  background: rgba(34, 43, 54, 0.9);
  color: #d8e4f0;
  border: 0;
  padding: 0.72rem 0.82rem;
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  align-items: center;
  column-gap: 0.8rem;
  row-gap: 0.28rem;
  border-radius: 12px;
  box-shadow: none;
}

.sidebar-link:hover {
  background: rgba(41, 53, 67, 0.96);
  color: #f4fbff;
}

.sidebar-link.active {
  background: rgba(12, 82, 69, 0.62);
  color: #eefcf8;
  border: 0;
  box-shadow: inset 0 1px 0 rgba(57, 233, 192, 0.08);
}

body:not(.theme-dark) .sidebar-link.active {
  color: #fff;
}

.sidebar-link-text {
  font-weight: 700;
}

.sidebar-link-content {
  min-width: 0;
  display: grid;
  gap: 0.22rem;
}

.sidebar-link-icon {
  width: 24px;
  height: 24px;
  color: #9fb1c3;
  display: grid;
  place-items: center;
}

.sidebar-link-icon svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  stroke-width: 2.25;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sidebar-link:hover .sidebar-link-icon {
  color: #b5c6d6;
}

.sidebar-link.active .sidebar-link-icon,
#dashboard-home-button.active .sidebar-link-icon {
  color: #22d0a5;
}

.sidebar-link-meta {
  font-size: 0.82rem;
  opacity: 0.82;
  line-height: 1.28;
}

.sidebar-empty {
  color: var(--muted);
  font-size: 0.92rem;
  padding: 0.5rem 0.15rem;
}

#dashboard-home-button {
  background: rgba(34, 43, 54, 0.9);
  color: #d8e4f0;
  border: 0;
  border-radius: 12px;
  padding: 0.86rem 1rem;
  font-weight: 700;
  box-shadow: none;
}

#dashboard-home-button:hover {
  background: rgba(41, 53, 67, 0.96);
}

#dashboard-home-button.active {
  background: rgba(12, 82, 69, 0.62);
  color: #eefcf8;
  box-shadow: inset 0 1px 0 rgba(57, 233, 192, 0.08);
}

.sidebar-footer .sidebar-links .sidebar-link {
  border-radius: 12px;
  padding-block: 0.72rem;
}

.sidebar-link-text {
  color: inherit;
}

.sidebar-link-meta {
  color: rgba(220, 233, 245, 0.82);
}

body:not(.theme-dark) .sidebar {
  background: rgba(238, 243, 248, 0.98);
}

body:not(.theme-dark) .sidebar-link {
  background: rgba(255, 255, 255, 0.96);
  color: #223245;
  box-shadow: 0 10px 22px rgba(33, 45, 60, 0.04);
}

body:not(.theme-dark) .sidebar-link .sidebar-link-icon {
  color: #6b7d91;
}

body:not(.theme-dark) .sidebar-link-meta {
  color: #6f8094;
}

body:not(.theme-dark) .sidebar-link:hover {
  background: rgba(247, 250, 253, 0.98);
  color: #1b2a3d;
}

body:not(.theme-dark) .sidebar-link.active,
body:not(.theme-dark) #dashboard-home-button.active {
  background: rgba(18, 148, 121, 0.86);
  color: #f7fffc;
  box-shadow: none;
}

body:not(.theme-dark) .sidebar-link.active .sidebar-link-icon,
body:not(.theme-dark) #dashboard-home-button.active .sidebar-link-icon {
  color: #ecfffa;
}

body:not(.theme-dark) .sidebar-link.active .sidebar-link-meta,
body:not(.theme-dark) #dashboard-home-button.active .sidebar-link-meta {
  color: rgba(247, 255, 252, 0.88);
}

body:not(.theme-dark) #dashboard-home-button {
  background: rgba(255, 255, 255, 0.96);
  color: #223245;
  box-shadow: 0 10px 22px rgba(33, 45, 60, 0.04);
}

body:not(.theme-dark) #dashboard-home-button:hover {
  background: rgba(247, 250, 253, 0.98);
  color: #1b2a3d;
}

body:not(.theme-dark) .sidebar-badge {
  background: rgba(92, 108, 127, 0.9);
  color: #f4f8fc;
}

body:not(.theme-dark) .sidebar-section-title {
  color: #6f8094;
}

.content-area {
  padding: 1rem;
}

.topbar-dashboard {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1rem;
}

.header-brand h1 {
  font-size: 1.75rem;
}

.selected-link-header h2 {
  font-size: 1.55rem;
}

.header-brand {
  display: block;
}

.toolbar {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  align-items: center;
}

.header-brand h1,
.header-brand p,
.hero-card h2,
.hero-card p,
.selected-link-header h2,
.section-header h2,
.section-header h3 {
  margin: 0;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.users-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.home-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.profile-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.home-toolbar h2,
.users-toolbar h2 {
  margin: 0;
}

.profile-toolbar h2 {
  margin: 0;
}

button.users-toolbar-button,
button.secondary.users-toolbar-button {
  padding-inline: 1rem;
  border-radius: 10px !important;
  background: #18a689 !important;
  color: #f6fffb !important;
  border: 1px solid rgba(78, 255, 221, 0.1);
  box-shadow: 0 10px 24px rgba(24, 166, 137, 0.22);
}

button.link-toolbar-button,
button.secondary.link-toolbar-button {
  padding-inline: 1rem;
  background: #18a689 !important;
  color: #f6fffb !important;
  border: 1px solid rgba(78, 255, 221, 0.1);
  box-shadow: 0 10px 24px rgba(24, 166, 137, 0.22);
}

button.users-toolbar-button:hover,
button.secondary.users-toolbar-button:hover {
  background: #12917a !important;
}

button.link-toolbar-button:hover,
button.secondary.link-toolbar-button:hover {
  background: #12917a !important;
}

.header-brand p,
.hint,
.group-stats,
.selected-link-url,
.eyebrow {
  color: var(--muted);
}

.selected-link-url-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.65rem;
  margin-top: 0;
}

.selected-link-url-row .selected-link-url {
  margin: 0;
  min-width: 0;
}

.link-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.link-toolbar h2 {
  margin: 0;
}

.link-owner-card {
  min-width: 200px;
  position: relative;
  padding: 0.95rem 0.95rem 0.7rem;
  border-radius: 12px;
  border: 0;
  background: color-mix(in srgb, var(--panel-alt), #fff 3%);
  display: grid;
  gap: 0.2rem;
}

.link-owner-card[hidden] {
  display: none !important;
}

.link-owner-card-label {
  position: absolute;
  top: -0.55rem;
  left: 0.7rem;
  padding: 0 0.28rem;
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.02em;
  background: var(--bg);
}

.link-owner-card-value {
  font-size: 0.98rem;
  font-weight: 500;
}

.link-toolbar-button {
  padding-inline: 1rem;
  border-radius: 10px !important;
}

.groups-inline-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  min-height: 40px;
}

.link-footer-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  min-height: 40px;
}

.link-workspace .delete-link-button {
  border-radius: 10px;
  background: #d84d57;
}

.link-workspace .delete-link-button:hover {
  background: #bb3e47;
}

.link-workspace .delete-group {
  background: #d84d57;
}

.link-workspace .delete-group:hover {
  background: #bb3e47;
}

.selected-link-title,
.group-item-title {
  letter-spacing: -0.02em;
}

.copy-link-button {
  justify-self: end;
  padding: 0.46rem 0.8rem;
  border-radius: 10px;
  font-size: 0.9rem;
  white-space: nowrap;
  background: #f3c847;
  color: #1f2a37;
  border-color: rgba(243, 200, 71, 0.32);
  box-shadow: 0 10px 22px rgba(243, 200, 71, 0.16);
}

.copy-link-button:hover {
  background: #e1b839;
}

.home-workspace {
  display: grid;
  gap: 0.95rem;
}

.hero-card,
.link-info-card,
.groups-card,
.empty-dashboard-card {
  display: grid;
  gap: 0.65rem;
}

.hero-copy {
  display: grid;
  gap: 0.2rem;
}

.hero-card {
  position: relative;
  overflow: hidden;
  padding: 1.3rem 1.15rem 1.15rem;
  border-radius: 18px;
  border-color: transparent;
  background: color-mix(in srgb, var(--panel-alt), var(--panel) 16%);
  box-shadow: none;
  margin-bottom: 1rem;
}

#dashboard-home-panel::before {
  content: "";
  position: absolute;
  top: 12px;
  bottom: 12px;
  left: 0;
  width: 3px;
  border-radius: 18px 0 0 18px;
  background: #ff5b3d;
}

.hero-card-header {
  align-items: start;
}

.hero-card-header > div {
  display: grid;
  gap: 0.35rem;
}

.hero-card h3 {
  margin: 0;
}

.hero-card-header > div > p + p {
  display: none;
}

.hero-card .inline-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 150px;
  align-items: center;
  gap: 0.8rem;
}

.hero-card .inline-form input {
  min-height: 46px;
  border-radius: 12px;
}

.hero-card .inline-form button {
  width: 100%;
  min-width: 150px;
  min-height: 46px;
  justify-self: end;
  border-radius: 10px;
}

.hero-card .hint {
  margin-top: 0.05rem;
}

.link-info-card {
  position: relative;
  overflow: hidden;
  padding: 0.62rem 0.9rem;
  border-radius: 18px;
  border-color: transparent;
  background: color-mix(in srgb, var(--panel-alt), var(--panel) 16%);
  box-shadow: none;
}

.link-info-card::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 3px;
  border-radius: 18px 0 0 18px;
  background: #ff5b3d;
}

.selected-link-summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  min-height: 42px;
}

.selected-link-actions:empty {
  display: none;
}

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

.selected-link-stat {
  position: relative;
  overflow: hidden;
  min-height: 72px;
  padding: 0.62rem 0.85rem 0.62rem 0.95rem;
  border-radius: 18px;
  border-color: transparent;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--panel-alt), #fff 3%) 0%, color-mix(in srgb, var(--panel-alt), var(--panel) 18%) 100%);
  box-shadow: none;
  display: grid;
  align-content: start;
  gap: 0.18rem;
}

.selected-link-stat::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 3px;
  border-radius: 18px 0 0 18px;
  background: #22c55e;
}

.selected-link-stat:nth-child(2)::before {
  background: #f5b942;
}

.selected-link-stat:nth-child(3)::before {
  background: #fb7185;
}

.selected-link-stat span {
  color: var(--muted);
  font-size: 0.74rem;
  letter-spacing: 0.02em;
}

.selected-link-stat strong {
  font-size: 1.35rem;
  line-height: 1.05;
  letter-spacing: -0.03em;
}

.selected-link-stat p {
  margin: 0;
  color: var(--text);
  font-size: 1rem;
  line-height: 1.45;
  max-width: 32ch;
}

.selected-link-stat-wide {
  grid-column: 1 / -1;
  min-height: 0;
}

.add-group-card,
.add-user-card {
  display: grid;
  gap: 0.65rem;
  padding: 1.3rem 1.2rem 1.2rem;
  border-radius: 14px;
  border-color: transparent;
  background: color-mix(in srgb, var(--panel-alt), var(--panel) 16%);
  transition: border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.add-group-card[hidden],
.add-user-card[hidden] {
  display: none !important;
}

.add-group-card.is-open,
.add-user-card.is-open {
  border-color: transparent;
  transform: none;
  box-shadow: none;
}

.add-group-card-header,
.add-user-card-header {
  align-items: center;
}

.group-form {
  margin-top: 0.45rem;
  padding-top: 0.9rem;
  border-top: 0;
}

.group-form button[type="submit"] {
  justify-self: start;
  min-width: 180px;
  border-radius: 10px;
}

#create-user-form > button[type="submit"] {
  justify-self: end;
  width: auto;
  min-width: 190px;
  border-radius: 10px;
}

html.has-link-selection #dashboard-home-panel {
  display: none;
}

.inline-form {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.inline-form input {
  flex: 1 1 280px;
}

.message {
  min-height: 1.5rem;
  color: var(--danger);
  font-weight: 700;
}

.message.success {
  color: var(--success);
}

.selected-link-panel,
.link-workspace,
.stack,
.groups-list {
  display: grid;
  gap: 0.65rem;
}

.users-workspace {
  display: grid;
  gap: 1rem;
}

.selected-link-header,
.group-actions {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}

.selected-link-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.badge {
  background: var(--panel-strong);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.5rem 0.9rem;
  font-weight: 800;
  white-space: nowrap;
}

.grid-3,
.group-grid {
  display: grid;
  gap: 1rem;
}

.grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.group-grid {
  grid-template-columns: 2fr 1fr 1fr auto;
  align-items: end;
}

.checkbox-field {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--text);
}

.checkbox-field input {
  width: auto;
}

.group-item {
  background: var(--panel-alt);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1rem;
  display: grid;
  gap: 0.75rem;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--panel-alt), #fff 6%) 0%, var(--panel-alt) 100%);
  box-shadow: 0 14px 32px rgba(13, 24, 36, 0.08);
}

.group-item-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}

.group-item-eyebrow {
  margin-bottom: 0.2rem;
}

.group-item-title {
  margin: 0;
  font-size: 1.12rem;
}

.group-status-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 84px;
  padding: 0.48rem 0.8rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--success), transparent 82%);
  color: var(--success);
  border: 1px solid color-mix(in srgb, var(--success), transparent 72%);
  font-weight: 700;
}

.group-status-badge.is-inactive {
  background: color-mix(in srgb, var(--muted), transparent 84%);
  color: var(--muted);
  border-color: color-mix(in srgb, var(--muted), transparent 72%);
}

.groups-card {
  padding: 0;
  overflow: hidden;
  border-radius: 18px;
  border-color: transparent;
  box-shadow: none;
}

.groups-card .section-header {
  padding: 1.15rem 1.15rem 0.8rem;
  margin: 0;
}

.groups-card .section-header .eyebrow {
  display: none;
}

.groups-table-head,
.group-row-summary {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(100px, 0.7fr) minmax(90px, 0.6fr) minmax(90px, 0.6fr) minmax(110px, 0.7fr) 54px;
  align-items: center;
  gap: 1rem;
  padding: 0.95rem 1.15rem;
}

.groups-table-head {
  background: #3e4a58;
  color: var(--muted);
  font-weight: 700;
}

.groups-table-actions {
  text-align: center;
}

.groups-list {
  display: block;
}

.groups-list > .empty-state {
  margin: 1rem 1.15rem 1.15rem;
}

.group-row-item {
  border-top: 0;
}

.group-row-item.is-open {
  background: color-mix(in srgb, var(--panel-alt), var(--panel) 8%);
}

.group-row-cell {
  min-width: 0;
  display: grid;
  gap: 0.22rem;
}

.group-row-label {
  display: none;
}

.group-row-value {
  display: block;
  min-width: 0;
  font-size: 0.98rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.group-row-cell-status {
  justify-items: start;
}

.group-row-summary .group-status-badge {
  min-width: 0;
  min-height: 0;
  padding: 0.18rem 0.55rem;
  border-radius: 6px;
  font-size: 0.82rem;
  line-height: 1.15;
  border-width: 0;
  background: rgba(15, 145, 116, 0.16);
  color: #1fc7a0;
}

.group-row-summary .group-status-badge.is-inactive {
  background: rgba(120, 134, 156, 0.16);
  color: #9aa7b7;
}

.group-row-toggle {
  width: 42px;
  height: 42px;
  padding: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  border: 1px solid transparent;
  font-size: 1.35rem;
  line-height: 1;
  box-shadow: none;
}

.group-row-toggle:hover {
  background: color-mix(in srgb, var(--accent), transparent 88%);
  color: var(--text);
}

.group-row-toggle.is-open {
  background: color-mix(in srgb, var(--accent), transparent 80%);
  color: var(--text);
  border-color: color-mix(in srgb, var(--accent), transparent 62%);
}

.group-edit-form {
  margin: 0;
  padding: 0.65rem 1.15rem 1.15rem;
  border-top: 1px solid color-mix(in srgb, var(--border), transparent 14%);
  border-radius: 0;
  background: color-mix(in srgb, var(--panel-alt), var(--panel) 18%);
}

.group-edit-form[hidden] {
  display: none !important;
}

.group-edit-form .group-grid {
  gap: 0.85rem;
}

.group-edit-form label {
  font-size: 0.9rem;
}

.group-edit-form input,
.group-edit-form select {
  border-radius: 10px;
}

body:not(.theme-dark) .link-info-card,
body:not(.theme-dark) .groups-card {
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(219, 226, 235, 0.9);
  box-shadow: 0 18px 40px rgba(44, 60, 80, 0.06);
}

body:not(.theme-dark) .link-owner-card {
  background: #f6f9fc;
  border: 0;
}

body:not(.theme-dark) .link-owner-card-label {
  background: var(--bg);
}

body:not(.theme-dark) .selected-link-stat {
  background: #f6f9fc;
  border-color: transparent;
}

body:not(.theme-dark) .groups-table-head {
  background: #eef2f6;
  color: #6d7d8f;
}

body:not(.theme-dark) .group-row-item + .group-row-item .group-row-summary {
  border-top: 1px solid rgba(228, 234, 241, 0.95);
}

body:not(.theme-dark) .group-edit-form {
  background: #f6f9fc;
  border-top-color: rgba(223, 231, 239, 0.95);
}

body:not(.theme-dark) .group-row-summary .group-status-badge {
  background: #dff1ea;
  color: #149b80;
}

body:not(.theme-dark) .group-row-summary .group-status-badge.is-inactive {
  background: #edf1f6;
  color: #7d8b9c;
}

.users-workspace > .users-card:last-child {
  padding: 0;
  overflow: hidden;
  border-radius: 14px;
  border-color: transparent;
  box-shadow: none;
}

.users-workspace > .users-card:last-child .section-header {
  padding: 1.15rem 1.15rem 0.8rem;
  margin: 0;
}

.users-table-head,
.user-row-summary {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1.1fr) minmax(140px, 0.8fr) minmax(110px, 0.7fr) 54px;
  align-items: center;
  gap: 1rem;
  padding: 0.95rem 1.15rem;
}

.users-table-head {
  background: #3e4a58;
  color: var(--muted);
  font-weight: 700;
  border-top: 0;
  border-bottom: 0;
}

.users-table-actions {
  text-align: center;
}

.users-list {
  display: block;
}

.user-row-item {
  border-top: 0;
}

.user-row-item:first-child {
  border-top: 0;
}

.user-row-item.is-open {
  background: color-mix(in srgb, var(--panel-alt), var(--panel) 8%);
}

.user-row-summary {
  min-height: 72px;
}

.user-row-cell {
  min-width: 0;
  display: grid;
  gap: 0.22rem;
}

.user-row-label {
  display: none;
}

.user-row-value {
  display: block;
  min-width: 0;
  font-size: 0.98rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-row-cell-status {
  justify-items: start;
}

.user-status-badge {
  min-width: 0;
  min-height: 0;
  padding: 0.18rem 0.55rem;
  border-radius: 6px;
  font-size: 0.82rem;
  line-height: 1.15;
  border-width: 0;
  background: rgba(15, 145, 116, 0.16);
  color: #1fc7a0;
}

.user-row-toggle {
  width: 42px;
  height: 42px;
  padding: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  border: 1px solid transparent;
  font-size: 1.35rem;
  line-height: 1;
  box-shadow: none;
}

.user-row-toggle:hover {
  background: color-mix(in srgb, var(--accent), transparent 88%);
  color: var(--text);
}

.user-row-toggle.is-open {
  background: color-mix(in srgb, var(--accent), transparent 80%);
  color: var(--text);
  border-color: color-mix(in srgb, var(--accent), transparent 62%);
}

.user-edit-form {
  margin: 0;
  padding: 0.65rem 1.15rem 1.15rem;
  border-top: 1px solid color-mix(in srgb, var(--border), transparent 14%);
  border-radius: 0;
  background: color-mix(in srgb, var(--panel-alt), var(--panel) 18%);
}

.user-edit-form .group-grid {
  gap: 0.85rem;
}

.user-edit-form label {
  font-size: 0.9rem;
}

.user-edit-form input,
.user-edit-form select {
  border-radius: 10px;
}

.user-edit-form .checkbox-field {
  align-self: end;
  min-height: 46px;
  padding: 0.2rem 0;
}

.user-edit-form .group-actions {
  margin-top: 0.2rem;
  align-items: center;
}

.user-edit-form .group-stats {
  font-size: 0.88rem;
}

.user-edit-form .button-row {
  gap: 0.65rem;
}

.user-edit-form[hidden] {
  display: none !important;
}

body:not(.theme-dark) .users-workspace > .users-card:last-child {
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(219, 226, 235, 0.9);
  box-shadow: 0 18px 40px rgba(44, 60, 80, 0.06);
}

body:not(.theme-dark) .users-table-head {
  background: #eef2f6;
  color: #6d7d8f;
}

body:not(.theme-dark) .user-row-summary {
  color: #243447;
}

body:not(.theme-dark) .user-row-item + .user-row-item .user-row-summary {
  border-top: 1px solid rgba(228, 234, 241, 0.95);
}

body:not(.theme-dark) .user-row-item.is-open {
  background: #f9fbfd;
}

body:not(.theme-dark) .user-status-badge {
  background: #dff1ea;
  color: #149b80;
}

body:not(.theme-dark) .user-row-toggle {
  color: #718399;
}

body:not(.theme-dark) .user-row-toggle:hover,
body:not(.theme-dark) .user-row-toggle.is-open {
  background: #edf3f7;
  color: #42566d;
  border-color: transparent;
}

body:not(.theme-dark) .user-edit-form {
  background: #f6f9fc;
  border-top-color: rgba(223, 231, 239, 0.95);
}

.user-grid {
  grid-template-columns: 1.5fr 1.3fr 1fr auto;
}

.users-list > .empty-state {
  margin: 1rem 1.15rem 1.15rem;
}

.profile-workspace {
  display: grid;
  gap: 0.95rem;
}

.profile-card {
  position: relative;
  overflow: hidden;
  padding: 1.2rem;
  border-radius: 14px;
  border-color: transparent;
  background: color-mix(in srgb, var(--panel-alt), var(--panel) 16%);
  box-shadow: none;
}

.profile-card::before {
  content: "";
  position: absolute;
  top: 12px;
  bottom: 12px;
  left: 0;
  width: 3px;
  border-radius: 18px 0 0 18px;
  background: #ff5b3d;
}

.profile-card input,
.profile-card select {
  border-radius: 10px;
}

.profile-submit-button {
  justify-self: end;
  min-width: 220px;
  border-radius: 10px;
}

.delete-user-button,
.user-edit-form .danger {
  background: #d84d57;
}

.delete-user-button:hover,
.user-edit-form .danger:hover {
  background: #bb3e47;
}

body:not(.theme-dark) .profile-card {
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(219, 226, 235, 0.9);
  box-shadow: 0 18px 40px rgba(44, 60, 80, 0.06);
}

body:not(.theme-dark) .hero-card {
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(219, 226, 235, 0.9);
  box-shadow: 0 18px 40px rgba(44, 60, 80, 0.06);
}

.button-row {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.button-row button {
  border-radius: 10px;
}

.empty-state,
.empty-dashboard-card {
  padding: 1rem;
  border: 1px dashed var(--border);
  border-radius: 16px;
  color: var(--muted);
  background: var(--bg-soft);
}

.theme-switch {
  position: relative;
  width: 58px;
  height: 30px;
  padding: 0;
  border-radius: 999px;
  background: #8ea0b3;
  box-shadow: 0 6px 18px rgba(10, 20, 30, 0.18);
  flex-shrink: 0;
}

.theme-switch:hover {
  transform: none;
  background: #8396aa;
}

.theme-switch-track {
  position: absolute;
  inset: 0;
  border-radius: 999px;
}

.theme-switch-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #0f2c4a;
  display: grid;
  place-items: center;
  transform: translateX(0);
  transition: transform 0.2s ease;
  overflow: hidden;
}

body.theme-dark .theme-switch-thumb {
  transform: translateX(28px);
}

.theme-icon {
  position: absolute;
  font-size: 14px;
  line-height: 1;
  color: #ffffff;
  transition: opacity 0.2s ease;
}

.theme-icon-sun {
  opacity: 1;
}

.theme-icon-moon {
  opacity: 0;
}

body.theme-dark .theme-icon-sun {
  opacity: 0;
}

body.theme-dark .theme-icon-moon {
  opacity: 1;
}

.auth-page .theme-switch {
  position: fixed;
  top: 1.35rem;
  right: 1.35rem;
  left: auto;
  z-index: 60;
}

@media (max-width: 900px) {
  html,
  body {
    overscroll-behavior-y: contain;
  }

  html {
    font-size: 92%;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    top: 68px;
    left: 0;
    width: min(310px, 82vw);
    height: calc(100dvh - 68px);
    max-height: calc(100dvh - 68px);
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    border-right: 1px solid var(--border);
    border-bottom: 0;
    padding: 1rem;
    padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    z-index: 45;
  }

  .sidebar::before,
  .sidebar::after {
    display: none;
  }

  .sidebar-brand {
    margin-bottom: 1rem;
  }

  .sidebar-section {
    margin-top: 1rem;
  }

  .mobile-menu-button {
    display: block;
  }

  .mobile-refresh-button {
    display: inline-flex;
  }

  .mobile-topbar {
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 68px;
    background: rgba(24, 31, 42, 0.96);
    backdrop-filter: blur(10px);
    z-index: 40;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  }

    .toolbar {
      position: fixed;
      top: 0.62rem;
      right: 0.75rem;
      z-index: 52;
      width: auto;
      flex-direction: row;
      align-items: center;
      justify-content: flex-end;
      flex-wrap: nowrap;
      gap: 0.55rem;
    }

    .toolbar .theme-switch {
      position: relative;
      top: auto;
      right: auto;
      z-index: auto;
    }

    .toolbar .secondary {
      position: relative;
      top: auto;
      right: auto;
      z-index: auto;
      min-width: 54px;
      padding: 0.52rem 0.68rem;
      font-size: 0.9rem;
    }

  .content-area {
    padding-top: 5.45rem;
  }

  body.mobile-menu-open .sidebar {
    transform: translateX(0);
  }

  body.mobile-menu-open .sidebar-overlay {
    display: block;
  }
}

@media (max-width: 760px) {
  .topbar-dashboard,
  .header-brand,
  .home-toolbar,
  .link-toolbar,
  .link-toolbar-actions,
  .users-toolbar,
  .profile-toolbar,
  .selected-link-summary,
  .selected-link-header,
  .group-actions,
  .selected-link-actions,
  .group-item-header,
  .add-group-card-header,
  .add-user-card-header {
    flex-direction: column;
    align-items: stretch;
  }

  .grid-3,
  .group-grid,
  .user-grid,
  .selected-link-insights {
    grid-template-columns: 1fr;
  }

  .groups-table-head {
    display: none;
  }

  .users-table-head {
    display: none;
  }

  .users-list {
    display: grid;
    gap: 0.85rem;
    padding: 0 1rem 1rem;
  }

  .user-row-item {
    border: 1px solid color-mix(in srgb, var(--border), transparent 12%);
    border-radius: 14px;
    background:
      linear-gradient(180deg, color-mix(in srgb, var(--panel-alt), #fff 3%) 0%, color-mix(in srgb, var(--panel-alt), var(--panel) 12%) 100%);
    overflow: hidden;
  }

  .user-row-summary {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "status action"
      "name name"
      "login login"
      "type type";
    gap: 0.55rem 0.8rem;
    padding: 1rem;
    min-height: auto;
    align-items: start;
  }

  .user-row-cell {
    gap: 0.15rem;
  }

  .user-row-cell-name {
    grid-area: name;
  }

  .user-row-cell-login {
    grid-area: login;
  }

  .user-row-cell-type {
    grid-area: type;
  }

  .user-row-cell-status {
    grid-area: status;
    justify-items: start;
  }

  .inline-form {
    flex-direction: column;
  }

  .hero-card .inline-form {
    grid-template-columns: 1fr;
  }

  .inline-form input,
  .inline-form button,
  .selected-link-actions button,
  .selected-link-actions .badge,
  #create-user-form > button[type="submit"],
  .group-form button[type="submit"],
  .profile-submit-button {
    width: 100%;
  }

  .user-row-label {
    display: block;
    color: var(--muted);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
  }

  .user-row-cell-name .user-row-label {
    display: none;
  }

  .user-row-cell-status .user-row-label {
    display: none;
  }

  .user-row-value {
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
  }

  .user-row-cell-name .user-row-value {
    font-size: 1.32rem;
    line-height: 1.2;
  }

  .user-row-cell-login .user-row-value,
  .user-row-cell-type .user-row-value {
    font-size: 0.98rem;
    font-weight: 600;
    color: color-mix(in srgb, var(--text), var(--muted) 18%);
  }

  .user-status-badge {
    min-width: auto;
    justify-self: start;
    align-self: center;
    padding: 0.24rem 0.62rem;
    border-radius: 7px;
    font-size: 0.8rem;
  }

  .user-row-toggle {
    grid-area: action;
    width: 40px;
    height: 40px;
    justify-self: end;
  }

  .groups-list {
    display: grid;
    gap: 0.85rem;
    padding: 0 1rem 1rem;
  }

  .group-row-item {
    border: 1px solid color-mix(in srgb, var(--border), transparent 12%);
    border-radius: 18px;
    background:
      linear-gradient(180deg, color-mix(in srgb, var(--panel-alt), #fff 3%) 0%, color-mix(in srgb, var(--panel-alt), var(--panel) 12%) 100%);
    overflow: hidden;
  }

  .group-row-summary {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "status action"
      "name name"
      "limit limit"
      "order clicks";
    gap: 0.55rem 0.8rem;
    padding: 1rem;
    min-height: auto;
    align-items: start;
  }

  .group-row-cell-name {
    grid-area: name;
  }

  .group-row-cell-limit {
    grid-area: limit;
  }

  .group-row-cell-order {
    grid-area: order;
  }

  .group-row-cell-clicks {
    grid-area: clicks;
  }

  .group-row-cell-status {
    grid-area: status;
  }

  .group-row-label {
    display: block;
    color: var(--muted);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
  }

  .group-row-cell-name .group-row-label,
  .group-row-cell-status .group-row-label {
    display: none;
  }

  .group-row-value {
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
  }

  .group-row-cell-name .group-row-value {
    font-size: 1.2rem;
    line-height: 1.2;
  }

  .group-row-toggle {
    grid-area: action;
    width: 40px;
    height: 40px;
    justify-self: end;
  }

  .group-edit-form {
    padding: 0 1rem 1rem;
    background: transparent;
    border-top: 0;
  }

  .user-edit-form {
    padding: 0 1rem 1rem;
    background: transparent;
    border-top: 0;
  }

  .profile-submit-button {
    justify-self: stretch;
    min-width: 0;
  }

  .hero-card .inline-form input {
    min-height: 52px;
    padding: 0.72rem 0.85rem;
    flex: 0 1 auto;
  }

    .toolbar button:not(.theme-switch) {
      width: auto;
    }

  .sidebar-logo {
    width: 112px;
    height: 112px;
  }

  .sidebar-link {
    padding: 0.75rem 0.85rem;
  }

  .card {
    padding: 1rem;
    border-radius: 18px;
  }

  .button-row button {
    flex: 1 1 auto;
  }

  .content-area {
    padding: 1rem;
    padding-top: 5.55rem;
  }
}

@media (max-width: 480px) {
  .content-area,
  .sidebar {
    padding: 0.85rem;
  }

  .content-area {
    padding-top: 5.45rem;
  }

  .auth-page .theme-switch {
    top: 1rem;
    right: 1rem;
  }

  .header-brand h1 {
    font-size: 1.55rem;
  }

  .header-brand p,
  .hint,
  .eyebrow,
  .sidebar-brand span,
  .sidebar-link-meta {
    font-size: 0.9rem;
  }

  .selected-link-title,
  .hero-card h2,
  .section-header h3 {
    font-size: 1.1rem;
  }

  .group-item {
    padding: 0.85rem;
  }

    .toolbar {
      gap: 0.45rem;
      right: 0.65rem;
    }

  .theme-switch {
    width: 46px;
    height: 26px;
  }

  .toolbar .theme-switch {
    width: 46px;
    min-width: 46px;
  }

  .theme-switch-thumb {
    width: 22px;
    height: 22px;
  }

  body.theme-dark .theme-switch-thumb {
    transform: translateX(20px);
  }

    .toolbar .secondary {
      min-width: 54px;
      padding: 0.52rem 0.65rem;
      font-size: 0.88rem;
    }
}
