/* Treadic CRM — global Django admin polish */

:root {
  --treadic-brand: #1fa6c9;
  --treadic-brand-dark: #163f57;
  --treadic-surface: #f8fafc;
  --treadic-page-bg: #f1f5f9;
  --treadic-border: #dbe7ef;
}

/* Softer dashboard background — cards sit on light gray (light mode only) */
html:not([data-theme="dark"]) body.dashboard {
  background: var(--treadic-page-bg);
}

html:not([data-theme="dark"]) body.dashboard .main > .content {
  background: transparent;
}

/* Consistent dashboard section headings */
.treadic-section-heading {
  margin: 0 0 0.75rem;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--treadic-brand-dark);
}

/* Responsive layout — fit any screen width without horizontal page scroll */
html {
  width: 100%;
  overflow-x: clip;
}

body {
  width: 100%;
  max-width: 100vw;
  overflow-x: clip;
}

#container {
  min-width: 0;
  width: 100%;
  max-width: 100%;
  overflow-x: clip;
}

.main {
  min-width: 0;
  width: 100%;
  max-width: 100%;
  overflow-x: clip;
}

.main > .content {
  min-width: 0;
  width: 100%;
  max-width: 100%;
}

#content {
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
  padding-left: clamp(12px, 2.5vw, 40px);
  padding-right: clamp(12px, 2.5vw, 40px);
}

#content.colM,
#content.colMS,
#content.colSM {
  margin-left: 0;
  margin-right: 0;
}

#content-related {
  display: none;
}

body.dashboard .main > .content,
body.dashboard #content {
  width: 100%;
  max-width: none;
}

#content-main {
  float: none;
  width: 100%;
  clear: both;
}

/* ── Premium admin header (Stripe / Linear aesthetic) ── */
#header {
  flex-wrap: nowrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  max-width: 100%;
  min-height: 52px;
  box-sizing: border-box;
  padding: 0.55rem clamp(12px, 2.5vw, 40px);
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 48%, #0f172a 100%);
  border-bottom: 1px solid rgba(148, 163, 184, 0.14);
  box-shadow:
    0 1px 0 rgba(52, 211, 153, 0.05),
    0 8px 32px rgba(15, 23, 42, 0.35);
  color: #f8fafc;
}

#header a:link,
#header a:visited,
#logout-form button {
  color: rgba(248, 250, 252, 0.88);
}

#header a:hover,
#header a:focus-visible,
#logout-form button:hover,
#logout-form button:focus-visible {
  color: #fff;
  text-decoration: none;
}

#branding {
  flex: 1 1 auto;
  min-width: 0;
  max-width: 100%;
  display: flex;
  align-items: center;
}

#site-name,
.treadic-admin-brand {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.55rem 0.75rem;
  margin: 0 !important;
  padding: 0;
  min-width: 0;
}

.treadic-admin-brand-link {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
  text-decoration: none !important;
  color: inherit !important;
}

.treadic-admin-brand-link:hover,
.treadic-admin-brand-link:focus-visible {
  opacity: 0.92;
}

.treadic-admin-logo-mark {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.28rem;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.85);
  background: #ffffff;
  box-shadow:
    0 1px 2px rgba(15, 23, 42, 0.12),
    0 4px 14px rgba(15, 23, 42, 0.18);
}

.treadic-header-logo {
  width: 1.85rem;
  height: 1.85rem;
  max-width: none;
  display: block;
  flex-shrink: 0;
  object-fit: contain;
}

.treadic-admin-title-stack {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.05rem;
  min-width: 0;
  line-height: 1.1;
}

.treadic-admin-title-primary {
  font-size: 1.22rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: #f8fafc;
  white-space: nowrap;
}

.treadic-admin-title-secondary {
  font-size: 0.58rem;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: rgba(148, 163, 184, 0.92);
  white-space: nowrap;
}

.treadic-admin-brand-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
}

.treadic-site-title-short {
  display: none;
}

@keyframes treadic-qbo-pulse {
  0%,
  100% {
    opacity: 1;
    box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.55);
  }

  50% {
    opacity: 0.82;
    box-shadow: 0 0 0 5px rgba(52, 211, 153, 0);
  }
}

.treadic-qbo-header-status {
  display: inline-flex;
  align-items: center;
  gap: 0.38rem;
  padding: 0.22rem 0.62rem;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.28);
  background: rgba(30, 41, 59, 0.65);
  color: rgba(226, 232, 240, 0.92);
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-decoration: none;
  line-height: 1.2;
  vertical-align: middle;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.treadic-qbo-header-status:hover,
