/* Shared components: buttons, forms, badges, status, menus, popovers, modals,
   toasts, tooltips, skeletons, empty/error states, key-value lists, secrets. */

/* ---------- Port expiration breakdown ---------- */
.port-expiry-summary {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 400;
  line-height: 1.3;
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
  white-space: nowrap;
}
.port-expiry-summary__value { font-weight: 400; }
.port-expiry-summary__value--valid { color: var(--ok-text); }
.port-expiry-summary__value--expired { color: var(--danger-text); }
.port-expiry-summary__separator { color: var(--text-muted); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 34px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  font-size: var(--fs-13);
  letter-spacing: -0.005em;
  white-space: nowrap;
  transition: background 0.12s, border-color 0.12s, color 0.12s, box-shadow 0.12s;
}
.btn:hover { background: var(--hover); border-color: var(--border-strong); }
.btn:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}
/* Disabled uses real colors, not whole-component opacity — label/icon stay identifiable */
.btn:disabled {
  cursor: not-allowed;
  color: var(--text-disabled);
  background: var(--surface-2);
  border-color: var(--border-soft);
}
.btn:disabled:hover {
  background: var(--surface-2);
  border-color: var(--border-soft);
  color: var(--text-disabled);
}
.btn .icon { width: 16px; height: 16px; }

.btn--primary {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--text-on-blue);
}
.btn--primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  color: var(--text-on-blue);
}
.btn--primary:active { background: var(--primary-active); border-color: var(--primary-active); }
.btn--primary:disabled {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--text-on-blue);
  opacity: 0.55;
}
.btn--primary:disabled:hover {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--text-on-blue);
}

.btn--ghost { border-color: transparent; background: transparent; }
.btn--ghost:hover { background: var(--hover); border-color: transparent; }
.btn--ghost:disabled { background: transparent; border-color: transparent; }

.btn--danger { color: var(--danger-text); border-color: var(--danger-border); background: var(--surface); }
.btn--danger:hover { background: var(--danger-soft); border-color: var(--danger-border); color: var(--danger-text); }
.modal__actions .btn--danger { background: var(--danger); border-color: var(--danger); color: var(--text-on-danger); }
.modal__actions .btn--danger:hover { background: var(--danger-hover); border-color: var(--danger-hover); color: var(--text-on-danger); }
.modal__actions .btn--danger:disabled { background: var(--danger); border-color: var(--danger); color: var(--text-on-danger); opacity: 0.55; }

.btn--sm { height: 28px; padding: 0 10px; font-size: var(--fs-12); }
.btn--block { width: 100%; justify-content: center; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
}
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn .icon { width: 18px; height: 18px; }
.icon-btn--bordered { border-color: var(--border); background: var(--surface); }

.copy-wrap {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  vertical-align: middle;
}
.copy-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px; height: 24px;
  border: none; border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  vertical-align: middle;
  cursor: pointer;
}
.copy-btn:hover { background: var(--hover); color: var(--text); }
.copy-btn .icon { width: 14px; height: 14px; }
.copy-btn.is-copied { color: var(--blue); }
.copy-feedback {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--blue);
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transform: translateX(-2px);
  transition: opacity 120ms ease, transform 120ms ease, visibility 120ms ease;
  pointer-events: none;
}
.copy-feedback.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translateX(0);
}

/* ---------- Forms ---------- */
.form-label {
  display: block;
  font-size: var(--fs-12);
  font-weight: 600;
  color: var(--text-secondary);
  margin: 14px 0 5px;
}
.form-label:first-child { margin-top: 0; }
.form-input, .form-select {
  width: 100%;
  height: 36px;
  padding: 0 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--input-bg);
  color: var(--text);
  font-weight: 500;
}
.form-input::placeholder, .form-select::placeholder {
  color: var(--input-placeholder);
}
.form-input:focus, .form-select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-soft); outline: none; }
.form-input:disabled, .form-select:disabled {
  color: var(--text-disabled);
  background: var(--surface-2);
  cursor: not-allowed;
}
.form-hint { font-size: var(--fs-12); color: var(--text-muted); margin-top: 5px; }
.form-row { display: flex; gap: 10px; }
.form-row > * { flex: 1; }

.switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
  user-select: none;
}
.switch input { position: absolute; opacity: 0; }
.switch__track {
  width: 34px; height: 20px;
  border-radius: var(--radius-pill);
  background: var(--neutral-block);
  position: relative;
  transition: background 0.15s;
  flex: none;
}
.switch__track::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--knob);
  transition: transform 0.15s;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.2);
}
.switch input:checked + .switch__track { background: var(--primary); }
.switch input:checked + .switch__track::after { transform: translateX(14px); }
.switch input:focus-visible + .switch__track { box-shadow: var(--focus-ring); }

/* ---------- Status indicator ---------- */
.status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: var(--fs-13);
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
}
.status__dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--neutral);
  flex: none;
}
.status .icon { width: 14px; height: 14px; }
.status--online .status__dot, .status--active .status__dot { background: var(--ok); }
.status--online, .status--active { color: var(--ok-text); }
.status--offline .status__dot, .status--disabled .status__dot { background: var(--neutral); }
.status--warning .status__dot { background: var(--warn); }
.status--warning { color: var(--warn-text); }
.status--error .status__dot { background: var(--danger); }
.status--error { color: var(--danger-text); }
.status--connecting .status__dot, .status--reconnecting .status__dot { background: var(--blue); animation: pulse 1.2s ease-in-out infinite; }
.status--connecting, .status--reconnecting { color: var(--blue); }
.status--rotating .status__dot { background: var(--blue); animation: pulse 1.2s ease-in-out infinite; }
.status--rotating { color: var(--blue); }
.status--suspended .status__dot { background: var(--suspended); }
.status--suspended { color: var(--suspended-text); }
.status--expired .status__dot { background: transparent; border: 2px solid var(--danger); width: 6px; height: 6px; }
.status--expired { color: var(--danger-text); }
.status--maintenance .status__dot { background: var(--neutral); }
.status--maintenance { color: var(--text-secondary); }

.status--compact {
  gap: 4px;
  max-width: none;
  justify-content: flex-start;
}
.status--compact .status__icon .icon {
  width: 12px;
  height: 12px;
}
.status--compact .status__label[hidden] { display: none !important; }
.status--critical {
  gap: 4px;
}

@keyframes pulse { 50% { opacity: 0.35; } }
@media (prefers-reduced-motion: reduce) {
  .status__dot { animation: none !important; }
}

