:root {
    --bg: #f4f6f8;
    --panel: #ffffff;
    --panel-soft: #f8faf9;
    --line: #dfe5e2;
    --line-strong: #cfd8d3;
    --text: #18181b;
    --muted: #6b7280;
    --primary: #0f9f6e;
    --primary-dark: #087b56;
    --primary-soft: #e8f6ef;
    --danger: #dc2626;
    --danger-soft: #fee2e2;
    --warn: #b7791f;
    --warn-soft: #fef3c7;
    --sidebar: #1f211f;
    --sidebar-soft: #2a2d2a;
    --radius: 8px;
    --shadow-sm: 0 1px 2px rgba(24, 24, 27, 0.05);
    --shadow: 0 10px 24px rgba(24, 24, 27, 0.07);
    --shadow-lg: 0 18px 42px rgba(24, 24, 27, 0.12);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 14px;
    line-height: 1.45;
}

button,
input,
select {
    font: inherit;
}

button {
    cursor: pointer;
}

a {
    color: inherit;
}

.hidden {
    display: none !important;
}

.login-screen {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(244, 246, 248, 0.96)),
        repeating-linear-gradient(90deg, rgba(31, 33, 31, 0.035) 0, rgba(31, 33, 31, 0.035) 1px, transparent 1px, transparent 80px);
}

.login-card {
    width: min(420px, 100%);
    display: grid;
    gap: 18px;
    padding: 34px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 10px;
    box-shadow: var(--shadow-lg);
}

.brand-mark {
    width: 54px;
    height: 54px;
    display: grid;
    place-items: center;
    border-radius: 10px;
    background: var(--primary-soft);
    color: var(--primary);
    font-size: 1.5rem;
}

.login-card h1,
.login-card p {
    margin: 0;
}

.login-card h1 {
    font-size: 1.75rem;
    letter-spacing: 0;
}

.login-card p,
.form-message,
.topbar p,
.sidebar-brand span,
.panel-head span {
    color: var(--muted);
}

label {
    display: grid;
    gap: 7px;
    color: var(--text);
    font-size: 0.88rem;
    font-weight: 650;
}

input,
select {
    min-height: 42px;
    width: 100%;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    outline: none;
    background: #fff;
    color: var(--text);
    padding: 0 12px;
    transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

input:focus,
select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(15, 159, 110, 0.14);
}

.primary-btn,
.ghost-btn,
.logout-btn,
.side-nav a,
.side-nav button,
.menu-btn,
.action-btn {
    border: none;
    border-radius: var(--radius);
    font-weight: 650;
    font-size: 0.92rem;
    transition: background 0.16s ease, color 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

.primary-btn {
    min-height: 40px;
    padding: 0 18px;
    background: var(--primary);
    color: #fff;
    box-shadow: var(--shadow-sm);
}

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

.primary-btn.inline {
    justify-self: start;
}

.ghost-btn {
    min-height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0 14px;
    border: 1px solid #cfe5da;
    background: var(--primary-soft);
    color: var(--primary-dark);
    text-decoration: none;
}

.ghost-btn:hover {
    border-color: #aed4c3;
    background: #dff1e8;
}

.admin-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 248px minmax(0, 1fr);
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding: 18px 14px;
    background: var(--sidebar);
    color: #fff;
    border-right: 1px solid rgba(255,255,255,0.08);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 56px;
    padding: 4px 8px 14px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-brand i {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border-radius: 9px;
    background: var(--primary);
    box-shadow: 0 10px 20px rgba(15, 159, 110, 0.22);
}

.sidebar-brand strong {
    font-size: 1rem;
    letter-spacing: 0;
}

.sidebar-brand strong,
.sidebar-brand span {
    display: block;
}

.sidebar-brand span {
    color: rgba(255,255,255,0.62);
    font-size: 0.78rem;
    margin-top: 3px;
}

.side-nav {
    display: grid;
    gap: 4px;
}

.side-nav a,
.side-nav button,
.logout-btn {
    display: flex;
    align-items: center;
    gap: 11px;
    width: 100%;
    background: transparent;
    color: rgba(255,255,255,0.7);
    text-align: left;
    text-decoration: none;
    min-height: 42px;
    padding: 0 12px;
    border: 1px solid transparent;
}

.side-nav a i,
.side-nav button i,
.logout-btn i {
    width: 18px;
    text-align: center;
    color: rgba(255,255,255,0.72);
}

.side-nav a.active,
.side-nav a:hover,
.side-nav button.active,
.side-nav button:hover {
    background: var(--sidebar-soft);
    border-color: rgba(255,255,255,0.08);
    color: #fff;
}

.side-nav a.active i,
.side-nav a:hover i,
.side-nav button.active i,
.side-nav button:hover i {
    color: #7ee0b6;
}

.logout-btn {
    margin-top: auto;
    min-height: 42px;
    padding: 0 12px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.08);
}

