/* ==========================================================================
   SETTINGS / ACCOUNT PAGES  (assets/css/settings.css)
   --------------------------------------------------------------------------
   Used by settings-profile.php, settings-account-defaults.php,
   settings-users.php, account-billing.php.

   1. Layout          .settings  (left menu + content)
   2. Settings menu   .settings-nav  .sn-*
   3. Page head/tabs  .set-head  .set-tabs  .set-tab
   4. Sections        .set-card  .set-grid  .set-row
   5. Controls        .switch  .set-select  .color-field
   6. Save bar        .save-bar
   7. Users table     .set-toolbar  .user-cell  .row-menu
   8. Billing         .plan-card  .meter  .kv
   9. Modal           dialog.set-modal
   ========================================================================== */

/* 1. LAYOUT ---------------------------------------------------------------- */
.settings {
  display: grid;
  grid-template-columns: 264px minmax(0, 1fr);
  gap: var(--sp-8);
  align-items: start;
}
.settings__main { min-width: 0; padding-bottom: 80px; }

/* 2. SETTINGS MENU -------------------------------------------------------- */
.settings-nav {
  position: sticky;
  top: calc(var(--header-h) + var(--sp-4));
  max-height: calc(100vh - var(--header-h) - var(--sp-8));
  overflow-y: auto;
  padding-right: var(--sp-2);
}
.settings-nav__head { margin-bottom: var(--sp-4); }
.settings-nav__back { display: inline-flex; align-items: center; gap: 6px; font-size: 13.5px; margin-bottom: var(--sp-2); }
.settings-nav__title { font-size: 22px; }
.settings-nav__mobile { display: none; }

.settings-nav__search {
  display: flex; align-items: center; gap: 8px;
  height: 40px; padding: 0 12px; margin-bottom: var(--sp-5);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text-subtle);
}
.settings-nav__search:focus-within { border-color: var(--brand); box-shadow: var(--focus-ring); }
.settings-nav__search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; font-size: 14px; color: var(--text); }

.sn-section { margin-bottom: var(--sp-5); }
.sn-heading { font-size: 15px; font-weight: 700; color: var(--text); padding: 4px 12px 8px; }
.sn-link {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  width: 100%; min-height: 40px; padding: 8px 12px;
  font-size: 15px; color: var(--text); text-align: left;
  border-radius: var(--radius-sm);
  transition: background-color var(--fast) var(--ease), color var(--fast) var(--ease);
}
.sn-link:hover { background: var(--surface-hover); }
.sn-link:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.sn-link.is-active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.sn-link--child { padding-left: 24px; font-size: 14px; color: var(--text-muted); min-height: 36px; }
.sn-chev { color: var(--text-muted); transition: transform var(--fast) var(--ease); }
.sn-toggle[aria-expanded="true"] .sn-chev { transform: rotate(180deg); }
.sn-sub { padding: 2px 0 4px; }
.sn-empty { padding: 8px 12px; color: var(--text-subtle); font-size: 14px; }

/* 3. PAGE HEAD + TABS ----------------------------------------------------- */
.set-head {
  display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between;
  gap: var(--sp-4); margin-bottom: var(--sp-5);
}
.set-head__title { font-size: clamp(22px, 1.1rem + 1vw, 28px); }
.set-head__sub { margin-top: 4px; color: var(--text-muted); }
.set-head__actions { display: flex; flex-wrap: wrap; gap: var(--sp-2); }

.set-tabs {
  display: flex; gap: var(--sp-6);
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--sp-6);
  overflow-x: auto; white-space: nowrap;
  scrollbar-width: none;
}
.set-tabs::-webkit-scrollbar { display: none; }
.set-tab {
  padding: 10px 0; font-size: 14.5px; font-weight: 500; color: var(--text-muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.set-tab:hover { color: var(--text); }
.set-tab.active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }
.set-tab:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: 4px; }

