/* ==========================================================================
   ForgeMail — "Forge console" design system
   Warm paper · graphite ink · ember accent · steel secondary · sharp geometry
   Display: Archivo · Body: IBM Plex Sans · Mono: IBM Plex Mono
   ========================================================================== */

:root {
    --paper: #f5f2ec;
    --paper-2: #ece7dd;
    --surface: #ffffff;
    --surface-sunk: #faf8f4;

    --ink: #1b1714;
    --ink-2: #423b34;
    --muted: #7a7167;
    --muted-2: #9a9087;

    --line: #e5ded2;
    --line-strong: #d3c8b7;

    --ember: #d6481c;
    --ember-deep: #b5380f;
    --ember-soft: rgba(214, 72, 28, .10);
    --steel: #2c4a63;
    --steel-soft: rgba(44, 74, 99, .10);

    --ok: #2f7d52;
    --ok-soft: rgba(47, 125, 82, .12);
    --warn: #a4660f;
    --warn-soft: rgba(164, 102, 15, .14);
    --danger: #b8392b;
    --danger-soft: rgba(184, 57, 43, .12);

    --font-display: 'Archivo', 'IBM Plex Sans', system-ui, sans-serif;
    --font-body: 'IBM Plex Sans', system-ui, -apple-system, sans-serif;
    --font-mono: 'IBM Plex Mono', ui-monospace, monospace;

    --r-xs: 3px;
    --r-sm: 5px;
    --r: 8px;
    --r-lg: 12px;

    --shadow-sm: 0 1px 2px rgba(27, 23, 20, .05);
    --shadow: 0 1px 2px rgba(27, 23, 20, .06), 0 14px 30px -22px rgba(27, 23, 20, .35);
    --shadow-lg: 0 2px 4px rgba(27, 23, 20, .06), 0 30px 60px -30px rgba(27, 23, 20, .4);

    --sidebar-w: 256px;
    --rail-w: 248px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
    margin: 0;
    font-family: var(--font-body);
    font-size: 14px;
    line-height: 1.55;
    color: var(--ink);
    background: var(--paper);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

/* faint blueprint grid behind everything for "console" atmosphere */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    background-image:
        linear-gradient(rgba(27, 23, 20, .018) 1px, transparent 1px),
        linear-gradient(90deg, rgba(27, 23, 20, .018) 1px, transparent 1px);
    background-size: 28px 28px;
}

h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 700; letter-spacing: -.015em; color: var(--ink); margin: 0; }
h1 { font-size: 1.65rem; line-height: 1.15; }
h2 { font-size: 1.12rem; line-height: 1.2; }
h3 { font-size: .95rem; margin: 1.4rem 0 .5rem; }
p { margin: 0 0 .65rem; }
a { color: var(--steel); text-decoration: none; }
a:hover { color: var(--ember-deep); }
code { font-family: var(--font-mono); font-size: .85em; background: var(--surface-sunk); border: 1px solid var(--line); border-radius: var(--r-xs); padding: .05em .35em; color: var(--ink-2); }
::selection { background: var(--ember); color: #fff; }

::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 8px; border: 3px solid var(--paper); }
::-webkit-scrollbar-thumb:hover { background: var(--muted-2); }

.muted { color: var(--muted); font-size: .88rem; }
.text-danger { color: var(--danger); }
.eyebrow {
    font-family: var(--font-mono);
    font-size: .68rem;
    font-weight: 500;
    letter-spacing: .16em;
    text-transform: uppercase;
    color: var(--ember-deep);
}

/* ========================== SHELL ======================================= */

.shell { position: relative; z-index: 1; min-height: 100vh; }
.shell--admin { display: grid; grid-template-columns: var(--sidebar-w) 1fr; }

.sidebar {
    position: sticky;
    top: 0;
    align-self: start;
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: linear-gradient(180deg, #211c18, #191512);
    color: #d9d1c6;
    border-right: 1px solid #000;
    overflow: hidden;
}

.brand {
    display: flex;
    align-items: center;
    gap: .55rem;
    padding: 1.15rem 1.25rem 1rem;
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 1.15rem;
    letter-spacing: -.02em;
    color: #fff;
    border-bottom: 1px solid rgba(255, 255, 255, .07);
}
.brand:hover { color: #fff; }
.brand__spark {
    width: 13px; height: 13px;
    background: var(--ember);
    transform: rotate(45deg);
    box-shadow: 0 0 14px 1px rgba(214, 72, 28, .6);
    flex: none;
}
.brand__tag {
    font-family: var(--font-mono);
    font-size: .6rem;
    letter-spacing: .18em;
    text-transform: uppercase;
    color: var(--ember);
    border: 1px solid rgba(214, 72, 28, .5);
    border-radius: var(--r-xs);
    padding: .1rem .35rem;
    margin-left: auto;
}

.sidenav { flex: 1; overflow-y: auto; padding: .65rem .7rem 1rem; }
.sidenav::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .12); border-color: transparent; }

