/**
 * Admin Panel — custom UI stylesheet
 * Replace variables and tokens below to white-label / resell.
 */

:root {
  --font-sans: "Plus Jakarta Sans", system-ui, -apple-system, sans-serif;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 4px 20px rgba(15, 23, 42, 0.07);
  --shadow-lg: 0 16px 48px rgba(15, 23, 42, 0.1);
  --ring: 0 0 0 3px rgba(79, 70, 229, 0.22);

  --bg-page: #eef1f6;
  --bg-elevated: #ffffff;
  --text-primary: #0f172a;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;

  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: rgba(79, 70, 229, 0.1);
  --accent-text-on: #ffffff;

  --sidebar-bg: #ffffff;
  --sidebar-border: #e8ecf2;
  --sidebar-text: #475569;
  --sidebar-hover: #f1f5f9;

  --danger: #dc2626;
  --danger-soft: rgba(220, 38, 38, 0.08);
  --success: #059669;
  --success-soft: rgba(5, 150, 105, 0.1);
  --warning: #d97706;
  --warning-soft: rgba(217, 119, 6, 0.12);

  --topbar-bg: rgba(255, 255, 255, 0.92);
  --overlay: rgba(15, 23, 42, 0.45);

  /* Depth shadows (buttons & cards); disabled via html.admin-no-depth */
  --depth-btn: 0 2px 8px rgba(15, 23, 42, 0.14), 0 1px 3px rgba(15, 23, 42, 0.08);
  --depth-btn-hover: 0 4px 16px rgba(15, 23, 42, 0.18), 0 2px 6px rgba(15, 23, 42, 0.1);
  --depth-btn-ghost: 0 1px 4px rgba(15, 23, 42, 0.07), 0 1px 2px rgba(15, 23, 42, 0.04);
  --depth-card-sm: 0 6px 24px rgba(15, 23, 42, 0.09), 0 2px 8px rgba(15, 23, 42, 0.05);
  --depth-card-md: 0 10px 36px rgba(15, 23, 42, 0.11), 0 4px 12px rgba(15, 23, 42, 0.06);
  --depth-card-lg: 0 20px 50px rgba(15, 23, 42, 0.13), 0 10px 28px rgba(15, 23, 42, 0.08);
}

html.dark {
  --bg-page: #080b10;
  --bg-elevated: #12181f;
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --border: #1e293b;
  --border-strong: #334155;

  --accent: #6366f1;
  --accent-hover: #818cf8;
  --accent-soft: rgba(99, 102, 241, 0.15);

  --sidebar-bg: #0d1117;
  --sidebar-border: #1e293b;
  --sidebar-text: #94a3b8;
  --sidebar-hover: #1e293b;

  --danger-soft: rgba(248, 113, 113, 0.12);
  --success-soft: rgba(52, 211, 153, 0.12);
  --warning-soft: rgba(251, 191, 36, 0.12);

  --topbar-bg: rgba(18, 24, 31, 0.92);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 4px 24px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.45);
  --ring: 0 0 0 3px rgba(129, 140, 248, 0.25);

  --depth-btn: 0 2px 12px rgba(0, 0, 0, 0.45), 0 2px 6px rgba(0, 0, 0, 0.32);
  --depth-btn-hover: 0 4px 20px rgba(0, 0, 0, 0.5), 0 2px 10px rgba(0, 0, 0, 0.35);
  --depth-btn-ghost: 0 1px 6px rgba(0, 0, 0, 0.32), 0 1px 2px rgba(0, 0, 0, 0.22);
  --depth-card-sm: 0 8px 32px rgba(0, 0, 0, 0.32), 0 2px 10px rgba(0, 0, 0, 0.2);
  --depth-card-md: 0 12px 40px rgba(0, 0, 0, 0.38), 0 4px 14px rgba(0, 0, 0, 0.24);
  --depth-card-lg: 0 24px 56px rgba(0, 0, 0, 0.48), 0 12px 32px rgba(0, 0, 0, 0.32);
}

html.admin-no-depth {
  --depth-btn: 0 0 #0000;
  --depth-btn-hover: 0 0 #0000;
  --depth-btn-ghost: 0 0 #0000;
  --depth-card-sm: 0 0 #0000;
  --depth-card-md: 0 0 #0000;
  --depth-card-lg: 0 0 #0000;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  height: 100%;
}

body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  background: var(--bg-page);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
}

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

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.hidden {
  display: none !important;
}

/* ----- Layout shell ----- */
.shell {
  display: flex;
  min-height: 100vh;
}

.shell-main {
  display: flex;
  min-width: 0;
  flex: 1;
  flex-direction: column;
}

.page-inner {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 1rem 1.25rem;
}

@media (min-width: 640px) {
  .page-inner {
    padding: 1.5rem 1.5rem;
  }
}

@media (min-width: 1024px) {
  .page-inner {
    padding: 2rem 2rem;
  }
}

.page-inner--wide {
  max-width: 1280px;
}

.page-inner--narrow {
  max-width: 42rem;
}