/* 4. SECTIONS ------------------------------------------------------------- */
.set-card { margin-bottom: var(--sp-5); }
.set-card__head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: var(--sp-3); margin-bottom: var(--sp-5); }
.set-card__title { font-size: 17px; font-weight: 700; }
.set-card__sub { margin-top: 4px; color: var(--text-muted); font-size: 14px; max-width: 640px; }
.set-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-5) var(--sp-6); }
.set-grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.set-grid .field { align-content: start; }
.set-grid .field--full { grid-column: 1 / -1; }
.field__help { font-size: 12.5px; color: var(--text-subtle); }
.input[readonly] { background: var(--surface-2); color: var(--text-muted); }
textarea.input { height: auto; min-height: 96px; padding: 12px 14px; resize: none; }

/* row: text on the left, control on the right */
.set-row {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4);
  padding: var(--sp-4) 0; border-top: 1px solid var(--border);
}
.set-row:first-child { border-top: 0; padding-top: 0; }
.set-row:last-child { padding-bottom: 0; }
.set-row__title { font-weight: 600; }
.set-row__desc { font-size: 13.5px; color: var(--text-muted); margin-top: 2px; }

.photo-row { display: flex; align-items: center; gap: var(--sp-5); margin-bottom: var(--sp-6); flex-wrap: wrap; }
.photo-row__img {
  width: 80px; height: 80px; border-radius: 50%; overflow: hidden; flex: none;
  display: grid; place-items: center;
  background: var(--gradient-1); color: #fff; font-size: 26px; font-weight: 700;
}
.photo-row__img img { width: 100%; height: 100%; object-fit: cover; }
.photo-row__actions { display: flex; gap: var(--sp-2); flex-wrap: wrap; }

.copy-field { display: flex; gap: var(--sp-2); }
.copy-field .input { flex: 1; }

/* connected account rows (email / calendar) */
.connect-row { display: flex; align-items: center; gap: var(--sp-4); }
.connect-row__icon {
  width: 44px; height: 44px; border-radius: var(--radius); flex: none;
  display: grid; place-items: center; background: var(--brand-soft); color: var(--brand);
}
.connect-row__body { flex: 1; min-width: 0; }

/* 5. CONTROLS ------------------------------------------------------------- */
.switch { position: relative; display: inline-flex; flex: none; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch__track {
  width: 42px; height: 24px; border-radius: var(--radius-pill);
  background: var(--border-strong); position: relative;
  transition: background-color var(--fast) var(--ease);
}
.switch__track::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 18px; height: 18px; border-radius: 50%; background: #fff;
  box-shadow: var(--shadow-sm); transition: transform var(--fast) var(--ease);
}
.switch input:checked + .switch__track { background: var(--brand); }
.switch input:checked + .switch__track::after { transform: translateX(18px); }
.switch input:focus-visible + .switch__track { box-shadow: var(--focus-ring); }

select.input {
  padding-right: 40px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%238a94a6' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m4 6 4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center;
}

.color-field { display: flex; align-items: center; gap: var(--sp-3); }
.color-field input[type="color"] {
  width: 46px; height: 46px; padding: 3px; flex: none; cursor: pointer;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface);
}

.logo-drop {
  display: grid; place-items: center; gap: 6px; text-align: center;
  padding: var(--sp-8) var(--sp-4); border: 2px dashed var(--border-strong);
  border-radius: var(--radius-lg); color: var(--text-muted); cursor: pointer;
  transition: border-color var(--fast) var(--ease), background-color var(--fast) var(--ease);
}
.logo-drop:hover, .logo-drop.is-over { border-color: var(--brand); background: var(--brand-soft); }
.logo-drop img { max-height: 64px; width: auto; }

/* 6. SAVE BAR (appears when a form changes) ------------------------------- */
.save-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
  display: flex; align-items: center; justify-content: flex-end; gap: var(--sp-3);
  padding: var(--sp-3) clamp(16px, 3vw, 40px);
  background: var(--surface); border-top: 1px solid var(--border); box-shadow: var(--shadow-lg);
  transform: translateY(110%); visibility: hidden;
  transition: transform var(--slow) var(--ease), visibility 0s linear var(--slow);
}
.save-bar.is-visible { transform: none; visibility: visible; transition: transform var(--slow) var(--ease), visibility 0s; }
.save-bar__text { margin-right: auto; color: var(--text-muted); font-size: 14px; }

