:root {
    --bg-a: #dceafe;
    --bg-b: #eef7ff;
    --bg-c: #f3eefe;
    --card: rgba(246, 250, 255, 0.78);
    --card-solid: #f8fbff;
    --white: #ffffff;
    --ink: #263245;
    --muted: #8fa0b8;
    --line: rgba(150, 173, 209, 0.24);
    --blue: #416fe8;
    --blue-2: #2f94d6;
    --green: #58bc92;
    --danger: #ef5f59;
    --shadow: 0 22px 70px rgba(86, 111, 158, 0.20);
}

* {
    box-sizing: border-box;
}

body {
    min-height: 100vh;
    margin: 0;
    color: var(--ink);
    font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    background:
        radial-gradient(circle at 8% 8%, rgba(90, 138, 255, 0.18), transparent 34%),
        radial-gradient(circle at 92% 34%, rgba(164, 128, 255, 0.20), transparent 31%),
        linear-gradient(135deg, var(--bg-a), var(--bg-b) 48%, var(--bg-c));
}

button,
input,
select,
textarea {
    font: inherit;
}

a {
    color: inherit;
    text-decoration: none;
}

.app-shell {
    width: min(1780px, calc(100vw - 72px));
    margin: 20px auto 28px;
    display: block;
    position: relative;
    z-index: 1;
    opacity: 1;
    visibility: visible;
}

.hero-card,
.side-card,
.control-card {
    border: 1px solid rgba(255, 255, 255, 0.78);
    border-radius: 18px;
    background: rgba(248, 251, 255, 0.74);
    box-shadow: var(--shadow);
}

.hero-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 24px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 14px;
}