.logout-btn:hover {
    background: rgba(255,255,255,0.1);
    color: #fff;
}

.workspace {
    min-width: 0;
    padding: 22px 28px 32px;
}

.topbar {
    min-height: 68px;
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 18px;
    padding: 12px 0 20px;
    border-bottom: 1px solid var(--line);
}

.topbar h2,
.topbar p {
    margin: 0;
}

.topbar p {
    margin-top: 4px;
}

.topbar h2 {
    font-size: 1.45rem;
    letter-spacing: 0;
}

.menu-btn {
    display: none;
    background: var(--panel);
    color: var(--text);
    border: 1px solid var(--line);
    min-width: 40px;
    min-height: 40px;
}

.admin-user {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 8px 12px;
    font-weight: 700;
    box-shadow: var(--shadow-sm);
}

.view {
    display: none;
}

.view.active {
    display: grid;
    gap: 16px;
}

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

.metric-card,
.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.metric-card {
    position: relative;
    overflow: hidden;
    padding: 16px;
    min-height: 104px;
    border-top: 3px solid var(--primary);
}

.list-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

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

.metric-card span {
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 650;
}

.metric-card strong {
    display: block;
    margin-top: 8px;
    font-size: 1.65rem;
    letter-spacing: 0;
}

.metric-card small {
    display: block;
    margin-top: 8px;
    color: var(--muted);
    font-size: 0.78rem;
}

.dashboard-metrics .metric-card:nth-child(2) {
    border-top-color: var(--info);
}

.dashboard-metrics .metric-card:nth-child(3) {
    border-top-color: var(--warn);
}

.dashboard-metrics .metric-card:nth-child(4) {
    border-top-color: var(--danger);
}

.insight-grid,
.status-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}

.insight-card,
.status-card {
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel-soft);
}

.insight-card span,
.status-card span {
    display: block;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 800;
}

.insight-card strong,
.status-card strong {
    display: block;
    margin-top: 8px;
    font-size: 1.2rem;
}

.insight-card.success {
    border-color: rgba(16, 163, 108, 0.22);
}

.insight-card.danger {
    border-color: rgba(225, 83, 83, 0.24);
}

.insight-card.info {
    border-color: rgba(47, 115, 216, 0.22);
}

.insight-card.warn {
    border-color: rgba(201, 138, 4, 0.24);
}

.two-column {
    display: grid;
    grid-template-columns: minmax(0, 1.5fr) minmax(320px, 1fr);
    gap: 16px;
}

.panel {
    padding: 16px;
    min-width: 0;
}

.panel.compact-panel {
    max-width: 560px;
}

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 42px;
    margin-bottom: 14px;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 42px;
    margin-bottom: 14px;
}

.panel-header h3 {
    margin: 0;
    font-size: 1rem;
    letter-spacing: 0;
}

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

.toolbar-actions input {
    width: min(260px, 42vw);
}

.panel-head h3 {
    margin: 0;
    font-size: 1rem;
    letter-spacing: 0;
}

.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.table-container {
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.user-table {
    min-width: 1660px;
}

.user-table th:first-child,
.user-table td:first-child {
    position: sticky;
    left: 0;
    z-index: 2;
    min-width: 190px;
    max-width: 220px;
    background: #fff;
    box-shadow: 1px 0 0 var(--line);
}

.user-table th:first-child {
    z-index: 3;
    background: var(--panel-soft);
}

.user-table tbody tr:hover td:first-child {
    background: #fbfcfb;
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    min-width: 760px;
    background: var(--panel);
}

th,
td {
    padding: 12px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: middle;
}

th {
    position: sticky;
    top: 0;
    z-index: 1;
    padding: 10px 12px;
    background: var(--panel-soft);
    color: var(--muted);
    font-size: 0.76rem;
    font-weight: 700;
}

tbody tr:hover {
    background: #fbfcfb;
}

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

.tag {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    border-radius: 999px;
    padding: 0 9px;
    background: var(--primary-soft);
    color: var(--primary-dark);
    font-size: 0.78rem;
    font-weight: 750;
}

.tag.warn {
    background: var(--warn-soft);
    color: var(--warn);
}

.tag.danger {
    background: var(--danger-soft);
    color: var(--danger);
}

.stack-list,
.form-list {
    display: grid;
    gap: 12px;
}

.list-card,
.channel-card {
    display: grid;
    gap: 12px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel-soft);
}

