:root {
    --bg: #f4efe6;
    --bg-strong: #fbf7f1;
    --panel: rgba(255, 252, 247, 0.92);
    --panel-strong: #fffdf9;
    --panel-accent: #fff7eb;
    --line: rgba(97, 79, 59, 0.16);
    --line-strong: rgba(97, 79, 59, 0.24);
    --ink: #211913;
    --muted: #706154;
    --brand: #195b53;
    --brand-strong: #103c37;
    --brand-soft: #dcefe9;
    --brand-surface: rgba(25, 91, 83, 0.08);
    --sand: #f2e8d9;
    --danger: #b54d36;
    --danger-soft: #f7e2dc;
    --shadow: 0 18px 45px rgba(49, 31, 17, 0.08);
    --shadow-strong: 0 24px 60px rgba(30, 22, 16, 0.12);
    --radius: 22px;
    --radius-sm: 14px;
    --font-sans: "IBM Plex Sans", "Noto Sans SC", "Segoe UI", sans-serif;
    --font-mono: "JetBrains Mono", "Cascadia Code", "SFMono-Regular", monospace;
    --font-display: "Noto Serif SC", Georgia, serif;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: var(--font-sans);
    color: var(--ink);
    background:
        radial-gradient(circle at top left, rgba(25, 91, 83, 0.14), transparent 28%),
        radial-gradient(circle at top right, rgba(216, 169, 86, 0.16), transparent 22%),
        linear-gradient(180deg, var(--bg-strong) 0%, var(--bg) 100%);
}

body.is-modal-open {
    overflow: hidden;
}

a {
    color: var(--brand);
}

code,
.mono,
pre {
    font-family: var(--font-mono);
}

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

h1,
h2 {
    font-family: var(--font-display);
    letter-spacing: -0.02em;
}

[hidden] {
    display: none !important;
}

.login-shell,
.admin-shell,
.public-shell {
    width: min(1200px, calc(100% - 32px));
    margin: 0 auto;
}

.admin-shell {
    width: min(1420px, calc(100% - 30px));
}

.public-shell {
    padding-bottom: 40px;
}

.login-page {
    min-height: 100vh;
    display: grid;
    align-items: center;
    padding: 32px 0;
}

.login-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(360px, 0.9fr);
    gap: 22px;
    align-items: stretch;
}

.login-brand-panel,
.login-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 28px;
    box-shadow: var(--shadow-strong);
}

.login-brand-panel {
    position: relative;
    overflow: hidden;
    padding: 34px;
    display: grid;
    gap: 24px;
    background:
        linear-gradient(135deg, rgba(25, 91, 83, 0.08), rgba(255, 247, 235, 0.92)),
        var(--panel);
}

.login-brand-panel::after {
    content: "";
    position: absolute;
    right: -42px;
    top: -38px;
    width: 220px;
    height: 220px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(25, 91, 83, 0.12), transparent 70%);
}

.login-brand-copy,
.login-copy,
.section-head,
.hero,
.public-hero {
    display: grid;
    gap: 8px;
}

.login-brand-copy h1 {
    font-size: clamp(36px, 4vw, 54px);
    line-height: 1.06;
}

.login-brand-copy p {
    max-width: 52ch;
}

.login-brand-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    position: relative;
    z-index: 1;
}

.login-brand-card {
    display: grid;
    gap: 10px;
    padding: 18px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.58);
    border: 1px solid rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(8px);
}

.login-brand-card span,
.login-brand-card small,
.meta-grid span,
.hero-side-card span,
.code-spotlight span {
    color: var(--muted);
    font-size: 13px;
}

.login-brand-card strong {
    font-size: 18px;
    line-height: 1.35;
}

.login-card {
    width: min(540px, 100%);
    padding: 32px;
    justify-self: end;
    display: grid;
    gap: 18px;
    align-content: center;
}

.login-card-strong {
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(255, 250, 243, 0.94)),
        var(--panel);
}

.login-copy h2 {
    font-size: 34px;
}

.login-form-panel {
    margin-bottom: 0;
}

.login-footnote {
    display: flex;
    justify-content: flex-start;
}