/* ---------- Badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 20px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--surface);
  font-size: var(--fs-11);
  font-weight: 700;
  color: var(--text-secondary);
  white-space: nowrap;
}
.badge--soft { background: var(--surface-2); border-color: var(--border-soft); }
.badge--blue { color: var(--blue); border-color: var(--blue-border); background: var(--blue-soft); }
.badge--warn { color: var(--warn-text); border-color: var(--warn-border); background: var(--warn-soft); }
.badge--danger { color: var(--danger-text); border-color: var(--danger-border); background: var(--danger-soft); }
.badge--ok { color: var(--ok-text); border-color: var(--ok-border); background: var(--ok-soft); }
.badge .icon { width: 11px; height: 11px; }

.flag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  height: 18px;
  padding: 0 4px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface-2);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
}

/* ---------- Menus & popovers ---------- */
.menu, .popover {
  position: fixed;
  z-index: var(--z-dropdown);
  min-width: 200px;
  max-width: 320px;
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-menu);
  padding: 6px;
}
.popover { max-width: 460px; padding: 14px; }
.popover--wide { width: 460px; max-width: min(460px, calc(100vw - 24px)); }
.popover--custom-range {
  width: min(400px, calc(100vw - 24px));
  max-width: min(400px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
  padding: 0;
}
.popover--over-drawer {
  z-index: var(--z-drawer-popover);
}
.menu.menu--sort {
  min-width: 240px;
  max-width: 280px;
  width: 252px;
}
.menu.menu--sort .menu__item {
  min-height: 36px;
  padding: 8px 10px;
}
.menu.menu--sort .menu__hint {
  flex: none;
  margin-left: 10px;
  color: var(--text-secondary);
  white-space: nowrap;
}
.menu__item.is-checked {
  background: var(--blue-soft);
  color: var(--text);
}
.menu__item.is-checked:hover,
.menu__item.is-checked:focus-visible {
  background: var(--blue-soft-2);
}

.menu.menu--dest-range,
.menu--dest-range {
  min-width: 160px;
  max-width: 180px;
  width: 168px;
}

.menu__item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 8px 10px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  text-align: left;
  font-size: var(--fs-13);
  font-weight: 600;
  color: var(--text);
}
.menu__item:hover, .menu__item:focus-visible { background: var(--hover); box-shadow: none; }
.menu__item[disabled] { color: var(--text-disabled); cursor: not-allowed; }
.menu__item[disabled] .menu__icon, .menu__item[disabled] .menu__hint { color: var(--text-disabled); }
.menu__item--danger { color: var(--danger); }
.menu__icon { width: 16px; height: 16px; flex: none; color: var(--text-secondary); }
.menu__item--danger .menu__icon { color: var(--danger); }
.menu__label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu__hint { font-size: var(--fs-11); color: var(--text-muted); font-weight: 600; }
.menu__check { width: 15px; height: 15px; color: var(--blue); }
.menu__item .plan-tier-badge { margin-left: auto; }
.menu__item.plan-locked-control[aria-disabled="true"] {
  opacity: 1;
  color: var(--text);
}
.menu__divider { height: 1px; margin: 6px 4px; background: var(--border-soft); }
.menu__header {
  padding: 8px 10px 4px;
  font-size: var(--fs-11);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

/* Bulk actions menu — stacked title + description */
.menu.menu--bulk {
  width: 340px;
  min-width: 320px;
  max-width: min(360px, calc(100vw - 24px));
  max-height: min(calc(100dvh - 16px), calc(100vh - 16px));
  padding: 8px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.menu--bulk .menu__header {
  padding: 8px 10px 2px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.menu--bulk .menu__header:first-child {
  padding-top: 2px;
}

.menu--bulk .menu__divider {
  height: 1px;
  margin: 4px 6px;
  background: var(--border-soft);
}

.menu--bulk .menu__item--stacked {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  text-align: left;
  font: inherit;
  color: var(--text);
  cursor: pointer;
}

.menu--bulk .menu__item--stacked:hover,
.menu--bulk .menu__item--stacked:focus-visible {
  background: var(--hover);
  outline: none;
  box-shadow: none;
}

.menu--bulk .menu__item--stacked:active {
  background: var(--blue-soft);
}

.menu--bulk .menu__icon {
  width: 16px;
  height: 16px;
  flex: none;
  margin-top: 1px;
  color: var(--text-secondary);
}

.menu--bulk .menu__body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.menu--bulk .menu__label {
  flex: none;
  font-size: var(--fs-12);
  font-weight: 600;
  line-height: 1.3;
  color: var(--text);
  white-space: normal;
  overflow: visible;
  text-overflow: unset;
}

.menu--bulk .menu__hint {
  font-size: var(--fs-11);
  font-weight: 400;
  line-height: 1.3;
  color: var(--text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.menu--bulk .menu__item--danger .menu__label,
.menu--bulk .menu__item--danger .menu__icon {
  color: var(--danger);
}

.menu--bulk .menu__item--danger .menu__hint {
  color: var(--text-muted);
}

.menu--bulk .menu__item--danger:hover,
.menu--bulk .menu__item--danger:focus-visible {
  background: var(--danger-soft);
}

.menu--bulk .menu__item--danger:active {
  background: var(--danger-soft-2);
}

/* ---------- Modal ---------- */
#modal-root {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  pointer-events: none;
}

#modal-root:not(:empty) {
  pointer-events: auto;
}

#modal-root > .modal,
#modal-root > .mconfirm {
  pointer-events: auto;
}

/* Stacked modals (e.g. Renew → Add funds on mobile) paint above the first. */
#modal-root > .modal ~ .modal {
  z-index: calc(var(--z-modal) + 2);
}

/* Mobile compact confirm — mounted on body, outside modal-root */
.mconfirm {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px 16px;
  box-sizing: border-box;
  background: var(--backdrop);
  pointer-events: auto;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.mconfirm__panel {
  position: relative;
  width: min(300px, calc(100vw - 32px));
  background: var(--surface-elevated);
  border-radius: 12px;
  box-shadow: var(--shadow-modal);
  display: flex;
  flex-direction: column;
  pointer-events: auto;
}

.mconfirm__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 14px 16px 0;
}

.mconfirm__title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.25;
  color: var(--text);
}

.mconfirm__close {
  flex-shrink: 0;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.mconfirm__close .icon {
  pointer-events: none;
}

.mconfirm__text {
  margin: 0;
  padding: 6px 16px 10px;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
  color: var(--text-secondary);
}

.mconfirm__actions {
  display: flex;
  gap: 8px;
  padding: 0 16px 14px;
  padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px));
}