.page-title {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.page-desc {
  margin: 0.35rem 0 0;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.breadcrumb-nav {
  margin-bottom: 1rem;
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.breadcrumb-nav a {
  font-weight: 600;
  color: var(--accent);
}

.breadcrumb-nav a:hover {
  color: var(--accent-hover);
}

.breadcrumb-nav__sep {
  margin: 0 0.35rem;
  opacity: 0.6;
}

.tables-index-grid {
  display: grid;
  gap: 1.25rem;
}

@media (min-width: 640px) {
  .tables-index-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.tables-index-card {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  text-decoration: none;
  color: inherit;
  transition: box-shadow 0.2s, border-color 0.15s;
}

.tables-index-card:hover {
  border-color: var(--accent-soft);
}

.tables-index-card .link-arrow {
  margin-top: 0.5rem;
  color: var(--accent);
}

.card__head--split {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.card__foot--split {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

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

.table-toolbar__details {
  position: relative;
}

.table-toolbar__details summary {
  list-style: none;
  cursor: pointer;
}

.table-toolbar__details summary::-webkit-details-marker {
  display: none;
}

.table-toolbar__popover {
  position: absolute;
  z-index: 45;
  top: calc(100% + 0.35rem);
  right: 0;
  min-width: 12rem;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  box-shadow: var(--shadow-lg);
}

.table-toolbar__check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0;
  font-size: 0.8125rem;
  color: var(--text-primary);
  cursor: pointer;
}

.table-toolbar__check input {
  width: 1rem;
  height: 1rem;
  accent-color: var(--accent);
}

.table-pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
}

.table-pager--inline {
  justify-content: flex-end;
  margin: 0;
}

.table-pager__meta {
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.table-pager__link.is-disabled {
  opacity: 0.45;
  pointer-events: none;
  cursor: not-allowed;
}

/* ----- Sidebar overlay ----- */
.sidebar-overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: var(--overlay);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.sidebar-overlay.is-visible {
  opacity: 1;
  pointer-events: auto;
}

@media (min-width: 1024px) {
  .sidebar-overlay {
    display: none;
  }
}

/* ----- Sidebar ----- */
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 50;
  display: flex;
  width: 16rem;
  flex-direction: column;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  transform: translateX(-100%);
  transition: transform 0.2s ease;
}

.sidebar.is-open {
  transform: translateX(0);
}

@media (min-width: 1024px) {
  .sidebar {
    position: static;
    transform: none;
  }
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  height: 4rem;
  padding: 0 1rem;
  border-bottom: 1px solid var(--sidebar-border);
}

.sidebar-brand__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--accent-text-on);
  box-shadow: var(--shadow-sm);
}

.sidebar-brand__icon svg {
  width: 1.25rem;
  height: 1.25rem;
}

.sidebar-brand__text {
  min-width: 0;
}

.sidebar-brand__name {
  margin: 0;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-brand__tag {
  margin: 0;
  font-size: 0.6875rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-nav {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.75rem;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--sidebar-text);
  transition: background 0.15s, color 0.15s;
}

.sidebar-link:hover {
  background: var(--sidebar-hover);
  color: var(--text-primary);
}

.sidebar-link svg {
  width: 1.25rem;
  height: 1.25rem;
  flex-shrink: 0;
  opacity: 0.9;
}

.sidebar-link.is-active {
  background: var(--accent);
  color: var(--accent-text-on);
  box-shadow: var(--shadow-sm);
}

.sidebar-link.is-active:hover {
  background: var(--accent-hover);
  color: var(--accent-text-on);
}

.sidebar-foot {
  padding: 0.75rem;
  border-top: 1px solid var(--sidebar-border);
}

.sidebar-logout {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--danger);
  transition: background 0.15s;
}

.sidebar-logout:hover {
  background: var(--danger-soft);
}

.sidebar-logout svg {
  width: 1.25rem;
  height: 1.25rem;
}

/* ----- Top bar ----- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  height: 4rem;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--topbar-bg);
  backdrop-filter: blur(10px);
}

@media (min-width: 1024px) {
  .topbar {
    padding: 0 1.5rem;
  }
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.topbar-menu-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
  box-shadow: var(--depth-btn-ghost);
}

.topbar-menu-btn:hover {
  background: var(--sidebar-hover);
}

@media (min-width: 1024px) {
  .topbar-menu-btn {
    display: none;
  }
}

.topbar-menu-btn svg {
  width: 1.25rem;
  height: 1.25rem;
}

.topbar-welcome {
  display: none;
}

@media (min-width: 640px) {
  .topbar-welcome {
    display: block;
  }
}

.topbar-welcome__label {
  margin: 0;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.topbar-welcome__name {
  margin: 0;
  font-size: 0.875rem;
  font-weight: 600;
}

.topbar-right {
  display: flex;
  flex: 1;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
}

@media (min-width: 640px) {
  .topbar-right {
    gap: 0.75rem;
  }
}

.topbar-search-wrap {
  position: relative;
  display: none;
  max-width: 20rem;
  flex: 1;
}

@media (min-width: 768px) {
  .topbar-search-wrap {
    display: block;
  }
}

.topbar-search-wrap svg {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  width: 1rem;
  height: 1rem;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.topbar-search {
  width: 100%;
  padding: 0.5rem 0.75rem 0.5rem 2.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  background: var(--bg-page);
  color: var(--text-primary);
}

.topbar-search:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--ring);
  background: var(--bg-elevated);
}

.topbar-search::placeholder {
  color: var(--text-muted);
}

.topbar-search:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
  box-shadow: var(--depth-btn-ghost);
}

.icon-btn:hover {
  background: var(--sidebar-hover);
}

html.dark .icon-btn--theme {
  color: #fcd34d;
}

.icon-btn svg {
  width: 1.25rem;
  height: 1.25rem;
}

html.dark #icon-sun {
  display: block;
}
html.dark #icon-moon {
  display: none;
}
#icon-sun {
  display: none;
}
#icon-moon {
  display: block;
}

/* Language switcher */
.lang-switch {
  display: flex;
  align-items: center;
  gap: 0.125rem;
  padding: 0.125rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-page);
}

.lang-switch a {
  padding: 0.35rem 0.5rem;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-decoration: none;
}

.lang-switch a:hover {
  color: var(--text-primary);
  background: var(--sidebar-hover);
}

.lang-switch a.is-active {
  background: var(--accent-soft);
  color: var(--accent);
}

/* User menu */
.user-menu {
  position: relative;
}

.user-menu-trigger {
  display: flex;
  align-items: center;
  gap: 0.125rem;
  padding: 0.125rem 0.125rem 0.125rem 0.125rem;
  border: none;
  border-radius: 9999px;
  background: transparent;
  cursor: pointer;
  transition: background 0.15s;
}

.user-menu-trigger:hover {
  background: var(--sidebar-hover);
}

.user-menu-trigger:focus-visible {
  outline: none;
  box-shadow: var(--ring);
  border-radius: 9999px;
}

.user-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 9999px;
  font-size: 0.875rem;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(135deg, var(--accent) 0%, #7c3aed 100%);
  box-shadow: var(--shadow-sm);
}

.user-menu-trigger__chev {
  display: none;
  width: 1rem;
  height: 1rem;
  color: var(--text-muted);
}

@media (min-width: 640px) {
  .user-menu-trigger__chev {
    display: block;
  }
}

.user-dropdown {
  position: absolute;
  right: 0;
  top: 100%;
  z-index: 50;
  margin-top: 0.5rem;
  width: 14rem;
  padding: 0.25rem 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-elevated);
  box-shadow: var(--shadow-lg);
}