.eyebrow {
    margin: 0 0 8px;
    color: var(--brand);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.hero,
.public-hero {
    position: relative;
    background:
        linear-gradient(135deg, rgba(255, 249, 239, 0.92), rgba(255, 255, 255, 0.9)),
        var(--panel);
    border: 1px solid var(--line);
    border-radius: 28px;
    padding: 30px;
    box-shadow: var(--shadow-strong);
    margin: 24px 0 18px;
}

.hero-board,
.public-hero-board,
.hero-detail-board {
    grid-template-columns: minmax(0, 1.15fr) minmax(280px, 0.85fr);
    align-items: start;
    gap: 24px;
}

.workspace-hero {
    display: grid;
}

.hero-copy-block {
    display: grid;
    gap: 12px;
    min-width: 0;
}

.hero-copy-block h1,
.public-hero h1,
.hero h1 {
    font-size: clamp(32px, 3.6vw, 52px);
    line-height: 1.04;
}

.hero-copy,
.muted,
.section-head p,
.login-copy p,
.login-brand-copy p {
    color: var(--muted);
    line-height: 1.68;
}

.hero-chip-group,
.info-pills,
.inline-metrics,
.section-summary,
.mini-meta,
.account-toolbar,
.alias-toolbar,
.hero-actions,
.section-actions,
.form-actions,
.inline-actions,
.table-actions,
.bulk-toolbar-main,
.bulk-toolbar-copy {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.hero-chip-group {
    margin-top: 6px;
}

.hero-side-panel {
    display: grid;
    gap: 14px;
    align-content: start;
}

.hero-side-card,
.code-spotlight,
.batch-spotlight-card,
.meta-card,
.insight-card,
.login-brand-card {
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

.hero-side-card,
.code-spotlight {
    display: grid;
    gap: 8px;
    padding: 18px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.72);
    border: 1px solid var(--line);
}

.hero-side-card strong {
    font-size: 28px;
}

.hero-actions-stack,
.section-actions-stack {
    display: grid;
    gap: 10px;
}

.insight-grid,
.workflow-grid,
.batch-grid {
    display: grid;
    gap: 16px;
    margin-bottom: 16px;
}

.insight-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.workflow-grid {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.batch-grid {
    grid-template-columns: minmax(300px, 0.7fr) minmax(0, 1.3fr);
}

.batch-grid-emphasis {
    align-items: start;
}

.panel,
.subpanel,
.mail-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.panel {
    padding: 24px;
    margin-bottom: 16px;
}

.stats-strip-panel {
    padding: 18px 22px;
}

.stats-inline {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    align-items: stretch;
}

.inline-stat {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 5px 10px;
    align-items: baseline;
    min-width: 0;
    padding: 8px 24px;
}

.inline-stat:first-child {
    padding-left: 0;
}

.inline-stat + .inline-stat {
    border-left: 1px solid var(--line);
}

.inline-stat span,
.inline-stat small {
    color: var(--muted);
}

.inline-stat span {
    font-size: 13px;
    white-space: nowrap;
}

.inline-stat strong {
    color: var(--ink);
    font-size: 24px;
    line-height: 1;
}

.inline-stat small {
    grid-column: 1 / -1;
    overflow-wrap: anywhere;
    font-size: 12px;
    line-height: 1.45;
}

.action-card {
    display: grid;
    gap: 18px;
    align-content: start;
}

.action-card-spotlight {
    background:
        linear-gradient(135deg, rgba(255, 248, 236, 0.95), rgba(255, 255, 255, 0.92)),
        var(--panel);
}

.action-card-top {
    display: grid;
    gap: 14px;
}

.insight-card {
    display: grid;
    gap: 10px;
    min-height: 150px;
    padding: 22px 20px;
    border-radius: 22px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(248, 242, 233, 0.92)),
        var(--panel);
    border: 1px solid var(--line);
}

.insight-card span,
.insight-card small {
    color: var(--muted);
}

.insight-card strong {
    font-size: clamp(34px, 3vw, 44px);
    line-height: 1;
}

.insight-card-primary {
    background:
        linear-gradient(135deg, rgba(25, 91, 83, 0.92), rgba(16, 60, 55, 0.96)),
        var(--brand);
    color: #fff;
}

.insight-card-primary span,
.insight-card-primary small {
    color: rgba(255, 255, 255, 0.82);
}

.insight-card-contrast {
    background:
        linear-gradient(135deg, rgba(242, 232, 217, 0.96), rgba(255, 250, 242, 0.96)),
        var(--panel-accent);
}

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

.form-grid label,
.field {
    display: grid;
    gap: 8px;
}

.form-grid label span,
.field span,
.toolbar-field span,
.preview-label {
    font-size: 13px;
    color: var(--muted);
}

.wide {
    grid-column: 1 / -1;
}

.stack-form {
    display: grid;
    gap: 16px;
}

.compact-stack-form {
    gap: 14px;
}

.field-inline {
    grid-template-columns: minmax(0, 1fr) 160px;
    align-items: end;
}

.field-inline span {
    padding-bottom: 12px;
}

.form-inline-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    align-items: end;
}

.form-inline-bar .field-inline {
    flex: 0 0 210px;
}

.form-inline-bar .form-actions {
    flex: 1 1 360px;
}

.field-small {
    flex: 0 1 170px;
}

.field-port {
    flex: 0 0 112px;
}

.checkbox-line {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    font-size: 14px;
}

.checkbox-line input {
    width: auto;
}

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

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.92);
    color: var(--ink);
    border-radius: 14px;
    padding: 12px 14px;
    outline: none;
    transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