.mconfirm__actions .btn {
  flex: 1;
  justify-content: center;
  min-height: 40px;
  height: 40px;
  font-size: 12px;
  font-weight: 700;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.mconfirm__actions .btn .icon {
  pointer-events: none;
}

body.has-mconfirm-open {
  overflow: hidden;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal__backdrop { position: absolute; inset: 0; background: var(--backdrop); }
.modal__panel {
  position: relative;
  width: 480px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 64px);
  display: flex;
  flex-direction: column;
  background: var(--surface-elevated);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-modal);
}
.modal__panel--sm { width: 420px; }
.modal__panel--lg { width: 620px; }
.modal__panel--renew {
  width: min(660px, calc(100vw - 32px));
  max-height: calc(100vh - 64px);
  margin: 0;
  overflow: hidden;
}
/* Desktop: pin tall renew checkout to the top (centering pushes it down). */
@media (min-width: 768px) {
  .modal.modal--renew {
    align-items: flex-start;
    justify-content: center;
    padding: 32px 16px 24px;
    overflow-y: auto;
    box-sizing: border-box;
  }
  .modal.modal--renew .modal__panel--renew,
  .modal.modal--renew .modal__panel--lg {
    max-height: calc(100vh - 56px);
  }
  .modal--renew .modal__body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
  }
}
.modal--renew .modal__head {
  position: sticky;
  top: 0;
  z-index: 2;
  flex: none;
  background: var(--surface-elevated);
  padding-bottom: 8px;
}
.modal--renew .modal__actions {
  position: sticky;
  bottom: 0;
  z-index: 2;
  flex: none;
  background: var(--surface-elevated);
}
.modal--renew .modal__body {
  padding-top: 8px;
}

