/* Admin only: settings modal fills the workspace to the right of the icon rail, and the rail stays visible and clickable.
   html.ma-admin-ui is set only for administrators (see rail-account.html). Desktop widths only. */
@media (min-width: 769px) {
  html.ma-admin-ui body:has(.modal.show .modal-inner.settings-modal) .modal-backdrop {
    left: var(--ma-rail-width, 62px) !important;
    width: calc(100% - var(--ma-rail-width, 62px)) !important;
  }

  /* The modal container must start after the rail, otherwise it blocks the rail's clicks. */
  html.ma-admin-ui body:has(.modal.show .modal-inner.settings-modal) .modal.show {
    inset: 0 0 0 var(--ma-rail-width, 62px) !important;
    width: calc(100dvw - var(--ma-rail-width, 62px)) !important;
    height: 100dvh !important;
  }

  /* .modal-inner is position: fixed, so its offsets are relative to the viewport. */
  html.ma-admin-ui body:has(.modal.show .modal-inner.settings-modal) .modal.show > .modal-inner {
    left: var(--ma-rail-width, 62px) !important;
    top: 0 !important;
    right: auto !important;
    bottom: auto !important;
    transform: none !important;
    width: calc(100dvw - var(--ma-rail-width, 62px)) !important;
    height: 100dvh !important;
    max-width: none !important;
    max-height: none !important;
    min-width: 0 !important;
    min-height: 0 !important;
    margin: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
  }

  /* Header height matches the rail avatar (40 px). */
  html.ma-admin-ui body:has(.modal.show .modal-inner.settings-modal) .modal.show > .modal-inner > .modal-header {
    height: 40px !important;
    min-height: 40px !important;
    max-height: 40px !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
  }

  /* Limits popup must not open over the settings tabs. */
  html.ma-admin-ui body:has(.modal.show .modal-inner.settings-modal) .ma-quota-overlays {
    display: none !important;
  }

  /* Rail labels that expand on hover would slide under the settings panel: hide them while settings are open. */
  html.ma-admin-ui body:has(.modal.show .modal-inner.settings-modal) .ma-command-rail .ma-rail-action span {
    display: none !important;
  }

  /* Header lines up with the rail logo (14px + 31px + 14px); title centred on that line. */
  html.ma-admin-ui body:has(.modal.show .modal-inner.settings-modal) .modal.show > .modal-inner > .modal-header {
    display: flex !important;
    align-items: center !important;
    height: 59px !important;
    min-height: 59px !important;
    max-height: 59px !important;
  }

  /* Close control: red exit (door) icon instead of the cross. */
  html.ma-admin-ui body:has(.modal.show .modal-inner.settings-modal) .modal.show > .modal-inner > .modal-header .modal-close {
    font-size: 0 !important;
    color: transparent !important;
    width: 34px !important;
    height: 34px !important;
    border-radius: 8px !important;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23ef4444' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4'/%3E%3Cpolyline points='16 17 21 12 16 7'/%3E%3Cline x1='21' y1='12' x2='9' y2='12'/%3E%3C/svg%3E") center / 20px 20px no-repeat !important;
  }

  /* Tariffs tab: centred heading and compact cards so the whole tab fits the screen. */
  html.ma-admin-ui body:has(.modal.show .modal-inner.settings-modal) .ma-tariff-section .ma-title {
    text-align: center !important;
  }
  html.ma-admin-ui body:has(.modal.show .modal-inner.settings-modal) .ma-tariff-section .ma-title p {
    margin-left: auto !important;
    margin-right: auto !important;
  }
  html.ma-admin-ui body:has(.modal.show .modal-inner.settings-modal) .ma-tariff-section .ma-pricing-grid {
    zoom: 0.8;
  }
}

/* Admin credits and resets block (Settings → Tariff): compact, purple accents. Layout only. */
.ma-credit-panel { display: grid !important; gap: 12px; margin-top: 18px !important; padding: 16px !important; }
.ma-credit-panel > .ma-title { margin: 0; }
.ma-credit-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.ma-credit-card { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 10px; border: 1px solid var(--border); border-radius: 12px; text-align: center; }
.ma-credit-card > span { font-size: .74rem; color: var(--text-secondary); }
.ma-credit-card > b { font-size: 1.05rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.ma-credit-card > button { margin-top: auto; padding: 6px 16px; border: 0; border-radius: 999px; background: var(--primary); color: #fff; font: inherit; font-size: .76rem; font-weight: 600; cursor: pointer; }
.ma-credit-card > button:disabled { opacity: .5; cursor: default; }
.ma-credit-card.is-off { opacity: .55; }
.ma-credit-topup-block { display: grid; gap: 8px; padding-top: 12px; border-top: 1px solid var(--border); }
.ma-credit-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; font-size: .78rem; color: var(--text-secondary); }
.ma-credit-head b { color: var(--text); font-weight: 700; font-variant-numeric: tabular-nums; }
.ma-credit-how { margin: 0; font-size: .74rem; color: var(--text-secondary); }
.ma-credit-slider { display: flex; align-items: center; gap: 12px; }
.ma-credit-slider input[type="range"] { flex: 1; -webkit-appearance: none; appearance: none; height: 18px; margin: 0; background: transparent; cursor: pointer; }
.ma-credit-slider input[type="range"]:focus { outline: none; }
.ma-credit-slider input[type="range"]::-webkit-slider-runnable-track { height: 4px; border-radius: 999px; background: linear-gradient(to right, var(--primary) var(--fill, 0%), var(--border) var(--fill, 0%)); }
.ma-credit-slider input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; margin-top: -6px; border-radius: 50%; background: var(--primary); border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--primary); }
.ma-credit-slider input[type="range"]::-moz-range-track { height: 4px; border-radius: 999px; background: var(--border); }
.ma-credit-slider input[type="range"]::-moz-range-progress { height: 4px; border-radius: 999px; background: var(--primary); }
.ma-credit-slider input[type="range"]::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: var(--primary); border: 2px solid var(--surface); }
.ma-credit-slider b { min-width: 84px; text-align: right; font-size: .9rem; font-variant-numeric: tabular-nums; }
.ma-credit-buy { justify-self: center; padding: 8px 20px; border: 0; border-radius: 10px; background: var(--primary); color: #fff; font: inherit; font-weight: 600; cursor: pointer; }
.ma-credit-buy:disabled { opacity: .5; cursor: default; }
.ma-credit-error { margin: 0; font-size: .8rem; color: #dc2626; text-align: center; }
@media (max-width: 560px) {
  .ma-credit-panel { padding: 12px !important; }
  .ma-credit-cards { grid-template-columns: minmax(0, 1fr); }
  .ma-credit-head { flex-direction: column; gap: 2px; }
}