.sidenav__group { margin-top: 1.1rem; }
.sidenav__label {
    display: block;
    font-family: var(--font-mono);
    font-size: .62rem;
    letter-spacing: .18em;
    text-transform: uppercase;
    color: #8a7f72;
    padding: 0 .65rem .3rem;
}
.sidenav__item {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .42rem .65rem;
    border-radius: var(--r-sm);
    color: #c7beb1;
    font-size: .86rem;
    font-weight: 500;
    line-height: 1.2;
    position: relative;
    transition: background .12s, color .12s;
}
.sidenav__item:hover { background: rgba(255, 255, 255, .05); color: #fff; }
.sidenav__item.active { background: rgba(214, 72, 28, .14); color: #fff; }
.sidenav__item.active::before {
    content: "";
    position: absolute;
    left: -.7rem;
    top: 6px; bottom: 6px;
    width: 3px;
    background: var(--ember);
    border-radius: 0 3px 3px 0;
}
.sidenav__glyph { width: 1.1rem; text-align: center; opacity: .85; font-size: .95rem; flex: none; }
.sidenav__item--top { margin: .15rem 0 .2rem; }

.sidebar__foot {
    padding: .8rem 1rem;
    border-top: 1px solid rgba(255, 255, 255, .07);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    font-size: .8rem;
}
.sidebar__foot a { color: #b3a99c; }
.sidebar__foot a:hover { color: #fff; }
.sidebar__foot .link-button { color: #b3a99c; }
.sidebar__foot .link-button:hover { color: var(--ember); }

.main { min-width: 0; display: flex; flex-direction: column; }
.content { padding: 1.6rem clamp(1rem, 3vw, 2.4rem) 3rem; }

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 1rem;
    height: 56px;
    padding: 0 clamp(1rem, 3vw, 2.4rem);
    background: rgba(245, 242, 236, .82);
    backdrop-filter: saturate(1.2) blur(8px);
    border-bottom: 1px solid var(--line);
}
.topbar__title { font-family: var(--font-display); font-weight: 700; font-size: 1rem; }
.topbar__spacer { flex: 1; }
.topbar__account { display: flex; align-items: center; gap: .9rem; font-size: .85rem; color: var(--muted); }
.topbar__account .who { font-weight: 600; color: var(--ink-2); }
.icon-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 34px; height: 34px;
    border: 1px solid var(--line); border-radius: var(--r-sm);
    background: var(--surface); color: var(--ink-2);
    font-size: 1rem; cursor: pointer; transition: border-color .12s, color .12s;
}
.icon-btn:hover { border-color: var(--ember); color: var(--ember); }

.shell--mail { display: flex; flex-direction: column; min-height: 100vh; }
.shell--mail .main--mail { flex: 1; min-height: 0; display: flex; }

.brand-mark {
    display: inline-flex; align-items: center; gap: .5rem;
    font-family: var(--font-display); font-weight: 800; font-size: 1.1rem;
    letter-spacing: -.02em; color: var(--ink);
}
.brand-mark::before {
    content: ""; width: 12px; height: 12px; background: var(--ember);
    transform: rotate(45deg); box-shadow: 0 0 12px rgba(214,72,28,.5);
}
.brand-mark:hover { color: var(--ink); }

.topsearch {
    display: flex; align-items: center; gap: .4rem;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm);
    padding: 0 .55rem; height: 36px; min-width: 200px; max-width: 460px; flex: 1;
}
.topsearch input { border: 0; outline: 0; background: transparent; width: 100%; font: inherit; padding: 0; }
.topsearch input:focus { box-shadow: none; }
.topsearch::before { content: "⌕"; color: var(--muted-2); font-size: 1.1rem; }

/* ========================== PAGE LAYOUT ================================= */

.admin-grid { display: flex; flex-direction: column; gap: 1.1rem; max-width: 1180px; }
.admin-grid-wide { max-width: 1180px; }

.breadcrumb {
    display: none; /* the sidebar handles navigation context now */
}

.section-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: .2rem; }
.section-header h1 { margin: .15rem 0 .25rem; }
.section-header .muted { max-width: 64ch; }

/* ========================== PANELS ===================================== */

.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r);
    padding: 1.25rem 1.35rem;
    box-shadow: var(--shadow-sm);
    animation: rise .42s cubic-bezier(.2, .7, .2, 1) both;
}
.panel > h2 {
    font-size: 1rem;
    padding-bottom: .55rem;
    margin-bottom: .9rem;
    border-bottom: 1px solid var(--line);
    position: relative;
}
.panel > h2::after {
    content: ""; position: absolute; left: 0; bottom: -1px; width: 32px; height: 2px; background: var(--ember);
}
.admin-grid > .panel:nth-child(1) { animation-delay: .02s; }
.admin-grid > .panel:nth-child(2) { animation-delay: .07s; }
.admin-grid > .panel:nth-child(3) { animation-delay: .12s; }
.admin-grid > .panel:nth-child(4) { animation-delay: .17s; }
.admin-grid > .panel:nth-child(5) { animation-delay: .22s; }
.admin-grid > .panel:nth-child(n+6) { animation-delay: .26s; }

@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ========================== BUTTONS ==================================== */

