/**
 * Client SaaS overlay — chrome/lists/tokens come from /portal/portal.css.
 * Keep only client auth modes + Profile/billing/admin extras here.
 */

/* Mode switch (portal.css uses portal-*; we use client-*) */
html.client-guest #login-view { display: flex !important; }
html.client-boot #boot-view { display: flex !important; }

html.client-app,
html.client-app body {
  height: 100%;
  overflow: hidden;
}

html.client-app #shell {
  display: flex !important;
  flex-direction: column;
  height: 100vh;
  max-height: 100vh;
  overflow: hidden;
}

/* Alias client spinner → portal spinner tokens already in portal.css */
.client-spinner {
  width: var(--portal-spinner-size);
  height: var(--portal-spinner-size);
  border: var(--portal-spinner-border) solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: portal-spin 0.75s linear infinite;
}

.client-loading-text {
  margin: 0;
  color: var(--muted);
  font-size: var(--fs-body);
  line-height: 1.35;
}

/* ── .btn = portal primary button for <a>/<button> in /app and /admin ── */
a.btn,
button.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--control-height);
  padding: 0 16px;
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  font-family: inherit;
  font-weight: 600;
  font-size: var(--fs-btn);
  line-height: 1.25;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}

a.btn:hover,
button.btn:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: #fff;
}

a.btn:active,
button.btn:active:not(:disabled) {
  background: var(--accent-active);
}

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

a.btn:focus-visible,
button.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

a.btn.ghost,
button.btn.ghost {
  background: transparent;
  color: var(--muted);
  border-color: transparent;
  font-weight: 500;
  padding: 0 12px;
}

a.btn.ghost:hover,
button.btn.ghost:hover:not(:disabled) {
  border-color: var(--border);
  background: var(--surface-hover);
  color: var(--text);
}

button.btn.danger {
  background: var(--surface);
  color: var(--danger);
  border-color: var(--danger-border);
}

button.btn.danger:hover:not(:disabled) {
  background: var(--danger-bg);
  border-color: var(--danger);
  color: var(--danger-hover);
}

#google-btn,
#admin-google-btn {
  width: 100%;
  margin-top: 20px;
  min-height: var(--control-height-lg);
  font-size: var(--fs-base);
}

/* Flash toasts (client-only) */
.flash-bar {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 80;
  margin: 0;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-md);
  font-size: var(--fs-md);
  font-weight: 500;
  line-height: 1.4;
  max-width: min(92vw, 480px);
}

.flash-bar.error { border-color: var(--danger-border); background: var(--danger-bg); color: var(--danger); }
.flash-bar.ok { border-color: var(--success-border); background: var(--success-bg); color: var(--success); }

/* Profile title = name · email */
.profile-user-title {
  color: var(--text);
  font-weight: 700;
  overflow-wrap: anywhere;
}

/* Carriers title row: Carriers 1  [+ Add carrier] */
.carriers-title-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.home-title-block button.carriers-add-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 0 4px;
  min-height: var(--control-height);
  padding: 0 14px 0 12px;
  border: 1px solid var(--accent);
  font-weight: 600;
  font-size: var(--fs-btn);
  line-height: 1.25;
  color: #fff;
  background: var(--accent);
  white-space: nowrap;
}

.home-title-block button.carriers-add-btn:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.carriers-add-btn svg {
  flex-shrink: 0;
}

#view-top10 .home-dash-top10 {
  margin-top: 0;
}

#top10-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--portal-loading-gap);
  min-height: 180px;
}

#top10-loading[hidden] {
  display: none !important;
}

/* Profile / billing panels */
.panel-block {
  margin-top: 16px;
  padding: 20px 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.panel-block h3 {
  margin: 0 0 8px;
  font-size: var(--fs-section);
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
}

.panel-block .lead {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: var(--fs-body);
  line-height: 1.5;
  max-width: 70ch;
}

.panel-block ol.lead {
  padding-left: 1.2rem;
}

.panel-active-note {
  margin-top: 12px !important;
}

.panel-block form .field:first-child {
  margin-top: 4px;
}

/* Status pill variants (base shape lives in portal.css with .phase-badge) */
.badge.active { color: var(--success); border-color: var(--success-border); background: var(--success-bg); }
.badge.active::before { background: var(--success-dot); }
.badge.pending { color: var(--warning); border-color: var(--warning-border); background: var(--warning-bg); }
.badge.rejected { color: var(--danger); border-color: var(--danger-border); background: var(--danger-bg); }
.badge.default { color: var(--muted); background: var(--surface-subtle); }
.badge.default::before { background: var(--subtle); }

.panel-plans-actions {
  margin-top: 16px;
}

.modal-scroll {
  overflow: auto;
  margin-top: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}

.pay-card {
  margin: 12px 0 16px;
  padding: 20px 22px;
  border-radius: var(--radius);
  background: var(--chrome);
  color: #fff;
  box-shadow: var(--shadow-card);
  max-width: 440px;
}

.pay-card-label {
  margin: 0 0 8px;
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--chrome-text-muted);
}

