:root {
    --green: #61bf31;
    --green-dark: #173f22;
    --green-soft: #e4ffda;
    --sidebar: #071422;
    --page: #cfd6d8;
    --panel: #d9dee1;
    --row: #e7eaec;
    --ink: #05070a;
    --muted: #566066;
    --line: rgba(7, 20, 34, 0.18);
    --shadow: 0 18px 45px rgba(7, 20, 34, 0.12);
    --radius-xl: 24px;
    --radius-lg: 18px;
    --sidebar-width: 228px;
}

@font-face {
    font-family: "Poppins";
    src: url("../fonts/poppins/Poppins-Regular.ttf") format("truetype");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "Poppins";
    src: url("../fonts/poppins/Poppins-SemiBold.ttf") format("truetype");
    font-weight: 600;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "Poppins";
    src: url("../fonts/poppins/Poppins-Bold.ttf") format("truetype");
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "Poppins";
    src: url("../fonts/poppins/Poppins-ExtraBold.ttf") format("truetype");
    font-weight: 800;
    font-style: normal;
    font-display: swap;
}


* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
}

body {
    min-height: 100%;
    margin: 0;
    background: var(--page);
    color: var(--ink);
    font-family: "Poppins", Arial, sans-serif;
    font-size: 15px;
}

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

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

button {
    cursor: pointer;
}

button:disabled,
.button.is-loading,
.icon-button.is-loading {
    cursor: wait;
    opacity: 0.72;
}

.icon {
    width: 28px;
    height: 28px;
    display: block;
    flex: 0 0 auto;
    pointer-events: none;
}

.page-loader {
    position: fixed;
    inset: 0;
    z-index: 200;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.16s ease;
}

.page-loader::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    width: 42%;
    height: 4px;
    border-radius: 0 999px 999px 0;
    background: var(--green);
    box-shadow: 0 0 22px rgba(97, 191, 49, 0.85);
    transform: translateX(-110%);
}

.page-loader::after {
    content: attr(data-label);
    position: fixed;
    right: 28px;
    bottom: 26px;
    min-width: 128px;
    border-radius: 16px;
    background: rgba(7, 20, 34, 0.92);
    color: #fff;
    padding: 13px 18px 13px 46px;
    font-weight: 700;
    box-shadow: var(--shadow);
}

.page-loader .loader-ring {
    position: fixed;
    right: 134px;
    bottom: 38px;
    color: #fff;
}

body.is-page-loading .page-loader {
    opacity: 1;
    pointer-events: auto;
}

body.is-page-loading .page-loader::before {
    animation: page-progress 1.05s ease-in-out infinite;
}

.loader-ring,
.button.is-loading::after,
.icon-button.is-loading::after {
    width: 20px;
    height: 20px;
    border: 3px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    display: inline-block;
    animation: spin 0.72s linear infinite;
}

.button.is-loading,
.icon-button.is-loading {
    position: relative;
}

.button.is-loading::after,
.icon-button.is-loading::after {
    content: "";
}

.icon-button.is-loading .icon {
    display: none;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes page-progress {
    0% {
        transform: translateX(-110%);
        width: 32%;
    }
    50% {
        width: 58%;
    }
    100% {
        transform: translateX(320%);
        width: 32%;
    }
}

.app-shell {
    min-height: 100vh;
}

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 30;
    width: var(--sidebar-width);
    padding: 30px 14px;
    background: var(--sidebar);
    color: #fff;
    box-shadow: 10px 0 30px rgba(7, 20, 34, 0.12);
}

.brand {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 2px;
    margin-bottom: 38px;
}

.brand img,
.account-pill img,
.account-wrap .account-menu::before {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
}

.avatar-initials {
    width: 48px;
    height: 48px;
    border: 3px solid var(--green);
    border-radius: 50%;
    background: #071422;
    color: var(--green);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    font-size: 18px;
    font-weight: 800;
    letter-spacing: 0;
}

.avatar-initials.small {
    width: 46px;
    height: 46px;
}

.avatar-initials.tiny {
    width: 42px;
    height: 42px;
    font-size: 16px;
}

.brand strong {
    display: block;
    font-size: 16px;
    line-height: 1.15;
    white-space: nowrap;
}

.brand small {
    display: block;
    margin-top: 4px;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.85);
}

.compose-button {
    width: 100%;
    height: 53px;
    border: 0;
    border-radius: 14px;
    background: var(--green);
    color: #071422;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    font-weight: 700;
    box-shadow: 0 12px 24px rgba(97, 191, 49, 0.22);
}

.compose-button .icon {
    width: 25px;
    height: 25px;
}

.side-nav {
    display: grid;
    gap: 6px;
    margin-top: 22px;
}

.side-nav a {
    height: 53px;
    border-radius: 0 12px 12px 0;
    display: flex;
    align-items: center;
    gap: 13px;
    padding: 0 28px;
    color: rgba(255, 255, 255, 0.94);
    font-weight: 700;
}

.side-nav a.is-active {
    background: var(--green-dark);
}

.side-nav .icon {
    width: 24px;
    height: 24px;
}

.mail-main {
    min-height: 100vh;
    margin-left: var(--sidebar-width);
    padding: 24px 24px 12px;
}

