:root {
  color-scheme: light;
  font: 100%/1.5 system-ui, "Microsoft YaHei", sans-serif;
  --forest: #173328;
  --paper: #fffef9;
  --ink: #172a21;
  --muted: #52645a;
  --line: #dce3dc;
  --green: #285640;
  --red: #93392b;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100vh; background: #f4f6ef; color: var(--ink); }
h1, h2, p { margin: 0; }
h1 { font-size: clamp(1.6rem, 4vw, 2.25rem); line-height: 1.25; letter-spacing: -.035em; }
h2 { font-size: 1.35rem; line-height: 1.35; }

.topbar { background: var(--forest); color: white; }
.topbar-inner { width: min(100% - 2rem, 68rem); margin: auto; min-height: 4.5rem; display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.brand { display: flex; gap: .8rem; align-items: center; font-size: .95rem; font-weight: 700; }
.brand-mark { display: grid; place-items: center; width: 2rem; height: 2rem; border-radius: .55rem; background: #f6cf79; flex: 0 0 auto; }
.brand-mark::before { content: ""; width: .875rem; height: .875rem; background: var(--forest); clip-path: polygon(0 0, 30% 0, 30% 35%, 70% 35%, 70% 0, 100% 0, 100% 70%, 75% 70%, 75% 100%, 25% 100%, 25% 70%, 0 70%); }
.loading { margin: 5rem 1rem; color: var(--muted); text-align: center; }

.login-card, .accounts-card, dialog { background: var(--paper); border: 1px solid var(--line); border-radius: 1rem; box-shadow: 0 12px 32px #203b2710; }
.login-card { width: min(100% - 2rem, 26rem); margin: clamp(2.5rem, 11vh, 7.5rem) auto; padding: clamp(1.4rem, 5vw, 2.25rem); }
.login-card h1 { margin-bottom: 1.65rem; font-size: 1.75rem; }
form, .field { display: grid; gap: .45rem; }
form > input, form > .field { margin-bottom: .75rem; }
label { color: var(--ink); font-weight: 650; font-size: .92rem; }
input { width: 100%; min-height: 2.75rem; border: 1px solid #bbc9bf; border-radius: .55rem; background: white; color: inherit; font: inherit; padding: .5rem .7rem; }
input:focus { border-color: var(--green); }
:focus-visible { outline: 3px solid #bd8623; outline-offset: 2px; }
.field-hint { color: var(--muted); font-size: .875rem; }

.button { min-height: 2.75rem; border: 1px solid transparent; border-radius: .55rem; padding: .52rem .9rem; font: inherit; font-size: .9rem; font-weight: 700; white-space: nowrap; cursor: pointer; }
.button:disabled { opacity: .55; cursor: default; }
.button-primary { background: var(--green); color: white; }
.button-primary:hover:not(:disabled) { background: var(--forest); }
.button-secondary { border-color: var(--line); background: white; color: var(--ink); }
.button-secondary:hover:not(:disabled) { background: #edf3ed; }
.button-light { background: transparent; color: white; border-color: #ffffff55; }
.button-light:hover:not(:disabled) { background: #ffffff18; }
.button-danger { background: var(--red); color: white; }
.button-danger:hover:not(:disabled) { background: #702a21; }
.button-quiet { background: transparent; color: var(--green); }
.button-quiet:hover:not(:disabled) { background: #edf3ed; }
.button-quiet.danger { color: var(--red); }

.dashboard { width: min(100% - 2rem, 68rem); margin: clamp(2rem, 6vw, 4rem) auto; }
.dashboard-nav { display: flex; flex-wrap: wrap; gap: .35rem; margin: 0 0 1.65rem; padding-bottom: .6rem; border-bottom: 1px solid var(--line); }
.dashboard-nav .button { background: transparent; color: var(--muted); }
.dashboard-nav [aria-pressed="true"] { background: #e1ece1; color: var(--forest); }
.dashboard-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.35rem; }
.dashboard-heading p { color: var(--muted); margin-top: .35rem; }
.accounts-card { overflow: hidden; }
.accounts-card > p { color: var(--muted); padding: 3rem 1rem; text-align: center; }
table { width: 100%; border-collapse: collapse; text-align: left; }
th, td { padding: .85rem 1.15rem; }
thead { background: #eaf0e8; }
th { color: #405747; font-size: .9rem; font-weight: 650; }
th:last-child, td:last-child { text-align: right; }
td { border-top: 1px solid var(--line); }
td:first-child { font-weight: 700; overflow-wrap: anywhere; }
td:nth-child(3) { color: var(--muted); white-space: nowrap; }
.account-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .15rem; }
.account-lookup-actions { display: flex; gap: .15rem; }
.status { display: inline-block; border-radius: 1rem; background: #deeedc; color: #234c34; padding: .23rem .65rem; font-size: .875rem; font-weight: 650; white-space: nowrap; }
.status.disabled { background: #ecebe6; color: #55564f; }
.status.failed { background: #f9e5df; color: var(--red); }
.notice { margin-bottom: .8rem; padding: .65rem .85rem; border-radius: .55rem; background: #e2efe2; color: #234c34; }
.error { color: var(--red); font-size: .9rem; }
.notice.error { background: #fff0ea; }
.settings-card { max-width: 30rem; padding: 1.25rem; gap: .75rem; }
.settings-card label { display: flex; align-items: center; gap: .65rem; min-height: 2.5rem; }
.settings-card input[type="checkbox"] { width: 1.15rem; height: 1.15rem; min-height: 0; margin: 0; accent-color: var(--green); }
.settings-card p { color: var(--muted); }
.settings-card button { justify-self: start; }
.access-filter { display: flex; align-items: end; flex-wrap: wrap; gap: .65rem; margin-bottom: 1rem; }
.access-filter > .field { flex: 1 1 10rem; margin: 0; max-width: 16rem; }
select { min-height: 2.75rem; border: 1px solid #bbc9bf; border-radius: .55rem; background: white; color: inherit; font: inherit; padding: .45rem .7rem; }
.access-card > p { padding: .65rem 1rem; text-align: left; font-size: .9rem; }
.access-card td:first-child { font-variant-numeric: tabular-nums; }
.access-card td:nth-child(2), .access-card td:nth-child(5) { color: var(--muted); font-size: .875rem; }
.access-card td:nth-child(3) { white-space: normal; overflow-wrap: anywhere; }
.access-pages { display: flex; align-items: center; justify-content: flex-end; gap: .7rem; margin-top: .75rem; color: var(--muted); font-size: .875rem; }
.revealed-password { display: block; unicode-bidi: plaintext; white-space: pre-wrap; overflow-wrap: anywhere; margin: .35rem 0; padding: .65rem .85rem; background: #eaf0e8; border: 1px solid var(--line); border-radius: .55rem; font-size: 1rem; }
#password-account { overflow-wrap: anywhere; }

dialog { width: min(100% - 2rem, 27rem); max-height: calc(100% - 2rem); overflow: auto; color: var(--ink); padding: 1.5rem; }
dialog::backdrop { background: #142b22a6; }
dialog h2 { margin-bottom: .45rem; }
#action-description { margin-bottom: .65rem; overflow-wrap: anywhere; }
.dialog-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: .65rem; margin-top: .25rem; }

@media (max-width: 42rem) {
  .topbar-inner { min-height: 4rem; }
  .dashboard-heading { align-items: flex-start; }
  thead { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; clip-path: inset(50%); overflow: hidden; }
  table, tbody { display: block; }
  tbody tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .35rem .7rem; padding: .85rem 1rem; }
  tbody tr + tr { border-top: 1px solid var(--line); }
  td { border: 0; padding: 0; }
  td:nth-child(2) { text-align: right; }
  td:nth-child(3) { grid-row: 2; grid-column: 1 / -1; font-size: .875rem; }
  td:last-child { grid-column: 1 / -1; }
  .access-card td:nth-child(2) { grid-row: 2; grid-column: 1 / -1; text-align: left; }
  .access-card td:nth-child(3) { grid-row: 3; grid-column: 1; }
  .access-card td:nth-child(4) { grid-row: 1; grid-column: 2; text-align: right; }
  .access-card td:nth-child(5) { grid-row: 3; grid-column: 2; }
}