/* 7. USERS ---------------------------------------------------------------- */
.set-toolbar { display: flex; flex-wrap: wrap; gap: var(--sp-3); align-items: center; margin-bottom: var(--sp-4); }
.set-toolbar .settings-nav__search { margin: 0; width: 280px; max-width: 100%; height: 40px; }
.set-toolbar select.input { width: auto; height: 40px; font-size: 14px; }
.set-toolbar__count { margin-left: auto; color: var(--text-muted); font-size: 14px; }

.set-table-card { padding: 0; overflow-x: auto; position: relative; }
.set-table { width: 100%; border-collapse: collapse; min-width: 760px; }
.set-table th {
  background: var(--surface-2); text-align: left; white-space: nowrap;
  font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em;
  color: var(--text-subtle); padding: 12px 14px;
}
.set-table td { padding: 12px 14px; border-top: 1px solid var(--border); vertical-align: middle; }
.set-table tbody tr:hover td { background: var(--surface-hover); }
.set-table .col-check { width: 44px; }
.set-table .col-actions { width: 1%; text-align: right; white-space: nowrap; }
.set-table tr.is-inactive td { color: var(--text-subtle); }

.user-cell { display: flex; align-items: center; gap: var(--sp-3); }
.user-cell__name { font-weight: 600; }
.user-cell__email { font-size: 13px; color: var(--text-muted); }
.set-table td:nth-child(n+3) { white-space: nowrap; }

.row-menu { position: relative; display: inline-block; }
.row-menu__list {
  position: fixed; z-index: 80; min-width: 170px;   /* placed by settings.js so the table's scroll box can't clip it */
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); padding: 6px; text-align: left;
}
.row-menu__list button {
  display: block; width: 100%; padding: 8px 10px; border-radius: 6px; font-size: 14px; text-align: left;
}
.row-menu__list button:hover { background: var(--surface-hover); }
.row-menu__list .is-danger { color: var(--danger); }

.team-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: var(--sp-4); }
.team-card__members { display: flex; margin-top: var(--sp-3); }
.team-card__members .avatar { margin-left: -8px; border: 2px solid var(--surface); }
.team-card__members .avatar:first-child { margin-left: 0; }

/* 8. BILLING -------------------------------------------------------------- */
.bill-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--sp-4); margin-bottom: var(--sp-5); }
.bill-stat__label { font-size: 13.5px; color: var(--text-muted); }
.bill-stat__value { font-size: 24px; font-weight: 700; margin-top: 4px; letter-spacing: -.02em; }
.bill-stat__meta { font-size: 13px; color: var(--text-subtle); margin-top: 4px; }

.plan-card { display: flex; flex-wrap: wrap; gap: var(--sp-5); align-items: center; justify-content: space-between; }
.plan-card__name { font-size: 20px; font-weight: 700; }

.meter-row + .meter-row { margin-top: var(--sp-5); }
.meter-row__head { display: flex; justify-content: space-between; gap: var(--sp-3); font-size: 14px; }
.meter-row__head span:last-child { color: var(--text-muted); }
.meter { height: 8px; border-radius: var(--radius-pill); background: var(--surface-3); overflow: hidden; margin-top: 8px; }
.meter__bar { display: block; height: 100%; width: var(--p, 0%); background: var(--brand); border-radius: inherit; }
.meter__bar--warn { background: var(--accent); }
.meter__bar--full { background: var(--danger); }

.kv { display: grid; grid-template-columns: 180px 1fr; gap: 12px var(--sp-4); font-size: 14px; }
.kv dt { color: var(--text-muted); }
.kv dd { margin: 0; font-weight: 500; }