.topbar {
    height: 78px;
    border-radius: var(--radius-xl);
    background: rgba(232, 236, 238, 0.78);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 18px 0 30px;
    margin-bottom: 26px;
}

.topbar-title {
    display: flex;
    align-items: center;
    gap: 16px;
    min-width: 0;
}

.topbar h1 {
    margin: 0;
    font-size: 26px;
    font-weight: 700;
}

.back-button,
.mobile-menu,
.icon-button,
.compose-controls button,
.compose-tool,
.modal-card header button {
    border: 0;
    background: transparent;
    color: var(--ink);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.back-button .icon {
    width: 32px;
    height: 32px;
}

.mobile-menu {
    display: none;
}

.account-wrap {
    position: relative;
}

.account-pill {
    min-width: 264px;
    height: 62px;
    border: 0;
    border-radius: 28px;
    background: rgba(243, 245, 246, 0.82);
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    color: var(--ink);
    text-align: left;
}

.account-pill .account-text {
    display: grid;
    flex: 1;
    min-width: 0;
}

.account-pill .avatar-initials {
    display: inline-flex;
    flex: 0 0 46px;
    min-width: 46px;
    aspect-ratio: 1;
}

.account-pill strong,
.account-menu strong {
    font-weight: 700;
    line-height: 1.15;
}

.account-pill small,
.account-menu span {
    overflow: hidden;
    color: #0d1115;
    font-size: 13px;
    text-overflow: ellipsis;
}

.account-pill .icon {
    width: 22px;
    height: 22px;
}

.account-menu {
    position: absolute;
    top: 68px;
    right: 18px;
    z-index: 40;
    width: 306px;
    border-radius: 12px;
    background: var(--green-soft);
    padding: 24px 30px 22px;
    box-shadow: var(--shadow);
    display: none;
}

.account-menu.is-open {
    display: grid;
}

.account-menu strong,
.account-menu span {
    text-align: center;
}

.account-menu span {
    margin-top: 4px;
    margin-bottom: 12px;
    font-size: 17px;
}

.account-menu a,
.account-menu > button:not(.button),
.account-menu form button {
    border: 0;
    background: transparent;
    padding: 7px 0;
    text-align: left;
    font-weight: 700;
    font-size: 18px;
}

.account-menu form {
    margin: 0;
}

.button {
    min-height: 48px;
    border: 0;
    border-radius: 12px;
    padding: 0 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: var(--ink);
    font-weight: 700;
}

.button-primary {
    background: var(--green);
    box-shadow: 0 10px 22px rgba(97, 191, 49, 0.2);
}

.button-soft {
    background: var(--green);
}

.button.large {
    width: 100%;
    min-height: 54px;
    margin-top: 8px;
}

.content-panel {
    min-height: calc(100vh - 128px);
    border-radius: var(--radius-xl);
    background: rgba(224, 229, 232, 0.58);
    padding: 16px;
}

.mail-toolbar {
    height: 54px;
    display: flex;
    align-items: center;
    gap: 28px;
    padding: 0 18px 8px;
}

.icon-button {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    cursor: pointer;
    touch-action: manipulation;
    transition: background 0.16s ease, transform 0.12s ease, box-shadow 0.16s ease;
}

.icon-button:hover,
.compose-tool:hover,
.back-button:hover {
    background: rgba(7, 20, 34, 0.06);
}

.icon-button[aria-disabled="true"] {
    opacity: 0.48;
}

.icon-button:active,
.compose-tool:active,
.back-button:active {
    transform: translateY(1px) scale(0.98);
}

.icon-button:focus-visible,
.compose-tool:focus-visible,
.back-button:focus-visible,
.compose-controls button:focus-visible,
.toolbar-check:focus-within,
.row-check:focus-within {
    outline: 3px solid rgba(97, 191, 49, 0.34);
    outline-offset: 2px;
}

.icon-button.large {
    width: 48px;
    height: 48px;
}

.toolbar-check,
.row-check {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.toolbar-check input,
.row-check input {
    position: absolute;
    opacity: 0;
}

.toolbar-check span,
.row-check span {
    position: relative;
    width: 27px;
    height: 27px;
    border: 2px solid rgba(5, 7, 10, 0.88);
    border-radius: 4px;
    background: transparent;
    display: block;
    transition: background 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}

.toolbar-check input:checked + span,
.toolbar-check input:indeterminate + span,
.row-check input:checked + span,
.checkbox-active span {
    background: var(--green);
    border-color: var(--green);
    box-shadow: 0 0 0 4px rgba(97, 191, 49, 0.14);
}

.toolbar-check span::after,
.row-check span::after {
    content: "";
    position: absolute;
    left: 7px;
    top: 3px;
    width: 8px;
    height: 14px;
    border: solid #071422;
    border-width: 0 3px 3px 0;
    opacity: 0;
    transform: rotate(45deg) scale(0.8);
    transition: opacity 0.12s ease, transform 0.12s ease;
}

.toolbar-check input:checked + span::after,
.toolbar-check input:indeterminate + span::after,
.row-check input:checked + span::after,
.checkbox-active span::after {
    opacity: 1;
    transform: rotate(45deg) scale(1);
}

.toolbar-check input:indeterminate + span::after {
    left: 5px;
    top: 10px;
    width: 13px;
    height: 0;
    border-width: 0 0 3px 0;
    transform: none;
}

.selected-count {
    margin-left: auto;
    border-radius: 999px;
    background: rgba(97, 191, 49, 0.16);
    color: #173f22;
    padding: 8px 13px;
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
}

.mail-list {
    display: grid;
    gap: 22px;
    padding: 0 0 38px;
}

.mail-row {
    position: relative;
    min-height: 100px;
    background: var(--row);
    display: grid;
    grid-template-columns: 76px minmax(180px, 1fr) auto;
    align-items: center;
    gap: 22px;
    padding: 0 38px 0 58px;
    cursor: pointer;
    transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.mail-row:hover {
    transform: translateY(-1px);
    box-shadow: 0 12px 28px rgba(7, 20, 34, 0.08);
}

.mail-row.mail-selected {
    background: rgba(97, 191, 49, 0.13);
    box-shadow: inset 4px 0 0 var(--green), 0 12px 28px rgba(7, 20, 34, 0.08);
}

.mail-row.is-loading {
    overflow: hidden;
    pointer-events: none;
}

.mail-row.is-loading::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.52), transparent);
    animation: shimmer 1.1s linear infinite;
}

