@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700;800&display=swap');

:root {
    --ui-bg: #f6f8fb;
    --ui-bg-band: #edf2f7;
    --ui-surface: rgba(255, 255, 255, 0.92);
    --ui-surface-strong: #ffffff;
    --ui-ink: #17212b;
    --ui-muted: #637083;
    --ui-border: rgba(23, 33, 43, 0.12);
    --ui-brand: #b4232f;
    --ui-brand-dark: #8f1d28;
    --ui-accent: #087f8c;
    --ui-accent-dark: #056773;
    --ui-success: #16835f;
    --ui-warning: #d9a21b;
    --ui-danger: #c83d4a;
    --ui-info: #1b7aa6;
    --ui-shadow-sm: 0 6px 18px rgba(23, 33, 43, 0.08);
    --ui-shadow-md: 0 14px 34px rgba(23, 33, 43, 0.12);
    --ui-shadow-lg: 0 22px 54px rgba(23, 33, 43, 0.16);
    --ui-radius: 8px;
}

html[data-theme="dark"] {
    --ui-bg: #0f141a;
    --ui-bg-band: #151d26;
    --ui-surface: rgba(24, 32, 41, 0.92);
    --ui-surface-strong: #182029;
    --ui-ink: #edf2f7;
    --ui-muted: #9eafc0;
    --ui-border: rgba(159, 176, 194, 0.18);
    --ui-brand: #d64553;
    --ui-brand-dark: #b82e3e;
    --ui-accent: #1b98a5;
    --ui-accent-dark: #177d88;
    --ui-success: #1ea776;
    --ui-warning: #e3b230;
    --ui-danger: #e25b68;
    --ui-info: #3b9dca;
    --ui-shadow-sm: 0 8px 22px rgba(0, 0, 0, 0.34);
    --ui-shadow-md: 0 16px 36px rgba(0, 0, 0, 0.38);
    --ui-shadow-lg: 0 26px 60px rgba(0, 0, 0, 0.44);
}

html[data-theme="dark"] body.app-shell {
    background: linear-gradient(180deg, #111820 0%, #151d26 42%, #0f141a 100%);
}

html[data-theme="dark"] body.auth-screen::after {
    background:
        linear-gradient(135deg, rgba(6, 10, 15, 0.58), rgba(8, 14, 20, 0.48)),
        linear-gradient(180deg, rgba(255, 255, 255, 0.02), rgba(0, 0, 0, 0.3));
}

html[data-theme="dark"] .dropdown-menu {
    background: var(--ui-surface-strong);
}

html[data-theme="dark"] .dropdown-item,
html[data-theme="dark"] .dropdown-item.text-danger {
    color: var(--ui-ink) !important;
}

html[data-theme="dark"] .dropdown-item:hover,
html[data-theme="dark"] .dropdown-item:focus {
    background: rgba(27, 152, 165, 0.12);
}

html[data-theme="dark"] .dropdown-divider,
html[data-theme="dark"] .modal-header,
html[data-theme="dark"] .modal-footer {
    border-color: var(--ui-border);
}

html[data-theme="dark"] .form-label {
    color: var(--ui-ink);
}

html[data-theme="dark"] .form-control::placeholder,
html[data-theme="dark"] textarea.form-control::placeholder {
    color: var(--ui-muted);
    opacity: 0.86;
}

html[data-theme="dark"] .table tbody td,
html[data-theme="dark"] .table thead th,
html[data-theme="dark"] .card-header,
html[data-theme="dark"] .navbar-text,
html[data-theme="dark"] .text-dark {
    color: var(--ui-ink) !important;
}

html[data-theme="dark"] .table tbody tr:hover {
    background: rgba(27, 152, 165, 0.1) !important;
}

html[data-theme="dark"] .pagination .page-item.disabled .page-link {
    background: rgba(24, 32, 41, 0.72);
}

html[data-theme="dark"] .auth-screen .login-card,
html[data-theme="dark"] .auth-screen .register-container,
html[data-theme="dark"] .auth-screen .verify-container {
    background: linear-gradient(180deg, rgba(8, 14, 20, 0.68), rgba(10, 18, 26, 0.54)) !important;
}

html[data-theme="dark"] .analysis-summary-header,
html[data-theme="dark"] .card-header.bg-primary {
    color: #ffffff !important;
}

.theme-setting-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 1rem;
}

.theme-setting-copy {
    max-width: 620px;
}

.theme-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 0.95rem;
    border: 1px solid var(--ui-border);
    border-radius: var(--ui-radius);
    background: var(--ui-surface);
}

.theme-toggle .form-check-input {
    width: 3rem;
    height: 1.7rem;
    margin: 0;
    cursor: pointer;
}

.theme-toggle .form-check-input:checked {
    background-color: var(--ui-accent);
    border-color: var(--ui-accent);
}

.theme-toggle-label {
    min-width: 130px;
    color: var(--ui-muted);
    font-weight: 700;
}

@media (max-width: 768px) {
    .theme-setting-row {
        grid-template-columns: 1fr;
        align-items: stretch;
    }

    .theme-toggle {
        justify-content: space-between;
    }
}

* {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
    font-family: 'Manrope', Arial, sans-serif;
    color: var(--ui-ink);
}

body {
    background-color: var(--ui-bg);
}

body.app-shell {
    background:
        linear-gradient(180deg, rgba(237, 242, 247, 0.94) 0%, rgba(246, 248, 251, 0.96) 42%, #ffffff 100%);
    padding-top: 76px;
}

body.auth-screen {
    min-height: 100vh;
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
}

body.auth-screen::before {
    background: rgba(0, 0, 0, 0.18) !important;
}

body.auth-screen::after {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background:
        linear-gradient(135deg, rgba(9, 15, 22, 0.46), rgba(13, 25, 31, 0.34)),
        linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(0, 0, 0, 0.18));
}

.app-shell .container,
.app-shell .container-fluid,
.auth-screen .login-wrapper,
.auth-screen .verify-container,
.auth-screen .login-card,
.auth-screen .register-container {
    position: relative;
    z-index: 1;
}

.container {
    max-width: 1180px;
}

.navbar.navbar-dark.bg-dark {
    background: linear-gradient(135deg, rgba(16, 24, 33, 0.98), rgba(28, 41, 51, 0.96)) !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 10px 28px rgba(9, 15, 22, 0.2);
    backdrop-filter: blur(14px);
}

.navbar-brand {
    min-height: 40px;
    font-weight: 800;
    letter-spacing: 0;
}

.navbar-brand img,
.logo {
    object-fit: contain;
}

.navbar-nav {
    align-items: center;
    gap: 0.25rem;
}

.navbar-nav .nav-link,
.dropdown-item {
    font-weight: 700;
    letter-spacing: 0;
}

