:root {
    --app-ink: #0f172a;
    --app-muted: #475569;
    --app-line: rgba(15, 23, 42, 0.12);
    --app-card: rgba(255, 255, 255, 0.9);
    --app-card-strong: rgba(255, 255, 255, 0.96);
    --app-shadow: 0 18px 42px -26px rgba(15, 23, 42, 0.45);
    --app-radius: 14px;
    --app-radius-sm: 10px;

    --pico-font-family: "Sora", "Segoe UI", "Trebuchet MS", sans-serif;
    --pico-background-color: transparent;
    --pico-color: var(--app-ink);
    --pico-muted-color: var(--app-muted);
    --pico-card-background-color: var(--app-card);
    --pico-card-border-color: var(--app-line);
    --pico-form-element-background-color: rgba(255, 255, 255, 0.94);
    --pico-form-element-border-color: rgba(14, 165, 233, 0.28);
    --pico-form-element-focus-color: rgba(14, 165, 233, 0.45);

    --pico-primary: #0284c7;
    --pico-primary-hover: #0369a1;
    --pico-primary-focus: rgba(2, 132, 199, 0.3);
    --pico-secondary: #f97316;
    --pico-secondary-hover: #ea580c;
}

* {
    box-sizing: border-box;
}

body {
    color: var(--app-ink);
    min-height: 100vh;
    background:
        radial-gradient(circle at 10% 8%, rgba(56, 189, 248, 0.2) 0, rgba(56, 189, 248, 0) 40%),
        radial-gradient(circle at 88% 14%, rgba(249, 115, 22, 0.22) 0, rgba(249, 115, 22, 0) 42%),
        linear-gradient(180deg, #e6f7ff 0%, #f5fbff 35%, #f8fafc 100%);
}

h1, h2, h3, nav strong {
    font-family: "Syne", "Sora", sans-serif;
    letter-spacing: 0.01em;
}

main.container {
    background: var(--app-card);
    border: 1px solid var(--app-line);
    border-radius: calc(var(--app-radius) + 2px);
    box-shadow: var(--app-shadow);
    padding: clamp(0.9rem, 1.2vw + 0.7rem, 1.4rem);
    margin-top: 1rem;
    margin-bottom: 1.5rem;
    backdrop-filter: blur(4px);
}

/* Nav */
nav.container-fluid {
    background: linear-gradient(90deg, #0f172a 0%, #0f3a5f 45%, #124f69 100%);
    border-bottom: 1px solid rgba(255, 255, 255, 0.18);
    box-shadow: 0 10px 28px -22px rgba(2, 6, 23, 0.9);
    margin-bottom: 0;
}

nav.container-fluid a,
nav.container-fluid strong,
nav.container-fluid li {
    color: #e6f6ff;
}

nav .active {
    background: rgba(249, 115, 22, 0.2);
    border: 1px solid rgba(249, 115, 22, 0.55);
    border-radius: 999px;
    font-weight: 700;
    padding: 0.26rem 0.72rem;
    text-decoration: none;
}

/* Buttons */
button,
[type="submit"],
[role="button"] {
    border-radius: 999px;
    border: 0;
    font-weight: 600;
    box-shadow: 0 8px 18px -16px rgba(14, 23, 42, 0.8);
}

button:not(.secondary),
[type="submit"]:not(.secondary),
[role="button"]:not(.secondary) {
    background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
}

.secondary {
    background: linear-gradient(135deg, #f97316 0%, #ea580c 100%);
    color: #fff;
}

/* Login card */
.login-card {
    max-width: 430px;
    margin: 3.5rem auto;
    background: var(--app-card-strong);
    border: 1px solid var(--app-line);
    border-radius: calc(var(--app-radius) + 4px);
    box-shadow: var(--app-shadow);
    padding: 1.35rem;
}

/* Flash messages */
.flash {
    padding: 0.8rem 1rem;
    border-radius: var(--app-radius-sm);
    margin-bottom: 1rem;
    font-size: 0.9rem;
    border: 1px solid transparent;
    box-shadow: 0 8px 24px -24px rgba(0, 0, 0, 0.45);
}

.flash-success {
    background: rgba(34, 197, 94, 0.13);
    color: #166534;
    border-color: rgba(34, 197, 94, 0.3);
}

.flash-error {
    background: rgba(239, 68, 68, 0.12);
    color: #991b1b;
    border-color: rgba(239, 68, 68, 0.28);
}

.flash-info {
    background: rgba(14, 165, 233, 0.14);
    color: #0c4a6e;
    border-color: rgba(14, 165, 233, 0.32);
}

/* Inbox header */
.inbox-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
    padding: 0.85rem 0.95rem;
    border: 1px solid rgba(2, 132, 199, 0.18);
    border-radius: var(--app-radius);
    background: linear-gradient(130deg, rgba(2, 132, 199, 0.08) 0%, rgba(249, 115, 22, 0.08) 100%);
}

.inbox-header h2 {
    margin: 0;
}

.message-count {
    color: var(--app-muted);
    font-size: 0.9rem;
}

.filter-input {
    margin-left: auto;
    max-width: 340px;
    margin-bottom: 0;
}

.mobile-sort-controls {
    display: none;
}

/* Table */
.table-wrap {
    overflow-x: auto;
}

.inbox-table,
.scan-results-table,
.rules-table,
.log-table {
    width: 100%;
    font-size: 0.8rem;
    border-collapse: separate;
    border-spacing: 0;
    border: 1px solid var(--app-line);
    border-radius: var(--app-radius);
    background: var(--app-card-strong);
    overflow: hidden;
}

.inbox-table thead th,
.scan-results-table thead th,
.rules-table thead th,
.log-table thead th {
    background: linear-gradient(180deg, rgba(14, 165, 233, 0.14) 0%, rgba(2, 132, 199, 0.08) 100%);
    color: #0c4a6e;
    border-bottom: 1px solid rgba(14, 165, 233, 0.25);
}

.inbox-table thead th {
    position: sticky;
    top: 0;
    z-index: 5;
}

.inbox-table th,
.inbox-table td,
.scan-results-table th,
.scan-results-table td,
.rules-table th,
.rules-table td,
.log-table th,
.log-table td {
    padding: 0.48rem 0.64rem;
    vertical-align: top;
    white-space: nowrap;
    border-bottom: 1px solid rgba(15, 23, 42, 0.06);
}

.inbox-table tbody tr:last-child td,
.scan-results-table tbody tr:last-child td,
.rules-table tbody tr:last-child td,
.log-table tbody tr:last-child td {
    border-bottom: 0;
}

.inbox-table tbody tr:nth-child(even):not(.group-row) {
    background: rgba(148, 163, 184, 0.07);
}

.inbox-table th .sort-btn {
    all: unset;
    cursor: pointer;
    color: inherit;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.inbox-table th .sort-btn:hover {
    text-decoration: underline;
}

.inbox-table .col-subject {
    white-space: normal;
    max-width: 520px;
    word-break: break-word;
}

.inbox-table .col-receivers {
    white-space: normal;
    max-width: 230px;
}

.inbox-table .col-fromto {
    white-space: normal;
    max-width: 300px;
    min-width: 230px;
}

.inbox-table .col-fromto .from-line,
.inbox-table .col-fromto .to-line {
    display: block;
    line-height: 1.3;
}

.inbox-table .col-fromto .to-line {
    color: var(--app-muted);
    font-size: 0.76rem;
    margin-top: 0.15rem;
}

.th-cb {
    width: 2.1rem;
    text-align: center;
}

.th-read {
    width: 4.2rem;
    text-align: center;
}

.cb-col-title {
    display: block;
    font-size: 0.67rem;
    line-height: 1;
    color: var(--app-muted);
    margin-bottom: 0.2rem;
    font-weight: 700;
}

.empty-inbox {
    text-align: center;
    color: var(--app-muted);
    padding: 2rem !important;
}

.group-row {
    background: linear-gradient(90deg, rgba(14, 165, 233, 0.12) 0%, rgba(249, 115, 22, 0.12) 100%);
    border-top: 2px solid rgba(14, 165, 233, 0.34);
}

.grouped-row {
    background: rgba(255, 255, 255, 0.92);
}

.group-toggle {
    all: unset;
    cursor: pointer;
    color: #0c4a6e;
    font-weight: 700;
}

.group-toggle:hover {
    text-decoration: underline;
}

.group-count {
    margin-left: 0.5rem;
    color: var(--app-muted);
    font-size: 0.8rem;
}

.group-child.group-collapsed {
    display: none;
}

.col-read {
    text-align: center;
    white-space: nowrap;
}

.btn-read-row {
    display: inline-block;
    border: 1px solid rgba(14, 165, 233, 0.28);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.92);
    color: #0c4a6e;
    padding: 0.18rem 0.56rem;
    font-size: 0.7rem;
    font-weight: 700;
    line-height: 1.15;
    text-decoration: none;
}

.btn-read-row:hover {
    border-color: rgba(3, 105, 161, 0.5);
    color: #075985;
}

.no-read {
    color: var(--app-muted);
    font-style: italic;
    font-size: 0.72rem;
}

/* Receiver toggle */
.receiver-toggle {
    cursor: pointer;
    color: #0369a1;
    text-decoration: underline;
    text-decoration-style: dotted;
}

.receiver-list {
    font-size: 0.82rem;
    color: var(--app-muted);
    word-break: break-all;
}

.no-receivers {
    color: var(--app-muted);
    font-style: italic;
}

/* Bulk actions bar */
.bulk-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.82rem 0.15rem;
    margin-top: 0.7rem;
    border-top: 1px solid var(--app-line);
}

.bulk-actions button {
    margin-bottom: 0;
    padding: 0.45rem 1.05rem;
    font-size: 0.85rem;
}

.btn-forward {
    background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
}

.btn-delete {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
}

#selected-count {
    font-size: 0.88rem;
    color: var(--app-muted);
}

