:root {
  color-scheme: light;
  --page: #f4f6f9;
  --surface: #fbfcfe;
  --surface-strong: #eef2f7;
  --text: #172033;
  --muted: #5d687a;
  --line: #d8dee8;
  --accent: #285ca8;
  --accent-hover: #1f4b8b;
  --accent-soft: #e7effa;
  --success: #22734b;
  --success-soft: #e7f4ed;
  --warning: #8a5a11;
  --warning-soft: #fff3d9;
  --danger: #a43a3a;
  --danger-soft: #fbeaea;
  --radius: 10px;
  --shadow: 0 12px 32px rgb(32 45 70 / 8%);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100dvh;
  color: var(--text);
  background: var(--page);
  font-size: 15px;
  line-height: 1.55;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible {
  outline: 3px solid rgb(40 92 168 / 28%);
  outline-offset: 2px;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  min-height: 64px;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  border-bottom: 1px solid var(--line);
  background: rgb(251 252 254 / 96%);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-size: 17px;
  font-weight: 720;
  text-decoration: none;
  white-space: nowrap;
}

.brand-mark {
  display: inline-grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 8px;
  color: #f8fafc;
  background: var(--accent);
  font-size: 16px;
  font-weight: 750;
}

.header-actions,
.heading-actions,
.dialog-actions,
.card-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.page-shell {
  width: min(1420px, calc(100% - 40px));
  margin: 0 auto;
  padding: 34px 0 64px;
}

.page-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

.page-heading h1 {
  margin-bottom: 5px;
  font-size: clamp(25px, 3vw, 34px);
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.page-heading p,
.dialog-heading p,
.form-hint {
  margin-bottom: 0;
  color: var(--muted);
}

.primary-button,
.secondary-button,
.text-button,
.close-button,
.small-button,
.danger-button {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  padding: 8px 15px;
  border: 1px solid transparent;
  cursor: pointer;
  font-weight: 650;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
}

.primary-button {
  color: #f8fafc;
  background: var(--accent);
}

.primary-button:hover {
  background: var(--accent-hover);
}

.secondary-button,
.small-button,
.close-button {
  color: var(--text);
  border-color: var(--line);
  background: var(--surface);
}

.secondary-button:hover,
.small-button:hover,
.close-button:hover {
  border-color: #aab5c5;
  background: var(--surface-strong);
}

.text-button {
  min-height: 34px;
  padding: 5px 8px;
  color: var(--accent);
  background: transparent;
}

.danger-button {
  min-height: 34px;
  padding: 6px 10px;
  color: var(--danger);
  border-color: #efcaca;
  background: var(--danger-soft);
}

.safety-banner {
  margin: 24px 0 18px;
  padding: 12px 15px;
  border: 1px solid #ead7a8;
  border-radius: var(--radius);
  color: #704d14;
  background: var(--warning-soft);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.summary-grid > div {
  display: flex;
  min-height: 90px;
  flex-direction: column;
  justify-content: center;
  padding: 16px 22px;
}

.summary-grid > div + div {
  border-left: 1px solid var(--line);
}

.summary-grid strong {
  font-variant-numeric: tabular-nums;
  font-size: 26px;
  line-height: 1.15;
}

.summary-grid span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.toolbar {
  display: flex;
  align-items: flex-end;
  gap: 14px;
  margin: 24px 0 16px;
}

.toolbar label,
.form-grid label,
.wide-field,
.login-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: #344054;
  font-size: 13px;
  font-weight: 650;
}

.search-field {
  flex: 1;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid #bfc8d5;
  border-radius: 8px;
  padding: 9px 11px;
  color: var(--text);
  background: #fdfefe;
}

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

input::placeholder,
textarea::placeholder {
  color: #7f8998;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
}

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

.project-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 5px 18px rgb(32 45 70 / 5%);
}

.project-card.is-archived {
  opacity: 0.72;
}

.card-main {
  padding: 20px;
}

.card-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.card-heading h2 {
  margin-bottom: 4px;
  font-size: 19px;
  line-height: 1.3;
}

.domain-link,
.plain-domain {
  display: inline-block;
  overflow: hidden;
  max-width: 100%;
  color: var(--accent);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.plain-domain {
  color: var(--muted);
}

.status-label {
  flex: none;
  border-radius: 7px;
  padding: 4px 8px;
  color: var(--warning);
  background: var(--warning-soft);
  font-size: 12px;
  font-weight: 700;
}

.status-label.done {
  color: var(--success);
  background: var(--success-soft);
}

.status-label.archived {
  color: var(--muted);
  background: var(--surface-strong);
}

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

.meta-item {
  min-width: 0;
}

.meta-item span,
.account-label {
  display: block;
  margin-bottom: 2px;
  color: var(--muted);
  font-size: 12px;
}

.meta-item strong,
.account-value {
  display: block;
  overflow: hidden;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-block {
  padding: 13px 14px;
  border-radius: 8px;
  background: var(--surface-strong);
}

.account-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

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

.workflow-item,
.workflow-form label,
.confirm-field {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #39465a;
  font-size: 13px;
}

.workflow-item input,
.workflow-form input,
.confirm-field input {
  width: 17px;
  min-height: 17px;
  margin: 0;
  accent-color: var(--accent);
}

.workflow-item input {
  cursor: pointer;
}

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 20px;
  border-top: 1px solid var(--line);
}

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

details.account-history {
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
}

details.account-history summary {
  width: fit-content;
  cursor: pointer;
  color: var(--accent);
}

.history-account {
  margin-top: 8px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
}

.empty-state {
  padding: 72px 20px;
  text-align: center;
  color: var(--muted);
}

.empty-state h2 {
  margin-bottom: 6px;
  color: var(--text);
}

.form-dialog {
  width: min(860px, calc(100% - 28px));
  max-height: calc(100dvh - 40px);
  padding: 0;
  border: 0;
  border-radius: 12px;
  color: var(--text);
  background: var(--surface);
  box-shadow: 0 28px 80px rgb(15 23 42 / 28%);
}

.small-dialog {
  width: min(720px, calc(100% - 28px));
}

.form-dialog::backdrop {
  background: rgb(18 25 38 / 56%);
}

.form-dialog form {
  padding: 24px;
}

.dialog-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

.dialog-heading h2 {
  margin-bottom: 4px;
  font-size: 23px;
}

.close-button {
  min-height: 34px;
  padding: 6px 10px;
}

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

.wide-field {
  grid-column: 1 / -1;
}

.form-section {
  margin: 22px 0;
  padding: 17px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.form-section legend {
  padding: 0 6px;
  font-weight: 730;
}

.form-section > p {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 13px;
}

.workflow-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.confirm-field {
  margin: 18px 0;
  font-weight: 680;
}

.required {
  color: var(--danger);
  font-size: 11px;
}

.history-panel {
  margin: 20px 0 0;
  padding: 16px;
  border-radius: var(--radius);
  background: var(--surface-strong);
}

.history-panel h3 {
  margin-bottom: 10px;
  font-size: 15px;
}

.activity-row {
  display: grid;
  grid-template-columns: 120px 110px 1fr;
  gap: 12px;
  padding: 7px 0;
  color: var(--muted);
  font-size: 12px;
}

.activity-row strong {
  color: var(--text);
}

.dialog-actions {
  justify-content: flex-end;
  margin-top: 22px;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 20;
  max-width: min(420px, calc(100% - 44px));
  padding: 12px 16px;
  border-radius: 8px;
  color: #f8fafc;
  background: #243248;
  box-shadow: var(--shadow);
}

.toast.error {
  background: #8a3030;
}

.login-page {
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-shell {
  width: 100%;
  max-width: 430px;
}

.login-panel {
  padding: 34px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.login-panel .brand-mark {
  margin-bottom: 13px;
}

.product-name {
  margin-bottom: 20px;
  color: var(--muted);
  font-weight: 700;
}

.login-panel h1 {
  margin-bottom: 6px;
  font-size: 28px;
}

.login-help,
.security-note {
  color: var(--muted);
}

.login-form {
  display: grid;
  gap: 15px;
  margin-top: 22px;
}

.login-form .primary-button {
  margin-top: 4px;
}

.security-note {
  margin: 22px 0 0;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  font-size: 12px;
}

.form-error:empty {
  display: none;
}

.form-error {
  margin: 16px 0 0;
  padding: 9px 11px;
  border-radius: 8px;
  color: var(--danger);
  background: var(--danger-soft);
}

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

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

@media (max-width: 640px) {
  .app-header {
    padding: 0 15px;
  }

  .brand {
    font-size: 15px;
  }

  .page-shell {
    width: min(100% - 24px, 1420px);
    padding-top: 22px;
  }

  .page-heading,
  .toolbar,
  .card-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .heading-actions,
  .card-actions {
    width: 100%;
  }

  .heading-actions > *,
  .card-actions > * {
    flex: 1;
  }

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

  .summary-grid > div:nth-child(3) {
    border-left: 0;
  }

  .summary-grid > div:nth-child(n+3) {
    border-top: 1px solid var(--line);
  }

  .form-dialog form,
  .login-panel {
    padding: 20px;
  }

  .form-grid,
  .workflow-form,
  .meta-grid,
  .workflow-list,
  .account-grid {
    grid-template-columns: 1fr;
  }

  .activity-row {
    grid-template-columns: 1fr;
    gap: 1px;
  }
}

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