.btn-primary, .btn-secondary {
    font-family: var(--font-body);
    font-size: .85rem;
    font-weight: 600;
    letter-spacing: .01em;
    padding: .5rem .95rem;
    border-radius: var(--r-sm);
    border: 1px solid transparent;
    cursor: pointer;
    transition: transform .08s, box-shadow .12s, background .12s, border-color .12s;
    display: inline-flex; align-items: center; gap: .4rem;
    text-decoration: none;
}
.btn-primary {
    background: var(--ember);
    color: #fff;
    box-shadow: 0 1px 0 var(--ember-deep), 0 6px 16px -8px rgba(214, 72, 28, .6);
}
.btn-primary:hover { background: var(--ember-deep); color: #fff; transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }
.btn-secondary {
    background: var(--surface);
    color: var(--ink-2);
    border-color: var(--line-strong);
}
.btn-secondary:hover { border-color: var(--ink-2); color: var(--ink); }
.btn-sm { padding: .3rem .6rem; font-size: .78rem; }

.link-button {
    background: none; border: 0; padding: 0; margin: 0;
    font: inherit; font-weight: 600; font-size: .82rem;
    color: var(--steel); cursor: pointer; text-decoration: none;
}
.link-button:hover { color: var(--ember); }

.inline-actions { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; }

/* ========================== FORMS ===================================== */

.stack-form { display: flex; flex-direction: column; gap: .8rem; }
.stack-form > label { display: flex; flex-direction: column; gap: .25rem; }
label > span:first-child { font-size: .8rem; font-weight: 600; color: var(--ink-2); }

input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
select, textarea {
    font-family: var(--font-body);
    font-size: .88rem;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: var(--r-sm);
    padding: .48rem .6rem;
    width: 100%;
    transition: border-color .12s, box-shadow .12s;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--ember);
    box-shadow: 0 0 0 3px var(--ember-soft);
}
textarea { resize: vertical; min-height: 2.6rem; }
input::placeholder, textarea::placeholder { color: var(--muted-2); }

.field-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: .8rem; }
.field-group { display: flex; flex-direction: column; gap: .25rem; }

.checkbox-row { display: flex; align-items: center; gap: .55rem; cursor: pointer; }
.checkbox-row span { font-size: .85rem; color: var(--ink-2); }
.checkbox-row input[type="checkbox"] { width: 1.05rem; height: 1.05rem; accent-color: var(--ember); flex: none; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--ember); }
input[type="file"] { font-size: .82rem; border: 0; padding: .3rem 0; }

/* ========================== DISCLOSURE =============================== */

.disclosure {
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    background: var(--surface-sunk);
    margin-top: .65rem;
}
.disclosure > summary {
    cursor: pointer;
    padding: .6rem .85rem;
    font-weight: 600;
    font-size: .85rem;
    color: var(--ink-2);
    list-style: none;
    display: flex; align-items: center; gap: .5rem;
}
.disclosure > summary::-webkit-details-marker { display: none; }
.disclosure > summary::before { content: "+"; font-family: var(--font-mono); color: var(--ember); font-weight: 700; }
.disclosure[open] > summary::before { content: "–"; }
.disclosure[open] > summary { border-bottom: 1px solid var(--line); }
.disclosure__body { padding: .9rem .85rem; }
.disclosure__summary-meta { color: var(--muted); font-weight: 400; font-size: .8rem; }

/* ========================== LISTS ==================================== */

.plain-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.plain-list > li {
    padding: .7rem 0;
    border-bottom: 1px solid var(--line);
    display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .6rem;
}
.plain-list > li:last-child { border-bottom: 0; }
.plain-list strong { font-weight: 600; }
.mlrow__actions { margin-left: auto; display: flex; gap: .8rem; align-items: center; }
.mlrow__actions form { display: inline; }

/* ========================== CHIPS / BADGES =========================== */

.status-chip, .badge {
    display: inline-flex; align-items: center; gap: .3rem;
    font-family: var(--font-mono);
    font-size: .68rem;
    font-weight: 500;
    letter-spacing: .04em;
    text-transform: uppercase;
    padding: .15rem .45rem;
    border-radius: var(--r-xs);
    background: var(--steel-soft);
    color: var(--steel);
    border: 1px solid transparent;
    white-space: nowrap;
}
.status-chip--ok { background: var(--ok-soft); color: var(--ok); }
.status-chip--warn { background: var(--warn-soft); color: var(--warn); }
.status-chip--bad { background: var(--danger-soft); color: var(--danger); }
.badge-row { display: flex; flex-wrap: wrap; gap: .4rem; }

/* flash message rendered as the first chip in a panel reads as a sentence */
.panel > .status-chip:first-of-type,
.maillist > .status-chip {
    text-transform: none;
    font-family: var(--font-body);
    letter-spacing: 0;
    font-size: .82rem;
    font-weight: 500;
    background: var(--ok-soft);
    color: var(--ok);
    padding: .4rem .7rem;
    border-radius: var(--r-sm);
}

/* ========================== TABLES ================================== */

.data-table { width: 100%; border-collapse: collapse; font-size: .85rem; }
.data-table thead th {
    text-align: left;
    font-family: var(--font-mono);
    font-size: .66rem;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--muted);
    font-weight: 500;
    padding: .5rem .65rem;
    border-bottom: 1.5px solid var(--line-strong);
    white-space: nowrap;
}
.data-table tbody td { padding: .55rem .65rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.data-table tbody tr:hover { background: var(--surface-sunk); }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table code { background: transparent; border: 0; padding: 0; color: var(--steel); }

.fb-grid td { text-align: center; min-width: 26px; }
.fb-grid th:first-child, .fb-grid td:first-child { text-align: left; white-space: nowrap; }

/* ========================== STAT CARDS ============================== */

.stat-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-left: 3px solid var(--ember);
    border-radius: var(--r-sm);
    padding: .9rem 1rem;
}
.stat-card .eyebrow { display: block; margin-bottom: .25rem; }
.stat-card strong, .stat-card .stat-value { font-family: var(--font-display); font-size: 1.55rem; font-weight: 700; }

.connector-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: .8rem; }
.connector-card { border: 1px solid var(--line); border-radius: var(--r-sm); padding: .9rem 1rem; background: var(--surface-sunk); }

/* ========================== WEBMAIL ================================ */

.mailwork { flex: 1; min-height: 0; display: flex; width: 100%; }
.mailwork__pane { min-height: 0; display: flex; flex-direction: column; }