.pay-card-number {
  margin: 0;
  font-size: var(--fs-2xl);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.08em;
}

.pay-card-hint {
  margin: 10px 0 0;
  font-size: var(--fs-sm);
  color: var(--chrome-text-muted);
  line-height: 1.45;
  white-space: pre-wrap;
}

.plans {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 12px;
}

.plan-card {
  text-align: left;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  font: inherit;
  color: inherit;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease), background-color var(--dur) var(--ease);
}

.plan-card:hover {
  border-color: var(--border-strong);
  background: var(--surface-subtle);
}

.plan-card.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 1px var(--accent);
}

.plan-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.plan-card h3 {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 6px;
  font-size: var(--fs-base);
  font-weight: 600;
  color: var(--text);
}

.plan-card-current {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 8px;
  border-radius: var(--radius-pill);
  background: var(--success-bg);
  border: 1px solid var(--success-border);
  color: var(--success);
  font-size: var(--fs-xs);
  font-weight: 600;
}

.plan-card .price {
  font-size: var(--fs-title);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.plan-card .price-period {
  font-size: var(--fs-sm);
  font-weight: 500;
  letter-spacing: 0;
  color: var(--muted);
}

.plan-card .meta { margin-top: 6px; color: var(--muted); font-size: var(--fs-meta); }

/* Modals (Add SCAC / Trucks) — same shell as portal dialog */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: var(--overlay);
}

.modal-backdrop:not([hidden]) .modal {
  animation: tripsSyncPop 180ms var(--ease);
}

.modal {
  width: min(100%, 420px);
  max-height: min(90vh, 640px);
  overflow: auto;
  padding: 20px 24px 24px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
}

.modal.wide { width: min(100%, 640px); }

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.modal-head h3 {
  margin: 0;
  font-size: var(--fs-xl);
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
}

.modal .field {
  margin-top: 12px;
}

.modal .list-summary {
  font-size: var(--fs-md);
  font-weight: 500;
  letter-spacing: 0;
}

.input-uppercase {
  text-transform: uppercase;
}

.input-uppercase::placeholder {
  text-transform: none;
}

/* Icon-only button (close etc.) */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--control-height-sm);
  height: var(--control-height-sm);
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  flex-shrink: 0;
}

.icon-btn svg {
  display: block;
  width: var(--icon-size);
  height: var(--icon-size);
  color: inherit;
  stroke: currentColor;
  flex-shrink: 0;
}

.icon-btn:hover {
  background: var(--surface-hover);
  border-color: var(--border);
  color: var(--text);
}

.icon-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ── Data tables (/app trucks + /admin) ── */
.tractors-table,
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-md);
  font-variant-numeric: tabular-nums;
}

.tractors-table th,
.tractors-table td,
.admin-table th,
.admin-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text);
}

.tractors-table th,
.admin-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-subtle);
  color: var(--muted);
  font-weight: 600;
  font-size: var(--fs-sm);
  white-space: nowrap;
  border-bottom-color: var(--border);
}

.tractors-table tbody tr:last-child td,
.admin-table tbody tr:last-child td {
  border-bottom: 0;
}

.tractors-table tbody tr:hover td,
.admin-table tbody tr:hover td {
  background: var(--surface-subtle);
}

.user-chip {
  margin: 0 0 4px;
  font-size: var(--fs-base);
  font-weight: 600;
}

.statement-page-error {
  margin: 16px 24px 0;
}

.error { color: var(--danger); }
.ok { color: var(--success); }
.muted { color: var(--muted); }
.hidden { display: none !important; }

/* ── Admin (/admin) ── */
.app-shell.admin-shell {
  min-height: 100vh;
  padding: 20px 24px 40px;
  max-width: 1100px;
  margin: 0 auto;
  font-size: var(--fs-base);
  line-height: 1.4;
  color: var(--text);
}

