:root {
  color-scheme: light;
  --bg: #f5f3ee;
  --surface: #ffffff;
  --surface-2: #f0f6f3;
  --ink: #202124;
  --muted: #69706d;
  --line: #d9ddd7;
  --accent: #0f766e;
  --accent-2: #b45309;
  --danger: #b42318;
  --shadow: 0 18px 48px rgba(32, 33, 36, 0.1);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
textarea,
select {
  font: inherit;
  letter-spacing: 0;
}

button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--ink);
  padding: 0 14px;
  cursor: pointer;
}

button:hover {
  border-color: #a8b5af;
}

button:disabled {
  cursor: wait;
  opacity: 0.6;
}

.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
}

.danger {
  border-color: var(--danger);
  background: var(--danger);
  color: white;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: white;
  color: var(--ink);
  padding: 10px 11px;
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

label span {
  font-weight: 650;
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-panel {
  width: min(420px, 100%);
  display: grid;
  gap: 18px;
  padding: 28px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.auth-panel h1,
.topbar h2,
.panel h3,
.empty-state h3 {
  margin: 0;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--accent-2);
  font-size: 12px;
  font-weight: 750;
  text-transform: uppercase;
}

.message {
  min-height: 20px;
  margin: 0;
  color: var(--danger);
  font-size: 13px;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(280px, 350px) 1fr;
}

.sidebar {
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: 14px;
  border-right: 1px solid var(--line);
  background: #fbfaf7;
  padding: 18px;
  min-height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 7px;
  background: #1f2933;
  color: white;
  font-weight: 800;
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  color: var(--muted);
  margin-top: 2px;
}

.toolbar {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.sidebar-controls {
  display: grid;
  gap: 10px;
}

.category-filter {
  gap: 5px;
}

.account-list {
  display: grid;
  align-content: start;
  gap: 15px;
  overflow: auto;
  padding-right: 4px;
}

.account-group {
  display: grid;
  gap: 8px;
}

.account-group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 3px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.account-group-head span {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  min-height: 22px;
  border-radius: 999px;
  background: var(--surface-2);
  color: #27584f;
}

.account-empty {
  margin: 8px 2px;
  color: var(--muted);
  font-size: 13px;
}

.account-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  width: 100%;
  min-height: 74px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 10px;
  text-align: left;
}

.account-row > span:first-child {
  min-width: 0;
}

.account-row.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.1);
}

.account-row strong {
  display: block;
  overflow-wrap: anywhere;
}

.account-row small {
  color: var(--muted);
}

.account-social {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 5px;
  color: #3f5f58 !important;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.account-social b {
  color: #164e46;
  font-weight: 750;
}

.account-social i {
  color: #a1aaa6;
  font-style: normal;
}

.account-social.unavailable {
  color: var(--muted) !important;
  white-space: normal;
}

.pill {
  border-radius: 999px;
  border: 1px solid var(--line);
  padding: 3px 8px;
  background: var(--surface-2);
  color: #27584f;
  font-size: 12px;
  white-space: nowrap;
}

.main {
  min-width: 0;
  padding: 22px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  margin-bottom: 14px;
}

.selected-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.x-profile-link {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  border: 1px solid #111;
  border-radius: 999px;
  background: #111;
  color: white;
  transition: background 120ms ease, transform 120ms ease;
}

.x-profile-link:hover {
  background: #333;
  transform: translateY(-1px);
}

.x-profile-link:focus-visible {
  outline: 3px solid rgba(15, 118, 110, 0.25);
  outline-offset: 2px;
}

.x-profile-link svg {
  width: 15px;
  height: 15px;
  fill: currentColor;
}

.top-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.status-band {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 34px;
  margin-bottom: 14px;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  padding: 0 10px;
  color: var(--muted);
  font-size: 13px;
}

.health-band {
  display: grid;
  gap: 11px;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 8px 28px rgba(32, 33, 36, 0.05);
  padding: 14px 16px;
}

.health-band h3 {
  margin: 0;
}

