:root {
    --ink: #1B2A4A;
    --ink-deep: #121E38;
    --paper: #F7F5F0;
    --paper-line: #E4DFD3;
    --slate: #5B7089;
    --charcoal: #242830;
    --charcoal-soft: #5B6270;
    --gold: #B7862F;
    --gold-soft: #F1E6D0;
    --green: #2F6B4F;
    --green-soft: #E4EEE8;
    --white: #FFFFFF;
    --radius: 10px;
    --shadow: 0 1px 2px rgba(18, 30, 56, 0.06), 0 4px 14px rgba(18, 30, 56, 0.05);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    height: 100%;
    max-height: 100%;
    overflow: hidden;
    font-family: 'Inter', sans-serif;
    color: var(--charcoal);
    background: #E9E6DD;
}

a { color: var(--ink); }

h1:focus { outline: none; }

#blazor-error-ui {
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}

.blazor-error-boundary {
    background: #b32121;
    padding: 1rem;
    color: #fff;
}

/* ---------- App shell (viewport locked) ---------- */
.app-shell {
    height: 100%;
    height: 100dvh;
    max-height: 100dvh;
    display: flex;
    justify-content: center;
    padding: 16px;
    overflow: hidden;
}

.app {
    width: 90%;
    max-width: 1728px; /* 90% of 1920 — keeps larger screens from stretching further */
    height: 100%;
    max-height: 100%;
    min-height: 0;
    display: flex;
    background: var(--white);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(18, 30, 56, 0.18);
    border: 1px solid #D9D4C6;
}

.app-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    background: var(--paper);
}

