@import url("https://cdn.jsdelivr.net/npm/bootstrap-icons@1.13.1/font/bootstrap-icons.min.css");
@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap");

/* ==========================================================================
   Theme tokens - monochrome. Reskin by changing these variables only.
   ========================================================================== */
:root {
    --bg: #fafafa;
    --surface: #ffffff;
    --surface-2: #f4f4f5;
    --surface-3: #e4e4e7;
    --border: #e4e4e7;
    --border-strong: #d4d4d8;
    --text: #09090b;
    --text-2: #3f3f46;
    --muted: #71717a;
    --faint: #a1a1aa;
    --primary: #09090b;
    --primary-fg: #fafafa;
    --primary-hover: #27272a;
    --hover: #f4f4f5;
    --active: #ececee;
    --ring: rgba(9, 9, 11, 0.14);
    --overlay: rgba(9, 9, 11, 0.4);
    --bubble-in: #f4f4f5;
    --bubble-out: #18181b;
    --bubble-out-fg: #fafafa;
    --note-bg: #fafafa;
    --chart-1: #18181b;
    --chart-2: #a1a1aa;
    /* Semantic status colours - used only for state (success, warning, danger, info), never decoration. */
    --success: #15803d;
    --success-bg: #dcfce7;
    --success-border: #86efac;
    --warning: #b45309;
    --warning-bg: #fef3c7;
    --warning-border: #fcd34d;
    --danger: #dc2626;
    --danger-bg: #fee2e2;
    --danger-border: #fca5a5;
    --info: #1d4ed8;
    --info-bg: #dbeafe;
    --info-border: #93c5fd;
    --whatsapp: #16a34a;
    --tick-read: #2563eb;
    --shadow-sm: 0 1px 2px rgba(9, 9, 11, 0.05);
    --shadow-md: 0 4px 16px rgba(9, 9, 11, 0.08);
    --shadow-lg: 0 24px 64px rgba(9, 9, 11, 0.18);
    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 14px;
    --sidebar-w: 248px;
    --sidebar-w-collapsed: 68px;
    --topbar-h: 64px;
    --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
    --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    color-scheme: light;
}

:root[data-theme="dark"] {
    --bg: #09090b;
    --surface: #111113;
    --surface-2: #18181b;
    --surface-3: #27272a;
    --border: #27272a;
    --border-strong: #3f3f46;
    --text: #fafafa;
    --text-2: #d4d4d8;
    --muted: #a1a1aa;
    --faint: #71717a;
    --primary: #fafafa;
    --primary-fg: #09090b;
    --primary-hover: #e4e4e7;
    --hover: #18181b;
    --active: #222225;
    --ring: rgba(250, 250, 250, 0.18);
    --overlay: rgba(0, 0, 0, 0.6);
    --bubble-in: #1c1c1f;
    --bubble-out: #f4f4f5;
    --bubble-out-fg: #09090b;
    --note-bg: #141416;
    --chart-1: #fafafa;
    --chart-2: #52525b;
    --success: #4ade80;
    --success-bg: rgba(34, 197, 94, 0.14);
    --success-border: rgba(74, 222, 128, 0.35);
    --warning: #fbbf24;
    --warning-bg: rgba(245, 158, 11, 0.14);
    --warning-border: rgba(251, 191, 36, 0.35);
    --danger: #f87171;
    --danger-bg: rgba(239, 68, 68, 0.15);
    --danger-border: rgba(248, 113, 113, 0.4);
    --info: #60a5fa;
    --info-bg: rgba(59, 130, 246, 0.15);
    --info-border: rgba(96, 165, 250, 0.4);
    --whatsapp: #22c55e;
    --tick-read: #60a5fa;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 24px 64px rgba(0, 0, 0, 0.7);
    color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #09090b;
        --surface: #111113;
        --surface-2: #18181b;
        --surface-3: #27272a;
        --border: #27272a;
        --border-strong: #3f3f46;
        --text: #fafafa;
        --text-2: #d4d4d8;
        --muted: #a1a1aa;
        --faint: #71717a;
        --primary: #fafafa;
        --primary-fg: #09090b;
        --primary-hover: #e4e4e7;
        --hover: #18181b;
        --active: #222225;
        --ring: rgba(250, 250, 250, 0.18);
        --overlay: rgba(0, 0, 0, 0.6);
        --bubble-in: #1c1c1f;
        --bubble-out: #f4f4f5;
        --bubble-out-fg: #09090b;
        --note-bg: #141416;
        --chart-1: #fafafa;
        --chart-2: #52525b;
    --success: #4ade80;
    --success-bg: rgba(34, 197, 94, 0.14);
    --success-border: rgba(74, 222, 128, 0.35);
    --warning: #fbbf24;
    --warning-bg: rgba(245, 158, 11, 0.14);
    --warning-border: rgba(251, 191, 36, 0.35);
    --danger: #f87171;
    --danger-bg: rgba(239, 68, 68, 0.15);
    --danger-border: rgba(248, 113, 113, 0.4);
    --info: #60a5fa;
    --info-bg: rgba(59, 130, 246, 0.15);
    --info-border: rgba(96, 165, 250, 0.4);
    --whatsapp: #22c55e;
    --tick-read: #60a5fa;
        --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
        --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.5);
        --shadow-lg: 0 24px 64px rgba(0, 0, 0, 0.7);
        color-scheme: dark;
    }
}

/* ==========================================================================
   Base
   ========================================================================== */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
    background-color: var(--bg);
    -webkit-font-smoothing: antialiased;
    font-feature-settings: "cv11", "ss01";
}

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

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

button {
    font: inherit;
    color: inherit;
}

[hidden] {
    display: none !important;
}

::selection {
    background: var(--primary);
    color: var(--primary-fg);
}

::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--surface-3);
    border-radius: 10px;
    border: 3px solid transparent;
    background-clip: content-box;
}

::-webkit-scrollbar-thumb:hover {
    background-color: var(--border-strong);
}

.muted {
    color: var(--muted);
}

.small {
    font-size: 12px;
}

.mono {
    font-family: var(--mono);
    font-size: 12px;
}

.nowrap {
    white-space: nowrap;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
}

/* ==========================================================================
   App shell: sidebar + main
   ========================================================================== */
.app {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    position: sticky;
    top: 0;
    width: var(--sidebar-w);
    height: 100vh;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 14px 12px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    transition: width 0.2s ease;
    z-index: 30;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 6px 14px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 6px;
    min-height: 52px;
}

.brand-mark {
    width: 34px;
    height: 34px;
    border-radius: 9px;
    background: var(--primary);
    color: var(--primary-fg);
    display: grid;
    place-items: center;
    flex-shrink: 0;
    font-size: 17px;
}

.brand-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.brand-name {
    font-weight: 600;
    font-size: 14px;
    letter-spacing: -0.01em;
}

.brand-sub {
    font-size: 12px;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-collapse {
    margin-left: auto;
}

.nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    overflow-y: auto;
}

.nav-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--faint);
    padding: 14px 10px 6px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 8px;
    color: var(--text-2);
    font-weight: 500;
    font-size: 13.5px;
    position: relative;
    white-space: nowrap;
}

.nav-item i {
    font-size: 17px;
    width: 20px;
    text-align: center;
    color: var(--muted);
}

