
/* v29: strict contrast and robust responsive layout. Loaded last. */

/* ---- strict color tokens ---- */
html[data-theme="light"] {
  --as-bg: #f7fbff;
  --as-surface: #ffffff;
  --as-surface-2: #f2f7fd;
  --as-text: #061427;
  --as-muted: #334155;
  --as-soft: #475569;
  --as-line: rgba(15, 23, 42, .12);
  --as-blue: #115fca;
  --as-cyan: #0f8fba;
  --as-on-dark: #ffffff;
}

html[data-theme="dark"] {
  --as-bg: #020814;
  --as-surface: #071225;
  --as-surface-2: #0b1728;
  --as-text: #f8fbff;
  --as-muted: #c7d4e8;
  --as-soft: #9fb0c8;
  --as-line: rgba(180, 210, 255, .18);
  --as-blue: #67ddff;
  --as-cyan: #67ddff;
  --as-on-dark: #ffffff;
}

/* Global contrast safety net. */
html[data-theme="light"] body,
html[data-theme="light"] main,
html[data-theme="light"] section,
html[data-theme="light"] article,
html[data-theme="light"] aside,
html[data-theme="light"] header,
html[data-theme="light"] footer,
html[data-theme="light"] .dashboard-page,
html[data-theme="light"] .dashboard-main,
html[data-theme="light"] .dashboard-card,
html[data-theme="light"] .card,
html[data-theme="light"] .product-card,
html[data-theme="light"] .team-card-v18,
html[data-theme="light"] .auth-card,
html[data-theme="light"] .auth-context-card {
  color: var(--as-text) !important;
}

html[data-theme="light"] :where(h1,h2,h3,h4,h5,h6,strong,b,label,legend,th,td,li,span,p,small,em,a) {
  text-shadow: none !important;
}

html[data-theme="light"] :where(h1,h2,h3,h4,h5,h6,strong,b,label,legend,th,td,li) {
  color: var(--as-text) !important;
}

html[data-theme="light"] :where(p,small,em,.hero-lead,.page-hero p,.card p,.section p,.dashboard-section-title p) {
  color: var(--as-muted) !important;
}

html[data-theme="light"] :where(.eyebrow,.section-kicker,.mini-note) {
  color: var(--as-blue) !important;
}

html[data-theme="dark"] :where(h1,h2,h3,h4,h5,h6,strong,b,label,legend,th,td,li) {
  color: var(--as-text) !important;
}

html[data-theme="dark"] :where(p,small,em,.hero-lead,.page-hero p,.card p,.section p,.dashboard-section-title p) {
  color: var(--as-muted) !important;
}

html[data-theme="dark"] :where(.eyebrow,.section-kicker,.mini-note) {
  color: var(--as-cyan) !important;
}

