:root {
    --portal-ink: #172b4d;
    --portal-blue: #1769e8;
    --portal-muted: #72819a;
    --portal-line: #e2e9f1;
    --portal-bg: #eef3f8;
}

body {
    min-height: 100vh;
    background: var(--portal-bg);
    color: var(--portal-ink);
    font-family: Arial, Helvetica, sans-serif;
}

.portal-nav {
    height: 74px;
    padding: 0;
    background: #fff;
    border-bottom: 1px solid #e6ebf1;
}

.portal-nav-inner {
    height: 100%;
    padding-right: 28px !important;
    padding-left: 28px !important;
}

.navbar-brand {
    display: inline-flex;
    align-items: center;
    padding: 0;
}

.navbar-brand img {
    display: block;
    max-width: min(260px, 55vw);
    height: auto;
}

.btn-signout {
    display: inline-flex;
    min-height: 44px;
    align-items: center;
    gap: 10px;
    padding: 0 17px;
    border: 1px solid #8cb9ff;
    border-radius: 11px;
    background: #fff;
    color: #1769e8;
    font-size: 0.95rem;
}

.btn-signout:hover,
.btn-signout:focus-visible {
    background: #f1f6ff;
    border-color: #1769e8;
    color: #1358c5;
}

.btn-signout svg,
.mailbox-icon svg,
.search-icon svg,
.message-chevron,
.btn-mail-action svg {
    width: 22px;
    height: 22px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.8;
}

.mailbox-page {
    overflow: hidden;
}

.mailbox-main {
    height: calc(100vh - 74px);
    padding: 14px 18px 18px !important;
    overflow: hidden;
}

.mail-layout {
    display: grid !important;
    width: 100%;
    height: 100%;
    min-height: 0;
    grid-template-columns: minmax(340px, 420px) minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
    gap: 16px;
}

.mail-list-panel,
.mail-reader {
    min-width: 0;
    height: 100%;
    overflow: hidden;
    border-radius: 14px !important;
    background: #fff;
    box-shadow: 0 7px 24px rgb(25 48 78 / 8%);
}

.mail-list-panel {
    display: flex;
    flex-direction: column;
}

.mail-list-header {
    flex: 0 0 auto;
    padding: 18px 20px 16px;
    background: #fff;
    border-bottom: 1px solid var(--portal-line);
}

.mailbox-identity {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: 14px;
    margin-bottom: 22px;
}

.mailbox-icon,
.sender-avatar {
    display: grid;
    flex: 0 0 auto;
    place-items: center;
    border-radius: 50%;
    background: #eaf2ff;
    color: #1769e8;
}

.mailbox-icon {
    width: 48px;
    height: 48px;
}

.mailbox-icon svg {
    width: 23px;
    height: 23px;
}

.eyebrow {
    color: #2774e8;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.16em;
}

.mail-account-name {
    color: #182b48;
    font-size: 0.93rem;
    font-weight: 700;
}

.messages-heading {
    margin-bottom: 12px;
    color: #172b4d;
    font-size: 0.95rem;
    font-weight: 700;
}

.input-group {
    min-height: 46px;
    overflow: hidden;
    border: 1px solid #dce5ef;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgb(25 48 78 / 5%);
}

.input-group .form-control,
.input-group .input-group-text,
.input-group .btn {
    border: 0;
}

.search-icon {
    padding-left: 13px;
    background: #fff;
    color: #667893;
}

.search-icon svg {
    width: 20px;
    height: 20px;
}

.input-group .form-control {
    min-width: 0;
    box-shadow: none;
    font-size: 0.9rem;
}

.input-group .btn-primary {
    padding-right: 18px;
    padding-left: 18px;
    background: #1769e8;
    font-weight: 600;
}

.message-list {
    min-height: 0;
    flex: 1 1 auto;
    overflow-y: auto;
    background: #fff;
}

.message-row {
    display: flex;
    min-height: 101px;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 17px 14px 20px;
    border: 0;
    border-bottom: 1px solid var(--portal-line);
    border-left: 5px solid transparent;
    color: inherit;
    text-decoration: none;
}

.message-row:hover {
    background: #f7faff;
    color: inherit;
}

.message-row.selected {
    border-left-color: #2677f4;
    background: #edf4ff;
}

.message-row-content {
    min-width: 0;
}

.message-subject {
    margin-bottom: 4px;
    color: #172b4d;
    font-size: 0.9rem;
    font-weight: 700;
}

.message-row.unread .message-subject {
    font-weight: 700;
}

.message-row .small {
    color: #687b96 !important;
    font-size: 0.78rem;
}