.nav-item:hover {
    background: var(--hover);
    color: var(--text);
}

.nav-item.active {
    background: var(--active);
    color: var(--text);
}

.nav-item.active i {
    color: var(--text);
}

.nav-item.is-locked {
    opacity: 0.5;
}

.nav-lock {
    margin-left: auto;
    font-size: 11px !important;
    width: auto !important;
}

.nav-badge {
    margin-left: auto;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 10px;
    background: var(--primary);
    color: var(--primary-fg);
    font-size: 11px;
    font-weight: 600;
    display: inline-grid;
    place-items: center;
}

.sidebar-footer {
    border-top: 1px solid var(--border);
    padding-top: 10px;
    position: relative;
}

.user-button {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px;
    border: 0;
    background: transparent;
    border-radius: 8px;
    cursor: pointer;
    text-align: left;
}

.user-button:hover {
    background: var(--hover);
}

.user-meta {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
}

.user-name {
    font-weight: 500;
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    font-size: 12px;
    color: var(--muted);
}

.app.sidebar-collapsed .sidebar {
    width: var(--sidebar-w-collapsed);
}

.app.sidebar-collapsed .brand-text,
.app.sidebar-collapsed .nav-item span,
.app.sidebar-collapsed .nav-label,
.app.sidebar-collapsed .user-meta,
.app.sidebar-collapsed .user-button > .bi-chevron-expand {
    display: none;
}

.app.sidebar-collapsed .nav-item {
    justify-content: center;
}

.app.sidebar-collapsed .nav-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    min-width: 16px;
    height: 16px;
    font-size: 10px;
    padding: 0 4px;
}

.app.sidebar-collapsed .brand {
    flex-direction: column;
    gap: 8px;
}

.app.sidebar-collapsed .sidebar-collapse {
    margin-left: 0;
    transform: rotate(180deg);
}

.sidebar-overlay {
    display: none;
}

.main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    min-height: var(--topbar-h);
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 28px;
    background: color-mix(in srgb, var(--bg) 85%, transparent);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
}

.topbar-title {
    flex: 1;
    min-width: 0;
}

.topbar-title h1 {
    font-size: 18px;
    font-weight: 600;
    letter-spacing: -0.02em;
    line-height: 1.3;
}

.topbar-title p {
    color: var(--muted);
    font-size: 13px;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.drawer-toggle {
    display: none;
}

.page {
    padding: 24px 28px 48px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    width: 100%;
    max-width: 1280px;
}

.page-narrow {
    max-width: 880px;
}

.page-full {
    max-width: none;
    padding: 0;
    flex: 1;
    min-height: 0;
}

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    height: 36px;
    padding: 0 14px;
    border-radius: 8px;
    border: 1px solid transparent;
    font-size: 13.5px;
    font-weight: 500;
    line-height: 1;
    cursor: pointer;
    white-space: nowrap;
    transition: background-color 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
    user-select: none;
}

.btn i {
    font-size: 15px;
}

.btn:focus-visible,
.icon-btn:focus-visible,
.nav-item:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--ring);
}

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

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

.btn-secondary {
    background: var(--surface);
    border-color: var(--border);
    color: var(--text);
    box-shadow: var(--shadow-sm);
}

.btn-secondary:hover {
    background: var(--hover);
    border-color: var(--border-strong);
}

.btn-ghost {
    background: transparent;
    color: var(--text-2);
}

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

.btn-danger {
    background: transparent;
    border-color: var(--border-strong);
    color: var(--text);
}

.btn-danger:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--primary-fg);
}

.btn-sm {
    height: 30px;
    padding: 0 10px;
    font-size: 12.5px;
    border-radius: 7px;
}

.btn-lg {
    height: 42px;
    padding: 0 18px;
    font-size: 14px;
}

.btn-block {
    width: 100%;
}

.btn[disabled],
.btn[aria-disabled="true"] {
    opacity: 0.45;
    pointer-events: none;
}

.icon-btn {
    width: 34px;
    height: 34px;
    display: inline-grid;
    place-items: center;
    border: 1px solid transparent;
    background: transparent;
    border-radius: 8px;
    color: var(--muted);
    cursor: pointer;
    font-size: 17px;
    flex-shrink: 0;
}

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

.icon-btn[disabled] {
    opacity: 0.3;
    pointer-events: none;
}

.icon-btn.bordered {
    border-color: var(--border);
    background: var(--surface);
}

.icon-btn.active {
    background: var(--active);
    color: var(--text);
}

/* ==========================================================================
   Forms
   ========================================================================== */
.form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

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

.form-row-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.field > label,
.label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
}

.form-hint {
    font-size: 12px;
    color: var(--muted);
}

.form-error {
    font-size: 12px;
    color: var(--text);
    font-weight: 500;
    min-height: 16px;
}

.form-error:not(:empty)::before {
    content: "\F33B";
    font-family: "bootstrap-icons";
    margin-right: 5px;
}

.input,
.select,
.textarea {
    width: 100%;
    height: 38px;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: 14px;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
    box-shadow: var(--shadow-sm);
}

.textarea {
    height: auto;
    min-height: 90px;
    padding: 10px 12px;
    resize: vertical;
    line-height: 1.5;
}

.select {
    appearance: none;
    padding-right: 34px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 16 16'%3E%3Cpath fill='%2371717a' d='M8 11L3 6h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}

.input::placeholder,
.textarea::placeholder {
    color: var(--faint);
}

.input:focus,
.select:focus,
.textarea:focus {
    border-color: var(--text);
    box-shadow: 0 0 0 3px var(--ring);
}

.input[readonly] {
    background: var(--surface-2);
    color: var(--text-2);
}

.input-sm,
.select-sm {
    height: 32px;
    font-size: 13px;
    padding: 0 10px;
}

.select-sm {
    padding-right: 30px;
    background-position: right 10px center;
}

.input-group {
    display: flex;
    gap: 8px;
    align-items: center;
}

.input-group .input {
    flex: 1;
}

.input-icon {
    position: relative;
}

.input-icon > i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--faint);
    pointer-events: none;
}

.input-icon .input {
    padding-left: 36px;
}

.input-icon .icon-btn {
    position: absolute;
    right: 3px;
    top: 50%;
    transform: translateY(-50%);
    width: 32px;
    height: 32px;
}

.checkbox {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    cursor: pointer;
    color: var(--text-2);
}

.checkbox input,
.check {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
    cursor: pointer;
    margin: 0;
}

.switch {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 13px;
}

.switch input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.switch-track {
    width: 36px;
    height: 20px;
    border-radius: 20px;
    background: var(--surface-3);
    position: relative;
    transition: background 0.15s;
    flex-shrink: 0;
}

.switch-track::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--surface);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
    transition: transform 0.15s;
}

.switch input:checked + .switch-track {
    background: var(--primary);
}

.switch input:checked + .switch-track::after {
    transform: translateX(16px);
    background: var(--primary-fg);
}

.switch input:focus-visible + .switch-track {
    box-shadow: 0 0 0 3px var(--ring);
}

.form-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    align-items: center;
}

/* ==========================================================================
   Cards, stats, lists
   ========================================================================== */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    min-width: 0;
}