.treadic-qbo-header-status:focus-visible {
  background: rgba(51, 65, 85, 0.75);
  border-color: rgba(148, 163, 184, 0.45);
  color: #fff;
}

.treadic-qbo-header-status--connected {
  background: rgba(16, 185, 129, 0.1);
  border-color: rgba(52, 211, 153, 0.38);
  color: #6ee7b7;
}

.treadic-qbo-header-status--connected:hover,
.treadic-qbo-header-status--connected:focus-visible {
  background: rgba(16, 185, 129, 0.18);
  border-color: rgba(52, 211, 153, 0.55);
  color: #a7f3d0;
}

.treadic-qbo-header-dot {
  width: 0.48rem;
  height: 0.48rem;
  border-radius: 999px;
  background: #fbbf24;
  box-shadow: 0 0 0 2px rgba(251, 191, 36, 0.22);
  flex-shrink: 0;
}

.treadic-qbo-header-status--connected .treadic-qbo-header-dot {
  background: #34d399;
  box-shadow: 0 0 0 2px rgba(52, 211, 153, 0.28);
  animation: treadic-qbo-pulse 2.2s ease-in-out infinite;
}

.treadic-qbo-header-label--long {
  display: none;
}

@media (min-width: 900px) {
  .treadic-qbo-header-label--short {
    display: none;
  }

  .treadic-qbo-header-label--long {
    display: inline;
  }
}

#user-tools {
  flex: 0 0 auto;
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0;
  font-size: 0.78rem;
  text-align: right;
}

.treadic-welcome-msg {
  color: rgba(203, 213, 225, 0.9);
  white-space: nowrap;
}

.treadic-welcome-msg strong {
  color: #f8fafc;
  font-weight: 700;
}

.treadic-logout-btn {
  border: 0;
  background: transparent;
  padding: 0;
  font: inherit;
  cursor: pointer;
  color: rgba(203, 213, 225, 0.88);
}

.treadic-logout-btn:hover,
.treadic-logout-btn:focus-visible {
  color: #fff;
}

.treadic-user-tools-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
}

.treadic-header-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  background: rgba(30, 41, 59, 0.55);
  color: rgba(226, 232, 240, 0.92);
  cursor: pointer;
  list-style: none;
  user-select: none;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.treadic-header-icon-btn:hover,
.treadic-header-icon-btn:focus-visible,
.treadic-header-menu[open] .treadic-header-icon-btn {
  background: rgba(51, 65, 85, 0.8);
  border-color: rgba(148, 163, 184, 0.42);
  color: #fff;
}

.treadic-menu-icon,
.treadic-moon-icon {
  width: 1rem;
  height: 1rem;
  display: block;
}

.treadic-header-menu-tab-label {
  display: none;
}

#header .treadic-theme-btn.theme-toggle {
  border: 1px solid rgba(148, 163, 184, 0.22);
  background: rgba(30, 41, 59, 0.55);
  vertical-align: middle;
}

#header .treadic-theme-btn.theme-toggle:hover,
#header .treadic-theme-btn.theme-toggle:focus-visible {
  background: rgba(51, 65, 85, 0.8);
  border-color: rgba(148, 163, 184, 0.42);
}

#header .treadic-theme-btn .treadic-moon-icon {
  width: 1rem;
  height: 1rem;
  color: rgba(226, 232, 240, 0.92);
  fill: none;
}

#header .treadic-theme-btn:hover .treadic-moon-icon,
#header .treadic-theme-btn:focus-visible .treadic-moon-icon {
  color: #fff;
}

html[data-theme="dark"] #header .treadic-theme-btn .treadic-moon-icon.theme-icon-when-dark {
  fill: currentColor;
  color: #fff;
}

#header .treadic-user-tools-actions .theme-toggle {
  margin: 0;
}

div.breadcrumbs {
  padding-left: clamp(12px, 2.5vw, 40px);
  padding-right: clamp(12px, 2.5vw, 40px);
}

/* Changelists & tables scroll inside their panel, not the page */
#changelist .changelist-form-container {
  min-width: 0;
  max-width: 100%;
}

#changelist .changelist-form-container:has(#changelist-filter) > div {
  min-width: 0;
  max-width: min(100%, calc(100% - 250px));
}

#changelist-form .results,
.inline-group .tabular,
.module table {
  max-width: 100%;
}

