:root {
  color-scheme: light;
  --ink: #172f2b;
  --muted: #506560;
  --brand: #146558;
  --brand-dark: #153732;
  --accent: #a16c2c;
  --paper: #eff4f2;
  --line: #d9e4df;
  --panel: #fff;
  --danger: #8c2c28;
  --danger-bg: #fff0ed;
  --ok: #1d6352;
  --ok-bg: #eaf5ef;
  font: 16px/1.55 "Instrument Sans", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; color: var(--ink); background: var(--paper); }
h1, h2, p { margin: 0; }
a { color: inherit; }
button, input, select { font: inherit; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, .table-scroll:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
button:disabled { cursor: default; opacity: .56; }

.brand {
  display: inline-flex;
  align-items: center;
  gap: .625rem;
  color: #eff7f1;
  text-decoration: none;
}
.brand-mark {
  display: grid;
  width: 2.3rem;
  height: 2.3rem;
  place-items: center;
  border-radius: .45rem;
  background: #d7ebe0;
  color: #17473d;
  font-size: 1.25rem;
  font-weight: 750;
}
.brand strong { display: block; font-size: 1rem; letter-spacing: .03em; line-height: 1.2; }
.brand small { display: block; margin-top: .14rem; font-size: .63rem; letter-spacing: .13em; color: #c3d7cd; }
.eyebrow { color: #317362; font-size: .875rem; font-weight: 650; }
.secondary-text, .form-note, .field small { color: var(--muted); font-size: .875rem; }

.login-page {
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  align-items: center;
  padding: 2.4rem 1.2rem;
  background: radial-gradient(ellipse at 80% 6%, #e3efea, transparent 56%), var(--paper);
}
.login-shell {
  width: min(100%, 57rem);
  min-height: 34rem;
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  margin: 0 auto;
  border: 1px solid #d1dfd9;
  border-radius: .9rem;
  background: var(--panel);
  overflow: hidden;
  box-shadow: 0 1rem 3rem rgb(30 64 53 / 9%);
}
.login-intro {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 3rem;
  min-width: 0;
  padding: clamp(1.7rem, 5vw, 3.1rem);
  color: #f4faf6;
  background:
    radial-gradient(ellipse at 118% 44%, #286759, transparent 64%),
    linear-gradient(148deg, var(--brand-dark), #16463c);
}
.login-intro-copy { padding-bottom: clamp(0rem, 4vw, 2.3rem); }
.login-intro-copy .eyebrow { color: #c9e3d8; }
.login-intro h1 {
  max-width: 12em;
  margin: .35rem 0 .65rem;
  font-weight: 760;
  font-size: clamp(2rem, 5vw, 3.2rem);
  line-height: 1.2;
  letter-spacing: -.038em;
}
.login-intro p:last-child { color: #d4e8de; }
.login-panel { align-self: center; padding: clamp(1.4rem, 5vw, 3.1rem); }
.form-heading { margin-bottom: 1.4rem; }
.form-heading h2 { margin-bottom: .3rem; font-size: 1.6rem; letter-spacing: -.035em; }
.form-heading p { color: var(--muted); font-size: .9375rem; }

form { margin: 0; }
fieldset { margin: 0; padding: 0; border: 0; min-width: 0; }
.field { display: grid; gap: .34rem; margin-bottom: 1rem; }
.field label, .search-field label { color: #253e38; font-size: .875rem; font-weight: 650; }
.field input, .field select, .search-field input {
  width: 100%;
  min-width: 0;
  min-height: 2.75rem;
  border: 1px solid #c5d5cf;
  border-radius: .38rem;
  padding: .5rem .68rem;
  color: var(--ink);
  background: #fff;
}
.field select {
  appearance: none;
  padding-right: 2rem;
  background:
    linear-gradient(45deg, transparent 50%, #4d7065 50%) top 1.2rem right 1rem / .34rem .34rem no-repeat,
    linear-gradient(135deg, #4d7065 50%, transparent 50%) top 1.2rem right .66rem / .34rem .34rem no-repeat,
    #fff;
}
input::placeholder { color: #657771; }
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.62rem;
  max-width: 100%;
  padding: .44rem .84rem;
  border: 1px solid transparent;
  border-radius: .37rem;
  font-size: .875rem;
  font-weight: 660;
  line-height: 1.3;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}
.button.primary { background: var(--brand); color: #fff; }
.button.primary:hover:not(:disabled) { background: #0e5248; }
.button.wide { width: 100%; min-height: 2.75rem; }
.button.secondary { border-color: #bfd1c9; background: #fff; color: #22554a; }
.button.secondary:hover:not(:disabled) { background: #eff7f3; }
.feedback { font-size: .875rem; line-height: 1.45; }
.feedback:not(:empty) {
  background: #edf5f1;
  color: #375e53;
  border-radius: .35rem;
  margin-bottom: .7rem;
  padding: .52rem .68rem;
}
.feedback[data-tone="error"]:not(:empty) { background: var(--danger-bg); color: var(--danger); }
.feedback[data-tone="success"]:not(:empty) { background: var(--ok-bg); color: var(--ok); }

.topbar { color: #eef7f1; background: var(--brand-dark); }
.topbar-inner {
  width: min(calc(100% - 2.6rem), 74rem);
  min-height: 4.15rem;
  margin: 0 auto;
  padding: .65rem 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .55rem 1rem;
}
.header-actions { display: flex; align-items: center; flex-wrap: wrap; gap: .48rem; }
.button.header-button { color: #eef7f1; background: transparent; border-color: #52796f; min-height: 2.28rem; }
.button.header-button:hover { background: #25574c; }
.manage-main { width: min(calc(100% - 2.6rem), 74rem); margin: 0 auto; padding: 2.05rem 0 3rem; }
.page-heading { margin-bottom: 1.25rem; }
.page-heading h1 { margin: .12rem 0 .28rem; font-size: clamp(1.85rem, 5vw, 2.6rem); letter-spacing: -.035em; line-height: 1.2; }
.page-heading p:last-child { color: var(--muted); }
.manage-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(17rem, 1fr);
  align-items: start;
  gap: .95rem;
}
.card { min-width: 0; border: 1px solid var(--line); border-radius: .58rem; background: var(--panel); }
.card-header { padding: 1.05rem 1.15rem; }
.card-header h2 { margin: 0; font-size: 1.125rem; font-weight: 710; }
.card-header p { margin-top: .13rem; }
.accounts-heading, .edit-heading { display: flex; align-items: end; justify-content: space-between; flex-wrap: wrap; gap: .6rem; }
.search-field { display: grid; gap: .23rem; width: min(100%, 12rem); }
.search-field input { min-height: 2.3rem; font-size: .875rem; }
.card-form { padding: 0 1.15rem 1rem; }
.table-scroll { max-height: 37rem; overflow: auto; border-top: 1px solid var(--line); }
.accounts-table { width: 100%; min-width: 27rem; border-collapse: collapse; font-size: .875rem; }
.accounts-table th, .accounts-table td { padding: .53rem .73rem; text-align: left; border-bottom: 1px solid var(--line); }
.accounts-table th:first-child, .accounts-table td:first-child { padding-left: 1.15rem; }
.accounts-table th { position: sticky; top: 0; color: #304c44; white-space: nowrap; background: #eaf3ef; }
.accounts-table td:last-child { width: 1%; white-space: nowrap; }
.accounts-table tbody tr:last-child td { border-bottom: 0; }
.accounts-table td.table-message { padding: 1.15rem; color: var(--muted); }
.phone { white-space: nowrap; font-variant-numeric: tabular-nums; }
.badge { display: inline-block; padding: .12rem .42rem; border-radius: .26rem; background: #eef1f0; color: #4e625d; }
.badge.active { background: #e3f1ea; color: #23594a; }
.button.table-action { min-height: 2rem; padding: .22rem .58rem; }
.retry-line { padding: .8rem 1.15rem; border-top: 1px solid var(--line); }

.account-dialog {
  width: min(28rem, calc(100% - 2rem));
  max-height: calc(100% - 2rem);
  padding: 0;
  border: 1px solid #c6d9d2;
  border-radius: .62rem;
  background: #fff;
  color: var(--ink);
  box-shadow: 0 .9rem 2.3rem rgb(20 51 42 / 21%);
}
.account-dialog::backdrop { background: rgb(15 46 39 / 47%); }
.account-dialog .card-form { padding-top: .15rem; }
.account-dialog .edit-heading { align-items: center; }
.check-field { display: flex; align-items: center; gap: .55rem; margin-bottom: 1rem; color: #253e38; font-weight: 650; font-size: .875rem; }
.check-field input { width: 1rem; height: 1rem; accent-color: var(--brand); }
.form-note { margin: 0 0 .65rem; }
.dialog-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .48rem; }

.archive-main { max-width: 58rem; }
.archive-controls {
  display: flex;
  align-items: end;
  flex-wrap: wrap;
  gap: .65rem;
  margin-bottom: 1rem;
  padding: .9rem 1.15rem;
}
.archive-controls input, .archive-controls .button { min-height: 2.45rem; }
.archive-count { margin: auto 0 .1rem auto; }
.archive-results { display: grid; gap: .65rem; }
.archive-day-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .6rem;
}
.archive-day time { font-variant-numeric: tabular-nums; }
.archive-empty { padding: 1.3rem 1.15rem; color: var(--muted); }
.archive-versions { border-top: 1px solid var(--line); }
.archive-versions summary {
  padding: .65rem 1.15rem;
  color: var(--brand);
  font-weight: 650;
  cursor: pointer;
}
.archive-versions summary:focus-visible { outline: 2px solid var(--accent); outline-offset: -3px; }
.archive-version-list { display: grid; gap: .6rem; margin: 0; padding: .25rem 1.15rem .8rem; list-style: none; }
.archive-version-list li { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: .45rem; }
.archive-version-list .button { min-height: 2.2rem; }

@media (max-width: 760px) {
  .login-shell { grid-template-columns: 1fr; width: min(100%, 33rem); }
  .login-intro { gap: 1.3rem; }
  .login-intro-copy { padding-bottom: 0; }
  .login-intro h1 { font-size: clamp(1.8rem, 7vw, 2.3rem); }
  .manage-grid { grid-template-columns: 1fr; }
  .create-panel { grid-row: 1; }
}

@media (max-width: 420px) {
  .login-page { display: block; padding: .8rem; }
  .topbar-inner, .manage-main { width: calc(100% - 1.45rem); }
  .header-actions .button { padding-inline: .5rem; }
  .search-field { width: 100%; }
  .archive-count { margin: auto 0 .1rem; }
}