@keyframes shimmer {
    from {
        transform: translateX(-100%);
    }
    to {
        transform: translateX(100%);
    }
}

.mail-row.is-read {
    background: rgba(231, 234, 236, 0.62);
}

.mail-row.is-unread {
    background: var(--row);
}

.row-check {
    position: absolute;
    left: 18px;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0;
    cursor: pointer;
    transition: opacity 0.16s ease;
}

.mail-row:hover .row-check,
.mail-row:focus-within .row-check,
.row-check.checkbox-active {
    opacity: 1;
}

.row-check span {
    width: 22px;
    height: 22px;
}

.row-check span::after {
    left: 6px;
    top: 2px;
    width: 6px;
    height: 12px;
    border-width: 0 2px 2px 0;
}

.avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    object-fit: cover;
}

.mail-copy {
    display: grid;
    gap: 2px;
    min-width: 0;
}

.mail-copy strong {
    font-size: 20px;
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mail-copy span {
    font-size: 17px;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mail-row.is-read .mail-copy strong {
    font-weight: 600;
    color: rgba(5, 7, 10, 0.86);
}

.mail-row.is-read .mail-copy span {
    font-weight: 400;
    color: rgba(5, 7, 10, 0.72);
}

.mail-row.is-unread .mail-copy strong {
    font-weight: 800;
    color: var(--ink);
}

.mail-row.is-unread .mail-copy span {
    font-weight: 700;
    color: var(--ink);
}

.mail-actions {
    display: flex;
    align-items: center;
    gap: 34px;
}

.mail-actions time {
    display: grid;
    min-width: 52px;
    text-align: center;
    font-size: 13px;
    line-height: 1.28;
}

.inline-form {
    display: inline;
    margin: 0;
}

.star-toggle.is-on {
    color: #000;
}

.star-toggle.is-on .icon path {
    fill: currentColor;
    stroke: currentColor;
}

.confirm-dialog {
    position: fixed;
    inset: 0;
    z-index: 240;
    display: grid;
    place-items: center;
    padding: 22px;
    background: rgba(7, 20, 34, 0.28);
}

.confirm-card {
    width: min(430px, 100%);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 18px;
    background: #101918;
    color: #fff;
    box-shadow: 0 24px 50px rgba(7, 20, 34, 0.32);
    padding: 24px 26px;
}

.confirm-card h2 {
    margin: 0 0 8px;
    font-size: 22px;
}

.confirm-card p {
    margin: 0;
    color: rgba(255, 255, 255, 0.82);
    line-height: 1.55;
}

.confirm-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 24px;
}

.confirm-actions button {
    min-width: 104px;
    min-height: 46px;
    border: 0;
    border-radius: 999px;
    padding: 0 18px;
    color: #071422;
    font-weight: 700;
}

.confirm-actions .confirm-cancel {
    background: #0b7778;
    color: #fff;
}

.confirm-actions .confirm-ok {
    background: #7dd4d8;
    box-shadow: 0 0 0 4px rgba(125, 212, 216, 0.26);
}

.empty-state {
    min-height: 280px;
    display: grid;
    place-content: center;
    gap: 6px;
    text-align: center;
    color: var(--muted);
}

.empty-state strong {
    color: var(--ink);
    font-size: 20px;
}

.panel-alert,
.alert {
    border-radius: 14px;
    background: #fff5d7;
    padding: 14px 16px;
    margin: 4px 0 16px;
    color: #3b2d00;
    font-weight: 600;
}

.panel-alert.error,
.alert.error {
    background: #ffe1e1;
    color: #661b1b;
}

.panel-alert.success,
.alert.success {
    background: #e4ffda;
    color: #153f19;
}

.panel-alert.subtle {
    background: rgba(255, 255, 255, 0.46);
    color: var(--muted);
}

.read-panel {
    padding: 20px 36px 40px;
}

.read-toolbar {
    display: grid;
    grid-template-columns: 54px minmax(240px, 1fr) auto;
    align-items: center;
    gap: 30px;
    min-height: 74px;
}

.read-toolbar h2 {
    margin: 0;
    font-size: 23px;
    font-weight: 700;
}

.read-actions {
    display: flex;
    align-items: center;
    gap: 24px;
}

.message-detail {
    display: grid;
    grid-template-columns: 56px minmax(0, 1fr);
    gap: 20px;
    max-width: 960px;
    margin: 26px 0 0 12px;
}

.message-detail h3 {
    margin: 0;
    font-size: 22px;
    font-weight: 700;
}

.to-me {
    border: 0;
    background: transparent;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0;
    font-weight: 600;
}

.to-me .icon {
    width: 16px;
    height: 16px;
}

.message-body {
    margin-top: 20px;
    max-width: 840px;
    line-height: 1.72;
    overflow-wrap: anywhere;
}

.attachments {
    display: grid;
    gap: 8px;
    margin-top: 28px;
}

.attachments span {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    width: fit-content;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.55);
    padding: 10px 14px;
}