/* Buttons are explicit exceptions: high contrast on their own backgrounds. */
.button-primary,
.nav-cta,
html[data-theme="light"] .button-primary,
html[data-theme="light"] .nav-cta,
html[data-theme="dark"] .button-primary,
html[data-theme="dark"] .nav-cta {
  color: #ffffff !important;
  background: linear-gradient(135deg, #2563eb, #7c3aed) !important;
}

.button-secondary,
html[data-theme="light"] .button-secondary {
  color: #061427 !important;
  background: #ffffff !important;
  border-color: rgba(15,23,42,.18) !important;
}

html[data-theme="dark"] .button-secondary {
  color: #f8fbff !important;
  background: rgba(255,255,255,.07) !important;
  border-color: rgba(180,210,255,.22) !important;
}

html[data-theme="light"] .button-danger {
  background: #eef2f7 !important;
  color: #263449 !important;
  border-color: #cbd5e1 !important;
}

html[data-theme="dark"] .button-danger {
  background: #334155 !important;
  color: #ffffff !important;
  border-color: #475569 !important;
}

/* Brand / logo text: never white on white. */
html[data-theme="light"] .brand-copy strong,
html[data-theme="light"] .brand-copy small,
html[data-theme="light"] .brand-dashboard .brand-copy strong,
html[data-theme="light"] .brand-dashboard .brand-copy small,
html[data-theme="light"] .auth-brand span strong,
html[data-theme="light"] .auth-brand span small {
  color: #061427 !important;
}

html[data-theme="dark"] .brand-copy strong,
html[data-theme="dark"] .brand-copy small,
html[data-theme="dark"] .auth-brand span strong,
html[data-theme="dark"] .auth-brand span small {
  color: #f8fbff !important;
}

html[data-theme="light"] .brand-dashboard,
html[data-theme="light"] .footer-brand {
  background: #ffffff !important;
  border: 1px solid rgba(15,23,42,.10) !important;
}

/* Light mobile menu: white panel, dark text. */
html[data-theme="light"] .menu-button-v24,
html[data-theme="light"] .dashboard-menu-button-v28 {
  background: #ffffff !important;
  color: #061427 !important;
  border-color: rgba(15,23,42,.14) !important;
}

html[data-theme="dark"] .menu-button-v24,
html[data-theme="dark"] .dashboard-menu-button-v28 {
  background: rgba(255,255,255,.07) !important;
  color: #ffffff !important;
  border-color: rgba(180,210,255,.22) !important;
}

html[data-theme="light"] .site-nav-v24 {
  background: rgba(255,255,255,.98) !important;
  border-color: rgba(15,23,42,.12) !important;
  box-shadow: 0 28px 90px rgba(15,23,42,.16) !important;
}

html[data-theme="light"] .site-nav-v24 > a,
html[data-theme="light"] .site-nav-v24 .nav-cta:not(.button-primary) {
  color: #061427 !important;
  background: #f7fbff !important;
  border-color: rgba(15,23,42,.09) !important;
}

html[data-theme="light"] .site-nav-v24 .nav-cta {
  color: #ffffff !important;
}

/* Dashboard sidebar: readable in both themes. */
html[data-theme="light"] .dashboard-page .sidebar {
  background: #ffffff !important;
  color: #061427 !important;
  border-color: rgba(15,23,42,.12) !important;
}

html[data-theme="light"] .dashboard-page .sidebar-nav a,
html[data-theme="light"] .dashboard-page .logout-form button {
  color: #061427 !important;
  background: #f5f9ff !important;
  border-color: rgba(15,23,42,.12) !important;
}

html[data-theme="dark"] .dashboard-page .sidebar-nav a,
html[data-theme="dark"] .dashboard-page .logout-form button {
  color: #f8fbff !important;
}

/* Status / alerts: readable. */
html[data-theme="light"] .dashboard-alert,
html[data-theme="light"] .dashboard-alert-success,
html[data-theme="light"] .dashboard-alert-warning,
html[data-theme="light"] .dashboard-alert-error {
  color: #061427 !important;
  background: #eef9ff !important;
  border-color: rgba(14, 165, 233, .28) !important;
}

html[data-theme="dark"] .dashboard-alert,
html[data-theme="dark"] .dashboard-alert-success,
html[data-theme="dark"] .dashboard-alert-warning,
html[data-theme="dark"] .dashboard-alert-error {
  color: #f8fbff !important;
}

/* ---- spacing: stop cramped sections ---- */
main > .section,
.section {
  margin-top: clamp(88px, 9vw, 144px) !important;
}

.dashboard-card,
.user-management-card-v29,
.admin-form-card-v29 {
  margin-bottom: 34px !important;
}

.section-head-v29,
.dashboard-section-title,
.admin-list-head-v25,
.admin-list-head-v26 {
  margin-bottom: 30px !important;
}

.eyebrow {
  margin-bottom: 14px !important;
}

.ecosystem,
.ecosystem-v18 {
  margin-top: clamp(96px, 10vw, 150px) !important;
  padding-top: clamp(70px, 8vw, 96px) !important;
  border-top: 1px solid var(--as-line) !important;
}

.ecosystem::before,
.ecosystem-v18::before {
  top: -1px !important;
}

/* ---- title scale: sober, no huge billboard typography ---- */
.hero h1,
.hero-premium h1 {
  font-size: clamp(1.75rem, 2.6vw, 2.95rem) !important;
  line-height: 1.12 !important;
  letter-spacing: -0.03em !important;
  max-width: 18ch !important;
}

.page-hero h1,
.dashboard-topbar h1 {
  font-size: clamp(1.55rem, 2vw, 2.25rem) !important;
  line-height: 1.12 !important;
  letter-spacing: -0.025em !important;
}

.auth-card h1,
.auth-context-card h2 {
  font-size: clamp(1.45rem, 2vw, 2.1rem) !important;
  line-height: 1.14 !important;
}

.section h2 {
  font-size: clamp(1.35rem, 1.65vw, 1.95rem) !important;
  line-height: 1.18 !important;
}

.hero-lead,
.page-hero p,
.auth-card p {
  font-size: .96rem !important;
  line-height: 1.76 !important;
}

/* ---- user management rewritten: no table, no crushed columns ---- */
.user-management-card-v29,
.admin-form-card-v29 {
  padding: clamp(22px, 3vw, 34px) !important;
  border-radius: 16px !important;
  background: var(--as-surface) !important;
  border: 1px solid var(--as-line) !important;
}

.users-team-section-v29 {
  background: linear-gradient(180deg, rgba(17,95,202,.06), var(--as-surface)) !important;
}

.users-orion-section-v29 {
  background: linear-gradient(180deg, rgba(15,143,186,.06), var(--as-surface)) !important;
}

.user-list-v29 {
  display: grid !important;
  gap: 10px !important;
}

.user-list-head-v29,
.user-row-v29 {
  display: grid !important;
  align-items: center !important;
  gap: 16px !important;
}

.user-list-team-v29 .user-list-head-v29,
.user-list-team-v29 .user-row-v29 {
  grid-template-columns:
    minmax(180px, 1.4fr)
    minmax(170px, 1.15fr)
    minmax(170px, 1.15fr)
    minmax(82px, .55fr)
    minmax(130px, .75fr)
    minmax(160px, .85fr) !important;
}

.user-list-orion-v29 .user-list-head-v29,
.user-list-orion-v29 .user-row-v29 {
  grid-template-columns:
    minmax(180px, 1.45fr)
    minmax(180px, 1.35fr)
    minmax(130px, .8fr)
    minmax(160px, .85fr) !important;
}

.user-list-head-v29 {
  padding: 0 16px 10px !important;
  color: var(--as-soft) !important;
  font-size: .68rem !important;
  line-height: 1.2 !important;
  font-weight: 900 !important;
  letter-spacing: .11em !important;
  text-transform: uppercase !important;
  border-bottom: 1px solid var(--as-line) !important;
}

.user-row-v29 {
  padding: 16px !important;
  border: 1px solid rgba(148,163,184,.14) !important;
  border-radius: 14px !important;
  background: color-mix(in srgb, var(--as-surface) 92%, var(--as-surface-2)) !important;
}

html[data-theme="light"] .user-row-v29 {
  background: #ffffff !important;
}

html[data-theme="dark"] .user-row-v29 {
  background: #081526 !important;
}

.user-row-v29:hover {
  border-color: rgba(17,95,202,.32) !important;
  box-shadow: 0 16px 46px rgba(15, 23, 42, .08) !important;
}

.user-field-v29 {
  min-width: 0 !important;
  overflow-wrap: anywhere !important;
  color: var(--as-text) !important;
  line-height: 1.45 !important;
  font-size: .9rem !important;
}

.user-identity-v29 {
  display: flex !important;
  align-items: center !important;
  gap: 12px !important;
  min-width: 0 !important;
}

.user-identity-v29 strong,
.user-identity-v29 small {
  display: block !important;
  min-width: 0 !important;
}

.user-identity-v29 strong {
  color: var(--as-text) !important;
  font-size: .93rem !important;
  line-height: 1.25 !important;
}

.user-identity-v29 small {
  color: var(--as-soft) !important;
  font-size: .76rem !important;
  margin-top: 2px !important;
}

.user-avatar-v29 {
  width: 32px !important;
  height: 32px !important;
  min-width: 32px !important;
  border-radius: 8px !important;
  display: grid !important;
  place-items: center !important;
  color: #ffffff !important;
  background: linear-gradient(135deg, #2563eb, #7c3aed) !important;
  font-weight: 900 !important;
  font-size: .78rem !important;
}

.status-pill-v29 {
  display: inline-flex !important;
  align-items: center !important;
  padding: 5px 9px !important;
  border-radius: 8px !important;
  color: #115fca !important;
  background: #eaf5ff !important;
  border: 1px solid rgba(17,95,202,.18) !important;
  font-size: .78rem !important;
  font-weight: 850 !important;
}

html[data-theme="dark"] .status-pill-v29 {
  color: #67ddff !important;
  background: rgba(103,221,255,.10) !important;
  border-color: rgba(103,221,255,.24) !important;
}

.user-actions-v29 {
  display: flex !important;
  flex-wrap: wrap !important;
  gap: 8px !important;
  align-items: center !important;
}

.user-actions-v29 form {
  margin: 0 !important;
}

.user-actions-v29 .button,
.user-actions-v29 button {
  min-height: 32px !important;
  padding: 0 11px !important;
  border-radius: 9px !important;
  font-size: .82rem !important;
}

.admin-user-form-v29 {
  display: grid !important;
  grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  gap: 16px !important;
}

.admin-user-form-v29 label {
  display: grid !important;
  gap: 7px !important;
  color: var(--as-text) !important;
}

.admin-user-form-v29 input,
.admin-user-form-v29 select {
  width: 100% !important;
  min-height: 42px !important;
  border-radius: 9px !important;
  padding: 0 12px !important;
  color: var(--as-text) !important;
  background: var(--as-surface) !important;
  border: 1px solid var(--as-line) !important;
}

.permission-fieldset-v29 {
  grid-column: 1 / -1 !important;
  border: 1px solid var(--as-line) !important;
  border-radius: 12px !important;
  padding: 14px !important;
  display: flex !important;
  flex-wrap: wrap !important;
  gap: 12px 18px !important;
}

.permission-fieldset-v29 label {
  display: flex !important;
  align-items: center !important;
  gap: 8px !important;
}

/* Responsive user cards: values use the whole card width. */
@media (max-width: 1100px) {
  .user-list-head-v29 {
    display: none !important;
  }

  .user-list-team-v29 .user-row-v29,
  .user-list-orion-v29 .user-row-v29,
  .user-row-v29 {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 0 !important;
    padding: 18px !important;
  }

  .user-field-v29 {
    display: block !important;
    width: 100% !important;
    padding: 12px 0 !important;
    border-top: 1px solid rgba(148,163,184,.14) !important;
  }

  .user-field-v29:first-child {
    border-top: 0 !important;
    padding-top: 0 !important;
  }

  .user-field-v29::before {
    content: attr(data-label) !important;
    display: block !important;
    margin-bottom: 7px !important;
    color: var(--as-blue) !important;
    font-size: .68rem !important;
    line-height: 1.25 !important;
    letter-spacing: .10em !important;
    text-transform: uppercase !important;
    font-weight: 900 !important;
  }

  html[data-theme="dark"] .user-field-v29::before {
    color: #67ddff !important;
  }

  .user-actions-v29 .button,
  .user-actions-v29 button {
    width: auto !important;
  }

  .admin-user-form-v29 {
    grid-template-columns: 1fr !important;
  }
}

/* Dashboard off-canvas sidebar: clean and readable. */
@media (max-width: 980px) {
  .dashboard-page .sidebar {
    background: var(--as-surface) !important;
    color: var(--as-text) !important;
  }

  .dashboard-page.dashboard-menu-open::before {
    background: rgba(2, 6, 14, .48) !important;
    backdrop-filter: blur(5px) !important;
  }
}

/* Final mobile title scale. */
@media (max-width: 760px) {
  .hero h1,
  .hero-premium h1 {
    font-size: clamp(1.85rem, 9.5vw, 2.65rem) !important;
    max-width: 15ch !important;
  }

  .page-hero h1,
  .dashboard-topbar h1 {
    font-size: clamp(1.45rem, 7vw, 2rem) !important;
  }

  .user-management-card-v29,
  .admin-form-card-v29 {
    padding: 18px !important;
  }

  .section-head-v29 {
    margin-bottom: 24px !important;
  }
}

/* Explicitly disable old table/card mobile rules if any old markup remains. */
.users-table-v25 td::before,
.users-table-v26 td::before {
  background: transparent !important;
}