.mailrail {
    width: var(--rail-w);
    flex: none;
    background: var(--paper-2);
    border-right: 1px solid var(--line);
    padding: 1rem .8rem;
    overflow-y: auto;
    gap: .15rem;
}
.mailrail__compose { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; margin-bottom: 1rem; width: 100%; }
.mailrail__folders { display: flex; flex-direction: column; gap: .1rem; }
.mailrail__section { margin-top: 1.3rem; }
.mailrail__section .eyebrow { padding: 0 .6rem .35rem; display: block; }

.folder-link {
    display: flex; align-items: center; gap: .6rem;
    padding: .42rem .6rem;
    border-radius: var(--r-sm);
    color: var(--ink-2);
    font-size: .88rem;
    font-weight: 500;
    position: relative;
    transition: background .12s, color .12s;
}
.folder-link:hover { background: rgba(27, 23, 20, .05); color: var(--ink); }
.folder-link.active { background: var(--surface); color: var(--ember-deep); box-shadow: var(--shadow-sm); }
.folder-link.active::before {
    content: ""; position: absolute; left: -.8rem; top: 7px; bottom: 7px; width: 3px; background: var(--ember); border-radius: 0 3px 3px 0;
}
.folder-link__glyph { width: 1.2rem; text-align: center; flex: none; }
.folder-link__name { flex: 1; }
.folder-link__count { font-family: var(--font-mono); font-size: .7rem; color: #fff; background: var(--ember); border-radius: 999px; padding: .02rem .4rem; }
.folder-row { display: flex; align-items: center; }
.folder-row__delete { margin-left: auto; }
.folder-row__delete .link-button { color: var(--muted-2); font-size: 1rem; }
.folder-row__delete .link-button:hover { color: var(--danger); }
.mailrail__newfolder { display: flex; gap: .35rem; margin-top: .5rem; padding: 0 .3rem; }
.mailrail__newfolder input { padding: .3rem .45rem; font-size: .8rem; }

.maillist { flex: 1 1 380px; max-width: 460px; border-right: 1px solid var(--line); background: var(--surface); }
.maillist[style*="flex:1"], .maillist[style*="flex: 1"] { max-width: none; }
.maillist__header {
    display: flex; align-items: center; justify-content: space-between; gap: .6rem;
    padding: .9rem 1.1rem; border-bottom: 1px solid var(--line);
}
.maillist__header h2 { font-size: 1.05rem; }
.maillist__search { display: flex; gap: .4rem; padding: .7rem 1.1rem; border-bottom: 1px solid var(--line); }
.maillist__scroll { overflow-y: auto; flex: 1; padding: .35rem; }

.mlrow {
    display: block; padding: .7rem .8rem; border-radius: var(--r-sm);
    border: 1px solid transparent; cursor: pointer; transition: background .1s, border-color .1s;
}
.mlrow:hover { background: var(--surface-sunk); border-color: var(--line); }
.mlrow.read { opacity: .96; }
.mlrow:not(.read) .mlrow__from { font-weight: 700; }
.mlrow__top { display: flex; align-items: baseline; justify-content: space-between; gap: .6rem; }
.mlrow__from { font-weight: 600; color: var(--ink); font-size: .9rem; }
.mlrow__time { font-size: .72rem; color: var(--muted-2); font-family: var(--font-mono); white-space: nowrap; }
.mlrow__subject { font-size: .86rem; color: var(--ink-2); margin: .1rem 0; }
.mlrow__preview { font-size: .8rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mailread { flex: 1; background: var(--surface); padding: 1.4rem clamp(1rem, 3vw, 2rem); overflow-y: auto; }
.mail-empty { color: var(--muted); padding: 2.5rem 1rem; text-align: center; }

.mailtips { display: flex; flex-direction: column; gap: .3rem; margin: .3rem 0 .5rem; }
.mailtips__item {
    font-size: .82rem; padding: .45rem .65rem;
    border-radius: var(--r-sm);
    background: var(--warn-soft);
    border: 1px solid rgba(164, 102, 15, .3);
    color: #7a4e0c;
}

.message-reading, .message-view-header { max-width: 820px; }
.message-detail-grid { display: grid; grid-template-columns: max-content 1fr; gap: .25rem 1rem; font-size: .85rem; margin: .5rem 0 1rem; }
.message-body, .message-html { line-height: 1.6; }
.message-html img { max-width: 100%; height: auto; }
.compose-form { display: flex; flex-direction: column; gap: .8rem; max-width: 780px; }

/* ========================== SETTINGS HUB =========================== */

.settings-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; }
.settings-card {
    display: block;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r);
    padding: 1.1rem 1.2rem;
    transition: border-color .12s, transform .12s, box-shadow .12s;
}
.settings-card:hover { border-color: var(--ember); transform: translateY(-2px); box-shadow: var(--shadow); }
.settings-card__glyph { font-size: 1.4rem; }
.settings-card h3 { font-family: var(--font-display); margin: .5rem 0 .2rem; font-size: 1rem; color: var(--ink); }
.settings-card p { margin: 0; color: var(--muted); font-size: .85rem; }
.settings-section { margin-bottom: 1.4rem; }
.settings-wrap { max-width: 980px; margin: 0 auto; padding: 1.8rem clamp(1rem, 4vw, 2.5rem); width: 100%; overflow-y: auto; }

/* ========================== AUTH ================================== */