.settings-panel {
    padding: 70px 16px 16px;
}

.settings-row {
    min-height: 100px;
    background: var(--row);
    display: flex;
    align-items: center;
    padding-left: 102px;
    margin-bottom: 2px;
    font-size: 20px;
    font-weight: 700;
}

.settings-form-row {
    justify-content: space-between;
    gap: 18px;
    border: 0;
    width: 100%;
    color: var(--ink);
}

.settings-form-row > button:not(.button) {
    border: 0;
    background: transparent;
    font-size: 20px;
    font-weight: 700;
}

.settings-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    grid-template-columns: none;
    width: min(520px, 100%);
}

.settings-toggle input {
    width: 24px;
    height: 24px;
}

.settings-row:nth-child(2) {
    background: transparent;
}

.form-panel {
    padding: 38px;
}

.settings-form,
.login-card {
    display: grid;
    gap: 16px;
}

label {
    display: grid;
    gap: 7px;
    color: #111820;
    font-weight: 700;
}

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

select {
    appearance: none;
    padding-right: 44px;
    background-image:
        linear-gradient(45deg, transparent 50%, #071422 50%),
        linear-gradient(135deg, #071422 50%, transparent 50%);
    background-position:
        calc(100% - 22px) 52%,
        calc(100% - 16px) 52%;
    background-repeat: no-repeat;
    background-size: 7px 7px;
    cursor: pointer;
}

select:hover {
    border-color: rgba(7, 20, 34, 0.34);
}

textarea {
    resize: vertical;
    line-height: 1.55;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--green);
    box-shadow: 0 0 0 4px rgba(97, 191, 49, 0.15);
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.form-grid.one {
    grid-template-columns: 1fr;
    margin-top: 12px;
}

.checkbox-line {
    display: flex;
    align-items: center;
    grid-template-columns: auto 1fr;
    gap: 10px;
}

.checkbox-line input {
    width: auto;
}

.signature-preview {
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.5);
    padding: 16px;
}

.signature-preview div {
    margin-top: 8px;
}

.signature-editor-wrap {
    border: 1px solid rgba(7, 20, 34, 0.18);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.42);
    overflow: hidden;
}

.signature-toolbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px;
    border-bottom: 1px solid rgba(7, 20, 34, 0.14);
    background: rgba(255, 255, 255, 0.34);
}

.signature-toolbar button {
    min-width: 38px;
    height: 36px;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: var(--ink);
    font-weight: 800;
}

.signature-toolbar button:hover {
    background: rgba(97, 191, 49, 0.18);
}

.signature-editor,
.signature-html-source {
    min-height: 150px;
    border: 0;
    border-radius: 0;
    background: transparent;
    padding: 14px;
    line-height: 1.58;
    outline: none;
}

.signature-editor:empty::before {
    content: attr(data-placeholder);
    color: rgba(5, 7, 10, 0.46);
}

.signature-editor:focus,
.signature-html-source:focus {
    box-shadow: inset 0 0 0 2px rgba(97, 191, 49, 0.22);
}

.signature-html-source {
    display: none;
    width: 100%;
    min-height: 190px;
    font-family: Consolas, "Courier New", monospace;
    font-size: 14px;
    resize: vertical;
}

.signature-editor-wrap.is-html-mode .signature-editor {
    display: none;
}

.signature-editor-wrap.is-html-mode .signature-html-source {
    display: block;
}

.signature-list {
    display: grid;
    gap: 18px;
    margin-top: 24px;
}

.signature-card {
    border-radius: 16px;
    background: rgba(231, 234, 236, 0.62);
    padding: 18px;
}

.signature-card h2 {
    margin: 0 0 4px;
}

.signature-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 6px;
}

.compose-modal {
    position: fixed;
    inset: 0;
    z-index: 60;
    pointer-events: none;
    display: none;
}

.compose-modal.is-open {
    display: block;
}

.compose-window {
    position: absolute;
    right: 50px;
    bottom: 0;
    width: min(710px, calc(100vw - var(--sidebar-width) - 70px));
    height: min(640px, calc(100vh - 128px));
    max-height: calc(100vh - 16px);
    border: 4px solid var(--green);
    border-bottom: 0;
    border-radius: 24px 24px 0 0;
    background: var(--page);
    box-shadow: 0 20px 45px rgba(7, 20, 34, 0.2);
    pointer-events: auto;
    display: grid;
    grid-template-rows: 78px minmax(0, 1fr) 74px;
    overflow: hidden;
}