textarea {
    resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
    border-color: rgba(25, 91, 83, 0.48);
    box-shadow: 0 0 0 4px rgba(25, 91, 83, 0.1);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    border: 0;
    border-radius: 14px;
    padding: 11px 16px;
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
    transition: transform 0.16s ease, box-shadow 0.16s ease, filter 0.16s ease;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn:disabled,
button:disabled {
    opacity: 0.52;
    cursor: not-allowed;
    transform: none;
}

.btn-small {
    min-height: 36px;
    padding: 8px 12px;
    font-size: 13px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--brand), var(--brand-strong));
    color: #fff;
    box-shadow: 0 12px 24px rgba(25, 91, 83, 0.2);
}

.btn-ghost {
    background: linear-gradient(180deg, rgba(220, 239, 233, 0.95), rgba(232, 245, 241, 0.95));
    color: var(--brand);
}

.btn-danger {
    background: linear-gradient(180deg, rgba(247, 226, 220, 0.96), rgba(250, 236, 231, 0.96));
    color: var(--danger);
}

.flash-stack,
.mail-list,
.card-stack {
    display: grid;
    gap: 12px;
}

.flash {
    border-radius: 16px;
    padding: 13px 15px;
    border: 1px solid transparent;
}

.flash-success {
    background: var(--brand-soft);
    color: var(--brand-strong);
    border-color: rgba(25, 91, 83, 0.18);
}

.flash-error {
    background: var(--danger-soft);
    color: var(--danger);
    border-color: rgba(181, 77, 54, 0.2);
}

.pill,
.info-pill,
.soft-badge,
.metric-chip {
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    padding: 8px 12px;
    border-radius: 999px;
    line-height: 1.35;
}

.pill {
    font-size: 13px;
    font-weight: 700;
}

.pill-on {
    background: var(--brand-soft);
    color: var(--brand);
}

.pill-off {
    background: rgba(112, 97, 84, 0.12);
    color: var(--muted);
}

.info-pill {
    background: rgba(242, 232, 217, 0.72);
    color: var(--ink);
    font-size: 13px;
}

.soft-badge {
    background: rgba(220, 239, 233, 0.82);
    color: var(--brand);
    font-size: 13px;
    font-weight: 600;
}

.metric-chip {
    gap: 8px;
    background: rgba(242, 232, 217, 0.76);
    color: var(--ink);
    font-size: 14px;
}

.metric-chip strong {
    font-size: 18px;
}

.batch-panel {
    overflow: hidden;
}

.batch-spotlight {
    display: grid;
    gap: 14px;
    align-content: start;
}

.batch-spotlight-card {
    display: grid;
    gap: 8px;
    padding: 22px;
    border-radius: 22px;
    background:
        linear-gradient(135deg, rgba(25, 91, 83, 0.92), rgba(13, 66, 59, 0.96)),
        var(--brand);
    color: #fff;
}

.batch-spotlight-card span,
.batch-spotlight-card small {
    color: rgba(255, 255, 255, 0.84);
}

.batch-spotlight-card strong {
    font-size: 28px;
}

.batch-preview-shell {
    display: grid;
    gap: 12px;
}

.batch-preview {
    display: grid;
    gap: 12px;
    align-content: start;
}

.preview-textarea {
    min-height: 220px;
    max-height: 340px;
    resize: vertical;
    background: rgba(252, 253, 251, 0.92);
}

.quick-list {
    display: grid;
    gap: 8px;
    max-height: min(460px, 58vh);
    overflow-y: auto;
    padding-right: 6px;
    align-content: start;
}

.quick-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.72);
}

.quick-row-main {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    flex: 1;
}