/* Fleet bulk renew — compact checkout */
.renew-ck {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.renew-ck__section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.renew-ck__section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}
.renew-ck__section-title {
  font-size: var(--fs-13);
  font-weight: 700;
  color: var(--text);
}
.renew-ck__section-count {
  font-size: var(--fs-12);
  font-weight: 500;
  color: var(--text-secondary);
}
.renew-ck__periods {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.renew-ck__period {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: var(--fs-13);
  font-weight: 600;
  cursor: pointer;
  min-height: 36px;
}
.renew-ck__period:hover { border-color: var(--border-strong, var(--border)); }
.renew-ck__period.is-selected {
  border-color: var(--blue);
  background: color-mix(in srgb, var(--blue) 12%, transparent);
  color: var(--text);
}
.renew-ck__eligibility {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.renew-ck__elig {
  font-size: var(--fs-13);
  font-weight: 600;
  color: var(--text);
}
.renew-ck__elig--ok { color: var(--text); }
.renew-ck__elig-note {
  font-size: var(--fs-12);
  color: var(--text-secondary);
}
.renew-ck__link {
  appearance: none;
  border: 0;
  background: none;
  padding: 0;
  margin: 0;
  color: var(--blue);
  font-size: var(--fs-13);
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  width: fit-content;
}
.renew-ck__link:hover { text-decoration: underline; }
.renew-ck__search { margin-top: 2px; }
.renew-ck__device-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.renew-ck__device-list.is-expanded {
  max-height: 220px;
  overflow-y: auto;
}
.renew-ck__device {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
.renew-ck__device:last-child { border-bottom: 0; }
.renew-ck__device-main { min-width: 0; flex: 1; }
.renew-ck__device-name {
  font-size: var(--fs-13);
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}
.renew-ck__device-meta {
  margin-top: 2px;
  font-size: var(--fs-12);
  color: var(--text-secondary);
  line-height: 1.35;
}
.renew-ck__device-exp {
  margin-top: 4px;
  font-size: var(--fs-12);
  color: var(--text-secondary);
}
.renew-ck__device-plan {
  flex: none;
  font-size: var(--fs-12);
  font-weight: 600;
  color: var(--text-secondary);
  padding-top: 2px;
}
.renew-ck__empty {
  margin: 0;
  padding: 12px;
  font-size: var(--fs-13);
  color: var(--text-secondary);
}
.renew-ck__coupon-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.renew-ck__coupon-row .form-input { flex: 1; min-width: 0; }
.renew-ck__coupon-applied {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.renew-ck__coupon-applied-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.renew-ck__coupon-code {
  font-size: var(--fs-13);
  font-weight: 700;
  color: var(--text);
}
.renew-ck__coupon-ok {
  font-size: var(--fs-12);
  font-weight: 600;
  color: var(--ok);
}
.renew-ck__coupon-label {
  font-size: var(--fs-12);
  color: var(--text-secondary);
}
.renew-ck__coupon-error { margin: 0; }
.renew-ck__sum-caption {
  font-size: var(--fs-12);
  color: var(--text-secondary);
}
.renew-ck__sum {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.renew-ck__sum-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  font-size: var(--fs-13);
  color: var(--text-secondary);
}
.renew-ck__sum-row strong {
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.renew-ck__sum-row--discount strong { color: var(--ok); }
.renew-ck__sum-row--total {
  font-size: var(--fs-14);
  color: var(--text);
}
.renew-ck__sum-row--total span,
.renew-ck__sum-row--total strong {
  font-weight: 700;
  color: var(--text);
}
.renew-ck__sum-row--due strong { font-weight: 700; }
.renew-ck__sum-divider {
  height: 1px;
  background: var(--border);
  margin: 2px 0;
}
.renew-ck__callout {
  margin-top: 4px;
  padding: 12px;
  border-radius: var(--radius-sm);
  border: 1px solid color-mix(in srgb, var(--danger) 35%, var(--border));
  background: color-mix(in srgb, var(--danger) 8%, var(--surface));
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-start;
}
.renew-ck__callout--muted {
  border-color: var(--border);
  background: var(--surface);
}
.renew-ck__callout-title {
  font-size: var(--fs-13);
  font-weight: 700;
  color: var(--text);
}
.renew-ck__callout-text,
.renew-ck__callout-hint {
  margin: 0;
  font-size: var(--fs-12);
  color: var(--text-secondary);
  line-height: 1.4;
}
.renew-ck__review-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 50vh;
  overflow-y: auto;
}
.renew-ck__review-item {
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.renew-ck__review-item:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}
.modal__panel--xl { width: min(1180px, calc(100vw - 32px)); max-width: 1180px; }
.modal__desc {
  margin: 0;
  font-size: var(--fs-13);
  font-weight: 500;
  color: var(--text-secondary);
  line-height: 1.4;
}
.modal__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px 0;
}
.modal__titles {
  min-width: 0;
  flex: 1;
}
.modal__head h2 { font-size: var(--fs-16); font-weight: 700; margin: 0; }
.modal__subtitle {
  margin: 4px 0 0;
  font-size: var(--fs-13);
  font-weight: 500;
  color: var(--text-secondary);
  line-height: 1.4;
}
.modal__head .modal__close { flex: none; margin-top: -2px; }
.modal__body { padding: 16px 20px; overflow-y: auto; }
.modal__actions {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  padding: 0 20px 18px;
}

/* Fleet bulk Manage Selected — compact forms */
.bulk-form { display: flex; flex-direction: column; gap: 12px; }
.bulk-form__lead {
  margin: 0;
  font-size: var(--fs-13);
  color: var(--text-secondary);
  line-height: 1.4;
}
.bulk-form__lead strong { color: var(--text); font-weight: 700; }
.bulk-form__section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.bulk-form__section-title {
  font-size: var(--fs-12);
  font-weight: 700;
  color: var(--text);
}
.bulk-form__hint {
  margin: 0;
  font-size: var(--fs-11);
  color: var(--text-muted);
  line-height: 1.4;
}
.bulk-form__warn {
  margin: 0;
  font-size: var(--fs-12);
  color: var(--text-secondary);
  line-height: 1.4;
}
.bulk-form__count {
  font-size: var(--fs-12);
  font-weight: 700;
  color: var(--text);
}
.bulk-form__examples {
  margin: 0;
  font-size: var(--fs-11);
  color: var(--text-muted);
  font-family: var(--font-mono, ui-monospace, monospace);
}
.bulk-form__checks {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.bulk-form__check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--fs-13);
  color: var(--text);
  cursor: pointer;
}
.bulk-form__section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.bulk-form__check--inline {
  flex: none;
  font-size: var(--fs-12);
  font-weight: 600;
  color: var(--text-secondary);
  user-select: none;
}
.bulk-form__check--inline input {
  margin: 0;
}
.bulk-form__info {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  margin: 0;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--blue-soft);
  border: 1px solid var(--blue-border-soft);
  font-size: 11px;
  color: var(--text-secondary);
  line-height: 1.4;
}
.bulk-form__info .icon {
  width: 13px;
  height: 13px;
  flex: none;
  margin-top: 1px;
  color: var(--blue);
}
.bulk-form--traffic {
  gap: 14px;
}
.bulk-form--traffic .bulk-form__section {
  gap: 6px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.bulk-form--traffic .bulk-form__fields {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.bulk-form--traffic .bulk-form__section.is-unlimited {
  background: var(--surface-2);
}
.bulk-form--traffic .bulk-form__section.is-unlimited .bulk-form__fields {
  opacity: 0.45;
  pointer-events: none;
}
.bulk-form--traffic .bulk-form__section.is-unlimited .bulk-form__check--inline {
  color: var(--blue);
}
.modal--traffic-limits .modal__subtitle {
  font-size: var(--fs-12);
}
.modal--traffic-limits .modal__body {
  padding-top: 12px;
  padding-bottom: 12px;
}
.bulk-form__row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
/* Native date-time inputs need a full row in the compact log dialog. */
#log-custom[hidden] { display: none; }
#log-custom .bulk-form__row { grid-template-columns: minmax(0, 1fr); gap: 12px; }
#log-custom .bulk-form__row > div { min-width: 0; }
#log-custom input { width: 100%; min-width: 0; max-width: 100%; box-sizing: border-box; font-size: 13px; }

.bulk-form__seg {
  display: inline-flex;
  align-self: flex-start;
  width: max-content;
  max-width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface);
}
.bulk-form__seg button {
  border: none;
  background: transparent;
  padding: 6px 12px;
  font-size: var(--fs-12);
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  flex: none;
}
.bulk-form__seg button.is-selected {
  background: var(--blue-soft);
  color: var(--blue);
}
.bulk-form__unit {
  display: flex;
  align-items: center;
  gap: 8px;
}
.bulk-form__unit .form-input { flex: 1; min-width: 0; }
.bulk-form__unit-suffix {
  font-size: var(--fs-12);
  font-weight: 600;
  color: var(--text-secondary);
  flex: none;
}
.bulk-form__preview {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  padding: 8px 10px;
  max-height: 120px;
  overflow: auto;
  font-size: var(--fs-12);
  font-family: var(--font-mono, ui-monospace, monospace);
  line-height: 1.45;
}
.bulk-form__preview .form-error { font-family: inherit; }

/* Bulk Rename — DEVICE | NEW NAME editor */
.modal--bulk-rename .modal__panel,
.modal--bulk-rename .modal__panel--lg {
  width: 640px;
  max-height: min(75vh, calc(100vh - 48px));
}
.modal--bulk-rename .modal__body {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  padding-top: 12px;
  padding-bottom: 12px;
}
.modal--bulk-rename .modal__actions {
  flex: none;
  border-top: 1px solid var(--border);
  padding-top: 12px;
  background: var(--surface-elevated);
}
.modal--bulk-rename .modal__head {
  flex: none;
  padding-bottom: 4px;
}
.rn-editor {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  flex: 1;
}
.rn-editor__tools {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: none;
  flex-wrap: wrap;
}
.rn-editor__pattern-toggle {
  color: var(--text-secondary);
  font-weight: 600;
  padding-left: 8px;
  padding-right: 8px;
}
.rn-editor__pattern-toggle.is-active {
  color: var(--blue);
  background: var(--blue-soft);
}
.rn-editor__search {
  flex: 1;
  min-width: 160px;
  margin: 0;
}
.rn-editor__search .form-input {
  height: 36px;
  min-height: 36px;
}
.rn-pattern {
  flex: none;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.rn-pattern__title {
  font-size: var(--fs-12);
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}
.rn-pattern__row {
  display: grid;
  grid-template-columns: 1fr 88px auto;
  gap: 10px;
  align-items: end;
}
.rn-pattern__field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.rn-pattern__field .form-label { margin: 0; }
.rn-pattern__apply {
  height: 40px;
  align-self: end;
  margin-bottom: 0;
}
.rn-pattern__field .bulk-form__hint { margin-top: 2px; }
.rn-editor__table {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.rn-editor__head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
  gap: 12px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  flex: none;
  position: sticky;
  top: 0;
  z-index: 1;
}
.rn-editor__head span {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.rn-editor__body {
  overflow-y: auto;
  flex: 1 1 auto;
  min-height: 0;
  max-height: min(48vh, 420px);
}
.rn-editor__empty {
  margin: 0;
  padding: 20px 12px;
  font-size: var(--fs-13);
  color: var(--text-muted);
  text-align: center;
}
.rn-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
  gap: 12px;
  align-items: start;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
.rn-row:last-child { border-bottom: none; }
.rn-row__device {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  padding-top: 10px;
}
.rn-row__name {
  font-size: var(--fs-13);
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rn-row__id {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rn-row__input {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.rn-row__mobile-label { display: none; }
.rn-row__input .form-input {
  height: 40px;
  min-height: 40px;
}
.rn-row__input .form-input.is-invalid {
  border-color: var(--danger-border, var(--danger));
  box-shadow: 0 0 0 1px var(--danger-border, var(--danger));
}
.rn-row__error {
  margin: 0;
  font-size: var(--fs-12);
  color: var(--danger);
  line-height: 1.3;
}

@media (max-width: 767px) {
  .modal--bulk-rename .modal__panel,
  .modal--bulk-rename .modal__panel--lg {
    width: 100%;
    max-height: none;
  }
  .modal--bulk-rename .modal__body {
    flex: 1;
    min-height: 0;
  }
  .rn-editor {
    flex: 1;
    min-height: 0;
  }
  .rn-editor__table {
    flex: 1;
    min-height: 0;
  }
  .rn-editor__body {
    max-height: none;
    flex: 1;
  }
  .rn-pattern__row {
    grid-template-columns: 1fr;
  }
  .rn-pattern__apply {
    width: 100%;
    justify-self: stretch;
  }
  .rn-editor__head { display: none; }
  .rn-row {
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 12px;
  }
  .rn-row__device { padding-top: 0; }
  .rn-row__mobile-label {
    display: block;
    font-size: var(--fs-12);
    font-weight: 600;
    color: var(--text-secondary);
  }
  .rn-row__name { white-space: normal; }
  .rn-row__input .form-input {
    height: 44px;
    min-height: 44px;
  }
}

.bulk-form textarea.form-input {
  min-height: 110px;
  resize: vertical;
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: var(--fs-12);
}
.bulk-form .form-input.is-invalid,
.bulk-form textarea.form-input.is-invalid {
  border-color: var(--danger-border, var(--danger));
  box-shadow: 0 0 0 1px var(--danger-border, var(--danger));
}
.bulk-form .form-error {
  margin: 0;
  font-size: var(--fs-12);
  color: var(--danger-text, var(--danger));
  line-height: 1.35;
}
.move-group-list {
  display: flex;
  flex-direction: column;
  max-height: 240px;
  overflow: auto;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
}
.move-group-list .device-picker__row {
  border-bottom: 1px solid var(--border-soft);
  margin: 0;
  padding: 8px 10px;
}
.move-group-list .device-picker__row:last-child { border-bottom: none; }
.move-group-mixed {
  font-size: var(--fs-12);
  color: var(--text-secondary);
  margin: 0 0 8px;
}
.modal__panel.is-busy { opacity: 0.7; pointer-events: none; }

.confirm__text { font-size: var(--fs-14); color: var(--text-secondary); line-height: 1.5; }
.confirm__text code { background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }
.confirm__details {
  margin-top: 12px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 4px 12px;
}
.confirm__detail {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 0;
  font-size: var(--fs-13);
  border-bottom: 1px solid var(--border-soft);
}
.confirm__detail:last-child { border-bottom: none; }
.confirm__detail span { color: var(--text-secondary); }
.confirm__consequences {
  display: flex;
  gap: 9px;
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--warn-soft);
  color: var(--warn-text);
  font-size: var(--fs-13);
}
.confirm__consequences .icon { width: 16px; height: 16px; flex: none; margin-top: 1px; }
.confirm__consequences p + p { margin-top: 4px; }

/* ---------- Toast ---------- */
.toast-root {
  position: fixed;
  left: 12px;
  bottom: 12px;
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: min(300px, calc(100vw - 24px));
  pointer-events: none;
}
.toast-root .toast { pointer-events: auto; }
.toast {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 9px;
  background: var(--inverse-surface);
  border: 1px solid var(--inverse-border);
  color: var(--inverse-text);
  border-radius: var(--radius-sm);
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.14);
  font-size: var(--fs-12);
  font-weight: 500;
  line-height: 1.35;
  animation: toast-in 0.16s ease-out;
}
.toast.is-leaving { opacity: 0; transition: opacity 0.16s; }
@keyframes toast-in { from { transform: translateY(6px); opacity: 0; } }
.toast__icon { width: 13px; height: 13px; flex: none; }
.toast--success .toast__icon { color: var(--inverse-ok); }
.toast--error .toast__icon { color: var(--inverse-danger); }
.toast--info .toast__icon { color: var(--inverse-link); }
.toast__body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.toast__msg { font-weight: 500; }
.toast__detail { font-weight: 400; color: var(--inverse-text-soft); font-size: var(--fs-11); line-height: 1.3; }
.toast__action {
  border: none; background: transparent;
  color: var(--inverse-link);
  font-weight: 600; font-size: var(--fs-12);
  padding: 0 2px;
  align-self: center;
}
.toast__action:hover { text-decoration: underline; }
.toast__close {
  border: none; background: transparent; color: var(--inverse-text-muted);
  width: 18px; height: 18px; padding: 0; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 4px;
  margin: -2px -2px -2px 0;
}
.toast__close:hover { color: var(--inverse-text); }
.toast__close .icon { width: 11px; height: 11px; }

/* ---------- Tooltip ---------- */
.tooltip {
  position: fixed;
  z-index: var(--z-tooltip);
  max-width: 320px;
  padding: 6px 9px;
  background: var(--inverse-surface);
  border: 1px solid var(--inverse-border);
  color: var(--inverse-text);
  border-radius: var(--radius-sm);
  font-size: var(--fs-12);
  font-weight: 600;
  pointer-events: none;
  box-shadow: var(--shadow-menu);
  white-space: pre-line;
}

.tooltip--titled {
  max-width: 260px;
  padding: 8px 10px;
  line-height: 1.4;
}

.tooltip__title {
  display: block;
  font-weight: 700;
  color: var(--inverse-text);
}

.tooltip__body {
  display: block;
  margin-top: 2px;
  font-weight: 500;
  color: var(--inverse-text-soft);
}

.tooltip--mono {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  max-width: min(420px, calc(100vw - 24px));
  word-break: break-all;
  line-height: 1.45;
}

/* ---------- Device issue badge + popover ---------- */
.issue-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 24px;
  height: 24px;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease;
}

.issue-badge .icon {
  width: 14px;
  height: 14px;
}

.issue-badge--critical { color: var(--danger); }
.issue-badge--warning { color: var(--warn); }
.issue-badge--notice { color: var(--blue); }

.issue-badge:hover,
.issue-badge[aria-expanded="true"] {
  background: var(--hover);
}

.issue-badge--critical:hover,
.issue-badge--critical[aria-expanded="true"] {
  background: var(--danger-soft);
}

.issue-badge--warning:hover,
.issue-badge--warning[aria-expanded="true"] {
  background: var(--warn-soft);
}

.issue-badge--notice:hover,
.issue-badge--notice[aria-expanded="true"] {
  background: var(--blue-soft);
}

.issue-badge:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.popover--issue {
  width: min(320px, calc(100vw - 24px));
  max-width: min(320px, calc(100vw - 24px));
  padding: 14px;
}

.issue-pop__head {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.issue-pop__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: 8px;
}

.issue-pop__icon .icon {
  width: 15px;
  height: 15px;
}

.issue-pop__icon--critical { background: var(--danger-soft); color: var(--danger); }
.issue-pop__icon--warning { background: var(--warn-soft); color: var(--warn); }
.issue-pop__icon--notice { background: var(--blue-soft); color: var(--blue); }

.issue-pop__heading {
  min-width: 0;
}

.issue-pop__title {
  margin: 0;
  font-size: var(--fs-14);
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
}

.issue-pop__device {
  margin: 2px 0 0;
  font-size: var(--fs-12);
  font-weight: 600;
  color: var(--text-muted);
}

.issue-pop__text {
  margin: 10px 0 0;
  font-size: var(--fs-13);
  font-weight: 500;
  line-height: 1.5;
  color: var(--text-secondary);
}

.issue-pop__section {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border-soft);
}

.issue-pop__section-title {
  margin: 0 0 6px;
  font-size: var(--fs-11);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.issue-pop__list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.issue-pop__list-item {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: var(--fs-13);
  font-weight: 600;
  color: var(--text);
}

.issue-pop__dot {
  width: 6px;
  height: 6px;
  flex: none;
  border-radius: 50%;
  background: currentColor;
}

.issue-pop__list-item--critical .issue-pop__dot { color: var(--danger); }
.issue-pop__list-item--warning .issue-pop__dot { color: var(--warn); }
.issue-pop__list-item--notice .issue-pop__dot { color: var(--blue); }

.issue-pop__foot {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
}

/* ---------- Skeletons ---------- */
.skeleton {
  background: linear-gradient(90deg, var(--skeleton-base) 25%, var(--skeleton-sheen) 50%, var(--skeleton-base) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite linear;
  border-radius: 6px;
}
@keyframes shimmer { to { background-position: -200% 0; } }
.skeleton--kv { height: 16px; margin: 14px 0; }
.skeleton--block { height: 72px; margin-bottom: 18px; }
.drawer-skeleton { padding: 4px 2px; }

/* ---------- Empty / error states ---------- */
.state-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: center;
  padding: 56px 24px;
}
.state-box__icon {
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  color: var(--text-muted);
  margin-bottom: 4px;
}
.state-box__icon .icon { width: 22px; height: 22px; }
.state-box h3 { font-size: var(--fs-16); font-weight: 700; }
.state-box p { font-size: var(--fs-13); color: var(--text-secondary); max-width: 420px; line-height: 1.5; }
.state-box__actions { display: flex; gap: 9px; margin-top: 10px; }
.state-box--error .state-box__icon { color: var(--danger); background: var(--danger-soft); border-color: var(--danger-border); }

/* ---------- Key-value list (drawers / workspaces) ---------- */
.kv { display: flex; flex-direction: column; }
.kv__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 34px;
  padding: 5px 0;
  border-bottom: 1px solid var(--border-soft);
  font-size: var(--fs-13);
}
.kv__row:last-child { border-bottom: none; }
.kv__label { color: var(--text-secondary); font-weight: 600; flex: none; display: inline-flex; align-items: center; gap: 7px; }
.kv__label .icon { width: 14px; height: 14px; color: var(--text-muted); }
.kv__value {
  font-weight: 600;
  text-align: right;
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  justify-content: flex-end;
}
.kv__value .mono { font-size: var(--fs-12); }

/* ---------- Secrets ---------- */
.secret { display: inline-flex; align-items: center; gap: 3px; }
.secret__mask { font-size: var(--fs-12); letter-spacing: 0.08em; }
.secret.is-revealed .secret__mask { letter-spacing: 0; color: var(--text); }

/* ---------- Section card (workspaces / pages) ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px 20px;
}
.card__title {
  font-size: var(--fs-13);
  font-weight: 700;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.card__title .muted { font-weight: 600; }

/* ---------- Banner (account-level states) ---------- */
.banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  font-size: var(--fs-13);
  font-weight: 600;
  margin-bottom: 14px;
  border: 1px solid;
}
.banner .icon { width: 16px; height: 16px; flex: none; }
.banner--warn { background: var(--warn-soft); border-color: var(--warn-border); color: var(--warn-text); }
.banner--danger { background: var(--danger-soft); border-color: var(--danger-border); color: var(--danger-text); }
.banner--info { background: var(--blue-soft); border-color: var(--blue-border-soft); color: var(--info-text); }
.banner__spacer { flex: 1; }

/* ---------- Keyboard hint ---------- */
kbd {
  display: inline-block;
  padding: 1px 6px;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--surface-2);
  font-family: var(--font);
  font-size: var(--fs-11);
  font-weight: 700;
  color: var(--text-secondary);
}

/* ---------- Plan tier badge / Ultra gate (neutral commercial state) ---------- */
.plan-tier-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 1px 7px;
  border-radius: var(--radius-sm);
  font-size: var(--fs-11);
  font-weight: 700;
  letter-spacing: 0.01em;
  line-height: 1.4;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-secondary);
  white-space: nowrap;
  flex: none;
}
.plan-tier-badge--ultra {
  color: var(--blue);
  border-color: var(--blue-border);
  background: var(--blue-soft);
}
.plan-tier-badge--free {
  color: var(--text-muted);
  border-color: var(--border-soft);
  background: var(--surface-2);
}
.plan-tier-badge--compact {
  padding: 0 6px;
  font-size: var(--fs-10, 10px);
}

