:root {
    --bg: #f4f7fb;
    --surface: #ffffff;
    --surface-soft: #f8fafc;
    --text: #172033;
    --muted: #667085;
    --line: #dfe5ee;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-soft: #eaf1ff;
    --success: #16803c;
    --success-soft: #eaf8ef;
    --warning: #b45309;
    --warning-soft: #fff6e8;
    --danger: #c12b2b;
    --danger-soft: #fff0f0;
    --shadow: 0 18px 55px rgba(31, 42, 68, 0.08);
    --radius: 18px;
}

* {
    box-sizing: border-box;
}

html {
    min-width: 1120px;
    background: var(--bg);
}

body {
    margin: 0;
    color: var(--text);
    background:
        radial-gradient(circle at 8% -10%, rgba(37, 99, 235, 0.1), transparent 28%),
        var(--bg);
    font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

[hidden] {
    display: none !important;
}

.login-gate {
    display: grid;
    min-height: 100vh;
    padding: 32px;
    place-items: center;
}

.login-card {
    display: grid;
    width: min(420px, calc(100vw - 64px));
    gap: 18px;
    padding: 34px;
    border: 1px solid var(--line);
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: var(--shadow);
}

.login-card h1 {
    margin: 0;
    font-size: 26px;
}

.login-card p:not(.eyebrow) {
    margin: 8px 0 0;
    color: var(--muted);
    font-size: 13px;
}

.login-card label {
    margin-bottom: -10px;
    font-size: 13px;
    font-weight: 700;
}

.login-card input {
    height: 44px;
    padding: 0 13px;
    border: 1px solid var(--line);
    border-radius: 11px;
    outline: none;
    color: var(--text);
    background: #fff;
}

.login-card input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.login-error {
    min-height: 18px;
    color: var(--danger);
    font-size: 12px;
}

button,
input {
    font: inherit;
}

button {
    cursor: pointer;
}

button:disabled,
input:disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

.page-shell {
    width: min(1800px, calc(100% - 32px));
    margin: 0 auto;
    padding-bottom: 48px;
}

.topbar {
    display: flex;
    min-height: 84px;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    color: inherit;
    text-decoration: none;
}

.brand-mark {
    display: grid;
    width: 42px;
    height: 42px;
    place-items: center;
    border-radius: 13px;
    color: #fff;
    background: linear-gradient(145deg, #4f8cff, #2154d6);
    box-shadow: 0 10px 24px rgba(37, 99, 235, 0.22);
    font-size: 15px;
    font-weight: 800;
}

.brand strong,
.brand small {
    display: block;
}

.brand strong {
    font-size: 16px;
}

.brand small {
    margin-top: 3px;
    color: var(--muted);
    font-size: 13px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.button {
    min-height: 38px;
    padding: 0 15px;
    border: 1px solid transparent;
    border-radius: 11px;
    font-size: 13px;
    font-weight: 700;
    transition: 140ms ease;
}

.button:hover:not(:disabled) {
    transform: translateY(-1px);
}

.button.primary {
    color: #fff;
    background: var(--primary);
    box-shadow: 0 7px 18px rgba(37, 99, 235, 0.18);
}

.button.primary:hover:not(:disabled) {
    background: var(--primary-dark);
}

.button.secondary {
    border-color: var(--line);
    color: var(--text);
    background: rgba(255, 255, 255, 0.78);
}

.button.secondary:hover:not(:disabled) {
    background: #fff;
}

.button.danger {
    color: var(--danger);
    background: var(--danger-soft);
}

.state-chip {
    display: inline-flex;
    min-height: 34px;
    align-items: center;
    gap: 8px;
    padding: 0 11px;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--muted);
    background: rgba(255, 255, 255, 0.72);
    font-size: 12px;
    font-weight: 700;
}

.state-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #98a2b3;
}

.state-chip.ok {
    border-color: #bfe8cc;
    color: var(--success);
    background: var(--success-soft);
}

.state-chip.ok .state-dot {
    background: var(--success);
}

.state-chip.error {
    border-color: #f0c8c8;
    color: var(--danger);
    background: var(--danger-soft);
}

.state-chip.error .state-dot {
    background: var(--danger);
}

.eyebrow {
    margin: 0 0 9px;
    color: #6284bd;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.14em;
}

.text-button {
    padding: 0;
    border: 0;
    color: var(--primary);
    background: transparent;
    font-size: 12px;
    font-weight: 800;
}

.status-bar {
    margin-top: 18px;
    padding: 12px 15px;
    border: 1px solid var(--line);
    border-radius: 12px;
    font-size: 13px;
}

.status-bar.info {
    color: #31598f;
    background: #edf4ff;
}

.status-bar.ok {
    border-color: #c8ead2;
    color: var(--success);
    background: var(--success-soft);
}

.status-bar.warn {
    border-color: #f1ddb8;
    color: var(--warning);
    background: var(--warning-soft);
}

.status-bar.error {
    border-color: #f0c8c8;
    color: var(--danger);
    background: var(--danger-soft);
}

.metrics {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin: 18px 0;
}

.metric-card {
    padding: 20px 22px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: 0 8px 25px rgba(31, 42, 68, 0.04);
}

.metric-card span,
.metric-card small,
.metric-card strong {
    display: block;
}

.metric-card span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.metric-card strong {
    margin: 9px 0 5px;
    font-size: 28px;
    letter-spacing: -0.04em;
}

.metric-card small {
    color: #8b95a7;
    font-size: 11px;
}

.workspace {
    display: grid;
    height: 900px;
    grid-template-columns: minmax(400px, 0.82fr) minmax(620px, 1.35fr);
    gap: 18px;
    align-items: stretch;
}

.panel {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: 0 12px 32px rgba(31, 42, 68, 0.05);
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 22px 24px 17px;
    border-bottom: 1px solid var(--line);
}

.panel-header .eyebrow {
    margin-bottom: 5px;
}

.panel h2 {
    margin: 0;
    font-size: 19px;
}

.create-form {
    padding: 18px 24px;
    border-bottom: 1px solid var(--line);
    background: var(--surface-soft);
}

.created-alias {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 14px;
    min-height: 58px;
    padding: 13px 16px;
    border: 1px dashed var(--line);
    border-radius: 10px;
    color: var(--muted);
    background: #fff;
    font-size: 14px;
}

.created-alias[hidden] {
    display: none;
}

.created-alias strong {
    margin-left: 4px;
    color: var(--text);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 17px;
    font-weight: 800;
}

.created-alias .mini-button {
    padding: 8px 13px;
    font-size: 13px;
}

.form-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.form-heading strong,
.form-heading span {
    display: block;
}

.form-heading strong {
    font-size: 14px;
}

.form-heading span {
    margin-top: 4px;
    color: var(--muted);
    font-size: 11px;
}

.search-input {
    width: 100%;
    height: 39px;
    padding: 0 11px;
    border: 1px solid var(--line);
    border-radius: 10px;
    outline: none;
    color: var(--text);
    background: #fff;
    font-size: 12px;
}

.search-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.list-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 24px;
    border-bottom: 1px solid var(--line);
}