.message-row-content time {
    display: block;
    margin-top: 5px;
    white-space: nowrap;
}

.message-chevron {
    flex: 0 0 auto;
    width: 18px;
    height: 18px;
    color: #8291a7;
}

.message-row.selected .message-chevron {
    color: #1769e8;
}

.mail-list-status {
    padding: 20px;
    color: var(--portal-muted);
    font-size: 0.9rem;
}

.mail-reader {
    overflow-y: auto;
}

.empty-reader {
    display: flex;
    width: 100%;
    height: 100%;
    min-height: 0;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    text-align: center;
}

.empty-reader-icon {
    display: grid;
    width: 3.5rem;
    height: 3.5rem;
    margin-bottom: 1rem;
    place-items: center;
    border-radius: 50%;
    background: #eaf2ff;
    color: #1769e8;
    font-size: 1.6rem;
}

.email-detail {
    min-height: 100%;
    background: #fff;
}

.email-detail-header {
    padding: 29px 32px 22px;
    border-bottom: 1px solid var(--portal-line);
}

.email-heading-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
}

.email-subject {
    color: #182b48;
    font-size: clamp(1.55rem, 2.3vw, 2.15rem);
    font-weight: 400;
    line-height: 1.25;
    overflow-wrap: anywhere;
}

.btn-mail-action {
    display: inline-grid;
    width: 48px;
    height: 48px;
    flex: 0 0 auto;
    place-items: center;
    border: 1px solid #e2e9f1;
    border-radius: 11px;
    background: #f8fafc;
    color: #41536c;
}

.btn-mail-action:hover {
    border-color: #bdd4f6;
    background: #edf4ff;
    color: #1769e8;
}

.sender-details {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
}

.sender-avatar {
    width: 58px;
    height: 58px;
    font-size: 1.05rem;
    font-weight: 700;
}

.sender-metadata {
    min-width: 0;
    color: #465a76;
    font-size: 0.95rem;
    overflow-wrap: anywhere;
}

.email-actions {
    display: flex;
    flex: 0 0 auto;
    gap: 10px;
    margin-left: auto;
}

.sender-metadata time {
    display: block;
    margin-top: 4px;
    color: #7888a0 !important;
}

.email-detail-body {
    padding: 27px 32px 36px;
    color: #243853;
}

.email-body {
    color: #243853;
    font-size: 1rem;
    line-height: 1.65;
    overflow-wrap: anywhere;
}

.email-body table {
    max-width: 100%;
    border-collapse: collapse;
}

.email-body td,
.email-body th {
    padding: 0.25rem;
    border: 1px solid var(--portal-line);
}

.email-inline-images {
    display: grid;
    gap: 1rem;
}

.email-inline-image {
    display: block;
    max-width: 100%;
    height: auto;
}

.back-link {
    color: var(--portal-blue);
    font-weight: 600;
    text-decoration: none;
}

.attachment-preview-frame {
    display: block;
    width: 100%;
    height: calc(100vh - 180px);
    border: 1px solid #d7deea;
    background: #fff;
}

.attachment-image-preview {
    padding: 1rem;
    text-align: center;
    background: #fff;
    border: 1px solid #d7deea;
}

.attachment-image-preview img {
    max-width: 100%;
    max-height: calc(100vh - 180px);
    object-fit: contain;
}

.attachment-text-preview {
    max-height: calc(100vh - 180px);
    padding: 1rem;
    overflow: auto;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    background: #fff;
    border: 1px solid #d7deea;
}

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

    .portal-nav,
    .mail-list-panel,
    .attachment-back,
    .attachment-toolbar,
    .attachment-actions,
    .btn-mail-action {
        display: none !important;
    }

    .mailbox-page,
    .mailbox-main,
    .mail-layout,
    .mail-reader {
        display: block !important;
        width: 100%;
        height: auto;
        overflow: visible;
        background: #fff;
        box-shadow: none;
    }

    .attachment-preview-frame {
        height: 100vh;
        border: 0;
    }
}

@media (max-width: 767.98px) {
    .mailbox-page {
        overflow: auto;
    }

    .mailbox-main {
        height: auto;
        min-height: calc(100vh - 74px);
        padding: 12px !important;
        overflow: visible;
    }

    .mail-layout {
        height: auto;
        min-height: calc(100vh - 98px);
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: minmax(280px, 38vh) minmax(55vh, 1fr);
    }

    .mail-list-panel {
        height: 100%;
    }

    .mail-reader {
        height: 100%;
        min-height: 55vh;
    }

    .email-detail-header {
        padding: 22px 20px 18px;
    }

    .email-detail-body {
        padding: 20px;
    }
}