#changelist-form .results {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Form fields shrink on narrower desktops */
.form-row input[type="text"],
.form-row input[type="number"],
.form-row input[type="email"],
.form-row input[type="url"],
.form-row input[type="password"],
.form-row input[type="date"],
.form-row input[type="datetime-local"],
.form-row select,
.form-row textarea,
.vTextField,
.vURLField,
.vLargeTextField,
.vIntegerField {
  max-width: 100%;
}

.form-row .related-widget-wrapper {
  max-width: 100%;
  flex-wrap: wrap;
}

.object-tools {
  flex-wrap: wrap;
  max-width: 100%;
}

img,
svg,
video {
  max-width: 100%;
  height: auto;
}

@media (min-width: 1025px) {
  #header {
    flex-wrap: nowrap;
    align-items: center;
  }

  #branding {
    flex: 1 1 auto;
  }

  #user-tools {
    flex: 0 1 auto;
    text-align: right;
  }
}

@media (max-width: 1024px) {
  #header #nav-global {
    display: none;
  }

  #changelist .changelist-form-container {
    flex-direction: column;
  }

  #changelist .changelist-form-container:has(#changelist-filter) > div {
    max-width: 100%;
    width: 100%;
  }

  #changelist-filter {
    width: 100%;
    max-width: 100%;
  }
}

/* Change forms — fieldsets */
fieldset.treadic-fieldset,
.module.treadic-fieldset {
  border-radius: 12px;
  border: 1px solid var(--treadic-border);
  background: var(--body-bg);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  margin-bottom: 1rem;
  overflow: hidden;
}

fieldset.treadic-fieldset h2,
fieldset.treadic-fieldset .fieldset-heading,
fieldset.treadic-qbo-fieldset h2 {
  background: linear-gradient(135deg, #f0fbff 0%, #e8f6fa 100%);
  color: var(--treadic-brand-dark);
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--treadic-border);
}

fieldset.treadic-qbo-fieldset h2 {
  background: linear-gradient(135deg, #ecfdf5 0%, #f0fdf4 100%);
}

fieldset.treadic-fieldset .form-row {
  padding-left: 0.25rem;
  padding-right: 0.25rem;
}

fieldset.treadic-fieldset .description {
  font-size: 0.86rem;
  line-height: 1.45;
  color: var(--body-quiet-color);
}

/* QuickBooks panels */
.treadic-qbo-panel {
  padding: 0.85rem 1rem;
  border-radius: 10px;
  border: 1px solid var(--treadic-border);
  background: var(--treadic-surface);
  max-width: 42rem;
}

.treadic-qbo-panel--disconnected {
  border-color: #fde68a;
  background: #fffbeb;
}

.treadic-qbo-panel--pending {
  border-color: #bae6fd;
  background: #f0f9ff;
}

.treadic-qbo-panel--linked {
  border-color: #bbf7d0;
  background: #f0fdf4;
}

.treadic-qbo-muted {
  color: var(--body-quiet-color);
  margin: 0;
}

.treadic-qbo-error {
  margin: 0.5rem 0 0;
  color: #b91c1c;
  font-size: 0.86rem;
}

.treadic-qbo-link {
  font-weight: 600;
}

.treadic-qbo-dl {
  display: grid;
  gap: 0.45rem;
  margin: 0.65rem 0 0;
}

.treadic-qbo-dl > div {
  display: grid;
  grid-template-columns: 7rem 1fr;
  gap: 0.5rem;
  font-size: 0.88rem;
}

.treadic-qbo-dl dt {
  margin: 0;
  font-weight: 600;
  color: var(--body-quiet-color);
}

.treadic-qbo-dl dd {
  margin: 0;
}

.treadic-qbo-badge,
.treadic-qbo-pill,
.treadic-status-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
}

.treadic-qbo-badge--ok,
.treadic-qbo-pill--ok {
  background: #dcfce7;
  color: #166534;
}

.treadic-qbo-badge--error,
.treadic-qbo-pill--error {
  background: #fee2e2;
  color: #991b1b;
}

.treadic-qbo-pill--pending {
  background: #e0f2fe;
  color: #0c4a6e;
}

.treadic-qbo-pill--muted {
  background: var(--darkened-bg);
  color: var(--body-quiet-color);
}

.treadic-status-pill {
  background: color-mix(in srgb, var(--pill-color) 14%, white);
  color: var(--pill-color);
  border: 1px solid color-mix(in srgb, var(--pill-color) 28%, white);
}