.auth-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 2rem;
    background:
        radial-gradient(70% 90% at 80% -10%, rgba(214, 72, 28, .14), transparent 60%),
        radial-gradient(60% 80% at -10% 110%, rgba(44, 74, 99, .12), transparent 60%),
        var(--paper);
}
.auth-card {
    width: min(420px, 100%);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    padding: 2.2rem 2rem;
    box-shadow: var(--shadow-lg);
    animation: rise .5s cubic-bezier(.2, .7, .2, 1) both;
}
.auth-card .eyebrow { display: block; margin-bottom: .4rem; }
.auth-card h1 { font-size: 1.7rem; margin-bottom: .4rem; }
.auth-card > p { color: var(--muted); margin-bottom: 1.4rem; }
.auth-form { display: flex; flex-direction: column; gap: .9rem; }
.auth-form .btn-primary { justify-content: center; padding: .65rem; margin-top: .3rem; }
.auth-alt { display: block; text-align: center; }
.divider { display: flex; align-items: center; gap: .8rem; color: var(--muted-2); font-size: .75rem; text-transform: uppercase; letter-spacing: .1em; margin: 1.1rem 0; }
.divider::before, .divider::after { content: ""; height: 1px; background: var(--line); flex: 1; }

/* ========================== LANDING HERO ========================= */

.hero-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1.2fr .8fr;
    align-items: center;
    gap: 3rem;
    padding: clamp(2rem, 6vw, 5rem);
    background:
        radial-gradient(60% 80% at 90% 0%, rgba(214, 72, 28, .12), transparent 55%),
        radial-gradient(50% 70% at 0% 100%, rgba(44, 74, 99, .12), transparent 55%),
        var(--paper);
}
.hero-copy { max-width: 56ch; animation: rise .6s cubic-bezier(.2,.7,.2,1) both; }
.hero-copy .eyebrow { display: block; margin-bottom: .6rem; }
.hero-copy h1 { font-size: clamp(2.6rem, 7vw, 4.4rem); line-height: .98; letter-spacing: -.03em; margin-bottom: 1rem; }
.hero-copy > p { font-size: 1.05rem; color: var(--ink-2); margin-bottom: 1.6rem; max-width: 48ch; }
.hero-actions { display: flex; gap: .8rem; flex-wrap: wrap; }
.hero-actions .btn-primary, .hero-actions .btn-secondary { padding: .7rem 1.3rem; font-size: .95rem; }
.hero-panel { display: flex; flex-direction: column; gap: .8rem; animation: rise .6s cubic-bezier(.2,.7,.2,1) .1s both; }
.hero-panel .stat-card { padding: 1.1rem 1.2rem; }
.hero-panel .stat-card span { font-family: var(--font-mono); font-size: .66rem; letter-spacing: .14em; text-transform: uppercase; color: var(--ember-deep); display: block; margin-bottom: .25rem; }
.hero-panel .stat-card strong { font-family: var(--font-display); font-size: 1rem; font-weight: 600; }

@media (max-width: 820px) { .hero-shell { grid-template-columns: 1fr; } }

/* document-style mail pages (compose, message, rules, auto-replies) center in the shell */
.main--mail > :not(.mailwork):not(.status-chip):not(.settings-wrap) {
    width: 100%;
    max-width: 940px;
    margin: 1.6rem auto 3rem;
    align-self: flex-start;
}

/* a status flash rendered at the top level of the mail shell floats as a toast */
.main--mail > .status-chip {
    position: fixed;
    top: 66px;
    right: 1.4rem;
    z-index: 50;
    box-shadow: var(--shadow);
    animation: rise .3s ease both;
}

/* ========================== CALENDAR ============================= */

