:root {
  color-scheme: light;
  --paper: #f7f6f2;
  --surface: #fffefa;
  --ink: #252722;
  --muted: #65685e;
  --line: #dcdcd1;
  --accent: #a24d31;
  --tint: #f6e8df;
  --radius: 14px;
  font-family: "DM Sans", "Segoe UI", "Microsoft YaHei UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; line-height: 1.55; }
[hidden] { display: none !important; }
input, select, button, textarea { font: inherit; color: inherit; }
button, select, summary { cursor: pointer; }
a { color: var(--accent); }
button:focus-visible, a:focus-visible, summary:focus-visible,
input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 3px solid #aa644a;
  outline-offset: 3px;
}

.topbar {
  min-height: 65px;
  padding: 12px max(5vw, calc((100vw - 1176px) / 2));
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.brand, .header-tools, .actions, .tools, .row-actions, .dialog-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 9px;
}
.brand { gap: 10px; font-weight: 650; letter-spacing: -.02em; }
.brand-mark, .avatar {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  background: var(--tint);
  color: var(--accent);
}
.brand-mark { width: 33px; height: 33px; border-radius: 10px; font-size: 23px; }
.brand-mark svg { width: 24px; height: 24px; }
.header-tools { font-size: .86rem; }
.shell { width: min(90%, 1176px); margin: 0 auto; padding: clamp(32px, 5vw, 72px) 0 70px; }
.page-head, .panel-head, .dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 18px;
}
.page-head { align-items: flex-end; margin-bottom: 29px; }
.eyeline { margin: 0 0 6px; font-size: .75rem; font-weight: 650; letter-spacing: .09em; color: var(--accent); }
h1, h2, h3, p { margin: 0; }
h1 {
  font-family: "Source Serif 4", Georgia, "Songti SC", SimSun, serif;
  font-size: clamp(2rem, 3.8vw, 3.5rem);
  font-weight: 500;
  line-height: 1.14;
  letter-spacing: -.035em;
}
h2 { font-size: 1.25rem; line-height: 1.4; letter-spacing: -.016em; }
h3 { font-size: 1rem; }
.page-head p:not(.eyeline), .vault-card p { color: var(--muted); }
.page-head h1 + p { margin-top: 9px; }