.navbar-nav .nav-link {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    border-radius: var(--ui-radius);
    padding: 0.55rem 0.8rem !important;
    transition: background-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.navbar-nav .nav-link:hover,
.navbar-nav .nav-link:focus {
    background: rgba(255, 255, 255, 0.12);
    color: #fff !important;
    transform: translateY(-1px);
}

.dropdown-menu {
    border: 1px solid var(--ui-border);
    border-radius: var(--ui-radius);
    box-shadow: var(--ui-shadow-md);
    overflow: hidden;
}

.page-section-title,
h1,
h2,
h3,
h4,
h5 {
    color: var(--ui-ink);
    font-weight: 800;
    letter-spacing: 0;
}

.page-section-title {
    line-height: 1.12;
}

.page-subtitle {
    max-width: 720px;
    color: var(--ui-muted);
    font-size: 0.98rem;
    line-height: 1.55;
}

.card,
.login-card,
.register-container,
.verify-container,
.profile-container,
.manual-card,
.scheme-card,
.summary-card,
.analysis-tab-card,
.chart-panel,
.insight-panel {
    border: 1px solid var(--ui-border) !important;
    border-radius: var(--ui-radius) !important;
    box-shadow: var(--ui-shadow-sm) !important;
}

.card,
.profile-container,
.manual-card,
.scheme-card,
.summary-card,
.analysis-tab-card,
.chart-panel {
    background: var(--ui-surface) !important;
}

.card-body {
    padding: 1.35rem;
}

.card-header {
    border-top-left-radius: var(--ui-radius) !important;
    border-top-right-radius: var(--ui-radius) !important;
    border-bottom: 1px solid var(--ui-border) !important;
    font-weight: 800;
}

.bg-primary,
.card-header.bg-primary {
    background: linear-gradient(135deg, var(--ui-brand), var(--ui-accent)) !important;
}

.form-label {
    margin-bottom: 0.45rem;
    color: #243241;
    font-weight: 800;
}

.form-text,
small {
    color: var(--ui-muted) !important;
}

.form-control,
.form-select,
.input-group-text,
textarea.form-control {
    min-height: 46px;
    border: 1px solid rgba(23, 33, 43, 0.16) !important;
    border-radius: var(--ui-radius) !important;
    background-color: rgba(255, 255, 255, 0.96) !important;
    color: var(--ui-ink);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

textarea.form-control {
    min-height: 118px;
    resize: vertical;
}

.form-control:focus,
.form-select:focus,
textarea.form-control:focus {
    border-color: rgba(8, 127, 140, 0.58) !important;
    box-shadow: 0 0 0 0.2rem rgba(8, 127, 140, 0.14) !important;
}

.btn {
    border-radius: var(--ui-radius) !important;
    font-weight: 800 !important;
    letter-spacing: 0;
    padding: 0.66rem 1rem !important;
    box-shadow: 0 8px 18px rgba(23, 33, 43, 0.08);
}

.btn-sm {
    padding: 0.42rem 0.68rem !important;
    font-size: 0.84rem !important;
}

.btn-lg {
    padding: 0.82rem 1.15rem !important;
}

.btn-primary,
.btn-success,
.btn-info,
.btn-warning,
.btn-danger {
    border: 0 !important;
}

.btn-primary {
    background: linear-gradient(135deg, var(--ui-brand), #d13946) !important;
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--ui-brand-dark), var(--ui-brand)) !important;
}

.btn-success {
    background: linear-gradient(135deg, var(--ui-success), #25a97b) !important;
}

.btn-danger {
    background: linear-gradient(135deg, var(--ui-danger), #e05260) !important;
}

.btn-warning {
    background: linear-gradient(135deg, var(--ui-warning), #f1c244) !important;
    color: #17212b !important;
}

.btn-info {
    background: linear-gradient(135deg, var(--ui-info), #2f9fcd) !important;
    color: #fff !important;
}

.btn-secondary {
    background: #566475 !important;
    border-color: #566475 !important;
}

.btn-outline-primary,
.btn-outline-secondary,
.btn-outline-danger,
.btn-outline-success {
    background: rgba(255, 255, 255, 0.84) !important;
    border-width: 1px !important;
}

.btn-view-action {
    min-width: 104px;
    color: #fff !important;
    background: linear-gradient(135deg, var(--ui-accent), var(--ui-info)) !important;
    border: 0 !important;
    box-shadow: 0 10px 20px rgba(27, 122, 166, 0.18);
}

.btn-view-action:hover,
.btn-view-action:focus {
    color: #fff !important;
    background: linear-gradient(135deg, var(--ui-accent-dark), var(--ui-accent)) !important;
}

.alert {
    border: 0 !important;
    border-radius: var(--ui-radius) !important;
    box-shadow: var(--ui-shadow-sm);
}

.badge {
    border-radius: 6px;
    padding: 0.45em 0.65em;
}

.table-responsive {
    width: 100%;
    border: 1px solid var(--ui-border);
    border-radius: var(--ui-radius);
    background: var(--ui-surface-strong);
    box-shadow: var(--ui-shadow-sm);
    overflow-x: auto;
}

.table {
    margin-bottom: 0;
    border-color: transparent !important;
    vertical-align: middle;
}

.table > :not(caption) > * > * {
    padding: 0.9rem 0.85rem;
    border-color: rgba(23, 33, 43, 0.08) !important;
}

.table thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    border: 0 !important;
    background: #17212b !important;
    color: #f8fafc !important;
    font-size: 0.78rem !important;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
    white-space: nowrap;
}

.table tbody td {
    color: #243241;
}

.table tbody tr {
    transition: background-color 0.16s ease;
}

.table tbody tr:hover {
    background: rgba(8, 127, 140, 0.06) !important;
}

.table img {
    max-width: 72px;
    height: 44px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid var(--ui-border);
}

.pagination {
    flex-wrap: wrap;
    gap: 0.35rem;
}

.pagination-shell {
    max-width: 100%;
    overflow-x: auto;
    padding: 0.25rem 0 0.5rem;
}

.pagination-compact {
    width: max-content;
    max-width: 100%;
    margin-right: auto;
    margin-left: auto;
}

.pagination .page-link {
    border: 0;
    border-radius: var(--ui-radius) !important;
    color: var(--ui-ink);
    background: #fff;
    box-shadow: var(--ui-shadow-sm);
    min-width: 2.35rem;
    text-align: center;
    white-space: nowrap;
}

.pagination .page-item.active .page-link {
    background: linear-gradient(135deg, var(--ui-brand), var(--ui-accent));
    color: #fff;
}

.pagination .page-item.disabled .page-link {
    color: #8d98a7;
    background: rgba(255, 255, 255, 0.72);
    box-shadow: none;
}

.pagination .page-ellipsis .page-link {
    min-width: 2rem;
    padding-right: 0.35rem;
    padding-left: 0.35rem;
    background: transparent;
}

.status-box {
    min-height: 132px;
    display: grid;
    align-content: center;
    gap: 0.45rem;
    overflow: hidden;
    color: #fff;
    border-radius: var(--ui-radius) !important;
    box-shadow: var(--ui-shadow-md);
}

.status-box h5 {
    margin: 0;
    font-size: 0.92rem;
    font-weight: 800;
    text-transform: uppercase;
}

.status-box h3 {
    margin: 0;
    color: #fff;
    font-size: 2.25rem;
}

.status-open {
    background: linear-gradient(135deg, #bf7b00, #e1a51c) !important;
}

.status-inprocess {
    background: linear-gradient(135deg, var(--ui-info), #36a9d7) !important;
}

.status-closed {
    background: linear-gradient(135deg, var(--ui-success), #25a97b) !important;
}

.summary-card .card-body {
    min-height: 118px;
    display: grid;
    align-content: center;
}

.summary-card h6 {
    color: var(--ui-muted);
    font-size: 0.82rem;
    font-weight: 800;
    text-transform: uppercase;
}

.summary-card h3 {
    margin: 0;
    font-size: 2rem;
}

.nav-tabs {
    gap: 0.45rem;
    border-bottom: 0;
}

.nav-tabs .nav-link {
    border: 1px solid var(--ui-border) !important;
    border-radius: var(--ui-radius) !important;
    background: #fff;
    color: #344255;
    font-weight: 800;
}

.nav-tabs .nav-link.active {
    background: linear-gradient(135deg, var(--ui-brand), var(--ui-accent));
    color: #fff !important;
}

.modal-content {
    border: 1px solid var(--ui-border) !important;
    border-radius: var(--ui-radius) !important;
    box-shadow: var(--ui-shadow-lg) !important;
}

.analysis-summary-header {
    background: linear-gradient(135deg, var(--ui-brand), var(--ui-accent)) !important;
    color: #fff;
}

.analysis-kpis {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.9rem;
    margin-bottom: 1rem;
}

.analysis-kpi {
    border: 1px solid var(--ui-border);
    border-radius: var(--ui-radius);
    background: #fff;
    padding: 1rem;
    text-align: left;
}

.analysis-kpi-label {
    color: var(--ui-muted);
    font-size: 0.78rem;
    font-weight: 800;
    text-transform: uppercase;
}

.analysis-kpi-value {
    margin-top: 0.25rem;
    color: var(--ui-ink);
    font-size: 1.75rem;
    font-weight: 800;
}

.analysis-kpi-trend,
.insight-subtext {
    color: var(--ui-muted);
    font-size: 0.86rem;
}

.analysis-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.45fr) minmax(260px, 0.9fr);
    gap: 1rem;
    align-items: stretch;
}

.chart-panel {
    min-height: 340px;
    padding: 1rem;
}

.chart-container {
    position: relative;
    width: 100%;
    height: 320px;
}

.chart-container canvas {
    width: 100% !important;
    height: 100% !important;
}

.insight-panel {
    background: linear-gradient(180deg, #17212b, #243241) !important;
    color: #f8fafc;
    padding: 1rem;
}

.insight-panel h6 {
    color: #fff;
    font-weight: 800;
}

.insight-list {
    display: grid;
    gap: 0.75rem;
}

.insight-item {
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: var(--ui-radius);
    background: rgba(255, 255, 255, 0.08);
    padding: 0.82rem;
}

.insight-title {
    font-size: 0.76rem;
    font-weight: 800;
    text-transform: uppercase;
    opacity: 0.72;
}

.insight-value {
    margin-top: 0.15rem;
    font-size: 1.1rem;
    font-weight: 800;
}

.auth-screen .login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
}

.auth-screen .login-card,
.auth-screen .register-container,
.auth-screen .verify-container {
    width: 100%;
    max-width: 460px;
    color: #fff;
    background: linear-gradient(180deg, rgba(12, 20, 28, 0.54), rgba(12, 20, 28, 0.4)) !important;
    border-color: rgba(255, 255, 255, 0.26) !important;
    box-shadow: 0 24px 50px rgba(0, 0, 0, 0.26) !important;
    backdrop-filter: blur(8px);
}

.auth-screen .login-card,
.auth-screen .register-container {
    padding: 2.2rem;
}

.auth-screen .verify-container {
    padding: 2.2rem;
}

.auth-screen .brand-title,
.auth-screen .title {
    color: #ffd65a;
    font-weight: 800;
    letter-spacing: 0;
}

.auth-screen .form-label {
    color: #fff;
}

.auth-screen .btn-login,
.auth-screen .btn-primary {
    background: linear-gradient(135deg, #ffd65a, #e7b81f) !important;
    color: #17212b !important;
}

.auth-screen a {
    color: #ffe07c;
    font-weight: 800;
}

.profile-container {
    max-width: 680px;
    margin: 0 auto;
    padding: 1.5rem;
}

.manual-card .card-body,
.scheme-card .card-body {
    min-height: 100%;
}

.manual-actions,
.scheme-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.remarks-input {
    max-width: 240px;
}

.filter-form,
.stack-form,
.add-form {
    align-items: end;
}

.user-profile-page {
    max-width: 1320px;
}

.user-profile-heading .page-subtitle {
    margin-right: auto;
    margin-left: auto;
}

.user-summary-grid .summary-card .card-body {
    min-height: 106px;
}

.user-filter-grid {
    display: grid !important;
    grid-template-columns: minmax(280px, 1.15fr) minmax(210px, 0.9fr) minmax(230px, 0.9fr) minmax(180px, 0.65fr) minmax(160px, 0.55fr);
    align-items: start;
    gap: 1rem;
}

.user-filter-grid .filter-field {
    min-width: 0;
}

.user-filter-grid .form-text {
    margin-top: 0.45rem;
    line-height: 1.35;
}

.user-filter-grid .filter-submit {
    padding-top: 1.85rem;
}

.user-actions-bar {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) auto;
    align-items: center;
    gap: 1rem;
}

.user-result-count {
    line-height: 1.45;
}

.user-bulk-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.6rem;
}

.user-bulk-actions form {
    margin: 0;
}

.user-bulk-actions .btn {
    min-width: 210px;
}

.user-profile-table {
    min-width: 1320px;
}

.user-profile-table th,
.user-profile-table td {
    text-align: left;
}

.user-profile-table th:first-child,
.user-profile-table td:first-child,
.user-profile-table th:nth-child(5),
.user-profile-table td:nth-child(5),
.user-delete-cell,
.user-edit-cell {
    text-align: center;
}

.user-inline-form {
    align-items: center;
    gap: 0.55rem;
    flex-wrap: nowrap;
}

.user-reset-form .form-control {
    width: 170px;
}

.user-role-form .form-select {
    width: 105px;
}

.user-delete-cell,
.user-edit-cell {
    white-space: nowrap;
}

.pricing-page {
    max-width: 1560px;
}

.pricing-card {
    height: 100%;
}

.batch-toolbar {
    display: grid;
    grid-template-columns: minmax(220px, 0.45fr) minmax(220px, 0.45fr) auto;
    align-items: start;
    gap: 1rem;
}

.batch-toolbar-actions {
    display: flex;
    align-items: end;
    justify-content: flex-end;
    gap: 0.6rem;
    padding-top: 1.85rem;
}

.batch-table {
    min-width: 1280px;
    table-layout: fixed;
}

.batch-table th,
.batch-table td {
    vertical-align: middle;
}

.batch-table th:nth-child(3),
.batch-table th:nth-child(4),
.batch-table th:nth-child(5),
.batch-table th:nth-child(6),
.batch-table th:nth-child(7),
.batch-table th:nth-child(8),
.batch-table td:nth-child(3),
.batch-table td:nth-child(4),
.batch-table td:nth-child(5),
.batch-table td:nth-child(6),
.batch-table td:nth-child(7),
.batch-table td:nth-child(8) {
    text-align: right;
}

.batch-table .batch-product {
    min-width: 0;
}

.batch-table .batch-plant {
    min-width: 0;
}

.batch-table .batch-ptd,
.batch-table .batch-margin {
    min-width: 0;
}

.batch-table .batch-status {
    min-width: 0;
}

.batch-table th:nth-child(1) { width: 155px; }
.batch-table th:nth-child(2) { width: 360px; }
.batch-table th:nth-child(3) { width: 125px; }
.batch-table th:nth-child(4) { width: 115px; }
.batch-table th:nth-child(5) { width: 110px; }
.batch-table th:nth-child(6) { width: 145px; }
.batch-table th:nth-child(7) { width: 145px; }
.batch-table th:nth-child(8) { width: 110px; }
.batch-table th:nth-child(9) { width: 115px; }

.batch-table .btn-sm {
    width: 100%;
}

.batch-output-panel {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 190px;
    gap: 1rem;
    align-items: end;
}

.batch-output-actions {
    display: grid;
    gap: 0.6rem;
}

.region-plant-form {
    align-items: end;
}

.region-plant-table {
    min-width: 980px;
}

.region-plant-table th:first-child,
.region-plant-table td:first-child {
    width: 70px;
    text-align: center;
}

.region-plant-table th:last-child,
.region-plant-table td:last-child {
    width: 190px;
    text-align: center;
    white-space: nowrap;
}

.region-plant-edit-grid {
    display: grid;
    grid-template-columns: 90px minmax(150px, 1fr) 110px minmax(190px, 1.2fr) minmax(150px, 1fr) auto;
    gap: 0.55rem;
    align-items: center;
}

.row.mb-3.align-items-center form.d-flex.flex-wrap {
    display: grid !important;
    grid-template-columns: minmax(220px, 1fr) minmax(170px, 0.75fr) minmax(185px, 0.65fr) minmax(185px, 0.65fr) minmax(150px, auto);
    align-items: center;
    width: 100%;
}

.row.mb-3.align-items-center form.d-flex.flex-wrap .form-control,
.row.mb-3.align-items-center form.d-flex.flex-wrap .form-select {
    width: 100%;
    min-width: 0;
}

.row.mb-3.align-items-center form.d-flex.flex-wrap input[name="search"] {
    min-width: 0;
}

.row.mb-3.align-items-center form.d-flex.flex-wrap .btn {
    width: 100%;
}

.col-xl-2.text-xl-end form,
.col-md-5.text-end form {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.w-sm-auto,
.w-md-auto {
    width: auto !important;
}

.rotate {
    animation: rotate360 1s linear infinite;
}

@keyframes rotate360 {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@media (max-width: 991px) {
    .navbar-nav {
        align-items: stretch;
        padding-top: 0.75rem;
    }

    .navbar-nav .nav-link {
        width: 100%;
        justify-content: flex-start;
    }

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

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

@media (max-width: 768px) {
    body.app-shell {
        padding-top: 66px;
    }

    .container {
        padding-right: 0.85rem;
        padding-left: 0.85rem;
    }

    .card-body {
        padding: 1rem;
    }

    .page-section-title,
    h2 {
        font-size: 1.35rem;
    }

    .page-subtitle {
        font-size: 0.92rem;
    }

    .btn {
        width: 100%;
    }

    .btn-sm {
        width: auto;
    }

    .d-flex > .btn-sm,
    form.d-inline .btn-sm {
        width: 100%;
    }

    .table-responsive {
        border-radius: var(--ui-radius);
    }

    .table {
        min-width: 780px;
        font-size: 0.86rem;
    }

    .table > :not(caption) > * > * {
        padding: 0.62rem;
        white-space: nowrap;
    }

    .pagination-shell {
        margin-right: -0.85rem;
        margin-left: -0.85rem;
        padding-right: 0.85rem;
        padding-left: 0.85rem;
    }

    .pagination-compact {
        justify-content: flex-start !important;
    }

    .pagination .page-link {
        min-width: 2.15rem;
        padding: 0.55rem 0.7rem !important;
    }

    .status-box {
        min-height: 104px;
        margin-bottom: 0.75rem;
    }

    .status-box h3 {
        font-size: 1.7rem;
    }

    .analysis-kpis {
        grid-template-columns: 1fr;
    }

    .chart-container {
        height: 250px;
    }

    .auth-screen .login-card,
    .auth-screen .register-container,
    .auth-screen .verify-container {
        padding: 1.4rem;
    }

    .filter-form,
    .stack-form,
    .add-form {
        display: grid !important;
        grid-template-columns: 1fr;
        gap: 0.75rem !important;
    }

    .filter-form .me-2,
    .stack-form .me-2,
    .add-form .me-2 {
        margin-right: 0 !important;
    }

    .user-filter-grid {
        grid-template-columns: 1fr;
        gap: 0.8rem;
    }

    .user-filter-grid .form-text {
        min-height: 0;
    }

    .user-filter-grid .filter-submit {
        padding-bottom: 0;
    }

    .user-actions-bar {
        grid-template-columns: 1fr;
        align-items: stretch;
    }

    .user-bulk-actions {
        justify-content: stretch;
    }

    .user-bulk-actions .btn,
    .user-bulk-actions form {
        width: 100%;
        min-width: 0;
    }

    .user-profile-table {
        min-width: 1120px;
    }

    .user-inline-form {
        flex-direction: row !important;
    }

    .batch-toolbar,
    .batch-output-panel {
        grid-template-columns: 1fr;
    }

    .batch-toolbar-actions {
        justify-content: stretch;
        padding-top: 0;
    }

    .batch-toolbar-actions .btn,
    .batch-output-actions .btn {
        width: 100%;
    }

    .batch-table {
        min-width: 1040px;
    }

    .region-plant-form {
        align-items: stretch;
    }

    .region-plant-table {
        min-width: 900px;
    }

    .region-plant-edit-grid {
        grid-template-columns: 1fr;
    }

    .manual-card .card-body {
        align-items: stretch !important;
        flex-direction: column;
    }

    .manual-actions,
    .scheme-actions {
        width: 100%;
    }

    .row.mb-3.align-items-center form.d-flex.flex-wrap,
    .col-xl-2.text-xl-end form,
    .col-md-5.text-end form {
        display: grid !important;
        width: 100%;
        grid-template-columns: 1fr;
        gap: 0.75rem !important;
    }

    .row.mb-3.align-items-center form.d-flex.flex-wrap .form-control,
    .row.mb-3.align-items-center form.d-flex.flex-wrap .form-select,
    .row.mb-3.align-items-center form.d-flex.flex-wrap input[name="search"] {
        width: 100%;
        min-width: 0;
    }

    .w-sm-auto,
    .w-md-auto {
        width: 100% !important;
    }
}

html[data-theme="dark"] body.app-shell {
    background: linear-gradient(180deg, #111820 0%, #151d26 42%, #0f141a 100%);
}

html[data-theme="dark"] .card,
html[data-theme="dark"] .profile-container,
html[data-theme="dark"] .manual-card,
html[data-theme="dark"] .scheme-card,
html[data-theme="dark"] .summary-card,
html[data-theme="dark"] .analysis-tab-card,
html[data-theme="dark"] .chart-panel,
html[data-theme="dark"] .table-responsive,
html[data-theme="dark"] .theme-toggle,
html[data-theme="dark"] .dropdown-menu,
html[data-theme="dark"] .modal-content {
    background: var(--ui-surface-strong) !important;
}

html[data-theme="dark"] .page-section-title,
html[data-theme="dark"] .page-subtitle,
html[data-theme="dark"] .text-muted,
html[data-theme="dark"] .table tbody td,
html[data-theme="dark"] .table tbody th,
html[data-theme="dark"] .table .form-text,
html[data-theme="dark"] .navbar-text,
html[data-theme="dark"] .form-label,
html[data-theme="dark"] .theme-toggle-label,
html[data-theme="dark"] .dropdown-item,
html[data-theme="dark"] .dropdown-item.text-danger,
html[data-theme="dark"] .text-dark {
    color: var(--ui-ink) !important;
}

html[data-theme="dark"] .page-subtitle,
html[data-theme="dark"] .form-text,
html[data-theme="dark"] small {
    color: var(--ui-muted) !important;
}

html[data-theme="dark"] .form-control,
html[data-theme="dark"] .form-select,
html[data-theme="dark"] .input-group-text,
html[data-theme="dark"] textarea.form-control {
    background-color: rgba(14, 21, 29, 0.95) !important;
    color: var(--ui-ink) !important;
    border-color: rgba(159, 176, 194, 0.22) !important;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

html[data-theme="dark"] .form-control::placeholder,
html[data-theme="dark"] textarea.form-control::placeholder {
    color: var(--ui-muted) !important;
    opacity: 0.88;
}

html[data-theme="dark"] .table tbody tr {
    background: transparent !important;
}

html[data-theme="dark"] .table tbody tr:hover {
    background: rgba(27, 152, 165, 0.1) !important;
}

html[data-theme="dark"] .table img {
    border-color: rgba(159, 176, 194, 0.2);
}

html[data-theme="dark"] .badge.bg-success {
    background-color: var(--ui-success) !important;
}

html[data-theme="dark"] .badge.bg-danger {
    background-color: var(--ui-danger) !important;
}

html[data-theme="dark"] .btn-outline-danger,
html[data-theme="dark"] .btn-outline-success,
html[data-theme="dark"] .btn-outline-primary,
html[data-theme="dark"] .btn-outline-secondary {
    background: rgba(20, 29, 38, 0.92) !important;
}

html[data-theme="dark"] .dropdown-item:hover,
html[data-theme="dark"] .dropdown-item:focus {
    background: rgba(27, 152, 165, 0.12);
}

html[data-theme="dark"] .dropdown-divider,
html[data-theme="dark"] .modal-header,
html[data-theme="dark"] .modal-footer {
    border-color: var(--ui-border);
}

html[data-theme="dark"] .pagination .page-link {
    background: rgba(24, 32, 41, 0.94);
    color: var(--ui-ink);
}

html[data-theme="dark"] .pagination .page-item.disabled .page-link {
    background: rgba(24, 32, 41, 0.72);
    color: var(--ui-muted);
}

html[data-theme="dark"] .user-profile-table .btn-warning,
html[data-theme="dark"] .user-profile-table .btn-danger,
html[data-theme="dark"] .user-profile-table .btn-primary,
html[data-theme="dark"] .user-profile-table .btn-info,
html[data-theme="dark"] .user-profile-table .btn-view-action {
    color: #fff !important;
}

html[data-theme="dark"] .user-profile-table {
    background: #182029;
}

html[data-theme="dark"] .user-profile-table.bg-white,
html[data-theme="dark"] .user-profile-table.bg-white > :not(caption) > * > *,
html[data-theme="dark"] .user-profile-table.table-hover > tbody > tr,
html[data-theme="dark"] .user-profile-table.table-bordered > :not(caption) > * > * {
    background-color: #182029 !important;
}

html[data-theme="dark"] .user-profile-table thead th {
    background: linear-gradient(180deg, #111821, #17212b) !important;
    color: #f7fbff !important;
    border-bottom: 1px solid rgba(159, 176, 194, 0.14) !important;
}

html[data-theme="dark"] .user-profile-table tbody tr {
    background: #182029 !important;
}

html[data-theme="dark"] .user-profile-table tbody tr:nth-child(even) {
    background: #1b2530 !important;
}

html[data-theme="dark"] .user-profile-table tbody tr:nth-child(even) > td {
    background-color: #1b2530 !important;
}

html[data-theme="dark"] .user-profile-table tbody td {
    color: #e7eef6 !important;
    border-color: rgba(159, 176, 194, 0.12) !important;
}

html[data-theme="dark"] .user-profile-table tbody td .text-muted,
html[data-theme="dark"] .user-profile-table tbody td .form-text {
    color: var(--ui-muted) !important;
}

html[data-theme="dark"] .user-profile-table tbody tr:hover {
    background: #202d39 !important;
}

html[data-theme="dark"] .user-profile-table .user-inline-form,
html[data-theme="dark"] .user-profile-table form:not(.d-inline) {
    padding: 0.1rem 0;
}

html[data-theme="dark"] .user-profile-table .form-control,
html[data-theme="dark"] .user-profile-table .form-select {
    background: rgba(10, 16, 23, 0.92) !important;
    color: #edf2f7 !important;
    border-color: rgba(159, 176, 194, 0.2) !important;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

html[data-theme="dark"] .user-profile-table .form-control::placeholder {
    color: #8ea0b3 !important;
}

html[data-theme="dark"] .user-profile-table .badge {
    box-shadow: none;
}

html[data-theme="dark"] .user-profile-table .btn-sm {
    box-shadow: none;
}

html[data-theme="dark"] .user-profile-table .btn-warning {
    color: #17212b !important;
}

.chat-page {
    padding-top: 84px;
    padding-bottom: 24px;
}

.chat-flash-stack {
    max-width: 1320px;
    margin: 0 auto 12px;
}

.chat-layout {
    max-width: 1320px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
    gap: 16px;
    min-height: calc(100vh - 124px);
}

.chat-sidebar,
.chat-thread-shell {
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid rgba(18, 34, 52, 0.08);
    border-radius: 8px;
    box-shadow: 0 22px 48px rgba(18, 38, 63, 0.12);
    overflow: hidden;
}

.chat-sidebar {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.chat-sidebar-header,
.chat-thread-header,
.chat-composer-shell {
    padding: 16px 18px;
}

.chat-sidebar-header,
.chat-thread-header {
    border-bottom: 1px solid rgba(18, 34, 52, 0.08);
}

.chat-contact-list {
    overflow-y: auto;
    padding: 10px;
    display: grid;
    gap: 8px;
}

.chat-contact {
    display: grid;
    grid-template-columns: 46px minmax(0, 1fr);
    gap: 12px;
    align-items: start;
    padding: 12px;
    border: 1px solid rgba(18, 34, 52, 0.08);
    border-radius: 8px;
    text-decoration: none;
    color: inherit;
    background: rgba(247, 250, 252, 0.94);
    transition: border-color 0.18s ease, background 0.18s ease, transform 0.18s ease;
}

.chat-contact:hover,
.chat-contact.is-active {
    border-color: rgba(27, 152, 165, 0.32);
    background: rgba(27, 152, 165, 0.08);
    transform: translateY(-1px);
}

.chat-contact-avatar,
.chat-thread-avatar {
    width: 46px;
    height: 46px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    font-weight: 700;
    color: #fff;
    background: linear-gradient(135deg, #1a5f7a, #26a69a);
    flex-shrink: 0;
}

.chat-thread-avatar {
    width: 52px;
    height: 52px;
}

.chat-contact-copy,
.chat-thread-profile {
    min-width: 0;
}

.chat-contact-topline,
.chat-thread-profile {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-contact-topline {
    justify-content: space-between;
    margin-bottom: 4px;
}

.chat-contact-name,
.chat-thread-name {
    font-weight: 700;
    color: #11283d;
}

.chat-contact-meta,
.chat-thread-meta,
.chat-contact-snippet,
.chat-bubble-meta {
    color: #5f7386;
    font-size: 0.84rem;
}

.chat-contact-snippet {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 4px;
}

.chat-unread-pill {
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    border-radius: 999px;
    display: inline-grid;
    place-items: center;
    background: #1b98a5;
    color: #fff;
    font-size: 0.75rem;
    font-weight: 700;
}

.chat-empty-side,
.chat-empty-state {
    display: grid;
    place-items: center;
    text-align: center;
    color: #5f7386;
}

.chat-empty-side {
    padding: 32px 16px;
    gap: 10px;
}

.chat-empty-state {
    min-height: 100%;
    padding: 24px;
    gap: 10px;
}

.chat-empty-state i,
.chat-empty-side i {
    font-size: 2rem;
    color: #1b98a5;
}

.chat-thread-shell {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.chat-thread-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}

.chat-thread-body {
    flex: 1;
    min-height: 360px;
    max-height: calc(100vh - 290px);
    overflow-y: auto;
    padding: 18px;
    background:
        linear-gradient(180deg, rgba(247, 250, 252, 0.96), rgba(240, 246, 250, 0.96)),
        radial-gradient(circle at top left, rgba(27, 152, 165, 0.06), transparent 36%);
    display: grid;
    gap: 12px;
}

.chat-bubble {
    max-width: min(78%, 680px);
    padding: 12px 14px;
    border-radius: 8px;
    border: 1px solid rgba(18, 34, 52, 0.08);
    box-shadow: 0 10px 20px rgba(18, 38, 63, 0.08);
}

.chat-bubble.is-own {
    margin-left: auto;
    background: linear-gradient(135deg, #1a5f7a, #2196a5);
    color: #fff;
    border-color: rgba(26, 95, 122, 0.35);
}

.chat-bubble.is-own .chat-bubble-meta,
.chat-bubble.is-own .chat-bubble-text a {
    color: rgba(255, 255, 255, 0.82);
}

.chat-bubble.is-other {
    margin-right: auto;
    background: #fff;
    color: #11283d;
}

.chat-bubble-meta {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 6px;
}

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

.chat-attachment {
    margin-top: 10px;
}

.chat-attachment img {
    max-width: min(100%, 320px);
    border-radius: 8px;
    display: block;
}

.chat-attachment audio {
    width: min(100%, 320px);
    display: block;
    margin-bottom: 8px;
}

.chat-file-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-radius: 8px;
    background: rgba(17, 40, 61, 0.06);
    color: inherit;
    text-decoration: none;
}

.chat-bubble.is-own .chat-file-chip {
    background: rgba(255, 255, 255, 0.16);
    color: #fff;
}

.chat-composer-shell {
    border-top: 1px solid rgba(18, 34, 52, 0.08);
    background: rgba(255, 255, 255, 0.98);
}

.chat-composer-status {
    font-size: 0.84rem;
    color: #5f7386;
    margin-bottom: 8px;
}

.chat-composer {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    align-items: end;
}

.chat-message-input {
    min-height: 48px;
    max-height: 140px;
    resize: vertical;
}

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

.chat-upload-preview {
    margin-top: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    background: rgba(27, 152, 165, 0.08);
    color: #1a5165;
    font-size: 0.9rem;
}

#voiceRecordButton.is-recording {
    background: #dc3545;
    border-color: #dc3545;
    color: #fff;
}

.chat-layout-advanced .chat-sidebar {
    backdrop-filter: blur(12px);
}

.chat-sidebar-copy {
    display: grid;
    gap: 2px;
}

.chat-live-pill,
.chat-thread-presence {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 999px;
    background: rgba(27, 152, 165, 0.1);
    color: #1a5165;
    font-size: 0.82rem;
    font-weight: 600;
}

.chat-live-dot,
.chat-presence-dot {
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: #22c55e;
    box-shadow: 0 0 0 6px rgba(34, 197, 94, 0.12);
}

.chat-sidebar-tools {
    padding: 0 16px 12px;
}

.chat-sidebar-tools .input-group-text {
    background: rgba(17, 40, 61, 0.04);
}

.chat-thread-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.chat-bubble.is-new {
    animation: chatBubbleGlow 1.4s ease;
}

@keyframes chatBubbleGlow {
    0% {
        transform: translateY(8px);
        box-shadow: 0 0 0 rgba(27, 152, 165, 0);
    }
    30% {
        transform: translateY(0);
        box-shadow: 0 0 0 6px rgba(27, 152, 165, 0.12);
    }
    100% {
        box-shadow: 0 10px 20px rgba(18, 38, 63, 0.08);
    }
}

.chat-bubble-status {
    margin-top: 8px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.77rem;
    opacity: 0.9;
}

.chat-bubble-status.delivered {
    color: rgba(255, 255, 255, 0.9);
}

.chat-bubble-status.read {
    color: #b7f5ff;
}

.chat-typing-indicator {
    padding: 0 18px 14px;
    font-size: 0.85rem;
    color: #5f7386;
    display: flex;
    align-items: center;
    gap: 8px;
}

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

.chat-typing-dots span {
    width: 6px;
    height: 6px;
    border-radius: 999px;
    background: currentColor;
    opacity: 0.32;
    animation: chatTypingPulse 1s infinite;
}

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

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

@keyframes chatTypingPulse {
    0%, 80%, 100% { opacity: 0.25; transform: translateY(0); }
    40% { opacity: 1; transform: translateY(-2px); }
}

.chat-composer-main {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    align-items: end;
}

.chat-emoji-panel {
    margin-top: 10px;
    padding: 12px;
    border: 1px solid rgba(18, 34, 52, 0.08);
    border-radius: 8px;
    background: rgba(247, 250, 252, 0.98);
    display: grid;
    gap: 12px;
}

.chat-emoji-section {
    display: grid;
    gap: 8px;
}

.chat-emoji-heading {
    font-size: 0.78rem;
    font-weight: 700;
    color: #5f7386;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.chat-emoji-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(34px, 1fr));
    gap: 6px;
}

.chat-emoji-btn {
    border: 1px solid rgba(18, 34, 52, 0.08);
    border-radius: 8px;
    background: #fff;
    min-height: 34px;
    font-size: 1.1rem;
    line-height: 1;
}

.chat-emoji-btn:hover {
    background: rgba(27, 152, 165, 0.08);
    border-color: rgba(27, 152, 165, 0.18);
}

html[data-theme="dark"] .chat-sidebar,
html[data-theme="dark"] .chat-thread-shell,
html[data-theme="dark"] .chat-composer-shell {
    background: #151d26 !important;
    border-color: rgba(159, 176, 194, 0.14);
}

html[data-theme="dark"] .chat-contact {
    background: rgba(19, 28, 37, 0.94);
    border-color: rgba(159, 176, 194, 0.12);
}

html[data-theme="dark"] .chat-contact:hover,
html[data-theme="dark"] .chat-contact.is-active {
    background: rgba(27, 152, 165, 0.16);
}

html[data-theme="dark"] .chat-contact-name,
html[data-theme="dark"] .chat-thread-name,
html[data-theme="dark"] .chat-bubble.is-other,
html[data-theme="dark"] .chat-upload-preview {
    color: #e7eef6;
}

html[data-theme="dark"] .chat-contact-meta,
html[data-theme="dark"] .chat-thread-meta,
html[data-theme="dark"] .chat-contact-snippet,
html[data-theme="dark"] .chat-bubble-meta,
html[data-theme="dark"] .chat-composer-status,
html[data-theme="dark"] .chat-empty-state,
html[data-theme="dark"] .chat-empty-side {
    color: #93a7ba;
}

html[data-theme="dark"] .chat-thread-body {
    background: linear-gradient(180deg, #10171f, #111b23);
}

html[data-theme="dark"] .chat-bubble.is-other {
    background: #1b2530;
    border-color: rgba(159, 176, 194, 0.14);
}

html[data-theme="dark"] .chat-bubble.is-own {
    background: linear-gradient(135deg, #1d6b7a, #1f8d9b);
}

html[data-theme="dark"] .chat-file-chip {
    background: rgba(255, 255, 255, 0.08);
    color: #e7eef6;
}

html[data-theme="dark"] .chat-upload-preview {
    background: rgba(27, 152, 165, 0.16);
}

html[data-theme="dark"] .chat-live-pill,
html[data-theme="dark"] .chat-thread-presence {
    background: rgba(27, 152, 165, 0.16);
    color: #d7edf1;
}

html[data-theme="dark"] .chat-typing-indicator,
html[data-theme="dark"] .chat-emoji-heading {
    color: #93a7ba;
}

html[data-theme="dark"] .chat-emoji-panel {
    background: #10171f;
    border-color: rgba(159, 176, 194, 0.14);
}

html[data-theme="dark"] .chat-emoji-btn {
    background: #1b2530;
    color: #e7eef6;
    border-color: rgba(159, 176, 194, 0.12);
}

html[data-theme="dark"] .chat-emoji-btn:hover {
    background: rgba(27, 152, 165, 0.18);
}

html[data-theme="dark"] .chat-sidebar-tools .input-group-text {
    background: rgba(255, 255, 255, 0.04);
}

@media (max-width: 991px) {
    .chat-layout {
        grid-template-columns: 1fr;
        min-height: auto;
    }

    .chat-sidebar {
        max-height: 320px;
    }

    .chat-thread-body {
        max-height: 56vh;
    }
}

@media (max-width: 767px) {
    .chat-page {
        padding-top: 72px;
    }

    .chat-thread-header,
    .chat-sidebar-header,
    .chat-composer-shell {
        padding: 14px;
    }

    .chat-composer {
        grid-template-columns: 1fr;
    }

    .chat-composer-main {
        grid-template-columns: 1fr;
    }

    .chat-bubble {
        max-width: 100%;
    }

    .chat-thread-profile {
        align-items: flex-start;
    }

    .chat-thread-header {
        align-items: flex-start;
    }
}

.chat-contact-avatar.is-group,
.chat-thread-avatar.is-group {
    background: linear-gradient(135deg, #c85d2a, #e3a320);
}

.chat-group-members {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 0 18px 14px;
}

.chat-member-chip,
.chat-edited-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 999px;
    background: rgba(27, 152, 165, 0.08);
    color: #1a5165;
    font-size: 0.78rem;
}

.chat-deleted-label {
    display: inline-flex;
    align-items: center;
    padding: 6px 10px;
    border-radius: 999px;
    background: rgba(139, 148, 158, 0.16);
    color: #617180;
    font-size: 0.78rem;
}

.chat-reply-snippet,
.chat-context-banner {
    border-left: 3px solid rgba(27, 152, 165, 0.72);
    background: rgba(27, 152, 165, 0.08);
    border-radius: 8px;
    padding: 10px 12px;
}

.chat-reply-snippet {
    margin-bottom: 10px;
    display: grid;
    gap: 4px;
}

.chat-deleted-message {
    font-style: italic;
    color: #617180;
}

.chat-context-banner {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 10px;
}

.chat-context-copy {
    display: grid;
    gap: 2px;
    min-width: 0;
}

.chat-bubble-footer,
.chat-bubble-tools,
.chat-input-stack {
    display: flex;
}

.chat-bubble-footer {
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-top: 8px;
}

.chat-bubble-tools {
    gap: 4px;
    flex-wrap: wrap;
}

.chat-inline-action {
    padding: 0 !important;
    text-decoration: none;
}

.chat-input-stack {
    position: relative;
    flex-direction: column;
    min-width: 0;
}

.chat-mention {
    color: #0f6c7b;
    font-weight: 700;
}

.chat-mention-panel {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + 6px);
    z-index: 12;
    border: 1px solid rgba(18, 34, 52, 0.08);
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 16px 32px rgba(18, 38, 63, 0.14);
    overflow: hidden;
}

.chat-mention-option {
    width: 100%;
    border: 0;
    background: transparent;
    text-align: left;
    padding: 10px 12px;
    display: grid;
    gap: 2px;
}

.chat-mention-option:hover {
    background: rgba(27, 152, 165, 0.08);
}

html[data-theme="dark"] .chat-member-chip,
html[data-theme="dark"] .chat-edited-label,
html[data-theme="dark"] .chat-reply-snippet,
html[data-theme="dark"] .chat-context-banner {
    background: rgba(27, 152, 165, 0.14);
    color: #d7edf1;
}

html[data-theme="dark"] .chat-deleted-label {
    background: rgba(159, 176, 194, 0.12);
    color: #aebfd0;
}

html[data-theme="dark"] .chat-deleted-message {
    color: #aebfd0;
}

html[data-theme="dark"] .chat-mention {
    color: #74dbe7;
}

html[data-theme="dark"] .chat-mention-panel {
    background: #10171f;
    border-color: rgba(159, 176, 194, 0.14);
}

html[data-theme="dark"] .chat-mention-option {
    color: #e7eef6;
}

html[data-theme="dark"] .chat-mention-option:hover {
    background: rgba(27, 152, 165, 0.18);
}

.chat-page {
    padding-top: 92px;
    padding-bottom: 30px;
}

.chat-layout.chat-layout-advanced {
    max-width: 1440px;
    gap: 20px;
    align-items: stretch;
}

.chat-sidebar,
.chat-thread-shell {
    border-color: rgba(18, 34, 52, 0.09);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(247, 250, 252, 0.96));
    box-shadow: 0 28px 60px rgba(18, 38, 63, 0.14);
}

.chat-sidebar {
    position: relative;
}

.chat-sidebar::after,
.chat-thread-shell::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.chat-sidebar::after {
    background:
        radial-gradient(circle at top left, rgba(180, 35, 47, 0.08), transparent 26%),
        radial-gradient(circle at bottom right, rgba(8, 127, 140, 0.08), transparent 28%);
}

.chat-thread-shell {
    position: relative;
}

.chat-thread-shell::before {
    background:
        radial-gradient(circle at top right, rgba(8, 127, 140, 0.08), transparent 30%),
        linear-gradient(180deg, rgba(255, 255, 255, 0.16), transparent 36%);
}

.chat-sidebar-header,
.chat-thread-header,
.chat-composer-shell,
.chat-sidebar-tools,
.chat-contact-list,
.chat-group-members,
.chat-typing-indicator {
    position: relative;
    z-index: 1;
}

.chat-sidebar-header {
    padding-bottom: 14px;
}

.chat-sidebar-eyebrow {
    font-size: 0.73rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--ui-brand);
}

.chat-sidebar-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 0 16px 14px;
}

.chat-sidebar-stat {
    display: grid;
    gap: 2px;
    padding: 10px 12px;
    border: 1px solid rgba(18, 34, 52, 0.08);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.74);
    min-width: 94px;
}

.chat-sidebar-stat-label {
    font-size: 0.74rem;
    color: var(--ui-muted);
    text-transform: uppercase;
    font-weight: 700;
}

.chat-sidebar-stat strong {
    font-size: 1.1rem;
    color: var(--ui-ink);
}

.chat-sidebar-tools {
    padding-bottom: 16px;
}

.chat-sidebar-tools .form-control,
.chat-sidebar-tools .input-group-text {
    min-height: 46px;
    background: rgba(255, 255, 255, 0.8);
}

.chat-contact-list {
    gap: 10px;
    padding: 10px 12px 12px;
}

.chat-contact {
    grid-template-columns: 52px minmax(0, 1fr);
    gap: 14px;
    padding: 14px;
    background: rgba(255, 255, 255, 0.74);
    box-shadow: 0 8px 20px rgba(18, 38, 63, 0.04);
}

.chat-contact:hover,
.chat-contact.is-active {
    background:
        linear-gradient(135deg, rgba(8, 127, 140, 0.08), rgba(27, 122, 166, 0.08));
    box-shadow: 0 16px 30px rgba(18, 38, 63, 0.08);
}

.chat-contact.is-active {
    border-color: rgba(8, 127, 140, 0.28);
}

.chat-contact-avatar,
.chat-thread-avatar {
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22), 0 12px 24px rgba(8, 127, 140, 0.2);
}

.chat-contact-avatar {
    width: 52px;
    height: 52px;
}

.chat-contact-name,
.chat-thread-name {
    letter-spacing: 0;
}

.chat-contact-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 10px;
}

.chat-contact-type {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 700;
    color: #1a5165;
}

.chat-contact-snippet {
    margin-top: 6px;
    line-height: 1.45;
}

.chat-thread-header {
    padding: 18px 20px;
    background: rgba(255, 255, 255, 0.64);
    backdrop-filter: blur(14px);
    align-items: flex-start;
}

.chat-thread-copy {
    min-width: 0;
    display: grid;
    gap: 5px;
}

.chat-thread-name-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.chat-thread-profile {
    gap: 14px;
}

.chat-thread-avatar {
    width: 58px;
    height: 58px;
}

.chat-thread-meta {
    line-height: 1.45;
}

.chat-thread-actions .btn {
    min-height: 40px;
    padding-inline: 14px;
    background: rgba(255, 255, 255, 0.72);
}

.chat-thread-actions {
    justify-content: flex-end;
}

.chat-thread-stage {
    position: relative;
    flex: 1;
    min-height: 0;
    padding: 16px 16px 0;
}

.chat-thread-stage::before {
    content: "";
    position: absolute;
    inset: 16px 16px 0;
    border: 1px solid rgba(18, 34, 52, 0.06);
    border-radius: 8px;
    background:
        radial-gradient(circle at top left, rgba(8, 127, 140, 0.08), transparent 26%),
        linear-gradient(180deg, rgba(246, 249, 252, 0.96), rgba(239, 245, 248, 0.96));
}

.chat-thread-body {
    position: relative;
    z-index: 1;
    max-height: calc(100vh - 340px);
    padding: 22px;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
    background: transparent;
}

.chat-bubble {
    max-width: min(72%, 760px);
    padding: 14px 16px 12px;
    border-radius: 8px;
}

.chat-bubble.is-own {
    background: linear-gradient(135deg, #136a7c, #1a8b9b 58%, #238ea8);
}

.chat-bubble.is-own .chat-bubble-text,
.chat-bubble.is-own .chat-bubble-text a,
.chat-bubble.is-own .chat-inline-action,
.chat-bubble.is-own .chat-deleted-message,
.chat-bubble.is-own .chat-mention {
    color: #f5fcff !important;
}

.chat-bubble.is-own .chat-inline-action.text-danger {
    color: #ffd7dd !important;
}

.chat-bubble.is-own .chat-inline-action:hover,
.chat-bubble.is-own .chat-inline-action:focus {
    color: #ffffff !important;
}

.chat-bubble.is-other {
    background: rgba(255, 255, 255, 0.94);
}

.chat-bubble-meta {
    font-size: 0.77rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 8px;
}

.chat-bubble-text {
    line-height: 1.55;
    font-size: 0.97rem;
}

.chat-bubble-footer {
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid rgba(18, 34, 52, 0.08);
}

.chat-bubble.is-own .chat-bubble-footer {
    border-top-color: rgba(255, 255, 255, 0.16);
}

.chat-bubble.is-own .chat-reply-snippet,
.chat-bubble.is-own .chat-context-banner {
    background: rgba(255, 255, 255, 0.12);
    border-left-color: rgba(255, 255, 255, 0.48);
    color: #f5fcff;
}

.chat-bubble.is-own .chat-edited-label,
.chat-bubble.is-own .chat-deleted-label {
    background: rgba(255, 255, 255, 0.16);
    color: #f5fcff;
}

.chat-inline-action {
    color: inherit;
    opacity: 0.82;
    font-weight: 700;
}

.chat-inline-action:hover,
.chat-inline-action:focus {
    opacity: 1;
}

.chat-group-members {
    padding-top: 14px;
    padding-bottom: 16px;
}

.chat-member-chip,
.chat-edited-label,
.chat-deleted-label {
    font-weight: 700;
}

.chat-typing-indicator {
    padding: 10px 20px 0;
}

.chat-composer-shell {
    margin: 0 16px 16px;
    border: 1px solid rgba(18, 34, 52, 0.08);
    border-radius: 8px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(247, 250, 252, 0.98));
    box-shadow: 0 18px 36px rgba(18, 38, 63, 0.08);
}

.chat-composer-status {
    font-weight: 600;
}

.chat-context-banner {
    margin-bottom: 12px;
}

.chat-message-input {
    min-height: 56px;
    border-radius: 8px;
    padding: 14px 15px;
    resize: none;
    line-height: 1.55;
}

.chat-composer-actions {
    gap: 10px;
}

.chat-icon-action {
    min-width: 42px;
    min-height: 42px;
    padding: 0;
    display: inline-grid;
    place-items: center;
}

.chat-send-button {
    min-height: 42px;
    padding-inline: 16px;
    background: linear-gradient(135deg, var(--ui-brand), #d64553);
    border-color: transparent;
    box-shadow: 0 12px 24px rgba(180, 35, 47, 0.18);
}

.chat-send-button:hover,
.chat-send-button:focus {
    background: linear-gradient(135deg, var(--ui-brand-dark), var(--ui-brand));
    border-color: transparent;
}

.chat-emoji-panel,
.chat-upload-preview,
.chat-mention-panel {
    box-shadow: 0 18px 34px rgba(18, 38, 63, 0.12);
}

.chat-empty-state {
    min-height: calc(100vh - 180px);
    background:
        radial-gradient(circle at top left, rgba(8, 127, 140, 0.08), transparent 24%),
        linear-gradient(180deg, rgba(255, 255, 255, 0.86), rgba(247, 250, 252, 0.94));
}

html[data-theme="dark"] .chat-sidebar,
html[data-theme="dark"] .chat-thread-shell {
    background:
        linear-gradient(180deg, rgba(21, 29, 38, 0.98), rgba(16, 23, 31, 0.98)) !important;
}

html[data-theme="dark"] .chat-sidebar::after {
    background:
        radial-gradient(circle at top left, rgba(214, 69, 83, 0.1), transparent 28%),
        radial-gradient(circle at bottom right, rgba(27, 152, 165, 0.1), transparent 28%);
}

html[data-theme="dark"] .chat-thread-shell::before {
    background:
        radial-gradient(circle at top right, rgba(27, 152, 165, 0.12), transparent 30%),
        linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent 34%);
}

html[data-theme="dark"] .chat-sidebar-stat,
html[data-theme="dark"] .chat-contact,
html[data-theme="dark"] .chat-thread-header,
html[data-theme="dark"] .chat-composer-shell,
html[data-theme="dark"] .chat-thread-actions .btn,
html[data-theme="dark"] .chat-sidebar-tools .form-control,
html[data-theme="dark"] .chat-sidebar-tools .input-group-text {
    background: rgba(21, 31, 40, 0.82) !important;
    border-color: rgba(159, 176, 194, 0.14);
    color: #e7eef6;
}

html[data-theme="dark"] .chat-contact:hover,
html[data-theme="dark"] .chat-contact.is-active {
    background: linear-gradient(135deg, rgba(27, 152, 165, 0.2), rgba(59, 157, 202, 0.16)) !important;
}

html[data-theme="dark"] .chat-sidebar-stat strong,
html[data-theme="dark"] .chat-sidebar-eyebrow,
html[data-theme="dark"] .chat-contact-type {
    color: #d7edf1;
}

html[data-theme="dark"] .chat-thread-stage::before {
    border-color: rgba(159, 176, 194, 0.12);
    background:
        radial-gradient(circle at top left, rgba(27, 152, 165, 0.12), transparent 26%),
        linear-gradient(180deg, rgba(15, 22, 29, 0.96), rgba(17, 27, 35, 0.96));
}

html[data-theme="dark"] .chat-thread-body {
    background: transparent;
}

html[data-theme="dark"] .chat-bubble.is-other {
    background: rgba(28, 39, 50, 0.95);
}

html[data-theme="dark"] .chat-bubble.is-own .chat-bubble-text,
html[data-theme="dark"] .chat-bubble.is-own .chat-bubble-text a,
html[data-theme="dark"] .chat-bubble.is-own .chat-inline-action,
html[data-theme="dark"] .chat-bubble.is-own .chat-deleted-message,
html[data-theme="dark"] .chat-bubble.is-own .chat-mention,
html[data-theme="dark"] .chat-bubble.is-own .chat-edited-label,
html[data-theme="dark"] .chat-bubble.is-own .chat-deleted-label {
    color: #f5fcff !important;
}

html[data-theme="dark"] .chat-bubble.is-own .chat-inline-action.text-danger {
    color: #ffd7dd !important;
}

html[data-theme="dark"] .chat-bubble-footer {
    border-top-color: rgba(159, 176, 194, 0.12);
}

html[data-theme="dark"] .chat-empty-state {
    background:
        radial-gradient(circle at top left, rgba(27, 152, 165, 0.12), transparent 24%),
        linear-gradient(180deg, rgba(16, 23, 31, 0.96), rgba(15, 20, 26, 0.98));
}

html[data-theme="dark"] .chat-send-button {
    box-shadow: 0 14px 28px rgba(214, 69, 83, 0.22);
}

@media (max-width: 991px) {
    .chat-layout.chat-layout-advanced {
        gap: 16px;
    }

    .chat-thread-stage {
        padding: 12px 12px 0;
    }

    .chat-thread-stage::before {
        inset: 12px 12px 0;
    }

    .chat-composer-shell {
        margin: 0 12px 12px;
    }
}

@media (max-width: 767px) {
    .chat-sidebar-summary {
        flex-direction: column;
        align-items: stretch;
    }

    .chat-contact {
        grid-template-columns: 46px minmax(0, 1fr);
        padding: 12px;
    }

    .chat-thread-name-row,
    .chat-thread-header {
        align-items: flex-start;
    }

    .chat-thread-actions {
        width: 100%;
        justify-content: flex-start;
    }

    .chat-thread-stage {
        padding: 10px 10px 0;
    }

    .chat-thread-stage::before {
        inset: 10px 10px 0;
    }

    .chat-thread-body {
        padding: 16px;
    }

    .chat-composer-shell {
        margin: 0 10px 10px;
    }
}
