﻿.profile-wrap {
  display: grid;
  gap: 16px;
}

.profile-settings-layout {
  width: 100%;
}

.profile-section-tree {
  display: none;
}

.profile-section-tree-row {
  padding-left: var(--tree-indent, 0.05rem);
}

.profile-section-tree-node {
  min-height: 2.15rem;
}

.profile-section-tree-icon {
  color: color-mix(in srgb, var(--fg) 58%, transparent);
}

.profile-section-tree-icon svg {
  display: block;
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.65;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.profile-card {
  border: 1px solid var(--border-subtle);
  background: var(--panel-bg);
  border-radius: 14px;
  overflow: hidden;
}

.profile-card-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  background: transparent;
  border: none;
  color: var(--fg);
  font-size: 15px;
  cursor: pointer;
}

.profile-card-title {
  font-weight: 600;
}

.profile-card-heading {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
}

.profile-card-section-icon {
  width: 1.15rem;
  height: 1.15rem;
  flex: 0 0 1.15rem;
  color: color-mix(in srgb, var(--fg) 62%, transparent);
}

.profile-card-section-icon svg {
  display: block;
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.65;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.profile-card-icon {
  font-size: 18px;
  line-height: 1;
}

.profile-card-body {
  display: grid;
  gap: 0;
  padding: 0 18px 16px;
}

.profile-card-body[hidden] {
  display: none;
}

.profile-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: stretch;
  gap: 0.45rem;
  padding: 0.875rem 0;
  border-bottom: 1px solid color-mix(in srgb, var(--fg) 8%, transparent);
}

.profile-row[hidden] {
  display: none;
}

.profile-row:last-child {
  border-bottom: none;
}

.profile-row-stack {
  grid-template-columns: minmax(0, 1fr);
  align-items: stretch;
  gap: 0.55rem;
  padding-block: 1rem;
}

.profile-label {
  color: color-mix(in srgb, var(--fg) 70%, transparent);
  font-size: 13px;
}

.profile-password-row.is-superadmin-preview > .profile-label {
  color: #7c3aed;
}

.profile-value {
  justify-self: start;
  color: var(--fg);
  font-size: 14px;
  text-align: left;
  word-break: break-word;
}

.profile-input {
  min-width: 0;
  width: 100%;
  max-width: 320px;
  height: var(--ut-textbox-height);
  min-height: var(--ut-textbox-height);
  box-sizing: border-box;
  justify-self: start;
  border: 1px solid var(--border-subtle);
  background: var(--bg);
  color: var(--fg);
  border-radius: 10px;
  padding: 0.5rem 0.75rem;
  text-align: left;
}

.profile-avatar-control {
  display:flex;
  align-items:center;
  gap:0.85rem;
}

.profile-avatar-preview {
  width:4rem;
  height:4rem;
  display:inline-flex;
  flex:0 0 4rem;
  align-items:center;
  justify-content:center;
  overflow:hidden;
  border-radius:50%;
  background:color-mix(in srgb, var(--fg) 12%, var(--bg));
  color:var(--fg);
  font-size:1.1rem;
  font-weight:700;
}

.profile-avatar-preview img {
  width:100%;
  height:100%;
  display:block;
  object-fit:cover;
}

.profile-avatar-actions {
  display:flex;
  flex-wrap:wrap;
  align-items:center;
  gap:0.5rem;
}

.profile-avatar-upload,
.profile-avatar-remove {
  min-height:2.15rem;
  padding:0.4rem 0.75rem;
  border:1px solid var(--border-subtle);
  border-radius:9px;
  background:var(--bg);
  color:var(--fg);
  font:inherit;
  font-size:13px;
  cursor:pointer;
}