.card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.card-header h2,
.card-header h3 {
    font-size: 15px;
    font-weight: 600;
    letter-spacing: -0.01em;
    flex: 1;
}

.card-header p {
    color: var(--muted);
    font-size: 13px;
}

.card-title-group {
    flex: 1;
    min-width: 0;
}

.card-body {
    padding: 20px;
}

.card-footer {
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

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

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

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
}

.stat {
    padding: 16px 18px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.stat-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: var(--muted);
    font-size: 13px;
    font-weight: 500;
}

.stat-top i {
    font-size: 16px;
}

.stat-value {
    font-size: 28px;
    font-weight: 600;
    letter-spacing: -0.03em;
    line-height: 1.1;
}

.stat-sub {
    font-size: 12px;
    color: var(--muted);
}

.list-plain {
    list-style: none;
    margin: 0;
    padding: 0;
}

.list-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
}

.list-row:last-child {
    border-bottom: 0;
}

a.list-row:hover {
    background: var(--hover);
}

.list-row-main {
    flex: 1;
    min-width: 0;
}

.list-row-title {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.list-row-sub {
    font-size: 12.5px;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

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

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}

.table th {
    text-align: left;
    font-weight: 500;
    font-size: 12px;
    color: var(--muted);
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--surface-2);
    white-space: nowrap;
}

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

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

.table tbody tr:hover {
    background: var(--hover);
}

.table .col-check {
    width: 40px;
    padding-right: 0;
}

.table .col-actions {
    width: 1%;
    white-space: nowrap;
    text-align: right;
}

.cell-main {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.cell-title {
    font-weight: 500;
}

/* Avatars, badges, chips */
.avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--surface-3);
    color: var(--text);
    display: inline-grid;
    place-items: center;
    font-size: 12px;
    font-weight: 600;
    flex-shrink: 0;
    letter-spacing: 0.02em;
}

.avatar-sm {
    width: 24px;
    height: 24px;
    font-size: 10px;
}

.avatar-lg {
    width: 56px;
    height: 56px;
    font-size: 18px;
}

.avatar-dark {
    background: var(--primary);
    color: var(--primary-fg);
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    height: 22px;
    padding: 0 8px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 500;
    white-space: nowrap;
    border: 1px solid var(--border-strong);
    color: var(--text-2);
    background: transparent;
}

.badge i {
    font-size: 10px;
}

.badge-solid {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--primary-fg);
}

.badge-outline {
    border-color: var(--text-2);
    color: var(--text);
}

.badge-dashed {
    border-style: dashed;
    border-color: var(--text-2);
    color: var(--text);
}

.badge-muted {
    background: var(--surface-2);
    border-color: var(--border);
    color: var(--muted);
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    height: 22px;
    padding: 0 8px;
    border-radius: 6px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    font-size: 12px;
    color: var(--text-2);
    white-space: nowrap;
}

.chip button {
    border: 0;
    background: transparent;
    padding: 0;
    margin-left: 2px;
    cursor: pointer;
    color: var(--muted);
    font-size: 13px;
    line-height: 1;
}

.chip button:hover {
    color: var(--text);
}

.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.kbd {
    font-family: var(--mono);
    font-size: 11px;
    padding: 1px 5px;
    border-radius: 4px;
    border: 1px solid var(--border-strong);
    background: var(--surface-2);
}

/* Tabs */
.tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
}

.tab {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 10px 12px;
    font-size: 13.5px;
    font-weight: 500;
    color: var(--muted);
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    white-space: nowrap;
    background: transparent;
    border-top: 0;
    border-left: 0;
    border-right: 0;
    cursor: pointer;
}

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

.tab.active {
    color: var(--text);
    border-bottom-color: var(--text);
}

.tab .count {
    font-size: 11px;
    color: var(--muted);
    background: var(--surface-2);
    border-radius: 999px;
    padding: 1px 7px;
}

.segmented {
    display: inline-flex;
    padding: 3px;
    gap: 2px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 9px;
}

.segmented button,
.segmented a {
    border: 0;
    background: transparent;
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 12.5px;
    font-weight: 500;
    color: var(--muted);
    cursor: pointer;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.segmented .active {
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow-sm);
}

/* Dropdown menus */
.dropdown {
    position: relative;
    display: inline-flex;
}

.menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 200px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    padding: 5px;
    z-index: 60;
    display: none;
    max-height: 340px;
    overflow-y: auto;
}

.menu.open {
    display: block;
}

.menu.menu-floating {
    position: fixed;
    right: auto;
    bottom: auto;
    z-index: 150;
}

.menu.menu-up {
    top: auto;
    bottom: calc(100% + 6px);
}

.menu.menu-left {
    right: auto;
    left: 0;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 9px;
    width: 100%;
    padding: 7px 9px;
    border: 0;
    background: transparent;
    border-radius: 6px;
    font-size: 13px;
    text-align: left;
    color: var(--text);
    cursor: pointer;
    white-space: nowrap;
}

.menu-item i {
    color: var(--muted);
    font-size: 15px;
    width: 16px;
}

.menu-item:hover,
.menu-item.focused {
    background: var(--hover);
}

.menu-item.selected::after {
    content: "\F633";
    font-family: "bootstrap-icons";
    margin-left: auto;
    font-size: 13px;
}

.menu-sep {
    height: 1px;
    background: var(--border);
    margin: 5px 0;
}

.menu-heading {
    font-size: 11px;
    font-weight: 600;
    color: var(--faint);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 8px 9px 4px;
}

/* Empty states */
.empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 8px;
    padding: 48px 24px;
    color: var(--muted);
}

.empty-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    display: grid;
    place-items: center;
    font-size: 22px;
    color: var(--text);
    margin-bottom: 4px;
}

.empty h3 {
    color: var(--text);
    font-size: 15px;
    font-weight: 600;
}

.empty p {
    max-width: 380px;
    font-size: 13.5px;
}

.empty .btn {
    margin-top: 8px;
}

/* Pagination */
.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    border-top: 1px solid var(--border);
}

.pagination-label {
    font-size: 13px;
    color: var(--muted);
}

/* Toolbar (search + filters above lists) */
.toolbar {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
}

.toolbar .input-icon {
    flex: 1;
    min-width: 200px;
    max-width: 380px;
}

.toolbar-spacer {
    flex: 1;
}

.bulk-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}

/* Alerts / callouts */
.callout {
    display: flex;
    gap: 12px;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-2);
    font-size: 13.5px;
}

.callout > i {
    font-size: 18px;
    flex-shrink: 0;
    margin-top: 1px;
}

.callout-strong {
    background: var(--primary);
    color: var(--primary-fg);
    border-color: var(--primary);
}

.callout-strong .btn-secondary {
    box-shadow: none;
}

.callout-dashed {
    border-style: dashed;
    border-color: var(--border-strong);
    background: transparent;
}

.copy-field {
    display: flex;
    align-items: center;
    gap: 8px;
}

.copy-field .input {
    font-family: var(--mono);
    font-size: 12.5px;
}

/* ==========================================================================
   Modal (native <dialog>), toasts, loader
   ========================================================================== */
