:root {
    --wine: #87213f;
    --wine-dark: #66152f;
    --wine-soft: #f7edf1;
    --leaf: #5f873f;
    --leaf-soft: #edf4e8;
    --gold: #b18a4b;
    --gold-soft: #f8f1e3;
    --ink: #1e1b19;
    --muted: #756f68;
    --line: #ded8cf;
    --paper: #fff;
    --canvas: #f4f1eb;
    --shadow: 0 18px 55px rgba(50, 39, 31, 0.09);
}

html,
body {
    min-height: 100%;
}

html {
    background: var(--canvas);
    scroll-behavior: smooth;
}

body {
    margin: 0;
    color: var(--ink);
    background: var(--canvas);
    font-family: Inter, Avenir, "Avenir Next", "Segoe UI", Arial, sans-serif;
    font-size: 1rem;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

button,
input {
    font: inherit;
}

button,
a {
    -webkit-tap-highlight-color: transparent;
}

a {
    color: var(--wine);
}

a:hover {
    color: var(--wine-dark);
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

h1,
h2,
h3 {
    color: var(--ink);
    line-height: 1.15;
}

h1 {
    margin-bottom: 0.65rem;
    font-family: Georgia, "Times New Roman", serif;
    font-size: clamp(2rem, 5vw, 3.35rem);
    font-weight: 400;
    letter-spacing: -0.025em;
}

h2 {
    margin-bottom: 0.55rem;
    font-size: clamp(1.25rem, 2vw, 1.6rem);
}

:focus-visible {
    outline: 3px solid rgba(135, 33, 63, 0.38);
    outline-offset: 3px;
}

h1:focus {
    outline: none;
}

.eyebrow {
    display: inline-block;
    margin-bottom: 0.55rem;
    color: var(--wine);
    font-size: 0.72rem;
    font-weight: 850;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

.eyebrow.light {
    color: #d9c8aa;
}

.muted {
    color: var(--muted);
}

.status-dot {
    flex: 0 0 auto;
    width: 0.55rem;
    height: 0.55rem;
    display: inline-block;
    border-radius: 50%;
    background: #77a74d;
    box-shadow: 0 0 0 4px rgba(119, 167, 77, 0.15);
}

.button {
    min-height: 3rem;
    padding: 0.72rem 1.25rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.7rem;
    border: 1px solid transparent;
    border-radius: 0.45rem;
    font-size: 0.85rem;
    font-weight: 800;
    letter-spacing: 0.035em;
    text-decoration: none;
    cursor: pointer;
    transition: transform 150ms ease, box-shadow 150ms ease, background-color 150ms ease;
}

.button:hover {
    transform: translateY(-1px);
    text-decoration: none;
}

.button-primary {
    color: #fff;
    background: linear-gradient(135deg, var(--wine) 0%, #9e2b51 100%);
    box-shadow: 0 10px 26px rgba(135, 33, 63, 0.22);
}

.button-primary:hover {
    color: #fff;
    background: linear-gradient(135deg, var(--wine-dark), var(--wine));
    box-shadow: 0 13px 30px rgba(135, 33, 63, 0.3);
}

.button-secondary {
    color: var(--ink);
    background: #fff;
    border-color: var(--line);
}

.page-heading {
    margin-bottom: 2rem;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 2rem;
}

.page-heading p {
    max-width: 44rem;
    margin-bottom: 0;
    color: var(--muted);
}

.surface-card,
.stat-card {
    background: var(--paper);
    border: 1px solid rgba(117, 104, 91, 0.14);
    border-radius: 0.85rem;
    box-shadow: var(--shadow);
}

.card-header-row {
    padding-bottom: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    border-bottom: 1px solid #eee9e2;
}

.card-header-row h2 {
    margin: 0;
}

.card-header-row .eyebrow {
    margin-bottom: 0.3rem;
}

.read-only-badge,
.folder-pill,
.safety-label {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    border-radius: 999px;
    white-space: nowrap;
}

.read-only-badge {
    padding: 0.5rem 0.75rem;
    color: #45652d;
    background: var(--leaf-soft);
    border: 1px solid #d7e6ca;
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.04em;
}

.folder-pill {
    max-width: 12rem;
    overflow: hidden;
    padding: 0.25rem 0.55rem;
    color: #625a52;
    background: #f2eee8;
    font-size: 0.68rem;
    font-weight: 750;
    text-overflow: ellipsis;
}

.alert-panel {
    margin-bottom: 1.5rem;
    padding: 1rem 1.15rem;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    border: 1px solid;
    border-radius: 0.65rem;
    font-size: 0.88rem;
}

.alert-error {
    color: #731c35;
    background: #fbeef2;
    border-color: #efccd7;
}

.alert-warning {
    color: #684b1d;
    background: #fcf6e8;
    border-color: #ead7aa;
}

.page-loading {
    min-height: 12rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.85rem;
    color: var(--muted);
}

.spinner {
    width: 1.25rem;
    height: 1.25rem;
    display: inline-block;
    border: 2px solid #d9d2c9;
    border-top-color: var(--wine);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Login */
.login-page {
    min-height: min(44rem, calc(100vh - 20rem));
    display: grid;
    place-items: center;
}

.login-card {
    width: min(100%, 62rem);
    min-height: 34rem;
    display: grid;
    grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
    overflow: hidden;
    background: #fff;
    border: 1px solid rgba(117, 104, 91, 0.15);
    border-radius: 1rem;
    box-shadow: 0 28px 80px rgba(43, 31, 25, 0.14);
}

.login-card.compact-card {
    min-height: 0;
    grid-template-columns: 1fr;
}

.login-story {
    position: relative;
    overflow: hidden;
    padding: 3.5rem 3rem;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    color: #f8f4ee;
    background:
        radial-gradient(circle at 20% 15%, rgba(255, 255, 255, 0.08) 0 3.8rem, transparent 3.9rem),
        linear-gradient(150deg, rgba(12, 10, 10, 0.08), rgba(12, 10, 10, 0.62)),
        linear-gradient(135deg, #551128 0%, #8b2142 55%, #2a151c 100%);
}

.login-story::before {
    content: "";
    position: absolute;
    inset: 0;
    opacity: 0.17;
    background-image: repeating-linear-gradient(115deg, transparent 0 34px, rgba(255, 255, 255, 0.1) 35px, transparent 36px);
}

.login-story > * {
    position: relative;
    z-index: 1;
}

.login-story h1 {
    max-width: 24rem;
    color: #fff;
    font-size: clamp(2.2rem, 4vw, 3.4rem);
}

.login-story p {
    max-width: 27rem;
    color: rgba(255, 255, 255, 0.76);
}

.grape-cluster {
    position: absolute;
    z-index: 0;
    top: 2.2rem;
    left: 2rem;
    width: 12rem;
    height: 12rem;
    opacity: 0.23;
    transform: rotate(-8deg);
}

.grape-cluster span {
    position: absolute;
    width: 3.5rem;
    height: 3.5rem;
    border: 1px solid #fff;
    border-radius: 50%;
}

.grape-cluster span:nth-child(1) { left: 3.8rem; top: 0; }
.grape-cluster span:nth-child(2) { left: 1.8rem; top: 2.6rem; }
.grape-cluster span:nth-child(3) { left: 5.8rem; top: 2.6rem; }
.grape-cluster span:nth-child(4) { left: 0; top: 5.4rem; }
.grape-cluster span:nth-child(5) { left: 3.9rem; top: 5.4rem; }
.grape-cluster span:nth-child(6) { left: 7.8rem; top: 5.4rem; }
.grape-cluster span:nth-child(7) { left: 2rem; top: 8.2rem; }
.grape-cluster span:nth-child(8) { left: 5.9rem; top: 8.2rem; }
.grape-cluster span:nth-child(9) { left: 4rem; top: 11rem; }

.read-only-promise {
    margin-top: 1.5rem;
    padding-top: 1.2rem;
    display: flex;
    align-items: center;
    gap: 0.7rem;
    color: #e9dfd2;
    border-top: 1px solid rgba(255, 255, 255, 0.18);
    font-size: 0.78rem;
    font-weight: 750;
    letter-spacing: 0.025em;
}

.login-form-panel {
    padding: 3.5rem clamp(2rem, 5vw, 4.5rem);
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.login-form-panel h2 {
    margin-bottom: 0.6rem;
    font-family: Georgia, "Times New Roman", serif;
    font-size: 2.15rem;
    font-weight: 400;
}

.form-intro {
    margin-bottom: 1.8rem;
    color: var(--muted);
    font-size: 0.9rem;
}

.login-form {
    display: grid;
    gap: 0.75rem;
}

.login-form label {
    margin-top: 0.3rem;
    color: #39342f;
    font-size: 0.77rem;
    font-weight: 800;
    letter-spacing: 0.045em;
}

.input-shell {
    min-height: 3.35rem;
    padding: 0 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.7rem;
    border: 1px solid #d8d1c8;
    border-radius: 0.5rem;
    background: #fbfaf8;
    transition: border-color 150ms ease, box-shadow 150ms ease, background-color 150ms ease;
}

.input-shell:focus-within {
    border-color: var(--wine);
    background: #fff;
    box-shadow: 0 0 0 4px rgba(135, 33, 63, 0.09);
}

.input-shell svg {
    width: 1.15rem;
    height: 1.15rem;
    flex: 0 0 auto;
    fill: #9a9188;
}

.input-shell input {
    width: 100%;
    min-width: 0;
    padding: 0.8rem 0;
    border: 0;
    outline: 0;
    color: var(--ink);
    background: transparent;
}

.login-button {
    width: 100%;
    margin-top: 0.9rem;
}

.credential-note {
    margin-top: 1.5rem;
    padding-top: 1.25rem;
    display: flex;
    gap: 0.7rem;
    color: var(--muted);
    border-top: 1px solid #ece7e0;
    font-size: 0.75rem;
}

.credential-note svg {
    width: 1.25rem;
    height: 1.25rem;
    flex: 0 0 auto;
    fill: var(--leaf);
}

/* Dashboard */
.stats-grid {
    margin-bottom: 1.5rem;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1rem;
}

.stat-card {
    min-width: 0;
    padding: 1.2rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.stat-icon {
    width: 3.1rem;
    height: 3.1rem;
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    border-radius: 0.7rem;
    font-size: 1.25rem;
    font-weight: 800;
}

.stat-icon.burgundy { color: var(--wine); background: var(--wine-soft); }
.stat-icon.green { color: var(--leaf); background: var(--leaf-soft); }
.stat-icon.gold { color: #8b672f; background: var(--gold-soft); }
.stat-icon.charcoal { color: #4c4945; background: #efedeb; }

.stat-card > div:last-child {
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.stat-card span {
    overflow: hidden;
    color: var(--muted);
    font-size: 0.7rem;
    font-weight: 750;
    letter-spacing: 0.045em;
    text-overflow: ellipsis;
    text-transform: uppercase;
    white-space: nowrap;
}

.stat-card strong {
    overflow: hidden;
    margin-top: 0.1rem;
    font-family: Georgia, "Times New Roman", serif;
    font-size: 1.55rem;
    font-weight: 400;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.stat-card strong.stat-date {
    font-family: inherit;
    font-size: 1rem;
    font-weight: 750;
}

.sync-banner {
    margin-bottom: 1.5rem;
    padding: 1rem 1.2rem;
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 1rem;
    color: #40572f;
    background: linear-gradient(90deg, #edf4e8, #f8faf5);
    border: 1px solid #d8e6cc;
    border-radius: 0.8rem;
}

.sync-visual {
    width: 2.4rem;
    height: 2.4rem;
    display: grid;
    place-items: center;
    background: #fff;
    border-radius: 50%;
}

.sync-banner > div:nth-child(2) {
    display: flex;
    flex-direction: column;
}

.sync-banner strong {
    color: #334a23;
    font-size: 0.88rem;
}

.sync-banner span:not(.status-dot):not(.read-only-badge) {
    font-size: 0.78rem;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.65fr) minmax(17rem, 0.75fr);
    gap: 1.25rem;
    align-items: start;
}

.latest-mail-card,
.safety-card,
.mail-table-card,
.mail-metadata,
.mail-content-card {
    padding: 1.35rem;
}

.mail-preview-list {
    display: grid;
}

.mail-preview {
    min-width: 0;
    padding: 0.95rem 0.2rem;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.85rem;
    color: var(--ink);
    border-bottom: 1px solid #eee9e2;
    text-decoration: none;
}

.mail-preview:last-child {
    border-bottom: 0;
}

.mail-preview:hover {
    color: var(--ink);
    background: linear-gradient(90deg, transparent, #fbf8f5, transparent);
}

.sender-avatar {
    width: 2.4rem;
    height: 2.4rem;
    display: grid;
    place-items: center;
    color: #fff;
    background: #7f2945;
    border-radius: 50%;
    font-size: 0.8rem;
    font-weight: 850;
}

.mail-preview-copy,
.mail-preview-meta {
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.mail-preview-copy strong,
.mail-preview-copy small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mail-preview-copy strong {
    font-size: 0.86rem;
}

.mail-preview-copy small,
.mail-preview-meta small {
    color: var(--muted);
    font-size: 0.72rem;
}

.mail-preview-meta {
    align-items: flex-end;
    gap: 0.25rem;
}

.safety-card {
    position: sticky;
    top: 1rem;
    overflow: hidden;
    background: linear-gradient(155deg, #191614 0%, #2a2022 100%);
    border-color: transparent;
}

.safety-card::after {
    content: "";
    position: absolute;
    right: -4rem;
    bottom: -4rem;
    width: 12rem;
    height: 12rem;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 50%;
}

.safety-card h2,
.safety-card .eyebrow,
.safety-card p,
.safety-card li {
    position: relative;
    z-index: 1;
}

.safety-card h2 {
    color: #fff;
    font-family: Georgia, "Times New Roman", serif;
    font-weight: 400;
}

.safety-card .eyebrow {
    color: #d4bd98;
}

.safety-mark {
    width: 3.1rem;
    height: 3.1rem;
    margin-bottom: 1rem;
    display: grid;
    place-items: center;
    background: rgba(119, 167, 77, 0.16);
    border: 1px solid rgba(119, 167, 77, 0.25);
    border-radius: 50%;
}

.safety-mark svg {
    width: 1.6rem;
    height: 1.6rem;
    fill: #84af61;
}

.check-list {
    margin: 1.4rem 0;
    padding: 0;
    display: grid;
    gap: 0.7rem;
    list-style: none;
}

.check-list li {
    color: #e3ddd5;
    font-size: 0.8rem;
}

.check-list li::before {
    content: "✓";
    margin-right: 0.6rem;
    color: #87ad65;
    font-weight: 900;
}

.small-note {
    margin: 0;
    color: #aaa097;
    font-size: 0.72rem;
}

.empty-inline {
    min-height: 13rem;
    display: grid;
    place-items: center;
    align-content: center;
    color: var(--muted);
}

.empty-inline span {
    font-size: 2rem;
    opacity: 0.4;
}

/* Mail archive */
.table-responsive {
    width: 100%;
    overflow-x: auto;
}

.mail-table {
    width: 100%;
    border-collapse: collapse;
}

.mail-table th {
    padding: 1rem 0.75rem 0.75rem;
    color: #8a8178;
    border-bottom: 1px solid #e9e3dc;
    font-size: 0.67rem;
    font-weight: 850;
    letter-spacing: 0.08em;
    text-align: left;
    text-transform: uppercase;
}

.mail-table td {
    padding: 0.9rem 0.75rem;
    color: #4f4944;
    border-bottom: 1px solid #f0ece6;
    font-size: 0.78rem;
    vertical-align: middle;
}

.mail-table tbody tr:hover {
    background: #fcfaf7;
}

.mail-table tbody tr:last-child td {
    border-bottom: 0;
}

.mail-subject,
.mail-sender {
    max-width: 38rem;
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mail-subject {
    color: var(--ink);
    font-size: 0.86rem;
    font-weight: 800;
    text-decoration: none;
}

.mail-subject:hover {
    color: var(--wine);
}

.mail-sender {
    margin-top: 0.15rem;
    color: var(--muted);
    font-size: 0.72rem;
}

.mail-date,
.mail-size {
    white-space: nowrap;
}

.empty-state {
    min-height: 24rem;
    padding: 3rem;
    display: grid;
    place-items: center;
    align-content: center;
    text-align: center;
}

.empty-state p {
    max-width: 30rem;
    color: var(--muted);
}

.empty-icon {
    width: 4rem;
    height: 4rem;
    margin-bottom: 1rem;
    display: grid;
    place-items: center;
    color: var(--wine);
    background: var(--wine-soft);
    border-radius: 50%;
    font-family: Georgia, "Times New Roman", serif;
    font-size: 1.25rem;
}

/* Mail details */
.back-link {
    display: inline-block;
    margin-bottom: 0.7rem;
    color: var(--wine);
    font-size: 0.78rem;
    font-weight: 800;
    text-decoration: none;
}

.mail-detail-heading h1 {
    max-width: 55rem;
    font-size: clamp(1.8rem, 4vw, 2.7rem);
}

.mail-detail-grid {
    display: grid;
    grid-template-columns: minmax(15rem, 0.55fr) minmax(0, 1.45fr);
    gap: 1.25rem;
    align-items: start;
}

.mail-metadata dl {
    margin: 0;
}

.mail-metadata dt {
    margin-top: 1rem;
    color: #8d847b;
    font-size: 0.65rem;
    font-weight: 850;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.mail-metadata dd {
    margin: 0.2rem 0 0;
    overflow-wrap: anywhere;
    color: #48423d;
    font-size: 0.78rem;
}

.mail-content-card {
    min-width: 0;
}

.safety-label {
    padding: 0.4rem 0.65rem;
    color: #596f48;
    background: #f0f5eb;
    font-size: 0.66rem;
    font-weight: 750;
}

.mail-body {
    min-height: 18rem;
    padding: 1.5rem 0.25rem;
    overflow-wrap: anywhere;
    color: #393531;
    font-family: "Segoe UI", Arial, sans-serif;
    font-size: 0.88rem;
    line-height: 1.65;
    white-space: pre-wrap;
}

.safe-html-notice {
    margin-top: 1.5rem;
    padding: 1.2rem;
    color: #674f26;
    background: #fbf5e8;
    border: 1px solid #ead8b1;
    border-radius: 0.65rem;
}

.safe-html-notice p {
    margin: 0.3rem 0 0;
    font-size: 0.8rem;
}

code {
    color: #6c233b;
    background: #f2ecee;
    border-radius: 0.25rem;
}

.valid.modified:not([type=checkbox]) {
    outline: 1px solid #5f873f;
}

.invalid {
    outline: 1px solid #b4234c;
}

.validation-message {
    color: #b4234c;
}

.blazor-error-boundary {
    padding: 1rem;
    color: #fff;
    background: #8b1e41;
    border-radius: 0.5rem;
}

/* Mail folders and pagination */
.mail-browser-grid {
    display: grid;
    grid-template-columns: minmax(15rem, 0.42fr) minmax(0, 1.58fr);
    gap: 1.25rem;
    align-items: start;
}

.folder-tree-card {
    position: sticky;
    top: 1rem;
    overflow: hidden;
}

.folder-tree-header {
    padding: 1.25rem 1.15rem 0.9rem;
    border-bottom: 1px solid #eee9e2;
}

.folder-tree-header h2 {
    margin: 0;
    font-family: Georgia, "Times New Roman", serif;
    font-weight: 400;
}

.folder-tree {
    padding: 0.55rem;
    display: grid;
}

.folder-tree-link {
    --folder-depth: 0;
    min-width: 0;
    min-height: 2.65rem;
    padding: 0.48rem 0.65rem 0.48rem calc(0.65rem + var(--folder-depth) * 1rem);
    display: grid;
    grid-template-columns: auto auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.55rem;
    color: #4e4944;
    border-radius: 0.45rem;
    font-size: 0.76rem;
    text-decoration: none;
    transition: color 150ms ease, background-color 150ms ease;
}

.folder-tree-link:hover {
    color: var(--wine);
    background: #faf6f4;
}

.folder-tree-link.selected {
    color: #fff;
    background: linear-gradient(135deg, var(--wine), #9c2a50);
}

.folder-tree-link.selected:hover {
    color: #fff;
}

.tree-branch {
    width: 0.5rem;
    height: 0.7rem;
    border-bottom: 1px solid #c9c1b7;
    border-left: 1px solid #c9c1b7;
    opacity: calc(var(--folder-depth));
}

.folder-tree-link.selected .tree-branch {
    border-color: rgba(255, 255, 255, 0.5);
}

.folder-icon {
    width: 1.15rem;
    color: #9a7145;
    font-size: 1.05rem;
    line-height: 1;
    text-align: center;
}

.folder-tree-link.selected .folder-icon {
    color: #f2dcb6;
}

.folder-name {
    overflow: hidden;
    font-weight: 750;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.folder-count {
    min-width: 1.55rem;
    padding: 0.1rem 0.35rem;
    color: #827970;
    background: #f0ece6;
    border-radius: 999px;
    font-size: 0.62rem;
    font-variant-numeric: tabular-nums;
    text-align: center;
}

.folder-tree-link.selected .folder-count {
    color: #fff;
    background: rgba(255, 255, 255, 0.18);
}

.mail-list-header {
    padding-right: 0.15rem;
    padding-left: 0.15rem;
}

.sortable-heading,
.orders-table th a {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    color: inherit;
    text-decoration: none;
}

.sortable-heading:hover,
.orders-table th a:hover {
    color: var(--wine);
}

.mail-order-link {
    margin-top: 0.35rem;
    display: inline-flex;
    padding: 0.18rem 0.45rem;
    color: #5b743f;
    background: #edf4e8;
    border-radius: 999px;
    font-size: 0.62rem;
    font-weight: 800;
    text-decoration: none;
}

.mail-order-link:hover {
    color: #3f5828;
    background: #e2edd9;
}

.mail-folder-empty {
    min-height: 22rem;
}

.empty-folder-symbol {
    display: block;
    color: #b69d79;
    font-size: 2.3rem;
}

.mail-folder-empty h3 {
    margin: 0.5rem 0 0.3rem;
    font-family: Georgia, "Times New Roman", serif;
    font-weight: 400;
}

.pagination-bar {
    padding: 1.15rem 0.15rem 0;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 1rem;
    border-top: 1px solid #eee9e2;
}

.pagination-link,
.pagination-number {
    min-height: 2.2rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #5b554f;
    border: 1px solid #ddd6ce;
    border-radius: 0.4rem;
    background: #fff;
    font-size: 0.72rem;
    font-weight: 800;
    text-decoration: none;
}

.pagination-link {
    padding: 0.45rem 0.7rem;
}

.pagination-link:first-child {
    justify-self: start;
}

.pagination-link:last-child {
    justify-self: end;
}

.pagination-link:hover,
.pagination-number:hover {
    color: var(--wine);
    border-color: #bc92a2;
}

.pagination-link.disabled {
    color: #aaa39b;
    background: #f5f2ee;
    pointer-events: none;
}

.pagination-pages {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.pagination-number {
    width: 2.2rem;
}

.pagination-number.current {
    color: #fff;
    background: var(--wine);
    border-color: var(--wine);
}

.pagination-gap {
    width: 1.2rem;
    color: #928a81;
    text-align: center;
}

.mail-detail-actions {
    display: flex;
    align-items: center;
    gap: 0.7rem;
}

.mail-search-form,
.order-lookup-form {
    margin-bottom: 1.25rem;
    padding: 0.7rem;
    display: flex;
    align-items: center;
    gap: 0.65rem;
    background: #fff;
    border: 1px solid rgba(117, 104, 91, 0.14);
    border-radius: 0.7rem;
    box-shadow: 0 10px 32px rgba(50, 39, 31, 0.06);
}

.mail-search-icon {
    width: 1.8rem;
    color: var(--wine);
    font-size: 1.35rem;
    text-align: center;
}

.mail-search-form input[type="search"] {
    min-width: 0;
    flex: 1;
    padding: 0.55rem 0.2rem;
    color: var(--ink);
    background: transparent;
    border: 0;
    outline: 0;
}

.mail-search-clear {
    color: var(--muted);
    font-size: 0.7rem;
    font-weight: 800;
}

.mail-search-form .button {
    min-height: 2.55rem;
    padding: 0.55rem 0.9rem;
}

.order-lookup-form {
    align-items: flex-start;
    flex-direction: column;
}

.order-lookup-form > label {
    color: #514a44;
    font-size: 0.68rem;
    font-weight: 850;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.order-lookup-form > div {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.order-lookup-form > div > span {
    color: var(--wine);
    font-family: Georgia, "Times New Roman", serif;
    font-size: 1.3rem;
}

.order-lookup-form input {
    min-width: 0;
    flex: 1;
    padding: 0.65rem 0.75rem;
    border: 1px solid #d9d1c8;
    border-radius: 0.45rem;
    outline: none;
}

.order-lookup-form input:focus {
    border-color: var(--wine);
    box-shadow: 0 0 0 4px rgba(135, 33, 63, 0.09);
}

.order-lookup-form > small {
    color: #a02649;
    font-size: 0.68rem;
}

.compact-button {
    min-height: 2.35rem;
    padding: 0.48rem 0.8rem;
    font-size: 0.72rem;
}

/* Orders */
.analysis-progress {
    position: relative;
    margin-bottom: 1.25rem;
    padding: 1.35rem 1.4rem 1.6rem;
    overflow: hidden;
}

.analysis-progress-copy {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.analysis-icon {
    width: 3.25rem;
    height: 3.25rem;
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    color: var(--wine);
    background: var(--wine-soft);
    border-radius: 50%;
    font-size: 1.4rem;
}

.analysis-progress-copy h2 {
    margin: 0;
    font-family: Georgia, "Times New Roman", serif;
    font-weight: 400;
}

.analysis-progress-copy p {
    margin: 0.25rem 0 0;
    color: var(--muted);
    font-size: 0.76rem;
}

.analysis-progress-numbers {
    position: absolute;
    top: 1.35rem;
    right: 1.4rem;
    display: flex;
    gap: 1.5rem;
}

.analysis-progress-numbers div {
    display: flex;
    flex-direction: column;
    text-align: right;
}

.analysis-progress-numbers strong {
    font-family: Georgia, "Times New Roman", serif;
    font-size: 1.35rem;
    font-weight: 400;
}

.analysis-progress-numbers span {
    color: var(--muted);
    font-size: 0.62rem;
}

.analysis-progress-track {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    height: 4px;
    overflow: hidden;
    background: #eee9e3;
}

.analysis-progress-track span {
    height: 100%;
    display: block;
    background: linear-gradient(90deg, var(--wine), #b13c60);
    transition: width 300ms ease;
}

.order-list-card {
    padding: 1.35rem;
}

.orders-table {
    width: 100%;
    border-collapse: collapse;
}

.orders-table th {
    padding: 1rem 0.7rem 0.7rem;
    color: #8a8178;
    border-bottom: 1px solid #e9e3dc;
    font-size: 0.63rem;
    font-weight: 850;
    letter-spacing: 0.07em;
    text-align: left;
    text-transform: uppercase;
    white-space: nowrap;
}

.orders-table td {
    padding: 0.85rem 0.7rem;
    color: #4f4944;
    border-bottom: 1px solid #f0ece6;
    font-size: 0.75rem;
    vertical-align: middle;
}

.orders-table tbody tr:hover {
    background: #fcfaf7;
}

.orders-table tbody tr:last-child td {
    border-bottom: 0;
}

.order-number-link {
    color: var(--wine);
    font-size: 0.82rem;
    font-weight: 850;
    text-decoration: none;
    white-space: nowrap;
}

.order-customer,
.orders-table td span {
    max-width: 18rem;
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.order-customer + span {
    margin-top: 0.12rem;
    color: var(--muted);
    font-size: 0.68rem;
}

.order-total {
    font-weight: 850;
    white-space: nowrap;
}

.order-status {
    padding: 0.22rem 0.5rem;
    display: inline-flex !important;
    color: #4f6e36;
    background: #edf4e8;
    border-radius: 999px;
    font-size: 0.64rem;
    font-weight: 800;
}

.source-count {
    width: 1.75rem;
    height: 1.75rem;
    display: grid !important;
    place-items: center;
    color: #655d55;
    background: #f0ece6;
    border-radius: 50%;
    font-weight: 850;
}

.order-detail-heading {
    align-items: center;
}

.order-detail-total {
    min-width: 12rem;
    padding: 0.85rem 1.1rem;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    background: #fff;
    border: 1px solid rgba(117, 104, 91, 0.14);
    border-radius: 0.7rem;
    box-shadow: var(--shadow);
}

.order-detail-total span,
.order-detail-total small {
    color: var(--muted);
    font-size: 0.64rem;
    font-weight: 750;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.order-detail-total strong {
    margin: 0.15rem 0;
    font-family: Georgia, "Times New Roman", serif;
    font-size: 1.45rem;
    font-weight: 400;
}

.order-detail-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.55fr) minmax(17rem, 0.55fr);
    gap: 1.25rem;
    align-items: start;
}

.order-detail-main,
.order-detail-side {
    min-width: 0;
    display: grid;
    gap: 1.25rem;
}

.order-lines-card,
.order-sources-card,
.order-info-card,
.token-audit-card {
    padding: 1.35rem;
}

.order-lines-list {
    display: grid;
}

.order-line-row {
    min-width: 0;
    padding: 1rem 0;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.9rem;
    border-bottom: 1px solid #eee9e2;
}

.order-line-position {
    width: 1.85rem;
    height: 1.85rem;
    display: grid;
    place-items: center;
    color: #8b7253;
    background: #f6f0e7;
    border-radius: 50%;
    font-size: 0.68rem;
    font-weight: 850;
}

.order-adjustment-row {
    color: #6f203b;
    background: linear-gradient(90deg, transparent, #fcf4f6, transparent);
}

.order-adjustment-row .order-line-position {
    color: #8b2142;
    background: #f8e8ee;
}

.order-adjustment-row .order-line-prices strong {
    color: #8b2142;
}

.order-line-product {
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.order-line-product a,
.order-line-product > strong {
    overflow: hidden;
    color: var(--ink);
    font-size: 0.82rem;
    font-weight: 800;
    text-decoration: none;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.order-line-product a:hover {
    color: var(--wine);
}

.order-line-product small,
.order-line-prices small {
    color: var(--muted);
    font-size: 0.67rem;
}

.order-line-prices {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    white-space: nowrap;
}

.order-line-prices del {
    color: #9a9188;
    font-size: 0.68rem;
}

.order-line-prices > strong {
    font-size: 0.84rem;
}

.order-totals {
    width: min(100%, 24rem);
    margin: 1rem 0 0 auto;
    display: grid;
}

.order-totals div {
    padding: 0.45rem 0;
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    color: #5d5650;
    font-size: 0.74rem;
}

.order-totals dt {
    font-weight: 650;
}

.order-totals dd {
    margin: 0;
    font-weight: 800;
}

.order-totals .order-total-row {
    margin-top: 0.3rem;
    padding-top: 0.75rem;
    color: var(--ink);
    border-top: 2px solid var(--ink);
    font-size: 0.9rem;
}

.order-source-list {
    display: grid;
}

.order-source-row {
    min-width: 0;
    padding: 0.8rem 0;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.7rem;
    color: var(--ink);
    border-bottom: 1px solid #eee9e2;
    text-decoration: none;
}

.order-source-row:last-child {
    border-bottom: 0;
}

.source-state {
    width: 1.65rem;
    height: 1.65rem;
    display: grid;
    place-items: center;
    color: #7a726a;
    background: #f0ece7;
    border-radius: 50%;
    font-size: 0.68rem;
    font-weight: 900;
}

.source-state.canonical {
    color: #4e7130;
    background: #eaf3e3;
}

.source-copy {
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.source-copy strong,
.source-copy small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.source-copy strong {
    font-size: 0.75rem;
}

.source-copy small,
.source-confidence {
    color: var(--muted);
    font-size: 0.65rem;
}

.order-info-card h2 {
    font-family: Georgia, "Times New Roman", serif;
    font-weight: 400;
}

.order-info-card address {
    margin: 0;
    display: flex;
    flex-direction: column;
    color: #514b45;
    font-size: 0.76rem;
    font-style: normal;
}

.order-info-card address a {
    margin-top: 0.45rem;
    overflow-wrap: anywhere;
    font-weight: 750;
    text-decoration: none;
}

.delivery-note {
    margin-top: 1rem;
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    color: #5e4c2b;
    background: #faf4e8;
    border-radius: 0.5rem;
    font-size: 0.72rem;
}

.order-definition-list {
    margin: 0;
    display: grid;
}

.order-definition-list div {
    padding: 0.55rem 0;
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    border-bottom: 1px solid #eee9e2;
    font-size: 0.69rem;
}

.order-definition-list div:last-child {
    border-bottom: 0;
}

.order-definition-list dt {
    color: var(--muted);
    font-weight: 650;
}

.order-definition-list dd {
    margin: 0;
    max-width: 65%;
    overflow-wrap: anywhere;
    font-weight: 800;
    text-align: right;
}

.token-audit-card {
    color: #e8e1d8;
    background: linear-gradient(150deg, #191614, #302428);
    border-color: transparent;
}

.token-audit-card h2 {
    color: #fff;
    font-family: Georgia, "Times New Roman", serif;
    font-weight: 400;
}

.token-audit-card .eyebrow {
    color: #d2b88f;
}

.token-audit-card .order-definition-list div {
    border-color: rgba(255, 255, 255, 0.09);
}

.token-audit-card .order-definition-list dt,
.token-audit-card p {
    color: #afa69e;
}

.token-audit-card p {
    margin: 0.8rem 0 0;
    font-size: 0.67rem;
}

/* Order handling and draft-only forwarding */
.handling-filter {
    margin-bottom: 1.25rem;
    padding: 0.4rem;
    display: inline-flex;
    gap: 0.3rem;
    background: #e9e4dc;
    border-radius: 0.6rem;
}

.handling-filter a {
    min-height: 2.35rem;
    padding: 0.45rem 0.8rem;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: #625b54;
    border-radius: 0.4rem;
    font-size: 0.72rem;
    font-weight: 800;
    text-decoration: none;
}

.handling-filter a:hover {
    color: var(--wine);
    background: rgba(255, 255, 255, 0.58);
}

.handling-filter a.selected {
    color: var(--ink);
    background: #fff;
    box-shadow: 0 3px 12px rgba(56, 43, 35, 0.08);
}

.handling-filter a span {
    min-width: 1.45rem;
    padding: 0.1rem 0.35rem;
    color: #827970;
    background: #eeeae5;
    border-radius: 999px;
    font-size: 0.6rem;
    text-align: center;
}

.handling-status {
    padding: 0.22rem 0.48rem;
    display: inline-flex !important;
    border-radius: 999px;
    font-size: 0.62rem;
    font-weight: 850;
}

.handling-status.handled {
    color: #4b6e31;
    background: #eaf3e3;
}

.handling-status.pending {
    color: #76582d;
    background: #faf1df;
}

.handling-status.local {
    color: #285d68;
    background: #e5f1f3;
}

.handling-status.attention {
    color: #8b2142;
    background: #f9e9ee;
}

.handling-date {
    margin-top: 0.2rem;
    display: block;
    color: var(--muted);
    font-size: 0.6rem;
    white-space: nowrap;
}

.order-heading-actions {
    display: flex;
    align-items: stretch;
    gap: 0.75rem;
}

.philipson-button {
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
}

.philipson-button small {
    color: rgba(255, 255, 255, 0.76);
    font-size: 0.58rem;
    font-weight: 600;
    letter-spacing: 0;
}

.handled-banner,
.pending-handoff-banner,
.sending-lock-banner {
    margin-bottom: 1.25rem;
    padding: 1rem 1.15rem;
    display: flex;
    align-items: center;
    gap: 0.85rem;
    border: 1px solid;
    border-radius: 0.7rem;
}

.handled-banner {
    color: #405c2d;
    background: linear-gradient(90deg, #ebf4e5, #f8faf5);
    border-color: #d2e4c5;
}

.handled-check,
.sending-lock-icon {
    width: 2.2rem;
    height: 2.2rem;
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    border-radius: 50%;
    font-weight: 900;
}

.handled-check {
    color: #fff;
    background: #648e43;
}

.handled-banner > div,
.pending-handoff-banner > div,
.sending-lock-banner > div {
    min-width: 0;
    display: flex;
    flex: 1;
    flex-direction: column;
}

.handled-banner span,
.pending-handoff-banner small,
.sending-lock-banner p {
    margin: 0;
    font-size: 0.72rem;
}

.handled-banner > a {
    color: #49662f;
    font-size: 0.7rem;
    font-weight: 850;
    white-space: nowrap;
}

.pending-handoff-banner {
    color: #6e5227;
    background: #fcf5e7;
    border-color: #ead7ad;
}

.local-handled-banner,
.smtp-attention-banner {
    margin-bottom: 1.25rem;
    padding: 1rem 1.15rem;
    display: flex;
    align-items: center;
    gap: 0.85rem;
    border: 1px solid;
    border-radius: 0.7rem;
}

.local-handled-banner {
    color: #285965;
    background: linear-gradient(90deg, #e7f2f4, #f7fafb);
    border-color: #c8e0e4;
}

.local-handled-icon {
    width: 2.2rem;
    height: 2.2rem;
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    color: #fff;
    background: #397685;
    border-radius: 50%;
    font-weight: 900;
}

.local-handled-banner > div,
.smtp-attention-banner > div {
    display: flex;
    flex-direction: column;
}

.local-handled-banner span,
.local-handled-banner small,
.smtp-attention-banner small {
    font-size: 0.7rem;
}

.smtp-attention-banner {
    color: #77213e;
    background: #f9e9ee;
    border-color: #e9c6d1;
}

.smtp-attention-banner > span:first-child {
    width: 2.2rem;
    height: 2.2rem;
    display: grid;
    place-items: center;
    color: #fff;
    background: #92284a;
    border-radius: 50%;
    font-weight: 900;
}

.local-handling-card {
    padding: 1.35rem;
}

.local-handling-card h2 {
    font-family: Georgia, "Times New Roman", serif;
    font-weight: 400;
}

.local-handling-card p {
    color: var(--muted);
    font-size: 0.73rem;
}

.local-handling-card label {
    display: block;
    margin-bottom: 0.3rem;
    font-size: 0.68rem;
    font-weight: 850;
}

.local-handling-card textarea {
    width: 100%;
    margin-bottom: 0.7rem;
    padding: 0.65rem;
    border: 1px solid #d9d1c8;
    border-radius: 0.45rem;
    resize: vertical;
}

.local-action-message {
    margin-top: 0.65rem;
    display: block;
    color: #496635;
    font-size: 0.68rem;
    font-weight: 800;
}

.pending-handoff-banner > span:first-child {
    width: 2.2rem;
    height: 2.2rem;
    display: grid;
    place-items: center;
    color: #84622d;
    background: #f3e5c6;
    border-radius: 50%;
    font-weight: 900;
}

.forward-draft-heading {
    align-items: center;
}

.draft-only-badge {
    padding: 0.48rem 0.75rem;
    color: #7c203f;
    background: #f8e9ee;
    border: 1px solid #ebcad5;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 850;
    letter-spacing: 0.04em;
    white-space: nowrap;
}

.alert-success {
    color: #3f6328;
    background: #ebf4e5;
    border-color: #cee1bf;
}

.sending-lock-banner {
    color: #6d263d;
    background: #fbecf1;
    border-color: #edc8d4;
}

.sending-lock-icon {
    color: #fff;
    background: #8b2142;
    font-size: 1.15rem;
}

.forward-draft-grid {
    display: grid;
    grid-template-columns: minmax(22rem, 0.85fr) minmax(0, 1.15fr);
    gap: 1.25rem;
    align-items: start;
}

.draft-editor-card,
.forward-preview-card {
    padding: 1.35rem;
}

.draft-saved-message {
    margin-top: 1rem;
    padding: 0.65rem 0.75rem;
    color: #47652f;
    background: #ebf4e5;
    border-radius: 0.45rem;
    font-size: 0.72rem;
    font-weight: 800;
}

.draft-form {
    margin-top: 1rem;
    display: grid;
    gap: 1rem;
}

.draft-field-grid {
    display: grid;
    grid-template-columns: 0.75fr 1.25fr;
    gap: 0.8rem;
}

.draft-field {
    min-width: 0;
    display: grid;
    gap: 0.35rem;
}

.draft-field label {
    color: #4c4640;
    font-size: 0.69rem;
    font-weight: 850;
    letter-spacing: 0.04em;
}

.draft-field input,
.draft-field textarea {
    width: 100%;
    padding: 0.7rem 0.8rem;
    color: var(--ink);
    background: #fbfaf8;
    border: 1px solid #d9d1c8;
    border-radius: 0.45rem;
    outline: none;
}

.draft-field textarea {
    min-height: 15rem;
    line-height: 1.55;
    resize: vertical;
}

.draft-field input:focus,
.draft-field textarea:focus {
    background: #fff;
    border-color: var(--wine);
    box-shadow: 0 0 0 4px rgba(135, 33, 63, 0.09);
}

.draft-field > small {
    color: var(--muted);
    font-size: 0.64rem;
}

.draft-field .validation-message {
    font-size: 0.65rem;
}

.draft-actions {
    padding-top: 1rem;
    display: flex;
    align-items: center;
    gap: 0.65rem;
    border-top: 1px solid #eee9e2;
}

.draft-actions > span {
    margin-left: auto;
    color: #8b2142;
    font-size: 0.65rem;
    font-weight: 850;
}

.manual-send-panel {
    margin-top: 1.2rem;
    padding-top: 1.2rem;
    border-top: 1px solid #ded7cf;
}

.manual-send-panel h3 {
    font-family: Georgia, "Times New Roman", serif;
    font-size: 1.25rem;
    font-weight: 400;
}

.button-danger {
    color: #fff;
    background: #8b2142;
    border-color: #8b2142;
    box-shadow: 0 8px 20px rgba(139, 33, 66, 0.18);
}

.button-danger:hover {
    color: #fff;
    background: #6f1734;
}

.button-danger:disabled {
    cursor: not-allowed;
    opacity: 0.5;
    transform: none;
}

.send-blocked-message {
    padding: 0.8rem;
    display: flex;
    flex-direction: column;
    color: #6f263d;
    background: #faedf1;
    border: 1px solid #edccd6;
    border-radius: 0.5rem;
    font-size: 0.72rem;
}

.send-confirmation-panel {
    padding: 1rem;
    color: #4e272f;
    background: #fcf4f5;
    border: 1px solid #e8c7d1;
    border-radius: 0.55rem;
}

.send-confirmation-panel p {
    font-size: 0.73rem;
}

.send-confirmation-panel > label:not(.danger-confirmation-check) {
    display: block;
    margin-bottom: 0.3rem;
    font-size: 0.67rem;
    font-weight: 850;
}

.send-confirmation-panel > input {
    width: 100%;
    padding: 0.65rem;
    border: 1px solid #d5aab8;
    border-radius: 0.4rem;
}

.danger-confirmation-check {
    margin: 0.8rem 0;
    display: flex;
    align-items: flex-start;
    gap: 0.55rem;
    font-size: 0.7rem;
    font-weight: 750;
}

.danger-confirmation-check input {
    margin-top: 0.15rem;
}

.send-confirmation-actions {
    display: flex;
    gap: 0.55rem;
}

/* Generic composer */
.compose-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.45fr) minmax(18rem, 0.55fr);
    gap: 1.25rem;
    align-items: start;
}

.compose-editor-card,
.compose-send-card {
    padding: 1.35rem;
}

.compose-send-card {
    position: sticky;
    top: 1rem;
}

.compose-send-card h2 {
    font-family: Georgia, "Times New Roman", serif;
    font-weight: 400;
}

.compose-send-card > p {
    color: var(--muted);
    font-size: 0.74rem;
}

.smtp-facts {
    margin-top: 1.1rem;
    padding-top: 0.8rem;
    display: grid;
    gap: 0.35rem;
    color: var(--muted);
    border-top: 1px solid #eee9e2;
    font-size: 0.64rem;
}

.smtp-facts span::before {
    content: "✓";
    margin-right: 0.4rem;
    color: var(--leaf);
    font-weight: 900;
}

/* Revenue */
.revenue-year-selector {
    margin-bottom: 1.25rem;
    display: flex;
    gap: 0.4rem;
}

.revenue-year-selector a {
    min-width: 4.2rem;
    padding: 0.45rem 0.7rem;
    color: #655e57;
    background: #e9e4dc;
    border-radius: 0.4rem;
    font-size: 0.72rem;
    font-weight: 850;
    text-align: center;
    text-decoration: none;
}

.revenue-year-selector a.selected {
    color: #fff;
    background: var(--wine);
}

.revenue-summary-grid {
    margin-bottom: 1.25rem;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1rem;
}

.revenue-summary-card {
    min-width: 0;
    padding: 1.15rem;
    display: flex;
    flex-direction: column;
}

.revenue-summary-card.primary {
    color: #fff;
    background: linear-gradient(145deg, #6f1734, #98294d);
    border-color: transparent;
}

.revenue-summary-card > span {
    color: var(--muted);
    font-size: 0.65rem;
    font-weight: 850;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.revenue-summary-card.primary > span,
.revenue-summary-card.primary small {
    color: rgba(255, 255, 255, 0.72);
}

.revenue-summary-card strong {
    margin: 0.3rem 0 0.15rem;
    overflow: hidden;
    color: inherit;
    font-family: Georgia, "Times New Roman", serif;
    font-size: clamp(1.3rem, 2.5vw, 1.75rem);
    font-weight: 400;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.revenue-summary-card small {
    color: var(--muted);
    font-size: 0.63rem;
}

.revenue-chart-card,
.revenue-table-card {
    margin-bottom: 1.25rem;
    padding: 1.35rem;
}

.revenue-chart-shell {
    position: relative;
    width: 100%;
    height: clamp(22rem, 42vw, 30rem);
    margin-top: 1rem;
    padding: 0.25rem 0.15rem 0;
}

.revenue-chart-shell canvas {
    width: 100% !important;
    height: 100% !important;
}

.revenue-table {
    width: 100%;
    border-collapse: collapse;
}

.revenue-table th,
.revenue-table td {
    padding: 0.7rem;
    border-bottom: 1px solid #eee9e2;
    font-size: 0.72rem;
    text-align: right;
    white-space: nowrap;
}

.revenue-table th:first-child,
.revenue-table td:first-child {
    text-align: left;
}

.revenue-table thead th {
    color: #887f76;
    font-size: 0.61rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.revenue-table tfoot th {
    color: var(--ink);
    border-top: 2px solid var(--ink);
    border-bottom: 0;
}

.revenue-amount {
    color: var(--wine);
    font-weight: 850;
}

.forward-preview-card {
    position: sticky;
    top: 1rem;
}

.forward-preview-headers {
    margin: 0;
    padding: 0.85rem 0;
    display: grid;
    gap: 0.45rem;
    border-bottom: 1px solid #eee9e2;
}

.forward-preview-headers div {
    display: grid;
    grid-template-columns: 3.2rem minmax(0, 1fr);
    gap: 0.6rem;
    font-size: 0.7rem;
}

.forward-preview-headers dt {
    color: var(--muted);
    font-weight: 700;
}

.forward-preview-headers dd {
    margin: 0;
    overflow-wrap: anywhere;
    font-weight: 750;
}

.forward-preview-body {
    max-height: 48rem;
    padding: 1rem 0.15rem;
    overflow: auto;
}

.forward-preview-body pre {
    margin: 0;
    color: #39342f;
    font-family: "Segoe UI", Arial, sans-serif;
    font-size: 0.72rem;
    line-height: 1.55;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.forward-preview-body pre.forward-original {
    margin-top: 1.2rem;
    padding-top: 1.2rem;
    color: #665f58;
    border-top: 1px solid #dcd5cd;
}

/* Operations */
.operations-actions {
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.live-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    color: #4f6c38;
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.035em;
    white-space: nowrap;
}

.live-pulse {
    position: relative;
    width: 0.55rem;
    height: 0.55rem;
    display: inline-block;
    background: #6e9c4a;
    border-radius: 50%;
}

.live-pulse::after {
    content: "";
    position: absolute;
    inset: -0.35rem;
    border: 1px solid #6e9c4a;
    border-radius: 50%;
    animation: live-pulse 1.8s ease-out infinite;
}

@keyframes live-pulse {
    0% { opacity: 0.8; transform: scale(0.45); }
    80%, 100% { opacity: 0; transform: scale(1.25); }
}

.refresh-button {
    min-height: 2.65rem;
    padding: 0.55rem 0.9rem;
}

.refresh-button:disabled {
    cursor: wait;
    opacity: 0.65;
}

.refresh-symbol {
    display: inline-block;
    font-size: 1rem;
}

.refresh-symbol.rotating {
    animation: spin 0.8s linear infinite;
}

.job-focus-card {
    position: relative;
    margin-bottom: 1.25rem;
    overflow: hidden;
    border-left: 5px solid #8b8178;
}

.job-focus-card.status-running { border-left-color: #2f7792; }
.job-focus-card.status-succeeded { border-left-color: var(--leaf); }
.job-focus-card.status-waiting { border-left-color: var(--gold); }
.job-focus-card.status-warning { border-left-color: #c77b24; }
.job-focus-card.status-failed { border-left-color: #ac2a4e; }
.job-focus-card.status-cancelled { border-left-color: #817970; }

.job-focus-main {
    padding: 1.5rem;
    display: flex;
    align-items: flex-start;
    gap: 1.1rem;
}

.job-state-icon {
    width: 3.6rem;
    height: 3.6rem;
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    color: #fff;
    background: #766f68;
    border-radius: 50%;
    font-size: 1.45rem;
    font-weight: 850;
}

.status-running .job-state-icon { background: #2f7792; }
.status-succeeded .job-state-icon { background: var(--leaf); }
.status-waiting .job-state-icon { background: var(--gold); }
.status-warning .job-state-icon { background: #c77b24; }
.status-failed .job-state-icon { background: #ac2a4e; }

.job-focus-card.status-running .job-state-icon {
    animation: spin 2s linear infinite;
}

.job-state-copy {
    min-width: 0;
}

.job-state-copy h2 {
    margin: 0.55rem 0 0.3rem;
    font-family: Georgia, "Times New Roman", serif;
    font-size: clamp(1.35rem, 3vw, 1.9rem);
    font-weight: 400;
}

.job-state-copy p {
    margin: 0;
    color: var(--muted);
    font-size: 0.84rem;
}

.job-state-copy .job-error {
    color: #8c2442;
}

.job-status-pill {
    display: inline-flex;
    align-items: center;
    padding: 0.28rem 0.58rem;
    border: 1px solid;
    border-radius: 999px;
    font-size: 0.65rem;
    font-weight: 850;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    white-space: nowrap;
}

.job-status-pill.compact {
    padding: 0.2rem 0.45rem;
    font-size: 0.59rem;
}

.job-status-pill.status-running { color: #27647b; background: #e9f5f8; border-color: #c5e4eb; }
.job-status-pill.status-succeeded { color: #4e702f; background: #edf5e7; border-color: #d2e4c4; }
.job-status-pill.status-waiting { color: #775a2d; background: #faf3e5; border-color: #e8d5ad; }
.job-status-pill.status-warning { color: #8d5214; background: #fff3e4; border-color: #f0cfaa; }
.job-status-pill.status-failed { color: #8a2141; background: #fbeef2; border-color: #eecbd6; }
.job-status-pill.status-cancelled { color: #625b54; background: #f1efed; border-color: #dcd7d2; }

.activity-track {
    height: 3px;
    overflow: hidden;
    background: #e9f1f3;
}

.activity-track span {
    width: 34%;
    height: 100%;
    display: block;
    background: linear-gradient(90deg, transparent, #3f8aa5, transparent);
    animation: activity-track 1.6s ease-in-out infinite;
}

@keyframes activity-track {
    from { transform: translateX(-110%); }
    to { transform: translateX(310%); }
}

.job-facts {
    padding: 1rem 1.5rem;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1rem;
    background: #fbfaf8;
    border-top: 1px solid #eee9e2;
}

.job-facts > div {
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.job-facts span,
.operation-stat-label {
    color: #8b8279;
    font-size: 0.63rem;
    font-weight: 850;
    letter-spacing: 0.07em;
    text-transform: uppercase;
}

.job-facts strong {
    margin-top: 0.2rem;
    overflow: hidden;
    font-size: 0.78rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.operations-stats {
    margin-bottom: 1.25rem;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1rem;
}

.operation-stat {
    min-width: 0;
    padding: 1.15rem;
    display: flex;
    flex-direction: column;
}

.operation-stat > strong {
    margin: 0.25rem 0 0.1rem;
    overflow: hidden;
    color: var(--ink);
    font-family: Georgia, "Times New Roman", serif;
    font-size: 1.85rem;
    font-weight: 400;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.operation-stat > strong.operation-stat-time {
    font-family: inherit;
    font-size: 1.25rem;
    font-weight: 750;
}

.operation-stat small {
    overflow: hidden;
    color: var(--muted);
    font-size: 0.68rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.operations-grid {
    margin-bottom: 1.25rem;
    display: grid;
    grid-template-columns: minmax(0, 1.7fr) minmax(17rem, 0.65fr);
    gap: 1.25rem;
    align-items: start;
}

.folder-activity-card,
.schedule-card,
.run-history-card {
    padding: 1.35rem;
}

.operation-empty {
    min-height: 12rem;
    display: grid;
    place-items: center;
    color: var(--muted);
    text-align: center;
}

.operation-empty p {
    max-width: 27rem;
    margin: 0;
    font-size: 0.82rem;
}

.folder-run-list {
    display: grid;
}

.folder-run-row {
    min-width: 0;
    padding: 0.9rem 0;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto 4.3rem;
    align-items: center;
    gap: 0.8rem;
    border-bottom: 1px solid #eee9e2;
}

.folder-run-row:last-child {
    border-bottom: 0;
}

.folder-state {
    width: 1.8rem;
    height: 1.8rem;
    display: grid;
    place-items: center;
    border-radius: 50%;
    font-size: 0.78rem;
    font-weight: 900;
}

.folder-state.folder-running { color: #286982; background: #e7f3f6; animation: spin 1.8s linear infinite; }
.folder-state.folder-succeeded { color: #507433; background: #edf5e7; }
.folder-state.folder-failed { color: #8b2141; background: #f9ebef; }

.folder-run-copy {
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.folder-run-copy strong,
.folder-run-copy small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.folder-run-copy strong {
    font-size: 0.8rem;
}

.folder-run-copy small,
.folder-run-row time {
    color: var(--muted);
    font-size: 0.68rem;
}

.folder-run-copy small.folder-error {
    color: #8b2141;
}

.folder-run-numbers {
    display: flex;
    gap: 0.7rem;
    color: var(--muted);
    font-size: 0.68rem;
    white-space: nowrap;
}

.folder-run-numbers strong {
    color: var(--ink);
}

.folder-run-row time {
    text-align: right;
    white-space: nowrap;
}

.schedule-card {
    position: sticky;
    top: 1rem;
    text-align: center;
}

.schedule-card h2 {
    font-family: Georgia, "Times New Roman", serif;
    font-size: 1.75rem;
    font-weight: 400;
}

.schedule-card > p {
    color: var(--muted);
    font-size: 0.78rem;
}

.schedule-clock {
    position: relative;
    width: 5.5rem;
    height: 5.5rem;
    margin: 1.25rem auto;
    border: 2px solid #d7c7a9;
    border-radius: 50%;
    box-shadow: inset 0 0 0 0.45rem #faf6ed;
}

.clock-hand {
    position: absolute;
    bottom: 50%;
    left: calc(50% - 1px);
    width: 2px;
    height: 1.65rem;
    background: var(--wine);
    border-radius: 2px;
    transform-origin: 50% 100%;
    transform: rotate(30deg);
}

.clock-center {
    position: absolute;
    top: calc(50% - 0.2rem);
    left: calc(50% - 0.2rem);
    width: 0.4rem;
    height: 0.4rem;
    background: var(--wine);
    border-radius: 50%;
}

.schedule-card dl {
    margin: 1.25rem 0 0;
    display: grid;
}

.schedule-card dl div {
    padding: 0.55rem 0;
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    border-top: 1px solid #eee8df;
    font-size: 0.7rem;
}

.schedule-card dt {
    color: var(--muted);
    font-weight: 650;
}

.schedule-card dd {
    margin: 0;
    color: var(--ink);
    font-weight: 800;
}

.run-history-table {
    width: 100%;
    border-collapse: collapse;
}

.run-history-table th {
    padding: 1rem 0.7rem 0.7rem;
    color: #8a8178;
    border-bottom: 1px solid #e9e3dc;
    font-size: 0.63rem;
    font-weight: 850;
    letter-spacing: 0.07em;
    text-align: left;
    text-transform: uppercase;
}

.run-history-table td {
    padding: 0.75rem 0.7rem;
    color: #504a45;
    border-bottom: 1px solid #f0ece6;
    font-size: 0.72rem;
    white-space: nowrap;
}

.run-history-table tr:last-child td {
    border-bottom: 0;
}

.run-history-table tr.current-run {
    background: #fbf8f3;
}

.run-history-table td.history-phase {
    max-width: 24rem;
    overflow: hidden;
    text-overflow: ellipsis;
}

@media (max-width: 1050px) {
    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .operations-stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .revenue-summary-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 850px) {
    .login-card {
        grid-template-columns: 1fr;
    }

    .login-story {
        min-height: 20rem;
        padding: 2.5rem;
    }

    .dashboard-grid,
    .mail-detail-grid,
    .mail-browser-grid,
    .order-detail-grid,
    .compose-grid,
    .forward-draft-grid,
    .operations-grid {
        grid-template-columns: 1fr;
    }

    .safety-card,
    .folder-tree-card,
    .compose-send-card,
    .forward-preview-card,
    .schedule-card {
        position: static;
    }

    .folder-tree {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 650px) {
    .page-heading {
        align-items: stretch;
        flex-direction: column;
        gap: 1.15rem;
    }

    .page-heading .button {
        align-self: flex-start;
    }

    .operations-actions {
        align-items: flex-start;
        flex-direction: column;
    }

    .mail-detail-actions {
        align-items: flex-start;
        flex-direction: column;
    }

    .mail-search-form {
        align-items: stretch;
        flex-wrap: wrap;
    }

    .mail-search-form input[type="search"] {
        min-width: calc(100% - 3rem);
    }

    .order-heading-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .handling-filter {
        width: 100%;
        overflow-x: auto;
    }

    .handling-filter a {
        flex: 1 0 auto;
        justify-content: center;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .operations-stats,
    .job-facts {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .sync-banner {
        grid-template-columns: auto 1fr;
    }

    .sync-banner > .read-only-badge {
        display: none;
    }

    .login-page {
        display: block;
    }

    .login-card {
        border-radius: 0.75rem;
    }

    .login-story {
        min-height: 18rem;
        padding: 2rem 1.5rem;
    }

    .login-form-panel {
        padding: 2.2rem 1.5rem;
    }

    .mail-preview {
        grid-template-columns: auto minmax(0, 1fr);
    }

    .mail-preview-meta {
        display: none;
    }

    .mail-table th:nth-child(4),
    .mail-table td:nth-child(4) {
        display: none;
    }

    .mail-table-card,
    .mail-content-card,
    .mail-metadata {
        padding: 1rem;
    }

    .folder-tree {
        grid-template-columns: 1fr;
    }

    .pagination-bar {
        grid-template-columns: auto 1fr auto;
        gap: 0.45rem;
    }

    .pagination-pages {
        justify-content: center;
    }

    .pagination-number {
        width: 2rem;
    }

    .pagination-link {
        overflow: hidden;
        max-width: 5.3rem;
        white-space: nowrap;
    }

    .analysis-progress-copy {
        align-items: flex-start;
    }

    .analysis-progress-numbers {
        position: static;
        margin-top: 1rem;
        justify-content: flex-start;
    }

    .analysis-progress-numbers div {
        text-align: left;
    }

    .orders-table th:nth-child(4),
    .orders-table td:nth-child(4),
    .orders-table th:nth-child(7),
    .orders-table td:nth-child(7),
    .orders-table th:nth-child(8),
    .orders-table td:nth-child(8) {
        display: none;
    }

    .order-list-card,
    .order-lines-card,
    .order-sources-card,
    .order-info-card,
    .token-audit-card {
        padding: 1rem;
    }

    .order-detail-total {
        align-items: flex-start;
    }

    .handled-banner,
    .pending-handoff-banner,
    .sending-lock-banner {
        align-items: flex-start;
    }

    .handled-banner > a {
        display: none;
    }

    .draft-field-grid {
        grid-template-columns: 1fr;
    }

    .draft-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .draft-actions > span {
        margin-left: 0;
    }

    .send-confirmation-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .revenue-summary-grid {
        grid-template-columns: 1fr;
    }

    .revenue-chart-shell {
        min-width: 40rem;
        height: 23rem;
    }

    .revenue-chart-card {
        overflow-x: auto;
    }

    .revenue-table th:nth-child(5),
    .revenue-table td:nth-child(5),
    .revenue-table th:nth-child(6),
    .revenue-table td:nth-child(6),
    .revenue-table th:nth-child(7),
    .revenue-table td:nth-child(7) {
        display: none;
    }

    .order-line-row {
        grid-template-columns: auto minmax(0, 1fr);
    }

    .order-line-prices {
        grid-column: 2;
        align-items: flex-start;
    }

    .safety-label {
        display: none;
    }

    .folder-run-row {
        grid-template-columns: auto minmax(0, 1fr) auto;
    }

    .folder-run-numbers {
        display: none;
    }

    .run-history-table th:nth-child(4),
    .run-history-table td:nth-child(4),
    .run-history-table th:nth-child(6),
    .run-history-table td:nth-child(6) {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
