:root {
  color-scheme: light;
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #edf2f7;
  color: #1a2638;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background: #edf2f7;
  color: #1a2638;
}

button,
input,
textarea {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr);
  gap: 18px;
  padding: 26px 28px 32px;
}

.sidebar {
  position: sticky;
  top: 26px;
  width: 86px;
  height: calc(100vh - 52px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 34px;
  padding: 22px 0;
  border-radius: 34px;
  background: #ffffff;
  border: 1px solid #dde7f2;
  box-shadow: 0 22px 45px rgba(28, 42, 64, 0.09);
}

.brand-mark {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: #1166e8;
  color: #ffffff;
  font-weight: 800;
  box-shadow: 0 12px 22px rgba(17, 102, 232, 0.24);
}

.brand-mark svg,
.metric-icon svg {
  width: 22px;
  height: 22px;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-button svg {
  width: 32px;
  height: 32px;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.55;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-stack {
  display: grid;
  width: 100%;
  justify-items: center;
  gap: 14px;
}

.nav-button {
  width: 46px;
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 17px;
  background: transparent;
  color: #70819b;
  cursor: pointer;
  transition: transform 180ms ease, background 180ms ease, border-color 180ms ease, color 180ms ease, box-shadow 180ms ease;
}

.nav-button.active {
  background: #edf5ff;
  border-color: #cfe1ff;
  color: #1267ee;
  box-shadow: inset 0 0 0 1px rgba(18, 103, 238, 0.08), 0 10px 20px rgba(18, 103, 238, 0.1);
}

.nav-button:hover {
  border-color: #d7e3f2;
  background: #f6f9fd;
  transform: translateY(-1px);
}

.nav-button:focus,
button:focus,
.secondary-link:focus {
  outline: none;
}

.nav-button:focus-visible,
button:focus-visible,
.secondary-link:focus-visible {
  outline: none;
  box-shadow: 0 0 0 4px rgba(18, 103, 238, 0.16);
}

.workspace {
  min-width: 0;
  display: grid;
  align-content: start;
  gap: 14px;
}

.eyebrow {
  margin: 0 0 4px;
  color: #75869f;
  font-size: 12px;
  font-weight: 750;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 26px;
  line-height: 1.2;
}

h2 {
  font-size: 18px;
  line-height: 1.25;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0;
  padding: 8px;
  border-radius: 18px;
  background: #ffffff;
  border: 1px solid #dce6f1;
  box-shadow: 0 14px 30px rgba(28, 42, 64, 0.055);
  animation: fade-slide 420ms ease both;
}

.panel {
  background: #ffffff;
  border: 1px solid #dce6f1;
  box-shadow: 0 16px 34px rgba(28, 42, 64, 0.06);
}

.metric-card {
  min-height: 52px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  border-right: 1px solid #e7edf5;
  background: transparent;
}

.metric-card:last-child {
  border-right: 0;
}

.metric-icon {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  border-radius: 11px;
}

.metric-icon svg {
  width: 17px;
  height: 17px;
}

.metric-icon.blue {
  background: #edf5ff;
  color: #1267ee;
}

.metric-icon.green {
  background: #eafaf2;
  color: #18a869;
}

.metric-icon.red {
  background: #fff0f2;
  color: #e34a5a;
}

.metric-icon.amber {
  background: #fff6df;
  color: #d58900;
}

.metric-label {
  display: block;
  color: #6d7d94;
  font-size: 12px;
  font-weight: 650;
  line-height: 1.1;
}

.metric-card strong {
  display: block;
  margin-top: 2px;
  font-size: 15px;
  line-height: 1.1;
  word-break: break-word;
}

.page-view {
  display: none;
}

.page-view.active {
  display: grid;
  gap: 18px;
  animation: fade-slide 360ms ease both;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(360px, 0.9fr);
  gap: 18px;
}

#resolvePage .content-grid {
  grid-template-columns: 1fr;
}

.panel {
  border-radius: 18px;
  padding: 22px;
  animation: fade-slide 420ms ease both;
  transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
}

.panel:hover {
  transform: translateY(-2px);
  box-shadow: 0 20px 42px rgba(28, 42, 64, 0.08);
  border-color: #cfdeef;
}

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

.form {
  display: grid;
  gap: 16px;
}

.account-inline-form {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(220px, 1fr) auto;
  gap: 14px;
  align-items: end;
}

.account-inline-form .field {
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 12px;
}

.account-inline-form .field > span {
  white-space: nowrap;
}

.account-inline-form .status-error {
  grid-column: 1 / -1;
}

.account-add-panel {
  padding: 14px 22px;
}

.account-add-action {
  align-self: end;
}

.form-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: end;
}

.form-row.equal {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.resolve-controls {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto auto;
  gap: 16px;
  align-items: end;
}

.resolve-controls .field {
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 12px;
}

.resolve-controls .field > span {
  white-space: nowrap;
}

.resolve-controls .mode-group {
  display: grid;
  grid-template-columns: auto auto auto;
  align-items: center;
  min-width: 0;
  gap: 8px;
}

.resolve-controls .mode-group .inline-label {
  width: auto;
  margin: 0 4px 0 0;
  white-space: nowrap;
}

.resolve-submit {
  align-self: end;
}

.field {
  display: grid;
  gap: 8px;
}

.field > span,
.mode-group .inline-label {
  color: #30445f;
  font-size: 14px;
  font-weight: 700;
}

textarea,
input[type="text"],
input[type="password"],
.link-input {
  width: 100%;
  border: 1px solid #cfdbe9;
  border-radius: 12px;
  background: #fbfdff;
  color: #182436;
  padding: 12px 14px;
  transition: border-color 180ms ease, box-shadow 180ms ease, background 180ms ease;
}

textarea {
  min-height: 134px;
  resize: vertical;
}

textarea:focus,
input[type="text"]:focus,
input[type="password"]:focus,
.link-input:focus {
  outline: none;
  border-color: #6da3ef;
  box-shadow: 0 0 0 4px rgba(18, 103, 238, 0.11);
}

textarea:disabled,
input:disabled {
  background: #f1f5f9;
  color: #8793a5;
  cursor: not-allowed;
}

.mode-group {
  min-width: 210px;
  display: flex;
  gap: 8px;
  margin: 0;
  padding: 0;
  border: 0;
  flex-wrap: wrap;
}

.mode-group label {
  position: relative;
}

.mode-group input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.mode-group label > span {
  min-width: 82px;
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  border: 1px solid #d4e0ef;
  background: #f7faff;
  color: #425873;
  font-weight: 750;
  cursor: pointer;
  transition: transform 180ms ease, background 180ms ease, border-color 180ms ease, color 180ms ease;
}

.mode-group input:checked + span {
  background: #eaf3ff;
  border-color: #bdd8ff;
  color: #1267ee;
}

.mode-group label > span:hover {
  transform: translateY(-1px);
}

.actions,
.link-actions,
.mini-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

button,
.secondary-link {
  min-height: 42px;
  border: 1px solid #d1ddec;
  border-radius: 14px;
  background: #f7faff;
  color: #32465f;
  padding: 0 16px;
  font-weight: 750;
  text-decoration: none;
  cursor: pointer;
  transition: transform 180ms ease, box-shadow 180ms ease, background 180ms ease, border-color 180ms ease, color 180ms ease;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.primary {
  background: #1267ee;
  border-color: #1267ee;
  color: #ffffff;
  box-shadow: 0 12px 22px rgba(18, 103, 238, 0.18);
}

button:not(:disabled):hover,
.secondary-link:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 18px rgba(28, 42, 64, 0.08);
}

.secondary-link {
  display: inline-flex;
  align-items: center;
}

.danger-button {
  border-color: #ffd6db;
  background: #fff4f5;
  color: #d84050;
}

.compact {
  min-height: 34px;
  padding: 0 12px;
  border-radius: 12px;
  font-size: 13px;
}

.status-pill {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 13px;
  font-weight: 750;
  white-space: nowrap;
  transition: background 180ms ease, border-color 180ms ease, color 180ms ease, transform 180ms ease;
}

.status-pill.neutral {
  background: #f1f5fb;
  color: #536985;
  border-color: #dbe5f1;
}

.status-pill.success {
  background: #eafaf2;
  color: #15764e;
  border-color: #c7ebda;
}

.status-pill.warn {
  background: #fff6df;
  color: #8f6500;
  border-color: #eedaa7;
}

.status-pill.danger {
  background: #fff0f2;
  color: #bc3141;
  border-color: #f2cbd2;
}

.status-copy {
  margin: 0;
  color: #43546c;
  line-height: 1.7;
}

.task-toolbar {
  min-height: 34px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.task-message {
  color: #43546c;
  font-size: 14px;
  line-height: 1.5;
}

.status-error,
.account-error {
  margin: 0;
  color: #bd2f41;
  line-height: 1.6;
  word-break: break-word;
}

.subsection {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid #e7edf5;
}

.subsection-title {
  margin-bottom: 10px;
  color: #30445f;
  font-size: 14px;
  font-weight: 800;
}

.attempt-list,
.selection-list,
.account-list {
  display: grid;
  gap: 10px;
}

.empty {
  min-height: 96px;
  place-items: center;
  border: 1px dashed #cedae9;
  border-radius: 16px;
  color: #8290a4;
  background: #fbfdff;
}

.attempt-item,
.selection-item,
.account-card {
  display: grid;
  gap: 10px;
  border: 1px solid #dfe8f2;
  border-radius: 16px;
  background: #fbfdff;
  animation: fade-slide 320ms ease both;
  transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.attempt-item:hover,
.selection-item:hover,
.account-card:hover {
  transform: translateY(-1px);
  border-color: #cfe0f3;
  box-shadow: 0 12px 22px rgba(28, 42, 64, 0.055);
}

.attempt-item {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  padding: 12px 14px;
}

.attempt-item p {
  grid-column: 1 / -1;
  margin: 0;
  color: #bd2f41;
  line-height: 1.55;
  word-break: break-word;
}

.selection-item,
.account-card {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  padding: 14px 16px;
}

.account-list {
  display: grid;
  gap: 12px;
}

.account-card {
  background: #ffffff;
  box-shadow: 0 14px 30px rgba(28, 42, 64, 0.055);
}

.account-card .account-main {
  display: flex;
  align-items: center;
  gap: 16px;
}

.account-card .account-main .muted {
  white-space: nowrap;
}

.selection-info,
.account-main {
  min-width: 0;
}

.selection-info strong,
.account-main strong,
.attempt-item strong {
  display: block;
  color: #223149;
  word-break: break-word;
}

.muted {
  color: #6f7e94;
  line-height: 1.6;
  word-break: break-word;
}

.account-side {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

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

.result-grid div {
  padding: 14px;
  border: 1px solid #dfe8f2;
  border-radius: 16px;
  background: #fbfdff;
}

.result-grid dt {
  color: #73839a;
  font-size: 13px;
  font-weight: 700;
}

.result-grid dd {
  margin: 6px 0 0;
  color: #223149;
  font-weight: 750;
  word-break: break-all;
}

.link-block {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

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

.link-row span {
  font-weight: 800;
  color: #30445f;
}

.link-input {
  background: #f6f9fd;
  word-break: break-all;
}

.hidden {
  display: none;
}

@keyframes fade-slide {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

  .sidebar {
    position: static;
    width: 100%;
    height: auto;
    flex-direction: row;
    justify-content: space-between;
    padding: 10px 14px;
    border-radius: 22px;
  }

  .nav-stack {
    grid-auto-flow: column;
    width: auto;
  }

  .content-grid,
  .account-inline-form,
  .resolve-controls,
  .form-row,
  .form-row.equal,
  .result-grid {
    grid-template-columns: 1fr;
  }

  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .metric-card:nth-child(2) {
    border-right: 0;
  }

  .metric-card:nth-child(-n+2) {
    border-bottom: 1px solid #e7edf5;
  }

  .mode-group {
    min-width: 0;
  }
}

@media (max-width: 620px) {
  .section-head,
  .selection-item,
  .account-card,
  .link-row {
    display: grid;
    grid-template-columns: 1fr;
  }

  .panel {
    padding: 16px;
  }

  .actions,
  .link-actions,
  .mini-actions,
  .account-side,
  .account-add-action,
  .resolve-submit {
    justify-content: stretch;
    justify-items: stretch;
  }

  button,
  .secondary-link {
    width: 100%;
  }

  .status-pill {
    width: fit-content;
    max-width: 100%;
  }

  .account-card .account-main {
    display: grid;
    gap: 4px;
  }

  .account-card .account-main .muted {
    white-space: normal;
  }
}

@media (max-width: 460px) {
  .metric-grid {
    grid-template-columns: 1fr;
  }

  .metric-card {
    border-right: 0;
    border-bottom: 1px solid #e7edf5;
  }

  .metric-card:last-child {
    border-bottom: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.001ms !important;
  }
}