.compose-status {
    position: absolute;
    inset: 78px 0 0;
    z-index: 4;
    background: rgba(207, 214, 216, 0.84);
    backdrop-filter: blur(6px);
    display: none;
    place-content: center;
    justify-items: center;
    gap: 14px;
    color: var(--ink);
}

.compose-window.is-sending .compose-status,
.compose-window.is-saving .compose-status {
    display: grid;
}

.compose-status .loader-ring {
    width: 44px;
    height: 44px;
    border-width: 5px;
    color: var(--green);
}

.compose-status strong {
    font-size: 20px;
}

.compose-modal.is-minimized .compose-window {
    height: 78px;
}

.compose-modal.is-maximized .compose-window {
    inset: 24px 24px 0 calc(var(--sidebar-width) + 24px);
    width: auto;
    height: auto;
}

.compose-header {
    background: var(--green);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 26px;
}

.compose-header h2 {
    margin: 0;
    font-size: 25px;
    font-weight: 700;
}

.compose-controls {
    display: flex;
    align-items: center;
    gap: 20px;
}

.compose-controls button .icon {
    width: 30px;
    height: 30px;
}

.compose-body {
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow-y: auto;
    padding: 14px 22px;
}

.compose-body input,
.compose-body textarea,
.compose-editor,
.compose-from,
.signature-select {
    border: 0;
    border-bottom: 1px solid rgba(7, 20, 34, 0.24);
    border-radius: 0;
    background: transparent;
    padding: 11px 10px;
}

.signature-select {
    color: rgba(5, 7, 10, 0.78);
    font-weight: 600;
}

.compose-from {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
}

.compose-from select {
    flex: 1;
    min-width: 0;
    border: 0;
    border-radius: 0;
    background-color: transparent;
    padding: 0 28px 0 0;
    font-weight: 700;
    box-shadow: none;
}

.compose-from select:focus {
    box-shadow: none;
}

.compose-from .icon {
    width: 18px;
    height: 18px;
}

.compose-line {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: center;
    border-bottom: 1px solid rgba(7, 20, 34, 0.24);
}

.compose-line input {
    border-bottom: 0;
}

.compose-line button {
    border: 0;
    background: transparent;
    padding: 0 12px;
    font-weight: 600;
}

.compose-optional {
    display: none;
}

.compose-optional.is-visible {
    display: block;
}

.compose-body textarea,
.compose-editor {
    flex: 1 1 auto;
    min-height: 0;
    border-bottom: 0;
    overflow: auto;
    resize: none;
}

.compose-editor {
    line-height: 1.55;
    outline: none;
    white-space: normal;
    overflow-wrap: anywhere;
}

.compose-editor:empty::before {
    content: attr(data-placeholder);
    color: rgba(5, 7, 10, 0.48);
}

.compose-editor:focus {
    box-shadow: inset 0 0 0 2px rgba(97, 191, 49, 0.2);
}

.compose-editor blockquote {
    border-left: 4px solid rgba(7, 20, 34, 0.24);
    margin: 8px 0;
    padding-left: 12px;
}

.compose-editor ul,
.compose-editor ol {
    margin: 8px 0;
    padding-left: 24px;
}

.compose-editor a {
    color: #0b6f8b;
    text-decoration: underline;
}

.compose-window.was-validated input:invalid,
.compose-window.was-validated textarea:invalid,
.compose-window.was-validated .compose-editor.is-invalid {
    border-color: #b42318;
    box-shadow: 0 2px 0 #b42318;
}

.compose-footer {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 14px;
    min-height: 74px;
    padding: 0 18px;
    border-top: 1px solid rgba(7, 20, 34, 0.12);
    background: var(--page);
    position: relative;
    z-index: 2;
}

.compose-footer .button {
    min-height: 52px;
}

.compose-tool {
    position: relative;
    width: 40px;
    height: 52px;
    border-radius: 10px;
}

.compose-tool input,
.signature-tool select {
    display: none;
}

.signature-tool select {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.format-wrap {
    position: relative;
    display: inline-flex;
}

.format-popover {
    position: absolute;
    left: 50%;
    bottom: 58px;
    z-index: 5;
    display: none;
    align-items: center;
    gap: 6px;
    width: max-content;
    max-width: min(420px, calc(100vw - 28px));
    border: 1px solid rgba(7, 20, 34, 0.16);
    border-radius: 14px;
    background: rgba(243, 245, 246, 0.98);
    padding: 8px;
    box-shadow: var(--shadow);
    transform: translateX(-50%);
}

.format-popover.is-open {
    display: flex;
}

.format-popover button {
    min-width: 36px;
    height: 36px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--ink);
    font-weight: 800;
}

.format-popover button:hover {
    background: rgba(97, 191, 49, 0.18);
}

.compose-tool.danger {
    margin-left: auto;
}

.modal {
    position: fixed;
    inset: 0;
    z-index: 80;
    background: rgba(7, 20, 34, 0.28);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 22px;
}

.modal.is-open {
    display: flex;
}

