.account-shell {
  --account-border: color-mix(in srgb, var(--line) 70%, var(--bg));
  --account-surface: color-mix(in srgb, var(--surface) 78%, var(--bg));
  --account-good: #8dd8b4;
  --account-warn: #edbc83;
  min-height: 68vh;
  max-width: 1184px;
  padding-block: clamp(30px, 6vw, 68px);
}

[data-theme="light"] .account-shell {
  --account-surface: var(--surface);
  --account-good: #176749;
  --account-warn: #86521d;
}

.account-shell [hidden] { display: none !important; }
.account-shell :is(h1, h2, p, dl, dd) { margin: 0; }
.account-shell h1 { font-size: clamp(29px, 4vw, 38px); font-weight: 680; line-height: 1.2; letter-spacing: -.045em; }
.account-shell h2 { font-size: 17px; font-weight: 650; line-height: 1.4; letter-spacing: -.018em; }
.account-shell p { font-size: 14px; color: var(--muted); }
.account-shell .button { min-height: 38px; padding: 8px 13px; white-space: normal; font-size: 13px; gap: 7px; }
.account-shell :is(a, button, summary, input):focus-visible { outline: 2px solid var(--blue); outline-offset: 3px; }

.account-guest {
  display: grid;
  justify-items: start;
  gap: 14px;
  max-width: 430px;
  margin: 3vh auto;
  padding: clamp(24px, 6vw, 40px);
  border: 1px solid var(--account-border);
  border-radius: 12px;
  background: var(--account-surface);
}
.account-guest .button { width: 100%; margin-top: 7px; }
.account-back-link { font-size: 13px; color: var(--muted); }
.account-back-link:hover { text-decoration: underline; }

.account-dashboard {
  display: grid;
  grid-template-columns: 196px minmax(0, 1fr);
  align-items: start;
  gap: clamp(24px, 5vw, 65px);
}
.account-sidebar { position: sticky; top: 92px; }
.account-sidebar-title { padding: 0 10px 12px; font-size: 14px; font-weight: 670; }
.account-sidebar nav { display: grid; gap: 4px; }
.account-sidebar nav a, .account-signout {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 7px;
  padding: 9px 10px;
  border-radius: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 550;
  line-height: 1.4;
}
.account-sidebar nav a:hover { background: var(--account-surface); color: var(--text); }
.account-sidebar nav a[aria-current] { background: var(--tint); color: var(--blue); }
.account-signout {
  width: 100%;
  margin-top: 16px;
  border: 0;
  border-top: 1px solid var(--account-border);
  border-radius: 0;
  background: transparent;
  text-align: left;
  padding-top: 14px;
}
.account-signout:hover, .account-unlink:hover { color: var(--text); }

