@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;500;600&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg: #090909;
    --bg-elevated: #111111;
    --bg-card: #141414;
    --bg-input: #1a1a1a;
    --border: #222222;
    --border-light: #2a2a2a;
    --text: #ececec;
    --text-muted: #888888;
    --text-dim: #555555;
    --accent: #e8e8e8;
    --accent-hover: #ffffff;
    --green: #3dd68c;
    --red: #f07178;
    --radius: 10px;
    --sidebar-w: 220px;
    --font: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, sans-serif;
}

html { font-size: 15px; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

/* ── Login ── */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
}

.login-card {
    width: 100%;
    max-width: 380px;
    padding: 2.5rem 2rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 14px;
}

.login-logo {
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

.login-card h1 {
    font-size: 1.35rem;
    font-weight: 600;
    margin-bottom: 0.35rem;
}

.login-sub {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 1.75rem;
}

.login-form label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.4rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.login-form input {
    width: 100%;
    padding: 0.7rem 0.85rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-family: var(--font);
    font-size: 0.95rem;
    margin-bottom: 1.25rem;
    outline: none;
    transition: border-color 0.15s;
}

.login-form input:focus { border-color: var(--border-light); }

.login-lang {
    text-align: center;
    margin-top: 1.5rem;
    font-size: 0.85rem;
    color: var(--text-dim);
}

.login-lang a { color: var(--text-muted); transition: color 0.15s; }
.login-lang a.active, .login-lang a:hover { color: var(--text); }

/* ── Layout ── */
.app {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-w);
    background: var(--bg);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 1.25rem 0;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 10;
    overflow-y: auto;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0 1.25rem 1.5rem;
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-muted);
}

.sidebar-nav {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 0 0.65rem;
}

.sidebar-bottom {
    padding: 0 0.65rem;
    border-top: 1px solid var(--border);
    padding-top: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.6rem 0.75rem;
    border-radius: 8px;
    font-size: 0.88rem;
    color: var(--text-muted);
    transition: background 0.12s, color 0.12s;
}

.nav-item svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.nav-item:hover { background: var(--bg-elevated); color: var(--text); }
.nav-item.active { background: var(--bg-elevated); color: var(--text); }
.nav-logout { color: var(--text-dim); }
.nav-logout:hover { color: var(--red); }

.main {
    flex: 1;
    margin-left: var(--sidebar-w);
    padding: 2rem 2.5rem;
    max-width: 1200px;
}

/* ── Page header ── */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 1.75rem;
    gap: 1rem;
}

.page-header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.page-sub {
    color: var(--text-muted);
    font-size: 0.88rem;
    margin-top: 0.25rem;
}

.scanner-badge {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    padding: 0.4rem 0.75rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 20px;
    white-space: nowrap;
}

.scanner-badge .dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--text-dim);
}

.scanner-badge.active .dot {
    background: var(--green);
    box-shadow: 0 0 6px var(--green);
}

.scanner-badge.disabled .dot {
    background: var(--red, #e5484d);
    box-shadow: none;
}

.scanner-badge.disabled {
    color: var(--text-muted);
}

.sidebar-scanner {
    padding: 0.75rem 1rem 0.5rem;
    border-bottom: 1px solid var(--border);
}

.sidebar-scanner .scanner-badge {
    margin-bottom: 0.5rem;
    width: 100%;
    box-sizing: border-box;
}

.scanner-toggle-btn.btn-block {
    width: 100%;
    justify-content: center;
}

.scanner-control-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

/* ── Stats ── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 600;
    letter-spacing: -0.03em;
}

.stat-value.stat-sm { font-size: 1rem; font-weight: 500; }

.stat-label {
    color: var(--text-muted);
    font-size: 0.82rem;
    margin-top: 0.25rem;
}

.accounts-stats {
    grid-template-columns: repeat(4, 1fr);
}

.stat-card.stat-ok .stat-value { color: var(--green); }
.stat-card.stat-error .stat-value { color: var(--red); }
.stat-card.stat-pending .stat-value { color: #ffc107; }

.stat-card.stat-link { padding: 0; }
.stat-card.stat-link .stat-link-inner {
    display: block;
    padding: 1.25rem 1.5rem;
    color: inherit;
    text-decoration: none;
    border-radius: var(--radius);
    transition: background 0.15s;
}
.stat-card.stat-link:hover .stat-link-inner { background: rgba(255, 255, 255, 0.03); }

.status-pill-action[data-recheck="1"] {
    cursor: pointer;
    text-decoration: underline dotted;
    text-underline-offset: 2px;
}
.status-pill-action.loading { opacity: 0.6; pointer-events: none; }

.btn-danger-ghost {
    color: var(--red) !important;
    border-color: rgba(240, 113, 120, 0.35) !important;
}
.btn-danger-ghost:hover {
    background: rgba(240, 113, 120, 0.1) !important;
}

@media (max-width: 900px) {
    .accounts-stats { grid-template-columns: repeat(2, 1fr); }
}

/* ── Cards ── */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
}

.card-header {
    margin-bottom: 1rem;
}

.card h2 {
    font-size: 1rem;
    font-weight: 600;
}

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

.empty-state {
    text-align: center;
    padding: 2.5rem;
    color: var(--text-dim);
    font-size: 0.9rem;
}

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

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

.data-table th {
    text-align: left;
    padding: 0.6rem 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid var(--border);
}