/* Row highlighting for spam */
tr.spam-flagged {
    background: rgba(239, 68, 68, 0.12);
}

tr.spam-learned {
    background: rgba(251, 191, 36, 0.16);
}

/* Spam section */
.spam-section {
    margin-bottom: 1.2rem;
    padding: 0.75rem;
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: var(--app-radius);
    background: rgba(239, 68, 68, 0.06);
}

.spam-section-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.6rem;
}

.spam-section-header h3 {
    margin: 0;
    color: #dc2626;
}

.spam-section-header .btn-delete {
    margin-left: auto;
    margin-bottom: 0;
    padding: 0.3rem 0.8rem;
    font-size: 0.75rem;
}

.spam-table {
    border-color: rgba(239, 68, 68, 0.25);
}

.spam-row:hover {
    background: rgba(239, 68, 68, 0.1);
}

.spam-count {
    font-weight: 700;
    text-align: center;
}

.col-reason {
    color: var(--app-muted);
    font-size: 0.72rem;
    white-space: normal;
    max-width: 300px;
}

.spam-badge {
    background: rgba(239, 68, 68, 0.15);
    color: #dc2626;
    padding: 0.12rem 0.48rem;
    border-radius: 999px;
    font-weight: 700;
    font-size: 0.72rem;
}