.brand-icon {
    display: grid;
    place-items: center;
    width: 48px;
    height: 48px;
    border-radius: 13px;
    background: linear-gradient(135deg, #3d73ed, #42a6d7);
    box-shadow: 0 12px 26px rgba(53, 119, 220, 0.28);
}

.brand-icon svg {
    width: 30px;
    height: 30px;
    fill: none;
    stroke: #fff;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

h1,
h2,
h3,
p {
    margin: 0;
}

h1 {
    font-size: 21px;
    line-height: 1.2;
}

.brand p {
    margin-top: 6px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 650;
}

.ready-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border: 1px solid rgba(76, 180, 146, 0.24);
    border-radius: 999px;
    background: rgba(89, 197, 159, 0.11);
    color: #49ad84;
    font-weight: 800;
}

.ready-pill span {
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: #58bc92;
}

.workspace {
    display: grid;
    grid-template-columns: 370px minmax(0, 1fr);
    gap: 14px;
    margin-top: 14px;
}

.side-card {
    min-height: calc(100vh - 150px);
    padding: 20px;
}

.side-title {
    display: grid;
    grid-template-columns: 22px 1fr auto;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
}

.side-title h2,
.result-heading h2 {
    font-size: 16px;
}

.line-icon {
    color: #8da0bc;
    font-weight: 800;
}

.side-title b {
    display: grid;
    place-items: center;
    min-width: 28px;
    height: 24px;
    border-radius: 999px;
    background: rgba(65, 111, 232, 0.10);
    color: var(--blue);
    font-size: 13px;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 10px;
    outline: none;
    background: rgba(255, 255, 255, 0.72);
    color: var(--ink);
    padding: 12px 14px;
}

input::placeholder,
textarea::placeholder {
    color: #a3b1c6;
}

input:focus,
select:focus,
textarea:focus {
    border-color: rgba(65, 111, 232, 0.45);
    box-shadow: 0 0 0 4px rgba(65, 111, 232, 0.10);
}

.mailbox-search {
    margin-bottom: 14px;
}

.import-box summary,
.secondary-button,
button {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    border: 0;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 800;
}

.import-box {
    margin-bottom: 10px;
}

.import-box summary {
    list-style: none;
    background: linear-gradient(135deg, #4e7af0, #2f63e4);
    color: white;
    box-shadow: 0 10px 26px rgba(65, 111, 232, 0.28);
}

.import-box summary::-webkit-details-marker {
    display: none;
}

.import-form {
    display: grid;
    gap: 10px;
    padding-top: 10px;
}

.import-form textarea {
    min-height: 96px;
    resize: vertical;
}

.import-form button,
.fetch-actions button {
    background: linear-gradient(135deg, #4e7af0, #2f63e4);
    color: #fff;
}

.secondary-button {
    width: 100%;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.55);
    color: #60728c;
}

.selection-row {
    display: flex;
    align-items: center;
    gap: 9px;
    margin: 18px 0 10px;
    color: #9aacbf;
    font-size: 13px;
}

.selection-row form {
    margin-left: auto;
}

.select-all-control {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.select-all-control input,
.mailbox-checkbox {
    appearance: none;
    display: grid;
    place-items: center;
    width: 18px;
    height: 18px;
    flex: 0 0 18px;
    border: 2px solid #9eb0c8;
    border-radius: 5px;
    background: rgba(255, 255, 255, 0.72);
    padding: 0;
    cursor: pointer;
}

.select-all-control input:checked,
.select-all-control input:indeterminate,
.mailbox-checkbox:checked {
    border-color: var(--blue);
    background: var(--blue);
}

.select-all-control input:checked::after,
.mailbox-checkbox:checked::after {
    content: "✓";
    color: #fff;
    font-size: 12px;
    font-weight: 900;
    line-height: 1;
}

.select-all-control input:indeterminate::after {
    content: "";
    width: 8px;
    height: 2px;
    border-radius: 999px;
    background: #fff;
}

.delete-soft {
    min-height: 34px;
    border: 1px solid rgba(239, 95, 89, 0.22);
    background: rgba(239, 95, 89, 0.06);
    color: var(--danger);
    padding: 0 14px;
}

.mailbox-list {
    display: grid;
    gap: 8px;
    max-height: calc(100vh - 415px);
    overflow: auto;
    padding-right: 2px;
}

.mailbox-item {
    display: grid;
    grid-template-columns: 24px minmax(0, 1fr);
    gap: 10px;
    align-items: start;
    min-height: 58px;
    padding: 12px 14px;
    border: 1px solid transparent;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.26);
}

.mailbox-item.active {
    border-color: rgba(65, 111, 232, 0.20);
    background: rgba(65, 111, 232, 0.10);
}

.mailbox-link {
    min-width: 0;
}

.mailbox-link strong {
    display: block;
    color: #3a475b;
    font-size: 14px;
    line-height: 1.25;
    overflow-wrap: anywhere;
}

.mailbox-link small {
    display: block;
    margin-top: 4px;
    color: var(--danger);
    line-height: 1.25;
}

.content {
    min-width: 0;
}

.control-card {
    padding: 18px 22px;
}

.filters {
    display: grid;
    grid-template-columns: minmax(260px, 1fr) 220px 120px 92px;
    gap: 12px;
}

.input-wrap {
    position: relative;
}

.input-wrap span {
    position: absolute;
    top: 50%;
    left: 13px;
    transform: translateY(-50%);
    color: #91a2bd;
    font-weight: 900;
}

.input-wrap input {
    padding-left: 38px;
}

.ghost-submit {
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.55);
    color: #60728c;
}

.protocol-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-top: 14px;
}

.protocol-tabs {
    display: flex;
    gap: 10px;
}

.protocol-tabs span {
    display: inline-flex;
    min-width: 62px;
    justify-content: center;
    border: 1px solid rgba(65, 111, 232, 0.32);
    border-radius: 999px;
    padding: 8px 16px;
    color: var(--blue);
    background: rgba(65, 111, 232, 0.06);
    font-weight: 800;
}

.fetch-actions {
    display: flex;
    gap: 10px;
}

.fetch-actions button {
    min-width: 112px;
    padding: 0 16px;
}

.fetch-actions .all-fetch {
    background: linear-gradient(135deg, #56a5dc, #2e86c8);
}

.result-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 22px 4px 12px;
}

.result-heading h2 {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #53637a;
}

.result-heading div {
    display: flex;
    gap: 10px;
}

.metric {
    border-radius: 999px;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 900;
}