.admin-shell > .top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.admin-shell .brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.admin-shell .brand img {
  border-radius: var(--radius-sm);
}

.admin-shell .brand h1 {
  margin: 0;
  font-size: var(--fs-2xl);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}

.admin-shell .brand .sub {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: var(--fs-md);
  font-weight: 500;
}

.admin-shell .row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.admin-shell > .error,
.admin-shell > .ok {
  margin: 0 0 12px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: var(--fs-md);
}

.admin-shell > .error { background: var(--danger-bg); border: 1px solid var(--danger-border); }
.admin-shell > .ok { background: var(--success-bg); border: 1px solid var(--success-border); }

.admin-shell .panel {
  margin-top: 12px;
  padding: 20px 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.admin-shell .panel-actions {
  margin-top: 16px;
}

/* Licenses: pinned summary + scrollable table */
.licenses-tab {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  flex: 1;
}

.licenses-summary {
  flex-shrink: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 0;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.licenses-stat {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
  min-width: 0;
  justify-content: flex-start;
  padding: 2px 18px 2px 0;
  margin-right: 18px;
  border-right: 1px solid var(--border);
}

.licenses-stat:last-of-type {
  margin-right: 0;
  padding-right: 0;
  border-right: 0;
}

.licenses-stat-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  background: var(--surface-subtle);
}

.licenses-stat-users .licenses-stat-icon { color: var(--accent); background: var(--accent-soft); }
.licenses-stat-active .licenses-stat-icon { color: var(--success); background: var(--success-bg); }
.licenses-stat-inactive .licenses-stat-icon { color: var(--danger); background: var(--danger-bg); }
.licenses-stat-trucks .licenses-stat-icon { color: var(--accent); background: var(--accent-soft); }
.licenses-stat-subscriptions .licenses-stat-icon { color: var(--success); background: var(--success-bg); }
.licenses-stat-overlimit .licenses-stat-icon { color: var(--warning); background: var(--warning-bg); }
.licenses-stat-unassigned .licenses-stat-icon { color: var(--muted); background: var(--surface-sunken); }

.licenses-stat-main {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}

.licenses-stat-stack {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  min-width: 0;
}

.licenses-stat-sub {
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
  margin: 0;
  padding: 0;
  line-height: 1.2;
  white-space: nowrap;
  color: var(--muted);
}

.licenses-stat-sub-n {
  font-size: var(--fs-xs);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.licenses-stat-sub-l {
  font-size: var(--fs-xs);
  font-weight: 500;
  color: var(--muted);
}

.licenses-stat-overlimit {
  position: relative;
  width: max-content;
  max-width: 100%;
}

.licenses-stat-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin: -2px -4px;
  padding: 2px 4px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
  transition: background var(--dur) var(--ease);
}

.licenses-stat-btn:disabled {
  opacity: 0.55;
  cursor: default;
}

.licenses-stat-overlimit .licenses-stat-btn:not(:disabled):hover {
  background: var(--warning-bg);
}

.licenses-stat-unassigned .licenses-stat-btn:not(:disabled):hover,
.licenses-stat-unassigned .licenses-stat-btn.is-current {
  background: var(--surface-hover);
}

.licenses-stat-btn:not(:disabled):hover .licenses-stat-l {
  color: var(--text);
}

.licenses-stat-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.overlimit-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: auto;
  z-index: 40;
  min-width: max(100%, 260px);
  width: max-content;
  max-width: min(380px, 85vw);
  max-height: 340px;
  overflow: auto;
  padding: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.overlimit-menu.hidden,
.overlimit-menu[hidden] {
  display: none;
}

.overlimit-menu-item {
  display: block;
  width: 100%;
  margin: 0;
  padding: 10px 12px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: var(--fs-body, var(--fs-md));
  font-weight: 600;
  line-height: 1.35;
  text-align: left;
  cursor: pointer;
}

.overlimit-menu-item:hover,
.overlimit-menu-item:focus-visible {
  background: var(--warning-bg);
  outline: none;
}

.licenses-stat-n,
.licenses-stat-l {
  line-height: 1.15;
  white-space: nowrap;
}

.licenses-stat-n {
  font-size: var(--fs-xl);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  letter-spacing: -0.02em;
}

.licenses-stat-l {
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--muted);
}