.clean-section-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.6rem;
}

.clean-section-header h3 {
    margin: 0;
}

/* Hide rows when filtering */
tr.filter-hidden {
    display: none;
}

/* Inbox pagination */
.pager {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin: 0.82rem 0;
    padding: 0.5rem 0.15rem;
}

.pager-info {
    color: var(--app-muted);
    font-size: 0.9rem;
}

.pager-disabled {
    color: var(--app-muted);
    opacity: 0.7;
}

/* Read message page */
.mail-read-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.9rem;
    flex-wrap: wrap;
}

.mail-read-head h2 {
    margin: 0;
}

.mail-read-card,
.mail-read-body-wrap {
    border: 1px solid rgba(14, 165, 233, 0.2);
    border-radius: var(--app-radius);
    background: rgba(255, 255, 255, 0.95);
    padding: 0.9rem;
    margin-bottom: 0.82rem;
}

.mail-read-meta {
    font-size: 0.88rem;
    margin-bottom: 0.4rem;
    word-break: break-word;
}

.mail-read-meta:last-child {
    margin-bottom: 0;
}

.mail-read-format {
    color: var(--app-muted);
    font-size: 0.78rem;
}

.mail-read-body {
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 0.82rem;
    line-height: 1.45;
    color: #0f172a;
    background: rgba(248, 250, 252, 0.92);
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 10px;
    padding: 0.8rem;
    max-height: 70vh;
    overflow: auto;
}

/* Scan page */
.scan-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.scan-controls button {
    margin-bottom: 0;
}

.dry-run-label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-bottom: 0;
    font-size: 0.9rem;
}