/* Changelists */
#changelist .actions,
#changelist-form .actions {
  border-radius: 10px;
}

#changelist table thead th {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--body-quiet-color);
}

#changelist-filter {
  border-radius: 12px;
  border: 1px solid var(--treadic-border);
  overflow: hidden;
}

#changelist-filter h2 {
  background: linear-gradient(135deg, var(--treadic-brand-dark) 0%, #1e5a78 100%);
  color: #fff;
  font-size: 0.82rem;
  padding: 0.7rem 0.85rem;
}

#changelist-filter h3 {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--treadic-brand-dark);
}

/* Inlines */
.inline-group {
  border-radius: 12px;
  border: 1px solid var(--treadic-border);
  overflow: hidden;
}

.inline-group h2 {
  background: var(--treadic-surface);
  color: var(--treadic-brand-dark);
  font-size: 0.9rem;
}

/* Object tools */
.object-tools a {
  border-radius: 999px;
}

/* Dashboard grouped modules */
.treadic-dash-groups {
  display: grid;
  gap: 1rem;
}

.treadic-dash-group {
  border-radius: 12px;
  border: 1px solid var(--treadic-border);
  overflow: hidden;
  background: var(--body-bg);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.treadic-dash-group-header {
  padding: 0.85rem 1rem;
  background: linear-gradient(135deg, #f8fafc 0%, #f0fbff 100%);
  border-bottom: 1px solid var(--treadic-border);
}

.treadic-dash-group-header h3 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--treadic-brand-dark);
}

.treadic-dash-group-header p {
  margin: 0.2rem 0 0;
  font-size: 0.78rem;
  color: var(--body-quiet-color);
}

.treadic-dash-group-models {
  list-style: none;
  margin: 0;
  padding: 0;
}

.treadic-dash-group-models li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 0.5rem;
  padding: 0.7rem 1rem;
  border-top: 1px solid var(--hairline-color);
}

.treadic-dash-group-models li:first-child {
  border-top: 0;
}

.treadic-dash-group-models .model-name a {
  font-weight: 600;
  font-size: 0.92rem;
}

.treadic-dash-group-models .model-actions a {
  display: inline-flex;
  padding: 0.3rem 0.65rem;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 600;
  background: var(--darkened-bg);
}

.treadic-dash-group-models .model-actions a.addlink {
  background: #e0f2fe;
  color: #0c4a6e;
}

.treadic-dash-action-card--qbo {
  border-color: #86efac;
  background: linear-gradient(135deg, #f0fdf4 0%, #ecfdf5 100%);
}

.treadic-dash-action-card--qbo.treadic-dash-action-card--connected {
  border-color: #22c55e;
}

@media (min-width: 900px) {
  .treadic-dash-groups {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1800px) {
  .treadic-dash-groups {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 899px) {
  .treadic-dash-groups {
    grid-template-columns: 1fr;
  }
}

/* Header menu tab */
.treadic-header-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.85rem;
}

.treadic-branding-stack {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.35rem;
}

#header .treadic-header-menu {
  position: relative;
}

#header .treadic-header-menu--brand {
  display: none;
}

.treadic-header-menu-tab {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.treadic-header-menu-tab::-webkit-details-marker {
  display: none;
}

.treadic-header-menu-panel {
  position: absolute;
  top: calc(100% + 0.45rem);
  right: 0;
  left: auto;
  z-index: 1200;
  width: 15.5rem;
  min-width: 15.5rem;
  max-width: min(15.5rem, calc(100vw - 2rem));
  padding: 0.35rem;
  border-radius: 12px;
  border: 1px solid var(--treadic-border);
  background: var(--body-bg);
  color: var(--body-fg);
  box-shadow: 0 14px 30px rgba(15, 23, 42, 0.18);
}

.treadic-header-menu-prompt {
  margin: 0 0 0.5rem;
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--body-quiet-color);
}

.treadic-header-menu-section-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.35rem;
  width: 100%;
  min-width: 0;
}

.treadic-header-menu-section-list > li {
  display: flex;
  min-height: 4.6rem;
}

.treadic-header-menu-section-link {
  width: 100%;
  height: 100%;
  min-height: 4.6rem;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 0.2rem;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--treadic-border);
  border-radius: 10px;
  background: var(--darkened-bg);
  color: var(--body-fg);
  text-align: left;
  text-decoration: none;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.treadic-header-menu-section-link:hover,
.treadic-header-menu-section-link:focus-visible {
  border-color: #7dd3ea;
  background: #f0f9ff;
  color: var(--body-fg);
}