.data-table td {
    padding: 0.75rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.data-table tr:last-child td { border-bottom: none; }

.cell-from { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell-date { color: var(--text-muted); white-space: nowrap; font-size: 0.82rem; }
.cell-muted { color: var(--text-muted); }
.cell-actions { display: flex; gap: 0.25rem; }

.kw-badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    background: var(--bg-input);
    border-radius: 4px;
    font-size: 0.78rem;
    color: var(--text-muted);
}

.status-pill {
    display: inline-block;
    padding: 0.15rem 0.55rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
}

.status-pill.on { background: rgba(61, 214, 140, 0.12); color: var(--green); }
.status-pill.off { background: rgba(240, 113, 120, 0.12); color: var(--red); }
.status-pill.pending { background: rgba(255, 193, 7, 0.12); color: #ffc107; }
.status-pill.unknown { background: rgba(136, 136, 136, 0.12); color: var(--text-muted); }

.acc-email { font-weight: 500; }
.acc-label { font-size: 0.78rem; color: var(--text-muted); margin-top: 0.1rem; }
.acc-host { font-size: 0.75rem; margin-top: 0.15rem; }
.cell-stat { font-variant-numeric: tabular-nums; font-weight: 500; }

.connection-result {
    padding: 0.65rem 0.85rem;
    border-radius: 8px;
    font-size: 0.85rem;
    margin-bottom: 1rem;
}

.connection-result.ok {
    background: rgba(61, 214, 140, 0.1);
    border: 1px solid rgba(61, 214, 140, 0.25);
    color: var(--green);
}

.connection-result.error {
    background: rgba(240, 113, 120, 0.1);
    border: 1px solid rgba(240, 113, 120, 0.25);
    color: var(--red);
}

.connection-result.loading {
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-muted);
}

.header-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-shrink: 0;
}

.btn-upload {
    cursor: pointer;
    position: relative;
}

.file-input-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.import-result:not([hidden]) {
    display: block;
}

.btn-sm {
    padding: 0.4rem 0.7rem;
    font-size: 0.8rem;
}

.import-hint {
    color: var(--text-dim);
    font-size: 0.78rem;
    margin: -0.75rem 0 1rem;
}

.import-result {
    padding: 0.75rem 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.85rem;
    margin-bottom: 1rem;
    line-height: 1.6;
}

.import-result .ok { color: var(--green); }
.import-result .err { color: var(--red); }
.import-result .muted { color: var(--text-muted); }

.kw-toolbar {
    margin-bottom: 0.75rem;
}


/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.55rem 1rem;
    border: none;
    border-radius: 8px;
    font-family: var(--font);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.12s, opacity 0.12s;
}

.btn svg { width: 16px; height: 16px; }

.btn-primary {
    background: var(--accent);
    color: var(--bg);
}

.btn-primary:hover { background: var(--accent-hover); }

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.btn-ghost:hover { color: var(--text); border-color: var(--border-light); }

.btn-full { width: 100%; justify-content: center; }

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    border-radius: 6px;
    color: var(--text-dim);
    cursor: pointer;
    transition: background 0.12s, color 0.12s;
}

.btn-icon svg { width: 16px; height: 16px; }
.btn-icon:hover { background: var(--bg-input); color: var(--text); }

/* ── Keywords ── */
.keywords-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
}

.kw-panel { padding: 1.75rem; }

.kw-panel-head h2 {
    font-size: 1.05rem;
    font-weight: 600;
    margin-bottom: 0.3rem;
}

.kw-panel-head p {
    color: var(--text-muted);
    font-size: 0.82rem;
    margin-bottom: 1.25rem;
}

.kw-add-form {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
}

.kw-add-form input {
    flex: 1;
    padding: 0.6rem 0.85rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-family: var(--font);
    font-size: 0.88rem;
    outline: none;
}

.kw-add-form input:focus { border-color: var(--border-light); }

.kw-add-form .btn-add-kw {
    white-space: nowrap;
    padding: 0.6rem 0.85rem;
}

.kw-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.kw-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.6rem 0.35rem 0.5rem;
    background: transparent;
    border: none;
    font-family: var(--font);
    font-size: 0.85rem;
    color: var(--text);
    cursor: default;
}

.kw-tag svg {
    width: 14px;
    height: 14px;
    color: var(--text-muted);
    flex-shrink: 0;
}

.kw-tag.ignore svg { color: var(--text-dim); }

.kw-remove {
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 1rem;
    cursor: pointer;
    padding: 0 0.15rem;
    line-height: 1;
    opacity: 0;
    transition: opacity 0.12s, color 0.12s;
}

.kw-tag:hover .kw-remove { opacity: 1; }
.kw-remove:hover { color: var(--red); }

/* ── Settings ── */
.settings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
}

.settings-form .form-row { margin-bottom: 1rem; }

.settings-form label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.35rem;
}

.settings-form input,
.settings-form select {
    width: 100%;
    padding: 0.6rem 0.85rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-family: var(--font);
    font-size: 0.88rem;
    outline: none;
}

.hint {
    color: var(--text-dim);
    font-size: 0.78rem;
    margin-top: 0.35rem;
}

.lang-switch { display: flex; gap: 0.5rem; }

.lang-btn {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.85rem;
    color: var(--text-muted);
    transition: all 0.12s;
}

.lang-btn.active {
    background: var(--bg-input);
    color: var(--text);
    border-color: var(--border-light);
}

.lang-btn:hover { color: var(--text); }

/* ── Modal ── */
.modal[hidden] { display: none; }

.modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
}

.modal-box {
    position: relative;
    width: 100%;
    max-width: 480px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.75rem;
    margin: 1rem;
}

.modal-box h3 {
    font-size: 1.05rem;
    margin-bottom: 1.25rem;
}

.form-row { margin-bottom: 0.85rem; }