.pay-card { display: flex; align-items: center; gap: var(--sp-4); }
.pay-card__brand {
  width: 52px; height: 36px; border-radius: 6px; flex: none;
  display: grid; place-items: center; font-size: 11px; font-weight: 800; letter-spacing: .04em;
  background: var(--gradient-2); color: #fff;
}

/* 9. MODAL ---------------------------------------------------------------- */
dialog.set-modal {
  width: min(520px, calc(100vw - 32px)); padding: 0; border: 0;
  border-radius: var(--radius-lg); background: var(--surface); color: var(--text);
  box-shadow: var(--shadow-lg);
}
dialog.set-modal::backdrop { background: rgba(10, 15, 28, .55); }
.set-modal__head { display: flex; align-items: center; justify-content: space-between; padding: var(--sp-5) var(--sp-6); border-bottom: 1px solid var(--border); }
.set-modal__title { font-size: 18px; }
.set-modal__body { display: grid; gap: var(--sp-4); padding: var(--sp-6); }
.set-modal__foot { display: flex; justify-content: flex-end; gap: var(--sp-2); padding: var(--sp-4) var(--sp-6); border-top: 1px solid var(--border); }


/* 10. ACCOUNT DEFAULTS (HubSpot-style single column) ---------------------- */
.set-tabs--boxed { gap: 0; border-bottom: 1px solid var(--border-strong); margin-bottom: var(--sp-5); }
.set-tabs--boxed .set-tab {
  padding: 12px 22px; margin-bottom: -1px;
  border: 1px solid var(--border-strong); border-left-width: 0; border-bottom-width: 1px;
  background: var(--surface-2); color: var(--text-muted);
}
.set-tabs--boxed .set-tab:first-child { border-left-width: 1px; border-top-left-radius: var(--radius-sm); }
.set-tabs--boxed .set-tab:last-child { border-top-right-radius: var(--radius-sm); }
.set-tabs--boxed .set-tab:hover { background: var(--surface-hover); color: var(--text); }
.set-tabs--boxed .set-tab.active { background: var(--bg); color: var(--text); border-bottom-color: var(--bg); font-weight: 600; }

.set-intro { color: var(--text-muted); padding-bottom: var(--sp-5); margin-bottom: var(--sp-6); border-bottom: 1px solid var(--border); }
/* Form fields sit two per row (same on every settings page); headings, help blocks and
   anything that is not a .field (or a .field--full) take the whole row. One column on phones. */
.set-stack { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-5); max-width: 980px; align-items: start; }
.set-stack > :not(.field), .set-stack > .field--full { grid-column: 1 / -1; }
@media (max-width: 767.98px) { .set-stack { grid-template-columns: minmax(0, 1fr); } }
.set-block { margin-top: var(--sp-3); }
.set-block--wide { max-width: 760px; margin-bottom: var(--sp-8); }
.set-block__title { font-size: 20px; font-weight: 600; letter-spacing: -.01em; }
.set-block__sub { margin-top: 4px; color: var(--text-muted); font-size: 14px; line-height: 1.55; }

.set-label { display: inline-flex; align-items: center; gap: 6px; }
.set-info { position: relative; display: inline-grid; place-items: center; color: var(--text-subtle); cursor: help; border-radius: 50%; }
.set-info:hover, .set-info:focus-visible { color: var(--brand); outline: none; }
.set-info::after {
  content: attr(data-tip-text); position: absolute; left: 50%; bottom: calc(100% + 8px); transform: translateX(-50%);
  width: max-content; max-width: 260px; padding: 8px 10px; border-radius: var(--radius-sm);
  background: var(--text); color: var(--bg); font-size: 12.5px; font-weight: 500; line-height: 1.4; white-space: normal;
  display: none; pointer-events: none; z-index: 30;
}
.set-info:hover::after, .set-info:focus-visible::after { display: block; }
.set-format-preview { margin-top: -2px; font-weight: 600; color: var(--text-muted); }