.quick-row-main strong {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.quick-row span {
    color: var(--muted);
    font-size: 13px;
    white-space: nowrap;
}

.toolbar-panel,
.bulk-toolbar {
    justify-content: space-between;
    gap: 14px;
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: rgba(252, 250, 246, 0.86);
}

.toolbar-panel {
    margin-top: 14px;
}

.toolbar-cluster {
    display: flex;
    flex: 1 1 0;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
}

.toolbar-submit-form {
    margin: 0;
}

.toolbar-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.toolbar-field {
    min-width: 180px;
    display: grid;
    gap: 6px;
}

.toolbar-field.compact {
    min-width: 96px;
}

.search-field {
    min-width: 240px;
    flex: 1 1 260px;
}

.bulk-toolbar-split {
    gap: 16px;
}

.selection-count,
.check-inline,
.pager-nav {
    color: var(--muted);
    font-size: 14px;
}

.check-inline {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.selection-count {
    min-width: 72px;
}

.section-head-inline,
.pager-bar,
.row-between {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
}

.pager-bar {
    margin-bottom: 14px;
}

.pager-bar-end {
    justify-content: flex-end;
}

.pager-form {
    display: flex;
    align-items: end;
    gap: 12px;
}

.pager-nav {
    display: flex;
    align-items: center;
    gap: 10px;
}

.imap-profile-panel,
.account-panel {
    margin-bottom: 16px;
}

.imap-profile-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
}

.imap-profile-summary-title {
    display: grid;
    gap: 4px;
    min-width: 0;
}

.imap-profile-summary-title .eyebrow {
    margin-bottom: 0;
}

.imap-profile-summary-title h2 {
    font-size: 24px;
}

.imap-profile-summary-meta {
    display: flex;
    flex: 1 1 auto;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 10px;
    min-width: 0;
}

.imap-profile-manage {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--line);
}

.imap-profile-manage-head {
    margin-bottom: 12px;
}

.alias-panel {
    margin-bottom: 28px;
}

#imap-section,
#actions-section,
#batch-section,
#accounts-section,
#aliases-section {
    scroll-margin-top: 18px;
}

.imap-create-form {
    display: flex;
    justify-content: space-between;
    align-items: end;
    gap: 14px;
    margin-top: 16px;
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: rgba(252, 250, 246, 0.86);
}

.imap-create-form .toolbar-cluster {
    align-items: end;
}

.imap-create-form .field {
    min-width: 180px;
    flex: 1 1 180px;
}

.imap-create-form .field-port {
    min-width: 112px;
}

.imap-create-actions {
    justify-content: flex-end;
    flex-shrink: 0;
}

.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.7);
}

.imap-profile-table-wrap,
.account-table-wrap,
.alias-table-wrap {
    margin-top: 14px;
}

.imap-profile-table {
    min-width: 1080px;
}

.account-table {
    min-width: 1120px;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 880px;
}

th,
td {
    padding: 15px 14px;
    text-align: left;
    vertical-align: top;
    border-bottom: 1px solid var(--line);
}

th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: rgba(246, 240, 231, 0.96);
    color: var(--muted);
    font-size: 12px;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    backdrop-filter: blur(10px);
}

tbody tr {
    transition: background-color 0.18s ease;
}

tbody tr:hover {
    background: rgba(25, 91, 83, 0.04);
}

tr:last-child td {
    border-bottom: 0;
}

.account-detail-row:hover,
.profile-detail-row:hover {
    background: transparent;
}

.account-detail-row td,
.profile-detail-row td {
    padding: 0;
    background: rgba(251, 248, 241, 0.96);
}

.account-detail-panel,
.profile-detail-panel {
    display: grid;
    gap: 14px;
    padding: 18px;
    border-top: 1px solid var(--line);
}

.col-expand {
    width: 90px;
    text-align: center;
}

.col-check {
    width: 44px;
    text-align: center;
}

.col-check input {
    width: 16px;
    height: 16px;
}

.table-toggle {
    min-width: 64px;
}

.table-actions,
.table-actions-tight {
    align-items: center;
}

.table-actions-tight {
    min-width: 210px;
}

.cell-stack {
    display: grid;
    gap: 4px;
}

.empty-row,
.empty-state {
    color: var(--muted);
    text-align: center;
    padding: 24px;
}

.empty-state.small {
    padding: 16px;
}

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

.public-meta-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    max-width: 980px;
    margin-left: auto;
    margin-right: auto;
}

.meta-card-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.meta-card {
    display: grid;
    gap: 6px;
    padding: 16px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid var(--line);
}

.meta-card strong {
    display: block;
    word-break: break-word;
}

.code-spotlight {
    min-height: 148px;
    align-content: start;
    background:
        linear-gradient(180deg, rgba(25, 91, 83, 0.08), rgba(255, 255, 255, 0.88)),
        rgba(255, 255, 255, 0.8);
}

.code-spotlight strong {
    font-size: clamp(34px, 3vw, 46px);
    line-height: 1;
}

.code-spotlight-compact strong {
    font-size: 38px;
}

.inline-banner {
    max-width: 980px;
    margin: 0 auto 16px;
    padding: 14px 16px;
    border-radius: 18px;
    border: 1px solid var(--line);
}

.banner-info {
    background: rgba(220, 239, 233, 0.82);
    color: var(--brand-strong);
}