.modal {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 0;
    width: min(560px, calc(100vw - 32px));
    max-height: calc(100vh - 48px);
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.modal.modal-lg {
    width: min(760px, calc(100vw - 32px));
}

.modal::backdrop {
    background: var(--overlay);
    backdrop-filter: blur(2px);
}

.modal[open] {
    display: flex;
    flex-direction: column;
    animation: modal-in 0.16s ease-out;
}

@keyframes modal-in {
    from {
        opacity: 0;
        transform: translateY(8px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

/* Most modals wrap header/body/footer in a <form>; it has to pass the height limit down so the
   body (not the whole dialog) scrolls and the footer buttons stay visible. */
.modal > form {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    max-height: inherit;
}

.modal-header,
.modal-footer {
    flex-shrink: 0;
}

.modal-body {
    flex: 1 1 auto;
    min-height: 0;
    overscroll-behavior: contain;
}

.modal-header {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 18px 20px 14px;
    border-bottom: 1px solid var(--border);
}

.modal-header h2 {
    font-size: 16px;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.modal-header p {
    font-size: 13px;
    color: var(--muted);
    margin-top: 2px;
}

.modal-header .icon-btn {
    margin-left: auto;
    margin-top: -4px;
    margin-right: -6px;
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
}

.modal-footer {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    background: var(--surface-2);
}

.toasts {
    position: fixed;
    bottom: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 200;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 260px;
    max-width: 380px;
    padding: 12px 14px;
    border-radius: var(--radius);
    background: var(--primary);
    color: var(--primary-fg);
    box-shadow: var(--shadow-lg);
    font-size: 13.5px;
    pointer-events: auto;
    animation: toast-in 0.2s ease-out;
}

.toast.toast-error {
    background: var(--surface);
    color: var(--text);
    border: 1.5px dashed var(--text);
}

.toast i {
    font-size: 16px;
}

@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

.loader-overlay {
    position: fixed;
    inset: 0;
    background: var(--overlay);
    display: none;
    place-items: center;
    z-index: 300;
}

.loader-overlay.show {
    display: grid;
}

.spinner {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2.5px solid var(--surface-3);
    border-top-color: var(--primary);
    animation: spin 0.7s linear infinite;
}

.loader-overlay .spinner {
    width: 36px;
    height: 36px;
    border-color: rgba(255, 255, 255, 0.25);
    border-top-color: #ffffff;
}

.spinner-sm {
    width: 16px;
    height: 16px;
    border-width: 2px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.skeleton {
    background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 37%, var(--surface-2) 63%);
    background-size: 400% 100%;
    animation: shimmer 1.3s ease infinite;
    border-radius: 6px;
}

@keyframes shimmer {
    0% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0 50%;
    }
}

/* ==========================================================================
   Auth pages
   ========================================================================== */
.auth-shell {
    flex: 1;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    min-height: 100vh;
}

.auth-aside {
    background: var(--primary);
    color: var(--primary-fg);
    padding: 48px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: relative;
    overflow: hidden;
}

.auth-aside::after {
    content: "";
    position: absolute;
    inset: 0;
    background-image: radial-gradient(color-mix(in srgb, var(--primary-fg) 12%, transparent) 1px, transparent 1px);
    background-size: 22px 22px;
    mask-image: linear-gradient(to bottom, transparent, black 60%);
    pointer-events: none;
}

.auth-aside .brand-mark {
    background: var(--primary-fg);
    color: var(--primary);
}

.auth-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    font-size: 15px;
}

.auth-pitch {
    position: relative;
    z-index: 1;
}

.auth-pitch h2 {
    font-size: 30px;
    line-height: 1.15;
    letter-spacing: -0.03em;
    font-weight: 600;
    max-width: 440px;
}

.auth-pitch ul {
    list-style: none;
    padding: 0;
    margin: 24px 0 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
    font-size: 14px;
    opacity: 0.85;
}

.auth-pitch li {
    display: flex;
    gap: 10px;
    align-items: center;
}

.auth-main {
    display: grid;
    place-items: center;
    padding: 32px 20px;
}

.auth-card {
    width: 100%;
    max-width: 380px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.auth-card-wide {
    max-width: 460px;
}

.auth-card h1 {
    font-size: 24px;
    font-weight: 600;
    letter-spacing: -0.03em;
}

.auth-card .lead {
    color: var(--muted);
    margin-top: 4px;
}

.auth-alt {
    text-align: center;
    font-size: 13.5px;
    color: var(--muted);
}

.auth-alt a {
    color: var(--text);
    font-weight: 500;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.inline-error {
    display: flex;
    gap: 8px;
    align-items: center;
    padding: 10px 12px;
    border: 1.5px dashed var(--text);
    border-radius: 8px;
    font-size: 13px;
}

/* ==========================================================================
   Dashboard
   ========================================================================== */
.chart {
    width: 100%;
    height: auto;
    display: block;
}

.chart text {
    fill: var(--muted);
    font-size: 11px;
    font-family: var(--font);
}

.chart .bar-in {
    fill: var(--chart-2);
}

.chart .bar-out {
    fill: var(--chart-1);
}

.chart .grid-line {
    stroke: var(--border);
    stroke-width: 1;
}

.legend {
    display: flex;
    gap: 14px;
    font-size: 12px;
    color: var(--muted);
}

.legend span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.legend i {
    width: 10px;
    height: 10px;
    border-radius: 3px;
    display: inline-block;
}

.checklist {
    display: flex;
    flex-direction: column;
}

.check-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
}

.check-item:last-child {
    border-bottom: 0;
}

.check-dot {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 1.5px dashed var(--border-strong);
    display: grid;
    place-items: center;
    font-size: 12px;
    flex-shrink: 0;
}

.check-item.done .check-dot {
    background: var(--primary);
    border: 0;
    color: var(--primary-fg);
}

.check-item.done .list-row-title {
    color: var(--muted);
    text-decoration: line-through;
}

.progress {
    height: 6px;
    border-radius: 6px;
    background: var(--surface-3);
    overflow: hidden;
    display: flex;
}

.progress > span {
    display: block;
    height: 100%;
    background: var(--primary);
}

.progress > span.light {
    background: var(--faint);
}

/* ==========================================================================
   Shared inbox
   ========================================================================== */
.inbox {
    display: grid;
    grid-template-columns: 340px minmax(0, 1fr) 320px;
    height: 100vh;
    min-height: 0;
    background: var(--surface);
}

.inbox.panel-hidden {
    grid-template-columns: 340px minmax(0, 1fr) 0;
}

.inbox.panel-hidden .contact-panel {
    display: none;
}

.conv-pane {
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border);
    min-height: 0;
    background: var(--surface);
}

.conv-pane-header {
    padding: 14px 16px 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
    border-bottom: 1px solid var(--border);
}

.conv-pane-title {
    display: flex;
    align-items: center;
    gap: 8px;
}

.conv-pane-title h1 {
    font-size: 17px;
    font-weight: 600;
    letter-spacing: -0.02em;
    flex: 1;
}

.conv-pane .tabs {
    border-bottom: 0;
    gap: 0;
    margin: 0 -4px;
}

.conv-pane .tab {
    padding: 8px 8px 10px;
    font-size: 13px;
}

.conv-list {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

.conv-item {
    display: flex;
    gap: 11px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    position: relative;
}

.conv-item:hover {
    background: var(--hover);
}

.conv-item.active {
    background: var(--active);
}

.conv-item.active::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--primary);
}

.conv-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.conv-line {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.conv-name {
    font-weight: 500;
    font-size: 13.5px;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conv-time {
    font-size: 11.5px;
    color: var(--muted);
    flex-shrink: 0;
}

.conv-preview {
    font-size: 12.5px;
    color: var(--muted);
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conv-item.unread .conv-name,
.conv-item.unread .conv-preview {
    color: var(--text);
    font-weight: 600;
}

.unread-dot {
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: var(--primary);
    color: var(--primary-fg);
    font-size: 10.5px;
    font-weight: 600;
    display: inline-grid;
    place-items: center;
    flex-shrink: 0;
}

.conv-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 4px;
    font-size: 11.5px;
    color: var(--muted);
}

.conv-meta .bi {
    font-size: 12px;
}

.thread-pane {
    display: flex;
    flex-direction: column;
    min-height: 0;
    min-width: 0;
    background: var(--bg);
}

.thread-empty {
    flex: 1;
    display: grid;
    place-items: center;
}

.thread-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    min-height: 62px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}

.thread-who {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.thread-who-text {
    min-width: 0;
}

.thread-name {
    font-weight: 600;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.thread-sub {
    font-size: 12px;
    color: var(--muted);
    display: flex;
    gap: 8px;
    align-items: center;
}

.thread-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.thread-back {
    display: none;
}

.banner {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    font-size: 12.5px;
    border-bottom: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text-2);
}

.banner i {
    font-size: 14px;
}

.banner .btn {
    margin-left: auto;
}

.banner-strong {
    background: var(--primary);
    color: var(--primary-fg);
    border-bottom-color: var(--primary);
}

.typing-dots {
    display: inline-flex;
    gap: 3px;
}

.typing-dots span {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: currentColor;
    animation: blink 1.2s infinite both;
}

.typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes blink {
    0%, 80%, 100% {
        opacity: 0.25;
    }
    40% {
        opacity: 1;
    }
}

.messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px 24px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-height: 0;
}

.load-older {
    align-self: center;
    margin-bottom: 8px;
}

.date-divider {
    align-self: center;
    font-size: 11.5px;
    font-weight: 500;
    color: var(--muted);
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 3px 10px;
    border-radius: 999px;
    margin: 12px 0 8px;
}

.msg {
    display: flex;
    flex-direction: column;
    max-width: min(560px, 78%);
    margin-top: 2px;
}

.msg.in {
    align-self: flex-start;
    align-items: flex-start;
}

.msg.out {
    align-self: flex-end;
    align-items: flex-end;
}

.msg.note {
    align-self: flex-end;
    align-items: flex-end;
}

.bubble {
    padding: 8px 12px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.45;
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-wrap: anywhere;
    position: relative;
}

.msg.in .bubble {
    background: var(--bubble-in);
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
}

.msg.out .bubble {
    background: var(--bubble-out);
    color: var(--bubble-out-fg);
    border-bottom-right-radius: 4px;
}

.msg.note .bubble {
    background: var(--note-bg);
    border: 1.5px dashed var(--border-strong);
    color: var(--text);
    border-bottom-right-radius: 4px;
}

.msg.failed .bubble {
    opacity: 0.75;
}

.bubble-label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    font-weight: 600;
    opacity: 0.7;
    margin-bottom: 3px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.bubble-header {
    font-weight: 600;
    margin-bottom: 4px;
}

.bubble-footer {
    font-size: 12px;
    opacity: 0.65;
    margin-top: 4px;
}

.bubble-buttons {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 8px;
}

.bubble-buttons span {
    display: block;
    text-align: center;
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    border: 1px solid color-mix(in srgb, currentColor 25%, transparent);
}

.bubble-media {
    display: block;
    max-width: 280px;
    max-height: 320px;
    border-radius: 10px;
    margin: -2px -6px 6px;
    background: var(--surface-3);
    object-fit: cover;
}

.bubble-file {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid color-mix(in srgb, currentColor 20%, transparent);
    margin-bottom: 4px;
    font-size: 13px;
}

.bubble-file i {
    font-size: 22px;
}

.msg-meta {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    color: var(--muted);
    margin-top: 3px;
    padding: 0 4px;
}

.msg-meta .bi {
    font-size: 13px;
}

.tick-read {
    color: var(--text);
}

.msg-error {
    font-size: 11.5px;
    color: var(--text);
    font-weight: 500;
    display: flex;
    gap: 4px;
    align-items: center;
    padding: 0 4px;
    margin-top: 2px;
}

.event-line {
    align-self: center;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--muted);
    margin: 8px 0;
    text-align: center;
    max-width: 90%;
}

.event-line i {
    font-size: 12px;
}

.composer {
    border-top: 1px solid var(--border);
    background: var(--surface);
    padding: 10px 16px 14px;
    position: relative;
}

.composer-modes {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
}

.composer-box {
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    transition: border-color 0.15s, box-shadow 0.15s;
}

.composer-box:focus-within {
    border-color: var(--text);
    box-shadow: 0 0 0 3px var(--ring);
}

.composer.note-mode .composer-box {
    border-style: dashed;
    background: var(--note-bg);
}

.composer textarea {
    width: 100%;
    border: 0;
    background: transparent;
    resize: none;
    padding: 10px 12px 4px;
    font: inherit;
    font-size: 14px;
    color: var(--text);
    outline: none;
    min-height: 44px;
    max-height: 200px;
    display: block;
}

.composer-tools {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 4px 6px 6px;
}

.composer-tools .hint {
    font-size: 11.5px;
    color: var(--faint);
    margin-left: 6px;
}

.composer-tools .btn-primary {
    margin-left: auto;
}

.attachment-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 8px 12px 0;
    padding: 6px 10px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 12.5px;
}

.window-closed {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px;
    border: 1.5px dashed var(--border-strong);
    border-radius: 12px;
    font-size: 13px;
    color: var(--text-2);
}

.window-closed i {
    font-size: 20px;
}

.window-closed .btn {
    margin-left: auto;
}

.reply-menu {
    position: absolute;
    left: 16px;
    right: 16px;
    bottom: calc(100% - 4px);
    max-height: 260px;
    overflow-y: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    padding: 5px;
    z-index: 40;
}

.reply-menu .menu-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    white-space: normal;
}