.form-row label {
    display: block;
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-bottom: 0.3rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.form-row input,
.form-row select {
    width: 100%;
    padding: 0.6rem 0.85rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-family: var(--font);
    font-size: 0.88rem;
    outline: none;
}

.form-row-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.checkbox-label {
    display: flex !important;
    align-items: center;
    gap: 0.5rem;
    text-transform: none !important;
    color: var(--text) !important;
    cursor: pointer;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 1.25rem;
}

/* ── Toast ── */
.toast {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    padding: 0.7rem 1.1rem;
    background: var(--bg-elevated);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    font-size: 0.85rem;
    color: var(--text);
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.2s, transform 0.2s;
    pointer-events: none;
    z-index: 200;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.alert-error {
    background: rgba(240, 113, 120, 0.1);
    border: 1px solid rgba(240, 113, 120, 0.3);
    color: var(--red);
    padding: 0.6rem 0.85rem;
    border-radius: 8px;
    font-size: 0.85rem;
    margin-bottom: 1rem;
}


.main-wide {
    max-width: 1080px;
}


/* ── Inbox (mail-client list) ── */
.inbox-page { display: flex; flex-direction: column; }
.inbox-top {
    display: flex; flex-wrap: wrap; align-items: flex-end;
    justify-content: space-between; gap: 1rem; margin-bottom: 1rem;
}
.inbox-tabs { display: flex; gap: 0.25rem; border-bottom: 1px solid var(--border); }
.inbox-tab {
    display: inline-flex; align-items: center; gap: 0.5rem;
    padding: 0.65rem 1rem; font-size: 0.88rem; color: var(--text-muted);
    border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.inbox-tab:hover { color: var(--text); }
.inbox-tab.active { color: var(--text); border-bottom-color: var(--accent); }
.tab-count {
    font-size: 0.72rem; padding: 0.12rem 0.5rem; background: var(--bg-input);
    border-radius: 10px; color: var(--text-muted);
}
.inbox-tab.active .tab-count { background: rgba(255,255,255,0.1); color: var(--text); }
.inbox-toolbar { flex: 1; min-width: 220px; max-width: 420px; display: flex; align-items: center; gap: 0.35rem; }
.inbox-toolbar .inbox-search-wrap { flex: 1; min-width: 0; }
.inbox-search-wrap { position: relative; }
.inbox-search-wrap .inbox-search-icon {
    position: absolute; left: 0.85rem; top: 50%; transform: translateY(-50%);
    width: 16px; height: 16px; color: var(--text-dim); pointer-events: none;
    display: flex; align-items: center; justify-content: center;
}
.inbox-search-wrap .inbox-search-icon svg { width: 16px; height: 16px; display: block; }
.inbox-search-wrap input {
    width: 100%; padding: 0.6rem 0.85rem 0.6rem 2.5rem;
    background: var(--bg-card); border: 1px solid var(--border); border-radius: 8px;
    color: var(--text); font-family: var(--font); font-size: 0.88rem; outline: none;
}
.inbox-actions-bar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0.35rem 0.25rem 0.65rem;
}
.inbox-select-all { display: flex; align-items: center; gap: 0.5rem; font-size: 0.82rem; color: var(--text-muted); cursor: pointer; }
.inbox-actions-right { display: flex; gap: 0.25rem; }

.inbox-list {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); overflow: hidden;
}
.inbox-empty { text-align: center; padding: 4rem 1rem; color: var(--text-dim); border: none; background: transparent; }
.inbox-empty-icon { font-size: 2.5rem; margin-bottom: 0.75rem; opacity: 0.5; }

.inbox-list-head {
    display: grid; grid-template-columns: 28px 28px 36px 100px 140px 1fr 88px 80px 140px 100px 32px;
    gap: 0.65rem; align-items: center;
    padding: 0.55rem 1rem; font-size: 0.68rem; text-transform: uppercase;
    letter-spacing: 0.04em; color: var(--text-dim);
    background: var(--bg-elevated); border-bottom: 1px solid var(--border);
}
.inbox-list-head span:nth-child(n+3) { padding-left: 0.15rem; }

.inbox-row {
    display: grid; grid-template-columns: 28px 28px 36px 100px 140px 1fr 88px 80px 140px 100px 32px;
    gap: 0.65rem; align-items: center;
    padding: 0.7rem 1rem; border-bottom: 1px solid var(--border);
    transition: background 0.1s; min-height: 56px;
}
.inbox-row:last-child { border-bottom: none; }
.inbox-row:hover { background: rgba(255,255,255,0.03); }
.inbox-row.is-starred { background: rgba(255,193,7,0.04); }
.inbox-row.hidden-by-search { display: none; }

.inbox-filters-wrap { position: relative; padding: 0 1rem 0.75rem; }
.inbox-filters {
    display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center;
}
.inbox-filter {
    display: inline-flex; align-items: center; gap: 0.35rem;
    padding: 0.35rem 0.75rem; border-radius: 999px;
    border: 1px solid var(--border); background: var(--bg-elevated);
    color: var(--text-muted); font-size: 0.78rem; cursor: pointer;
    transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.inbox-filter:hover { border-color: var(--border-light); color: var(--text); }
.inbox-filter.active {
    background: rgba(100,149,237,0.15); border-color: rgba(100,149,237,0.45);
    color: #8ab4f8; font-weight: 600;
}
.inbox-filter-count {
    font-size: 0.68rem; opacity: 0.75; font-weight: 500;
}
.inbox-filter-settings { flex-shrink: 0; }
.inbox-filter-menu {
    position: absolute; top: 100%; right: 1rem; z-index: 20;
    min-width: 200px; padding: 0.75rem;
    background: var(--bg-elevated); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: 0 8px 24px rgba(0,0,0,0.35);
}
.inbox-filter-menu-title {
    margin: 0 0 0.5rem; font-size: 0.72rem; text-transform: uppercase;
    letter-spacing: 0.04em; color: var(--text-dim);
}
.inbox-filter-menu-item {
    display: flex; align-items: center; gap: 0.5rem;
    padding: 0.35rem 0; font-size: 0.82rem; color: var(--text-muted); cursor: pointer;
}
.inbox-filter-menu-item input { accent-color: var(--accent); }

.inbox-row-check { display: flex; align-items: center; justify-content: center; }
.inbox-check { width: 15px; height: 15px; accent-color: var(--accent); cursor: pointer; }
.inbox-star {
    background: none; border: none; padding: 0; cursor: pointer;
    color: var(--text-dim); line-height: 0; border-radius: 4px;
}
.inbox-star svg { width: 16px; height: 16px; }
.inbox-star:hover, .inbox-star.starred { color: #ffc107; }

.inbox-row-avatar {
    width: 34px; height: 34px; border-radius: 50%;
    background: linear-gradient(145deg, #2e2e2e, #1a1a1a);
    border: 1px solid var(--border-light);
    display: flex; align-items: center; justify-content: center;
    font-size: 0.82rem; font-weight: 600; color: var(--text-muted);
}

.inbox-row-from { min-width: 0; cursor: pointer; }
.inbox-row-sender {
    display: block; font-size: 0.84rem; font-weight: 600; color: var(--text);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.inbox-row-account {
    display: block; font-size: 0.72rem; color: var(--text-dim);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.inbox-row-subject {
    min-width: 0; cursor: pointer;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    font-size: 0.84rem; color: var(--text-muted);
}
.inbox-row-subject-text { color: var(--text); font-weight: 500; }
.inbox-row-snippet { color: var(--text-dim); font-weight: 400; }
.inbox-row-inline-badges { margin-left: 0.35rem; display: inline-flex; gap: 0.25rem; vertical-align: middle; }
.inbox-row-changes {
    display: flex; flex-wrap: wrap; gap: 0.2rem; align-items: center; min-width: 0;
}
.inbox-change-none { color: var(--text-dim); opacity: 0.35; font-size: 0.75rem; }
.inbox-row-amount {
    font-size: 0.78rem; font-variant-numeric: tabular-nums;
    color: var(--text-dim); white-space: nowrap; text-align: right;
}
.inbox-row-amount.has-amount {
    color: #3dd68c; font-weight: 700; font-size: 0.82rem;
}
.inbox-row-doctype {
    display: flex; flex-wrap: wrap; gap: 0.2rem; align-items: center; min-width: 0;
}
.inbox-doctype-none { color: var(--text-dim); opacity: 0.35; font-size: 0.75rem; }
.badge-doctype {
    display: inline-block; padding: 0.1rem 0.4rem; border-radius: 4px;
    font-size: 0.62rem; font-weight: 600; white-space: nowrap;
    background: rgba(61,214,140,0.15); color: #3dd68c;
}
.badge-doctype-invoice { background: rgba(100,149,237,0.15); color: #8ab4f8; }
.badge-doctype-rechnung, .badge-doctype-endrechnung { background: rgba(255,193,7,0.15); color: #ffc107; }
.badge-doctype-faktura, .badge-doctype-factura, .badge-doctype-facture { background: rgba(61,214,140,0.15); color: #3dd68c; }
.badge-doctype-schet { background: rgba(61,214,140,0.18); color: #3dd68c; }
.badge-doctype-payment { background: rgba(200,150,255,0.15); color: #c896ff; }
.badge-doctype-presupuesto { background: rgba(255,160,100,0.15); color: #ffb464; }
.inbox-att-names .badge-doctype { margin-left: 0.25rem; vertical-align: middle; }
.mail-file-name .badge-doctype { margin-left: 0.35rem; vertical-align: middle; }

.inbox-row-files {
    min-width: 0; display: flex; align-items: center; gap: 0.35rem;
    font-size: 0.75rem; color: var(--text-dim);
}
.inbox-att-indicator {
    display: inline-flex; align-items: center; gap: 0.2rem;
    color: var(--text-muted); flex-shrink: 0;
}
.inbox-att-count { font-size: 0.72rem; font-weight: 600; }
.inbox-att-names {
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text-dim);
}
.inbox-att-none { color: var(--text-dim); opacity: 0.4; }

.inbox-row-time {
    font-size: 0.72rem; color: var(--text-dim); white-space: nowrap; text-align: right;
}
.inbox-delete { opacity: 0; padding: 0.2rem; border-radius: 4px; }
.inbox-row:hover .inbox-delete { opacity: 0.7; }
.inbox-delete:hover { opacity: 1 !important; color: #f07178; background: rgba(240,113,120,0.1); }

.badge-kw {
    padding: 0.1rem 0.35rem; background: rgba(100,149,237,0.12);
    color: #8ab4f8; border-radius: 4px; font-size: 0.65rem; font-weight: 500;
}
.badge-invoice-pdf {
    display: inline-flex; align-items: center; justify-content: center;
    width: 1rem; height: 1rem; border-radius: 3px;
    background: rgba(61,214,140,0.18); color: #3dd68c;
    font-size: 0.62rem; font-weight: 700; flex-shrink: 0;
    vertical-align: middle; margin-left: 0.15rem;
}
.badge-change {
    display: inline-block; padding: 0.08rem 0.35rem; border-radius: 4px;
    font-size: 0.62rem; font-weight: 600; white-space: nowrap;
    max-width: 100%; overflow: hidden; text-overflow: ellipsis;
}
.badge-change-email { background: rgba(255,193,7,0.15); color: #ffc107; }
.badge-change-email_reset { background: rgba(160,160,160,0.15); color: #aaa; }
.badge-change-amount { background: rgba(61,214,140,0.15); color: #3dd68c; }
.badge-change-invoice { background: rgba(100,149,237,0.15); color: #8ab4f8; }
.badge-change-attachment { background: rgba(200,150,255,0.15); color: #c896ff; }

.sidebar-changes {
    margin: 0.75rem 0.65rem 0; padding-top: 0.75rem;
    border-top: 1px solid var(--border);
    flex: 0 1 auto; min-height: 0; display: flex; flex-direction: column;
    max-height: 38vh; overflow: hidden;
}
.sidebar-changes-head {
    padding: 0 0.6rem 0.5rem; font-size: 0.68rem; text-transform: uppercase;
    letter-spacing: 0.04em; color: var(--text-dim); font-weight: 600;
}
.sidebar-changes-list {
    overflow-y: auto; display: flex; flex-direction: column; gap: 0.25rem;
    padding: 0 0.35rem 0.5rem;
}
.sidebar-changes-empty {
    margin: 0; padding: 0.35rem 0.6rem; font-size: 0.72rem; color: var(--text-dim);
}
.sidebar-change-item {
    display: grid; grid-template-columns: 1fr; gap: 0.15rem;
    padding: 0.45rem 0.6rem; border-radius: 6px; text-decoration: none;
    color: inherit; transition: background 0.12s;
}
.sidebar-change-item:hover { background: rgba(255,255,255,0.04); }
.sidebar-change-subject {
    font-size: 0.72rem; color: var(--text-muted);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar-change-time {
    font-size: 0.62rem; color: var(--text-dim);
}
.mail-file-name .badge-invoice-pdf { margin-left: 0.35rem; }
.badge-amount {
    padding: 0.1rem 0.35rem; background: rgba(61,214,140,0.15);
    color: var(--green); border-radius: 4px; font-size: 0.65rem; font-weight: 600;
}
.badge-fwd {
    padding: 0.08rem 0.3rem; background: rgba(100,149,237,0.12);
    color: #6495ed; border-radius: 4px; font-size: 0.62rem;
}
.badge-pdf {
    padding: 0.08rem 0.3rem; background: rgba(240,113,120,0.15);
    color: #f07178; border-radius: 4px; font-size: 0.62rem; font-weight: 600;
}
.badge-edited {
    padding: 0.06rem 0.28rem; background: rgba(255,193,7,0.15);
    color: #ffc107; border-radius: 3px; font-size: 0.6rem; margin-left: 0.25rem;
}
.badge-replaced {
    padding: 0.06rem 0.28rem; background: rgba(61,214,140,0.12);
    color: var(--green); border-radius: 3px; font-size: 0.62rem; margin-left: 0.25rem;
}

.btn-sm { padding: 0.35rem 0.65rem !important; font-size: 0.78rem !important; }

/* ── Mail viewer (Gmail-like) ── */
.mail-modal {
    position: fixed; inset: 0; z-index: 1000;
    display: flex; align-items: center; justify-content: center; padding: 1rem;
}
.mail-modal[hidden] { display: none !important; }
.mail-modal-backdrop {
    position: absolute; inset: 0; background: rgba(0,0,0,0.8); backdrop-filter: blur(6px);
}
.mail-modal-box {
    position: relative; width: 100%; max-width: 920px; max-height: 94vh;
    background: #111; border: 1px solid var(--border-light); border-radius: 12px;
    display: flex; flex-direction: column; overflow: hidden;
    box-shadow: 0 40px 80px rgba(0,0,0,0.6);
}

.mail-view-toolbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0.65rem 1rem; background: var(--bg-card); border-bottom: 1px solid var(--border);
}
.mail-view-toolbar-actions { display: flex; gap: 0.35rem; }

.mail-view-content {
    flex: 1; overflow: auto; display: flex; flex-direction: column;
    background: #0f0f0f;
}
.mail-modal-loading { padding: 3rem; text-align: center; color: var(--text-dim); }
.mail-loading-bar {
    width: 120px; height: 3px; background: var(--border); border-radius: 2px;
    margin: 0 auto 0.75rem; overflow: hidden; position: relative;
}
.mail-loading-bar::after {
    content: ''; position: absolute; left: -40%; width: 40%; height: 100%;
    background: var(--text-muted); animation: mailLoad 1s ease-in-out infinite;
}
@keyframes mailLoad { 0% { left: -40%; } 100% { left: 100%; } }

.mail-view-main { padding: 0; flex: 1; }

.mail-view-subject-wrap {
    padding: 1.5rem 1.75rem 1rem; border-bottom: 1px solid var(--border);
    background: var(--bg-card);
}
.mail-view-subject {
    font-size: 1.35rem; font-weight: 600; line-height: 1.35;
    margin: 0 0 0.5rem; color: var(--text); word-break: break-word;
}
.mail-view-tags { display: flex; flex-wrap: wrap; gap: 0.35rem; }

.mail-view-envelope {
    display: flex; gap: 1rem; padding: 1.1rem 1.75rem;
    background: var(--bg-card); border-bottom: 1px solid var(--border);
}
.mail-env-avatar {
    width: 48px; height: 48px; border-radius: 50%; flex-shrink: 0;
    background: linear-gradient(145deg, #333, #1a1a1a);
    border: 1px solid var(--border-light);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.15rem; font-weight: 600; color: var(--text-muted);
}
.mail-env-details { flex: 1; min-width: 0; }
.mail-env-row {
    display: flex; gap: 0.75rem; margin-bottom: 0.35rem; font-size: 0.86rem; line-height: 1.45;
}
.mail-env-row:last-child { margin-bottom: 0; }
.mail-env-label {
    width: 3.5rem; flex-shrink: 0; color: var(--text-dim);
    font-size: 0.78rem; padding-top: 0.1rem;
}
.mail-env-value { color: var(--text); word-break: break-word; }
.mail-env-email { color: var(--text-muted); font-size: 0.82rem; }
.mail-env-amount-row { margin-top: 0.35rem; padding-top: 0.35rem; border-top: 1px solid var(--border); }
.mail-env-amount {
    color: #3dd68c; font-weight: 700; font-size: 1.05rem; font-variant-numeric: tabular-nums;
}

.mail-view-files {
    padding: 1rem 1.75rem; background: var(--bg-elevated);
    border-bottom: 1px solid var(--border);
}
.mail-view-files-head {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 0.65rem; font-size: 0.78rem; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: 0.03em;
}
.mail-files-grid { display: flex; flex-direction: column; gap: 0.5rem; }
.mail-no-files { margin: 0; font-size: 0.85rem; color: var(--text-dim); font-style: italic; }

.mail-file-card {
    display: grid; grid-template-columns: 48px 1fr auto; gap: 0.75rem; align-items: center;
    padding: 0.65rem 0.85rem; background: var(--bg-card);
    border: 1px solid var(--border); border-radius: 10px;
    transition: border-color 0.12s;
}
.mail-file-card:hover { border-color: var(--border-light); }
.mail-file-card.is-previewable { cursor: pointer; }
.mail-file-card.is-previewable:focus { outline: 2px solid rgba(100,149,237,0.45); outline-offset: 2px; }
.mail-file-card.is-pdf { border-color: rgba(240,113,120,0.25); }
.mail-file-card.is-replaced { border-color: rgba(61,214,140,0.25); }
.mail-file-icon {
    width: 48px; height: 48px; border-radius: 8px;
    background: var(--bg-input); border: 1px solid var(--border);
    display: flex; align-items: center; justify-content: center;
    font-size: 0.72rem; font-weight: 700; color: var(--text-muted);
}
.mail-file-card.is-pdf .mail-file-icon {
    background: rgba(240,113,120,0.12); color: #f07178; border-color: rgba(240,113,120,0.25);
}
.mail-file-meta { min-width: 0; }
.mail-file-name {
    font-size: 0.88rem; font-weight: 500; color: var(--text);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.mail-file-sub { font-size: 0.75rem; color: var(--text-dim); margin-top: 0.15rem; }
.mail-file-actions { display: flex; gap: 0.35rem; flex-shrink: 0; }
.mail-btn-dl { text-decoration: none; }

.mail-view-tabs-row {
    display: flex; align-items: center; justify-content: space-between; gap: 1rem;
    padding: 0 1.75rem; background: var(--bg-card); border-bottom: 1px solid var(--border);
}
.mail-view-tabs {
    display: flex; gap: 0.25rem;
}
.mail-view-format {
    display: flex; gap: 0.25rem; padding: 0.35rem;
    background: rgba(255,255,255,0.04); border-radius: 8px;
}
.mail-format-btn {
    background: none; border: none; border-radius: 6px;
    padding: 0.3rem 0.65rem; font-size: 0.72rem; color: var(--text-dim);
    cursor: pointer; font-family: var(--font);
}
.mail-format-btn.active { background: rgba(100,149,237,0.2); color: #8ab4f8; }
.mail-format-btn:hover:not(.active) { color: var(--text-muted); }
.mail-tab {
    background: none; border: none; border-bottom: 2px solid transparent;
    padding: 0.55rem 0.75rem; color: var(--text-muted); font-family: var(--font);
    font-size: 0.82rem; cursor: pointer; margin-bottom: -1px;
}
.mail-tab.active { color: var(--text); border-bottom-color: var(--accent); }
.mail-tab.tab-same:not(.active) { opacity: 0.55; }

.mail-view-body-panel {
    flex: 1; background: #fff; margin: 1.25rem 1.75rem 1.75rem;
    border-radius: 8px; box-shadow: 0 2px 12px rgba(0,0,0,0.3); overflow: hidden;
}
.mail-view-body {
    padding: 0; font-size: 0.92rem; line-height: 1.7;
    color: #222; min-height: 180px; max-height: 45vh; overflow: hidden;
    display: flex; flex-direction: column;
}
.mail-plain-body {
    padding: 1.75rem 2rem; overflow: auto; flex: 1;
}
.mail-html-frame {
    width: 100%; flex: 1; min-height: 220px; border: none; background: #fff;
}
.mail-para { margin: 0 0 1rem; white-space: pre-wrap; word-break: break-word; color: #333; }
.mail-quote {
    margin: 0.75rem 0 1rem; padding: 0.75rem 1rem;
    border-left: 3px solid #ccc; background: #f5f5f5;
    color: #666; font-size: 0.88rem; border-radius: 0 6px 6px 0;
}
.mail-separator {
    margin: 1rem 0; padding: 0.45rem 0; border-top: 1px solid #ddd; border-bottom: 1px solid #ddd;
    font-size: 0.75rem; color: #888; text-align: center;
}
.mail-header-line { display: flex; gap: 0.5rem; margin-bottom: 0.25rem; font-size: 0.84rem; color: #555; }
.mail-hl-label { color: #888; min-width: 4rem; font-weight: 500; }
.mail-empty-body { color: #999; font-style: italic; }

.mail-warning {
    margin: 0.75rem 1.75rem 0; padding: 0.55rem 0.85rem;
    background: rgba(255,193,7,0.08); border: 1px solid rgba(255,193,7,0.2);
    border-radius: 8px; font-size: 0.78rem; color: #ffc107;
}

.mail-send-panel {
    position: absolute; inset: 0; z-index: 50;
    background: var(--bg-card); flex-direction: column;
    overflow: auto;
}
.mail-send-panel[hidden] { display: none !important; }
.mail-send-panel:not([hidden]) {
    display: flex !important;
}
.mail-send-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 1rem 1.5rem; border-bottom: 1px solid var(--border);
}
.mail-send-head h2 { margin: 0; font-size: 1.05rem; font-weight: 600; }
.mail-send-from-line {
    margin: 0 0 0.35rem;
    font-size: 0.9rem;
}
.mail-send-from-line span { color: var(--text-dim); }
.mail-send-via-line {
    margin: 0 0 0.85rem;
    font-size: 0.82rem;
    color: var(--text-dim);
}
.mail-send-via-line span { color: var(--text-dim); }
.mail-send-panel label {
    display: block; margin: 0.85rem 1.5rem 0.35rem;
    font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--text-dim);
}
.mail-send-panel input[type="email"],
.mail-send-panel input[type="text"],
.mail-send-panel textarea {
    margin: 0 1.5rem; width: calc(100% - 3rem);
    padding: 0.65rem 0.85rem; background: var(--bg-input);
    border: 1px solid var(--border); border-radius: 8px;
    color: var(--text); font-family: var(--font); font-size: 0.88rem;
}
.mail-send-panel textarea { resize: vertical; min-height: 140px; }
.mail-send-atts-wrap { padding: 1rem 1.5rem 0.5rem; }
.mail-send-atts-label {
    display: block; font-size: 0.72rem; text-transform: uppercase;
    letter-spacing: 0.03em; color: var(--text-dim); margin-bottom: 0.5rem;
}
.mail-send-atts { display: flex; flex-direction: column; gap: 0.35rem; }
.mail-send-att-item {
    display: flex; align-items: center; gap: 0.5rem;
    padding: 0.55rem 0.75rem; background: var(--bg-elevated);
    border: 1px solid var(--border); border-radius: 8px;
    font-size: 0.84rem; cursor: pointer;
}
.mail-send-att-item input { accent-color: var(--accent); flex-shrink: 0; }
.mail-send-att-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-send-att-meta { font-size: 0.72rem; color: var(--text-dim); flex-shrink: 0; }
.mail-send-no-atts { font-size: 0.82rem; color: var(--text-dim); margin: 0; }
.mail-send-footer {
    display: flex; justify-content: flex-end; gap: 0.5rem;
    padding: 1rem 1.5rem 1.25rem; margin-top: auto;
    border-top: 1px solid var(--border);
}

.att-preview-modal {
    position: fixed; inset: 0; z-index: 1100;
}
.att-preview-modal:not([hidden]) { display: block; }
.att-preview-backdrop {
    position: absolute; inset: 0; background: rgba(0,0,0,0.85); backdrop-filter: blur(4px);
}
.att-preview-box {
    position: absolute; inset: 2vh 2vw; background: #111;
    border: 1px solid var(--border-light); border-radius: 12px;
    display: flex; flex-direction: column; overflow: hidden;
    box-shadow: 0 24px 64px rgba(0,0,0,0.55);
}
.att-preview-head {
    display: flex; align-items: center; justify-content: space-between; gap: 1rem;
    padding: 0.75rem 1rem; border-bottom: 1px solid var(--border); background: var(--bg-card);
}
.att-preview-title {
    margin: 0; font-size: 0.92rem; font-weight: 600;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.att-preview-head-actions { display: flex; align-items: center; gap: 0.35rem; flex-shrink: 0; }
.att-preview-body {
    flex: 1; min-height: 0; background: #1a1a1a;
    display: flex; position: relative;
}
.att-preview-loading {
    position: absolute; inset: 0; display: flex; flex-direction: column;
    align-items: center; justify-content: center; gap: 0.75rem;
    color: var(--text-muted); background: #1a1a1a;
}
.att-preview-loading[hidden] { display: none !important; }
.att-preview-frame {
    width: 100%; height: 100%; border: none; background: #fff;
}
.att-preview-img {
    max-width: 100%; max-height: 100%; object-fit: contain; background: #111;
}
.att-preview-fallback {
    text-align: center; padding: 2rem; color: var(--text-muted); font-size: 0.9rem;
}

.att-preview-view {
    flex: 1; min-width: 0; min-height: 0;
    display: flex; align-items: center; justify-content: center; position: relative;
}
.att-preview-box.is-editing .att-preview-view {
    flex: 1.2;
    border-right: 1px solid var(--border);
}
.att-preview-editor {
    width: min(420px, 38vw);
    flex-shrink: 0;
    display: flex; flex-direction: column; gap: 0.65rem;
    padding: 0.85rem 1rem 1rem;
    background: var(--bg-card);
    overflow: auto;
}
.att-preview-editor[hidden] { display: none !important; }
.att-preview-editor-hint {
    margin: 0; font-size: 0.78rem; color: var(--text-muted); line-height: 1.45;
}
.att-preview-editor-row {
    display: grid; grid-template-columns: 72px 1fr 1fr 28px; gap: 0.35rem; align-items: center;
}
.att-preview-editor-row label {
    font-size: 0.72rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.03em;
}
.att-preview-editor-row input {
    font-size: 0.82rem; padding: 0.4rem 0.5rem;
    border: 1px solid var(--border); border-radius: 6px; background: var(--bg);
    color: var(--text); min-width: 0;
}
.att-preview-editor-row .btn-icon {
    width: 28px; height: 28px; padding: 0; color: var(--text-muted);
}
.att-preview-add-row { align-self: flex-start; }
.att-preview-text-details summary {
    cursor: pointer; font-size: 0.78rem; color: var(--text-muted); margin-bottom: 0.35rem;
}
.att-pdf-edit-fulltext {
    width: 100%; font-size: 0.75rem; font-family: ui-monospace, monospace;
    border: 1px solid var(--border); border-radius: 6px; background: var(--bg);
    color: var(--text-muted); padding: 0.5rem; resize: vertical;
}

.mail-modal-edit {
    padding: 1.25rem 1.75rem 2rem; display: flex; flex-direction: column; gap: 0.5rem;
}
.mail-modal-edit label {
    font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--text-dim);
}
.mail-modal-edit input, .mail-modal-edit textarea {
    width: 100%; padding: 0.65rem 0.85rem; background: var(--bg-input);
    border: 1px solid var(--border); border-radius: 8px; color: var(--text);
    font-family: var(--font); font-size: 0.88rem; outline: none;
}
.mail-modal-edit textarea { min-height: 320px; resize: vertical; }

.mail-view-footer {
    display: flex; align-items: center; gap: 0.5rem;
    padding: 0.75rem 1.25rem; border-top: 1px solid var(--border); background: var(--bg-card);
}
.mail-modal-actions-spacer { flex: 1; }

@media (max-width: 1100px) {
    .inbox-list-head { display: none; }
    .inbox-row {
        grid-template-columns: 28px 28px 36px 1fr 32px;
        grid-template-areas:
            "check star av from del"
            ". . . changes ."
            ". . . subject ."
            ". . . amount ."
            ". . . doctype ."
            ". . . files .";
        gap: 0.35rem 0.65rem; padding: 0.85rem 1rem;
    }
    .inbox-row-check { grid-area: check; }
    .inbox-star { grid-area: star; }
    .inbox-row-avatar { grid-area: av; }
    .inbox-row-from { grid-area: from; }
    .inbox-row-changes { grid-area: changes; }
    .inbox-row-subject { grid-area: subject; white-space: normal; }
    .inbox-row-amount { grid-area: amount; text-align: left; }
    .inbox-row-doctype { grid-area: doctype; }
    .inbox-row-files { grid-area: files; }
    .inbox-row-time { display: none; }
    .inbox-delete { grid-area: del; opacity: 0.6; }
}

@media (max-width: 640px) {
    .mail-modal-box { max-height: 98vh; border-radius: 8px; }
    .mail-view-subject-wrap, .mail-view-envelope, .mail-view-files { padding-left: 1rem; padding-right: 1rem; }
    .mail-view-body-panel { margin: 1rem; }
    .mail-view-body { padding: 1.25rem; }
    .mail-file-card { grid-template-columns: 40px 1fr; }
    .mail-file-actions { grid-column: 1 / -1; justify-content: flex-end; }
}





@media (max-width: 900px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .keywords-grid { grid-template-columns: 1fr; }
    .settings-grid { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
    .sidebar { display: none; }
    .main { margin-left: 0; padding: 1.25rem; }
    .page-header { flex-direction: column; }
}

.dashboard-pdf-card .card-header {
    display: flex; align-items: center; justify-content: space-between; gap: 1rem;
}
.dashboard-pdf-card .card-meta { font-size: 0.82rem; color: var(--text-dim); }
.dashboard-pdf-table .cell-subject a {
    color: var(--text); font-weight: 500; text-decoration: none;
}
.dashboard-pdf-table .cell-subject a:hover { color: #8ab4f8; }
.dashboard-pdf-table .cell-amount {
    font-variant-numeric: tabular-nums; color: var(--text-dim); white-space: nowrap;
}
.dashboard-pdf-table .cell-amount.has-amount {
    color: #3dd68c; font-weight: 700; font-size: 0.95rem;
}
.dashboard-pdf-table .cell-from,
.dashboard-pdf-table .cell-account {
    font-size: 0.82rem; color: var(--text-muted); max-width: 180px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.dashboard-pdf-table .cell-doctype { min-width: 72px; }
.dashboard-pdf-table .cell-doctype .badge-doctype {
    display: inline-block; margin: 0.1rem 0.15rem 0.1rem 0;
}

/* ── Pagination ── */
.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border);
    background: var(--bg-elevated);
}

.pagination-info {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin: 0;
}

.pagination-controls {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.pagination-btn,
.pagination-page {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2rem;
    height: 2rem;
    padding: 0 0.65rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-muted);
    font-size: 0.82rem;
    text-decoration: none;
    transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.pagination-btn:hover,
.pagination-page:hover {
    border-color: var(--border-light);
    color: var(--text);
    background: var(--bg-input);
}

.pagination-btn.disabled,
.pagination-page.active {
    pointer-events: none;
}

.pagination-page.active {
    background: var(--text);
    border-color: var(--text);
    color: var(--bg);
    font-weight: 600;
}

.pagination-btn.disabled {
    opacity: 0.4;
}

.pagination-pages {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.pagination-ellipsis {
    color: var(--text-dim);
    padding: 0 0.25rem;
    font-size: 0.82rem;
}

.inbox-page .pagination {
    border: 1px solid var(--border);
    border-radius: 0 0 var(--radius) var(--radius);
    margin-top: -1px;
}

.dashboard-pdf-card .pagination {
    border-top: 1px solid var(--border);
    border-radius: 0 0 var(--radius) var(--radius);
}

.accounts-card .accounts-toolbar {
    padding: 0 1rem;
    border-bottom: 1px solid var(--border);
}

.accounts-card .accounts-tabs {
    border-bottom: none;
}

.accounts-card .pagination {
    border-top: 1px solid var(--border);
    border-radius: 0 0 var(--radius) var(--radius);
}

@media (max-width: 640px) {
    .pagination {
        flex-direction: column;
        align-items: stretch;
    }
    .pagination-controls {
        justify-content: center;
        flex-wrap: wrap;
    }
}
.dashboard-pdf-table .cell-actions { text-align: right; }
.header-actions { display: flex; align-items: center; gap: 0.75rem; }