.banner-error {
    background: var(--danger-soft);
    color: var(--danger);
}

.history-form-panel {
    display: grid;
    gap: 16px;
    padding: 22px;
    background:
        linear-gradient(135deg, rgba(255, 253, 249, 0.96), rgba(246, 240, 231, 0.9)),
        var(--panel);
}

.history-form-copy {
    display: grid;
    gap: 6px;
}

.history-form-copy .eyebrow {
    margin-bottom: 0;
}

.history-form-copy h2 {
    font-size: 24px;
}

.history-form-copy p {
    color: var(--muted);
    line-height: 1.6;
}

.history-lookup-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    align-items: end;
}

.history-lookup-form input {
    min-height: 52px;
    border-radius: 16px;
    font-family: var(--font-mono);
}

.history-lookup-form .btn {
    min-height: 52px;
    padding-inline: 22px;
}

.history-helper-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.history-shell .public-meta,
.history-shell .public-mode-panel,
.history-shell .inline-banner,
.history-shell .public-card {
    width: min(980px, 100%);
}

.history-shell .history-result-summary,
.history-shell .history-mail-card {
    width: min(1040px, 100%);
}

.history-result-summary {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(160px, 0.62fr) minmax(160px, 0.52fr);
    gap: 14px;
}

.history-email-card strong {
    font-size: 16px;
}

.history-code-card {
    background:
        linear-gradient(135deg, rgba(25, 91, 83, 0.92), rgba(16, 60, 55, 0.96)),
        var(--brand);
    color: #fff;
}

.history-code-card span {
    color: rgba(255, 255, 255, 0.78);
}

.history-code-card strong {
    color: #fff;
    font-size: 30px;
    line-height: 1.1;
}

.history-shell .mail-list {
    display: grid;
    gap: 18px;
    justify-items: center;
}

.history-mail-card {
    border-radius: 22px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(252, 249, 244, 0.94)),
        var(--panel);
}

.mail-card {
    overflow: hidden;
}

.mail-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    padding: 20px 22px;
    border-bottom: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.58);
}

.mail-head h2,
.mail-head h3 {
    font-size: 20px;
    margin-bottom: 6px;
}

.mail-side {
    display: grid;
    gap: 6px;
    text-align: right;
    color: var(--muted);
    flex-shrink: 0;
}

.mail-side-label {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.mail-body {
    padding: 18px 20px 20px;
}

.history-mail-card .mail-head {
    align-items: center;
    padding: 18px 20px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.86), rgba(250, 246, 239, 0.72)),
        rgba(255, 255, 255, 0.58);
}

.history-mail-title {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 5px 10px;
    align-items: center;
    min-width: 0;
}