.reply-menu .menu-item small {
    color: var(--muted);
    font-size: 12px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.contact-panel {
    border-left: 1px solid var(--border);
    overflow-y: auto;
    background: var(--surface);
    min-height: 0;
}

.panel-section {
    padding: 16px 18px;
    border-bottom: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.panel-section h4 {
    font-size: 11.5px;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.panel-profile {
    align-items: center;
    text-align: center;
    padding-top: 22px;
}

.panel-profile .name {
    font-weight: 600;
    font-size: 15px;
}

.kv {
    display: grid;
    grid-template-columns: 76px minmax(0, 1fr);
    gap: 8px 10px;
    font-size: 13px;
    align-items: center;
}

.kv dt {
    color: var(--muted);
}

.kv dd {
    margin: 0;
    min-width: 0;
    overflow-wrap: anywhere;
}

.inline-edit {
    border: 1px solid transparent;
    border-radius: 6px;
    padding: 4px 6px;
    margin: -4px -6px;
    background: transparent;
    width: calc(100% + 12px);
    font: inherit;
    color: var(--text);
    outline: none;
}

.inline-edit:hover {
    border-color: var(--border);
}

.inline-edit:focus {
    border-color: var(--text);
    background: var(--surface);
    box-shadow: 0 0 0 3px var(--ring);
}

textarea.inline-edit {
    resize: vertical;
    min-height: 60px;
}

.tag-add {
    display: flex;
    gap: 6px;
}

.run-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 13px;
}

/* ==========================================================================
   Automations
   ========================================================================== */
.automation-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 14px;
}

.automation-card {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 18px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    transition: border-color 0.15s, box-shadow 0.15s;
}

.automation-card:hover {
    border-color: var(--border-strong);
    box-shadow: var(--shadow-md);
}

.automation-card-top {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.automation-icon {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    display: grid;
    place-items: center;
    font-size: 18px;
    flex-shrink: 0;
}

.automation-card.is-active .automation-icon {
    background: var(--primary);
    color: var(--primary-fg);
    border-color: var(--primary);
}

.automation-card h3 {
    font-size: 14.5px;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.automation-card .trigger-line {
    font-size: 12.5px;
    color: var(--muted);
    margin-top: 2px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.automation-stats {
    display: flex;
    gap: 16px;
    font-size: 12px;
    color: var(--muted);
    border-top: 1px solid var(--border);
    padding-top: 12px;
}

.automation-stats span {
    display: inline-flex;
    gap: 5px;
    align-items: center;
}

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

.recipe {
    display: flex;
    gap: 12px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    cursor: pointer;
    text-align: left;
    width: 100%;
    transition: border-color 0.15s, background 0.15s;
}

.recipe:hover {
    border-color: var(--text);
}

.recipe h4 {
    font-size: 13.5px;
    font-weight: 600;
}

.recipe p {
    font-size: 12.5px;
    color: var(--muted);
    margin-top: 2px;
}

.builder {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 300px;
    gap: 20px;
    align-items: start;
}

.builder-side {
    position: sticky;
    top: calc(var(--topbar-h) + 20px);
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.flow {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    padding: 24px;
    background-color: var(--surface-2);
    background-image: radial-gradient(var(--border-strong) 1px, transparent 1px);
    background-size: 18px 18px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    min-height: 420px;
}

.flow-list {
    display: flex;
    flex-direction: column;
    align-items: stretch;
}

.flow-node {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
    width: 100%;
    max-width: 560px;
    margin: 0 auto;
}

.flow-node.trigger {
    border: 1.5px solid var(--text);
}

.flow-node-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
}

.flow-node-icon {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    background: var(--surface-2);
    border: 1px solid var(--border);
    font-size: 14px;
    flex-shrink: 0;
}

.flow-node.trigger .flow-node-icon {
    background: var(--primary);
    color: var(--primary-fg);
    border-color: var(--primary);
}

.flow-node-title {
    flex: 1;
    font-weight: 600;
    font-size: 13px;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.flow-node-title small {
    font-weight: 400;
    font-size: 11px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.flow-node-tools {
    display: flex;
    gap: 2px;
}

.flow-node-tools .icon-btn {
    width: 28px;
    height: 28px;
    font-size: 14px;
}

.flow-node-body {
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.flow-node-body .textarea {
    min-height: 70px;
}

.flow-node-body .field > label {
    font-size: 12px;
    color: var(--muted);
    font-weight: 500;
}

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

.flow-inline > * {
    flex: 1;
    min-width: 120px;
}

.flow-inline .fixed {
    flex: 0 0 auto;
    min-width: 0;
}

.flow-connector {
    width: 2px;
    height: 22px;
    background: var(--border-strong);
    margin: 0 auto;
    position: relative;
}

.flow-add {
    display: flex;
    justify-content: center;
    position: relative;
}

.flow-add-btn {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 1px solid var(--border-strong);
    background: var(--surface);
    display: grid;
    place-items: center;
    cursor: pointer;
    color: var(--muted);
    font-size: 14px;
    transition: all 0.15s;
}

.flow-add-btn:hover {
    border-color: var(--text);
    background: var(--primary);
    color: var(--primary-fg);
}

.flow-add-btn.big {
    width: auto;
    height: 32px;
    border-radius: 999px;
    padding: 0 14px;
    gap: 6px;
    display: inline-flex;
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
}

.flow-add .menu {
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    min-width: 240px;
}

.flow-end {
    align-self: center;
    font-size: 11.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
    border: 1px dashed var(--border-strong);
    padding: 4px 12px;
    border-radius: 999px;
    background: var(--surface);
}

.flow-branches {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    width: 100%;
    max-width: 860px;
    margin: 0 auto;
}

.flow-branch {
    border: 1px dashed var(--border-strong);
    border-radius: 12px;
    padding: 12px;
    background: color-mix(in srgb, var(--surface) 55%, transparent);
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.flow-branch-label {
    align-self: center;
    font-size: 11.5px;
    font-weight: 600;
    padding: 2px 10px;
    border-radius: 999px;
    margin-bottom: 10px;
    letter-spacing: 0.04em;
}

.flow-branch-label.yes {
    background: var(--primary);
    color: var(--primary-fg);
}

.flow-branch-label.no {
    border: 1px solid var(--text-2);
    color: var(--text);
}

.flow-branch .flow-node {
    max-width: none;
}

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

.var-hint {
    font-size: 11.5px;
    color: var(--muted);
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    align-items: center;
}

.var-hint button {
    font-family: var(--mono);
    font-size: 11px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    border-radius: 4px;
    padding: 1px 5px;
    cursor: pointer;
    color: var(--text-2);
}

.var-hint button:hover {
    border-color: var(--text);
    color: var(--text);
}

.button-editor {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.button-editor .input-group .input {
    text-align: center;
}

/* ==========================================================================
   Templates (WhatsApp-style previews)
   ========================================================================== */
.template-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 14px;
}

.template-card {
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.template-card-head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 16px 10px;
}

.template-card-head h3 {
    font-family: var(--mono);
    font-size: 13px;
    font-weight: 600;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.template-meta {
    display: flex;
    gap: 6px;
    padding: 0 16px 12px;
}

.wa-preview {
    margin: 0 12px 12px;
    padding: 14px;
    border-radius: 12px;
    background-color: var(--surface-2);
    background-image: radial-gradient(var(--border) 1px, transparent 1px);
    background-size: 14px 14px;
    flex: 1;
}

.bubble-text {
    white-space: pre-wrap;
}

.wa-preview .bubble {
    white-space: normal;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    border-top-left-radius: 4px;
    font-size: 13px;
    max-width: 100%;
}

.wa-preview .bubble-buttons span {
    background: var(--surface);
    border: 1px solid var(--border);
}

.template-card-foot {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px 12px 16px;
    border-top: 1px solid var(--border);
    font-size: 12px;
    color: var(--muted);
}

.template-card-foot form {
    margin-left: auto;
}

/* ==========================================================================
   Settings
   ========================================================================== */
.settings-layout {
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr);
    gap: 28px;
    align-items: start;
}

.settings-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
    position: sticky;
    top: calc(var(--topbar-h) + 24px);
}

.settings-content {
    display: flex;
    flex-direction: column;
    gap: 20px;
    min-width: 0;
}

.hours-grid {
    display: grid;
    grid-template-columns: 120px 1fr 1fr auto;
    gap: 8px 12px;
    align-items: center;
    font-size: 13px;
}

.hours-grid .head {
    font-size: 12px;
    color: var(--muted);
    font-weight: 500;
}

.connection-status {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.connection-status .automation-icon {
    width: 44px;
    height: 44px;
    font-size: 20px;
}

.steps-guide {
    margin: 0;
    padding-left: 18px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 13px;
    color: var(--text-2);
}

/* ==========================================================================
   Status colours (success / warning / danger / info). Kept after the components
   so they override the monochrome defaults on equal specificity.
   ========================================================================== */
.badge-success {
    background: var(--success-bg);
    border-color: var(--success-border);
    color: var(--success);
}

.badge-warning {
    background: var(--warning-bg);
    border-color: var(--warning-border);
    color: var(--warning);
}

.badge-danger {
    background: var(--danger-bg);
    border-color: var(--danger-border);
    color: var(--danger);
}

.badge-info {
    background: var(--info-bg);
    border-color: var(--info-border);
    color: var(--info);
}

.tab .count.badge-warning {
    background: var(--warning-bg);
    color: var(--warning);
}

.tone-success { background: var(--success-bg); color: var(--success); border-color: var(--success-border); }
.tone-warning { background: var(--warning-bg); color: var(--warning); border-color: var(--warning-border); }
.tone-danger { background: var(--danger-bg); color: var(--danger); border-color: var(--danger-border); }
.tone-info { background: var(--info-bg); color: var(--info); border-color: var(--info-border); }

.banner.tone-warning,
.banner.tone-danger,
.banner.tone-info {
    border-bottom-width: 1px;
    border-bottom-style: solid;
}

.banner-strong.tone-info {
    background: var(--info);
    color: #ffffff;
    border-color: var(--info);
}

/* Errors */
.form-error,
.msg-error,
.msg-meta .bi-exclamation-circle {
    color: var(--danger);
}

.inline-error {
    border: 1px solid var(--danger-border);
    background: var(--danger-bg);
    color: var(--danger);
}

.toast.toast-error {
    background: var(--surface);
    color: var(--danger);
    border: 1px solid var(--danger-border);
    border-left: 4px solid var(--danger);
}

.btn-danger {
    color: var(--danger);
    border-color: var(--danger-border);
}

.btn-danger:hover {
    background: var(--danger);
    border-color: var(--danger);
    color: #ffffff;
}

.msg.failed .bubble {
    outline: 1.5px solid var(--danger-border);
    outline-offset: 1px;
}

/* Inbox */
.tick-read {
    color: var(--tick-read);
}

.unread-dot,
.nav-badge {
    background: var(--success);
    color: #ffffff;
}

:root[data-theme="dark"] .unread-dot,
:root[data-theme="dark"] .nav-badge {
    color: #052e16;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .unread-dot,
    :root:not([data-theme="light"]) .nav-badge {
        color: #052e16;
    }
}

.window-warning {
    color: var(--warning);
    font-weight: 500;
}

.window-shut {
    color: var(--danger);
    font-weight: 500;
}

.window-closed {
    border-color: var(--warning-border);
    background: var(--warning-bg);
    color: var(--text);
}

.window-closed > i {
    color: var(--warning);
}

.conv-meta .bi-robot,
.event-line .bi-robot,
.bubble-label .bi-robot {
    color: var(--info);
}

.msg.out .bubble-label .bi-robot {
    color: inherit;
}

.conv-meta .bi-hourglass-bottom {
    color: var(--warning);
}

/* WhatsApp connection */
.connection-status.is-connected .automation-icon {
    background: var(--success-bg);
    border-color: var(--success-border);
    color: var(--whatsapp);
}

.connection-status.is-error .automation-icon {
    background: var(--danger-bg);
    border-color: var(--danger-border);
    color: var(--danger);
}

.check-item.done .check-dot {
    background: var(--success);
    color: #ffffff;
}

/* Campaign and usage bars */
.progress > span {
    background: var(--success);
}

.progress > span.light {
    background: var(--success-border);
}

/* ==========================================================================
   Billing
   ========================================================================== */
.plan-notice {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 10px 12px;
    margin-bottom: 8px;
    border-radius: 10px;
    border: 1px solid;
    font-size: 12.5px;
    line-height: 1.4;
}

.plan-notice i {
    font-size: 16px;
    margin-top: 1px;
}

.app.sidebar-collapsed .plan-notice span {
    display: none;
}

.meters {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 18px;
}

.meter {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.meter-top {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    font-size: 13px;
    color: var(--text-2);
}

.meter-top i {
    color: var(--muted);
    margin-right: 4px;
}

.meter.is-high .progress > span {
    background: var(--warning);
}

.meter.is-high .meter-top b {
    color: var(--warning);
}

.meter.is-full .progress > span {
    background: var(--danger);
}

.meter.is-full .meter-top b {
    color: var(--danger);
}

.plan-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 14px;
    align-items: start;
}

.plan-card {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 22px 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.plan-card.is-featured {
    border: 1.5px solid var(--text);
    box-shadow: var(--shadow-md);
}

.plan-card h3 {
    font-size: 16px;
    font-weight: 600;
}

.plan-flag {
    position: absolute;
    top: -11px;
    right: 16px;
}

.plan-price {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.plan-amount {
    font-size: 24px;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.plan-features {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 13px;
    color: var(--text-2);
    flex: 1;
}

.plan-features i {
    color: var(--success);
    margin-right: 4px;
}

/* ==========================================================================
   Platform console - always dark, so operators never mistake it for a workspace
   ========================================================================== */
.sidebar-platform {
    background: #0b0b0d;
    border-right-color: #1f1f23;
    color: #e4e4e7;
}

.sidebar-platform .brand,
.sidebar-platform .sidebar-footer {
    border-color: #1f1f23;
}

.sidebar-platform .brand-mark {
    background: var(--warning);
    color: #0b0b0d;
}

.sidebar-platform .brand-sub,
.sidebar-platform .user-role {
    color: #a1a1aa;
}

.sidebar-platform .nav-item {
    color: #d4d4d8;
}

.sidebar-platform .nav-item i {
    color: #a1a1aa;
}

.sidebar-platform .nav-item:hover,
.sidebar-platform .nav-item.active {
    background: #1c1c20;
    color: #ffffff;
}

.sidebar-platform .nav-item.active i {
    color: var(--warning);
}

.sidebar-platform .avatar {
    background: #27272a;
    color: #fafafa;
}

.nav-badge.nav-badge-warning {
    background: var(--warning);
    color: #0b0b0d;
}

.auth-shell-platform {
    background: #0b0b0d;
    color: #fafafa;
    --surface: #111113;
    --border: #27272a;
    --text: #fafafa;
    --muted: #a1a1aa;
    --primary: #fafafa;
    --primary-fg: #09090b;
    --primary-hover: #e4e4e7;
}

.auth-shell-platform .brand-mark {
    background: var(--warning);
    color: #0b0b0d;
}

/* Operator support view of a workspace: a fixed amber bar that can't be missed */
.support-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 40px;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 16px;
    background: var(--warning);
    color: #1c1917;
    font-size: 13px;
    overflow: hidden;
    white-space: nowrap;
}

.support-bar span {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.support-bar .btn {
    background: #1c1917;
    color: #ffffff;
}

body.support-mode {
    padding-top: 40px;
}

body.support-mode .sidebar {
    top: 40px;
    height: calc(100vh - 40px);
}

body.support-mode .topbar {
    top: 40px;
}

body.support-mode .inbox {
    height: calc(100vh - 40px);
}

.risk-word {
    background: var(--danger-bg);
    color: var(--danger);
    border-radius: 3px;
    padding: 0 2px;
    font-weight: 600;
}

/* Shop */
.product-thumb {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    object-fit: cover;
    flex-shrink: 0;
    border: 1px solid var(--border);
    background: var(--surface-2);
}

.product-thumb-empty {
    display: inline-grid;
    place-items: center;
    color: var(--faint);
}

/* Support tickets */
.ticket-thread {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.ticket-msg {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 14px 16px;
    box-shadow: var(--shadow-sm);
    margin-right: 48px;
}

.ticket-msg.from-support {
    margin-right: 0;
    margin-left: 48px;
    border-color: var(--info-border);
    background: var(--info-bg);
}

.ticket-msg.is-internal {
    margin-left: 48px;
    margin-right: 0;
    border: 1.5px dashed var(--warning-border);
    background: var(--warning-bg);
}

.ticket-msg header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    font-size: 13px;
}

.ticket-body {
    font-size: 14px;
    line-height: 1.55;
    overflow-wrap: anywhere;
}

/* Coexistence (WhatsApp Business app + Cloud API on one number) */
.connect-options {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.connect-option {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
}

.connect-option.is-recommended {
    border: 1.5px solid var(--whatsapp);
}

.connect-option h3 {
    font-size: 14px;
    font-weight: 600;
    display: flex;
    gap: 8px;
    align-items: center;
}

.connect-option h3 i {
    color: var(--whatsapp);
    font-size: 18px;
}

.connect-option ul {
    margin: 0;
    padding-left: 18px;
    font-size: 12.5px;
    color: var(--text-2);
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}

.btn-whatsapp {
    background: var(--whatsapp);
    color: #ffffff;
}

.btn-whatsapp:hover {
    filter: brightness(0.95);
}

.bubble-label .bi-phone {
    color: inherit;
}

/* ==========================================================================
   Responsive - kept at the end so overrides win on equal specificity
   ========================================================================== */
/* Shop reports */
.grid-split-3 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 20px;
}

.tone-text-warning {
    color: var(--warning);
    font-weight: 600;
}

/* Automation builder: integration steps */
.flow-rows {
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: flex-start;
}

.flow-rows > .flow-inline {
    width: 100%;
}

.flow-inline > .icon-btn,
.flow-inline > label,
.flow-inline > .btn {
    flex: 0 0 auto;
    min-width: 0;
}

.textarea-sm {
    font-size: 13px;
    padding: 8px 10px;
}

.callout.small {
    padding: 8px 12px;
    font-size: 12.5px;
}

/* Inbox: deleting stored media */
.media-wrap {
    position: relative;
}

.media-delete {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 0;
    background: rgba(0, 0, 0, .55);
    color: #fff;
    display: grid;
    place-items: center;
    cursor: pointer;
    opacity: 0;
    transition: opacity .15s;
}

.media-wrap:hover .media-delete,
.media-delete:focus-visible {
    opacity: 1;
}

.media-deleted {
    color: var(--muted);
    font-style: italic;
}

@media (max-width: 1280px) {
    .inbox {
        grid-template-columns: 300px minmax(0, 1fr) 280px;
    }

    .inbox.panel-hidden {
        grid-template-columns: 300px minmax(0, 1fr) 0;
    }
}

@media (max-width: 1100px) {
    .inbox,
    .inbox.panel-hidden {
        grid-template-columns: 300px minmax(0, 1fr);
    }

    .contact-panel {
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        width: 320px;
        z-index: 45;
        box-shadow: var(--shadow-lg);
        transform: translateX(100%);
        transition: transform 0.2s ease;
    }

    .inbox:not(.panel-hidden) .contact-panel {
        transform: none;
    }

    .inbox.panel-hidden .contact-panel {
        display: block;
    }

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

    .builder-side {
        position: static;
    }

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

@media (max-width: 992px) {
    .sidebar,
    .app.sidebar-collapsed .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        width: 272px;
        transform: translateX(-100%);
        transition: transform 0.22s ease;
        box-shadow: var(--shadow-lg);
        z-index: 50;
    }

    .app.sidebar-collapsed .brand-text,
    .app.sidebar-collapsed .nav-item span,
    .app.sidebar-collapsed .nav-label,
    .app.sidebar-collapsed .user-meta {
        display: revert;
    }

    .app.sidebar-collapsed .nav-item {
        justify-content: flex-start;
    }

    .app.sidebar-collapsed .brand {
        flex-direction: row;
    }

    .app.sidebar-collapsed .nav-badge {
        position: static;
    }

    .sidebar-collapse {
        display: none;
    }

    .app.drawer-open .sidebar {
        transform: none;
    }

    .app.drawer-open .sidebar-overlay {
        display: block;
        position: fixed;
        inset: 0;
        background: var(--overlay);
        z-index: 40;
    }

    .drawer-toggle {
        display: inline-grid;
        margin-left: -6px;
    }

    .topbar {
        padding: 10px 16px;
    }

    .page {
        padding: 16px 16px 40px;
    }

    .settings-layout {
        grid-template-columns: minmax(0, 1fr);
        gap: 16px;
    }

    .settings-nav {
        position: static;
        flex-direction: row;
        overflow-x: auto;
        border-bottom: 1px solid var(--border);
    }

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

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

    .auth-aside {
        display: none;
    }
}

@media (max-width: 768px) {
    .inbox,
    .inbox.panel-hidden {
        grid-template-columns: minmax(0, 1fr);
        height: 100dvh;
    }

    .inbox .thread-pane {
        display: none;
    }

    .inbox.thread-open .conv-pane {
        display: none;
    }

    .inbox.thread-open .thread-pane {
        display: flex;
    }

    .thread-back {
        display: inline-grid;
    }

    .contact-panel {
        width: 100%;
    }

    .msg {
        max-width: 88%;
    }

    .messages {
        padding: 16px 12px;
    }

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

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

    .flow {
        padding: 14px 10px;
    }

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

    .hours-grid {
        grid-template-columns: 90px 1fr 1fr auto;
        gap: 6px 8px;
    }

    .topbar-title p {
        display: none;
    }

    .toasts {
        left: 16px;
        right: 16px;
        bottom: 16px;
    }

    .toast {
        max-width: none;
    }

    .hide-sm,
    .table .hide-sm {
        display: none;
    }

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

    .modal-footer {
        flex-wrap: wrap;
    }
}

@media (hover: none) {
    .media-delete {
        opacity: 1;
    }
}