.modal-card {
    width: min(680px, 100%);
    max-height: min(760px, calc(100vh - 44px));
    overflow: auto;
    border-radius: 20px;
    background: var(--row);
    padding: 22px;
    box-shadow: var(--shadow);
}

.modal-card.compact {
    width: min(450px, 100%);
}

.modal-card header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
}

.modal-card h2 {
    margin: 0;
}

.modal-card footer {
    display: flex;
    justify-content: flex-end;
    margin-top: 18px;
}

.account-list {
    display: grid;
    gap: 12px;
}

.account-choice {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.52);
    padding: 12px;
}

.account-choice span {
    display: grid;
}

.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 26px;
    background:
        linear-gradient(135deg, rgba(7, 20, 34, 0.96), rgba(23, 63, 34, 0.86)),
        var(--page);
}

.login-shell {
    width: min(980px, 100%);
    display: grid;
    grid-template-columns: 0.9fr 1.1fr;
    gap: 24px;
    align-items: stretch;
}

.login-brand,
.login-card {
    border-radius: 24px;
    background: rgba(231, 234, 236, 0.92);
    padding: 34px;
    box-shadow: var(--shadow);
}

.login-brand {
    display: grid;
    align-content: center;
    justify-items: start;
}

.login-brand img {
    width: 82px;
    height: 82px;
    border-radius: 50%;
}

.login-brand h1,
.login-card h2 {
    margin: 18px 0 8px;
    font-size: clamp(30px, 4vw, 48px);
    line-height: 1;
}

.login-brand p {
    color: #273039;
    line-height: 1.7;
}

.login-card h2 {
    font-size: 30px;
    margin-top: 0;
}

.toast-stack {
    position: fixed;
    right: 28px;
    bottom: 24px;
    z-index: 100;
    display: grid;
    gap: 10px;
}

.toast {
    min-width: 230px;
    max-width: 360px;
    border-radius: 14px;
    background: #071422;
    color: #fff;
    padding: 13px 16px;
    box-shadow: var(--shadow);
    font-weight: 700;
    animation: toast-in 0.18s ease both;
}

.toast.success {
    background: #173f22;
}

.toast.error {
    background: #741d1d;
}

.toast.warning {
    background: #6d5200;
}

.toast.info {
    background: #0b5168;
}

@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-card.is-loading {
    position: relative;
    overflow: hidden;
}

.modal-card.is-loading::after {
    content: "Loading...";
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    background: rgba(231, 234, 236, 0.72);
    color: var(--ink);
    font-weight: 700;
}