.licenses-search-wrap {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 1 280px;
  width: 280px;
  max-width: 100%;
  min-width: 180px;
  min-height: var(--control-height);
  padding: 0 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}

.licenses-search-wrap:hover:not(:focus-within) {
  border-color: var(--border-strong);
}

.licenses-search-wrap:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

.licenses-search-icon {
  flex-shrink: 0;
  color: var(--muted);
}

.licenses-search {
  width: 100%;
  min-width: 0;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.licenses-search:hover,
.licenses-search:focus {
  border: 0;
  box-shadow: none;
}

.admin-shell .panel.licenses-table-panel {
  margin-top: 0;
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 0;
}

@media (max-width: 720px) {
  .licenses-summary {
    gap: 10px 0;
  }
  .licenses-stat {
    margin-right: 14px;
    padding-right: 14px;
  }
  .licenses-search-wrap {
    margin-left: 0;
    flex: 1 1 100%;
    width: 100%;
    max-width: none;
  }
  .app-shell.admin-shell {
    padding: 16px 14px 32px;
  }
}

.licenses-empty {
  margin: 0;
  text-align: center;
  padding: 32px 16px;
}

.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;
}

.admin-shell .panel h2 {
  margin: 0 0 4px;
  font-size: var(--fs-section);
  font-weight: 700;
  color: var(--text);
}

.admin-shell .lead {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: var(--fs-md);
  line-height: 1.5;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.stat-card {
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.stat-card .stat-n {
  font-size: var(--fs-2xl);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.stat-card .stat-l {
  margin-top: 4px;
  font-size: var(--fs-sm);
  color: var(--muted);
  font-weight: 600;
}

/* Pending payment submissions */
.admin-item {
  padding: 16px 0;
  border-bottom: 1px solid var(--border-subtle);
}

.admin-item:first-child { padding-top: 4px; }
.admin-item:last-child { border-bottom: 0; padding-bottom: 0; }

.admin-item-head {
  justify-content: space-between;
  align-items: flex-start;
}

.admin-item-name {
  font-weight: 600;
  color: var(--text);
}

.admin-item-plan {
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.admin-item-meta {
  margin: 10px 0 0;
  font-size: var(--fs-md);
}

.admin-item-note {
  margin: 6px 0 0;
  font-size: var(--fs-md);
}

.admin-item-actions {
  margin-top: 12px;
}

.admin-item img {
  display: block;
  max-width: min(100%, 360px);
  margin-top: 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

#empty.muted {
  margin: 0;
  padding: 24px 0 8px;
  text-align: center;
}

.admin-table.licenses-table th,
.admin-table.licenses-table td {
  text-align: center;
  vertical-align: middle;
}

.admin-table.licenses-table th.carrier-col,
.admin-table.licenses-table td.carrier-cell {
  text-align: left;
  padding-left: 14px;
  padding-right: 8px;
}

.admin-table.licenses-table th.scac-col,
.admin-table.licenses-table td.scac-cell {
  text-align: left;
  padding-left: 4px;
  padding-right: 10px;
}

.admin-table .carrier-name {
  font-weight: 600;
  color: var(--text);
}

.admin-table .scac-code {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: var(--radius-xs);
  background: var(--surface-sunken);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  font-weight: 600;
  letter-spacing: 0.04em;
}

.admin-table .trucks-cell {
  white-space: nowrap;
}

.admin-table .trucks-count {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--text);
}

.admin-table .plan-cell {
  white-space: nowrap;
}

.plan-select {
  max-width: 168px;
  min-height: 28px;
  padding: 0 8px;
  font-size: var(--fs-sm);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
}

.admin-table.licenses-table tr.is-alarming td {
  background: var(--warning-bg);
}


.admin-table .status-cell {
  white-space: nowrap;
}

/* License ON/OFF — status pill that toggles */
.status-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 64px;
  height: 28px;
  padding: 0 12px;
  font-size: var(--fs-sm);
  font-weight: 600;
  letter-spacing: 0.02em;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  cursor: pointer;
  background: var(--surface);
  color: var(--muted);
}

.status-toggle::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.status-toggle.is-on {
  color: var(--success);
  border-color: var(--success-border);
  background: var(--success-bg);
}

.status-toggle.is-on::before { background: var(--success-dot); }

.status-toggle.is-off {
  color: var(--danger);
  border-color: var(--danger-border);
  background: var(--danger-bg);
}

.status-toggle.is-on:hover { border-color: var(--success); }
.status-toggle.is-off:hover { border-color: var(--danger); }

.admin-table .expiry-date {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--text);
}

.admin-table .expiry-countdown {
  margin-top: 2px;
  font-size: var(--fs-sm);
  color: var(--muted);
  line-height: 1.3;
}

.admin-table .expiry-countdown.is-expired {
  color: var(--danger);
}

.renew-cell {
  position: relative;
  text-align: center;
  white-space: nowrap;
}

.admin-table.licenses-table th.delete-col,
.admin-table.licenses-table td.delete-cell {
  width: 52px;
  min-width: 52px;
  max-width: 52px;
  text-align: center;
  padding-left: 4px;
  padding-right: 4px;
}

button.btn.renew-btn {
  min-height: var(--control-height-sm);
  padding: 0 12px;
  font-weight: 500;
  background: #fff;
  border-color: var(--border);
  color: var(--accent);
}

button.btn.renew-btn:hover:not(:disabled) {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

.admin-table .license-delete-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--control-height-sm);
  min-width: var(--control-height-sm);
  height: var(--control-height-sm);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--muted);
  font-size: 18px;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
}