.health-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.health-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.health-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 31px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 11px;
  font-size: 13px;
}

.health-chip strong {
  font-size: 15px;
}

.health-chip.healthy,
.health-inline.healthy,
.health-value.healthy {
  color: #166534;
}

.health-chip.healthy {
  border-color: #a7d8b4;
  background: #f0fdf4;
}

.health-chip.danger,
.health-inline.danger,
.health-value.danger {
  color: var(--danger);
}

.health-chip.danger {
  border-color: #f0aaa4;
  background: #fff5f4;
}

.health-chip.attention,
.health-chip.stale,
.health-inline.attention,
.health-value.attention {
  color: #92400e;
}

.health-chip.attention,
.health-chip.stale {
  border-color: #efc487;
  background: #fffbeb;
}

.health-chip.unknown,
.health-inline.unknown,
.health-value.unknown {
  color: var(--muted);
}

.health-chip.unknown {
  background: #f7f7f5;
}

.health-progress {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.health-inline {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-weight: 650;
}

.health-inline i {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: currentColor;
}

.account-row.health-danger {
  border-left: 4px solid var(--danger);
}

.account-row.health-attention {
  border-left: 4px solid #d97706;
}

.health-value {
  font-weight: 650;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 360px;
  border: 1px dashed #bbc3bd;
  border-radius: 8px;
  color: var(--muted);
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(280px, 1fr));
  gap: 14px;
  align-items: start;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 28px rgba(32, 33, 36, 0.06);
}

.action-panel {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.panel-title {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

.help-tip {
  position: relative;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 24px;
  min-height: 24px;
  border-color: #b8c1bc;
  border-radius: 999px;
  padding: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
}

.help-tip::after {
  content: attr(data-help);
  position: absolute;
  z-index: 50;
  top: calc(100% + 9px);
  left: -5px;
  width: min(330px, calc(100vw - 56px));
  border: 1px solid #323a36;
  border-radius: 8px;
  background: #202724;
  box-shadow: 0 14px 34px rgba(20, 27, 24, 0.25);
  padding: 11px 12px;
  color: white;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.45;
  text-align: left;
  white-space: normal;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(-3px);
  transition: opacity 120ms ease, transform 120ms ease, visibility 120ms ease;
}

.help-tip:hover::after,
.help-tip:focus-visible::after {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.danger-panel {
  border-color: rgba(180, 35, 24, 0.35);
}

.form-note {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.counter {
  color: var(--muted);
  font-size: 12px;
}

.facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
}

.facts div {
  min-height: 58px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 9px;
  background: #fbfaf7;
}

.facts dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.facts dd {
  margin: 5px 0 0;
  overflow-wrap: anywhere;
}

.audit-panel {
  grid-column: 1 / -1;
}

.audit-log {
  display: grid;
  gap: 6px;
  max-height: 280px;
  overflow: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}

.audit-item {
  display: grid;
  grid-template-columns: 176px 130px 1fr;
  gap: 8px;
  border-bottom: 1px solid var(--line);
  padding: 7px 0;
}

dialog {
  width: min(560px, calc(100vw - 28px));
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 0;
}

dialog::backdrop {
  background: rgba(32, 33, 36, 0.36);
}

.dialog-body {
  display: grid;
  gap: 13px;
  padding: 18px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(420px, calc(100vw - 36px));
  border: 1px solid var(--line);
  border-left: 5px solid var(--accent);
  border-radius: 8px;
  background: white;
  box-shadow: var(--shadow);
  padding: 13px 14px;
  color: var(--ink);
}

.toast.error {
  border-left-color: var(--danger);
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .account-list {
    max-height: 260px;
  }

  .detail-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .health-head {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 560px) {
  .main,
  .sidebar {
    padding: 14px;
  }

  .toolbar,
  .facts,
  .audit-item {
    grid-template-columns: 1fr;
  }

  .panel-head {
    align-items: flex-start;
    flex-direction: column;
  }
}