.button, .icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 15px;
  min-height: 39px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  text-decoration: none;
  line-height: 1.35;
  font-size: .88rem;
  font-weight: 600;
}
.button:hover, .icon-button:hover { background: #f0f0e8; border-color: #b8bbae; }
.primary { background: var(--accent); border-color: var(--accent); color: white; }
.primary:hover { background: #864029; border-color: #864029; }
.ghost { background: transparent; }
.danger { color: #983e35; }
.icon-button { min-width: 38px; padding: 8px; }
button:disabled { opacity: .55; cursor: default; }

.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(160px, 100%), 1fr));
  padding: 6px 0;
  border-block: 1px solid var(--line);
  margin-bottom: 30px;
}
.metric { display: flex; flex-direction: column; padding: 14px 22px; }
.metric:first-child { padding-left: 0; }
.metric + .metric { border-left: 1px solid var(--line); }
.metric-title, .meta, dt { color: var(--muted); font-size: .84rem; }
.metric-value { margin-top: auto; font-size: clamp(1.6rem, 3vw, 2.35rem); font-weight: 550; line-height: 1.22; font-variant-numeric: tabular-nums; }
#due-count { color: var(--accent); }
.notice, .alert, #feedback {
  margin: 0 0 14px;
  padding: 11px 15px;
  border: 1px solid #e6c9a4;
  background: #fff2dc;
  color: #77451b;
  border-radius: 8px;
  overflow-wrap: anywhere;
}
#feedback { background: var(--surface); color: var(--ink); border-color: var(--line); }
#feedback.alert { color: #823b2d; background: #fff0e9; }
.panel, .vault-card {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: var(--radius);
}
.panel-head { padding: 21px 24px; border-bottom: 1px solid var(--line); }
.search, input, textarea, select {
  min-width: 0;
  max-width: 100%;
  padding: 8px 11px;
  border: 1px solid #c9cbbf;
  border-radius: 7px;
  background: var(--surface);
  line-height: 1.45;
}
.tools input { width: clamp(215px, 25vw, 320px); }
.tools, .tools input, .tools select { font-size: .88rem; }
.team + .team { border-top: 1px solid var(--line); }
.team-head, .child-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  padding: 17px 24px;
}
.avatar { width: 38px; height: 38px; border-radius: 11px; font-size: .9rem; font-weight: 650; }
.identity { min-width: 0; flex: 1 1 155px; }
.account-email, .identity, dd { overflow-wrap: anywhere; }
.row-actions { gap: 6px; }
.row-actions .button { min-height: 32px; padding: 5px 10px; font-size: .81rem; }
.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 99px;
  color: #42553b;
  background: #eaf0e4;
  font-size: .75rem;
  font-weight: 600;
}
.soon, .today { color: #794816; background: #fff0d3; }
.expired { color: #8c4238; background: #f8e4de; }
.team-body { margin: 0 24px 20px; padding: 16px; border-radius: 9px; background: #f6f6ef; }
.details { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(158px, 100%), 1fr)); gap: 15px; margin: 0; }
dd { margin: 3px 0 0; font-size: .92rem; white-space: pre-wrap; }
.team-body > .panel-head { padding: 0 0 10px; margin-bottom: 12px; }
.billing-details h4 { margin: 12px 0 8px; }
.children { margin-top: 18px; }
.child-row { display: block; padding: 11px 0; border-top: 1px solid var(--line); font-size: .9rem; }
.child-row .team-head { padding: 3px 0 8px; }
.empty { padding: clamp(34px, 7vw, 82px) 18px; text-align: center; color: var(--muted); overflow-wrap: anywhere; }
.empty h3 { margin-bottom: 6px; color: var(--ink); font-size: 1.1rem; }
.empty .button { margin-top: 16px; }

.dialog.vault-card { width: min(460px, calc(100% - 32px)); }
.vault-card .form-grid { margin-top: 17px; }
.dialog {
  width: min(620px, calc(100% - 32px));
  max-height: calc(100dvh - 48px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 14px 65px #25272226;
}
.dialog::backdrop { background: #292a245c; }
.dialog > form, .dialog > section { padding: clamp(18px, 3vw, 28px); }
.dialog-head { margin-bottom: 18px; align-items: flex-start; }
#payment-fields:not(:empty) { margin: 18px 0; }
.payment-group { min-width: 0; margin: 12px 0; padding: 14px; background: var(--paper); border: 1px solid var(--line); border-radius: 8px; }
.payment-group legend { padding: 0 5px; font-size: .9rem; font-weight: 600; }
.payment-group > .button { margin-top: 12px; }
#account-form > .actions { margin-top: 15px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; }
.field { min-width: 0; display: grid; align-content: start; gap: 5px; font-size: .88rem; }
.field input, .field select, .field textarea { width: 100%; }
textarea { resize: vertical; }
.wide, .form-grid > details { grid-column: 1 / -1; }
.dialog details { border-top: 1px solid var(--line); padding-top: 12px; }
summary { font-weight: 600; }
summary + .form-grid { margin-top: 14px; }
.dialog-actions { justify-content: flex-end; padding-top: 18px; margin-top: 20px; border-top: 1px solid var(--line); }

@media (max-width: 640px) {
  .shell { width: calc(100% - 32px); padding-top: 27px; }
  .topbar { padding-inline: 16px; }
  .page-head { align-items: flex-start; }
  .metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .metric { padding: 8px 10px; }
  .metric-title { display: block; line-height: 1.4; }
  .panel-head, .team-head { padding: 15px; }
  .team-body { margin: 0 12px 14px; }
  .team-head .row-actions { flex-basis: 100%; }
  .tools, .search, .tools input { width: 100%; max-width: 100%; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
}