.account-view { display: grid; gap: 16px; }
.account-view > h1 { margin-bottom: 7px; }
.account-panel {
  padding: clamp(16px, 3vw, 25px);
  background: var(--account-surface);
  border: 1px solid var(--account-border);
  border-radius: 10px;
  min-width: 0;
}
.account-identity, .account-settings, .account-section-head, .account-bot-identity {
  display: flex;
  align-items: center;
  gap: 15px;
  min-width: 0;
}
.account-identity > img, .account-bot-identity > img { border: 1px solid var(--account-border); border-radius: 10px; object-fit: cover; }
.account-identity h2 { font-size: 20px; overflow-wrap: anywhere; }
#account-email { font-size: 13px; min-width: 0; overflow-wrap: anywhere; }
.account-email-control { display: flex; align-items: center; gap: 6px; }
#account-email-toggle {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 30px;
  height: 30px;
  padding: 0;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 5px;
}
#account-email-toggle:hover { color: var(--text); background: var(--hover); }
#account-email-toggle svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.7; }
#account-email-toggle[aria-label="Ocultar e-mail"] .account-eye-slash { display: none; }
.account-provider {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
}
.account-overview { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.account-summary { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 9px; }
.account-summary span:first-child { grid-column: 1 / -1; color: var(--muted); font-size: 13px; }
.account-summary strong { font-size: 17px; font-weight: 640; overflow-wrap: anywhere; }
.account-summary span:last-child { color: var(--blue); }
.account-summary:hover { border-color: var(--tint-line); }
.account-settings { justify-content: space-between; }
.account-settings p { margin-top: 4px; }
.account-settings a { flex-shrink: 0; }

.account-feedback:empty { display: none; }
.account-content > .account-feedback { margin-bottom: 12px; }
.account-section-head { justify-content: space-between; }
.account-description:not(:empty) { margin-top: 7px; }
.account-state { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; }
.account-state::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.account-state[data-state="active"], .account-state[data-state="online"] { color: var(--account-good); }
.account-state[data-state="expired"], .account-state[data-state="suspenso"] { color: var(--account-warn); }
.account-shell .account-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-block: 19px;
  padding-block: 14px;
  border-top: 1px solid var(--account-border);
  border-bottom: 1px solid var(--account-border);
}
.account-shell .account-metrics-bot { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.account-metrics dt { color: var(--muted); font-size: 12px; }
.account-metrics dd { font-size: 14px; font-weight: 630; margin-top: 2px; }
.account-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.account-bot > .account-feedback { margin-bottom: 14px; }
#bot-plan-link { margin-top: 13px; }
.account-bot-banner { display: block; width: 100%; height: clamp(82px, 18vw, 165px); object-fit: cover; border-radius: 7px; margin-bottom: 14px; }
.account-bot-identity #bot-name { overflow-wrap: anywhere; }
.account-bot-identity .account-state { margin-left: auto; flex-shrink: 0; }

.account-form { display: grid; gap: 8px; max-width: 480px; margin-top: 16px; }
.account-form label { font-size: 13px; font-weight: 600; }
.account-form input {
  width: 100%;
  min-width: 0;
  margin-bottom: 5px;
  padding: 8px 10px;
  border: 1px solid var(--account-border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 13px;
}
.account-form p { font-size: 12px; }
.account-form .button { justify-self: start; margin-top: 4px; }
.account-editor { margin-top: 17px; border-top: 1px solid var(--account-border); padding-top: 14px; }
.account-editor summary { cursor: pointer; font-size: 14px; font-weight: 600; }
.account-bot-footer { margin-top: 17px; border-top: 1px solid var(--account-border); padding-top: 12px; }
.account-unlink { padding: 0; border: 0; background: transparent; color: var(--account-warn); font-size: 13px; }

@media (max-width: 720px) {
  .account-dashboard { grid-template-columns: 1fr; gap: 22px; }
  .account-sidebar { position: static; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 7px 10px; border-bottom: 1px solid var(--account-border); padding-bottom: 11px; }
  .account-sidebar-title { padding: 0; }
  .account-sidebar nav { display: flex; flex-wrap: wrap; order: 2; width: 100%; }
  .account-signout { width: auto; margin: 0; padding: 3px 0; border: 0; }
}
@media (max-width: 430px) {
  .account-shell { width: calc(100% - 32px); }
  .account-settings { align-items: flex-start; flex-direction: column; }
  .account-identity { flex-wrap: wrap; }
  .account-provider { margin-left: 0; }
  .account-shell .account-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.account-bot .account-feedback[data-state="error"] { color: var(--account-warn); }
.account-bot .account-feedback[data-state="success"] { color: var(--account-good); }

@media (min-width: 640px) {
  .account-shell .account-metrics-bot { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

.systems-view .systems-intro { margin: -6px 0 16px; }
.systems-view #bot-sistemas-acesso { margin-bottom: 12px; }
.systems-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(145px, 24%);
  gap: 14px;
  padding: 16px;
}
.systems-toolbar label {
  display: block;
  margin-bottom: 5px;
  font-size: 13px;
  font-weight: 650;
}
.systems-toolbar :is(input, select) {
  width: 100%;
  min-height: 40px;
  padding: 7px 10px;
  border: 1px solid var(--account-border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 14px;
}
.systems-toolbar select:focus-visible { outline: 2px solid var(--blue); outline-offset: 3px; }
.systems-view #bot-sistemas-vazio { padding: 24px 0 12px; }
.systems-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
  gap: 12px;
  margin-block: 12px;
}
.system-card { padding: 16px; }
.system-card-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}
.system-card-head > div { flex: 1 1 155px; min-width: 0; }
.system-card .system-description { margin-top: 4px; overflow-wrap: anywhere; }
.system-choice {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  padding: 5px 8px;
  border: 1px solid var(--account-border);
  border-radius: 7px;
  font-size: 12px;
  cursor: pointer;
}
.system-choice input { margin: 0; width: 14px; height: 14px; accent-color: var(--blue); }
.system-card:has(.system-choice input:checked:not(:disabled)) { border-color: var(--blue); }
.system-details {
  margin-top: 14px;
  padding-top: 9px;
  border-top: 1px solid var(--account-border);
}
.system-details summary { width: fit-content; cursor: pointer; color: var(--text); font-size: 13px; font-weight: 600; }
.system-details-body { padding-top: 8px; overflow-wrap: anywhere; }
.system-commands { display: grid; gap: 6px; margin: 8px 0 0; padding: 0; list-style: none; color: var(--muted); font-size: 13px; }
.system-commands code { color: var(--text); background: var(--bg); padding: 2px 5px; border-radius: 4px; }
.systems-actions {
  position: sticky;
  bottom: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  box-shadow: 0 7px 18px #0002;
}
.systems-actions .button { flex-shrink: 0; }
.systems-actions .button:disabled { opacity: .65; cursor: default; }
.systems-actions #bot-sistemas-contagem { color: var(--text); font-weight: 650; }
.systems-actions .account-feedback[data-state="error"],
.systems-actions #bot-sistemas-ajuda { color: var(--account-warn); }
.systems-actions .account-feedback[data-state="success"] { color: var(--account-good); }

@media (max-width: 800px) {
  .systems-list { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 460px) {
  .systems-toolbar { grid-template-columns: minmax(0, 1fr); }
  .systems-actions { flex-wrap: wrap; bottom: 6px; }
}
@media (prefers-reduced-motion: no-preference) {
  .system-card { transition: border-color 180ms ease; }
  .system-details[open] .system-details-body { animation: mostrar-detalhes-sistema 180ms ease-out; }
  @keyframes mostrar-detalhes-sistema {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
  }
}

.bot-action-panel {
  padding: 14px;
  text-align: center;
  border: 1px solid var(--account-border);
  border-radius: 10px;
  background: var(--bg);
}
#bot-controls { justify-content: center; margin: 0; }
.bot-invite-row { display: flex; justify-content: center; }
#bot-editor > summary {
  display: list-item;
  width: fit-content;
  padding: 8px 12px;
  border: 1px solid var(--account-border);
  border-radius: 8px;
}
.account-bot-footer, .dialog-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: space-between;
}
.bot-danger {
  color: var(--account-warn);
  background: transparent;
  border: 1px solid currentColor;
}
.bot-danger:hover { background: color-mix(in srgb, var(--account-warn) 12%, var(--bg)); }
.account-dialog {
  width: min(520px, calc(100% - 32px));
  max-height: calc(100% - 32px);
  overflow: auto;
  padding: 22px;
  border: 1px solid var(--account-border);
  border-radius: 14px;
  background: var(--account-surface);
  color: var(--text);
}
.account-dialog::backdrop { background: #090d15b3; }
.account-dialog > p, .dialog-actions { margin-top: 10px; }
.dialog-actions { justify-content: flex-end; }
.account-dialog label span { font-weight: normal; color: var(--muted); }

.bot-hero {
  overflow: hidden;
  border: 1px solid var(--account-border);
  border-radius: 13px;
  background: var(--account-surface);
}
.bot-hero-cover {
  position: relative;
  height: clamp(106px, 20vw, 180px);
  background: radial-gradient(ellipse at 70% -45%, var(--blue), transparent 75%),
    linear-gradient(120deg, var(--bg), var(--account-surface));
}
.bot-hero-cover .account-bot-banner {
  width: 100%;
  height: 100%;
  margin: 0;
  border-radius: 0;
}
.bot-hero .account-bot-identity { padding: 0 18px 16px; align-items: flex-end; flex-wrap: wrap; }
.bot-hero .account-bot-identity > img {
  position: relative;
  margin-top: -22px;
  border: 3px solid var(--account-surface);
  background: var(--account-surface);
  border-radius: 13px;
}
.bot-hero-name { flex: 1 1 150px; min-width: 0; padding-top: 8px; }
.bot-hero-name h2 { font-size: clamp(24px, 4vw, 32px); }
.bot-hero-name .account-state { margin-left: 0; }
.bot-action-panel { margin-top: 14px; }
.bot-action-panel:has(#bot-controls[hidden]) { display: none; }
.bot-servers-panel {
  margin-top: 16px;
  padding: 15px;
  border: 1px solid var(--account-border);
  border-radius: 10px;
}
.bot-servers-panel .account-section-head { margin-bottom: 10px; }
#bot-servers-count {
  padding: 2px 8px;
  border-radius: 20px;
  background: var(--bg);
  font-variant-numeric: tabular-nums;
}
#bot-servers-list {
  display: grid;
  max-height: 290px;
  overflow: auto;
  list-style: none;
  margin: 0;
  padding: 0;
}
#bot-servers-list li {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 8px 2px;
  border-top: 1px solid var(--account-border);
}
#bot-servers-list strong { overflow-wrap: anywhere; font-size: 14px; }
#bot-servers-list small { color: var(--muted); font-variant-numeric: tabular-nums; }
.bot-server-initial {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  background: var(--bg);
  border: 1px solid var(--account-border);
  border-radius: 8px;
  font-weight: 650;
}
.systems-layout {
  display: grid;
  grid-template-columns: minmax(170px, 27%) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}
.systems-layout .systems-toolbar { grid-template-columns: minmax(0, 1fr); position: sticky; top: 74px; }
.systems-layout .systems-list { grid-template-columns: minmax(0, 1fr); margin-top: 0; }
.systems-layout .system-card { min-height: 184px; display: flex; flex-direction: column; }
.system-card .system-details { margin-top: auto; }
.system-card .system-card-head { margin-bottom: 10px; }
@media (max-width: 760px) {
  .systems-layout { grid-template-columns: minmax(0, 1fr); }
  .systems-layout .systems-toolbar { position: static; }
}
@media (max-width: 450px) {
  .bot-hero .account-bot-identity { padding-inline: 12px; }
  #bot-servers-list li { grid-template-columns: auto minmax(0, 1fr); }
  #bot-servers-list small { grid-column: 2; }
}