.treadic-header-menu-section-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--treadic-brand-dark);
  line-height: 1.25;
}

.treadic-header-menu-section-desc {
  flex: 1;
  min-height: 2.1rem;
  font-size: 0.66rem;
  color: var(--body-quiet-color);
  line-height: 1.3;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}

.treadic-header-menu-section-desc:empty {
  visibility: hidden;
}

/* System / Security hub pages */
.treadic-menu-hub {
  display: grid;
  gap: 1rem;
  width: 100%;
  max-width: 100%;
}

.treadic-menu-hub-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.treadic-menu-hub-tab {
  display: inline-flex;
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  border: 1px solid var(--treadic-border);
  background: var(--body-bg);
  color: var(--body-fg);
  font-size: 0.84rem;
  font-weight: 700;
  text-decoration: none;
}

.treadic-menu-hub-tab.is-active,
.treadic-menu-hub-tab:hover,
.treadic-menu-hub-tab:focus-visible {
  border-color: #7dd3ea;
  background: #f0f9ff;
  color: var(--treadic-brand-dark);
}

.treadic-menu-hub-card {
  border-radius: 12px;
  border: 1px solid var(--treadic-border);
  background: var(--body-bg);
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.treadic-menu-hub-table {
  width: 100%;
  border-collapse: collapse;
}

.treadic-menu-hub-table th,
.treadic-menu-hub-table td {
  padding: 0.85rem 1rem;
  border-top: 1px solid var(--hairline-color);
  text-align: left;
  vertical-align: middle;
}

.treadic-menu-hub-table thead th {
  border-top: 0;
  background: var(--darkened-bg);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--body-quiet-color);
}

.treadic-menu-hub-table tbody th {
  font-size: 0.95rem;
  font-weight: 600;
}

.treadic-menu-hub-action {
  display: inline-flex;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
  text-decoration: none;
}

.treadic-menu-hub-action--view {
  background: #ecfeff;
  color: #155e75;
}

.treadic-menu-hub-action--add {
  background: #e0f2fe;
  color: #0c4a6e;
}

.treadic-menu-hub-action:hover,
.treadic-menu-hub-action:focus-visible {
  filter: brightness(0.96);
}

.treadic-menu-hub-muted {
  color: var(--body-quiet-color);
}

/* User tools — Menu + settings row */
.treadic-user-links-main {
  display: inline-flex;
  align-items: center;
  gap: 0.15rem;
}

.treadic-user-links-extra a {
  color: rgba(203, 213, 225, 0.78);
  font-size: 0.74rem;
}

.treadic-user-links-extra a:hover,
.treadic-user-links-extra a:focus-visible {
  color: #fff;
}

@media (max-width: 1024px) {
  #header {
    padding: 0.45rem 14px;
    gap: 0.45rem;
    min-height: 48px;
  }

  .treadic-admin-title-primary {
    font-size: 1.05rem;
  }

  .treadic-header-logo {
    width: 1.85rem;
    height: 1.85rem;
  }

  .treadic-welcome-msg,
  .treadic-user-links-extra {
    display: none !important;
  }

  #header #user-tools {
    flex: 0 0 auto;
    gap: 0.3rem;
  }
}

@media (max-width: 767px) {
  #header {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    justify-content: space-between !important;
    padding: 0.35rem 10px !important;
    gap: 0.35rem !important;
    min-height: 44px !important;
  }

  #branding {
    flex: 1 1 auto;
    min-width: 0;
    max-width: calc(100% - 8.5rem);
  }

  #site-name,
  .treadic-admin-brand {
    gap: 0.35rem 0.45rem;
  }

  .treadic-admin-brand-link {
    gap: 0.45rem;
    min-width: 0;
  }

  .treadic-admin-title-secondary {
    font-size: 0.5rem;
    letter-spacing: 0.16em;
  }

  .treadic-admin-title-primary {
    font-size: 0.95rem;
  }

  .treadic-header-logo {
    width: 1.65rem;
    height: 1.65rem;
  }

  #user-tools {
    flex: 0 0 auto;
    width: auto !important;
    gap: 0.28rem !important;
    font-size: 0.62rem;
  }

  .treadic-user-links-main {
    display: inline-flex !important;
    align-items: center;
    flex: 0 0 auto;
  }

  #logout-form {
    margin: 0;
  }

  #logout-form .treadic-logout-btn {
    padding: 0.18rem 0.42rem;
    border-radius: 8px;
    border: 1px solid rgba(148, 163, 184, 0.28);
    background: rgba(30, 41, 59, 0.55);
    font-size: 0.58rem;
    font-weight: 700;
    line-height: 1.2;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: rgba(226, 232, 240, 0.92);
  }

  .treadic-header-icon-btn {
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 8px;
  }

  .treadic-menu-icon,
  .treadic-moon-icon {
    width: 0.9rem;
    height: 0.9rem;
  }

  .treadic-qbo-header-status {
    padding: 0.14rem 0.38rem;
    font-size: 0.56rem;
    flex-shrink: 0;
  }

  .treadic-qbo-header-dot {
    width: 0.4rem;
    height: 0.4rem;
  }

  .treadic-message-bell {
    padding: 2px 7px;
    font-size: 10px;
    flex-shrink: 0;
  }

  .treadic-message-bell-count {
    min-width: 16px;
    height: 16px;
    font-size: 10px;
    padding: 0 4px;
  }

  #header .treadic-header-menu-panel {
    max-width: calc(100vw - 1.25rem);
    right: 0;
  }
}