.font-row { display: flex; gap: var(--sp-2); align-items: center; }
.font-row .input { flex: 1; }
.font-row .font-row__size { flex: 0 0 104px; }
.font-row__color { width: 46px; height: 46px; padding: 3px; flex: none; cursor: pointer; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); }
.font-preview { margin-top: var(--sp-2); padding: var(--sp-3) var(--sp-4); border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); }

.fx-card { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4); }
.switch-labeled { display: inline-flex; align-items: center; gap: 10px; font-size: 13px; font-weight: 700; color: var(--text-muted); cursor: pointer; }

.check-row { display: flex; align-items: center; gap: 10px; margin-top: var(--sp-4); cursor: pointer; }
.check-row__note { margin: 6px 0 0 30px; }

.profile-list { display: grid; gap: var(--sp-2); max-width: 560px; margin-top: var(--sp-4); }
.profile-list:empty { display: none; }
.profile-item { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); padding: 12px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }

@media (max-width: 767.98px) {
  .set-tabs--boxed .set-tab { padding: 10px 14px; }
  .fx-card { align-items: flex-start; }
  .set-info::after { left: auto; right: -40px; transform: none; }
}


/* 11. USERS & TEAMS (HubSpot-style users table) --------------------------- */
.ut-intro { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--sp-3) var(--sp-5); margin-bottom: var(--sp-5); }
.ut-intro p { flex: 1 1 360px; color: var(--text-muted); }
.ut-ext { display: inline-flex; align-items: center; gap: 4px; }
.ut-intro .btn-crm .icon, .ut-name .btn-crm .icon { margin-left: 2px; }

.ut-shell { border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); overflow: hidden; }
.ut-views { display: flex; overflow-x: auto; background: var(--surface-2); border-bottom: 1px solid var(--border); scrollbar-width: none; }
.ut-views::-webkit-scrollbar { display: none; }
.ut-view {
  display: inline-flex; align-items: center; gap: 8px; flex: none;
  padding: 12px 20px; font-size: 14px; font-weight: 500; color: var(--text-muted);
  border-right: 1px solid var(--border); border-bottom: 2px solid transparent; white-space: nowrap;
}
.ut-view:hover { background: var(--surface-hover); color: var(--text); }
.ut-view.is-active { background: var(--surface); color: var(--text); font-weight: 600; border-bottom-color: var(--brand); }
.ut-view:focus-visible { outline: none; box-shadow: inset var(--focus-ring); }
.ut-count {
  min-width: 24px; height: 22px; padding: 0 7px; border-radius: var(--radius-pill);
  display: inline-grid; place-items: center; font-size: 12px; font-weight: 700;
  background: var(--text); color: var(--surface);
}

.ut-filters { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--border); }
select.input.ut-pill {
  width: auto; height: 36px; padding: 0 34px 0 14px; font-size: 14px; font-weight: 600;
  border-radius: var(--radius-pill); background-color: var(--surface); background-position: right 12px center;
}
select.input.ut-pill.is-set { background-color: var(--brand-soft); border-color: var(--brand); color: var(--brand); }
.ut-clear { font-size: 14px; margin-left: var(--sp-2); }

.ut-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--sp-3); padding: var(--sp-3) var(--sp-4); }
.ut-search.settings-nav__search { margin: 0; width: 320px; max-width: 100%; height: 38px; border-radius: var(--radius-pill); }
.ut-bar__right { display: flex; gap: var(--sp-2); }
.ut-cols { min-width: 240px; }
.ut-cols__item { display: flex; align-items: center; gap: 10px; padding: 7px 10px; font-size: 14px; border-radius: 7px; cursor: pointer; }
.ut-cols__item:hover { background: var(--surface-hover); }

.ut-bulk { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-5); padding: 10px var(--sp-4); background: var(--brand-soft); border-top: 1px solid var(--border); font-size: 14px; }
.ut-danger { color: var(--danger) !important; }