.dry-run-label input {
    margin: 0;
}

.scan-summary {
    margin: 1rem 0;
    padding: 1rem;
    background: linear-gradient(140deg, rgba(14, 165, 233, 0.1) 0%, rgba(249, 115, 22, 0.1) 100%);
    border: 1px solid rgba(14, 165, 233, 0.2);
    border-radius: var(--app-radius);
}

.badge-dryrun {
    display: inline-block;
    background: linear-gradient(135deg, #facc15 0%, #f59e0b 100%);
    color: #422006;
    padding: 0.15rem 0.55rem;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 700;
}

.newly-learned {
    margin-top: 0.75rem;
    padding: 0.58rem 0.78rem;
    background: rgba(34, 197, 94, 0.14);
    border-radius: var(--app-radius-sm);
    border: 1px solid rgba(34, 197, 94, 0.2);
    font-size: 0.9rem;
}

.newly-learned ul {
    margin: 0.25rem 0 0 1.5rem;
    padding: 0;
}

.scan-results-table {
    margin-top: 0.55rem;
}

/* Rules page */
.rule-section {
    margin-top: 1.05rem;
    padding: 1rem;
    border: 1px solid rgba(14, 165, 233, 0.18);
    border-radius: var(--app-radius);
    background: linear-gradient(160deg, rgba(255, 255, 255, 0.96) 0%, rgba(247, 250, 252, 0.96) 100%);
}

.rule-section h3 {
    margin-top: 0;
}

.rule-form label {
    margin-bottom: 0.75rem;
}

.inline-add-form {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 0.75rem;
}

.inline-add-form input[type="text"] {
    min-width: 280px;
    flex: 1;
}

.rules-table {
    width: 100%;
}

.actions-col {
    width: 140px;
    text-align: right;
}

.inline-action-form {
    display: inline;
}

.inline-action-form button {
    margin: 0;
    padding: 0.3rem 0.72rem;
}

/* Log page */
.log-filter-form {
    display: flex;
    gap: 0.75rem;
    align-items: end;
    flex-wrap: wrap;
    margin-bottom: 1rem;
    padding: 0.85rem 0.95rem;
    border: 1px solid rgba(249, 115, 22, 0.22);
    border-radius: var(--app-radius);
    background: linear-gradient(135deg, rgba(249, 115, 22, 0.09) 0%, rgba(14, 165, 233, 0.09) 100%);
}

.log-filter-form label {
    margin-bottom: 0;
    min-width: 180px;
}

.log-table th,
.log-table td {
    vertical-align: top;
}

.log-details {
    white-space: normal;
    word-break: break-word;
    min-width: 360px;
}

@media (max-width: 900px) {
    main.container {
        padding: 0.85rem;
    }

    .filter-input {
        margin-left: 0;
        max-width: none;
        width: 100%;
    }

    .bulk-actions {
        flex-wrap: wrap;
    }

    .log-details {
        min-width: 240px;
    }
}

@media (max-width: 700px) {
    .mobile-sort-controls {
        display: flex;
        flex-wrap: wrap;
        gap: 0.38rem;
        margin: 0 0 0.72rem;
    }

    .mobile-sort-controls .sort-btn {
        all: unset;
        border: 1px solid rgba(14, 165, 233, 0.28);
        border-radius: 999px;
        background: rgba(255, 255, 255, 0.92);
        color: #0c4a6e;
        padding: 0.3rem 0.62rem;
        font-size: 0.74rem;
        font-weight: 700;
        line-height: 1;
        cursor: pointer;
        white-space: nowrap;
    }

    .inbox-header {
        display: grid;
        gap: 0.4rem;
        padding: 0.72rem 0.78rem;
    }

    .inbox-header h2 {
        font-size: 1.02rem;
    }

    .message-count {
        font-size: 0.74rem;
        line-height: 1.25;
    }

    .inbox-header .filter-input {
        margin-left: 0;
        width: 100%;
    }

    #inbox-form .table-wrap {
        overflow-x: visible;
    }

    #inbox-form .inbox-table {
        border: 0;
        background: transparent;
        border-radius: 0;
    }

    #inbox-form .inbox-table thead {
        display: none;
    }

    #inbox-form .inbox-table tbody {
        display: block;
    }

    #inbox-form .inbox-table tr[data-record-id] {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 0.38rem 0.62rem;
        margin: 0 0 0.64rem;
        padding: 0.62rem 0.66rem;
        border: 1px solid rgba(14, 165, 233, 0.22);
        border-radius: 12px;
        background: rgba(255, 255, 255, 0.95);
    }

    #inbox-form .inbox-table tr.group-row {
        background: linear-gradient(100deg, rgba(14, 165, 233, 0.17) 0%, rgba(249, 115, 22, 0.17) 100%);
        border-color: rgba(14, 165, 233, 0.38);
    }

    #inbox-form .inbox-table tr.group-child {
        background: rgba(255, 255, 255, 0.9);
        border-color: rgba(148, 163, 184, 0.34);
    }

    #inbox-form .inbox-table tr.group-child.group-collapsed,
    #inbox-form .inbox-table tr.filter-hidden {
        display: none !important;
    }

    #inbox-form .inbox-table td {
        padding: 0;
        border: 0;
        white-space: normal;
        min-width: 0;
    }

    #inbox-form .inbox-table td:nth-child(1) {
        grid-column: 1;
    }

    #inbox-form .inbox-table td:nth-child(2) {
        grid-column: 2;
    }

    #inbox-form .inbox-table td:nth-child(3) {
        grid-column: 3;
        justify-self: end;
        text-align: right;
    }

    #inbox-form .inbox-table td:nth-child(4) {
        grid-column: 1 / -1;
    }

    #inbox-form .inbox-table td:nth-child(5) {
        grid-column: 1 / -1;
    }

    #inbox-form .inbox-table td:nth-child(6) {
        grid-column: 1 / span 2;
    }

    #inbox-form .inbox-table td:nth-child(7) {
        grid-column: 3;
        text-align: right;
    }

    #inbox-form .inbox-table td:nth-child(1)::before,
    #inbox-form .inbox-table td:nth-child(2)::before,
    #inbox-form .inbox-table td:nth-child(3)::before,
    #inbox-form .inbox-table td:nth-child(4)::before,
    #inbox-form .inbox-table td:nth-child(5)::before,
    #inbox-form .inbox-table td:nth-child(6)::before,
    #inbox-form .inbox-table td:nth-child(7)::before {
        display: block;
        font-size: 0.62rem;
        line-height: 1;
        font-weight: 700;
        letter-spacing: 0.03em;
        text-transform: uppercase;
        color: rgba(71, 85, 105, 0.9);
        margin-bottom: 0.2rem;
    }

    #inbox-form .inbox-table td:nth-child(1)::before { content: "Fwd"; }
    #inbox-form .inbox-table td:nth-child(2)::before { content: "Del"; }
    #inbox-form .inbox-table td:nth-child(3)::before { content: "Read"; }
    #inbox-form .inbox-table td:nth-child(4)::before { content: "From / To"; }
    #inbox-form .inbox-table td:nth-child(5)::before { content: "Subject"; }
    #inbox-form .inbox-table td:nth-child(6)::before { content: "Receivers"; }
    #inbox-form .inbox-table td:nth-child(7)::before { content: "Date"; }

    #inbox-form .inbox-table td:nth-child(1) input,
    #inbox-form .inbox-table td:nth-child(2) input {
        margin: 0;
        transform: scale(1.03);
    }

    #inbox-form .inbox-table .col-read .btn-read-row {
        width: auto;
        padding: 0.18rem 0.54rem;
        font-size: 0.67rem;
    }

    #inbox-form .inbox-table .col-fromto {
        max-width: none;
        min-width: 0;
        font-size: 0.73rem;
        line-height: 1.28;
    }

    #inbox-form .inbox-table .col-fromto .to-line {
        font-size: 0.71rem;
    }

    #inbox-form .inbox-table .col-subject {
        max-width: none;
        font-size: 0.78rem;
        line-height: 1.32;
    }

    #inbox-form .inbox-table .col-receivers,
    #inbox-form .inbox-table .col-date {
        font-size: 0.71rem;
    }

    #inbox-form .inbox-table .receiver-toggle,
    #inbox-form .inbox-table .receiver-list {
        font-size: 0.71rem;
    }

    #inbox-form .group-toggle {
        font-size: 0.79rem;
        line-height: 1.2;
    }

    #inbox-form .group-count {
        font-size: 0.71rem;
    }

    #inbox-form .bulk-actions {
        position: sticky;
        bottom: 0.4rem;
        z-index: 9;
        border: 1px solid rgba(14, 165, 233, 0.2);
        border-radius: 12px;
        background: rgba(255, 255, 255, 0.96);
        backdrop-filter: blur(4px);
        padding: 0.58rem 0.62rem;
        gap: 0.5rem;
        margin-top: 0.5rem;
    }

    #inbox-form #selected-count {
        flex: 1 1 100%;
        font-size: 0.74rem;
    }

    #inbox-form .bulk-actions button {
        flex: 1 1 calc(50% - 0.35rem);
        font-size: 0.75rem;
        padding: 0.44rem 0.5rem;
    }
}

