:root {
    --bg: #12151c;
    --bg-alt: #1a1e27;
    --surface: #1b202b;
    --border: #2b303c;
    --text: #e6e9ef;
    --text-muted: #9aa4b2;
    --primary: #3b82f6;
    --secondary: #5b6472;
    --danger: #ef4444;
    --warning-bg: #3a2f12;
    --warning-text: #ffd479;
    --warning-border: #6b4e12;
}

* {
    box-sizing: border-box;
    user-select: none;
    -webkit-user-select: none;
    outline: none;
}

input, textarea, .token {
    user-select: text;
    -webkit-user-select: text;
}

body {
    font-family: Arial, sans-serif;
    margin: 0;
    background: var(--bg);
    color: var(--text);
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.wrap { max-width: 1260px; margin: 0 auto; padding: 20px 2rem 2rem; }

.topnav {
    position: relative;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    z-index: 1100;
}
.topnav-inner {
    max-width: 960px;
    margin: 0 auto;
    padding: 0.6rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}
.topnav-user { font-weight: 600; }
.topnav-links { display: flex; gap: 0.3rem; flex-wrap: wrap; }
.topnav-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 0.3rem 0.7rem;
    border-radius: 8px;
    color: var(--text-muted);
    font-size: 0.7rem;
    text-decoration: none;
}
.topnav-link:hover {
    color: var(--text);
    background: var(--bg-alt);
    text-decoration: none;
}
.topnav-link.active {
    color: #fff;
    background: var(--primary);
    font-weight: 600;
    text-decoration: none;
}

.topnav-item { position: relative; }
.topnav-toggle {
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.7rem;
}
.topnav-submenu {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 0.4rem;
    background: var(--bg-alt);
    border: 1px solid var(--primary);
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
    padding: 0.4rem;
    min-width: 180px;
    z-index: 1100;
}
.topnav-submenu.open { display: flex; flex-direction: column; }
.topnav-submenu a {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem 0.7rem;
    border-radius: 6px;
    color: var(--text);
    font-size: 0.85rem;
    text-decoration: none;
}
.topnav-submenu a:hover { background: var(--primary); color: #fff; text-decoration: none; }
.topnav-submenu a span { font-weight: normal; }

.topnav-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 1090;
}
.topnav-backdrop.open { display: block; }

.modal-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 1500;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.modal-backdrop.open { display: flex; }
.modal {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
    padding: 1.5rem;
    width: 100%;
    max-width: 360px;
    overflow: visible;
}
.modal-body { max-height: 80vh; overflow-y: auto; }
#user-devices-backdrop .modal { max-width: 760px; }
#company-detail-backdrop .modal { max-width: 820px; }
.company-detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 210px), 1fr)); gap: 0.75rem; }
.company-detail-grid section { min-width: 0; padding: 0.75rem; background: var(--bg-alt); border: 1px solid var(--border); border-radius: 8px; }
.company-detail-grid h4 { margin: 0 0 0.65rem; }
.company-detail-grid ul { margin: 0; max-height: 40vh; overflow-y: auto; }
.company-detail-grid li { overflow-wrap: anywhere; }
.company-detail-grid .company-detail-empty { color: var(--text-muted); }
#user-devices-table[hidden] { display: none; }
#user-devices-table td { overflow-wrap: anywhere; }
.modal h3 { margin-top: 0; }
.modal ul { list-style: none; padding: 0; margin: 0 0 1rem; }
.modal ul li {
    padding: 0.5rem 0.7rem;
    border-radius: 6px;
    background: var(--bg-alt);
    margin-bottom: 0.4rem;
}
.modal-close-btn {
    position: absolute;
    top: -0.75rem;
    right: -0.75rem;
    width: 2.2rem;
    height: 2.2rem;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--danger);
    color: #fff;
    border: 2px solid var(--bg);
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
    line-height: 1;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}
.modal-close-btn:hover { background: #f4756c; }

.toolbar {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 1rem;
    align-items: center;
    margin-bottom: 1rem;
}
.toolbar h1 { font-size: 1.3rem; margin: 0; }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem 1.5rem;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
    margin-bottom: 1rem;
}
.card h2 { margin-top: 0; font-size: 1.1rem; }
.company-child-links { display: flex; flex-wrap: wrap; gap: 0.35rem 0.8rem; margin-top: 0.4rem; font-size: 0.82rem; }
.card summary {
    cursor: pointer;
    font-weight: 600;
    font-size: 1.1rem;
    list-style: none;
}
.card summary::-webkit-details-marker { display: none; }
.card summary::before {
    content: "▸";
    display: inline-block;
    margin-right: 0.5rem;
    transition: transform 0.15s ease;
}
.card[open] summary::before { transform: rotate(90deg); }

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
}