/* Admin login + MFA step (password first, then authenticator) */
body.login.treadic-admin-login #header {
  padding: 1rem 1.25rem;
}

body.login.treadic-admin-login #content {
  padding: 2rem 1rem 3rem;
}

.treadic-login-shell {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-height: 50vh;
}

.treadic-login-card {
  width: min(100%, 26rem);
  padding: 1.5rem 1.6rem 1.35rem;
  border-radius: 14px;
  border: 1px solid #c9e8f2;
  background: linear-gradient(135deg, #f8fdff 0%, #eef8fc 55%, #ffffff 100%);
  box-shadow: 0 18px 40px rgba(15, 45, 66, 0.08);
}

.treadic-login-card--wide {
  width: min(100%, 30rem);
}

.treadic-login-brand {
  display: flex;
  gap: 0.9rem;
  align-items: center;
  margin-bottom: 1.25rem;
}

.treadic-login-logo {
  flex-shrink: 0;
}

.treadic-login-eyebrow {
  margin: 0 0 0.2rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #1fa6c9;
}

.treadic-login-brand-text h1 {
  margin: 0;
  font-size: 1.35rem;
  line-height: 1.2;
  color: #163f57;
}

.treadic-login-subtitle {
  margin: 0.45rem 0 0;
  color: #475569;
  line-height: 1.45;
  font-size: 0.92rem;
}

.treadic-login-form .form-row {
  margin-bottom: 0.9rem;
}

.treadic-login-form label {
  display: block;
  margin-bottom: 0.35rem;
  font-weight: 600;
  color: #163f57;
}

.treadic-login-form input[type="text"],
.treadic-login-form input[type="password"] {
  width: 100%;
  box-sizing: border-box;
  padding: 0.65rem 0.75rem;
  border-radius: 8px;
  border: 1px solid #b8d9e8;
  font-size: 1rem;
}

.treadic-login-form .submit-row {
  margin-top: 1rem;
  padding: 0;
}

.treadic-login-form .submit-row input[type="submit"] {
  width: 100%;
  padding: 0.7rem 1rem;
  border: 0;
  border-radius: 8px;
  background: linear-gradient(135deg, #1fa6c9 0%, #1688a8 100%);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}

.treadic-login-footnote {
  margin: 0.85rem 0 0;
  font-size: 0.82rem;
  color: #64748b;
  line-height: 1.45;
}

.treadic-mfa-qr-wrap {
  display: flex;
  justify-content: center;
  margin: 0.5rem 0 0.75rem;
  padding: 0.75rem;
  border-radius: 10px;
  background: #fff;
}

.treadic-mfa-qr {
  width: 12rem;
  height: 12rem;
}

.treadic-mfa-secret {
  margin: 0 0 1rem;
  font-size: 0.82rem;
  color: #475569;
  word-break: break-all;
  text-align: center;
}

html[data-theme="dark"] .treadic-login-card {
  border-color: #334155;
  background: linear-gradient(135deg, #0f172a 0%, #111827 55%, #0b1220 100%);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
}

html[data-theme="dark"] .treadic-login-brand-text h1,
html[data-theme="dark"] .treadic-login-form label {
  color: #e2e8f0;
}

html[data-theme="dark"] .treadic-login-subtitle,
html[data-theme="dark"] .treadic-mfa-secret,
html[data-theme="dark"] .treadic-login-footnote {
  color: #94a3b8;
}

