:root {
  color-scheme: light;
  --ink: #20252b;
  --muted: #66707a;
  --line: #dfe3e6;
  --line-strong: #c8ced3;
  --surface: #ffffff;
  --surface-soft: #f5f7f8;
  --header: #202a2c;
  --green: #168a63;
  --green-dark: #0d6c4c;
  --green-soft: #e8f5ef;
  --blue: #246bce;
  --blue-soft: #eaf1fb;
  --red: #bf3f45;
  --red-soft: #fbecee;
  --amber: #9a6a08;
  --amber-soft: #fff5d9;
  --shadow: 0 14px 40px rgba(22, 28, 33, 0.16);
  font-family: Inter, "Segoe UI", "Microsoft YaHei UI", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; color: var(--ink); background: var(--surface-soft); font-size: 14px; letter-spacing: 0; }
button, input, select, textarea { font: inherit; letter-spacing: 0; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
svg { width: 18px; height: 18px; stroke-width: 1.8; flex: 0 0 auto; }
[hidden] { display: none !important; }

.button {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 8px 13px;
  text-decoration: none;
  font-weight: 600;
  white-space: nowrap;
  transition: border-color .16s, background .16s, color .16s;
}
.button-primary { color: #fff; background: var(--green); border-color: var(--green); }
.button-primary:hover { background: var(--green-dark); border-color: var(--green-dark); }
.button-secondary { color: #354047; background: #fff; border-color: var(--line-strong); }
.button-secondary:hover { color: var(--blue); border-color: #91add7; background: #f8fbff; }
.button-danger { color: var(--red); background: #fff; border-color: #e4aeb2; }
.button-danger:hover { color: #fff; background: var(--red); border-color: var(--red); }
.button-ghost { color: #4e5962; background: transparent; border-color: transparent; }
.button-ghost:hover { background: #eef1f2; }
.icon-button {
  width: 38px;
  height: 38px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: #4b565f;
  background: #fff;
}
.icon-button:hover { color: var(--blue); border-color: #9fb8db; }
.icon-button.inverse { color: #dce4e2; background: transparent; border-color: #526164; }

.eyebrow { margin: 0 0 5px; color: var(--green); font-size: 11px; font-weight: 750; }
.brand-mark { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 7px; color: #fff; background: var(--green); }
.header-brand { display: flex; align-items: center; gap: 11px; }
.header-brand strong { display: block; color: #fff; font-size: 18px; line-height: 1.1; }
.header-brand span { display: block; margin-top: 3px; color: #abb9b8; font-size: 12px; }

.app-header {
  height: 64px;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--header);
  border-bottom: 1px solid #384446;
}
.header-nav { height: 100%; display: flex; align-items: center; gap: 8px; }
.header-nav > a { height: 100%; display: flex; align-items: center; gap: 8px; padding: 0 16px; color: #b9c5c4; text-decoration: none; border-bottom: 3px solid transparent; }
.header-nav > a.active { color: #fff; border-bottom-color: #40ba8f; }
.admin-menu { height: 38px; display: flex; align-items: center; gap: 8px; margin-left: 8px; padding-left: 14px; border-left: 1px solid #445153; }
.admin-menu form { display: flex; }
.admin-avatar { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 50%; color: #fff; background: #576568; font-weight: 700; }
.admin-name { color: #e7edec; max-width: 140px; overflow: hidden; text-overflow: ellipsis; }

.app-main { width: min(1600px, 100%); margin: 0 auto; padding: 26px 28px 44px; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 20px; }
.page-heading h1 { margin: 0; font-size: 25px; font-weight: 700; }
.heading-actions { display: flex; gap: 8px; }
.metrics-band { min-height: 92px; display: grid; grid-template-columns: repeat(5, minmax(130px, 1fr)); align-items: center; border-block: 1px solid var(--line); background: var(--surface); }
.metric { min-width: 0; padding: 18px 24px; border-right: 1px solid var(--line); }
.metric:last-child { border-right: 0; }
.metric span { display: block; margin-bottom: 8px; color: var(--muted); font-size: 12px; }
.metric strong { font-size: 26px; line-height: 1; font-weight: 700; font-variant-numeric: tabular-nums; }
.metric-error strong { color: var(--red); }

.management-band { margin-top: 20px; background: var(--surface); border: 1px solid var(--line); }
.filter-row { min-height: 64px; padding: 12px 14px; display: flex; align-items: center; flex-wrap: wrap; gap: 12px; border-bottom: 1px solid var(--line); }
.search-control { height: 40px; flex: 1 1 340px; max-width: 620px; display: flex; align-items: center; gap: 9px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 6px; background: #fff; }
.search-control svg { color: #7b858d; }
.search-control input { width: 100%; height: 100%; border: 0; outline: 0; color: var(--ink); background: transparent; }
.segmented { height: 40px; display: inline-flex; padding: 3px; border: 1px solid var(--line); border-radius: 6px; background: #eef1f2; }
.segmented button { min-width: 64px; border: 0; border-radius: 4px; color: #5c6770; background: transparent; }
.segmented button.active { color: var(--ink); background: #fff; box-shadow: 0 1px 3px rgba(25, 31, 35, .1); font-weight: 650; }
.provider-filter { flex-shrink: 0; }
.provider-filter button { min-width: auto; display: inline-flex; align-items: center; gap: 6px; padding: 0 10px; white-space: nowrap; }
.provider-filter small { min-width: 18px; padding: 1px 5px; border-radius: 8px; color: #6a747b; background: #dfe4e6; font-size: 10px; font-variant-numeric: tabular-nums; }
.provider-filter button.active small { color: #fff; background: #5e6b72; }
.provider-dot { width: 8px; height: 8px; flex: 0 0 auto; border-radius: 50%; background: #7d878d; }
.provider-mailcom { background: #168a63; }
.provider-gmx { background: #246bce; }
.provider-microsoft { background: #d83b01; }
.provider-all { background: #59656c; }
select { height: 40px; min-width: 126px; padding: 0 34px 0 11px; border: 1px solid var(--line-strong); border-radius: 6px; color: var(--ink); background: #fff; }

.bulk-toolbar { min-height: 54px; display: flex; align-items: center; gap: 16px; padding: 8px 14px; border-bottom: 1px solid var(--line); background: #f7faf9; }
.selection-count { min-width: 84px; color: var(--muted); white-space: nowrap; }
.selection-count strong { color: var(--green); }
.bulk-actions { display: flex; flex-wrap: wrap; gap: 7px; }
.bulk-actions .button { min-height: 34px; padding: 6px 10px; font-size: 13px; }
.bulk-toolbar[data-empty="true"] .bulk-actions button { opacity: .48; pointer-events: none; }

.table-shell { width: 100%; overflow-x: auto; }
.account-table { width: 100%; min-width: 1300px; border-collapse: collapse; table-layout: fixed; }
.account-table th { height: 42px; padding: 0 11px; color: #69737b; background: #f5f7f8; border-bottom: 1px solid var(--line); text-align: left; font-size: 12px; font-weight: 650; }
.account-table td { height: 57px; padding: 8px 11px; border-bottom: 1px solid #e9ecee; vertical-align: middle; }
.account-table tr:hover td { background: #fafcfc; }
.account-table tr.selected td { background: #edf7f3; }
.account-table th:nth-child(2) { width: 220px; }
.account-table th:nth-child(3) { width: 112px; }
.account-table th:nth-child(4) { width: 84px; }
.account-table th:nth-child(5) { width: 310px; }
.account-table th:nth-child(6), .account-table th:nth-child(7) { width: 106px; }
.account-table th:nth-child(8) { width: 68px; }
.account-table th:nth-child(9) { width: 145px; }
.checkbox-column { width: 46px; text-align: center !important; }
.actions-column { width: 132px; }
input[type="checkbox"] { width: 17px; height: 17px; accent-color: var(--green); }
.email-cell { min-width: 0; }
.email-cell strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.email-cell small { display: block; margin-top: 3px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.provider-badge, .type-badge, .status-badge, .usage-badge { display: inline-flex; align-items: center; min-height: 24px; padding: 3px 8px; border-radius: 4px; font-size: 12px; white-space: nowrap; }
.provider-badge { gap: 6px; color: #4d5961; background: #f0f2f3; }
.provider-badge-mailcom { color: #28634f; background: #e8f5ef; }
.provider-badge-gmx { color: #315f9d; background: #eaf1fb; }
.provider-badge-microsoft { color: #93401f; background: #fff0e9; }
.type-primary { color: #355d96; background: var(--blue-soft); }
.type-alias { color: #356553; background: var(--green-soft); }
.usage-used { color: #356553; background: var(--green-soft); }
.usage-unused { color: #6c747a; background: #edf0f1; }
.status-error { color: var(--red); background: var(--red-soft); }
.status-done, .status-synced { color: #287154; background: var(--green-soft); }
.status-ready { color: #5f6971; background: #eef1f2; }
.pickup-url-cell { display: flex; align-items: center; gap: 6px; min-width: 0; }
.pickup-url-cell code { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #4b5760; font: 12px/1.4 Consolas, monospace; }
.mini-icon { width: 30px; height: 30px; display: inline-grid; place-items: center; border: 0; border-radius: 5px; color: #657079; background: transparent; }
.mini-icon:hover { color: var(--blue); background: var(--blue-soft); }
.row-actions { display: flex; align-items: center; gap: 2px; }
.message-number, .time-cell { color: #5f6971; font-variant-numeric: tabular-nums; }
.empty-state { min-height: 280px; display: grid; place-items: center; align-content: center; gap: 10px; color: #7b858d; }
.empty-state svg { width: 32px; height: 32px; }
.table-footer { min-height: 54px; padding: 7px 14px; display: flex; align-items: center; justify-content: space-between; gap: 16px; color: var(--muted); border-top: 1px solid var(--line); font-size: 12px; }
.table-summary { display: flex; align-items: center; gap: 14px; white-space: nowrap; }
.pagination { display: flex; align-items: center; justify-content: flex-end; gap: 5px; }
.pagination select { width: 72px; min-width: 72px; height: 32px; padding-left: 9px; }
.pagination-button, .page-number { width: 32px; height: 32px; display: inline-grid; place-items: center; padding: 0; border: 1px solid var(--line-strong); border-radius: 5px; color: #526069; background: #fff; }
.pagination-button:hover:not(:disabled), .page-number:hover { color: var(--blue); border-color: #91add7; }
.pagination-button:disabled { cursor: default; opacity: .4; }
.page-buttons { display: flex; gap: 5px; }
.page-number.active { color: #fff; background: var(--green); border-color: var(--green); font-weight: 700; }

.mail-drawer { position: fixed; z-index: 40; inset: 0 0 0 auto; width: min(600px, 92vw); padding: 0; background: #fff; border-left: 1px solid var(--line); box-shadow: var(--shadow); transform: translateX(105%); transition: transform .2s ease; overflow-y: auto; }
.mail-drawer.open { transform: translateX(0); }
.mail-drawer > header { position: sticky; z-index: 2; top: 0; min-height: 76px; padding: 15px 18px; display: flex; align-items: center; justify-content: space-between; background: #fff; border-bottom: 1px solid var(--line); }
.mail-drawer h2 { max-width: 470px; margin: 0; overflow-wrap: anywhere; font-size: 17px; }
.drawer-summary { min-height: 46px; padding: 0 18px; display: flex; align-items: center; justify-content: space-between; color: var(--muted); background: #f7f9f9; border-bottom: 1px solid var(--line); }
.drawer-backdrop { position: fixed; z-index: 35; inset: 0; background: rgba(21, 27, 30, .35); }
.message-list { padding: 0 18px 24px; }
.message-item { padding: 17px 0; border-bottom: 1px solid var(--line); }
.message-item header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.message-item h3 { margin: 5px 0 0; font-size: 15px; }
.message-item time { flex: 0 0 auto; color: var(--muted); font-size: 11px; }
.message-item .from { color: #4d5861; font-size: 13px; overflow-wrap: anywhere; }
.message-item pre { max-height: 340px; overflow: auto; margin: 14px 0 0; padding: 13px; white-space: pre-wrap; overflow-wrap: anywhere; color: #354047; background: #f6f8f8; border: 1px solid #e5e8ea; font: 13px/1.6 inherit; }

.modal { width: min(620px, calc(100vw - 28px)); padding: 0; border: 0; border-radius: 7px; box-shadow: var(--shadow); }
.modal::backdrop { background: rgba(21, 27, 30, .48); }
.modal-content { margin: 0; padding: 0; }
.modal-content > header { min-height: 72px; padding: 14px 18px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.modal-content h2 { margin: 0; font-size: 18px; }
.modal-content > label { display: block; margin: 18px 18px 8px; font-weight: 650; }
.import-provider { margin: 18px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.import-provider button { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 8px; border: 1px solid var(--line-strong); border-radius: 6px; color: #536069; background: #fff; font-weight: 650; }
.import-provider button:hover { border-color: #8da9ce; background: #f8fbff; }
.import-provider button.active { color: var(--ink); border-color: #5f87bc; background: var(--blue-soft); box-shadow: 0 0 0 2px rgba(36, 107, 206, .1); }
.import-provider + label { margin-top: 0; }
.modal-content textarea { width: calc(100% - 36px); margin: 0 18px 18px; padding: 12px; resize: vertical; border: 1px solid var(--line-strong); border-radius: 6px; outline: none; font: 13px/1.6 Consolas, monospace; }
.modal-content textarea:focus { border-color: #76a6e6; box-shadow: 0 0 0 3px rgba(36, 107, 206, .12); }
.modal-content > p { margin: 20px 18px; line-height: 1.7; }
.modal-content > footer { min-height: 62px; padding: 11px 18px; display: flex; justify-content: flex-end; gap: 8px; border-top: 1px solid var(--line); background: #f7f9f9; }

.toast-region { position: fixed; z-index: 80; right: 20px; bottom: 20px; display: grid; gap: 8px; }
.toast { width: min(390px, calc(100vw - 32px)); min-height: 48px; display: flex; align-items: center; gap: 10px; padding: 11px 13px; color: #fff; background: #2c373a; border-radius: 6px; box-shadow: var(--shadow); }
.toast.error { background: #8e3035; }
.toast.success { background: #176f53; }
.loading-overlay { position: fixed; z-index: 90; inset: 0; display: grid; place-items: center; align-content: center; gap: 12px; color: #fff; background: rgba(26, 32, 35, .56); }
.spinner { width: 34px; height: 34px; border: 3px solid rgba(255,255,255,.35); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
.empty-state .spinner { border-color: #d5dcda; border-top-color: var(--green); }
@keyframes spin { to { transform: rotate(360deg); } }

.login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: #e9eeec; }
.login-shell { width: min(900px, 100%); min-height: 530px; display: grid; grid-template-columns: 1fr 1fr; background: #fff; border: 1px solid #d4dcd9; border-radius: 8px; overflow: hidden; box-shadow: 0 22px 60px rgba(27, 37, 35, .16); }
.login-brand { display: flex; align-items: center; justify-content: center; gap: 14px; padding: 48px; background: var(--header); }
.login-brand .brand-mark { width: 54px; height: 54px; }
.login-brand .brand-mark svg { width: 27px; height: 27px; }
.login-brand strong { display: block; color: #fff; font-size: 30px; }
.login-brand span { display: block; margin-top: 5px; color: #adbbba; }
.login-panel { align-self: center; padding: 54px; }
.login-panel h1 { margin: 0 0 27px; font-size: 24px; }
.login-form { display: grid; gap: 8px; }
.login-form label { margin-top: 8px; color: #4e5962; font-size: 13px; font-weight: 600; }
.input-with-icon { height: 44px; display: flex; align-items: center; gap: 9px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 6px; }
.input-with-icon:focus-within { border-color: #65a58d; box-shadow: 0 0 0 3px rgba(22, 138, 99, .12); }
.input-with-icon svg { color: #7c878e; }
.input-with-icon input { flex: 1; height: 100%; min-width: 0; border: 0; outline: 0; background: transparent; }
.login-submit { margin-top: 20px; justify-content: space-between; padding-inline: 16px; }
.alert { margin: -12px 0 14px; padding: 10px 12px; border-radius: 5px; }
.alert-error { color: #8c3035; background: var(--red-soft); border: 1px solid #efc7ca; }

.pickup-page { min-height: 100vh; background: #f2f5f4; }
.pickup-header { min-height: 66px; padding: 0 max(20px, calc((100% - 1080px)/2)); display: flex; align-items: center; justify-content: space-between; background: var(--header); }
.pickup-main { width: min(1080px, calc(100% - 32px)); margin: 0 auto; padding: 30px 0 60px; }
.pickup-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.pickup-heading h1 { margin: 0; overflow-wrap: anywhere; font-size: 24px; }
.count-badge { min-width: 60px; padding: 7px 10px; text-align: center; color: #356553; background: var(--green-soft); border-radius: 5px; }
.stale-notice { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; padding: 10px 12px; color: var(--amber); background: var(--amber-soft); border: 1px solid #f0db99; }
.public-message-list { display: grid; gap: 12px; }
.public-message { padding: 20px; background: #fff; border: 1px solid var(--line); border-radius: 7px; }
.public-message > header { display: flex; justify-content: space-between; gap: 18px; }
.public-message h2 { margin: 6px 0 0; font-size: 16px; }
.public-message time { color: var(--muted); font-size: 12px; }
.message-from { color: #4d5861; overflow-wrap: anywhere; }
.public-message dl { margin: 14px 0 0; padding-top: 12px; border-top: 1px solid var(--line); }
.public-message dl div { display: flex; gap: 10px; }
.public-message dt { color: var(--muted); }
.public-message dd { margin: 0; overflow-wrap: anywhere; }
.public-message pre { margin: 16px 0 0; padding: 14px; white-space: pre-wrap; overflow-wrap: anywhere; background: #f6f8f8; border: 1px solid #e6e9ea; font: 14px/1.65 inherit; }
.pickup-empty { min-height: 340px; display: grid; place-items: center; align-content: center; gap: 10px; color: #768088; background: #fff; border: 1px solid var(--line); }
.pickup-empty svg { width: 36px; height: 36px; }
.pickup-empty h1, .pickup-empty h2, .pickup-empty p { margin: 0; }
.pickup-empty.error { color: #8f3439; }

.error-page { min-height: 100vh; display: grid; place-items: center; background: #eef2f1; }
.error-shell { display: grid; place-items: center; gap: 12px; text-align: center; }
.error-code { color: var(--green); font-size: 52px; }
.error-shell h1 { margin: 0 0 10px; font-size: 20px; }

@media (max-width: 900px) {
  .app-header { height: auto; min-height: 62px; padding: 10px 16px; }
  .header-nav > a, .admin-name { display: none; }
  .app-main { padding: 20px 14px 36px; }
  .metrics-band { grid-template-columns: repeat(2, 1fr); }
  .metric { border-bottom: 1px solid var(--line); }
  .metric:nth-child(2n) { border-right: 0; }
  .metric:last-child { grid-column: span 2; border-bottom: 0; }
  .filter-row { align-items: stretch; flex-wrap: wrap; }
  .search-control { flex-basis: 100%; max-width: none; }
  .segmented { flex: 1; }
  .segmented button { flex: 1; }
  .provider-filter { flex: 1 1 100%; overflow-x: auto; }
  .provider-filter button { flex: 1 0 auto; }
  .bulk-toolbar { align-items: flex-start; flex-direction: column; }
  .table-footer { align-items: flex-start; flex-direction: column; }
  .pagination { width: 100%; justify-content: flex-start; flex-wrap: wrap; }
  .login-shell { max-width: 490px; min-height: auto; grid-template-columns: 1fr; }
  .login-brand { justify-content: flex-start; padding: 24px 32px; }
  .login-brand .brand-mark { width: 42px; height: 42px; }
  .login-brand strong { font-size: 23px; }
  .login-panel { padding: 36px 32px 42px; }
}

@media (max-width: 560px) {
  .app-header { padding-inline: 12px; }
  .header-brand strong { font-size: 16px; }
  .header-nav { gap: 4px; }
  .admin-menu { padding-left: 7px; margin-left: 2px; }
  .page-heading { align-items: center; }
  .page-heading h1 { font-size: 21px; }
  .page-heading .button span { display: none; }
  .metric { padding: 15px 16px; }
  .metric strong { font-size: 22px; }
  .filter-row select { flex: 1; }
  .provider-filter { height: auto; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); overflow: visible; }
  .provider-filter button { min-height: 34px; justify-content: center; }
  .bulk-actions .button span { display: none; }
  .bulk-actions .button { width: 38px; padding: 7px; }
  .mail-drawer { width: 100vw; }
  .pickup-header { padding-inline: 12px; }
  .pickup-header .button span { display: none; }
  .pickup-main { width: calc(100% - 20px); padding-top: 20px; }
  .pickup-heading { align-items: flex-start; }
  .pickup-heading h1 { font-size: 19px; }
  .public-message { padding: 15px; }
  .public-message > header { flex-direction: column; gap: 8px; }
  .login-page { padding: 12px; }
  .login-panel { padding: 30px 22px 34px; }
}