.list-toolbar .search-input {
    flex: 1;
}

.list-toolbar span,
.inbox-summary {
    color: var(--muted);
    font-size: 11px;
}

.alias-batch-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 24px;
    border-bottom: 1px solid var(--line);
    background: #fbfcff;
}

.alias-batch-toolbar label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-right: auto;
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
}

.alias-batch-toolbar input {
    width: 15px;
    height: 15px;
}

.alias-batch-toolbar .mini-button.active {
    color: #fff;
    background: var(--primary);
}

.alias-list {
    flex: 1;
    min-height: 0;
    overflow: auto;
}

.alias-row {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 14px;
    padding: 15px 24px;
    border-bottom: 1px solid #edf0f5;
}

.alias-checkbox {
    width: 15px;
    height: 15px;
    margin-top: 2px;
}

.alias-row:last-child {
    border-bottom: 0;
}

.alias-row.inactive {
    opacity: 0.62;
}

.alias-row.selected {
    box-shadow: inset 4px 0 0 var(--primary);
    background: #f3f7ff;
}

.alias-email {
    overflow: hidden;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 14px;
    font-weight: 800;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.alias-meta {
    margin-top: 5px;
    overflow: hidden;
    color: var(--muted);
    font-size: 11px;
    line-height: 1.5;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.row-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.badge {
    padding: 4px 7px;
    border-radius: 999px;
    color: var(--warning);
    background: var(--warning-soft);
    font-size: 10px;
    font-weight: 800;
}

.badge.active {
    color: var(--success);
    background: var(--success-soft);
}

.mini-button {
    padding: 5px 8px;
    border: 0;
    border-radius: 8px;
    color: var(--primary);
    background: var(--primary-soft);
    font-size: 11px;
    font-weight: 800;
}

.mini-button.danger {
    color: var(--danger);
    background: var(--danger-soft);
}

.mini-button.pickup {
    color: #6d4bc3;
    background: #f1edff;
    white-space: nowrap;
}

.qq-mail-bar {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 8px;
    align-items: center;
    padding: 10px 24px;
    border-bottom: 1px solid var(--line);
    background: #fbfcff;
}

.qq-mail-bar strong {
    font-size: 12px;
    white-space: nowrap;
}

.qq-mail-bar #qq-mail-status {
    justify-self: end;
}

#qq-mail-status {
    color: var(--muted);
    font-size: 11px;
    white-space: nowrap;
}