.plan-preview-badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 7px;
  border-radius: var(--radius-sm);
  font-size: var(--fs-11);
  font-weight: 700;
  color: var(--text-muted);
  border: 1px dashed var(--border);
  background: transparent;
}

.plan-locked-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.plan-locked-head__title {
  font-size: var(--fs-13);
  font-weight: 700;
  color: var(--text);
}
.plan-locked-head__sub {
  flex: 1 1 100%;
  margin: 0;
  font-size: var(--fs-12);
  color: var(--text-muted);
  font-weight: 500;
}

.plan-locked-section {
  position: relative;
  cursor: pointer;
  border-radius: var(--radius-md);
  outline: none;
}
.plan-locked-section:focus-visible {
  box-shadow: 0 0 0 2px var(--blue-border);
}
.plan-locked-section::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(180deg, transparent 0%, rgba(255, 255, 255, 0.35) 100%);
  pointer-events: none;
}
[data-theme="dark"] .plan-locked-section::after {
  background: linear-gradient(180deg, transparent 0%, rgba(0, 0, 0, 0.25) 100%);
}

.plan-locked-control {
  cursor: pointer;
}
.plan-locked-control[aria-disabled="true"] {
  opacity: 0.72;
}
/* Switch uses a visually-hidden checkbox; never let lock styles reveal it. */
.switch input.plan-locked-control,
.switch input.plan-locked-control[aria-disabled="true"],
.auto-switch input.plan-locked-control,
.auto-switch input.plan-locked-control[aria-disabled="true"] {
  opacity: 0;
  pointer-events: none;
}
.switch.plan-locked-control,
.auto-switch.plan-locked-control {
  opacity: 0.72;
  cursor: pointer;
}