.ut-table-card { border-top: 1px solid var(--border); border-radius: 0; }
.ut-table { min-width: 1400px; }
.ut-table th { white-space: nowrap; }
.ut-table td { white-space: nowrap; }
.ut-table .ut-col-name { width: 340px; min-width: 300px; }
.ut-table tr.is-menu-open td { background: var(--surface-hover); }
.ut-sort { font: inherit; color: inherit; text-transform: inherit; letter-spacing: inherit; display: inline-flex; gap: 6px; }
.ut-sort:hover { color: var(--text); }
.ut-wrap { display: block; white-space: normal; min-width: 200px; max-width: 280px; line-height: 1.45; }

.ut-name { display: flex; align-items: center; gap: 10px; min-width: 0; }
.ut-name__link { font-weight: 600; color: var(--brand-ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.ut-name__link:hover { text-decoration: underline; }
.ut-tag { flex: none; padding: 2px 8px; border-radius: var(--radius-pill); background: var(--indigo-bg); color: var(--indigo); font-size: 11.5px; font-weight: 700; }
.ut-hover { display: none; align-items: center; gap: 6px; margin-left: auto; flex: none; }
.ut-table tr:hover .ut-hover, .ut-table tr:focus-within .ut-hover, .ut-table tr.is-menu-open .ut-hover { display: inline-flex; }
.ut-table tr:hover .ut-tag, .ut-table tr:focus-within .ut-tag, .ut-table tr.is-menu-open .ut-tag { display: none; }
.ut-hover .btn-crm--sm { --btn-h: 30px; padding: 0 10px; font-size: 13px; }

.ut-invite { font-size: 13.5px; }
.ut-invite--pending { color: var(--warning); font-weight: 600; }
.ut-invite--bounced { color: var(--danger); font-weight: 600; }

.row-menu__sep { display: block; height: 1px; margin: 6px 0; background: var(--border); }
.row-menu__note { display: block; max-width: 220px; padding: 2px 10px 6px; font-size: 12px; color: var(--text-subtle); white-space: normal; }
.row-menu__list button { white-space: nowrap; }

.ut-foot { padding: 12px var(--sp-4); font-size: 13.5px; color: var(--text-muted); border-top: 1px solid var(--border); }

@media (max-width: 767.98px) {
  .ut-search.settings-nav__search { width: 100%; }
  .ut-bar__right { width: 100%; }
  .ut-bar__right > * { flex: 1; }
  .ut-bar__right .btn-crm { width: 100%; justify-content: center; }
  .ut-hover { display: inline-flex; }       /* no hover on touch: keep buttons visible */
  .ut-table tr .ut-tag { display: inline-block; }
  .ut-table .ut-col-name { width: 420px; }
}


/* 12. USERS & TEAMS - Seats / Teams / Permission sets / Presets ----------- */
.ut-lead { color: var(--text-muted); margin-bottom: var(--sp-5); max-width: 900px; }
.ut-actions-row { display: flex; justify-content: flex-end; margin-bottom: var(--sp-3); }
.ut-search--sm.settings-nav__search { width: 240px; }
button.ut-name__link { font: inherit; font-weight: 600; text-align: left; padding: 0; }
.ut-shell + .ut-shell, .seat-summary + .ut-shell { margin-top: var(--sp-5); }

.seat-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); gap: var(--sp-5); padding: var(--sp-6); text-align: center; }
.seat-sum { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.seat-sum__label { display: inline-flex; align-items: center; justify-content: center; gap: 5px; min-height: 32px; font-size: 12.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.seat-sum__value { font-size: 26px; font-weight: 700; letter-spacing: -.02em; margin-top: 4px; }
.seat-sum__meta { font-size: 12.5px; color: var(--text-muted); margin-bottom: 8px; }
.seat-sum.is-full .seat-sum__meta { color: var(--warning); font-weight: 600; }
.seat-sum .seat-sum__link { font-size: 13px; font-weight: 600; margin-top: 2px; line-height: 1.35; }
.seat-sum button.seat-sum__link { font-weight: 500; }
.seat-sum__link[disabled] { color: var(--text-subtle); cursor: not-allowed; text-decoration: none; }

.ss-table { min-width: 860px; }
.ss-who { display: flex; flex-direction: column; min-width: 0; }
.ss-who span { font-size: 12.5px; color: var(--text-muted); }
.ss-seat { font: inherit; color: var(--text); padding: 4px 8px; margin-left: -8px; border-radius: 6px; border: 1px dashed transparent; }
.ss-seat:hover { border-color: var(--border-strong); background: var(--surface-hover); }
.ss-status { display: inline-flex; align-items: center; gap: 7px; }
.ss-status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--success); flex: none; }
.ss-status--pending::before { background: var(--accent); }
.ss-status--bounced::before { background: var(--danger); }