#qq-mail-status.connected {
    color: var(--success);
}

.inbox-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 24px;
    border-bottom: 1px solid var(--line);
    background: var(--surface-soft);
}

.inbox-grid {
    display: grid;
    flex: 1;
    min-height: 0;
    grid-template-columns: minmax(300px, 0.92fr) minmax(300px, 1.08fr);
}

.mail-list {
    min-width: 0;
    min-height: 0;
    overflow: auto;
    border-right: 1px solid var(--line);
}

.mail-row {
    display: grid;
    width: 100%;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    padding: 15px 17px;
    border: 0;
    border-bottom: 1px solid #edf0f5;
    text-align: left;
    color: inherit;
    background: #fff;
}

.mail-row:hover,
.mail-row.selected {
    background: #f5f8ff;
}

.mail-row.unread .mail-from,
.mail-row.unread .mail-subject {
    font-weight: 800;
}

.mail-from-line {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: 7px;
}

.unread-dot {
    flex: none;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--primary);
}

.mail-from,
.mail-subject,
.mail-preview {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mail-from {
    font-size: 12px;
}

.mail-subject {
    margin-top: 7px;
    font-size: 12px;
}

.mail-preview {
    margin-top: 5px;
    color: var(--muted);
    font-size: 11px;
}

.mail-time {
    color: #8b95a7;
    font-size: 10px;
    white-space: nowrap;
}

.mail-detail {
    display: flex;
    flex-direction: column;
    overflow: auto;
    min-width: 0;
    min-height: 0;
    padding: 28px 28px 0;
}

.mail-detail-header {
    padding-bottom: 20px;
    border-bottom: 1px solid var(--line);
}

.mail-detail h3 {
    margin: 0;
    font-size: 21px;
    line-height: 1.35;
}

.detail-meta {
    display: grid;
    gap: 6px;
    margin-top: 14px;
    color: var(--muted);
    font-size: 12px;
}

.detail-body {
    flex: 1 1 auto;
    overflow: auto;
    min-height: 220px;
    padding: 24px 0;
    color: #3c465a;
    font-size: 14px;
    line-height: 1.8;
    white-space: pre-wrap;
}

.detail-frame {
    flex: 1 1 auto;
    width: 100%;
    min-height: 360px;
    margin: 20px 0 0;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
}

.empty-state {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 6px;
    padding: 42px 24px;
    color: var(--muted);
    text-align: center;
}

.empty-state strong {
    color: #596376;
    font-size: 13px;
}

.empty-state small {
    max-width: 300px;
    line-height: 1.6;
}

.empty-mark {
    display: grid;
    width: 42px;
    height: 42px;
    margin-bottom: 7px;
    place-items: center;
    border-radius: 13px;
    color: #7394ce;
    background: var(--primary-soft);
    font-weight: 800;
}

.toast {
    position: fixed;
    right: 28px;
    bottom: 28px;
    z-index: 20;
    max-width: 380px;
    padding: 12px 15px;
    border-radius: 11px;
    color: #fff;
    background: #172033;
    box-shadow: 0 14px 38px rgba(23, 32, 51, 0.25);
    font-size: 12px;
    opacity: 0;
    pointer-events: none;
    transform: translateY(8px);
    transition: 160ms ease;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}


/* Compact batch-action row */
.list-toolbar .alias-select-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
    white-space: nowrap;
}

.list-toolbar .alias-select-label input {
    width: 15px;
    height: 15px;
}

.alias-batch-toolbar {
    justify-content: flex-start;
    gap: 7px;
    padding: 9px 52px;
}

.alias-batch-toolbar .mini-button {
    min-height: 26px;
    padding: 5px 9px;
    border-radius: 8px;
    line-height: 16px;
    white-space: nowrap;
}