.profile-avatar-remove {
  color:var(--danger, #d33);
}

.profile-avatar-hint {
  width:100%;
  color:color-mix(in srgb, var(--fg) 62%, transparent);
  font-size:12px;
}

.profile-handle-control {
  width: 100%;
  max-width: 410px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  justify-self: end;
  gap: 8px;
}

.profile-handle-row {
  grid-template-columns: minmax(9rem, 0.8fr) minmax(0, 1.5fr);
  align-items: center;
  gap: 0.4rem 1.25rem;
  padding-block: 0.875rem;
}

.profile-handle-row .profile-handle-control,
.profile-handle-row .profile-handle-status {
  grid-column: 2;
}

.profile-handle-prefix {
  color: color-mix(in srgb, var(--fg) 68%, transparent);
  font-size: 14px;
}

.profile-handle-input {
  min-width: 0;
}

.profile-handle-status {
  min-height: 1.1rem;
  color: color-mix(in srgb, var(--fg) 62%, transparent);
  font-size: 12px;
  text-align: left;
}

.profile-handle-status:empty {
  display: none;
}

/* Account is a compact, single-column form: label first, value underneath. */
.profile-card-body:has(#profile-name) {
  width: 100%;
  margin-inline: 0;
}

.profile-card-body:has(#profile-name) .profile-row,
.profile-card-body:has(#profile-name) .profile-handle-row {
  grid-template-columns: minmax(0, 1fr);
  align-items: stretch;
  gap: 0.45rem;
  padding-block: 0.9rem;
}

.profile-card-body:has(#profile-name) .profile-input {
  width: 100%;
  max-width: 320px;
  justify-self: start;
}

.profile-card-body:has(#profile-name) #profile-name {
  max-width: 260px;
}

.profile-card-body:has(#profile-name) #profile-company {
  max-width: 260px;
}

.profile-card-body:has(#profile-name) .profile-handle-control {
  width: 100%;
  max-width: 260px;
  justify-self: start;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.35rem;
  min-height: var(--ut-textbox-height);
  box-sizing: border-box;
  padding-inline: 0.75rem;
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  background: var(--bg);
}

.profile-card-body:has(#profile-name) .profile-handle-input {
  max-width: none;
  min-height: auto;
  padding: 0;
  border: 0;
  border-radius: 0;
  outline: 0;
  background: transparent;
}

.profile-card-body:has(#profile-name) .profile-handle-control:focus-within {
  border-color: color-mix(in srgb, var(--fg) 42%, var(--border-subtle));
}

.profile-card-body:has(#profile-name) .profile-handle-control,
.profile-card-body:has(#profile-name) .profile-handle-status {
  grid-column: 1;
}

.profile-card-body:has(#profile-name) .profile-value {
  justify-self: start;
  text-align: left;
}

.profile-card-body:has(#profile-name) > .profile-row:nth-child(5) {
  margin-top: 0.65rem;
  border-top: 0;
}

.profile-form-actions {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.75rem;
  padding-top: 1.15rem;
}

.profile-save-status {
  color: color-mix(in srgb, var(--fg) 65%, transparent);
  font-size: 12px;
}

.profile-save-btn {
  box-sizing: border-box;
  min-height: var(--ut-button-height-standard);
  padding: 0 var(--ut-button-padding-inline);
  border: 1px solid var(--border-subtle);
  border-radius: var(--ut-button-radius-inline);
  background: var(--fg);
  color: var(--bg);
  font: inherit;
  font-size: var(--ut-button-font-size-standard);
  font-weight: var(--ut-button-font-weight-standard);
  line-height: var(--ut-button-line-height-standard);
  cursor: pointer;
}

.profile-save-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.profile-handle-status[data-state="ok"] {
  color: #2c974b;
}

.profile-handle-status[data-state="error"] {
  color: var(--danger, #d33);
}

.profile-theme-options {
  display: flex;
  gap: 16px;
  align-items: center;
}

.profile-theme-option {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  color: var(--fg);
  font-size: 14px;
}

.profile-theme-option input {
  accent-color: var(--fg);
}

.profile-notification-row {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 1rem;
}

.profile-notification-hint {
  display: block;
  margin-top: 0.3rem;
  color: color-mix(in srgb, var(--fg) 58%, transparent);
  font-size: 12px;
  line-height: 1.4;
}

.profile-notification-row.is-disabled {
  opacity: 0.52;
}

.profile-toggle {
  position: relative;
  display: inline-flex;
  flex: 0 0 auto;
  cursor: pointer;
}

.profile-toggle input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
}

.profile-toggle > span {
  box-sizing: border-box;
  width: var(--ut-switch-width);
  height: var(--ut-switch-height);
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  background: color-mix(in srgb, var(--fg) 12%, transparent);
  transition: background 160ms ease, border-color 160ms ease;
}

.profile-toggle > span::after {
  content: "";
  display: block;
  box-sizing: border-box;
  width: var(--ut-switch-thumb-size);
  height: var(--ut-switch-thumb-size);
  margin: var(--ut-switch-thumb-inset);
  border-radius: 50%;
  background: var(--bg);
  box-shadow: 0 1px 3px color-mix(in srgb, #000 25%, transparent);
  transition: transform 160ms ease;
}

.profile-toggle input:checked + span {
  border-color: var(--fg);
  background: var(--fg);
}

.profile-toggle input:checked + span::after {
  transform: translateX(var(--ut-switch-thumb-travel));
}

.profile-toggle input:focus-visible + span {
  outline: 2px solid color-mix(in srgb, var(--fg) 55%, transparent);
  outline-offset: 2px;
}

.profile-toggle input:disabled + span {
  cursor: default;
}

.profile-tab-order {
  display: grid;
  gap: 6px;
}

.profile-tab-order-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 0;
}

.profile-tab-order-label {
  color: var(--fg);
  font-size: 14px;
}

.profile-tab-order-actions {
  display: inline-flex;
  gap: 6px;
}

.profile-mini-btn {
  border: 1px solid var(--border-subtle);
  background: color-mix(in srgb, var(--bg) 96%, transparent);
  color: var(--fg);
  border-radius: 8px;
  padding: 4px 8px;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

.profile-mini-btn:disabled {
  opacity: 0.42;
  cursor: default;
}

.profile-storage {
  display: grid;
  gap: 10px;
}

.profile-storage-head,
.profile-storage-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.profile-storage-head {
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 0.4rem;
}

.profile-storage-bar {
  width: 100%;
  height: 12px;
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  background: color-mix(in srgb, var(--fg) 8%, transparent);
  overflow: hidden;
}

.profile-storage-bar span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #2c974b, #2563eb);
  transition: width 180ms ease;
}

.profile-storage-meta,
.profile-storage-note {
  color: color-mix(in srgb, var(--fg) 62%, transparent);
  font-size: 12px;
}

.profile-storage-note[data-state="error"] {
  color: var(--danger, #d33);
}

.profile-storage-breakdown .profile-row {
  padding: 6px 0;
}

.profile-link {
  color: var(--fg);
  text-decoration: none;
  font-size: 14px;
}

.profile-link:hover {
  text-decoration: underline;
}

.profile-action-intro {
  padding: 0.2rem 0 1.1rem;
  border-bottom: 1px solid color-mix(in srgb, var(--fg) 8%, transparent);
}

.profile-action-kicker {
  color: color-mix(in srgb, var(--fg) 58%, transparent);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.profile-action-intro h2 {
  margin: 0.35rem 0 0.45rem;
  color: var(--fg);
  font-size: 1.15rem;
}

.profile-action-intro p,
.profile-action-review p {
  margin: 0;
  color: color-mix(in srgb, var(--fg) 66%, transparent);
  font-size: 13px;
  line-height: 1.5;
}

.profile-action-scope {
  width: 100%;
  max-width: 32rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  box-sizing: border-box;
  padding: 0.8rem 0.9rem;
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  color: var(--fg);
  font-size: 13px;
}

.profile-action-scope strong {
  white-space: nowrap;
}

.profile-action-review-btn {
  justify-self: start;
}

.profile-action-review-actions {
  padding-top: 1rem;
}

.profile-action-review {
  display: grid;
  gap: 0.75rem;
  margin-top: 1.25rem;
  padding: 1rem;
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  background: color-mix(in srgb, var(--fg) 4%, transparent);
}

.profile-action-review[hidden] {
  display: none;
}

.profile-action-note {
  padding-top: 0.7rem;
  border-top: 1px solid color-mix(in srgb, var(--fg) 8%, transparent);
}

.profile-action-confirm {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  color: var(--fg);
  font-size: 13px;
  line-height: 1.4;
}

.profile-action-confirm input {
  margin-top: 0.15rem;
  accent-color: var(--ut-checkbox-accent);
}

@media (min-width: 1280px) {
  .profile-settings-page .page-shell {
    max-width: 800px;
  }

  .profile-settings-page .profile-section-tree {
    display: block;
    position: fixed;
    top: 75px;
    bottom: 0;
    left: 0;
    z-index: 50;
    width: clamp(228px, calc((100vw - 800px) / 2 - 12px), 320px);
    max-height: none;
    box-sizing: border-box;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    padding: 1.5rem 0.75rem 1.5rem 0.3rem;
    border-right: 1px solid transparent;
    scrollbar-width: thin;
    scrollbar-color: color-mix(in srgb, var(--fg) 28%, transparent) transparent;
  }

  .profile-section-tree .dashboard-group-tree-header {
    margin-bottom: 0.65rem;
  }

  .profile-wrap {
    display: block;
  }

  .profile-card {
    display: none;
    border: 0;
    border-radius: 0;
    background: transparent;
    overflow: visible;
  }

  .profile-card.is-active {
    display: block;
  }

  .profile-card.is-active .profile-card-toggle {
    display: none;
  }

  .profile-card.is-active .profile-card-body {
    display: block;
    padding: 0;
  }
}

@media (max-width: 700px) {
  input,
  select,
  textarea {
    font-size: 16px;
  }

  .profile-row {
    grid-template-columns: minmax(0, 1fr);
    align-items: flex-start;
    gap: 0.4rem;
  }

  .profile-input {
    max-width: none;
    justify-self: stretch;
    text-align: left;
  }

  .profile-handle-row {
    grid-template-columns: minmax(0, 1fr);
  }

  .profile-handle-control {
    grid-template-columns: auto minmax(0, 1fr);
    max-width: none;
    width: 100%;
  }

  .profile-handle-row .profile-handle-control,
  .profile-handle-row .profile-handle-status {
    grid-column: 1;
  }

  .profile-handle-claim,
  .profile-handle-control .profile-mini-btn {
    grid-column: 1 / -1;
    justify-self: start;
  }

  .profile-handle-status {
    text-align: left;
  }

  .profile-value {
    justify-self: start;
    width: 100%;
    text-align: left;
  }

  .profile-theme-options {
    width: 100%;
  }

  .profile-tab-order-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .profile-storage-head,
  .profile-storage-meta {
    align-items: flex-start;
  }

  .profile-action-scope {
    align-items: flex-start;
    flex-direction: column;
    gap: 0.35rem;
  }
}