.plan-unlock-cta {
  margin-top: 8px;
}

.plan-gate {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 4px 2px 2px;
}
.plan-gate__eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.plan-gate__eyebrow-label {
  font-size: var(--fs-12);
  font-weight: 600;
  color: var(--text-muted);
}
.plan-gate__title {
  margin: 0;
  font-size: var(--fs-16);
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
}
.plan-gate__benefit,
.plan-gate__secondary {
  margin: 0;
  font-size: var(--fs-13);
  color: var(--text-secondary);
  line-height: 1.45;
  font-weight: 500;
}
.plan-gate__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}

.plan-paused-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-12);
  font-weight: 600;
  color: var(--text-muted);
}
.plan-paused-tag::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--neutral);
  flex: none;
}

.banner--plan {
  background: var(--blue-soft);
  border-color: var(--blue-border-soft);
  color: var(--text-secondary);
  flex-wrap: wrap;
}
.banner--plan .banner__title {
  color: var(--text);
  font-weight: 700;
}
.banner--plan .banner__copy { flex: 1; min-width: 0; }
.banner--plan .banner__sub,
.banner--plan .banner__secondary {
  font-size: var(--fs-12);
  font-weight: 500;
  color: var(--text-muted);
  margin-top: 2px;
}

.plan-free-quota {
  margin-bottom: 14px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-2);
}
.plan-free-quota__top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: var(--fs-12);
  font-weight: 600;
  margin-bottom: 8px;
}
.plan-free-quota__label { color: var(--text-secondary); }
.plan-free-quota__vals { color: var(--text); }
.plan-free-quota__bar {
  height: 6px;
  border-radius: 999px;
  background: var(--border-soft);
  overflow: hidden;
}
.plan-free-quota__fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--blue);
}
.plan-free-quota[data-band="warning"] .plan-free-quota__fill { background: var(--warn); }
.plan-free-quota[data-band="critical"] .plan-free-quota__fill,
.plan-free-quota[data-band="exhausted"] .plan-free-quota__fill { background: var(--blue); }
.plan-free-quota__meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 6px;
  font-size: var(--fs-11);
  color: var(--text-muted);
  font-weight: 600;
}