.app-main > article,
.app-main .page-body {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.mobile-bar {
    display: none;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: var(--white);
    border-bottom: 1px solid var(--paper-line);
    flex-shrink: 0;
}

.mobile-menu-btn {
    width: 40px;
    height: 40px;
    border: 1px solid var(--paper-line);
    border-radius: 10px;
    background: var(--paper);
    color: var(--ink);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    margin: 0;
}

.mobile-bar-title {
    font-family: 'Source Serif 4', serif;
    font-weight: 600;
    color: var(--ink-deep);
    font-size: 15px;
}

.nav-drawer-toggle {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.sidebar-backdrop {
    display: none;
}

.sidebar-close {
    display: none;
}

/* ---------- Sidebar ---------- */
.sidebar-panel {
    width: 250px;
    flex-shrink: 0;
    background: linear-gradient(185deg, var(--ink) 0%, var(--ink-deep) 100%);
    color: #EDEFF4;
    display: flex;
    flex-direction: column;
    padding: 22px 16px;
    min-height: 0;
    overflow-y: auto;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 8px 22px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    margin-bottom: 18px;
    text-decoration: none;
    color: inherit;
}

.brand-mark {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: var(--gold);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Source Serif 4', serif;
    font-weight: 700;
    color: var(--ink-deep);
    font-size: 16px;
}

.brand-name {
    font-family: 'Source Serif 4', serif;
    font-size: 16.5px;
    font-weight: 600;
}

.brand-sub {
    font-size: 10.5px;
    color: #A9B3C8;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.side-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.side-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    color: #C7CEDD !important;
    text-decoration: none;
    transition: background .15s ease, color .15s ease;
}

.side-nav .nav-link:hover {
    background: rgba(255, 255, 255, 0.06);
    color: #fff !important;
}

.side-nav .nav-link.active {
    background: rgba(183, 134, 47, 0.16);
    color: #fff !important;
    box-shadow: inset 3px 0 0 var(--gold);
}

.nav-section-label {
    font-size: 10.5px;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    color: #7E8AA3;
    margin: 20px 12px 8px;
}

.queue-item {
    padding: 9px 12px;
    border-radius: 8px;
    font-size: 12.5px;
    color: #AAB4C8;
    text-decoration: none;
    display: block;
}

.queue-item:hover { background: rgba(255, 255, 255, 0.05); color: #E9ECF3; }
.queue-item b { color: #E9ECF3; font-weight: 500; }

.sidebar-footer {
    margin-top: auto;
    padding-top: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    position: relative;
}

.sidebar-user-menu {
    min-width: 0;
    width: 100%;
    position: relative;
}

.user-menu-trigger {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    text-align: left;
    background: transparent;
    border: 0;
    padding: 6px 4px;
    margin: -6px -4px;
    border-radius: 8px;
    cursor: pointer;
    color: inherit;
}

.user-menu-trigger:hover {
    background: rgba(255, 255, 255, 0.06);
}

.user-menu-trigger:hover .who {
    color: #fff;
}

.user-menu-meta {
    min-width: 0;
    flex: 1;
}

.user-menu-caret {
    flex-shrink: 0;
    color: #8A93AA;
    opacity: 0.85;
}

.avatar-small {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: #3A4D74;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11.5px;
    font-weight: 600;
    color: #fff;
    flex-shrink: 0;
}

.sidebar-footer .who { font-size: 12.5px; color: #DADFEA; font-weight: 500; }
.sidebar-footer .role { font-size: 10.5px; color: #8A93AA; }

.user-context-menu {
    position: absolute;
    left: 0;
    bottom: calc(100% + 8px);
    min-width: 160px;
    background: #fff;
    border: 1px solid #D9D4C6;
    border-radius: 10px;
    box-shadow: 0 10px 28px rgba(18, 30, 56, 0.22);
    padding: 6px;
    z-index: 60;
}

.user-menu-dismiss {
    position: fixed;
    inset: 0;
    z-index: 55;
    background: transparent;
}

.user-menu-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-radius: 8px;
    color: var(--ink-deep) !important;
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
}

.user-menu-item:hover {
    background: #F3F5F9;
}

/* ---------- Buttons ---------- */
.btn-support {
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    font-weight: 600;
    padding: 9px 16px;
    border-radius: 8px;
    cursor: pointer;
    border: 1px solid transparent;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    transition: all .15s ease;
    text-decoration: none;
}

.btn-support:disabled { opacity: .55; cursor: not-allowed; }

.btn-outline-support {
    background: var(--white);
    border-color: #C7CEDD;
    color: var(--ink);
}

.btn-outline-support:hover:not(:disabled) {
    background: #F3F5F9;
    border-color: var(--ink);
}

.btn-resolve {
    background: var(--green-soft);
    border-color: #BEDACB;
    color: var(--green);
}

.btn-resolve:hover:not(:disabled) { background: #D7E9DD; }

.btn-ink {
    background: var(--ink);
    color: #fff;
    border-color: var(--ink);
}

.btn-ink:hover:not(:disabled) { background: var(--ink-deep); color: #fff; }

/* ---------- Tickets list ---------- */
.inbox-page {
    padding: 24px 28px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    height: 100%;
    min-height: 0;
    overflow: hidden;
}

.inbox-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    flex-shrink: 0;
}

.inbox-title {
    font-family: 'Source Serif 4', serif;
    font-size: 26px;
    font-weight: 600;
    color: var(--ink-deep);
    margin: 0;
}

.inbox-sub {
    font-size: 13px;
    color: var(--charcoal-soft);
    margin-top: 4px;
}

.inbox-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    flex-shrink: 0;
}

.inbox-search {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1 1 220px;
    min-width: 180px;
    max-width: 420px;
    background: var(--white);
    border: 1px solid var(--paper-line);
    border-radius: 10px;
    padding: 0 10px;
    box-shadow: var(--shadow);
    color: var(--slate);
}

.inbox-search input {
    flex: 1;
    border: none;
    background: transparent;
    outline: none;
    font-family: 'Inter', sans-serif;
    font-size: 13.5px;
    color: var(--charcoal);
    padding: 10px 0;
}

.inbox-search input::placeholder { color: #A6A093; }

.inbox-clear {
    border: none;
    background: transparent;
    color: #9A947F;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    padding: 0 2px;
}

.inbox-clear:hover { color: var(--ink); }

.inbox-filter {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--white);
    border: 1px solid var(--paper-line);
    border-radius: 10px;
    padding: 0 10px 0 12px;
    box-shadow: var(--shadow);
}

.inbox-filter label {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    color: #9A947F;
    margin: 0;
}

.inbox-filter select {
    border: none;
    background: transparent;
    outline: none;
    font-family: 'Inter', sans-serif;
    font-size: 13.5px;
    color: var(--charcoal);
    padding: 10px 4px 10px 0;
    cursor: pointer;
    max-width: 180px;
}

.inbox-reset {
    border: 1px solid var(--paper-line);
    background: var(--paper);
    color: var(--charcoal-soft);
    border-radius: 9px;
    padding: 8px 12px;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
}

.inbox-reset:hover {
    background: #E9E6DD;
    color: var(--ink);
}

.inbox-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #F5F1E6;
    border: 1px solid var(--paper-line);
    border-radius: 999px;
    padding: 6px 8px 6px 12px;
    font-size: 12px;
    color: var(--charcoal-soft);
    font-weight: 600;
}

.inbox-chip button {
    border: none;
    background: transparent;
    color: #9A947F;
    font-size: 15px;
    line-height: 1;
    cursor: pointer;
    padding: 0 2px;
}

.inbox-chip button:hover { color: var(--ink); }

.inbox-count {
    margin-left: auto;
    font-size: 12px;
    color: #9A947F;
    font-family: 'IBM Plex Mono', monospace;
}

.th-with-filter {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.th-filter-icon {
    color: #C7C2B3;
    opacity: 0.9;
}

.th-filter-icon.active { color: var(--gold); }

.inbox-card {
    background: var(--white);
    border: 1px solid var(--paper-line);
    border-radius: 12px;
    overflow: auto;
    box-shadow: var(--shadow);
    flex: 1;
    min-height: 0;
}

.inbox-table {
    width: 100%;
    border-collapse: collapse;
}

.inbox-table th {
    text-align: left;
    font-size: 11px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: #9A947F;
    padding: 12px 16px;
    border-bottom: 1px solid var(--paper-line);
    background: #FBF9F4;
}

.inbox-table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--paper-line);
    font-size: 14px;
    vertical-align: middle;
}

.inbox-table tr { cursor: pointer; }
.inbox-table tbody tr:hover { background: #FBF9F4; }
.inbox-empty { padding: 28px 16px; color: var(--charcoal-soft); font-size: 14px; }

.status-seal {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px 4px 8px;
    border-radius: 20px;
    background: var(--gold-soft);
    border: 1px solid #E4CE9C;
    color: #8A611F;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.3px;
    text-transform: uppercase;
}

.status-seal .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--gold);
}

.status-seal.resolved {
    background: var(--green-soft);
    border-color: #BEDACB;
    color: var(--green);
}

.status-seal.resolved .dot { background: var(--green); }

.create-panel {
    background: var(--white);
    border: 1px solid var(--paper-line);
    border-radius: 12px;
    padding: 16px;
    box-shadow: var(--shadow);
}

.create-panel label {
    font-size: 12px;
    font-weight: 600;
    color: var(--charcoal-soft);
    display: block;
    margin-bottom: 6px;
}

.create-panel .form-control,
.create-panel textarea {
    border: 1px solid var(--paper-line);
    border-radius: 8px;
    background: #fff;
    font-size: 14px;
}

/* ---------- Ticket detail / chat ---------- */
.ticket-page {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    overflow: hidden;
}

.topbar {
    background: var(--white);
    border-bottom: 1px solid var(--paper-line);
    padding: 16px 28px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    flex-shrink: 0;
}

.topbar-left { display: flex; flex-direction: column; gap: 6px; min-width: 0; }

.back-link {
    font-size: 12.5px;
    color: var(--slate);
    text-decoration: none;
    font-weight: 500;
}

.back-link:hover { color: var(--ink); }

.ticket-title-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.ticket-title {
    font-family: 'Source Serif 4', serif;
    font-size: 22px;
    font-weight: 600;
    color: var(--ink-deep);
    margin: 0;
}

.ticket-meta {
    font-size: 12.5px;
    color: var(--charcoal-soft);
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.ticket-meta .case-id {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 11px;
    color: #8891A3;
    background: #F0EEE7;
    padding: 2px 7px;
    border-radius: 5px;
    border: 1px solid var(--paper-line);
}

.topbar-actions { display: flex; gap: 10px; flex-shrink: 0; flex-wrap: wrap; }

.meeting-banner {
    margin: 12px 28px 0;
    background: var(--white);
    border: 1px solid var(--paper-line);
    border-radius: 12px;
    padding: 12px 14px;
    box-shadow: var(--shadow);
    flex: 0 0 auto;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 0;
}

.meeting-banner.is-expanded {
    flex: 1 1 auto;
    min-height: 0;
    margin-bottom: 0;
}

.ticket-page.has-expanded-meeting .drop-zone {
    flex: 0 1 15%;
    max-height: 17%;
    min-height: 118px; /* composer stays usable */
}

.ticket-page.has-expanded-meeting .thread {
    padding-top: 10px;
    padding-bottom: 8px;
}

.meeting-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    flex-shrink: 0;
}

.meeting-link {
    font-size: 13px;
    font-weight: 600;
    margin-right: 4px;
}

.meeting-expand-btn {
    margin-left: auto;
}

.daily-frame {
    width: 100%;
    height: 280px;
    background: var(--ink-deep);
    border-radius: 8px;
    overflow: hidden;
    flex: 0 0 auto;
    position: relative;
}

.meeting-banner.is-expanded .daily-frame {
    flex: 1 1 auto;
    height: 0; /* fill remaining banner height in the flex column */
    min-height: 0;
}

.daily-frame > iframe {
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    border: 0 !important;
    border-radius: 8px;
}

.daily-frame.is-ended {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.daily-ended-msg {
    color: #C7CEDD;
    font-size: 13px;
    text-align: center;
    line-height: 1.45;
    max-width: 28rem;
}

.daily-ended-msg strong {
    color: #fff;
}

.thread {
    flex: 1 1 auto;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 26px 28px 32px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background-image: radial-gradient(circle, #E3DFD1 1px, transparent 1px);
    background-size: 22px 22px;
    background-position: -8px -8px;
    min-height: 0;
}

.day-divider {
    align-self: center;
    font-size: 11px;
    color: #9A947F;
    background: #EFEBDF;
    padding: 4px 12px;
    border-radius: 20px;
    letter-spacing: 0.3px;
}

.msg-row {
    display: flex;
    gap: 10px;
    max-width: 64%;
}

.msg-row.mine {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.msg-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
    color: #fff;
    margin-top: 2px;
}

.msg-avatar.client { background: var(--slate); }
.msg-avatar.agent { background: var(--gold); color: #4A3410; }

.msg-col { display: flex; flex-direction: column; gap: 4px; }
.msg-row.mine .msg-col { align-items: flex-end; }

.msg-meta {
    font-size: 11px;
    color: #9A947F;
    display: flex;
    gap: 6px;
    align-items: center;
    padding: 0 2px;
}

.msg-meta .name { font-weight: 600; color: var(--charcoal-soft); }
.msg-meta .mono-time { font-family: 'IBM Plex Mono', monospace; font-size: 10px; }

.edited-tag {
    font-size: 10px;
    color: #A6A093;
    font-style: italic;
}

.msg-edit-btn {
    border: none;
    background: transparent;
    color: var(--ink);
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    padding: 0 2px;
}

.msg-edit-btn:hover { color: var(--ink); }
.msg-edit-btn:disabled { opacity: .5; cursor: not-allowed; }

.bubble {
    background: var(--white);
    border: 1px solid var(--paper-line);
    border-radius: 14px 14px 14px 4px;
    padding: 11px 15px;
    font-size: 14px;
    line-height: 1.5;
    color: var(--charcoal);
    box-shadow: var(--shadow);
    white-space: pre-wrap;
    word-break: break-word;
}

.msg-row.mine .bubble {
    background: var(--ink);
    color: #EEF1F7;
    border-color: var(--ink);
    border-radius: 14px 14px 4px 14px;
}

.bubble-edit {
    width: min(420px, 100%);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.bubble-edit-input {
    width: 100%;
    border: 1px solid var(--paper-line);
    border-radius: 10px;
    padding: 10px 12px;
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    line-height: 1.45;
    color: var(--charcoal);
    background: var(--white);
    resize: vertical;
    min-height: 72px;
}

.msg-row.mine .bubble-edit-input {
    border-color: #5A6A86;
}

.bubble-edit-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.msg-edit-cancel,
.msg-edit-save {
    border-radius: 8px;
    padding: 6px 12px;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
}

.msg-edit-cancel {
    border: 1px solid var(--paper-line);
    background: var(--paper);
    color: var(--charcoal-soft);
}

.msg-edit-save {
    border: none;
    background: var(--ink);
    color: #fff;
}

.msg-edit-save:disabled,
.msg-edit-cancel:disabled {
    opacity: .5;
    cursor: not-allowed;
}

.exhibit-card {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--white);
    border: 1px solid var(--paper-line);
    border-radius: 12px;
    padding: 12px 14px;
    box-shadow: var(--shadow);
    text-decoration: none;
    color: inherit;
    max-width: 360px;
}

.msg-delete-btn {
    border: none;
    background: transparent;
    color: #A33;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    padding: 0 2px;
}

.msg-delete-btn:hover { text-decoration: underline; }
.msg-delete-btn:disabled { opacity: .5; cursor: not-allowed; }

.exhibit-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: #FCEFE0;
    color: var(--gold);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.exhibit-label {
    font-size: 10px;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    color: #9A947F;
    font-weight: 600;
}

.exhibit-name { font-size: 13.5px; font-weight: 600; color: var(--ink-deep); display: block; }
.exhibit-sub { font-size: 11.5px; color: var(--charcoal-soft); }

.system-pill {
    align-self: center;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11.5px;
    color: #7C8698;
    background: #EEF0F4;
    border: 1px solid #DEE2EA;
    padding: 6px 14px;
    border-radius: 20px;
    font-family: 'IBM Plex Mono', monospace;
    max-width: 80%;
    text-align: center;
}

.composer {
    background: var(--white);
    border-top: 1px solid var(--paper-line);
    padding: 14px 20px;
    flex-shrink: 0;
}

.drop-zone {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.drop-overlay {
    display: none;
    position: absolute;
    inset: 8px;
    z-index: 20;
    border: 2px dashed #8A9BB8;
    border-radius: 14px;
    background: rgba(251, 249, 244, 0.92);
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.drop-zone.is-dragging .drop-overlay { display: flex; }

.drop-overlay-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    color: var(--ink);
    text-align: center;
    padding: 16px;
}

.drop-overlay-card strong {
    font-size: 15px;
    font-weight: 600;
}

.drop-overlay-card span {
    font-size: 12.5px;
    color: var(--charcoal-soft);
}

.composer-row {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--paper);
    border: 1px solid var(--paper-line);
    border-radius: 12px;
    padding: 6px 8px 6px 12px;
    transition: border-color .15s ease, box-shadow .15s ease;
}

.drop-zone.is-dragging .composer-row {
    border-color: #8A9BB8;
    box-shadow: 0 0 0 3px rgba(58, 77, 116, 0.12);
}

.icon-btn {
    width: 36px;
    height: 36px;
    border-radius: 9px;
    border: none;
    background: transparent;
    color: var(--slate);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
}

.icon-btn:hover { background: #E9E6DD; color: var(--ink); }

.icon-btn.recording {
    background: #F8E6E6;
    color: #A33;
}

.icon-btn.recording:hover {
    background: #F0D0D0;
    color: #8A2020;
}

.icon-btn input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.composer-input {
    flex: 1;
    border: none;
    background: transparent;
    outline: none;
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    color: var(--charcoal);
    padding: 8px 4px;
}

.composer-input::placeholder { color: #A6A093; }

.send-btn {
    background: var(--ink);
    color: #fff;
    border: none;
    border-radius: 9px;
    padding: 9px 18px;
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 7px;
    flex-shrink: 0;
}

.send-btn:disabled { opacity: .5; cursor: not-allowed; }
.send-btn:hover:not(:disabled) { background: var(--ink-deep); }

.composer-hint {
    font-size: 10.5px;
    color: #A6A093;
    margin: 8px 2px 0;
}

.composer-error {
    font-size: 12px;
    color: #a33;
    margin-top: 6px;
}

.hero-panel {
    margin: 28px;
    padding: 2rem 1.5rem;
    border-radius: 14px;
    background: linear-gradient(185deg, var(--ink) 0%, var(--ink-deep) 100%);
    color: #EDEFF4;
}

.hero-panel h1 {
    font-family: 'Source Serif 4', serif;
    font-size: 28px;
    margin: 0 0 8px;
}

.hero-panel .lead {
    opacity: .9;
    max-width: 36rem;
    margin: 0 0 16px;
}

/* Guest / no-session shell (no sidebar) */
.guest-shell {
    height: 100%;
    height: 100dvh;
    max-height: 100dvh;
    overflow: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 28px;
    background: #E9E6DD;
}

.guest-card {
    width: 100%;
    max-width: 560px;
    background: var(--white);
    border: 1px solid #D9D4C6;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(18, 30, 56, 0.14);
    padding: 28px;
}

.guest-hero .guest-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 22px;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--paper-line);
}

.guest-hero h1 {
    font-family: 'Source Serif 4', serif;
    font-size: 26px;
    font-weight: 600;
    color: var(--ink-deep);
    margin: 0 0 10px;
}

.guest-hero .lead {
    margin: 0;
    font-size: 14.5px;
    line-height: 1.55;
    color: var(--charcoal-soft);
}

.guest-admin-link {
    margin: 18px 0 0;
    font-size: 13px;
}

.guest-admin-link a {
    color: var(--ink);
    font-weight: 600;
    text-decoration: none;
}

.guest-admin-link a:hover {
    text-decoration: underline;
}

.admin-login-form {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 18px;
}

.admin-login-form label {
    font-size: 12px;
    font-weight: 600;
    color: var(--charcoal-soft);
    margin-top: 6px;
}

.admin-login-form .form-control {
    margin-bottom: 4px;
}

.admin-login-form .btn-support {
    margin-top: 14px;
    align-self: flex-start;
}

.admin-recaptcha {
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: flex-start;
}

.btn-ghost {
    background: transparent;
    border-color: #C7CEDD;
    color: var(--ink);
}

.btn-ghost:hover:not(:disabled) {
    background: #F3F5F9;
    border-color: var(--ink);
}

.btn-danger-ghost {
    background: transparent;
    border-color: #E2C4C4;
    color: #9a3b3b;
}

.btn-danger-ghost:hover:not(:disabled) {
    background: #F8EEEE;
    border-color: #9a3b3b;
}

.admin-users-panel {
    margin-bottom: 16px;
}

.admin-editor-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 8px;
}

.admin-users-table-wrap {
    background: var(--white);
    border: 1px solid var(--paper-line);
    border-radius: 12px;
    overflow: auto;
    box-shadow: var(--shadow);
}

.admin-users-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.admin-users-table th,
.admin-users-table td {
    padding: 12px 14px;
    text-align: left;
    border-bottom: 1px solid var(--paper-line);
    vertical-align: middle;
}

.admin-users-table th {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--slate);
    background: #F7F5EF;
}

.admin-users-table tr:last-child td {
    border-bottom: none;
}

.admin-row-actions {
    display: flex;
    gap: 6px;
    justify-content: flex-end;
    white-space: nowrap;
}

.admin-status {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 999px;
}

.admin-status.on {
    background: #D7E9DD;
    color: var(--green);
}

.admin-status.off {
    background: #EEECEA;
    color: #7A7468;
}

.admin-success {
    font-size: 12px;
    color: var(--green);
}

/* ---------- Home analytics ---------- */
.dash-page {
    padding: 24px 28px;
    height: 100%;
    min-height: 0;
    overflow: auto;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.dash-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    flex-shrink: 0;
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}

.stat-card {
    background: var(--white);
    border: 1px solid var(--paper-line);
    border-radius: 12px;
    padding: 14px 16px;
    box-shadow: var(--shadow);
    text-decoration: none;
    color: inherit;
    display: block;
    transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}

a.stat-card:hover {
    border-color: #C9C2AE;
    box-shadow: 0 4px 14px rgba(40, 48, 64, 0.08);
    transform: translateY(-1px);
}

a.stat-card:focus-visible {
    outline: 2px solid var(--ink);
    outline-offset: 2px;
}

.stat-label {
    font-size: 11px;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    color: #9A947F;
    font-weight: 600;
}

.stat-value {
    margin-top: 6px;
    font-family: 'Source Serif 4', serif;
    font-size: 28px;
    font-weight: 600;
    color: var(--ink-deep);
}

.stat-value.accent { color: var(--gold); }
.stat-value.success { color: var(--green); }

.chart-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.chart-card {
    background: var(--white);
    border: 1px solid var(--paper-line);
    border-radius: 12px;
    padding: 16px 18px;
    box-shadow: var(--shadow);
    min-height: 240px;
}

.chart-card-wide { grid-column: 1 / -1; }

.chart-title {
    margin: 0 0 14px;
    font-family: 'Source Serif 4', serif;
    font-size: 17px;
    font-weight: 600;
    color: var(--ink-deep);
}

.pie-layout {
    display: flex;
    align-items: center;
    gap: 22px;
    flex-wrap: wrap;
}

.pie-donut {
    width: 150px;
    height: 150px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    flex-shrink: 0;
    text-decoration: none;
    color: inherit;
}

a.pie-donut:hover .pie-hole {
    background: #F5F1E6;
}

.pie-hole {
    width: 84px;
    height: 84px;
    border-radius: 50%;
    background: #FBF9F4;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: background .15s ease;
}

.pie-center {
    font-family: 'Source Serif 4', serif;
    font-size: 22px;
    font-weight: 600;
    color: var(--ink-deep);
    line-height: 1;
}

.pie-center-sub {
    font-size: 10px;
    color: #9A947F;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.pie-legend {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
    min-width: 160px;
}

.pie-legend li {
    margin: 0;
}

.pie-legend-link {
    display: grid;
    grid-template-columns: 12px 1fr auto;
    gap: 8px;
    align-items: center;
    font-size: 13px;
    color: var(--charcoal-soft);
    text-decoration: none;
    border-radius: 8px;
    padding: 4px 6px;
    margin: -4px -6px;
}

.pie-legend-link:hover {
    background: #F5F1E6;
    color: var(--ink-deep);
}

.pie-legend .swatch {
    width: 10px;
    height: 10px;
    border-radius: 3px;
}

.bar-chart {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    height: 170px;
    padding-top: 8px;
}

.bar-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    height: 100%;
    text-decoration: none;
    color: inherit;
    border-radius: 8px;
    padding: 2px;
}

a.bar-col:hover .bar-fill {
    filter: brightness(1.12);
}

a.bar-col.has-data:hover .bar-count {
    color: var(--ink-deep);
}

.bar-track {
    flex: 1;
    width: 100%;
    max-width: 36px;
    background: #F0EEE7;
    border-radius: 8px 8px 4px 4px;
    display: flex;
    align-items: flex-end;
    overflow: hidden;
}

.bar-fill {
    width: 100%;
    background: linear-gradient(180deg, #3A4D74 0%, var(--ink) 100%);
    border-radius: 8px 8px 0 0;
    min-height: 4px;
    transition: filter .15s ease;
}

.bar-label {
    font-size: 11px;
    color: #9A947F;
    font-weight: 600;
}

.bar-count {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 10px;
    color: var(--charcoal-soft);
}

.firm-bars {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.firm-row {
    display: grid;
    grid-template-columns: minmax(100px, 180px) 1fr 36px;
    gap: 10px;
    align-items: center;
    text-decoration: none;
    color: inherit;
    border-radius: 8px;
    padding: 6px 8px;
    margin: -6px -8px;
}

a.firm-row:hover {
    background: #F5F1E6;
}

.firm-name {
    font-size: 13px;
    color: var(--charcoal);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.firm-track {
    height: 10px;
    background: #F0EEE7;
    border-radius: 999px;
    overflow: hidden;
}

.firm-fill {
    height: 100%;
    background: var(--gold);
    border-radius: 999px;
}

.firm-count {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 12px;
    color: var(--charcoal-soft);
    text-align: right;
}

@media (max-width: 900px) {
    .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .chart-grid { grid-template-columns: 1fr; }
    .dash-page { padding: 16px 14px; }
    .firm-row { grid-template-columns: 1fr; gap: 4px; }
}

.thread::-webkit-scrollbar { width: 8px; }
.thread::-webkit-scrollbar-thumb { background: #D2CCBB; border-radius: 8px; }
.inbox-card::-webkit-scrollbar { width: 8px; }
.inbox-card::-webkit-scrollbar-thumb { background: #D2CCBB; border-radius: 8px; }

@media (max-width: 900px) {
    .app-shell {
        padding: 0;
    }

    .app {
        width: 100%;
        border-radius: 0;
        border: 0;
        max-width: none;
        box-shadow: none;
    }

    .mobile-bar {
        display: flex;
    }

    .sidebar-close {
        display: flex;
        align-self: flex-end;
        width: 36px;
        height: 36px;
        margin: -6px 0 10px;
        border-radius: 8px;
        align-items: center;
        justify-content: center;
        font-size: 24px;
        color: #C7CEDD;
        cursor: pointer;
    }

    .sidebar-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(18, 30, 56, 0.45);
        z-index: 30;
        opacity: 0;
        pointer-events: none;
        transition: opacity .2s ease;
    }

    .nav-drawer-toggle:checked ~ .app .sidebar-backdrop {
        opacity: 1;
        pointer-events: auto;
    }

    .sidebar-panel {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: min(280px, 86vw);
        z-index: 40;
        transform: translateX(-105%);
        transition: transform .22s ease;
        box-shadow: 8px 0 30px rgba(18, 30, 56, 0.25);
    }

    .nav-drawer-toggle:checked ~ .app .sidebar-panel {
        transform: translateX(0);
    }

    .topbar {
        padding: 12px 14px;
        flex-direction: column;
    }

    .topbar-actions {
        width: 100%;
    }

    .topbar-actions .btn-support {
        flex: 1;
        justify-content: center;
    }

    .ticket-title {
        font-size: 18px;
    }

    .thread {
        padding: 16px 14px;
    }

    .msg-row {
        max-width: 92%;
    }

    .composer {
        padding: 10px 12px;
    }

    .inbox-page {
        padding: 16px 14px;
    }

    .inbox-toolbar {
        gap: 8px;
    }

    .inbox-search {
        flex: 1 1 100%;
        max-width: none;
    }

    .inbox-count {
        margin-left: 0;
        width: 100%;
    }

    .meeting-banner {
        margin: 10px 14px 0;
    }

    /* Mobile: leave more room for composer + a little thread history */
    .ticket-page.has-expanded-meeting .drop-zone {
        flex: 0 1 36%;
        max-height: 38%;
        min-height: 150px;
    }

    .daily-frame {
        height: 200px;
    }
}

@media (max-width: 520px) {
    .composer-row {
        flex-wrap: wrap;
    }

    .send-btn {
        width: 100%;
        justify-content: center;
    }

    .msg-row {
        max-width: 100%;
    }

    /* Narrow phones: expanded call keeps composer, hides thread scroll */
    .ticket-page.has-expanded-meeting .drop-zone {
        flex: 0 0 auto;
        max-height: none;
        min-height: 0;
    }

    .ticket-page.has-expanded-meeting .thread {
        display: none;
    }

    .ticket-page.has-expanded-meeting .composer {
        padding: 8px 10px;
    }

    .daily-frame {
        height: 180px;
    }
}
