:root {
  color-scheme: light;
  font-family: Inter, "SF Pro Text", "PingFang SC", "Microsoft YaHei", sans-serif;
  --bg: #f3f5f3;
  --surface: #ffffff;
  --soft: #f7f8f6;
  --text: #292c28;
  --muted: #747a73;
  --line: #dde1db;
  --dark: #232420;
  --blue: #3974bd;
  --blue-soft: #edf4fc;
  --green: #267452;
  --green-soft: #edf7f1;
  --amber: #95600e;
  --amber-soft: #fff4df;
  --red: #ac463e;
  --red-soft: #fff0ee;
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; }
body { overflow: hidden; background: var(--bg); color: var(--text); }
button, input, textarea, select { font: inherit; letter-spacing: 0; }
button { color: inherit; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, a:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
[hidden] { display: none !important; }

.mail-shell { display: grid; grid-template-columns: 220px minmax(0, 1fr); width: 100%; height: 100vh; }
.mail-sidebar { display: flex; flex-direction: column; min-height: 0; padding: 20px 13px 14px; background: var(--dark); color: #f6f7f4; }
.mail-brand { display: flex; align-items: center; gap: 11px; min-height: 48px; padding: 0 9px; color: inherit; text-decoration: none; }
.mail-brand img { width: 34px; height: 34px; border-radius: 8px; }
.mail-brand strong, .mail-brand span { display: block; }
.mail-brand strong { font-size: 13px; }
.mail-brand span { margin-top: 4px; color: #9ea29a; font-size: 9px; }
.workspace-nav { display: grid; gap: 5px; margin-top: 24px; }
.workspace-link { display: grid; grid-template-columns: 19px minmax(0, 1fr) auto; align-items: center; gap: 9px; width: 100%; min-height: 42px; padding: 0 11px; border: 0; border-radius: 6px; background: transparent; color: #c9ccc5; cursor: pointer; font-size: 11px; text-align: left; text-decoration: none; }
.workspace-link:hover { background: #30322d; color: #ffffff; }
.workspace-link.active { background: #3a3c36; color: #ffffff; }
.workspace-link svg { width: 16px; height: 16px; }
.workspace-link b { display: grid; min-width: 20px; height: 20px; padding: 0 5px; place-items: center; border-radius: 10px; background: #4b4e46; color: #e5e7e1; font-size: 8px; }
.mail-account { display: grid; grid-template-columns: 32px minmax(0, 1fr) 32px; align-items: center; gap: 9px; min-width: 0; margin-top: auto; padding: 14px 4px 0; border-top: 1px solid #3a3c36; }
.account-avatar { display: grid; width: 32px; height: 32px; place-items: center; border-radius: 7px; background: #f2a62c; color: #272820; font-size: 11px; font-weight: 750; }
.mail-account > div:nth-child(2) { min-width: 0; }
.mail-account strong, .mail-account span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-account strong { font-size: 10px; }
.mail-account span { margin-top: 4px; color: #9ea29a; font-size: 8px; }
.mail-account .icon-button { color: #b9bdb5; }

.mail-main { min-width: 0; min-height: 0; overflow: hidden; }
.workspace-view { width: 100%; height: 100%; }
#inboxView { position: relative; display: grid; grid-template-rows: 76px 58px minmax(0, 1fr); padding: 0 20px 20px; }
.mail-header, .mail-controls, .header-actions, .sync-state, .mail-tabs, .primary-action, .secondary-action, .danger-action, .message-search label, .message-sender-row, .reader-toolbar, .reader-actions, .reader-meta, .verification-card, .verification-card button, .row-header, .request-heading, .request-addresses, .compose-actions, .toast { display: flex; align-items: center; }
.mail-header { justify-content: space-between; gap: 20px; }
.mail-title { min-width: 0; }
.mail-title span, .section-header span { display: block; color: var(--muted); font-size: 9px; }
.mail-title h1 { max-width: min(760px, 56vw); margin: 5px 0 0; overflow: hidden; font-size: 16px; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.header-actions { gap: 12px; }
.sync-state { gap: 6px; color: var(--green); font-size: 10px; white-space: nowrap; }
.sync-state svg { width: 14px; height: 14px; }
.sync-state.syncing { color: var(--blue); }
.sync-state.syncing svg, .list-state .lucide-loader-circle, .primary-action:disabled .lucide-refresh-cw { animation: spin 1s linear infinite; }
.sync-state.error { color: var(--red); }

.icon-button { display: inline-grid; flex: 0 0 auto; width: 34px; height: 34px; padding: 0; place-items: center; border: 1px solid transparent; border-radius: 6px; background: transparent; color: inherit; cursor: pointer; text-decoration: none; }
.icon-button:hover { border-color: var(--line); background: var(--soft); }
.icon-button svg { width: 17px; height: 17px; }
.primary-action, .secondary-action, .danger-action { justify-content: center; gap: 7px; min-height: 36px; padding: 0 13px; border-radius: 6px; cursor: pointer; font-size: 11px; font-weight: 650; text-decoration: none; white-space: nowrap; }
.primary-action { border: 1px solid var(--dark); background: var(--dark); color: #ffffff; }
.primary-action:hover { background: #373832; }
.secondary-action { border: 1px solid var(--line); background: var(--surface); }
.secondary-action:hover { background: var(--soft); }
.danger-action { border: 1px solid #eccbc7; background: var(--red-soft); color: var(--red); }
.primary-action:disabled, .secondary-action:disabled, .danger-action:disabled { opacity: .55; cursor: wait; }
.primary-action svg, .secondary-action svg, .danger-action svg { width: 14px; height: 14px; }

.mail-controls { border-bottom: 1px solid var(--line); }
.mail-tabs { align-self: stretch; gap: 34px; }
.mail-tab { position: relative; align-self: stretch; padding: 0; border: 0; background: transparent; color: #454943; cursor: pointer; font-size: 11px; font-weight: 650; }
.mail-tab::after { position: absolute; right: 0; bottom: 0; left: 0; height: 2px; background: transparent; content: ""; }
.mail-tab.active { color: var(--blue); }
.mail-tab.active::after { background: var(--blue); }
.mail-tab span { display: inline-grid; min-width: 18px; height: 18px; margin-left: 3px; place-items: center; border-radius: 9px; background: var(--blue-soft); font-size: 8px; }

.mail-stage { display: grid; grid-template-columns: clamp(340px, 28vw, 480px) minmax(0, 1fr); min-height: 0; margin-top: 16px; overflow: hidden; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); }
.message-column { display: grid; grid-template-rows: 64px minmax(0, 1fr); min-width: 0; min-height: 0; border-right: 1px solid var(--line); }
.message-search { padding: 14px 16px; border-bottom: 1px solid var(--line); background: var(--soft); }
.message-search label { gap: 7px; height: 36px; padding: 0 10px; border: 1px solid #d4d9d2; border-radius: 5px; background: var(--surface); }
.message-search label:focus-within { border-color: #91acd0; }
.message-search svg { flex: 0 0 auto; width: 15px; color: var(--muted); }
.message-search input { width: 100%; min-width: 0; border: 0; outline: 0; background: transparent; font-size: 11px; }
.message-list { min-height: 0; overflow-y: auto; }
.message-item { position: relative; display: grid; width: 100%; min-height: 112px; padding: 15px 18px; overflow: hidden; border: 0; border-bottom: 1px solid var(--line); background: var(--surface); cursor: pointer; text-align: left; }
.message-item:hover { background: #fbfcfa; }
.message-item.active { background: var(--blue-soft); }
.message-item.unread::before, .message-item.new-arrival::before { position: absolute; top: 19px; left: 7px; width: 6px; height: 6px; border-radius: 50%; background: var(--blue); content: ""; }
.message-item.new-arrival::before { background: #d7931c; box-shadow: 0 0 0 3px #fff0d2; }
.message-sender-row { justify-content: space-between; gap: 12px; min-width: 0; }
.message-sender-row strong, .message-subject, .message-preview { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.message-sender-row strong { font-size: 12px; font-weight: 650; }
.message-sender-row svg { flex: 0 0 auto; width: 13px; color: #df9c22; fill: #df9c22; }
.message-subject { margin-top: 7px; font-size: 11px; font-weight: 500; }
.message-item.unread .message-subject { font-weight: 700; }
.message-code, .folder-badge { width: max-content; max-width: 100%; margin-top: 6px; padding: 3px 6px; overflow: hidden; border-radius: 4px; font-size: 8px; text-overflow: ellipsis; white-space: nowrap; }
.message-code { background: var(--amber-soft); color: var(--amber); }
.message-code b { margin-left: 4px; font-family: "SFMono-Regular", Consolas, monospace; font-size: 10px; }
.folder-badge { background: var(--red-soft); color: var(--red); }
.message-preview { margin-top: 6px; color: var(--muted); font-size: 10px; }
.message-item time { margin-top: 7px; color: var(--muted); font-size: 9px; }

.list-state, .reader-empty, .empty-view { display: grid; min-height: 100%; place-content: center; justify-items: center; gap: 11px; color: var(--muted); text-align: center; }
.list-state svg { width: 27px; height: 27px; }
.list-state span, .reader-empty span, .empty-view span { font-size: 11px; }
.message-reader { position: relative; min-width: 0; min-height: 0; overflow-y: auto; background: var(--surface); }
.reader-empty { height: 100%; }
.reader-empty svg { width: 48px; height: 48px; color: #526273; stroke-width: 1.25; }
.reader-toolbar { position: sticky; z-index: 2; top: 0; justify-content: space-between; height: 52px; padding: 0 20px; border-bottom: 1px solid var(--line); background: rgba(255, 255, 255, .96); }
.reader-actions { gap: 3px; margin-left: auto; }
.reader-actions .active { color: #d99722; }
.reader-actions .active svg { fill: #d99722; }
.mobile-back { display: none; }
.reader-content { max-width: 850px; margin: 0 auto; padding: 34px 44px 64px; }
.reader-content h2 { margin: 0; font-size: 21px; line-height: 1.4; }
.reader-meta { gap: 11px; margin-top: 22px; padding-bottom: 22px; border-bottom: 1px solid var(--line); }
.sender-mark { display: grid; flex: 0 0 38px; width: 38px; height: 38px; place-items: center; border-radius: 7px; background: var(--blue-soft); color: #2465a7; font-size: 10px; font-weight: 700; }
.reader-meta > div:nth-child(2) { min-width: 0; }
.reader-meta strong, .reader-meta span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reader-meta strong { font-size: 11px; }
.reader-meta span { margin-top: 4px; color: var(--muted); font-size: 9px; }
.reader-meta time { margin-left: auto; color: var(--muted); font-size: 9px; white-space: nowrap; }
.verification-card { justify-content: space-between; gap: 20px; margin: 24px 0; padding: 17px 18px; border: 1px solid #ead7b2; border-radius: 6px; background: var(--amber-soft); }
.verification-card span { display: block; color: var(--amber); font-size: 9px; }
.verification-card strong { display: block; margin-top: 4px; font-family: "SFMono-Regular", Consolas, monospace; font-size: 24px; }
.verification-card button { gap: 6px; min-height: 34px; padding: 0 11px; border: 1px solid #d9bd83; border-radius: 5px; background: var(--surface); cursor: pointer; font-size: 9px; }
.verification-card button svg { width: 13px; }
.message-body { color: #3f443e; font-size: 12px; line-height: 1.8; overflow-wrap: anywhere; }
.message-body p { margin: 0 0 16px; }

.section-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 30px; max-width: 980px; margin: 0 auto; padding: 46px 44px 24px; border-bottom: 1px solid var(--line); }
.section-header h1 { margin: 5px 0 0; font-size: 24px; }
.section-header p { max-width: 520px; margin: 4px 0 0; color: var(--muted); font-size: 10px; line-height: 1.7; text-align: right; }
.row-header { align-items: center; }
.compose-form { display: grid; max-width: 900px; margin: 0 auto; padding: 28px 44px 60px; }
.compose-form label, .review-dialog label { display: grid; grid-template-columns: 110px minmax(0, 1fr); align-items: start; min-height: 56px; border-bottom: 1px solid var(--line); }
.compose-form label > span, .review-dialog label > span { padding-top: 14px; color: var(--muted); font-size: 10px; font-weight: 650; }
.compose-form input, .compose-form textarea, .review-dialog textarea { width: 100%; min-width: 0; padding: 13px 0; border: 0; outline: 0; background: transparent; color: var(--text); font-size: 12px; }
.compose-form textarea { min-height: 220px; resize: vertical; line-height: 1.7; }
.compose-form .reason-field { min-height: 90px; }
.compose-form input[readonly] { color: var(--muted); }
.compose-actions { justify-content: flex-end; gap: 8px; padding-top: 20px; }

#requestsView, #reviewView, #composeView { overflow-y: auto; }
.request-list { max-width: 980px; min-height: 320px; margin: 18px auto 60px; padding: 0 44px; }
.request-row { display: grid; grid-template-columns: minmax(0, 1fr) 150px; gap: 28px; padding: 22px 0; border-bottom: 1px solid var(--line); }
.request-heading { justify-content: space-between; gap: 16px; }
.request-heading strong { min-width: 0; overflow: hidden; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.request-status { flex: 0 0 auto; min-height: 23px; padding: 5px 8px; border-radius: 12px; font-size: 8px; font-weight: 700; }
.status-pending { background: var(--amber-soft); color: var(--amber); }
.status-approved, .status-sent { background: var(--green-soft); color: var(--green); }
.status-sending { background: #e9f0fa; color: #315f95; }
.status-rejected { background: var(--red-soft); color: var(--red); }
.request-addresses { flex-wrap: wrap; gap: 6px 18px; margin-top: 10px; color: var(--muted); font-size: 9px; }
.request-main p { max-height: 72px; margin: 13px 0 0; overflow: hidden; color: #464a44; font-size: 11px; line-height: 1.65; white-space: pre-line; }
.request-main small { display: block; margin-top: 8px; color: var(--muted); font-size: 9px; }
.request-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; color: var(--muted); text-align: right; }
.request-meta strong { color: var(--text); font-size: 10px; }
.request-meta time { font-size: 9px; }
.request-meta .secondary-action { margin-top: auto; }
.empty-view { min-height: 320px; border-bottom: 1px solid var(--line); }
.empty-view svg { width: 28px; }
.empty-view.error { color: var(--red); }
#reviewStatus { height: 36px; padding: 0 30px 0 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); font-size: 10px; }

.review-dialog { width: min(620px, calc(100vw - 28px)); padding: 0; border: 0; border-radius: 8px; box-shadow: 0 24px 70px rgba(30, 34, 29, .22); }
.review-dialog::backdrop { background: rgba(24, 25, 23, .44); }
.review-dialog form > header { display: flex; align-items: flex-start; justify-content: space-between; padding: 20px 22px 16px; border-bottom: 1px solid var(--line); }
.review-dialog header span { color: var(--muted); font-size: 9px; }
.review-dialog h2 { margin: 5px 0 0; font-size: 17px; }
.review-summary { display: grid; gap: 8px; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.review-summary span { color: var(--muted); font-size: 9px; }
.review-summary strong { font-size: 11px; }
.review-summary p { max-height: 160px; margin: 4px 0 0; overflow-y: auto; color: #454942; font-size: 11px; line-height: 1.7; white-space: pre-line; }
.review-dialog label { grid-template-columns: 100px minmax(0, 1fr); margin: 0 22px; }
.review-dialog textarea { min-height: 90px; resize: vertical; }
.review-dialog footer { display: flex; justify-content: flex-end; gap: 8px; padding: 16px 22px; border-top: 1px solid var(--line); }

.password-change-dialog { width: min(430px, calc(100vw - 28px)); padding: 0; border: 0; border-radius: 8px; box-shadow: 0 24px 70px rgba(30, 34, 29, .24); }
.password-change-dialog::backdrop { background: rgba(24, 25, 23, .66); }
.password-change-dialog form { display: grid; padding: 30px; }
.password-change-mark { display: grid; width: 42px; height: 42px; place-items: center; border-radius: 8px; background: var(--amber-soft); color: var(--amber); }
.password-change-mark svg { width: 20px; height: 20px; }
.password-change-dialog form > span { margin-top: 20px; color: var(--amber); font-size: 9px; font-weight: 700; }
.password-change-dialog h2 { margin: 6px 0 0; font-size: 22px; }
.password-change-dialog p { margin: 9px 0 20px; color: var(--muted); font-size: 10px; line-height: 1.65; }
.password-change-dialog label { display: grid; gap: 7px; margin-top: 12px; color: var(--muted); font-size: 9px; }
.password-change-dialog input { width: 100%; height: 42px; padding: 0 11px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }
.password-change-dialog input:focus { border-color: #91acd0; outline: 0; box-shadow: 0 0 0 3px var(--blue-soft); }
.password-change-dialog .primary-action { width: 100%; margin-top: 22px; }
.password-change-dialog a { justify-self: center; margin-top: 16px; color: var(--muted); font-size: 9px; text-decoration: none; }
.password-change-dialog a:hover { color: var(--text); }

.toast { position: fixed; z-index: 20; right: 22px; bottom: 22px; gap: 8px; max-width: min(360px, calc(100vw - 32px)); min-height: 40px; padding: 0 13px; transform: translateY(16px); border: 1px solid #cde6d9; border-radius: 6px; background: var(--green-soft); color: var(--green); box-shadow: 0 8px 24px rgba(33, 51, 67, .14); opacity: 0; pointer-events: none; transition: opacity .18s ease, transform .18s ease; font-size: 10px; }
.toast.show { transform: translateY(0); opacity: 1; }
.toast.error { border-color: #efd0cc; background: var(--red-soft); color: var(--red); }
.toast svg { width: 15px; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 900px) {
  .mail-shell { grid-template-columns: 74px minmax(0, 1fr); }
  .mail-sidebar { padding-inline: 10px; }
  .mail-brand { justify-content: center; padding-inline: 0; }
  .mail-brand div, .workspace-link span, .mail-account > div:nth-child(2), .mail-account .icon-button { display: none; }
  .workspace-link { grid-template-columns: 1fr; justify-items: center; padding: 0; }
  .workspace-link b { position: absolute; margin: -22px 0 0 20px; }
  .mail-account { display: flex; justify-content: center; }
}

@media (max-width: 680px) {
  body { overflow: hidden; }
  .mail-shell { display: block; }
  .mail-sidebar { position: fixed; z-index: 10; right: 0; bottom: 0; left: 0; display: block; height: 64px; padding: 0; border-top: 1px solid var(--line); background: #ffffff; color: var(--text); }
  .mail-brand, .mail-account { display: none; }
  .workspace-nav { display: flex; height: 100%; margin: 0; overflow: hidden; }
  .workspace-link { position: relative; display: flex; flex: 1 0 68px; flex-direction: column; justify-content: center; gap: 4px; min-height: 64px; padding: 0 6px; border-radius: 0; color: var(--muted); font-size: 8px; }
  .workspace-link span { display: block; }
  .workspace-link:hover, .workspace-link.active { background: var(--soft); color: var(--blue); }
  .workspace-link b { position: absolute; top: 6px; left: 50%; margin: 0 0 0 7px; background: var(--blue); color: #ffffff; }
  .mail-main { height: calc(100vh - 64px); }
  #inboxView { grid-template-rows: 64px 52px minmax(0, 1fr); padding: 0; }
  .mail-header, .mail-controls { padding: 0 14px; }
  .mail-title span, .sync-state { display: none; }
  .mail-title h1 { max-width: calc(100vw - 96px); margin: 0; font-size: 13px; }
  .primary-action span { display: none; }
  .header-actions .primary-action { width: 36px; padding: 0; }
  .mail-tabs { gap: 24px; }
  .mail-stage { grid-template-columns: 1fr; margin: 0; border: 0; border-radius: 0; }
  .message-column { border-right: 0; }
  .message-reader { position: absolute; z-index: 5; inset: 116px 0 0; display: none; }
  .message-reader.open { display: block; }
  .reader-empty { display: none; }
  .mobile-back { display: inline-grid; }
  .reader-content { padding: 26px 20px 44px; }
  .reader-content h2 { font-size: 18px; }
  .reader-meta { align-items: flex-start; }
  .reader-meta time { max-width: 90px; white-space: normal; text-align: right; }
  .section-header { padding: 26px 18px 18px; }
  .section-header h1 { font-size: 20px; }
  .section-header p { display: none; }
  .compose-form { padding: 14px 18px 40px; }
  .compose-form label { grid-template-columns: 1fr; padding: 8px 0; }
  .compose-form label > span { padding-top: 0; }
  .compose-form textarea { min-height: 170px; }
  .compose-form .reason-field { min-height: 80px; }
  .compose-actions .primary-action span { display: inline; }
  .request-list { margin-top: 6px; padding: 0 18px; }
  .request-row { grid-template-columns: 1fr; gap: 12px; padding: 18px 0; }
  .request-meta { align-items: flex-start; text-align: left; }
  .request-meta .secondary-action { margin-top: 4px; }
  .request-meta .secondary-action span { display: inline; }
  .request-addresses { display: grid; }
  .review-dialog label { grid-template-columns: 1fr; padding: 12px 0; }
  .review-dialog label > span { padding-top: 0; }
  .review-dialog footer .primary-action span, .review-dialog footer .danger-action span { display: inline; }
  .toast { right: 14px; bottom: 78px; left: 14px; justify-content: center; }
}