.list-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.list-card-head strong,
.list-card-head span {
    display: block;
}

.list-card-head span,
.subtext {
    color: var(--muted);
    font-size: 0.82rem;
    margin-top: 3px;
}

.action-row,
.adjust-row,
.channel-grid,
.user-manage {
    display: grid;
    gap: 10px;
}

.adjust-row {
    grid-template-columns: 92px 1fr;
}

.channel-grid {
    grid-template-columns: 90px 1.5fr 120px minmax(180px, 1fr) auto;
    align-items: end;
}

.user-manage {
    grid-template-columns: 128px 150px;
    align-items: center;
}

.user-identity {
    display: grid;
    gap: 3px;
}

.user-identity strong {
    font-size: 0.95rem;
}

.user-identity span,
.user-identity small {
    color: var(--muted);
    font-size: 0.78rem;
}

.user-action-card {
    display: grid;
    gap: 10px;
    min-width: 220px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel-soft);
}

.user-action-card.compact {
    grid-template-columns: minmax(120px, 1fr) auto;
    align-items: center;
    min-width: 260px;
    padding: 0;
    border: 0;
    background: transparent;
}

.user-action-card.account-summary {
    min-width: 230px;
    max-width: 280px;
}

.account-summary-lines {
    display: grid;
    gap: 4px;
    color: var(--muted);
    font-size: 0.78rem;
    line-height: 1.35;
}

.account-summary-lines span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-action-card.group-action {
    min-width: 230px;
}

.user-action-card.money-action {
    min-width: 230px;
}

.action-card-title {
    color: var(--muted);
    font-size: 0.76rem;
    font-weight: 750;
}

.user-action-card .action-btn {
    width: 100%;
}

.inline-check {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: 0.82rem;
    font-weight: 800;
    white-space: nowrap;
}

.inline-check input {
    width: auto;
    min-height: auto;
}

.action-btn.success {
    background: var(--primary);
    color: #fff;
}

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

.action-btn.danger {
    background: var(--danger);
    color: #fff;
}

.action-btn {
    min-height: 34px;
    padding: 0 10px;
    border: 1px solid var(--line);
    background: #fff;
    color: var(--text);
}

.action-btn:hover {
    border-color: var(--line-strong);
    background: var(--panel-soft);
}

.btn {
    min-height: 36px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fff;
    color: var(--text);
    font-weight: 650;
}

.btn:hover:not(:disabled) {
    border-color: var(--line-strong);
    background: var(--panel-soft);
}

.btn:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

.pagination-controls {
    color: var(--muted);
    font-weight: 650;
}

.modal {
    border: 1px solid var(--line);
    border-radius: 10px;
    box-shadow: var(--shadow-lg);
}

.modal::backdrop {
    background: rgba(24, 24, 27, 0.42);
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.confirm-modal {
    width: min(420px, calc(100vw - 36px));
    padding: 0;
}

.confirm-dialog {
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr);
    gap: 14px;
    padding: 20px;
}

.confirm-dialog h3,
.confirm-dialog p {
    margin: 0;
}

.confirm-dialog h3 {
    font-size: 1.08rem;
}

.confirm-dialog p {
    margin-top: 6px;
    color: var(--muted);
}

.confirm-dialog .modal-actions {
    grid-column: 1 / -1;
    margin-top: 4px;
}

.confirm-icon {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border-radius: var(--radius);
    background: var(--primary-soft);
    color: var(--primary-dark);
}

.confirm-modal.danger .confirm-icon {
    background: var(--danger-soft);
    color: var(--danger);
}

.danger-btn {
    background: var(--danger);
}