.user-dropdown__head {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
}

.user-dropdown__head p {
  margin: 0;
}

.user-dropdown__label {
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--text-muted);
}

.user-dropdown__email {
  margin-top: 0.25rem !important;
  font-size: 0.875rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-dropdown a {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 1rem;
  font-size: 0.875rem;
  color: var(--text-primary);
  transition: background 0.12s;
}

.user-dropdown a:hover {
  background: var(--sidebar-hover);
  color: var(--text-primary);
}

.user-dropdown a svg {
  width: 1.25rem;
  height: 1.25rem;
  flex-shrink: 0;
  color: var(--text-muted);
}

.user-dropdown__sep {
  height: 1px;
  margin: 0.25rem 0;
  background: var(--border);
  border: 0;
}

.user-dropdown a.is-danger {
  font-weight: 600;
  color: var(--danger);
}

.user-dropdown a.is-danger:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

/* ----- Buttons ----- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 1rem;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn--primary {
  background: var(--accent);
  color: var(--accent-text-on);
  box-shadow: var(--depth-btn);
  transition: background 0.15s, opacity 0.15s, box-shadow 0.15s;
}

.btn--primary:hover:not(:disabled) {
  background: var(--accent-hover);
  box-shadow: var(--depth-btn-hover);
}

.btn--outline {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.5rem 0.875rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
  background: var(--bg-elevated);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
  box-shadow: var(--depth-btn-ghost);
}

.btn--outline:hover:not(:disabled) {
  background: var(--sidebar-hover);
}

.btn--outline:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn--block {
  width: 100%;
}

/* ----- Cards & panels ----- */
.card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-elevated);
  box-shadow: var(--depth-card-sm);
  transition: box-shadow 0.2s;
}

.card--padded {
  padding: 1.25rem;
}