.history-mail-title h2 {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.history-mail-title .muted {
    grid-column: 2;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mail-index {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    height: 28px;
    padding: 0 8px;
    border-radius: 999px;
    background: var(--brand-surface);
    color: var(--brand);
    font-size: 12px;
    font-weight: 800;
}

.dot-separator {
    color: rgba(112, 97, 84, 0.55);
    padding: 0 4px;
}

.history-code-badge {
    min-width: 112px;
    padding: 10px 12px;
    border-radius: 16px;
    background: rgba(220, 239, 233, 0.86);
    color: var(--brand);
    text-align: center;
}

.history-code-badge strong {
    color: var(--brand-strong);
    font-size: 20px;
    line-height: 1;
}

.history-mail-card .mail-body {
    padding: 14px 16px 16px;
}

.mail-preview-shell {
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 18px;
    background:
        linear-gradient(180deg, #fff, rgba(252, 250, 246, 0.98));
}

.public-mode-panel {
    max-width: 980px;
    margin-left: auto;
    margin-right: auto;
    padding: 16px 18px;
}

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

.mode-strip > span {
    color: var(--muted);
    font-size: 13px;
}

.global-view-toggle,
.split-tabs {
    display: inline-flex;
    gap: 8px;
}

.split-tabs {
    margin-bottom: 12px;
}

.tab-btn {
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.92);
    color: var(--muted);
    border-radius: 12px;
    padding: 9px 12px;
    cursor: pointer;
    transition: transform 0.16s ease, background-color 0.16s ease, color 0.16s ease;
}

.tab-btn:hover {
    transform: translateY(-1px);
}

.tab-btn.is-active {
    background: linear-gradient(135deg, var(--brand), var(--brand-strong));
    border-color: var(--brand);
    color: #fff;
}

.tab-panel {
    display: none;
}

.tab-panel.is-active {
    display: block;
}

.public-shell[data-view-mode="html"] .view-panel-text,
.public-shell[data-view-mode="text"] .view-panel-html {
    display: none;
}

.public-shell[data-view-mode="html"] .view-panel-html,
.public-shell[data-view-mode="text"] .view-panel-text {
    display: block;
}

pre {
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
    line-height: 1.7;
    background: rgba(250, 247, 241, 0.9);
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 16px;
}

.mail-frame {
    width: 100%;
    display: block;
    min-height: 560px;
    height: 560px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: #fff;
}

.history-shell .mail-frame {
    min-height: 420px;
    height: min(680px, 72vh);
    border: 0;
    border-radius: 0;
}

.history-redesign {
    gap: 16px;
    padding: 24px 16px 32px;
    overflow-x: hidden;
}

.history-redesign .history-compact-hero,
.history-redesign .history-search-card,
.history-redesign .history-result-toolbar,
.history-redesign .history-inbox {
    width: min(1120px, 100%);
    max-width: 1120px;
    margin-left: auto;
    margin-right: auto;
}

.history-redesign .history-compact-hero {
    padding: 28px 30px;
    border-radius: 20px;
}

.history-redesign .history-compact-hero h1 {
    font-size: clamp(34px, 4vw, 52px);
    line-height: 1.04;
    margin-bottom: 8px;
}

.history-redesign .hero-copy {
    max-width: 640px;
}

.history-redesign .history-search-card {
    grid-template-columns: 1fr;
    align-items: stretch;
    gap: 10px;
    padding: 18px;
    border-radius: 18px;
}

.history-redesign .history-form-copy h2 {
    font-size: 20px;
}

.history-redesign .history-lookup-form input {
    width: 100%;
    min-width: 0;
    background: #fff;
}

.history-redesign .history-lookup-form .wide {
    grid-column: auto;
}

.history-redesign .history-lookup-form .form-actions {
    align-self: end;
    flex-wrap: nowrap;
}

.history-redesign .history-result-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 16px;
    border-radius: 18px;
}

.history-result-main {
    display: grid;
    gap: 4px;
    min-width: 0;
}

.history-result-main span,
.history-stat span {
    color: var(--muted);
    font-size: 12px;
}

.history-result-main strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    overflow-wrap: anywhere;
    font-size: 17px;
}

.history-result-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    flex-shrink: 0;
}

.history-stat {
    display: grid;
    gap: 3px;
    min-width: 96px;
    padding: 9px 12px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.74);
}

.history-stat strong {
    color: var(--brand-strong);
    font-size: 18px;
    line-height: 1.1;
}

.history-redesign .global-view-toggle {
    padding: 4px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.7);
}

.history-redesign .tab-btn {
    min-height: 38px;
    border-radius: 10px;
    padding: 8px 12px;
}

.history-inbox {
    display: grid;
    grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
    height: min(760px, calc(100vh - 270px));
    min-height: 600px;
    padding: 0;
    overflow: hidden;
    border-radius: 18px;
}

.history-message-list {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    min-width: 0;
    min-height: 0;
    border-right: 1px solid var(--line);
    background: rgba(250, 247, 241, 0.78);
}

.history-list-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--line);
}

.history-list-head span {
    color: var(--muted);
    font-size: 12px;
}

.history-message-scroll {
    display: grid;
    align-content: start;
    gap: 8px;
    min-height: 0;
    overflow: auto;
    padding: 10px;
}

.history-message-row {
    width: 100%;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
    padding: 11px 10px;
    border: 1px solid transparent;
    border-radius: 14px;
    background: transparent;
    color: var(--text);
    text-align: left;
    cursor: pointer;
}

.history-message-row:hover {
    background: rgba(255, 255, 255, 0.72);
}

.history-message-row.is-active {
    border-color: rgba(25, 91, 83, 0.28);
    background: #fff;
    box-shadow: 0 10px 28px rgba(44, 31, 18, 0.08);
}

.history-row-index {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 30px;
    border-radius: 999px;
    background: var(--brand-surface);
    color: var(--brand);
    font-size: 12px;
    font-weight: 800;
}

.history-row-copy {
    display: grid;
    gap: 4px;
    min-width: 0;
}

.history-row-copy strong,
.history-row-copy span,
.history-row-copy time {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.history-row-copy strong {
    font-size: 14px;
    overflow-wrap: anywhere;
}

.history-row-copy span,
.history-row-copy time {
    color: var(--muted);
    font-size: 12px;
}

.history-row-code {
    padding: 6px 8px;
    border-radius: 10px;
    background: rgba(220, 239, 233, 0.9);
    color: var(--brand-strong);
    font-size: 13px;
    font-weight: 800;
}

.history-preview-stack {
    min-width: 0;
    min-height: 0;
    background: #fff;
}

.history-preview-card {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    height: 100%;
    min-width: 0;
    min-height: 0;
}

.history-preview-card[hidden] {
    display: none;
}

.history-preview-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 17px 18px;
    border-bottom: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.88);
}