.danger-btn:hover {
    background: #b91c1c;
}

.group-modal {
    width: min(980px, calc(100vw - 36px));
    padding: 0;
}

.user-account-modal {
    width: min(760px, calc(100vw - 36px));
    padding: 0;
}

.group-form {
    display: grid;
    gap: 18px;
    padding: 22px;
}

.user-account-form {
    display: grid;
    gap: 18px;
    padding: 22px;
}

.account-modal-section {
    display: grid;
    gap: 10px;
}

.account-modal-section h4 {
    margin: 0;
    color: var(--muted);
    font-size: 0.86rem;
}

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

.account-modal-grid label {
    display: grid;
    gap: 7px;
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 800;
}

.modal-titlebar {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--line);
}

.modal-titlebar h3,
.modal-titlebar p,
.rule-section-head h4,
.rule-section-head p {
    margin: 0;
}

.modal-titlebar h3 {
    font-size: 1.18rem;
}

.modal-titlebar p,
.rule-section-head p {
    margin-top: 4px;
    color: var(--muted);
    font-size: 0.86rem;
}

.group-form-grid {
    display: grid;
    grid-template-columns: minmax(240px, 1fr) 180px;
    gap: 14px;
}

.rule-section-head {
    display: flex;
    justify-content: space-between;
    gap: 16px;
}

.rule-section-head h4 {
    font-size: 1rem;
}

.rule-table-wrap {
    max-height: min(430px, 52vh);
    overflow: auto;
}

.rule-table {
    min-width: 0;
    table-layout: fixed;
}

.rule-table th:first-child,
.rule-table td:first-child {
    width: 96px;
}

.rule-table input,
.rule-table select {
    min-width: 0;
    width: 100%;
}

input[type="number"] {
    appearance: textfield;
    -moz-appearance: textfield;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    display: none;
    margin: 0;
}

.rule-table th:nth-child(1),
.rule-table td:nth-child(1) {
    width: 92px;
}

.rule-table th:nth-child(4),
.rule-table td:nth-child(4) {
    width: 124px;
}

.rule-table th:nth-child(5),
.rule-table td:nth-child(5) {
    width: 120px;
}

.rule-index {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 0 10px;
    border-radius: 999px;
    background: var(--primary-soft);
    color: var(--primary-dark);
    font-weight: 750;
    font-size: 0.8rem;
}

.groups-table {
    min-width: 920px;
}

.action-btn.success {
    border-color: var(--primary);
    background: var(--primary);
    color: #fff;
}

.action-btn.success:hover {
    border-color: var(--primary-dark);
    background: var(--primary-dark);
}

.action-btn.danger {
    border-color: var(--danger);
    background: var(--danger);
    color: #fff;
}

.switch-list {
    display: grid;
    gap: 12px;
    margin-bottom: 18px;
}

.switch-list label {
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 12px;
    background: var(--panel-soft);
}

.switch-list input,
.channel-grid input[type="checkbox"] {
    width: auto;
    min-height: auto;
}

.settings-grid {
    display: grid;
    gap: 12px;
    margin-bottom: 18px;
}

.setting-field {
    display: grid;
    gap: 8px;
    max-width: 360px;
    font-weight: 800;
}

.setting-toggle {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    width: fit-content;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 12px;
    background: var(--panel-soft);
    font-weight: 800;
}

.setting-toggle input {
    width: auto;
    min-height: auto;
}

.input-suffix {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel-soft);
}

.input-suffix input {
    border: 0;
    background: transparent;
}

.input-suffix em {
    padding: 0 14px;
    color: var(--muted);
    font-style: normal;
    font-weight: 900;
}

.setting-note {
    max-width: 620px;
    color: var(--muted);
}

.toast {
    position: fixed;
    right: 18px;
    bottom: 18px;
    min-width: 220px;
    max-width: calc(100vw - 36px);
    border-radius: var(--radius);
    background: #202420;
    color: #fff;
    padding: 12px 14px;
    opacity: 0;
    transform: translateY(12px);
    pointer-events: none;
    transition: 0.2s ease;
    z-index: 20;
}

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

.sound-enable-btn {
    position: fixed;
    right: 18px;
    bottom: 74px;
    z-index: 30;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: 0;
    border-radius: 999px;
    background: #0fa36b;
    color: #fff;
    padding: 12px 16px;
    font-weight: 900;
    box-shadow: 0 14px 32px rgba(15, 163, 107, 0.28);
    cursor: pointer;
}