.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.5rem;
}

.admin-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.6rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    color: var(--text);
    text-decoration: none;
}
.admin-tile:hover {
    background: var(--bg-alt);
    border-color: var(--primary);
    text-decoration: none;
}
.admin-tile span { font-weight: 600; }

.account-username { color: var(--text-muted); margin: 0 0 1rem; }
.account-devices { display: flex; flex-wrap: wrap; gap: 0.75rem; }
.account-device-card { box-sizing: border-box; flex: 1 1 250px; min-width: 0; max-width: 360px; padding: 0.85rem 1rem; background: var(--bg-alt); border: 1px solid var(--border); border-radius: 8px; }
.account-device-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 0.75rem; }
.account-device-name { min-width: 0; overflow-wrap: anywhere; }
.account-device-action { flex: none; }
.account-device-action form { margin: 0; }
.account-device-status { margin: 0.3rem 0 0.6rem; color: var(--text-muted); font-size: 0.85rem; }
.account-device-added { margin: 0; color: var(--text-muted); font-size: 0.85rem; }
.account-device-added span { display: inline-block; color: var(--text); text-align: center; vertical-align: top; }

.inline { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
.name-edit-form { display: flex; flex-wrap: nowrap; align-items: center; gap: 0.4rem; }
.name-edit-form input[type=text] { width: auto; flex: 1 1 auto; min-width: 100px; max-width: 160px; }
.inline input[type=text], .inline input[type=password], .inline select {
    width: auto;
    flex: 0 1 auto;
    min-width: 140px;
    max-width: 220px;
}

table { width: 100%; border-collapse: collapse; }
th, td { border-bottom: 1px solid var(--border); padding: 0.1rem; text-align: left; }
th { color: var(--text-muted); font-weight: 600; }
.date-col { width: 90px; min-width: 90px; max-width: 90px; text-align: center; }
td[data-label="Akce"] { text-align: right; }
td[data-label="Akce"] > button,
td[data-label="Akce"] > form,
td[data-label="Akce"] > span { display: inline-flex; align-items: center; vertical-align: middle; margin: 2.5px; }

.messages-table { font-size: 0.85rem; }
.topic-filter {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    background: var(--bg-alt);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.5rem 0.75rem;
}
.topic-filter svg { color: var(--text-muted); flex-shrink: 0; }

.custom-select { position: relative; }
.custom-select-toggle {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    justify-content: space-between;
    min-width: 200px;
    max-width: 260px;
    padding: 0.5rem 0.7rem;
    background: var(--secondary);
    border: 1px solid var(--primary);
    border-radius: 6px;
    color: #fff;
    cursor: pointer;
    font-family: inherit;
    font-size: 1rem;
}
.custom-select-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 0.4rem;
    background: var(--bg-alt);
    border: 1px solid var(--primary);
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
    padding: 0.4rem;
    min-width: 200px;
    max-width: 260px;
    z-index: 200;
}
.custom-select-menu.open { display: flex; flex-direction: column; }
.custom-select-menu a {
    padding: 0.5rem 0.7rem;
    border-radius: 6px;
    color: var(--text);
    text-decoration: none;
}
.custom-select-menu a:hover { background: var(--primary); color: #fff; text-decoration: none; }
.custom-select-menu a.active { background: var(--primary); color: #fff; font-weight: 600; }

.messages-table .highlight { background: #1c2e4d; color: #fff; }
.messages-table tbody tr[data-id] { cursor: pointer; }
.messages-table tbody tr[data-id]:hover { background: var(--bg-alt); }
.messages-table tbody tr[data-id]:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.message-detail-header { display: flex; align-items: center; flex-wrap: wrap; gap: 0.5rem; padding-right: 1rem; }
.message-detail-header img { flex: none; object-fit: contain; }
.message-detail-topic { display: inline-flex; align-items: center; max-width: 100%; padding: 0.35rem 0.7rem; border-radius: 999px; background: rgba(59, 130, 246, 0.16); color: #9bc3ff; font-size: 0.8rem; font-weight: 700; overflow-wrap: anywhere; }
.message-detail-date { color: var(--text-muted); font-size: 0.82rem; }
#message-detail-backdrop h3 { margin: 0.5rem 0 0.5rem; line-height: 1.1; overflow-wrap: anywhere; }
.message-detail-message,
.message-detail-content { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.65; user-select: text; }
.message-detail-message { margin: 0; }
.message-detail-content { font-family: monospace; font-size:9pt; margin: 0.5rem 0 0; padding: 0.5rem 0.5rem; background: var(--bg-alt); border: 1px solid var(--border); border-radius: 8px; }
.message-detail-content[hidden] { display: none; }
.message-detail-link { margin: 0.75rem 0 0; text-align: center; }
.message-detail-link[hidden] { display: none; }
.message-detail-link a { color: var(--text-muted); font-size: 0.72rem; text-decoration: underline; overflow-wrap: anywhere; user-select: text; }
.message-detail-link a:hover { color: var(--primary); }
.account-topics { display: flex; flex-flow: row wrap; gap: 0.75rem; }
.account-topic-card { box-sizing: border-box; display: flex; align-items: center; min-width: 180px; max-width: 100%; padding: 0.8rem 1rem; background: var(--bg-alt); border: 1px solid var(--border); border-radius: 8px; }
.account-topic-card label { display: flex; align-items: center; gap: 0.7rem; cursor: pointer; margin: 0; }
.account-topic-card input[type="checkbox"] { width: auto; margin: 0; flex: none; }
.account-topic-card input[type="checkbox"]:focus-visible { outline: 2px solid var(--primary); outline-offset: 3px; }
.account-topic-card span { overflow-wrap: anywhere; }
@media (max-width: 480px) {
    .message-detail-header { gap: 0.4rem; }
}
.messages-table .type-col { padding: 5px; }
.messages-table .type-col,
.messages-table .topic-col,
.messages-table .title-col,
.messages-table .date-col { vertical-align: top; }
.messages-table .topic-col,
.messages-table .title-col { padding-top: 0.7rem; }
.messages-table .message-text {
    white-space: pre-wrap;
    word-break: break-word;
    font-family: inherit;
}

button, .button {
    padding: 0.7rem 1rem;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    background: var(--primary);
    color: #fff;
    transition: background-color 0.15s ease, transform 0.05s ease;
}
button:hover, .button:hover { background: #5a9bfb; }
button:active, .button:active { transform: scale(0.97); }
.secondary { background: var(--secondary); }
.secondary:hover { background: #707a89; }
.danger { background: var(--danger); }
.danger:hover { background: #f4756c; }
.success { background: #22c55e; }
.success:hover { background: #45d374; }
.icon-button.secondary.user-edit-button,
.icon-button.secondary.topic-edit-button,
.icon-button.edit-button {
    background: #2563eb;
    border: 1px solid rgba(37, 99, 235, 0.6);
}
.icon-button.secondary.user-edit-button:hover,
.icon-button.secondary.topic-edit-button:hover,
.icon-button.edit-button:hover {
    background: #1d4ed8;
}

.icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
    width: 2.4rem;
    height: 2.4rem;
}

.title-row { display: flex; align-items: center; gap: 1rem; }
.title-row h1 { margin: 0; }
.messages-header { gap: 0.5rem; margin-bottom: 1rem; }
.messages-header h2 { margin: 0; min-width: 0; }
.messages-header > .icon-button { flex-shrink: 0; }
.messages-header .topic-filter { margin-left: auto; min-width: 0; max-width: 45%; padding: 0; border: none; background: none; }
.messages-header .topic-filter > svg { display: none; }
.messages-header .custom-select { min-width: 0; }
.messages-header .custom-select-toggle { min-width: 0; max-width: 100%; }
.messages-header .custom-select-toggle span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.messages-header .custom-select-menu { left: auto; right: 0; max-width: min(260px, 80vw); }
.messages-header .custom-select-menu a { overflow-wrap: anywhere; }

.toggle-row { display: flex; gap: 0.5rem; }
.icon-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.4rem;
    height: 2.4rem;
    flex-shrink: 0;
    background: var(--bg-alt);
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}
.icon-toggle:hover { border-color: var(--primary); }
.icon-toggle input { display: none; }
.icon-toggle .icon-toggle-icon { display: flex; color: var(--text-muted); }
.icon-toggle:has(input:checked) { background: #22c55e; border-color: #22c55e; }
.icon-toggle:has(input:checked) .icon-toggle-icon { color: #fff; }
.icon-toggle-admin:has(input:checked) { background: var(--primary); border-color: var(--primary); }
.icon-toggle-admin:has(input:checked) .icon-toggle-icon { color: #fff; }

.alert {
    margin-bottom: 1rem;
    padding: 0.7rem 1rem;
    border-radius: 8px;
    background: var(--warning-bg);
    color: var(--warning-text);
    border: 1px solid var(--warning-border);
}
.error { color: #ff8a8a; }
.alert.success { background: #12351f; color: #7ee787; border-color: #2f6b3a; }

.queue-list { display: flex; flex-direction: column; gap: 0.75rem; }
.queue-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.75rem 1rem;
}
.queue-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.6rem 1rem;
}
.queue-row-main { font-weight: 600; }
.queue-topic { font-weight: normal; font-size: 0.8rem; color: var(--text-muted); }
.queue-title { font-weight: normal; font-size: 0.9rem; }
.queue-row-meta {
    margin-top: 0.4rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}
.queue-id { color: var(--text-muted); font-weight: normal; }
.queue-title { flex: 1 1 auto; }
.queue-status {
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    font-size: 0.8rem;
    background: var(--bg-alt);
    border: 1px solid var(--border);
}
.queue-status.status-sent { color: #7ee787; border-color: #2f6b3a; }
.queue-status.status-failed { color: #ff8a8a; border-color: #6b2f2f; }
.queue-status.status-pending, .queue-status.status-processing { color: var(--warning-text); border-color: var(--warning-border); }

.token {
    display: block;
    overflow-wrap: anywhere;
    padding: 0.8rem;
    background: var(--warning-bg);
    color: var(--warning-text);
    border: 1px solid var(--warning-border);
    border-radius: 8px;
}

textarea[name="message"] { resize: none; }

input[type=text], input[type=password], select, textarea {
    width: 100%;
    padding: 0.6rem;
    background: var(--bg-alt);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 6px;
    font-family: inherit;
    box-sizing: border-box;
}
input[type=text], input[type=password], select {
    height: 2.6rem;
    line-height: 1.4;
    -webkit-appearance: none;
    appearance: none;
}
label { color: var(--text); }

.icon-select { position: relative; }
.icon-select-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    min-height: 2.6rem;
    padding: 0.6rem;
    background: var(--bg-alt);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font: inherit;
    text-align: left;
}
.icon-select-toggle:hover { background: var(--bg-alt); border-color: var(--primary); }
.icon-select-value, .icon-select-option { display: flex; align-items: center; gap: 0.6rem; }
.icon-select img { flex-shrink: 0; object-fit: contain; }
.icon-select-arrow { width: 7px; height: 7px; margin: 0 0.3rem 0.2rem 1rem; border-right: 2px solid var(--text-muted); border-bottom: 2px solid var(--text-muted); transform: rotate(45deg); }
.icon-select.open .icon-select-arrow { transform: rotate(225deg); }
.icon-select-menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    z-index: 10;
    max-height: min(240px, 40vh);
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 0.25rem;
    background: var(--bg-alt);
    border: 1px solid var(--border);
    border-radius: 6px;
    box-shadow: 0 8px 24px #0006;
}
.icon-select-option { padding: 0.5rem; border-radius: 4px; cursor: pointer; }
.icon-select-option[aria-selected="true"] { background: var(--surface); font-weight: 600; }
.icon-select-option[aria-selected="true"]::after { content: '\2713'; margin-left: auto; }
.icon-select-option:hover, .icon-select-option:focus { background: var(--primary); color: #fff; outline: none; }
.icon-select-toggle:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* Mobile: collapse tables marked as responsive into stacked cards, one row = one card. */
@media (max-width: 640px) {
    .modal-backdrop {
        top: var(--modal-viewport-top, 0px);
        bottom: auto;
        height: var(--modal-viewport-height, 100dvh);
        box-sizing: border-box;
        padding: 0.75rem;
    }
    .modal-backdrop .modal {
        box-sizing: border-box;
        max-height: 100%;
        padding: 0.75rem;
        display: flex;
        flex-direction: column;
    }
    .modal-backdrop .modal-body {
        min-height: 0;
        max-height: none;
        overscroll-behavior: contain;
    }
    .modal-backdrop .modal h3 { margin-bottom: 0.5rem; padding-right: 1rem; }
    .send-message-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.4rem 0.5rem; }
    .send-message-form > :not(input[type="hidden"]) { grid-column: 1 / -1; margin-top: 0 !important; min-width: 0; }
    .send-message-form > div:nth-of-type(2),
    .send-message-form > div:nth-of-type(3) { grid-column: auto; }
    .send-message-form label { font-size: 0.85rem; }
    .send-message-form input[type="text"],
    .send-message-form textarea,
    .send-message-form .icon-select-toggle { font-size: 16px; padding: 0.35rem 0.5rem; }
    .send-message-form input[type="text"],
    .send-message-form .icon-select-toggle { height: 2.25rem; min-height: 2.25rem; }
    .send-message-form .icon-select-value { min-width: 0; }
    .send-message-form .icon-select-value span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .send-message-form .icon-select-arrow { flex-shrink: 0; margin-left: 0.25rem; }
    .send-message-form textarea { height: 3.5rem; }
    .send-message-form > button[type="submit"] { padding: 0.5rem; }
    .wrap { padding: 0 1rem 5rem; }
    .topnav {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        top: auto;
        z-index: 1100;
        border-bottom: none;
        border-top: 1px solid var(--border);
    }
    .topnav-inner {
        padding: 0.4rem 0.5rem calc(0.4rem + env(safe-area-inset-bottom));
        flex-wrap: nowrap;
        overflow-x: visible;
        justify-content: center;
    }
    .topnav-user { display: none; }
    .topnav-links { flex-wrap: nowrap; flex-shrink: 0; width: 100%; justify-content: space-around; }
    .topnav-link { padding: 0.3rem 0.5rem; }
    .topnav-submenu {
        top: auto;
        bottom: 100%;
        right: auto;
        left: 50%;
        transform: translateX(-50%);
        margin-top: 0;
        margin-bottom: 0.4rem;
    }
    .card { padding: 1rem; }

    table.responsive-table,
    table.responsive-table thead,
    table.responsive-table tbody,
    table.responsive-table th,
    table.responsive-table tr,
    table.responsive-table td {
        display: block;
    }
    table.responsive-table thead { display: none; }
    table.responsive-table tbody tr {
        background: var(--surface);
        border: 1px solid var(--border);
        border-radius: 8px;
        margin-bottom: 0.75rem;
        padding: 0.5rem 0.75rem;
    }
    table.responsive-table tbody td {
        border-bottom: none;
        padding: 0.4rem 0;
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 0.5rem;
    }
    table.responsive-table .date-col { width: auto; min-width: 0; max-width: none; }
    table.responsive-table tbody td::before {
        content: attr(data-label);
        font-weight: bold;
        color: var(--text-muted);
    }
    table.responsive-table tbody td[data-label="Akce"] { justify-content: flex-end; }
    table.responsive-table tbody td[data-label="Akce"]::before { content: none; }
    table.responsive-table tbody td form {
        display: flex;
        flex-wrap: wrap;
        justify-content: flex-end;
        gap: 0.4rem;
    }

    .inline { flex-direction: column; align-items: stretch; }
    .inline input[type=text], .inline input[type=password], .inline select {
        flex: 0 0 auto;
        width: 100%;
        max-width: none;
    }
    .toolbar { flex-direction: column; align-items: flex-start; }

    /* Mobile messages: icon, topic and date, followed by full-width title and text. */
    table.messages-table.responsive-table tbody tr {
        display: grid;
        grid-template-columns: 24px minmax(0, 1fr) auto;
        grid-template-areas:
            "type topic date"
            "title title title"
            "message message message";
        align-items: center;
        gap: 0.3rem 0.5rem;
    }
    table.messages-table.responsive-table tbody td {
        display: block;
        padding: 0;
        min-width: 0;
    }
    table.messages-table.responsive-table tbody td::before { content: none; }
    .messages-table .topic-col { grid-area: topic; font-weight: 600; overflow-wrap: anywhere; }
    .messages-table .type-col { grid-area: type; justify-self: start; }
    .messages-table .type-col img { display: block; }
    .messages-table .date-col { grid-area: date; justify-self: end; white-space: nowrap; color: var(--text-muted); font-size: 0.8rem; }
    .messages-table .title-col { grid-area: title; text-align: left; font-weight: 600; overflow-wrap: anywhere; }
    .messages-table .message-col { grid-area: message; }

    /* Messages page: main panel spans the full width with no outer padding on mobile. */
    .wrap-full { padding-left: 0; padding-right: 0; }
    .messages-card {
        padding: 0.5rem 0.75rem;
        background: none;
        border: none;
        box-shadow: none;
        border-radius: 0;
    }
    table.messages-table.responsive-table tbody tr {
        padding: 0.5rem 0.75rem;
        margin-bottom: 0.6rem;
        background: var(--surface);
        border: 1px solid var(--border);
        border-radius: 8px;
    }

    /* Queue page: same edge-to-edge treatment as the messages list. */
    .queue-card {
        padding: 0.5rem 0.75rem;
        background: none;
        border: none;
        box-shadow: none;
        border-radius: 0;
    }

    /* Simple admin listings (users/topics/tokens): same edge-to-edge treatment on mobile. */
    .list-card {
        padding: 0.5rem 0.75rem;
        background: none;
        border: none;
        box-shadow: none;
        border-radius: 0;
    }
}