.card__head {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.card__title {
  margin: 0;
  font-size: 0.875rem;
  font-weight: 600;
}

.card__sub {
  margin: 0.2rem 0 0;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.card__foot {
  padding: 0.75rem 1.25rem;
  border-top: 1px solid var(--border);
}

.card__block {
  padding: 1.25rem;
}

.table-pager--footer {
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

/* ----- Stat cards ----- */
.stat-grid {
  display: grid;
  gap: 1rem;
  margin-top: 2rem;
  grid-template-columns: 1fr;
}

@media (min-width: 640px) {
  .stat-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1024px) {
  .stat-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (min-width: 1280px) {
  .stat-grid {
    grid-template-columns: repeat(6, 1fr);
  }
}

.stat-card {
  position: relative;
  overflow: hidden;
  padding: 1.25rem;
  border-radius: var(--radius-lg);
  color: #fff;
  box-shadow: var(--depth-card-md);
  border: 1px solid rgba(255, 255, 255, 0.12);
  transition: box-shadow 0.2s;
}

.stat-card__glow {
  pointer-events: none;
  position: absolute;
  right: -1.5rem;
  top: -1.5rem;
  width: 7rem;
  height: 7rem;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  filter: blur(24px);
}

.stat-card__label {
  position: relative;
  margin: 0;
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  opacity: 0.92;
}

.stat-card__value {
  position: relative;
  margin: 0.5rem 0 0;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

@media (min-width: 1280px) {
  .stat-card__value {
    font-size: 1.75rem;
  }
}

.stat-card__hint {
  position: relative;
  margin: 0.35rem 0 0;
  font-size: 0.75rem;
  opacity: 0.88;
}

.stat-card--emerald {
  background: linear-gradient(135deg, #10b981 0%, #0d9488 100%);
}
.stat-card--amber {
  background: linear-gradient(135deg, #f59e0b 0%, #ea580c 100%);
}
.stat-card--brand {
  background: linear-gradient(135deg, #6366f1 0%, #7c3aed 100%);
}
.stat-card--magenta {
  background: linear-gradient(135deg, #d946ef 0%, #db2777 100%);
}
.stat-card--sky {
  background: linear-gradient(135deg, #0ea5e9 0%, #2563eb 100%);
}
.stat-card--rose {
  background: linear-gradient(135deg, #f43f5e 0%, #dc2626 100%);
}

/* ----- Tip cards ----- */
.tip-grid {
  display: grid;
  gap: 1.5rem;
  margin-top: 2rem;
}

@media (min-width: 768px) {
  .tip-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1280px) {
  .tip-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.tip-card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-elevated);
  box-shadow: var(--depth-card-sm);
  transition: box-shadow 0.2s;
}

.tip-card:hover {
  box-shadow: var(--depth-card-md);
}

.tip-card__art {
  position: relative;
  display: flex;
  height: 10rem;
  align-items: center;
  justify-content: center;
  padding: 0 1.5rem;
}

.tip-card__art--indigo {
  background: linear-gradient(145deg, #e0e7ff 0%, #ede9fe 45%, #ffffff 100%);
}
html.dark .tip-card__art--indigo {
  background: linear-gradient(145deg, #1e1b4b 0%, #312e81 40%, #12181f 100%);
}

.tip-card__art--emerald {
  background: linear-gradient(145deg, #d1fae5 0%, #ccfbf1 45%, #ffffff 100%);
}
html.dark .tip-card__art--emerald {
  background: linear-gradient(145deg, #064e3b 0%, #134e4a 40%, #12181f 100%);
}

.tip-card__art--amber {
  background: linear-gradient(145deg, #fef3c7 0%, #ffedd5 45%, #ffffff 100%);
}
html.dark .tip-card__art--amber {
  background: linear-gradient(145deg, #78350f 0%, #9a3412 40%, #12181f 100%);
}

.tip-pattern {
  position: absolute;
  inset: 0;
  opacity: 0.35;
}

.tip-pattern-svg {
  display: block;
  width: 100%;
  height: 100%;
}

html.dark .tip-pattern {
  opacity: 0.2;
}

.tip-pattern-dot {
  fill: rgba(100, 116, 139, 0.35);
}

html.dark .tip-pattern-dot {
  fill: rgba(255, 255, 255, 0.08);
}

.tip-card__svg-wrap {
  position: relative;
  height: 7rem;
  width: 100%;
  max-width: 200px;
}

.tip-card__svg-wrap svg {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.06));
}

.tip-card__body {
  display: flex;
  flex: 1;
  flex-direction: column;
  padding: 1.25rem;
}

.tip-card__row {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}

.tip-card__icon {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: var(--radius-sm);
}

.tip-card__icon--indigo {
  background: var(--accent-soft);
  color: var(--accent);
}
.tip-card__icon--emerald {
  background: var(--success-soft);
  color: var(--success);
}
.tip-card__icon--amber {
  background: var(--warning-soft);
  color: var(--warning);
}

.tip-card__icon svg {
  width: 1.5rem;
  height: 1.5rem;
}

.tip-card__meta {
  min-width: 0;
}

.tip-card__tag {
  margin: 0;
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.tip-card__tag--indigo {
  color: var(--accent);
}
.tip-card__tag--emerald {
  color: var(--success);
}
.tip-card__tag--amber {
  color: var(--warning);
}

.tip-card__title {
  margin: 0.2rem 0 0;
  font-size: 1rem;
  font-weight: 600;
}

.tip-card__text {
  margin: 0.75rem 0 0;
  font-size: 0.875rem;
  line-height: 1.55;
  color: var(--text-secondary);
}

/* SVG strokes in tips (chart illustration) */
.tip-stroke-line {
  stroke: var(--border-strong);
}
html.dark .tip-stroke-line {
  stroke: #475569;
}

.tip-stroke-ring {
  stroke: var(--success);
}
.tip-stroke-accent {
  stroke: #059669;
}
html.dark .tip-stroke-accent {
  stroke: #34d399;
}

.tip-rect-glass {
  fill: rgba(255, 255, 255, 0.6);
  stroke: #cbd5e1;
  stroke-width: 2;
}
html.dark .tip-rect-glass {
  fill: rgba(30, 41, 59, 0.6);
  stroke: #475569;
}

/* ----- Dashboard grid ----- */
.dash-grid {
  display: grid;
  gap: 1.5rem;
  margin-top: 2rem;
}

@media (min-width: 1024px) {
  .dash-grid--12 {
    grid-template-columns: repeat(12, 1fr);
  }

  .dash-grid__filler {
    display: block;
    visibility: hidden;
  }

  .dash-span-8 {
    grid-column: span 8;
  }
  .dash-span-4 {
    grid-column: span 4;
  }
  .dash-span-5 {
    grid-column: span 5;
  }
  .dash-span-3 {
    grid-column: span 3;
  }
  .dash-span-12 {
    grid-column: span 12;
  }
}

.dash-span-8 {
  grid-column: span 1;
}

.dash-span-4 {
  grid-column: span 1;
}

.dash-span-5 {
  grid-column: span 1;
}

.dash-span-3 {
  grid-column: span 1;
}

.dash-span-12 {
  grid-column: span 1;
}

.dash-grid__filler {
  display: none;
  min-height: 0;
  pointer-events: none;
}

/* ----- Dashboard drag-and-drop (unified grid) ----- */
.dashboard-dnd-root {
  display: grid;
  gap: 1rem;
  margin-top: 2rem;
  grid-template-columns: 1fr;
}

.dashboard-dnd-item {
  position: relative;
  min-width: 0;
}

.dashboard-dnd-handle {
  position: absolute;
  z-index: 12;
  top: 0.5rem;
  inset-inline-end: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.2rem 0.35rem;
  margin: 0;
  border: none;
  border-radius: 0.375rem;
  cursor: grab;
  color: var(--text-muted);
  background: var(--bg-elevated);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
  transition: color 0.15s, background 0.15s;
}

html.dark .dashboard-dnd-handle {
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

.dashboard-dnd-handle:hover {
  color: var(--text-primary);
  background: var(--sidebar-hover);
}

.dashboard-dnd-handle:active {
  cursor: grabbing;
}

.dashboard-dnd-handle__icon {
  display: block;
}

.dashboard-dnd-item--stat .dashboard-dnd-handle {
  color: rgba(255, 255, 255, 0.92);
  background: rgba(0, 0, 0, 0.18);
  box-shadow: none;
}

.dashboard-dnd-item--stat .dashboard-dnd-handle:hover {
  color: #fff;
  background: rgba(0, 0, 0, 0.28);
}

.dashboard-dnd-ghost {
  opacity: 0.5;
}

.dashboard-dnd-chosen {
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.35);
  border-radius: var(--radius-lg);
}

.dashboard-dnd-dragging {
  opacity: 1;
}

@media (min-width: 640px) {
  .dashboard-dnd-root {
    grid-template-columns: repeat(12, 1fr);
  }

  .dashboard-dnd-item--stat {
    grid-column: span 6;
  }

  .dashboard-dnd-item--tip,
  .dashboard-dnd-item--lg8,
  .dashboard-dnd-item--lg4,
  .dashboard-dnd-item--lg5,
  .dashboard-dnd-item--lg7,
  .dashboard-dnd-item--full {
    grid-column: span 12;
  }
}

@media (min-width: 768px) {
  .dashboard-dnd-item--tip {
    grid-column: span 6;
  }
}

@media (min-width: 1024px) {
  .dashboard-dnd-root {
    gap: 1.5rem;
  }

  .dashboard-dnd-item--stat {
    grid-column: span 4;
  }

  .dashboard-dnd-item--lg8 {
    grid-column: span 8;
  }

  .dashboard-dnd-item--lg4 {
    grid-column: span 4;
  }

  .dashboard-dnd-item--lg5 {
    grid-column: span 5;
  }

  .dashboard-dnd-item--lg7 {
    grid-column: span 7;
  }

  .dashboard-dnd-item--full {
    grid-column: span 12;
  }
}

@media (min-width: 1280px) {
  .dashboard-dnd-item--stat {
    grid-column: span 2;
  }

  .dashboard-dnd-item--tip {
    grid-column: span 4;
  }
}

.chart-box {
  position: relative;
  margin-top: 1rem;
  height: 18rem;
  min-height: 16rem;
}

.chart-box--sm {
  height: 16rem;
}

.chart-box--donut {
  margin-top: 0.5rem;
  height: 14rem;
  max-width: 240px;
  margin-left: auto;
  margin-right: auto;
}

.dash-card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.pill {
  display: inline-block;
  padding: 0.25rem 0.625rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--accent-soft);
  color: var(--accent);
}

/* Chat */
.chat-panel {
  display: flex;
  max-height: 320px;
  flex: 1;
  flex-direction: column;
}

.chat-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.25rem;
}

.chat-msg {
  display: flex;
  margin-bottom: 0.75rem;
}

.chat-msg--out {
  justify-content: flex-end;
}

.chat-bubble--out {
  max-width: 85%;
  padding: 0.625rem 0.875rem;
  border-radius: var(--radius-lg);
  border-bottom-right-radius: 6px;
  background: var(--accent);
  color: #fff;
  font-size: 0.875rem;
  box-shadow: var(--shadow-sm);
}

.chat-bubble--out .chat-time {
  margin: 0.35rem 0 0;
  text-align: right;
  font-size: 0.625rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.75);
}

.chat-bubble--in {
  max-width: 85%;
  padding: 0.625rem 0.875rem;
  border-radius: var(--radius-lg);
  border-bottom-left-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-page);
  color: var(--text-primary);
  font-size: 0.875rem;
}

.chat-bubble--in .chat-name {
  margin: 0;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
}

.chat-bubble--in .chat-time {
  margin: 0.35rem 0 0;
  font-size: 0.625rem;
  color: var(--text-muted);
}

.chat-input-row {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem;
  border-top: 1px solid var(--border);
}

.chat-input-row .input {
  flex: 1;
  min-width: 0;
}

/* ----- Forms ----- */
.form-stack {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
}

.input,
.select {
  width: 100%;
  padding: 0.625rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.875rem;
  background: var(--bg-elevated);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

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

.check-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.875rem;
  color: var(--text-primary);
}

.check-row input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  accent-color: var(--accent);
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  padding-top: 1.5rem;
  margin-top: 0;
  border-top: 1px solid var(--border);
}

.form-section {
  margin-bottom: 2rem;
}

.form-section h2 {
  margin: 0 0 1rem;
  font-size: 0.875rem;
  font-weight: 600;
}

.form-section-stack {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* ----- Tables ----- */
.basic-table-wrap {
  overflow-x: auto;
}

.basic-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.basic-table caption {
  caption-side: top;
  padding: 0 0 0.75rem;
  text-align: start;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.basic-table th,
.basic-table td {
  padding: 0.625rem 0.875rem;
  border: 1px solid var(--border);
  text-align: start;
  vertical-align: top;
}

.basic-table thead th {
  background: var(--bg-page);
  font-weight: 600;
  color: var(--text-primary);
}

html.dark .basic-table thead th {
  background: rgba(30, 41, 59, 0.4);
}

.basic-table tbody tr:nth-child(even) {
  background: var(--bg-page);
}

html.dark .basic-table tbody tr:nth-child(even) {
  background: rgba(15, 23, 42, 0.35);
}

.basic-table tfoot td {
  font-size: 0.8125rem;
  color: var(--text-muted);
  background: var(--bg-elevated);
}

.basic-table th.is-col-hidden,
.basic-table td.is-col-hidden,
.data-table th.is-col-hidden,
.data-table td.is-col-hidden {
  display: none;
}

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

.data-table {
  width: 100%;
  min-width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.data-table thead {
  background: var(--bg-page);
}

html.dark .data-table thead {
  background: rgba(30, 41, 59, 0.35);
}

.data-table th {
  padding: 0.75rem 1.25rem;
  text-align: left;
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

.data-table td {
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.data-table tbody tr:hover {
  background: var(--sidebar-hover);
}

.data-table .cell-strong {
  font-weight: 600;
}

.data-table .cell-accent {
  font-weight: 600;
  color: var(--accent);
}

.cell-progress {
  min-width: 8.5rem;
  max-width: 12rem;
}

.row-progress {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.row-progress__track {
  flex: 1;
  min-width: 3.5rem;
  height: 0.45rem;
  border-radius: 9999px;
  background: var(--bg-page);
  overflow: hidden;
}

html.dark .row-progress__track {
  background: rgba(51, 65, 85, 0.55);
}

.row-progress__fill {
  height: 100%;
  max-width: 100%;
  border-radius: inherit;
  transition: width 0.25s ease;
}

.row-progress__fill--success {
  background: linear-gradient(90deg, #059669 0%, #10b981 100%);
}

.row-progress__fill--warning {
  background: linear-gradient(90deg, #d97706 0%, #f59e0b 100%);
}

.row-progress__fill--muted {
  background: linear-gradient(90deg, #94a3b8 0%, #cbd5e1 100%);
}

.row-progress__value {
  flex-shrink: 0;
  min-width: 2.35rem;
  font-size: 0.75rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
}

html.dark .row-progress__value {
  color: var(--text-muted);
}

.data-table--compact td {
  padding: 1rem 1.25rem;
}

.cell-numeric {
  white-space: nowrap;
}

.data-table .cell-end,
.basic-table .cell-end {
  text-align: end;
}

.muted-inline {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.badge {
  display: inline-flex;
  padding: 0.125rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
}

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

html.dark .badge--success {
  color: #6ee7b7;
}

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

html.dark .badge--warning {
  color: #fcd34d;
}

.badge--neutral {
  background: var(--bg-page);
  color: var(--text-secondary);
}

html.dark .badge--neutral {
  background: #334155;
  color: #e2e8f0;
}

.badge--muted {
  background: var(--bg-page);
  color: var(--text-secondary);
}

/* ----- Page header row ----- */
.page-head-row {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  align-items: stretch;
}

@media (min-width: 640px) {
  .page-head-row {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
}

/* ----- Alerts ----- */
.alert {
  margin-top: 1.5rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  border: 1px solid var(--border);
}

.alert--error {
  background: var(--danger-soft);
  border-color: rgba(220, 38, 38, 0.25);
  color: #991b1b;
}

html.dark .alert--error {
  color: #fecaca;
}

.alert--success {
  background: var(--success-soft);
  border-color: rgba(5, 150, 105, 0.25);
  color: #065f46;
}

html.dark .alert--success {
  color: #a7f3d0;
}

/* ----- Login page ----- */
.login-page {
  display: flex;
  min-height: 100vh;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  position: relative;
}

.login-bg {
  pointer-events: none;
  position: fixed;
  inset: 0;
  overflow: hidden;
}

.login-bg__blob {
  position: absolute;
  width: 24rem;
  height: 24rem;
  border-radius: 50%;
  filter: blur(48px);
  opacity: 0.35;
}

.login-bg__blob--1 {
  left: -8rem;
  top: -8rem;
  background: #818cf8;
}

html.dark .login-bg__blob--1 {
  opacity: 0.2;
  background: #4f46e5;
}

.login-bg__blob--2 {
  right: -8rem;
  bottom: -8rem;
  background: #a78bfa;
}

html.dark .login-bg__blob--2 {
  opacity: 0.15;
  background: #7c3aed;
}

.login-wrap {
  position: relative;
  width: 100%;
  max-width: 28rem;
}

.login-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

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

.login-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.login-brand__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  box-shadow: var(--depth-btn);
}

.login-brand__icon svg {
  width: 1.5rem;
  height: 1.5rem;
}

.login-brand__name {
  font-size: 1.125rem;
  font-weight: 600;
}

.login-card {
  padding: 2rem;
  border-radius: var(--radius-xl);
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--depth-card-lg);
  backdrop-filter: blur(12px);
  transition: box-shadow 0.2s;
}

html.dark .login-card {
  background: rgba(18, 24, 31, 0.92);
}

.login-card h1 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
}

.login-card > p {
  margin: 0.35rem 0 0;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.login-demo {
  margin-top: 1.5rem;
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.login-demo code {
  padding: 0.125rem 0.375rem;
  border-radius: 4px;
  font-family: ui-monospace, monospace;
  font-size: 0.6875rem;
  background: var(--bg-page);
  color: var(--text-primary);
}

/* Profile card */
.profile-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 2rem;
  padding: 1.5rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  box-shadow: var(--depth-card-sm);
  transition: box-shadow 0.2s;
}

.profile-avatar-lg {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 4rem;
  height: 4rem;
  border-radius: 9999px;
  font-size: 1.5rem;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, var(--accent) 0%, #7c3aed 100%);
  box-shadow: var(--shadow-md);
}

.profile-card .profile-name {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 600;
}

.profile-card .profile-role {
  margin: 0.25rem 0 0;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.muted-note {
  margin-top: 1.5rem;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

/* ----- Visual settings drawer (opposite sidebar) ----- */
.ui-prefs-overlay {
  position: fixed;
  inset: 0;
  z-index: 55;
  background: var(--overlay);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.ui-prefs-overlay.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.ui-prefs-panel {
  position: fixed;
  top: 0;
  bottom: 0;
  z-index: 56;
  display: flex;
  width: min(19rem, calc(100vw - 1.25rem));
  flex-direction: column;
  padding-top: max(0.75rem, env(safe-area-inset-top));
  padding-bottom: max(0.75rem, env(safe-area-inset-bottom));
  border-inline-start: 1px solid var(--sidebar-border);
  background: var(--sidebar-bg);
  box-shadow: var(--shadow-lg);
  transform: translateX(100%);
  transition: transform 0.25s ease;
  inset-inline-end: 0;
  inset-inline-start: auto;
}

.ui-prefs-panel.is-open {
  transform: translateX(0);
}

html[dir="rtl"] .ui-prefs-panel {
  transform: translateX(-100%);
}

html[dir="rtl"] .ui-prefs-panel.is-open {
  transform: translateX(0);
}

.ui-prefs-panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0 1rem 1rem;
  border-bottom: 1px solid var(--sidebar-border);
}

.ui-prefs-panel__title {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.ui-prefs-panel__close {
  flex-shrink: 0;
}

.ui-prefs-panel__body {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
}

.ui-prefs-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.ui-prefs-row__label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.4;
}

.ui-prefs-hint {
  margin: 0.75rem 0 0;
  font-size: 0.75rem;
  line-height: 1.45;
  color: var(--text-muted);
}

.ui-prefs-switch {
  position: relative;
  display: inline-flex;
  flex-shrink: 0;
  width: 2.75rem;
  height: 1.5rem;
  cursor: pointer;
}

.ui-prefs-switch input {
  position: absolute;
  margin: 0;
  opacity: 0;
  width: 0;
  height: 0;
}

.ui-prefs-switch__track {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 9999px;
  background: var(--border-strong);
  transition: background 0.15s ease;
}

.ui-prefs-switch__track::after {
  content: "";
  position: absolute;
  top: 2px;
  inset-inline-start: 2px;
  width: 1.125rem;
  height: 1.125rem;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--shadow-sm);
  transition: inset-inline-start 0.15s ease;
}

html.dark .ui-prefs-switch__track::after {
  background: var(--bg-elevated);
}

.ui-prefs-switch input:focus-visible + .ui-prefs-switch__track {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.ui-prefs-switch input:checked + .ui-prefs-switch__track {
  background: var(--accent);
}

.ui-prefs-switch input:checked + .ui-prefs-switch__track::after {
  inset-inline-start: calc(100% - 1.125rem - 2px);
}

/* ----- User profile ----- */
.profile-table-link {
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
}

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

.profile-table-link--subtle {
  font-weight: 600;
  font-size: 0.8125rem;
}

.cell-fit {
  width: 1%;
  white-space: nowrap;
}

.profile-hero {
  position: relative;
  overflow: hidden;
  margin-top: 0.5rem;
  padding: 0;
  border: 1px solid var(--border);
}

.profile-hero__banner {
  height: 7rem;
  background: linear-gradient(120deg, #6366f1 0%, #8b5cf6 45%, #a855f7 100%);
}

html.dark .profile-hero__banner {
  background: linear-gradient(120deg, #4338ca 0%, #6d28d9 50%, #7c3aed 100%);
}

.profile-hero__body {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 1.25rem;
  padding: 0 1.5rem 1.5rem;
  margin-top: -3.5rem;
}

.profile-hero__avatar-wrap {
  flex-shrink: 0;
  padding: 4px;
  border-radius: 50%;
  background: var(--bg-elevated);
  box-shadow: var(--shadow-md);
}

.profile-hero__avatar {
  display: block;
  width: 7.5rem;
  height: 7.5rem;
  border-radius: 50%;
  object-fit: cover;
}

.profile-hero__main {
  flex: 1 1 12rem;
  min-width: 0;
  padding-top: 3.75rem;
}

@media (min-width: 640px) {
  .profile-hero__main {
    padding-top: 0.25rem;
  }
}

.profile-hero__title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
}

.profile-hero__name {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.profile-hero__title {
  margin: 0.35rem 0 0;
  font-size: 0.9375rem;
  color: var(--text-secondary);
}

.profile-hero__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  margin: 0.85rem 0 0;
  padding: 0;
  list-style: none;
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.profile-hero__meta li {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.profile-hero__meta-icon {
  width: 1.125rem;
  height: 1.125rem;
  flex-shrink: 0;
  opacity: 0.85;
}

.profile-hero__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  width: 100%;
}

@media (min-width: 640px) {
  .profile-hero__actions {
    width: auto;
    margin-inline-start: auto;
    justify-content: flex-end;
  }
}

.profile-stats {
  display: grid;
  gap: 1rem;
  margin-top: 1.25rem;
  grid-template-columns: 1fr;
}

@media (min-width: 640px) {
  .profile-stats {
    grid-template-columns: repeat(3, 1fr);
  }
}

.profile-stat__value {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.profile-stat__label {
  margin: 0.25rem 0 0;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.profile-layout {
  display: grid;
  gap: 1.25rem;
  margin-top: 1.25rem;
}

@media (min-width: 1024px) {
  .profile-layout {
    grid-template-columns: 1fr min(22rem, 34%);
    align-items: start;
  }
}

.profile-section__title {
  margin: 0 0 0.75rem;
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
}

.profile-section__text {
  margin: 0;
  font-size: 0.9375rem;
  line-height: 1.65;
  color: var(--text-secondary);
}

.profile-skills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.profile-skill-pill {
  display: inline-block;
  padding: 0.35rem 0.75rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-primary);
  background: var(--accent-soft);
  border-radius: 999px;
  border: 1px solid var(--border);
}

.profile-dl {
  margin: 0;
}

.profile-dl > div {
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--border);
}

.profile-dl > div:first-child {
  padding-top: 0;
}

.profile-dl > div:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.profile-dl dt {
  margin: 0;
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.profile-dl dd {
  margin: 0.25rem 0 0;
  font-size: 0.875rem;
  color: var(--text-primary);
}

.profile-dl a {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}

.profile-dl a:hover {
  text-decoration: underline;
  color: var(--accent-hover);
}

.profile-timeline {
  margin: 0;
  padding: 0;
  list-style: none;
}

.profile-timeline__item {
  position: relative;
  padding-inline-start: 1.35rem;
  padding-bottom: 1.25rem;
}

.profile-timeline__item:last-child {
  padding-bottom: 0;
}

.profile-timeline__item::before {
  content: "";
  position: absolute;
  top: 0.35rem;
  bottom: -0.25rem;
  inset-inline-start: 0.3rem;
  width: 2px;
  background: var(--border);
}

.profile-timeline__item:last-child::before {
  display: none;
}

.profile-timeline__dot {
  position: absolute;
  top: 0.2rem;
  inset-inline-start: 0;
  width: 0.65rem;
  height: 0.65rem;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.profile-timeline__date {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
}

.profile-timeline__text {
  margin: 0.25rem 0 0;
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--text-secondary);
}

/* Law firm UI */
.lf-filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.lf-filter-pill {
  display: inline-block;
  padding: 0.35rem 0.85rem;
  font-size: 0.8125rem;
  font-weight: 600;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  text-decoration: none;
}

.lf-filter-pill:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.lf-filter-pill.is-active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

.lf-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.5rem;
}

.lf-tab {
  padding: 0.5rem 0.85rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: var(--radius-sm);
}

.lf-tab:hover {
  color: var(--accent);
  background: var(--accent-soft);
}

.lf-tab.is-active {
  color: var(--accent);
  background: var(--accent-soft);
}

.lf-case-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.lf-form-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: 1fr;
}

@media (min-width: 640px) {
  .lf-form-grid {
    grid-template-columns: repeat(2, 1fr);
  }

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

.lf-stack-form {
  margin-bottom: 1.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.lf-search-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.lf-search-bar .input {
  flex: 1 1 12rem;
  min-width: 0;
}

.lf-result-list {
  margin: 0;
  padding-inline-start: 1.25rem;
}

.lf-result-list li {
  margin: 0.35rem 0;
}

.lf-mini-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.lf-mini-list__item {
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}

.lf-mini-list__item:last-child {
  border-bottom: none;
}

.lf-mini-list__time {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
}

.lf-mini-list__title {
  margin: 0.25rem 0 0;
  font-weight: 600;
  color: var(--text-primary);
}

.lf-mini-list__sub {
  margin: 0.15rem 0 0;
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.lf-mini-list__empty {
  padding: 1rem 0;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.lf-doc-list {
  margin: 1rem 0 0;
  padding-inline-start: 1.25rem;
}

.lf-doc-list li {
  margin: 0.35rem 0;
}

.lf-inline-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}

.lf-prose {
  line-height: 1.65;
}

.btn--sm {
  padding: 0.35rem 0.65rem;
  font-size: 0.8125rem;
}

.input--sm {
  padding: 0.35rem 0.5rem;
  font-size: 0.8125rem;
  max-width: 12rem;
}

.dash-grid.mt-8 {
  margin-top: 2rem;
}

/* Utility */
.mt-8 {
  margin-top: 2rem;
}
.link-arrow {
  font-size: 0.75rem;
  font-weight: 600;
}

/* Hide product column on very small screens */
@media (max-width: 639px) {
  .hide-xs {
    display: none;
  }
}