.history-preview-head > div:first-child {
    min-width: 0;
}

.history-preview-kicker {
    display: inline-block;
    margin-bottom: 4px;
    color: var(--brand);
    font-size: 12px;
    font-weight: 800;
}

.history-preview-head h2 {
    min-width: 0;
    margin-bottom: 6px;
    font-size: 22px;
    line-height: 1.25;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.history-preview-head .muted {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.history-preview-code {
    display: grid;
    gap: 5px;
    min-width: 104px;
    padding: 10px 12px;
    border-radius: 14px;
    background: var(--brand-surface);
    color: var(--brand-strong);
    text-align: center;
}

.history-preview-code span {
    color: var(--muted);
    font-size: 12px;
}

.history-preview-code strong {
    font-size: 20px;
    line-height: 1;
}

.history-preview-body {
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    padding: 14px;
    background: #fff;
}

.history-redesign[data-view-mode="html"] .view-panel-html,
.history-redesign[data-view-mode="text"] .view-panel-text {
    display: block;
    height: 100%;
}

.history-redesign .history-preview-body pre {
    height: 100%;
    overflow: auto;
    border-radius: 14px;
    background: rgba(250, 247, 241, 0.78);
    font-size: 14px;
}

.history-redesign .history-preview-frame {
    width: 100%;
    height: 100%;
    min-height: 100%;
    border: 1px solid var(--line);
    border-radius: 14px;
}

.wrap {
    word-break: break-all;
}

.public-hero,
.public-meta,
.public-card {
    max-width: 980px;
    margin-left: auto;
    margin-right: auto;
}

.is-disabled {
    opacity: 0.45;
    pointer-events: none;
}

.copy-toast {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 80;
    max-width: min(420px, calc(100vw - 32px));
    padding: 12px 14px;
    border-radius: 14px;
    background: #123a32;
    color: #fff;
    box-shadow: 0 18px 50px rgba(44, 31, 18, 0.24);
}

.copy-toast[data-tone="warn"] {
    background: #5c4630;
}

.copy-assist[hidden],
.copy-toast[hidden] {
    display: none;
}

.copy-assist {
    position: fixed;
    inset: 0;
    z-index: 90;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(19, 16, 12, 0.44);
    backdrop-filter: blur(4px);
}

.copy-assist-card {
    width: min(720px, 100%);
    display: grid;
    gap: 16px;
    padding: 22px;
    border-radius: 20px;
    background: var(--panel);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
}

@media (max-width: 1180px) {
    .login-layout,
    .hero-board,
    .public-hero-board,
    .hero-detail-board,
    .insight-grid,
    .workflow-grid,
    .batch-grid,
    .meta-grid,
    .public-meta-grid,
    .login-brand-grid {
        grid-template-columns: 1fr;
    }

    .login-card {
        justify-self: stretch;
        width: 100%;
    }
}

@media (max-width: 980px) {
    .stats-inline {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        row-gap: 12px;
    }

    .inline-stat {
        padding: 8px 16px;
    }

    .inline-stat:nth-child(odd) {
        padding-left: 0;
        border-left: 0;
    }

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

    .section-head-inline,
    .pager-bar,
    .mail-head,
    .row-between,
    .quick-row,
    .mode-strip {
        flex-direction: column;
        align-items: flex-start;
    }

    .mail-side {
        text-align: left;
    }

    .field-inline {
        grid-template-columns: 1fr;
    }

    .field-inline span {
        padding-bottom: 0;
    }

    .history-result-summary,
    .history-lookup-form {
        grid-template-columns: 1fr;
    }

    .history-mail-title h2,
    .history-mail-title .muted {
        white-space: normal;
    }

    .history-redesign {
        padding: 16px 12px 28px;
    }

    .history-redesign .history-compact-hero {
        padding: 22px;
    }

    .history-redesign .history-search-card,
    .history-redesign .history-result-toolbar,
    .history-redesign .history-lookup-form {
        grid-template-columns: 1fr;
    }

    .history-redesign .history-lookup-form .form-actions,
    .history-redesign .history-lookup-form .btn {
        width: 100%;
    }

    .history-redesign .history-result-toolbar,
    .history-preview-head {
        flex-direction: column;
        align-items: stretch;
    }

    .history-result-actions {
        flex-direction: row;
        width: 100%;
        justify-content: flex-start;
        flex-wrap: wrap;
    }

    .history-result-actions > * {
        flex: 1 1 136px;
    }

    .history-redesign .global-view-toggle {
        width: 100%;
    }

    .history-redesign .global-view-toggle .tab-btn {
        flex: 1;
    }

    .history-result-main strong,
    .history-preview-head h2,
    .history-preview-head .muted {
        white-space: normal;
        overflow: visible;
        text-overflow: clip;
        overflow-wrap: anywhere;
    }

    .history-inbox {
        grid-template-columns: 1fr;
        height: auto;
        min-height: 0;
    }

    .history-message-list {
        border-right: 0;
        border-bottom: 1px solid var(--line);
    }

    .history-message-scroll {
        max-height: 330px;
    }

    .history-preview-card {
        min-height: 620px;
    }

    .history-preview-code {
        width: 100%;
    }

    .toolbar-panel,
    .bulk-toolbar,
    .toolbar-cluster,
    .toolbar-actions,
    .imap-create-form,
    .imap-create-actions,
    .account-toolbar,
    .alias-toolbar,
    .bulk-toolbar-main,
    .bulk-toolbar-copy,
    .form-inline-bar,
    .hero-actions,
    .section-actions {
        flex-direction: column;
        align-items: flex-start;
    }

    .imap-create-form .field {
        min-width: 0;
        width: 100%;
    }

    .imap-profile-summary {
        flex-direction: column;
        align-items: flex-start;
    }

    .imap-profile-summary-meta {
        justify-content: flex-start;
        width: 100%;
    }

    .table-wrap {
        border: 0;
        background: transparent;
        overflow: visible;
    }

    .imap-profile-table,
    .account-table,
    .alias-table,
    .imap-profile-table tbody,
    .account-table tbody,
    .alias-table tbody {
        display: grid;
        min-width: 0;
        gap: 12px;
    }

    .imap-profile-table thead,
    .account-table thead,
    .alias-table thead {
        display: none;
    }

    .profile-list-row,
    .account-list-row,
    .alias-row {
        display: grid;
        gap: 12px;
        padding: 18px;
        border: 1px solid var(--line);
        border-radius: 20px;
        background: rgba(255, 255, 255, 0.76);
        box-shadow: var(--shadow);
    }

    .imap-profile-table td,
    .account-table td,
    .alias-table td {
        display: grid;
        grid-template-columns: 92px minmax(0, 1fr);
        gap: 12px;
        padding: 0;
        border: 0;
    }

    .imap-profile-table td::before,
    .account-table td::before,
    .alias-table td::before {
        content: attr(data-label);
        color: var(--muted);
        font-size: 12px;
        text-transform: uppercase;
        letter-spacing: 0.05em;
    }

    .imap-profile-table .col-expand,
    .account-table .col-expand,
    .alias-table .col-check {
        width: auto;
        text-align: left;
    }

    .imap-profile-table .col-expand::before,
    .account-table .col-expand::before,
    .alias-table .col-check::before {
        content: attr(data-label);
    }

    .profile-detail-row,
    .account-detail-row {
        display: block;
    }

    .profile-detail-row td,
    .account-detail-row td {
        display: block;
        padding: 0;
    }

    .profile-detail-row td::before,
    .account-detail-row td::before {
        display: none;
    }

    .accountEmptyStateRow,
    #aliasEmptyState {
        display: block;
    }

    table {
        min-width: 0;
    }
}

@media (max-width: 640px) {
    .stats-inline {
        grid-template-columns: 1fr;
        row-gap: 0;
    }

    .inline-stat,
    .inline-stat:nth-child(odd) {
        padding: 12px 0;
        border-left: 0;
    }

    .inline-stat + .inline-stat {
        border-top: 1px solid var(--line);
    }

    .inline-stat:first-child {
        padding-top: 0;
    }

    .inline-stat:last-child {
        padding-bottom: 0;
    }

    .login-shell,
    .admin-shell,
    .public-shell {
        width: min(100% - 20px, 1420px);
    }

    .login-brand-panel,
    .login-card,
    .hero,
    .public-hero,
    .panel,
    .insight-card,
    .profile-list-row,
    .account-list-row,
    .alias-row {
        padding: 18px;
        border-radius: 20px;
    }

    .hero h1,
    .public-hero h1,
    .login-brand-copy h1 {
        font-size: 30px;
    }

    .login-copy h2 {
        font-size: 28px;
    }

    .btn,
    .btn-small {
        width: 100%;
    }

    .copy-toast {
        right: 10px;
        left: 10px;
        bottom: 10px;
        max-width: none;
    }

    .imap-profile-table td,
    .account-table td,
    .alias-table td {
        grid-template-columns: 1fr;
        gap: 6px;
    }
}