.metric.success,
.tag {
    background: rgba(88, 188, 146, 0.13);
    color: #38a97a;
}

.metric.total {
    background: rgba(65, 111, 232, 0.10);
    color: var(--blue);
}

.message-list {
    display: grid;
    gap: 10px;
}

.mail-card {
    display: block;
    border: 1px solid rgba(255, 255, 255, 0.68);
    border-radius: 14px;
    background: rgba(248, 251, 255, 0.74);
    padding: 17px 20px;
    box-shadow: 0 10px 28px rgba(86, 111, 158, 0.09);
}

.mail-card:hover {
    border-color: rgba(65, 111, 232, 0.24);
    transform: translateY(-1px);
}

.mail-card-head {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    color: #647389;
    font-size: 13px;
    font-weight: 800;
}

.tag {
    display: inline-flex;
    align-items: center;
    margin-left: 8px;
    border-radius: 6px;
    padding: 3px 8px;
    font-size: 11px;
    font-weight: 900;
}

.mail-card h3 {
    margin-top: 8px;
    font-size: 15px;
}

.mail-card p {
    margin-top: 8px;
    color: #99a9bf;
    font-size: 13px;
    line-height: 1.4;
    overflow-wrap: anywhere;
}

.mail-card small {
    display: block;
    margin-top: 10px;
    color: #9aabc1;
}

.notice {
    margin-top: 14px;
    border: 1px solid rgba(255, 255, 255, 0.74);
    border-radius: 14px;
    background: rgba(248, 251, 255, 0.84);
    box-shadow: var(--shadow);
    padding: 13px 16px;
}

.notice.ok {
    color: #2d946d;
}

.notice.warn {
    color: #9d7a16;
}

.notice.error {
    color: var(--danger);
}

.notice ul {
    margin: 8px 0 0;
    padding-left: 18px;
}

.empty-sidebar,
.empty-list {
    display: grid;
    place-items: center;
    min-height: 120px;
    color: var(--muted);
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    display: grid;
    place-items: center;
    background: rgba(207, 218, 236, 0.68);
    padding: 34px;
    z-index: 50;
}

.mail-modal {
    position: relative;
    width: min(880px, 92vw);
    max-height: 84vh;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.82);
    border-radius: 20px;
    background: rgba(248, 251, 255, 0.94);
    box-shadow: 0 30px 90px rgba(61, 83, 126, 0.28);
    padding: 28px 30px 30px;
}

.mail-modal h2 {
    margin-right: 34px;
    font-size: 18px;
}

.modal-close {
    position: absolute;
    top: 24px;
    right: 28px;
    color: #92a2b8;
    font-size: 26px;
    font-weight: 500;
}

.message-facts {
    display: grid;
    grid-template-columns: 64px minmax(0, 1fr);
    gap: 11px 18px;
    margin: 22px 0 18px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.46);
    padding: 18px;
}

.message-facts dt {
    color: #9dafc5;
    font-weight: 800;
}

.message-facts dd {
    margin: 0;
    color: #53637a;
    overflow-wrap: anywhere;
}

.modal-body {
    max-height: 390px;
    overflow: auto;
    border-radius: 10px;
    background: #fff;
    padding: 0;
}

.rendered-body {
    height: min(52vh, 560px);
    border: 1px solid rgba(150, 173, 209, 0.18);
}

.email-render {
    min-height: 100%;
    padding: 28px;
    background: #fff;
    color: #1f2937;
}

.email-render img {
    max-width: 100%;
    height: auto;
}

.email-render table {
    max-width: 100%;
}

.email-render a {
    color: #2563eb;
}

pre {
    margin: 0;
    white-space: pre-wrap;
    color: #343b48;
    font-family: inherit;
    font-size: 15px;
    line-height: 1.65;
}

@media (max-width: 980px) {
    .app-shell {
        width: calc(100vw - 28px);
    }

    .workspace,
    .filters {
        grid-template-columns: 1fr;
    }

    .side-card {
        min-height: auto;
    }

    .mailbox-list {
        max-height: 280px;
    }

    .protocol-row,
    .fetch-actions,
    .hero-card {
        align-items: stretch;
        flex-direction: column;
    }
}