.cal { flex: 1; min-width: 0; background: var(--surface); }
.cal__bar {
    display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
    padding: .7rem 1.1rem; border-bottom: 1px solid var(--line);
}
.cal__nav { display: flex; align-items: center; gap: .5rem; }
.cal__arrow {
    display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px;
    border: 1px solid var(--line); border-radius: var(--r-sm); color: var(--ink-2); font-size: 1.2rem; line-height: 1;
}
.cal__arrow:hover { border-color: var(--ember); color: var(--ember); }
.cal__title { font-size: 1.25rem; margin-left: .4rem; }
.cal__tools { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.cal__views { display: inline-flex; background: var(--surface-sunk); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 2px; gap: 2px; flex-wrap: wrap; }
.cal__view { padding: .28rem .6rem; border-radius: var(--r-xs); font-size: .8rem; font-weight: 600; color: var(--muted); }
.cal__view:hover { color: var(--ink); }
.cal__view.active { background: var(--ember); color: #fff; box-shadow: var(--shadow-sm); }

.cal__layout { flex: 1; min-height: 0; display: flex; }
.cal__side { width: 230px; flex: none; border-right: 1px solid var(--line); padding: 1rem; overflow-y: auto; }
.cal__view-area { flex: 1; min-width: 0; overflow: auto; padding: 1rem 1.1rem; }

/* mini month */
.mini__head { font-family: var(--font-display); font-weight: 700; font-size: .9rem; margin-bottom: .5rem; }
.mini__grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; }
.mini__day { aspect-ratio: 1; display: grid; place-items: center; font-size: .72rem; color: var(--ink-2); border-radius: var(--r-xs); }
.mini__day:hover { background: var(--ember-soft); color: var(--ember-deep); }
.mini__day.out { color: var(--muted-2); }
.mini__day.today { background: var(--ember); color: #fff; font-weight: 700; }

/* event color variants (shared) */
.cal-ev--busy, .cal-chip.cal-ev--busy { --ev: var(--ember); --evbg: var(--ember-soft); --evtext: var(--ember-deep); }
.cal-ev--free { --ev: var(--ok); --evbg: var(--ok-soft); --evtext: var(--ok); }
.cal-ev--tentative { --ev: var(--steel); --evbg: var(--steel-soft); --evtext: var(--steel); }
.cal-ev--oof { --ev: #7a4fbf; --evbg: rgba(122,79,191,.12); --evtext: #5f3aa0; }

/* month grid */
.cal-month { display: flex; flex-direction: column; min-height: 100%; }
.cal-month__head, .cal-month__row { display: grid; grid-template-columns: repeat(7, 1fr); }
.cal-month.with-weeks .cal-month__head, .cal-month.with-weeks .cal-month__row { grid-template-columns: 32px repeat(7, 1fr); }
.cal-month__head { border-bottom: 1px solid var(--line); }
.cal-month__head span { font-family: var(--font-mono); font-size: .66rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); padding: .4rem .5rem; }
.cal-month__row { flex: 1; border-bottom: 1px solid var(--line); }
.cal-month__wk { display: grid; place-items: center; font-family: var(--font-mono); font-size: .66rem; color: var(--muted-2); border-right: 1px solid var(--line); }
.cal-month__cell { border-right: 1px solid var(--line); padding: .3rem; min-height: 92px; cursor: pointer; overflow: hidden; transition: background .1s; }
.cal-month__cell:hover { background: var(--surface-sunk); }
.cal-month__cell.out { background: #fbf9f5; }
.cal-month__cell.out .cal-month__num { color: var(--muted-2); }
.cal-month__cell.weekend { background: #faf7f1; }
.cal-month__num { font-family: var(--font-display); font-weight: 600; font-size: .85rem; }
.cal-month__cell.today .cal-month__num { background: var(--ember); color: #fff; border-radius: 999px; width: 1.5rem; height: 1.5rem; display: inline-grid; place-items: center; }
.cal-month__events { display: flex; flex-direction: column; gap: 2px; margin-top: .25rem; }
.cal-chip {
    display: block; font-size: .72rem; line-height: 1.35; padding: .05rem .35rem;
    border-radius: var(--r-xs); background: var(--evbg, var(--ember-soft)); color: var(--evtext, var(--ember-deep));
    border-left: 2px solid var(--ev, var(--ember));
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; text-transform: none; font-family: var(--font-body); letter-spacing: 0;
}
.cal-chip time { font-family: var(--font-mono); font-size: .66rem; opacity: .85; margin-right: .25rem; }
.cal-more { font-size: .68rem; color: var(--muted); padding-left: .35rem; }

/* time grid (week/work week/day/n-day) */
.cal-grid { display: flex; flex-direction: column; min-width: 540px; }
.cal-grid__head, .cal-grid__allday { display: flex; }
.cal-grid__gutter { width: 58px; flex: none; font-family: var(--font-mono); font-size: .6rem; color: var(--muted-2); text-transform: uppercase; letter-spacing: .06em; display: flex; align-items: center; justify-content: flex-end; padding-right: .4rem; }
.cal-grid__dayhead { flex: 1; text-align: center; padding: .4rem; border-left: 1px solid var(--line); }
.cal-grid__dayhead em { display: block; font-style: normal; font-family: var(--font-mono); font-size: .62rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.cal-grid__dayhead strong { font-family: var(--font-display); font-size: 1.25rem; }
.cal-grid__dayhead.today strong { color: var(--ember); }
.cal-grid__allday { border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); min-height: 26px; background: var(--surface-sunk); }
.cal-grid__alldaycol { flex: 1; border-left: 1px solid var(--line); padding: 2px; display: flex; flex-direction: column; gap: 2px; }
.cal-grid__body { display: flex; position: relative; }
.cal-grid__hours { width: 58px; flex: none; }
.cal-grid__hour { height: var(--rowpx); position: relative; }
.cal-grid__hour span { position: absolute; top: -.55rem; right: .4rem; font-family: var(--font-mono); font-size: .64rem; color: var(--muted-2); }
.cal-grid__col { flex: 1; position: relative; border-left: 1px solid var(--line); }
.cal-grid__col.today { background: rgba(214,72,28,.025); }
.cal-grid__slot { height: var(--rowpx); border-top: 1px solid var(--line); cursor: pointer; }
.cal-grid__slot:hover { background: var(--ember-soft); }
.cal-ev {
    position: absolute; left: 1px; right: 1px; overflow: hidden;
    background: var(--evbg, var(--ember-soft)); border-left: 3px solid var(--ev, var(--ember));
    border-radius: var(--r-xs); padding: .15rem .35rem; font-size: .72rem; color: var(--evtext, var(--ember-deep)); cursor: pointer;
    box-shadow: var(--shadow-sm);
}
.cal-ev strong { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-ev time { font-family: var(--font-mono); font-size: .62rem; opacity: .85; }
.cal-ev em { font-style: normal; display: block; opacity: .8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* agenda */
.cal-agenda { display: flex; flex-direction: column; gap: .2rem; max-width: 720px; }
.cal-agenda__day { display: flex; gap: 1rem; padding: .7rem 0; border-bottom: 1px solid var(--line); }
.cal-agenda__date { width: 70px; flex: none; text-align: center; }
.cal-agenda__date strong { font-family: var(--font-display); font-size: 1.7rem; display: block; line-height: 1; }
.cal-agenda__date span { font-family: var(--font-mono); font-size: .64rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.cal-agenda__items { flex: 1; display: flex; flex-direction: column; gap: .35rem; padding-top: .2rem; }
.cal-agenda__item { display: flex; align-items: baseline; gap: .55rem; font-size: .88rem; }
.cal-dot { width: 9px; height: 9px; border-radius: 999px; background: var(--ev, var(--ember)); flex: none; align-self: center; }
.cal-agenda__time { font-family: var(--font-mono); font-size: .72rem; color: var(--muted); width: 68px; flex: none; }
.cal-agenda__title { font-weight: 600; color: var(--ink); }

/* year */
.cal-year { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 1.1rem; }
.cal-year__name { font-family: var(--font-display); font-weight: 700; font-size: .95rem; margin-bottom: .4rem; color: var(--ember-deep); }
.cal-year__grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; }
.cal-year__day { aspect-ratio: 1; display: grid; place-items: center; font-size: .64rem; color: var(--ink-2); border-radius: var(--r-xs); }
.cal-year__day.out { color: transparent; pointer-events: none; }
.cal-year__day.has { background: var(--ember-soft); color: var(--ember-deep); font-weight: 700; }
.cal-year__day.today { outline: 2px solid var(--ember); }
.cal-year__day:hover { background: var(--ember); color: #fff; }

/* heatmap */
.cal-heat__grid { display: flex; gap: 3px; overflow-x: auto; padding: .6rem 0; }
.cal-heat__col { display: flex; flex-direction: column; gap: 3px; }
.cal-heat__day { width: 13px; height: 13px; border-radius: 2px; display: block; }
.cal-heat__day.l0 { background: var(--line); }
.cal-heat__day.l1 { background: rgba(214,72,28,.28); }
.cal-heat__day.l2 { background: rgba(214,72,28,.5); }
.cal-heat__day.l3 { background: rgba(214,72,28,.72); }
.cal-heat__day.l4 { background: var(--ember); }
.cal-heat__legend { display: flex; align-items: center; gap: 4px; font-size: .7rem; color: var(--muted); }
.cal-heat__legend i { width: 13px; height: 13px; border-radius: 2px; display: inline-block; }
.cal-heat__legend .l0 { background: var(--line); } .cal-heat__legend .l1 { background: rgba(214,72,28,.28); }
.cal-heat__legend .l2 { background: rgba(214,72,28,.5); } .cal-heat__legend .l3 { background: rgba(214,72,28,.72); } .cal-heat__legend .l4 { background: var(--ember); }

/* timeline */
.cal-timeline__axis { display: flex; border-bottom: 1.5px solid var(--line-strong); }
.cal-timeline__day { font-family: var(--font-mono); font-size: .64rem; color: var(--muted); padding: .3rem .4rem; border-left: 1px solid var(--line); text-align: center; }
.cal-timeline__track { position: relative; margin-top: .4rem; }
.cal-bar {
    position: absolute; height: 28px; border-radius: var(--r-xs); background: var(--evbg, var(--ember-soft));
    border-left: 3px solid var(--ev, var(--ember)); color: var(--evtext, var(--ember-deep));
    font-size: .74rem; font-weight: 600; padding: .25rem .5rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; box-shadow: var(--shadow-sm);
}

/* dialogs */
.cal-dialog { border: 1px solid var(--line-strong); border-radius: var(--r-lg); padding: 0; width: min(520px, 94vw); box-shadow: var(--shadow-lg); background: var(--surface); color: var(--ink); }
.cal-dialog::backdrop { background: rgba(27,23,20,.4); backdrop-filter: blur(2px); }
.cal-dialog form { padding: 1.3rem 1.4rem; }
.cal-dialog__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: .4rem; }
.cal-dialog__head h2 { font-size: 1.2rem; }

/* ========================== COMPOSE ============================== */

.compose { padding: 1.4rem 1.5rem; }
.compose .compose-form { gap: 0; max-width: none; }
.compose-field { display: flex; align-items: center; gap: .6rem; border-bottom: 1px solid var(--line); padding: .5rem 0; }
.compose-field__label { width: 56px; flex: none; color: var(--muted); font-size: .8rem; font-weight: 600; }
.compose-field input { border: 0; box-shadow: none !important; padding: .35rem 0; background: transparent; }
.compose-ccbtn { flex: none; }
.compose-cc { display: none; }
.compose.show-cc .compose-cc { display: block; }
.compose-body { border: 0; box-shadow: none !important; padding: 1rem 0; min-height: 320px; resize: vertical; background: transparent; font-size: .95rem; line-height: 1.55; }
.compose-actions { display: flex; align-items: center; gap: 1.2rem; padding-top: .8rem; border-top: 1px solid var(--line); flex-wrap: wrap; }
.compose-actions .btn-primary { padding: .6rem 1.6rem; }
.compose-options { display: flex; gap: 1rem; flex-wrap: wrap; }

/* ========================== MESSAGE VIEW ========================= */

.msg {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    animation: rise .35s cubic-bezier(.2,.7,.2,1) both;
}
.msg__toolbar {
    position: sticky; top: 0; z-index: 2;
    display: flex; align-items: center; justify-content: space-between; gap: .6rem; flex-wrap: wrap;
    padding: .7rem 1.1rem; border-bottom: 1px solid var(--line);
    background: rgba(255,255,255,.9); backdrop-filter: blur(6px);
}
.msg__actions { display: flex; align-items: center; gap: .5rem; }
.msg__actions form { display: inline-flex; margin: 0; }
.msg__move select { padding: .35rem .5rem; font-size: .82rem; }

.msg__head { display: flex; gap: 1rem; padding: 1.2rem 1.3rem; border-bottom: 1px solid var(--line); }
.msg__avatar {
    width: 46px; height: 46px; flex: none; border-radius: 999px;
    display: grid; place-items: center;
    background: linear-gradient(150deg, var(--ember), #e9763f); color: #fff;
    font-family: var(--font-display); font-weight: 700; font-size: 1.05rem;
    box-shadow: 0 4px 12px -4px rgba(214,72,28,.55);
}
.msg__meta { flex: 1; min-width: 0; }
.msg__subject { font-size: 1.4rem; margin-bottom: .35rem; line-height: 1.2; }
.msg__from { font-weight: 600; color: var(--ink); }
.msg__recipients { font-size: .85rem; color: var(--ink-2); margin-top: .1rem; }
.msg__when { text-align: right; flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: .15rem; }
.msg__when time { font-family: var(--font-mono); font-size: .74rem; color: var(--muted); display: block; }
.msg__when .status-chip { margin-top: .3rem; }

.msg__attachments { display: flex; flex-wrap: wrap; gap: .5rem; padding: .9rem 1.3rem; border-bottom: 1px solid var(--line); background: var(--surface-sunk); }
.attach-chip {
    display: inline-flex; align-items: center; gap: .45rem;
    border: 1px solid var(--line-strong); border-radius: var(--r-sm);
    background: var(--surface); padding: .4rem .65rem; font-size: .82rem; color: var(--ink-2);
    transition: border-color .12s, transform .12s;
}
.attach-chip:hover { border-color: var(--ember); transform: translateY(-1px); color: var(--ink); }
.attach-chip__name { font-weight: 600; }
.attach-chip__size { color: var(--muted-2); font-family: var(--font-mono); font-size: .72rem; }

.msg__body { padding: 1.4rem 1.5rem; line-height: 1.65; font-size: .95rem; }
.msg__body .message-html img { max-width: 100%; height: auto; }
.msg__body .message-body { white-space: pre-wrap; font-family: var(--font-body); margin: 0; }
.msg__footer { display: flex; gap: .6rem; padding: 0 1.5rem 1.3rem; }
.msg .disclosure { margin: 0 1.3rem 1rem; }

/* ---- inbox split view: bulk bar, rows, reading pane ---- */
.maillist__bulk { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; padding: .55rem 1.1rem; border-bottom: 1px solid var(--line); background: var(--surface-sunk); }
.bulk-selectall { display: flex; align-items: center; gap: .35rem; font-size: .78rem; color: var(--muted); }
.bulk-selectall input { accent-color: var(--ember); }
.maillist__bulk select { width: auto; min-width: 110px; padding: .3rem .5rem; font-size: .8rem; }

.mlrow-wrap { display: flex; align-items: flex-start; gap: .15rem; }
.mlrow-check { margin: .85rem .1rem 0 .35rem; accent-color: var(--ember); flex: none; }
.mlrow-wrap .mlrow { flex: 1; min-width: 0; }
.mlrow.unread .mlrow__from { font-weight: 700; color: var(--ink); }
.mlrow.unread .mlrow__subject { color: var(--ink); font-weight: 600; }
.mlrow.unread::before { content: ""; position: absolute; left: .2rem; top: 50%; transform: translateY(-50%); width: 6px; height: 6px; border-radius: 999px; background: var(--ember); }
.mlrow { position: relative; }
.mlrow.unread { padding-left: 1.1rem; }
.mlrow.selected { background: var(--ember-soft); border-color: rgba(214,72,28,.3); }

.mailread { padding: 0; }
.mailread__toolbar { position: sticky; top: 0; z-index: 3; background: rgba(255,255,255,.92); backdrop-filter: blur(6px); }
.mailread__empty { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; color: var(--muted); gap: .3rem; padding: 2rem; text-align: center; }
.mailread__empty-mark { font-size: 2.6rem; opacity: .35; }

/* ---- clickable list rows (admin) ---- */
.rowlink { cursor: pointer; }
.rowlink td { vertical-align: middle; }
.rowlink:hover { background: var(--ember-soft) !important; }
.rowlink__badges { text-align: right; white-space: nowrap; }
.rowlink__chev { color: var(--muted-2); font-size: 1.2rem; margin-left: .5rem; }
.rowlink:hover .rowlink__chev { color: var(--ember); }

/* ---- dialog footer / scroll (admin config dialogs) ---- */
.cal-dialog { max-height: 92vh; }
.cal-dialog form { max-height: 90vh; overflow-y: auto; }
.cal-dialog__head h2 { font-size: 1.2rem; margin-top: .15rem; }
.cal-dialog__foot { display: flex; align-items: center; gap: 1rem; padding-top: .9rem; margin-top: .4rem; border-top: 1px solid var(--line); }
.link-button.danger { color: var(--danger); margin-left: auto; }
.link-button.danger:hover { color: #8f2a1f; }

@media print {
    .msg__toolbar, .msg__footer, .mailrail, .topbar, .sidebar { display: none !important; }
    .msg { border: 0; box-shadow: none; }
    body::before { display: none; }
}

/* ========================== RESPONSIVE ============================ */

@media (max-width: 900px) {
    .cal__side { display: none; }
    .shell--admin { grid-template-columns: 1fr; }
    .sidebar { position: relative; height: auto; }
    .sidenav { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0 1rem; }
    .maillist { max-width: none; flex: 1; }
    .mailrail { width: 200px; }
    .mailread { display: none; }
}