.admin-table .license-delete-btn:hover:not(:disabled) {
  border-color: var(--danger);
  background: var(--danger-bg);
  color: var(--danger);
}

/* Appended to <body> with fixed coords so scrolling table panels never clip it. */
.renew-menu {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 60;
  width: 248px;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: left;
}

.renew-menu-btn {
  width: 100%;
  justify-content: center;
}

.renew-cal {
  user-select: none;
}

.renew-cal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 6px;
}

.renew-cal-title {
  font-size: var(--fs-md);
  font-weight: 600;
  color: var(--text);
}

.renew-cal-nav {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  line-height: 0;
}

.renew-cal-nav:hover {
  background: var(--surface-hover);
  border-color: var(--border-strong);
}

.renew-cal-chevron {
  display: block;
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.renew-cal-dow,
.renew-cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  text-align: center;
}

.renew-cal-dow {
  margin-bottom: 4px;
}

.renew-cal-dow span {
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--muted);
  padding: 2px 0;
}

.renew-cal-day {
  height: 30px;
  border: 0;
  border-radius: var(--radius-xs);
  background: transparent;
  color: var(--text);
  font-size: var(--fs-sm);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  padding: 0;
}

.renew-cal-day:not(.is-empty):not(.is-disabled):hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.renew-cal-day.is-current {
  font-weight: 700;
  box-shadow: inset 0 0 0 1px var(--accent);
  color: var(--accent);
}

.renew-cal-day.is-empty {
  cursor: default;
  visibility: hidden;
}

.renew-cal-day.is-disabled,
.renew-cal-day:disabled {
  color: var(--muted);
  opacity: 0.35;
  cursor: default;
}

.admin-table .price-input {
  width: 120px;
  min-height: var(--control-height-sm);
  padding: 4px 10px;
  font-variant-numeric: tabular-nums;
}

.admin-shell .login-hero {
  max-width: 420px;
  margin: 48px auto;
  padding: 28px 32px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
}

.admin-shell .login-hero h2 {
  margin: 0 0 8px;
  font-size: var(--fs-xl);
  font-weight: 700;
  color: var(--text);
}

.admin-shell .login-hero p {
  margin: 0;
  color: var(--muted);
  font-size: var(--fs-md);
  line-height: 1.5;
}

/* Embedded inside owner portal shell (sidebar stays) */
html.admin-embed,
html.admin-embed body {
  height: 100%;
  margin: 0;
  background: transparent;
}

.admin-shell.is-embed {
  height: 100%;
  min-height: 100%;
  max-width: none;
  margin: 0;
  padding: 20px 24px 24px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.admin-shell.is-embed #view-admin {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.admin-shell.is-embed #view-admin.hidden {
  display: none !important;
}

.admin-shell.is-embed .tab-panel {
  flex: 1;
  min-height: 0;
}

.admin-shell.is-embed .tab-panel.hidden {
  display: none !important;
}

/* Portal sidebar already has Sign out; Refresh is unused in embed. */
.admin-shell.is-embed > .top {
  display: none;
}

.admin-shell.is-embed .login-hero {
  margin: 24px auto;
}

/* Users table + detail */
.admin-table.licenses-table th.user-col,
.admin-table.licenses-table td.user-cell {
  text-align: left;
  padding-left: 14px;
}