.tt-table { min-width: 560px; }
.tt-table td:nth-child(2) { width: 55%; }
.tt-parent { display: block; font-size: 12.5px; color: var(--text-subtle); margin-top: 2px; }
.tt-none { color: var(--text-subtle); }
.tt-stack { display: inline-flex; align-items: center; }
.tt-stack .avatar { margin-left: -6px; border: 2px solid var(--surface); }
.tt-stack .avatar:first-child { margin-left: 0; }
.tt-more { margin-left: 8px; font-size: 13px; font-weight: 600; color: var(--text-muted); }

.pp-table { min-width: 560px; }
.pp-access { display: block; }
.pp-level { display: block; font-size: 12.5px; color: var(--text-subtle); }
.pp-table .pp-users { text-align: right; width: 110px; }
.pp-table th.pp-users .ut-sort { margin-left: auto; }

.preset-empty { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: var(--sp-8); padding: var(--sp-10) var(--sp-4); }
.preset-empty__text { max-width: 340px; color: var(--text-muted); display: grid; gap: 10px; justify-items: start; }
.preset-empty__title { font-size: 20px; color: var(--text); }
.preset-empty__art { width: 220px; height: auto; }

.pd-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.pd-grid .check-row { margin-top: 0; }

/* side panel dialog (Create team) */
dialog.set-drawer {
  position: fixed; inset: 0 0 0 auto; margin: 0; height: 100dvh; max-height: 100dvh;
  width: min(560px, 100vw); padding: 0; border: 0; background: var(--surface); color: var(--text);
  box-shadow: var(--shadow-lg);
}
dialog.set-drawer[open] { animation: drawer-in var(--slow) var(--ease); }
@keyframes drawer-in { from { transform: translateX(40px); opacity: 0; } }
dialog.set-drawer::backdrop { background: rgba(10, 15, 28, .55); }
.set-drawer__form { display: flex; flex-direction: column; height: 100%; }
.set-drawer__head { display: flex; align-items: center; justify-content: space-between; padding: var(--sp-5) var(--sp-6); border-bottom: 1px solid var(--border); }
.set-drawer__body { flex: 1; overflow-y: auto; display: grid; align-content: start; gap: var(--sp-5); padding: var(--sp-6); }
.set-drawer__foot { display: flex; gap: var(--sp-2); padding: var(--sp-4) var(--sp-6); border-top: 1px solid var(--border); }
.td-members { margin-top: var(--sp-3); padding: var(--sp-3); border: 1px solid var(--border); border-radius: var(--radius); }
.td-members .ut-search { width: 100%; }
.td-members__count { font-size: 13px; font-weight: 600; margin: var(--sp-3) 2px var(--sp-2); }
.td-list { max-height: 340px; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.td-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-top: 1px solid var(--border); }
.td-item:first-child { border-top: 0; }
.td-item.is-on { background: var(--brand-soft); }
.td-who { flex: 1; min-width: 0; display: flex; flex-direction: column; font-size: 13.5px; }
.td-who span { color: var(--text-muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; }
.td-who .td-other { color: var(--warning); }
.td-none { padding: 14px; color: var(--text-subtle); font-size: 14px; }

@media (max-width: 767.98px) {
  .ut-search--sm.settings-nav__search { width: 100%; }
  .pd-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .seat-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); padding: var(--sp-4); }
}