@media (max-width: 980px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.18s ease;
    }

    .sidebar.is-open {
        transform: translateX(0);
    }

    .mail-main {
        margin-left: 0;
        padding: 14px;
    }

    .mobile-menu {
        display: inline-flex;
    }

    .account-pill {
        min-width: 0;
        width: 64px;
    }

    .account-pill .account-text,
    .account-pill > .icon {
        display: none;
    }

    .compose-window,
    .compose-modal.is-maximized .compose-window {
        inset: auto 0 0 0;
        width: 100%;
        height: min(660px, calc(100vh - 70px));
        border-left: 0;
        border-right: 0;
    }

    .read-toolbar {
        grid-template-columns: 48px 1fr;
    }

    .read-actions {
        grid-column: 1 / -1;
        justify-content: flex-start;
        flex-wrap: wrap;
    }

    .login-shell {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 680px) {
    .topbar {
        height: auto;
        min-height: 72px;
        padding: 10px 12px;
        gap: 10px;
    }

    .topbar h1 {
        font-size: 22px;
    }

    .content-panel {
        padding: 12px;
    }

    .mail-toolbar {
        gap: 14px;
        overflow-x: auto;
    }

    .mail-row {
        grid-template-columns: 52px 1fr;
        min-height: 92px;
        gap: 12px;
        padding: 14px 14px 14px 48px;
    }

    .row-check {
        left: 14px;
    }

    .mail-copy strong {
        font-size: 16px;
    }

    .mail-copy span {
        font-size: 14px;
    }

    .mail-actions {
        grid-column: 2;
        justify-content: space-between;
        gap: 12px;
    }

    .settings-row {
        padding-left: 24px;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .compose-footer {
        flex-wrap: wrap;
        height: auto;
        padding: 10px;
    }

    .compose-window {
        grid-template-rows: 72px minmax(0, 1fr) auto;
    }
}

@media print {
    body {
        background: #fff;
    }

    .sidebar,
    .topbar,
    .read-toolbar,
    .toast-stack,
    .page-loader,
    .compose-modal {
        display: none !important;
    }

    .mail-main {
        margin: 0;
        padding: 0;
    }

    .content-panel {
        min-height: 0;
        background: #fff;
        padding: 0;
    }
}

/* Premium luxury polish + safer auto-refresh state */
body {
    background:
        radial-gradient(circle at top left, rgba(97, 191, 49, 0.22), transparent 30%),
        linear-gradient(135deg, #eef4f0 0%, #d8dee2 48%, #f7faf7 100%);
}
.sidebar {
    background: linear-gradient(180deg, #04111d 0%, #071422 52%, #02070d 100%);
    border-right: 1px solid rgba(255,255,255,0.08);
}
.content-panel,
.topbar,
.account-menu,
.modal-card,
.compose-window {
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
}
.content-panel {
    background: rgba(255,255,255,0.58);
    border: 1px solid rgba(255,255,255,0.72);
    box-shadow: 0 24px 70px rgba(7, 20, 34, 0.16);
}
.mail-toolbar {
    background: rgba(255,255,255,0.62);
    border: 1px solid rgba(7,20,34,0.08);
    box-shadow: 0 10px 26px rgba(7,20,34,0.08);
}
.mail-row {
    border: 1px solid rgba(7,20,34,0.06);
    background: rgba(255,255,255,0.72);
    transition: transform .18s ease, box-shadow .18s ease, background .18s ease, border-color .18s ease;
}
.mail-row:hover {
    transform: translateY(-2px);
    background: rgba(255,255,255,0.92);
    border-color: rgba(97,191,49,0.32);
    box-shadow: 0 14px 35px rgba(7,20,34,0.12);
}
.icon-button,
.button,
.account-pill {
    transition: transform .16s ease, box-shadow .16s ease, background .16s ease, border-color .16s ease;
}
.icon-button:hover,
.button:hover,
.account-pill:hover {
    transform: translateY(-1px);
}
.icon-button {
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
[data-auto-refresh-mailbox].is-refreshing-soft {
    opacity: .96;
}
[data-auto-refresh-mailbox].is-refreshing-soft::before {
    content: "Syncing mail…";
    display: block;
    width: fit-content;
    margin: 0 auto 10px;
    padding: 7px 12px;
    border-radius: 999px;
    color: #173f22;
    background: rgba(97,191,49,0.16);
    border: 1px solid rgba(97,191,49,0.24);
    font-size: 12px;
    font-weight: 700;
}
.selected-count {
    margin-left: auto;
    padding: 9px 14px;
    border-radius: 999px;
    background: rgba(97,191,49,0.14);
    color: #173f22;
    border: 1px solid rgba(97,191,49,0.22);
    font-weight: 700;
    font-size: 13px;
}
.brand img {
    background: #fff;
    padding: 4px;
    box-shadow: 0 10px 28px rgba(97,191,49,0.22);
}
@media (max-width: 768px) {
    .icon-button {
        min-width: 42px;
        min-height: 42px;
    }
    .selected-count {
        order: 10;
        width: 100%;
        text-align: center;
        margin-left: 0;
    }
}

/* =========================================================
   Final responsive Gmail-style layout patch
   ========================================================= */
html,
body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
}

body.sidebar-open {
    overflow: hidden;
}

.sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 24;
    background: rgba(2, 7, 13, 0.46);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease;
}

body.sidebar-open .sidebar-backdrop {
    opacity: 1;
    pointer-events: auto;
}

.topbar,
.content-panel,
.mail-toolbar,
.mail-list,
.mail-row,
.read-panel,
.message-detail,
.form-panel,
.settings-panel,
.modal-card,
.compose-window {
    max-width: 100%;
}

.topbar {
    position: sticky;
    top: 12px;
    z-index: 20;
}

.mobile-menu {
    width: 46px;
    height: 46px;
    border-radius: 14px;
    background: rgba(255,255,255,.72);
    box-shadow: 0 10px 22px rgba(7,20,34,.08);
}

.back-button {
    width: 46px;
    height: 46px;
    border-radius: 14px;
}

.mail-toolbar {
    position: sticky;
    top: 104px;
    z-index: 18;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
}

.mail-row {
    border-radius: 24px;
}

.mail-row .icon-button,
.mail-toolbar .icon-button,
.read-actions .icon-button {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.message-body,
.message-body * {
    max-width: 100%;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.message-body img,
.message-body table,
.message-body iframe {
    max-width: 100% !important;
}

.message-body table {
    display: block;
    overflow-x: auto;
}

.form-grid,
.settings-form,
.signature-card,
.signature-list,
.login-card,
.login-panel {
    max-width: 100%;
}

input,
select,
textarea {
    max-width: 100%;
}

@media (min-width: 1280px) {
    .mail-main {
        padding: 28px 34px 18px;
    }

    .content-panel {
        border-radius: 30px;
    }
}

@media (max-width: 1180px) {
    :root {
        --sidebar-width: 214px;
    }

    .sidebar {
        padding-inline: 12px;
    }

    .side-nav a {
        padding: 0 20px;
    }

    .mail-row {
        grid-template-columns: 64px minmax(0, 1fr) auto;
        gap: 16px;
        padding-right: 22px;
    }

    .mail-copy strong {
        font-size: 18px;
    }

    .mail-copy span {
        font-size: 15px;
    }

    .mail-actions {
        gap: 18px;
    }
}

@media (max-width: 980px) {
    .sidebar {
        width: min(82vw, 310px);
        border-radius: 0 28px 28px 0;
        box-shadow: 24px 0 60px rgba(2,7,13,.34);
    }

    .sidebar.is-open {
        transform: translateX(0);
    }

    .mail-main {
        width: 100%;
        margin-left: 0;
        padding: 14px;
    }

    .topbar {
        top: 8px;
        border-radius: 22px;
        margin-bottom: 16px;
    }

    .mail-toolbar {
        top: 94px;
    }

    .account-menu {
        right: 0;
        left: auto;
        width: min(360px, calc(100vw - 28px));
    }

    .content-panel {
        border-radius: 24px;
    }
}

@media (max-width: 760px) {
    body {
        font-size: 14px;
    }

    .mail-main {
        padding: 10px;
    }

    .topbar {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: center;
        gap: 8px;
        min-height: 66px;
        padding: 8px 10px;
        border-radius: 20px;
    }

    .topbar-title {
        min-width: 0;
        gap: 8px;
    }

    .topbar h1 {
        max-width: 46vw;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        font-size: 20px;
    }

    .mobile-menu,
    .back-button {
        width: 42px;
        height: 42px;
        min-width: 42px;
        border-radius: 13px;
    }

    .account-pill {
        width: 46px;
        height: 46px;
        min-width: 46px;
        padding: 4px;
        border-radius: 50%;
        justify-content: center;
    }

    .account-pill .avatar-initials.small,
    .account-pill img {
        width: 38px;
        height: 38px;
        border-width: 2px;
        font-size: 14px;
    }

    .content-panel {
        padding: 10px;
        border-radius: 22px;
        background: rgba(255,255,255,.74);
    }

    .mail-toolbar {
        top: 84px;
        gap: 8px;
        justify-content: flex-start;
        padding: 8px;
        border-radius: 18px;
        overflow-x: auto;
        flex-wrap: nowrap;
        scrollbar-width: none;
    }

    .mail-toolbar::-webkit-scrollbar {
        display: none;
    }

    .toolbar-check,
    .mail-toolbar .icon-button {
        flex: 0 0 auto;
    }

    .selected-count {
        flex: 0 0 auto;
        width: auto;
        white-space: nowrap;
        order: 0;
    }

    .mail-list {
        gap: 10px;
        padding-bottom: 80px;
    }

    .mail-row {
        min-height: auto;
        grid-template-columns: 44px minmax(0, 1fr);
        align-items: start;
        gap: 10px;
        padding: 14px 12px 12px 42px;
        border-radius: 18px;
    }

    .row-check {
        left: 12px;
        top: 22px;
        transform: none;
        opacity: 1;
    }

    .row-check span {
        width: 20px;
        height: 20px;
    }

    .avatar {
        width: 42px;
        height: 42px;
    }

    .mail-copy {
        padding-right: 2px;
    }

    .mail-copy strong {
        font-size: 15px;
        line-height: 1.25;
    }

    .mail-copy span {
        font-size: 13px;
        line-height: 1.35;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        white-space: normal;
    }

    .mail-actions {
        grid-column: 2;
        justify-content: space-between;
        width: 100%;
        gap: 8px;
        margin-top: 8px;
    }

    .mail-actions .icon-button {
        width: 38px;
        min-width: 38px;
        height: 38px;
        min-height: 38px;
    }

    .mail-actions time {
        min-width: auto;
        display: flex;
        gap: 4px;
        font-size: 11px;
        opacity: .8;
    }

    .read-toolbar {
        display: grid;
        grid-template-columns: 42px minmax(0, 1fr);
        gap: 10px;
        align-items: start;
    }

    .read-toolbar h2 {
        font-size: 20px;
        line-height: 1.28;
        overflow-wrap: anywhere;
    }

    .read-actions {
        grid-column: 1 / -1;
        display: flex;
        gap: 8px;
        overflow-x: auto;
        padding-bottom: 4px;
    }

    .message-detail {
        display: grid;
        grid-template-columns: 42px minmax(0, 1fr);
        gap: 10px;
    }

    .message-detail h3 {
        font-size: 16px;
    }

    .message-body {
        font-size: 14px;
        line-height: 1.6;
    }

    .compose-window,
    .compose-modal.is-maximized .compose-window {
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        max-width: 100%;
        height: min(92vh, 720px);
        border-radius: 24px 24px 0 0;
    }

    .compose-header,
    .compose-controls,
    .compose-footer {
        flex-wrap: wrap;
    }

    .modal {
        padding: 10px;
    }

    .modal-card {
        width: 100%;
        max-height: calc(100vh - 20px);
        overflow-y: auto;
        border-radius: 22px;
    }

    .form-grid {
        grid-template-columns: 1fr !important;
    }

    .settings-row,
    .settings-form-row,
    .signature-actions {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .signature-toolbar {
        display: flex;
        overflow-x: auto;
        gap: 6px;
        padding-bottom: 4px;
    }

    .signature-editor {
        min-height: 160px;
    }
}

@media (max-width: 420px) {
    .mail-main {
        padding: 8px;
    }

    .topbar h1 {
        max-width: 40vw;
        font-size: 18px;
    }

    .content-panel {
        padding: 8px;
        border-radius: 18px;
    }

    .mail-row {
        grid-template-columns: 38px minmax(0, 1fr);
        padding-left: 38px;
    }

    .avatar {
        width: 38px;
        height: 38px;
    }

    .mail-copy strong {
        font-size: 14px;
    }

    .mail-copy span {
        font-size: 12px;
    }

    .brand strong {
        font-size: 14px;
    }

    .brand img {
        width: 42px;
        height: 42px;
    }
}