.sound-enable-btn:hover {
    background: #0b8f5d;
}

.sound-enable-btn[hidden] {
    display: none;
}

.empty {
    color: var(--muted);
    padding: 14px;
    border: 1px dashed var(--line);
    border-radius: var(--radius);
    text-align: center;
    background: var(--panel-soft);
}

/* Chat Layout (Admin) */
.chat-panel {
    padding: 0;
    display: flex;
    height: calc(100vh - 140px);
    overflow: hidden;
}

.chat-layout {
    display: flex;
    width: 100%;
    height: 100%;
}

.chat-sidebar {
    width: 280px;
    border-right: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    background: var(--panel-soft);
}

.chat-sidebar-head {
    padding: 16px;
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #fff;
}

.chat-sidebar-head h3 {
    margin: 0;
}

.chat-list {
    flex: 1;
    overflow-y: auto;
}

.chat-item {
    padding: 16px;
    border-bottom: 1px solid var(--line);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 6px;
    transition: background 0.16s ease, border-color 0.16s ease;
}

.chat-item:hover, .chat-item.active {
    background: #edf6f1;
}

.chat-item.active {
    border-left: 3px solid var(--primary);
    padding-left: 13px;
}

.chat-item-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-item-head strong {
    font-size: 0.95rem;
}

.chat-item-head span {
    font-size: 0.75rem;
    color: var(--muted);
}

.chat-item-msg {
    font-size: 0.82rem;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #f7f8f7;
}

.chat-main-head {
    padding: 16px;
    background: var(--panel);
    border-bottom: 1px solid var(--line);
}

.chat-main-head h3 {
    margin: 0;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.chat-bubble {
    max-width: 75%;
    display: flex;
    flex-direction: column;
}

.chat-bubble.user {
    align-self: flex-start;
}

.chat-bubble.bot {
    align-self: flex-end;
}

.chat-bubble p {
    margin: 0;
    padding: 12px 16px;
    border-radius: 10px;
    font-size: 0.95rem;
    line-height: 1.4;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.chat-bubble.user p {
    background: #fff;
    border: 1px solid var(--line);
    border-bottom-left-radius: 3px;
}

.chat-bubble.bot p {
    background: var(--primary);
    color: #fff;
    border-bottom-right-radius: 3px;
}

.chat-bubble time {
    font-size: 0.75rem;
    color: var(--muted);
    margin-top: 6px;
}

.chat-bubble.user time {
    align-self: flex-start;
}

.chat-bubble.bot time {
    align-self: flex-end;
}

.chat-composer {
    padding: 16px;
    background: var(--panel);
    border-top: 1px solid var(--line);
    display: flex;
    gap: 10px;
}

.chat-composer textarea {
    flex: 1;
    background: var(--panel-soft);
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--text);
    font: inherit;
    line-height: 1.45;
    min-height: 44px;
    max-height: 132px;
    padding: 10px 12px;
    resize: vertical;
}

.chat-composer textarea:disabled {
    background: #ecefed;
    cursor: not-allowed;
}

.chat-composer .primary-btn {
    min-width: 76px;
}

@media (max-width: 980px) {
    .admin-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: fixed;
        z-index: 10;
        transform: translateX(-100%);
        transition: transform 0.2s ease;
        width: 260px;
    }

    body.sidebar-open .sidebar {
        transform: translateX(0);
    }

    .menu-btn {
        display: inline-grid;
        place-items: center;
    }

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

    .two-column {
        grid-template-columns: 1fr;
    }

    .channel-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .workspace {
        padding: 18px;
    }

    .metric-grid {
        grid-template-columns: 1fr;
    }

    .topbar {
        align-items: flex-start;
    }

    .panel-head,
    .panel-header,
    .toolbar-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .toolbar-actions input {
        width: 100%;
    }

    .adjust-row,
    .user-manage {
        grid-template-columns: 1fr;
    }

    .admin-user {
        padding: 8px 10px;
    }
}

.nav-badge {
    background: #e74c3c;
    color: white;
    font-size: 0.75rem;
    padding: 2px 6px;
    border-radius: 10px;
    margin-left: auto;
    font-weight: bold;
}