.admin-table.users-table tbody tr.user-row {
  cursor: pointer;
}

.admin-table.users-table tbody tr.user-row:hover td {
  background: var(--surface-hover);
}

.admin-table.users-table tbody tr.user-row.is-alarming:hover td {
  background: color-mix(in srgb, var(--warning-bg), var(--warning-border) 30%);
}

.admin-table .user-open-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  max-width: 280px;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.admin-table tr.user-row:hover .user-name,
.admin-table .user-open-btn:focus-visible .user-name {
  color: var(--accent);
}

.admin-table .user-open-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: var(--radius-xs);
}

.admin-table .user-name,
.admin-table .user-email {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-table .user-name {
  font-weight: 600;
  color: var(--text);
  transition: color var(--dur) var(--ease);
}

.admin-table .user-email {
  font-size: var(--fs-sm);
  color: var(--muted);
}

.admin-table tr.is-unassigned .user-name {
  color: var(--muted);
  font-style: italic;
}

.admin-table .carriers-cell {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.plan-label {
  font-size: var(--fs-sm);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.plan-label.is-unset {
  color: var(--muted);
  font-weight: 500;
}

.licenses-empty .text-btn {
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.licenses-empty .text-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.plan-select.is-unset {
  color: var(--muted);
}

.plan-select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.plan-select.is-alarming {
  background: var(--warning-bg);
  color: var(--text);
}

.status-toggle:focus-visible,
.license-delete-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.status-toggle:disabled,
.renew-btn:disabled,
.plan-select:disabled,
.license-delete-btn:disabled {
  opacity: 0.55;
  cursor: progress;
}

.renew-btn[aria-expanded="true"] {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 52px;
  height: 24px;
  padding: 0 10px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.02em;
}

.status-pill.is-on {
  color: var(--success);
  border-color: var(--success-border);
  background: var(--success-bg);
}

.status-pill.is-off {
  color: var(--danger);
  border-color: var(--danger-border);
  background: var(--danger-bg);
}

/* Loading skeleton */
.licenses-skeleton {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px 14px;
}

.licenses-skeleton span {
  display: block;
  height: 40px;
  border-radius: var(--radius-sm);
  background: var(--surface-sunken);
  animation: licenses-pulse 1.2s ease-in-out infinite;
}

.licenses-skeleton span:nth-child(2) { animation-delay: 120ms; }
.licenses-skeleton span:nth-child(3) { animation-delay: 240ms; }

@keyframes licenses-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

/* User detail */
.licenses-detail-panel {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 16px 22px 24px;
  min-height: 0;
  flex: 1 1 auto;
  overflow: auto;
}

.licenses-detail-panel.hidden,
.licenses-detail-panel[hidden] {
  display: none !important;
}

.user-detail-back {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 28px;
  margin-left: -8px;
  padding: 0 10px 0 6px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: var(--fs-sm);
  font-weight: 600;
  cursor: pointer;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}

.user-detail-back:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.user-detail-back:focus {
  outline: none;
}

.user-detail-back:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.user-card {
  padding: 18px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.user-card-row {
  display: flex;
  align-items: center;
  gap: 24px;
}

.user-card-grid {
  flex: 0 0 60%;
  width: 60%;
  max-width: 60%;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr)) auto;
  align-items: start;
  column-gap: 24px;
}

.user-card-cell {
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.user-card-label {
  display: block;
  margin: 0 0 8px;
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--muted);
  cursor: default;
}

label.user-card-label {
  cursor: pointer;
}

.user-card-grid .plan-select {
  width: 100%;
  max-width: none;
  min-height: var(--control-height-sm);
  font-size: var(--fs-sm);
}

.user-card-row > .user-detail-notify-btn {
  margin-left: auto;
  flex-shrink: 0;
  align-self: center;
}

.user-detail-identity {
  min-width: 0;
}

.user-detail-identity h2 {
  margin: 0;
  font-size: var(--fs-lg);
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.25;
  background: none;
}

.user-detail-identity h2:focus {
  outline: none;
}

.user-detail-identity p,
.user-card-email p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: var(--fs-md);
  line-height: 1.3;
  overflow-wrap: anywhere;
}

button.btn.ghost.user-detail-notify-btn {
  flex-shrink: 0;
  border-color: var(--border);
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
}

button.btn.ghost.user-detail-notify-btn[aria-expanded="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.user-summary-value {
  display: block;
  font-size: var(--fs-xl);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
  color: var(--text);
}

.user-summary-meta {
  display: block;
  margin-top: 4px;
  font-size: var(--fs-sm);
  color: var(--muted);
}

.user-summary-meta.is-expired {
  color: var(--danger);
}

/* Notify composer (inline, not a modal) */
.user-notify {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px 18px;
  border: 1px solid var(--accent-border);
  border-radius: var(--radius);
  background: var(--surface-subtle);
  animation: user-notify-in 180ms var(--ease);
}

.user-notify.hidden,
.user-notify[hidden] {
  display: none !important;
}

@keyframes user-notify-in {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: none; }
}

.user-notify-head h3 {
  margin: 0;
  font-size: var(--fs-lg);
  font-weight: 700;
}

.user-notify-head p {
  margin: 2px 0 0;
  font-size: var(--fs-sm);
  color: var(--muted);
}

.user-notify-templates {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.notify-template-btn {
  margin: 0;
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: var(--fs-sm);
  font-weight: 600;
  cursor: pointer;
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease), color var(--dur) var(--ease);
}

.notify-template-btn:hover {
  border-color: var(--border-strong);
}

.notify-template-btn[aria-checked="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.notify-template-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.user-notify-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.user-notify-field > span {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--muted);
}

.user-notify-field input,
.user-notify-field textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: var(--fs-md);
  line-height: 1.5;
}

