:root {
  --ink: #18201d;
  --muted: #68736e;
  --paper: #f6f7f2;
  --card: #ffffff;
  --line: #dfe5df;
  --green: #235c45;
  --green-dark: #174532;
  --green-pale: #e6f1e9;
  --amber: #b56f20;
  --red: #a33a35;
  --shadow: 0 24px 70px rgba(29, 54, 43, 0.1);
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--paper); }

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 8%, rgba(116, 157, 127, .17), transparent 25rem),
    linear-gradient(180deg, #fbfcf8 0%, var(--paper) 100%);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  display: flex;
  flex-direction: column;
}

a { color: inherit; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }

.site-header {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  min-height: 86px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  text-decoration: none;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  color: white;
  font-family: Georgia, serif;
  font-size: 21px;
  background: var(--green);
  box-shadow: 0 8px 20px rgba(35, 92, 69, .22);
}

.brand strong, .brand small { display: block; }
.brand strong { font-size: 16px; letter-spacing: .05em; }
.brand small { margin-top: 2px; color: var(--muted); font-size: 9px; letter-spacing: .16em; text-transform: uppercase; }

.page-shell {
  width: min(1180px, calc(100% - 40px));
  margin: auto;
  padding: 42px 0 70px;
}

.hero-grid {
  min-height: 610px;
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(380px, .8fr);
  gap: clamp(40px, 9vw, 125px);
  align-items: center;
}

.eyebrow {
  display: inline-block;
  color: var(--green);
  font-size: 12px;
  font-weight: 750;
  letter-spacing: .2em;
  text-transform: uppercase;
}

.hero-copy h1, .mailbox-header h1, .admin-heading h1 {
  margin: 18px 0;
  font-family: Georgia, "Songti SC", serif;
  font-size: clamp(46px, 7vw, 84px);
  font-weight: 500;
  line-height: 1.03;
  letter-spacing: -.04em;
}

.hero-copy > p {
  max-width: 520px;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.8;
}

.trust-list { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 34px; }
.trust-list span, .badge {
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255,255,255,.7);
  color: var(--green-dark);
  font-size: 12px;
  font-weight: 700;
}

.card {
  background: rgba(255,255,255,.93);
  border: 1px solid rgba(211, 221, 213, .9);
  border-radius: 28px;
  box-shadow: var(--shadow);
}

.access-card { padding: clamp(26px, 5vw, 48px); }
.card-heading, .section-heading > div { display: flex; align-items: center; gap: 15px; margin-bottom: 34px; }
.card-heading h2, .section-heading h2 { margin: 0 0 5px; font-size: 20px; }
.card-heading p, .section-heading p { margin: 0; color: var(--muted); font-size: 13px; }

.step-number {
  flex: 0 0 auto;
  width: 39px;
  height: 39px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--green);
  background: var(--green-pale);
  font-size: 12px;
  font-weight: 800;
}

.form-stack { display: grid; gap: 20px; }
label > span { display: block; margin: 0 0 8px 2px; font-size: 13px; font-weight: 750; }

input {
  width: 100%;
  height: 52px;
  padding: 0 16px;
  color: var(--ink);
  background: #fafbf8;
  border: 1px solid var(--line);
  border-radius: 12px;
  outline: none;
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}

input:focus {
  background: white;
  border-color: #5d8a70;
  box-shadow: 0 0 0 4px rgba(63, 111, 82, .11);
}

select {
  width: 100%;
  height: 52px;
  padding: 0 38px 0 14px;
  color: var(--ink);
  background: #fafbf8;
  border: 1px solid var(--line);
  border-radius: 12px;
  outline: none;
}