/* Masked date/time text inputs (DD/MM/YYYY + HH:mm) */
.dt-field,
.dt-input--date,
.dt-input--time {
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
  caret-color: var(--blue, #2563eb);
}
.dt-input--date { min-width: 9.5rem; }
.dt-input--time { min-width: 4.75rem; text-align: center; }
.dt-field.dt-seg--day,
.dt-field.dt-seg--month,
.dt-field.dt-seg--year,
.dt-field.dt-seg--hour,
.dt-field.dt-seg--minute {
  background-image: linear-gradient(
    to bottom,
    transparent calc(100% - 2px),
    color-mix(in srgb, var(--blue) 35%, transparent) calc(100% - 2px)
  );
}
.dt-field.is-invalid,
.dt-input--date.is-invalid,
.dt-input--time.is-invalid {
  color: var(--danger, #dc2626);
}
.pp-expiry-dt .dt-input--date,
.pp-expiry-dt .dt-input--time,
.cp-grid-2 .dt-input--date,
.cp-grid-2 .dt-input--time {
  width: 100%;
}

/* Unified Expiration date-time picker */
.dtp {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.dtp__label {
  font-size: var(--fs-12);
  font-weight: 700;
  color: var(--text);
}
.dtp__control {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  min-width: 0;
  height: 38px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  transition: border-color 0.12s, box-shadow 0.12s;
}
.dtp__control:hover {
  border-color: var(--border-strong, var(--border));
}
.dtp.is-open .dtp__control,
.dtp__control:focus-within {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--blue-soft);
}
.dtp__input {
  width: 100%;
  height: 100%;
  padding: 0 36px 0 11px;
  border: none !important;
  border-radius: inherit;
  background: transparent !important;
  box-shadow: none !important;
  font-size: 13px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  caret-color: var(--blue, #2563eb);
  color: var(--text);
}
.dtp__input:focus {
  outline: none;
  box-shadow: none !important;
}
.dtp__input.dt-field.dt-seg--day,
.dtp__input.dt-field.dt-seg--month,
.dtp__input.dt-field.dt-seg--year,
.dtp__input.dt-field.dt-seg--hour,
.dtp__input.dt-field.dt-seg--minute {
  background-image: none;
}
.dtp__input::selection {
  background: color-mix(in srgb, var(--blue) 28%, transparent);
  color: var(--blue);
}
.dtp__cal-btn {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}
.dtp__cal-btn:hover,
.dtp.is-open .dtp__cal-btn {
  background: var(--blue-soft);
  color: var(--blue);
}
.dtp__cal-btn .icon {
  width: 15px;
  height: 15px;
}
.dtp.is-invalid .dtp__control {
  border-color: var(--danger-border, var(--danger));
}
.dtp.is-invalid .dtp__control:focus-within {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 18%, transparent);
}
.dtp.is-invalid .dtp__input,
.dtp__input.is-invalid {
  border-color: transparent;
}
.dtp__error {
  margin: 0;
  font-size: 11px;
}
.dtp__error[hidden] { display: none !important; }

.popover--dtp {
  padding: 0;
  width: 280px;
  max-width: calc(100vw - 24px);
  /* Sit above Custom range / host popovers when stacked. */
  z-index: calc(var(--z-drawer-popover, var(--z-dropdown)) + 2);
}
.dtp-pop__shell {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
}
.dtp-pop__nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}
.dtp-pop__navbtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  flex: none;
}
.dtp-pop__navbtn:hover {
  background: var(--hover);
  color: var(--text);
}
.dtp-pop__navbtn .icon {
  width: 15px;
  height: 15px;
}
.dtp-pop__nav-title {
  font-size: var(--fs-13);
  font-weight: 700;
  color: var(--text);
}
.dtp-pop__nav-links {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}
.dtp-pop__nav-link {
  border: none;
  background: transparent;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  font-size: var(--fs-13);
  font-weight: 700;
  color: var(--text);
  cursor: pointer;
}
.dtp-pop__nav-link:hover {
  background: var(--blue-soft);
  color: var(--blue);
}
.dtp-pop__week,
.dtp-pop__grid--days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}
.dtp-pop__wd {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 22px;
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
}
.dtp-pop__day,
.dtp-pop__cell {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 30px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  font-size: var(--fs-12);
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
}
.dtp-pop__day:hover,
.dtp-pop__cell:hover {
  background: var(--blue-soft);
  color: var(--blue);
}
.dtp-pop__day.is-outside {
  color: var(--text-muted);
  opacity: 0.5;
}
.dtp-pop__day.is-today:not(.is-selected),
.dtp-pop__cell.is-today:not(.is-selected) {
  border-color: var(--blue-border-soft, var(--blue-border));
  color: var(--blue);
}
.dtp-pop__day.is-selected,
.dtp-pop__cell.is-selected {
  background: var(--blue);
  border-color: var(--blue);
  color: var(--text-on-blue, #fff);
}
.dtp-pop__day.is-selected:hover,
.dtp-pop__cell.is-selected:hover {
  background: var(--blue);
  color: var(--text-on-blue, #fff);
}
.dtp-pop__day.is-past {
  opacity: 0.35;
}
.dtp-pop__day.is-disabled {
  opacity: 0.35;
  pointer-events: none;
  cursor: default;
}
.dtp-pop__day:focus-visible,
.dtp-pop__cell:focus-visible,
.dtp-pop__nav-link:focus-visible,
.dtp-pop__navbtn:focus-visible,
.dtp-pop__time-input:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 1px;
}
.dtp-pop__grid--months {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
}
.dtp-pop__grid--years {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
}
.dtp-pop__time {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}
.dtp-pop__time-label {
  font-size: var(--fs-12);
  font-weight: 700;
  color: var(--text);
}
.dtp-pop__time-fields {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.dtp-pop__time-seg {
  min-width: 40px;
  height: 32px;
  padding: 0 8px;
  text-align: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: var(--fs-13);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  cursor: pointer;
}
.dtp-pop__time-seg:hover {
  border-color: var(--blue-border);
  background: var(--blue-soft);
  color: var(--blue);
}
.dtp-pop__time-seg:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 1px;
}
.dtp-pop__time-input {
  width: 40px;
  height: 32px;
  text-align: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: var(--fs-13);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.dtp-pop__time-input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--blue-soft);
  outline: none;
}
.dtp-pop__time-sep {
  font-weight: 700;
  color: var(--text-secondary);
}