.user-notify-field input {
  min-height: var(--control-height);
  font-weight: 600;
}

.user-notify-field textarea {
  min-height: 96px;
  resize: vertical;
  max-width: 75ch;
}

.user-notify-field input:focus,
.user-notify-field textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

.user-notify-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* Carriers of one user */
.user-totals {
  display: flex;
  align-items: baseline;
  gap: 28px;
  /* Border of the table plus the first cell’s padding, so “1” sits on the C of Carrier. */
  padding-left: 13px;
}

.user-total {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
}

.user-total-n {
  font-size: var(--fs-xl);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  color: var(--text);
}

.user-total-l {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--muted);
}

.user-detail-carriers-scroll {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.admin-table.user-carriers-table {
  table-layout: fixed;
  width: 100%;
}

/* Carrier + SCAC + Trucks = 50% of the table; leftover is fill + actions. */
.user-carriers-table .col-carrier { width: 24%; }
.user-carriers-table .col-scac { width: 14%; }
.user-carriers-table .col-trucks { width: 12%; }
.user-carriers-table .col-license { width: 12%; }
.user-carriers-table .col-actions { width: 48px; }

.admin-table.user-carriers-table th,
.admin-table.user-carriers-table td {
  text-align: left;
}

.admin-table.user-carriers-table th.scac-col,
.admin-table.user-carriers-table td.scac-cell,
.admin-table.user-carriers-table th.trucks-col,
.admin-table.user-carriers-table td.trucks-cell {
  text-align: center;
}

.admin-table.user-carriers-table th.fill-col,
.admin-table.user-carriers-table td.fill-col {
  padding: 0;
  border-bottom-color: var(--border-subtle);
}

.admin-table.user-carriers-table th.actions-col,
.admin-table.user-carriers-table td.actions-cell {
  width: 48px;
  text-align: center;
}

.admin-table.user-carriers-table tfoot td {
  border-top: 1px solid var(--border);
  border-bottom: 0;
  background: var(--surface-subtle);
  font-weight: 600;
  color: var(--muted);
}

.admin-table.user-carriers-table tfoot td.num {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.admin-table .license-delete-btn svg {
  display: block;
}

@media (prefers-reduced-motion: reduce) {
  .user-notify,
  .licenses-skeleton span {
    animation: none;
  }
}

@media (max-width: 900px) {
  .user-card-row {
    flex-wrap: wrap;
  }
  .user-card-grid {
    flex: 1 1 100%;
    width: 100%;
    max-width: none;
    grid-template-columns: repeat(2, minmax(0, 1fr)) auto;
  }
  .user-card-row > .user-detail-notify-btn {
    margin-left: 0;
  }
}

@media (max-width: 560px) {
  .licenses-detail-panel {
    padding: 14px 14px 20px;
  }
  .user-card-grid {
    grid-template-columns: 1fr 1fr;
  }
  button.btn.ghost.user-detail-notify-btn {
    width: 100%;
  }
  .user-notify-actions .btn {
    flex: 1;
  }
}