/* 13. EDIT PERMISSIONS panel ---------------------------------------------- */
.ep-who { display: flex; align-items: center; gap: var(--sp-3); min-width: 0; }
.ep-who .set-modal__title { font-size: 17px; }
.ep-section { padding-bottom: var(--sp-5); border-bottom: 1px solid var(--border); }
.ep-section:last-child { border-bottom: 0; padding-bottom: 0; }
.ep-section > .input, .ep-section > select { margin-top: var(--sp-2); }
.ep-title { font-size: 15px; font-weight: 700; margin-bottom: 2px; }
.ep-admin { padding: 0; border: 0; }
.ep-tools { margin-top: var(--sp-2); border: 1px solid var(--border); border-radius: var(--radius); }
.ep-tool { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); padding: 10px 12px; border-top: 1px solid var(--border); }
.ep-tool:first-child { border-top: 0; }
.ep-tool__main { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; min-width: 0; }
.ep-tool__main strong { display: block; font-size: 14px; }
.ep-tool__main .field__help { display: block; }
select.input.ep-level { width: 110px; height: 36px; font-size: 13.5px; flex: none; }
select.input.ep-level:disabled { opacity: .45; }
.is-disabled .ep-tools, .is-disabled > select { opacity: .5; pointer-events: none; }
.ep-extra { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 16px; margin-top: 6px; }
@media (max-width: 575.98px) {
  .ep-tool { flex-wrap: wrap; }
  .ep-extra { grid-template-columns: 1fr; }
}

/* RESPONSIVE -------------------------------------------------------------- */
@media (max-width: 1499.98px) and (min-width: 768px) {
  .set-table .col-last { display: none; }
}
@media (max-width: 1199.98px) {
  .bill-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .set-grid--3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 991.98px) {
  .settings { grid-template-columns: 1fr; gap: var(--sp-4); }
  .settings-nav { position: static; max-height: none; overflow: visible; padding: 0; }
  .settings-nav__head { display: flex; align-items: center; gap: var(--sp-3); margin-bottom: 0; }
  .settings-nav__back { margin: 0; }
  .settings-nav__title { font-size: 18px; margin-right: auto; }
  .settings-nav__mobile { display: inline-flex; }
  .settings-nav__body {
    display: none; margin-top: var(--sp-3); padding: var(--sp-4);
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  }
  .settings-nav.is-open .settings-nav__body { display: block; }
}
@media (max-width: 767.98px) {
  .set-grid, .set-grid--3, .bill-grid { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; gap: 2px; }
  .kv dd { margin-bottom: 10px; }
  .set-toolbar__count { margin-left: 0; width: 100%; }
  .set-row { align-items: flex-start; flex-wrap: wrap; }
  .save-bar { bottom: calc(var(--mobile-nav-h) + env(safe-area-inset-bottom)); }
}

/* Create / edit dialogs open from the right like dialog.set-drawer.
   Add class "set-modal--drawer" to a dialog.set-modal (confirmations stay centred). */
dialog.set-modal.set-modal--drawer {
  position: fixed; inset: 0 0 0 auto; margin: 0;
  width: min(520px, 100vw); height: 100dvh; max-height: 100dvh;
  border-radius: 0; overflow: hidden;
}
dialog.set-modal--drawer[open] { animation: drawer-in var(--slow) var(--ease); }
dialog.set-modal--drawer > form, dialog.set-modal--drawer > div { display: flex; flex-direction: column; height: 100%; }
dialog.set-modal--drawer .set-modal__body { flex: 1; overflow-y: auto; align-content: start; }
dialog.set-modal--drawer .set-modal__foot { justify-content: flex-start; flex-direction: row-reverse; justify-content: flex-end; }

/* very small phones: the single settings column may shrink, header wraps */
@media (max-width: 991.98px) { .settings { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 380px) { .settings-nav__head { flex-wrap: wrap; row-gap: var(--sp-2); } }