.cp-exp-panel .dtp,
.pp-expiry-dt .dtp,
.port-qsettings__custom-dt .dtp {
  width: 100%;
}
.cp-exp-panel .dtp__control {
  height: 28px;
}
.cp-exp-panel .dtp__input.cp-input {
  border: none;
  background: transparent;
  box-shadow: none;
  height: 100%;
}
.cp-presets .cp-preset.is-active,
.pp-chips .pp-chip.is-active {
  border-color: var(--blue-border);
  background: var(--blue-soft);
  color: var(--blue);
}
/* Help & Support */
.support-panel { color: var(--text); }
.support-intro { margin: 0 0 16px; color: var(--text-secondary, #526176); line-height: 1.6; }
.support-hours { margin: 0 0 16px; font-size: 13px; }
.support-contacts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.support-contacts--single { grid-template-columns: 1fr; }
.support-contact { padding: 18px; border: 1px solid var(--border, #dce2eb); border-radius: 12px; display: flex; flex-direction: column; align-items: flex-start; }
.support-contact h3 { margin: 0; font-size: 15px; }
.support-contact p { margin: 8px 0 18px; font-size: 13px; line-height: 1.6; color: var(--text-secondary, #526176); flex: 1; }
.support-contact .btn { width: 100%; }
.support-contact .btn svg, .support-status svg { width: 16px; height: 16px; }
.support-guides-title { margin: 24px 0 12px; font-size: 15px; }
.support-guides details { border-bottom: 1px solid var(--border, #dce2eb); }
.support-guides summary { padding: 14px 0; cursor: pointer; font-weight: 600; font-size: 14px; }
.support-guides p { margin: 0 0 16px; font-size: 13px; line-height: 1.7; color: var(--text-secondary, #526176); }
.support-status { display: inline-flex; align-items: center; gap: 8px; margin-top: 20px; }
@media (max-width: 520px) { .support-contacts { grid-template-columns: 1fr; } }
.popover--columns .filter-panel__columns { display: block; }
.popover--columns .columns-presets { display: flex; gap: 8px; margin-bottom: 20px; }
.popover--columns .columns-presets .filter-quick { flex: 1; justify-content: center; }
.popover--columns .columns-options-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.popover--columns .columns-options-grid .filter-quick { display: flex; align-items: center; gap: 10px; background: transparent; }
.popover--columns .columns-options-grid .filter-quick::before { content: ''; width: 16px; height: 16px; flex: 0 0 16px; border: 1px solid var(--border-strong); border-radius: 4px; text-align: center; line-height: 16px; }
.popover--columns .columns-options-grid .filter-quick.is-active::before { content: '✓'; color: var(--text-on-blue); background: var(--blue); border-color: var(--blue); }
.popover--columns .columns-footer { border-top: 1px solid var(--border); padding-top: 12px; margin-top: 12px; }
@media (max-width: 480px) {
  .popover--columns .columns-presets { flex-wrap: wrap; }
  .popover--columns .columns-options-grid { gap: 12px; }
}
.copy-confirmation { position: fixed; z-index: 10000; pointer-events: none; padding: 5px 9px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface-elevated); color: var(--text-secondary); font-size: 12px; line-height: 18px; font-weight: 500; opacity: 0; transform: translateY(2px); transition: opacity 140ms ease, transform 140ms ease; }
.copy-confirmation.is-visible { opacity: 1; transform: translateY(0); }
@media (prefers-reduced-motion: reduce) { .copy-confirmation { transition: none; transform: none; } }