/* Compact clean sci-fi pass */
html {
    font-size: 14px;
}

:root {
    --app-ink: #0b2331;
    --app-muted: #45687a;
    --app-line: rgba(0, 140, 170, 0.22);
    --app-card: rgba(246, 252, 255, 0.9);
    --app-card-strong: rgba(251, 254, 255, 0.95);
    --app-shadow: 0 14px 36px -30px rgba(0, 62, 84, 0.65);
    --app-radius: 10px;
    --app-radius-sm: 7px;

    --pico-font-family: "Space Grotesk", "Segoe UI", "Trebuchet MS", sans-serif;
    --pico-primary: #008ea8;
    --pico-primary-hover: #00768d;
    --pico-primary-focus: rgba(0, 142, 168, 0.26);
    --pico-secondary: #00b4d8;
    --pico-secondary-hover: #009fc0;
}

body {
    background:
        linear-gradient(rgba(0, 142, 168, 0.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 142, 168, 0.04) 1px, transparent 1px),
        radial-gradient(circle at 84% 8%, rgba(0, 180, 216, 0.12) 0, rgba(0, 180, 216, 0) 34%),
        radial-gradient(circle at 10% 90%, rgba(0, 142, 168, 0.12) 0, rgba(0, 142, 168, 0) 36%),
        linear-gradient(180deg, #f0f8fc 0%, #f7fcff 100%);
    background-size: 22px 22px, 22px 22px, auto, auto, auto;
}

h1, h2, h3, nav strong {
    font-family: "Orbitron", "Space Grotesk", sans-serif;
    letter-spacing: 0.04em;
}

main.container {
    max-width: 1240px;
    padding: 0.75rem 0.85rem;
    margin-top: 0.65rem;
    margin-bottom: 0.95rem;
}

nav.container-fluid {
    min-height: 48px;
    background: linear-gradient(90deg, #062230 0%, #093446 52%, #0a475d 100%);
    border-bottom: 1px solid rgba(0, 198, 230, 0.28);
}

nav.container-fluid ul {
    gap: 0.45rem;
}

nav.container-fluid a {
    font-size: 0.77rem;
    letter-spacing: 0.02em;
}

nav .active {
    background: rgba(0, 198, 230, 0.14);
    border-color: rgba(0, 198, 230, 0.42);
    padding: 0.2rem 0.6rem;
}

button,
[type="submit"],
[role="button"] {
    border-radius: 999px;
    padding: 0.34rem 0.82rem;
    font-size: 0.75rem;
    line-height: 1.2;
    box-shadow: 0 8px 20px -18px rgba(0, 52, 72, 0.85);
}

button:not(.secondary),
[type="submit"]:not(.secondary),
[role="button"]:not(.secondary) {
    background: linear-gradient(135deg, #008ea8 0%, #00768d 100%);
}

.secondary {
    background: linear-gradient(135deg, #00a6c4 0%, #0089a3 100%);
}

input,
select,
textarea {
    font-size: 0.77rem;
    min-height: 2rem;
    padding: 0.3rem 0.5rem;
    border-radius: 8px;
}

.login-card {
    max-width: 370px;
    margin: 2.2rem auto;
    padding: 0.95rem;
}

.flash {
    padding: 0.56rem 0.75rem;
    margin-bottom: 0.72rem;
    font-size: 0.77rem;
}

.inbox-header {
    margin-bottom: 0.68rem;
    gap: 0.5rem;
    padding: 0.58rem 0.7rem;
    background: linear-gradient(130deg, rgba(0, 142, 168, 0.08) 0%, rgba(0, 180, 216, 0.08) 100%);
}

.inbox-header h2 {
    font-size: 1.03rem;
    letter-spacing: 0.05em;
}

.message-count {
    font-size: 0.74rem;
}

.filter-input {
    max-width: 260px;
}

.inbox-table,
.scan-results-table,
.rules-table,
.log-table {
    font-size: 0.73rem;
    border-radius: 9px;
}

.inbox-table thead th,
.scan-results-table thead th,
.rules-table thead th,
.log-table thead th {
    background: linear-gradient(180deg, rgba(0, 180, 216, 0.18) 0%, rgba(0, 142, 168, 0.1) 100%);
    color: #08475e;
}

.inbox-table th,
.inbox-table td,
.scan-results-table th,
.scan-results-table td,
.rules-table th,
.rules-table td,
.log-table th,
.log-table td {
    padding: 0.34rem 0.46rem;
}

.inbox-table .col-subject {
    max-width: 430px;
}

.inbox-table .col-receivers {
    max-width: 200px;
}

.inbox-table .col-fromto {
    max-width: 260px;
    min-width: 200px;
}

.inbox-table .col-fromto .to-line {
    font-size: 0.69rem;
}

.cb-col-title {
    font-size: 0.6rem;
}

.th-cb {
    width: 1.8rem;
}

.th-read {
    width: 3.8rem;
}

.btn-read-row {
    padding: 0.13rem 0.48rem;
    font-size: 0.64rem;
}

.group-row {
    background: linear-gradient(90deg, rgba(0, 142, 168, 0.12) 0%, rgba(0, 180, 216, 0.12) 100%);
    border-top: 1px solid rgba(0, 142, 168, 0.34);
}

.group-count {
    font-size: 0.73rem;
}

.receiver-list {
    font-size: 0.72rem;
}

.bulk-actions {
    gap: 0.7rem;
    padding: 0.58rem 0.12rem;
    margin-top: 0.54rem;
}

.bulk-actions button {
    padding: 0.34rem 0.78rem;
    font-size: 0.72rem;
}

#selected-count {
    font-size: 0.75rem;
}

.pager {
    margin: 0.6rem 0;
    padding: 0.35rem 0.12rem;
}

.pager-info {
    font-size: 0.74rem;
}

.mail-read-card,
.mail-read-body-wrap,
.rule-section,
.scan-summary {
    padding: 0.7rem;
    border-radius: 9px;
}

.mail-read-meta,
.mail-read-body,
.dry-run-label,
.newly-learned,
.log-details {
    font-size: 0.75rem;
}

.mail-read-body {
    padding: 0.62rem;
}

.scan-controls {
    margin-bottom: 0.7rem;
    gap: 0.65rem;
}

.badge-dryrun {
    font-size: 0.67rem;
    padding: 0.1rem 0.44rem;
}

.inline-add-form {
    gap: 0.34rem;
    margin-bottom: 0.58rem;
}

.inline-add-form input[type="text"] {
    min-width: 210px;
}

.actions-col {
    width: 112px;
}

.inline-action-form button {
    padding: 0.2rem 0.54rem;
}

.log-filter-form {
    gap: 0.55rem;
    margin-bottom: 0.72rem;
    padding: 0.62rem 0.7rem;
    background: linear-gradient(135deg, rgba(0, 180, 216, 0.08) 0%, rgba(0, 142, 168, 0.08) 100%);
    border: 1px solid rgba(0, 142, 168, 0.24);
}

.log-filter-form label {
    min-width: 150px;
}

@media (max-width: 900px) {
    html {
        font-size: 13px;
    }

    main.container {
        padding: 0.7rem;
    }
}

@media (max-width: 700px) {
    html {
        font-size: 12.5px;
    }

    .mobile-sort-controls .sort-btn {
        font-size: 0.68rem;
        padding: 0.26rem 0.54rem;
    }

    #inbox-form .inbox-table tr[data-record-id] {
        margin: 0 0 0.5rem;
        padding: 0.5rem 0.56rem;
    }

    #inbox-form .bulk-actions {
        padding: 0.48rem 0.52rem;
    }
}

/* Typography bump */
html {
    font-size: 17px;
}

@media (max-width: 900px) {
    html {
        font-size: 16px;
    }
}

@media (max-width: 700px) {
    html {
        font-size: 15px;
    }
}