select:focus { background: white; border-color: #5d8a70; box-shadow: 0 0 0 4px rgba(63, 111, 82, .11); }

textarea {
  width: 100%;
  min-height: 150px;
  padding: 14px 16px;
  color: var(--ink);
  background: #fafbf8;
  border: 1px solid var(--line);
  border-radius: 12px;
  outline: none;
  resize: vertical;
  line-height: 1.65;
}

textarea:focus { background: white; border-color: #5d8a70; box-shadow: 0 0 0 4px rgba(63, 111, 82, .11); }

input[type="checkbox"] {
  width: 18px;
  height: 18px;
  padding: 0;
  accent-color: var(--green);
  cursor: pointer;
}

.primary-button, .secondary-button, .mini-button, .copy-button, .text-button {
  border: 0;
  border-radius: 11px;
  font-weight: 750;
}

.primary-button {
  min-height: 54px;
  padding: 0 20px;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  color: white;
  background: var(--green);
  box-shadow: 0 10px 24px rgba(35, 92, 69, .2);
}
.primary-button:hover { background: var(--green-dark); }

.secondary-button {
  min-height: 43px;
  padding: 0 17px;
  color: var(--green);
  border: 1px solid #b9cbbf;
  background: white;
}
.secondary-button:hover { background: var(--green-pale); }
.button-link { display: inline-flex; align-items: center; text-decoration: none; }

.text-button { padding: 8px; color: var(--green); background: transparent; }
.text-button:hover { text-decoration: underline; }
.fine-print, .privacy-note { margin: 20px 0 0; color: #84908a; font-size: 11px; line-height: 1.6; }

.site-footer {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 24px 0 30px;
  color: #8a948f;
  display: flex;
  justify-content: center;
  gap: 9px;
  font-size: 11px;
}
.site-footer a { text-underline-offset: 3px; }

.flash-stack { position: relative; z-index: 2; display: grid; gap: 10px; margin-bottom: 24px; }
.flash { padding: 14px 16px; border-radius: 12px; display: flex; align-items: center; justify-content: space-between; gap: 14px; font-size: 13px; }
.flash-error { color: #7b2926; background: #f9e5e3; border: 1px solid #efc7c3; }
.flash-success { color: #20573f; background: #e4f2e8; border: 1px solid #bedac7; }
.flash-info { color: #36576b; background: #e7f0f5; border: 1px solid #c6d9e4; }
.flash-code { color: #4f3b16; background: #fff3d4; border: 1px solid #ead39c; font-weight: 700; }
.copy-button { padding: 7px 11px; color: var(--green); background: white; border: 1px solid var(--line); font-size: 12px; }

.mailbox-header, .admin-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 30px;
  margin-bottom: 38px;
}
.mailbox-header h1, .admin-heading h1 { margin: 10px 0 5px; font-size: clamp(32px, 5vw, 58px); overflow-wrap: anywhere; }
.mailbox-header p, .admin-heading p { margin: 0; color: var(--muted); }

.mail-list { display: grid; gap: 16px; }
.mail-card { padding: 24px; background: white; border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 8px 30px rgba(29, 54, 43, .05); }
.mail-meta { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 14px; align-items: center; }
.sender-avatar { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; color: var(--green); background: var(--green-pale); font-family: Georgia, serif; font-weight: 700; }
.mail-heading { min-width: 0; }
.mail-heading h2 { margin: 0 0 5px; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-heading p, .mail-meta time { margin: 0; color: var(--muted); font-size: 12px; }
.mail-meta time { white-space: nowrap; }
.code-panel { margin: 20px 0 5px 56px; padding: 15px 18px; display: flex; align-items: center; gap: 16px; border-radius: 13px; background: var(--green-pale); }
.code-panel span { color: var(--muted); font-size: 12px; }
.code-panel strong { margin-right: auto; color: var(--green-dark); font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 24px; letter-spacing: .11em; }
details { margin: 18px 0 0 56px; }
summary { color: var(--green); cursor: pointer; font-size: 13px; font-weight: 700; }
.mail-body { max-height: 420px; margin: 15px 0 0; padding: 18px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; color: #3b4540; background: #f7f8f5; border: 1px solid #e5e9e5; border-radius: 12px; font: 13px/1.75 ui-monospace, SFMono-Regular, Consolas, monospace; }

.empty-state { padding: 70px 30px; text-align: center; background: rgba(255,255,255,.72); border: 1px dashed #c9d3cc; border-radius: 22px; }
.empty-state strong { display: block; margin: 8px 0; font-family: Georgia, "Songti SC", serif; font-size: 25px; font-weight: 500; }
.empty-state p { max-width: 520px; margin: 0 auto; color: var(--muted); line-height: 1.7; }
.empty-icon { color: var(--green); font-size: 34px; }
.loading-state { padding: 52px 30px; }
.loading-spinner { width: 30px; height: 30px; margin: 0 auto 14px; border: 3px solid #dce8df; border-top-color: var(--green); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.error-state { border-color: #e6c4c1; background: #fff9f8; }
.compact { padding: 40px; }

.centered-section { min-height: 590px; display: grid; place-items: center; }
.login-card { width: min(450px, 100%); padding: 42px; }
.login-card h1 { margin: 12px 0 8px; font-family: Georgia, "Songti SC", serif; font-size: 38px; font-weight: 500; }
.login-card > p { margin: 0 0 30px; color: var(--muted); }

.admin-heading { align-items: center; }
.status-card { min-width: 270px; padding: 14px 16px; display: flex; align-items: center; gap: 11px; border: 1px solid var(--line); border-radius: 14px; background: white; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--amber); }
.status-ok .status-dot { background: #3b8a61; box-shadow: 0 0 0 5px rgba(59,138,97,.11); }
.status-card div { margin-right: auto; }
.status-card strong, .status-card small { display: block; }
.status-card strong { font-size: 13px; }
.status-card small { margin-top: 3px; color: var(--muted); font-size: 11px; }

.admin-card { padding: 28px; }
.icloud-settings-card { margin-bottom: 22px; }
.section-heading { margin-bottom: 22px; }
.section-heading > div { margin-bottom: 0; }
.settings-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.settings-heading > div { margin: 0; }
.icloud-account-create-form { display: grid; grid-template-columns: .8fr 1fr 1fr auto; gap: 12px; align-items: end; }
.icloud-account-create-form input { height: 46px; }
.icloud-account-create-form .primary-button { min-height: 46px; white-space: nowrap; }
.settings-note { margin: 13px 0 0; color: var(--muted); font-size: 11px; line-height: 1.6; }
.icloud-account-list { display: grid; gap: 12px; margin-top: 22px; }
.icloud-account-item { padding: 16px; border: 1px solid var(--line); border-radius: 14px; background: #fafbf9; }
.icloud-account-summary { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.icloud-account-summary > div { margin-right: auto; }
.icloud-account-summary strong, .icloud-account-summary span { display: block; }
.icloud-account-summary span { margin-top: 3px; color: var(--muted); font-size: 11px; }
.icloud-account-summary small { color: var(--muted); font-size: 11px; }
.icloud-account-edit-form { display: grid; grid-template-columns: .8fr 1fr 1fr auto; gap: 10px; align-items: end; }
.icloud-account-edit-form input, .icloud-account-edit-form .secondary-button { height: 40px; min-height: 40px; }
.icloud-account-actions { display: flex; gap: 7px; margin-top: 10px; justify-content: flex-end; }
.admin-create-form { display: grid; grid-template-columns: 1.05fr 1.2fr .9fr .7fr .9fr auto; gap: 12px; align-items: end; }
.admin-create-form input, .admin-create-form select { height: 46px; }
.admin-create-form .primary-button { min-height: 46px; white-space: nowrap; }
.batch-import-card { margin-top: 22px; }
.batch-import-form { display: grid; gap: 13px; }
.batch-import-actions { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.batch-import-actions p { margin: 0; color: var(--muted); font-size: 11px; }
.batch-import-actions .primary-button { min-height: 44px; padding: 0 18px; white-space: nowrap; }

.admin-section { margin-top: 44px; }
.section-title-row { margin-bottom: 14px; display: flex; justify-content: space-between; align-items: end; gap: 20px; }
.section-title-row h2 { margin: 0 0 4px; font-size: 20px; }
.section-title-row p { margin: 0; color: var(--muted); font-size: 12px; }
.table-wrap { overflow-x: auto; background: white; border: 1px solid var(--line); border-radius: 16px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 16px; text-align: left; border-bottom: 1px solid #edf0ed; vertical-align: middle; white-space: nowrap; }
th { color: var(--muted); background: #fafbf9; font-size: 11px; letter-spacing: .06em; }
tr:last-child td { border-bottom: 0; }
td strong, td small { display: block; }
td small { margin-top: 5px; color: var(--muted); font-size: 10px; }
.badge { display: inline-block; padding: 6px 9px; border: 0; background: var(--green-pale); }
.badge-off { color: #68706c; background: #ecefed; }
.badge-warn { color: #795018; background: #fff0ce; }
.select-column { width: 58px; text-align: center; }
.export-actions { display: flex; align-items: center; justify-content: flex-end; gap: 9px; flex-wrap: wrap; }
.selection-control { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; font-weight: 700; }
.selection-control > span { margin: 0; }
.export-button { min-height: 40px; padding: 0 14px; font-size: 12px; white-space: nowrap; }
.export-button.primary-button { box-shadow: none; }
.export-button:disabled { cursor: not-allowed; opacity: .45; }
.delete-selected-button { color: var(--red); background: #fff5f3; border-color: #f1ccc6; }
.delete-selected-button:hover:not(:disabled) { background: #ffe8e3; }
.action-row { display: flex; gap: 6px; }
.key-cell { display: flex; align-items: center; gap: 8px; }
.key-cell code { color: var(--green-dark); font-size: 12px; font-weight: 750; letter-spacing: .04em; }
.key-cell .copy-button { padding: 5px 8px; }
.mailbox-account-form { display: flex; align-items: center; gap: 6px; }
.mailbox-account-form select { min-width: 120px; height: 34px; padding-left: 9px; font-size: 11px; }
.mini-button { padding: 7px 9px; color: #425049; background: #f0f3f0; font-size: 11px; }
.mini-button:hover { background: #e3e9e4; }
.open-mailbox-button { color: white; background: var(--green); }
.open-mailbox-button:hover { background: var(--green-dark); }
.danger-button { color: var(--red); }
.admin-preview-badge { display: inline-block; margin-top: 10px; background: #fff0ce; color: #795018; }

.audit-list { background: white; border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.audit-item { padding: 12px 16px; display: grid; grid-template-columns: 160px minmax(180px, 1fr) 190px 120px; gap: 15px; align-items: center; border-bottom: 1px solid #edf0ed; font-size: 11px; }
.audit-item:last-child { border-bottom: 0; }
.audit-item strong { overflow-wrap: anywhere; }
.audit-item > span:not(.audit-event), .audit-item code { color: var(--muted); }
.audit-event { color: var(--green); font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.muted { color: var(--muted); }

@media (max-width: 980px) {
  .hero-grid { grid-template-columns: 1fr; min-height: auto; gap: 45px; }
  .hero-copy { max-width: 700px; }
  .access-card { max-width: 650px; width: 100%; }
  .admin-create-form { grid-template-columns: repeat(2, 1fr); }
  .icloud-account-create-form, .icloud-account-edit-form { grid-template-columns: repeat(2, 1fr); }
  .icloud-account-create-form .primary-button, .icloud-account-edit-form .secondary-button { grid-column: 1 / -1; justify-content: center; }
  .admin-create-form .primary-button { grid-column: 1 / -1; justify-content: center; }
  .section-title-row { align-items: flex-start; flex-direction: column; }
  .export-actions { justify-content: flex-start; }
  .audit-item { grid-template-columns: 130px 1fr 170px; }
  .audit-item code { display: none; }
}

@media (max-width: 680px) {
  .site-header, .page-shell, .site-footer { width: min(100% - 26px, 1180px); }
  .site-header { min-height: 72px; }
  .page-shell { padding: 25px 0 50px; }
  .hero-copy h1 { font-size: 50px; }
  .hero-copy > p { font-size: 15px; }
  .access-card, .login-card { padding: 25px; border-radius: 20px; }
  .mailbox-header, .admin-heading { align-items: flex-start; flex-direction: column; }
  .status-card { width: 100%; }
  .mail-card { padding: 18px; }
  .mail-meta { grid-template-columns: auto 1fr; }
  .mail-meta time { grid-column: 2; }
  .code-panel, details { margin-left: 0; }
  .code-panel { align-items: flex-start; flex-wrap: wrap; }
  .code-panel strong { width: 100%; order: 3; }
  .admin-create-form { grid-template-columns: 1fr; }
  .icloud-account-create-form, .icloud-account-edit-form { grid-template-columns: 1fr; }
  .icloud-account-create-form .primary-button, .icloud-account-edit-form .secondary-button { grid-column: auto; }
  .settings-heading { align-items: flex-start; flex-direction: column; }
  .icloud-account-summary { align-items: flex-start; flex-wrap: wrap; }
  .icloud-account-summary > div { width: 100%; }
  .batch-import-actions { align-items: stretch; flex-direction: column; }
  .batch-import-actions .primary-button { justify-content: center; }
  .admin-create-form .primary-button { grid-column: auto; }
  .audit-item { grid-template-columns: 1fr 1fr; }
  .audit-item > span:nth-child(3) { text-align: right; }
  .site-footer span:nth-child(2), .site-footer a { display: none; }
}
