﻿

:root {
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 0px;
    --topbar-height: 64px;
    --red-primary: #D32F2F;
    --red-dark: #B71C1C;
    --red-light: #FFEBEE;
    --sidebar-bg: #1F2933;
    --sidebar-hover: #2d3748;
    --sidebar-active: #D32F2F;
    --accent: #D32F2F;
    --amber: #D32F2F;
    --green: #1F7A5C;
    --border: #e2e8f0;

    --safety-amber: #D32F2F;
    --road-green: #1F7A5C;
    --chalk-white: #f8fafc;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.06);
}

.admin-body {
    background: #f4f6f9;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.admin-topbar {
    height: var(--topbar-height);
    background: #1F2933;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1100;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.topbar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
}

.topbar-logo {
    height: 36px;
    width: auto;
    max-width: 120px;
    object-fit: contain;
    flex-shrink: 0;
    border-radius: 4px;
}

.topbar-btn-text {
    display: none;
}

@media (min-width: 640px) {
    .topbar-btn-text { display: inline; }
}

.topbar-brand-name {
    color: white;
    font-weight: 700;
    font-size: 1.1rem;
    line-height: 1.1;
    display: none;
}

.topbar-brand-name span {
    color: var(--amber);
    display: block;
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

@media (min-width: 480px) {
    .topbar-brand-name { display: block; }
}

.sidebar-toggle {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 5px;
    border-radius: 8px;
    transition: background 0.2s;
}

.sidebar-toggle:hover {
    background: rgba(255,255,255,0.1);
}

.sidebar-toggle span {
    display: block;
    width: 22px;
    height: 2px;
    background: white;
    border-radius: 2px;
    transition: all 0.3s ease;
}

.sidebar-open .sidebar-toggle span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}
.sidebar-open .sidebar-toggle span:nth-child(2) {
    opacity: 0;
}
.sidebar-open .sidebar-toggle span:nth-child(3) {
    transform: rotate(-45deg) translate(5px, -5px);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: white;
    font-size: 0.9rem;
}

.topbar-user strong {
    display: none;
}

@media (min-width: 600px) {
    .topbar-user strong { display: inline; }
}

.topbar-avatar {
    width: 36px;
    height: 36px;
    background: var(--red-primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.topbar-role-badge {
    background: #5B738B;
    color: white;
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    display: none;
}

@media (min-width: 768px) {
    .topbar-role-badge { display: inline-block; }
}

.topbar-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 1rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    text-decoration: none;
    transition: all 0.2s;
    white-space: nowrap;
}

.topbar-btn-outline {
    background: transparent;
    border: 1.5px solid rgba(255,255,255,0.3);
    color: white;
}

.topbar-btn-outline:hover {
    background: rgba(255,255,255,0.1);
    color: white;
}

.topbar-btn-red {
    background: var(--red-primary);
    color: white;
}

.topbar-btn-red:hover {
    background: var(--red-dark);
    color: white;
}

.topbar-btn img {
    width: 14px;
    height: 14px;
    filter: brightness(0) invert(1);
}

.profile-switch-bar {
    background: #ff6b6b;
    padding: 0.5rem 1.5rem;
    text-align: center;
    font-size: 0.85rem;
    color: white;
    position: fixed;
    top: var(--topbar-height);
    left: 0;
    right: 0;
    z-index: 1090;
}

.profile-switch-bar a {
    color: white;
    font-weight: 700;
    text-decoration: underline;
    margin-left: 1rem;
}

.admin-sidebar {
    position: fixed;
    top: var(--topbar-height);
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: #1F2933;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 1080;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
}

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

@media (min-width: 1024px) {
    .admin-sidebar {
        transform: translateX(0);
    }
    .admin-sidebar.collapsed {
        transform: translateX(-100%);
    }
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1070;
}

.sidebar-overlay.active {
    display: block;
}

@media (min-width: 1024px) {
    .sidebar-overlay { display: none !important; }
}

.admin-sidebar::-webkit-scrollbar {
    width: 4px;
}
.admin-sidebar::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.1);
    border-radius: 2px;
}

.sidebar-nav {
    padding: 1rem 0;
    flex: 1;
}

.sidebar-section-label {
    color: rgba(255,255,255,0.35);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    padding: 1.25rem 1.25rem 0.5rem;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.75rem 1.25rem;
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    font-size: 0.92rem;
    font-weight: 500;
    transition: all 0.2s;
    border-left: 3px solid transparent;
    position: relative;
}

.sidebar-nav a:hover {
    color: white;
    background: rgba(255,255,255,0.06);
    border-left-color: rgba(255,255,255,0.3);
}

.sidebar-nav a.active {
    color: white;
    background: rgba(211,47,47,0.2);
    border-left-color: var(--red-primary);
}

.sidebar-nav a img {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    opacity: 0.7;
    filter: brightness(0) invert(1);
    transition: opacity 0.2s;
}

.sidebar-nav a:hover img,
.sidebar-nav a.active img {
    opacity: 1;
}

.sidebar-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--red-primary);
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    padding: 0 0.4rem;
    margin-left: auto;
}

.sidebar-divider {
    height: 1px;
    background: rgba(255,255,255,0.08);
    margin: 0.75rem 1.25rem;
}

.sidebar-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid rgba(255,255,255,0.08);
}

.sidebar-footer a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: rgba(255,255,255,0.5);
    font-size: 0.85rem;
    text-decoration: none;
    padding: 0.5rem 0;
    transition: color 0.2s;
}

.sidebar-footer a:hover {
    color: white;
}

.sidebar-footer a img {
    width: 16px;
    height: 16px;
    filter: brightness(0) invert(1);
    opacity: 0.5;
}

.admin-main {
    margin-top: var(--topbar-height);
    padding: 2rem;
    min-height: calc(100vh - var(--topbar-height));
    transition: margin-left 0.3s ease;
}

@media (min-width: 1024px) {
    .admin-main {
        margin-left: var(--sidebar-width);
    }
    .admin-main.sidebar-collapsed {
        margin-left: 0;
    }
}

.admin-container {
    max-width: 1400px;
    margin: 0 auto;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 2rem;
    gap: 1rem;
    flex-wrap: wrap;
}

.page-header h1 {
    margin: 0 0 0.25rem;
    font-size: clamp(1.3rem, 3vw, 1.75rem);
    color: #1F2933;
}

.page-header .page-subtitle {
    color: #718096;
    font-size: 0.9rem;
    margin: 0;
}

.page-header-actions {
    display: flex;
    gap: 0.75rem;
    flex-shrink: 0;
    flex-wrap: wrap;
}

.visitor-banner {
    background: linear-gradient(135deg, #1F2933 0%, #2d3748 100%);
    padding: 2rem;
    border-radius: 16px;
    margin-bottom: 2rem;
    color: white;
    box-shadow: 0 4px 16px rgba(31,41,51,0.2);
}

.visitor-banner h2 {
    color: white;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.1rem;
}

.visitor-banner h2 img {
    width: 22px;
    height: 22px;
    filter: brightness(0) invert(1);
}

.visitor-stat-box {
    background: rgba(255,255,255,0.1);
    padding: 1.25rem;
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.15);
    transition: all 0.3s ease;
}

.visitor-stat-box:hover {
    background: rgba(255,255,255,0.15);
    transform: translateY(-2px);
}

.visitor-stat-box .stat-label {
    font-size: 0.8rem;
    margin-bottom: 0.5rem;
    color: rgba(255,255,255,0.7);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.visitor-stat-box .stat-value {
    font-size: 2rem;
    font-weight: 800;
    color: var(--amber);
}

.visitor-banner p {
    margin-top: 1rem;
    color: rgba(255,255,255,0.8);
    font-size: 0.9rem;
    margin-bottom: 0;
}

.visitor-banner p img {
    width: 16px;
    height: 16px;
    filter: brightness(0) invert(1);
    vertical-align: middle;
    margin-right: 0.25rem;
}

.weekly-chart {
    background: white;
    border-radius: 16px;
    padding: 1.75rem;
    margin-bottom: 2rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    border: 1px solid var(--border);
    min-width: 0;
    overflow: hidden;
}

.weekly-chart h3 {
    color: #1F2933;
    margin-bottom: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1rem;
}

.weekly-chart table {
    width: 100%;
    border-collapse: collapse;
}

.weekly-chart th {
    background: #F9FAFB;
    padding: 0.875rem 1rem;
    text-align: left;
    font-weight: 600;
    color: #1F2933;
    font-size: 0.875rem;
    border-bottom: 2px solid var(--border);
}

.weekly-chart td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.875rem;
    color: #4a5568;
}

.weekly-chart tbody tr:hover { background: #F9FAFB; }

.trend-up { color: #10B981; font-weight: 700; }
.trend-down { color: #DC2626; font-weight: 700; }

.admin-stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.25rem;
    margin-bottom: 2rem;
}

@media (min-width: 768px) {
    .admin-stats-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

.admin-stat-card {
    background: white;
    padding: 1.5rem;
    border-radius: 16px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    display: flex;
    align-items: center;
    gap: 1.25rem;
    transition: all 0.3s ease;
    border: 1px solid var(--border);
}

.admin-stat-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.1);
    border-color: var(--amber);
}

.admin-stat-card .stat-icon {
    width: 54px;
    height: 54px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.admin-stat-card .stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: #1F2933;
    line-height: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.admin-stat-card > div:not(.stat-icon) {
    min-width: 0;
    overflow: hidden;
}

.admin-stat-card .stat-label {
    font-size: 0.8rem;
    color: #718096;
    font-weight: 500;
    margin-top: 0.25rem;
}

.admin-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
}

@media (min-width: 900px) {
    .admin-grid {
        grid-template-columns: 1fr 1fr;
    }
}

.admin-grid > * {
    min-width: 0;
}

.admin-card {
    background: white;
    border-radius: 16px;
    padding: 1.75rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    border: 1px solid var(--border);
}

.admin-card h3 {
    margin-bottom: 1.25rem;
    color: #1F2933;
    font-size: 1.05rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.admin-card h3 img {
    width: 18px;
    height: 18px;
}

.admin-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.admin-card-header h3 {
    margin: 0;
}

.admin-table-wrapper {
    overflow-x: auto;
    border-radius: 8px;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 500px;
}

.admin-table thead {
    background: #F9FAFB;
}

.admin-table th {
    padding: 0.875rem 1rem;
    text-align: left;
    font-weight: 600;
    color: #1F2933;
    font-size: 0.85rem;
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}

.admin-table td {
    padding: 0.875rem 1rem;
    border-bottom: 1px solid var(--border);
    color: #4a5568;
    font-size: 0.9rem;
}

.admin-table tbody tr {
    transition: background 0.2s;
}

.admin-table tbody tr:hover {
    background: #F9FAFB;
}

.admin-table tbody tr:last-child td {
    border-bottom: none;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.75rem 1.5rem;
    font-size: 0.925rem;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 2px solid transparent;
    text-decoration: none;
    white-space: nowrap;
    line-height: 1;
}

.btn img, .btn svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.btn-primary {
    background: var(--red-primary);
    color: white;
    border-color: var(--red-primary);
}

.btn-primary:hover {
    background: var(--red-dark);
    border-color: var(--red-dark);
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(211,47,47,0.35);
}

.btn-amber {
    background: white;
    color: var(--red-primary);
    border-color: var(--red-primary);
}

.btn-amber:hover {
    background: var(--red-primary);
    border-color: var(--red-primary);
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(211, 47, 47, 0.25);
}

.btn-secondary {
    background: white;
    color: #1F2933;
    border-color: var(--border);
}

.btn-secondary:hover {
    background: #F9FAFB;
    border-color: #c6d0e0;
    color: #1F2933;
}

.btn-success {
    background: var(--green);
    color: white;
    border-color: var(--green);
}

.btn-success:hover {
    background: #186348;
    color: white;
    transform: translateY(-1px);
}

.btn-sm {
    padding: 0.4rem 0.875rem;
    font-size: 0.8rem;
    border-radius: 6px;
}

.btn-sm img { width: 14px; height: 14px; }

.btn-danger {
    background: #dc3545;
    color: white;
    border-color: #dc3545;
}

.btn-danger:hover {
    background: #c82333;
    border-color: #bd2130;
    color: white;
}

.btn-icon {
    padding: 0.4rem;
    border-radius: 6px;
    width: 34px;
    height: 34px;
}

.badge {
    display: inline-block;
    padding: 0.25rem 0.7rem;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 600;
    white-space: nowrap;
    line-height: 1.4;
}

.badge-success { background: #d4edda; color: #155724; }
.badge-warning { background: #fff3cd; color: #856404; }
.badge-danger  { background: #f8d7da; color: #721c24; }
.badge-info    { background: #d1ecf1; color: #0c5460; }
.badge-muted   { background: #e2e8f0; color: #4a5568; }
.badge-red     { background: var(--red-light); color: var(--red-dark); }
.badge-amber   { background: #FFEBEE; color: #795548; }

.badge:not([class*="badge-"]) {
    background: #FFEBEE;
    color: #795548;
}

.admin-form-group {
    margin-bottom: 1.25rem;
}

.admin-form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    font-size: 0.875rem;
    color: #374151;
}

.admin-form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 0.925rem;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: white;
    color: #1F2933;
}

.admin-form-control:focus {
    outline: none;
    border-color: var(--red-primary);
    box-shadow: 0 0 0 3px rgba(211,47,47,0.1);
}

.admin-form-control:disabled,
.admin-form-control[readonly] {
    background: #F9FAFB;
    color: #718096;
}

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

.admin-form-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

@media (min-width: 600px) {
    .admin-form-grid-2 { grid-template-columns: 1fr 1fr; }
    .admin-form-grid-3 { grid-template-columns: 1fr 1fr 1fr; }
}

.form-hint {
    font-size: 0.8rem;
    color: #718096;
    margin-top: 0.25rem;
}

.admin-checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.9rem;
    color: #1F2933;
}

.admin-checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--red-primary);
}

.form-section {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.form-section-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--red-primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 1.25rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--red-light);
}

.alert {
    padding: 1rem 1.25rem;
    border-radius: 10px;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    font-size: 0.925rem;
    line-height: 1.5;
}

.alert-success {
    background: #d4edda;
    border: 1px solid #c3e6cb;
    color: #155724;
}

.alert-error, .alert-danger {
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
}

.alert-warning {
    background: #fff3cd;
    border: 1px solid #ffeeba;
    color: #856404;
}

.alert-info {
    background: #d1ecf1;
    border: 1px solid #bee5eb;
    color: #0c5460;
}

.filters {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    align-items: center;
}

.filters select,
.filters input[type="text"],
.filters input[type="search"] {
    padding: 0.6rem 0.875rem;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 0.875rem;
    background: white;
    color: #1F2933;
    transition: border-color 0.2s;
}

.filters select:focus,
.filters input:focus {
    outline: none;
    border-color: var(--red-primary);
}

.search-bar {
    margin-bottom: 1.25rem;
    width: 90%;
}

.search-bar input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 0.925rem;
    transition: border-color 0.2s;
}

.search-bar input:focus {
    outline: none;
    border-color: var(--red-primary);
    box-shadow: 0 0 0 3px rgba(211,47,47,0.1);
}

.status-online {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #28a745;
    box-shadow: 0 0 0 2px rgba(40,167,69,0.25);
}

.status-offline {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #dc3545;
    box-shadow: 0 0 0 2px rgba(220,53,69,0.25);
}

.nav-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--red-primary);
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 0.15rem 0.4rem;
    border-radius: 10px;
    min-width: 18px;
    height: 18px;
}

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: #718096;
}

.empty-state img {
    width: 64px;
    height: 64px;
    opacity: 0.3;
    margin-bottom: 1rem;
}

.empty-state p {
    font-size: 1rem;
    margin: 0;
}

.icon-sm { width: 16px; height: 16px; }
.icon-md { width: 20px; height: 20px; }
.icon-lg { width: 28px; height: 28px; }
.icon-stat { width: 26px; height: 26px; filter: brightness(0) invert(1); }

@media (max-width: 640px) {
    .admin-table-wrapper.card-on-mobile .admin-table { min-width: unset; }
    .admin-table-wrapper.card-on-mobile .admin-table thead { display: none; }
    .admin-table-wrapper.card-on-mobile .admin-table,
    .admin-table-wrapper.card-on-mobile .admin-table tbody,
    .admin-table-wrapper.card-on-mobile .admin-table tr,
    .admin-table-wrapper.card-on-mobile .admin-table td {
        display: block; width: 100%;
    }
    .admin-table-wrapper.card-on-mobile .admin-table tr {
        background: white;
        border-radius: 10px;
        margin-bottom: 1rem;
        padding: 1rem;
        box-shadow: 0 2px 6px rgba(0,0,0,0.06);
        border: 1px solid var(--border);
    }
    .admin-table-wrapper.card-on-mobile .admin-table td {
        padding: 0.4rem 0;
        border: none;
        position: relative;
        padding-left: 45%;
        font-size: 0.875rem;
    }
    .admin-table-wrapper.card-on-mobile .admin-table td:before {
        content: attr(data-label);
        position: absolute;
        left: 0;
        width: 40%;
        font-weight: 600;
        color: #718096;
        font-size: 0.8rem;
    }
    .admin-table-wrapper.card-on-mobile .admin-table td:first-child {
        padding-left: 0;
        padding-bottom: 0.5rem;
        margin-bottom: 0.5rem;
        border-bottom: 1px solid var(--border);
        font-weight: 700;
    }
    .admin-table-wrapper.card-on-mobile .admin-table td:first-child:before { display: none; }
}

.text-muted { color: #718096; }
.text-success { color: #155724; }
.text-danger { color: #721c24; }
.text-amber { color: #795548; }
.fw-bold { font-weight: 700; }

code {
    background: #F3F4F6;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-size: 0.85em;
    color: #4a5568;
}

.admin-back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    color: #718096;
    text-decoration: none;
    font-size: 0.875rem;
    margin-bottom: 1.25rem;
    transition: color 0.2s;
}

.admin-back-link:hover { color: var(--red-primary); }
.admin-back-link img { width: 14px; height: 14px; }

.admin-header, .admin-nav { display: none !important; }

body.has-profile-switch .admin-sidebar,
body.has-profile-switch .admin-main {
    top: calc(var(--topbar-height) + 38px);
    margin-top: calc(var(--topbar-height) + 38px);
}

.visitor-banner {
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    padding: 2rem;
    border-radius: 20px;
    margin-bottom: 2rem;
    color: #1F2933;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
    border: 2px solid #e2e8f0;
}

.visitor-banner h2 {
    color: #1F2933;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.visitor-banner h2 img {
    width: 28px;
    height: 28px;
}

.visitor-stat-box {
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
    padding: 1.5rem;
    border-radius: 15px;
    border: 2px solid #e2e8f0;
    transition: all 0.3s ease;
}

.visitor-stat-box:hover {
    border-color: #D32F2F;
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(211, 47, 47, 0.15);
}

.visitor-stat-box .stat-label {
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
    color: #718096;
}

.visitor-stat-box .stat-value {
    font-size: 2.5rem;
    font-weight: 800;
    color: #D32F2F;
    text-shadow: none;
}

.visitor-banner p {
    margin-top: 1rem;
    color: #4a5568;
    font-size: 0.95rem;
}

.visitor-banner p img {
    width: 20px;
    height: 20px;
}

.weekly-chart {
    background: white;
    border-radius: 15px;
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    border: 1px solid #e2e8f0;
    min-width: 0;
    overflow: hidden;
}

.weekly-chart h3 {
    color: #1F2933;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.weekly-chart table {
    width: 100%;
    border-collapse: collapse;
}

.weekly-chart th {
    background: #F9FAFB;
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    color: #1F2933;
    border-bottom: 2px solid #e2e8f0;
}

.weekly-chart td {
    padding: 0.875rem 1rem;
    border-bottom: 1px solid #e2e8f0;
}

.weekly-chart tbody tr:hover {
    background: #F9FAFB;
}

.trend-up {
    color: #10B981;
    font-weight: 700;
}

.trend-down {
    color: #DC2626;
    font-weight: 700;
}

.admin-header {
    background: #1F2933;
    padding: 1.5rem 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.admin-header.hidden {
    transform: none !important;
}

.admin-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 2rem;
}

.admin-header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.admin-title {
    margin: 0;
    color: #D32F2F;
    font-size: 1.5rem;
}

.admin-header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.admin-welcome {
    color: white;
}

.admin-role-badge {
    margin-left: 0.5rem;
    padding: 0.3rem 0.8rem;
    background: #5B738B;
    border-radius: 15px;
    font-size: 0.85rem;
}

.admin-mobile-toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    z-index: 1002;
    width: 45px;
    height: 45px;
}

.admin-mobile-toggle span {
    display: block;
    width: 30px;
    height: 3px;
    background: var(--chalk-white);
    transition: all 0.3s ease;
    border-radius: 3px;
}

.admin-mobile-toggle.active span:nth-child(1) {
    transform: rotate(45deg) translate(9px, 9px);
}

.admin-mobile-toggle.active span:nth-child(2) {
    opacity: 0;
    transform: translateX(-20px);
}

.admin-mobile-toggle.active span:nth-child(3) {
    transform: rotate(-45deg) translate(9px, -9px);
}

.admin-nav {
    background: white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    position: sticky;
    top: 0;
    z-index: 998;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: #D32F2F #f1f1f1;
    scroll-behavior: smooth;
}

.admin-nav::-webkit-scrollbar {
    height: 4px;
}

.admin-nav::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.admin-nav::-webkit-scrollbar-thumb {
    background: #D32F2F;
    border-radius: 2px;
}

.admin-nav ul {
    list-style: none;
    display: flex;
    flex-direction: row;
    gap: 0;
    margin: 0;
    padding: 0 1rem;
    white-space: nowrap;
    min-width: min-content;
}

.admin-nav li {
    display: inline-block;
    flex-shrink: 0;
}

.admin-nav a {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem 1.25rem;
    color: #1F2933;
    font-weight: 500;
    transition: all 0.3s ease;
    border-bottom: 3px solid transparent;
    text-decoration: none;
    font-size: 0.95rem;
    white-space: nowrap;
}

.admin-nav a:hover {
    background: #F9FAFB;
    color: #D32F2F;
}

.admin-nav a:hover img {
    filter: brightness(0) saturate(100%) invert(79%) sepia(68%) saturate(1543%) hue-rotate(1deg) brightness(101%) contrast(95%);
}

.admin-nav a.active {
    color: #D32F2F;
    border-bottom-color: #D32F2F;
    background: #F9FAFB;
}

.admin-nav a.active img {
    filter: brightness(0) saturate(100%) invert(79%) sepia(68%) saturate(1543%) hue-rotate(1deg) brightness(101%) contrast(95%);
}

.nav-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #ff4444;
    color: white;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.2rem 0.45rem;
    border-radius: 10px;
    min-width: 18px;
    height: 18px;
}

.admin-nav img {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    transition: filter 0.3s ease;
}

.admin-stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.admin-stat-card {
    background: white;
    padding: 1.5rem;
    border-radius: 15px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    display: flex;
    align-items: center;
    gap: 1.5rem;
    transition: all 0.3s ease;
    border: 1px solid #e2e8f0;
}

.admin-stat-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);
    border-color: #D32F2F;
}

.admin-stat-card .stat-icon {
    width: 60px;
    height: 60px;
    border-radius: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    flex-shrink: 0;
}

.admin-stat-card .stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: #1F2933;
}

.admin-stat-card .stat-label {
    font-size: 0.9rem;
    color: #718096;
    font-weight: 500;
}

.admin-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

.admin-grid > * {
    min-width: 0;
}

.admin-card {
    background: white;
    border-radius: 15px;
    padding: 2rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    border: 1px solid #e2e8f0;
}

.admin-card h3 {
    margin-bottom: 1.5rem;
    color: #1F2933;
    font-size: 1.3rem;
}

.admin-table-wrapper {
    overflow-x: auto;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
}

.admin-table thead {
    background: #F9FAFB;
}

.admin-table th {
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    color: #1F2933;
    border-bottom: 2px solid #e2e8f0;
}

.admin-table td {
    padding: 1rem;
    border-bottom: 1px solid #e2e8f0;
    color: #4a5568;
}

.admin-table tbody tr {
    transition: background 0.3s ease;
}

.admin-table tbody tr:hover {
    background: #F9FAFB;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.875rem 1.75rem;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid transparent;
    text-decoration: none;
    box-sizing: border-box;
    max-width: 100%;
}

.btn img,
.btn svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.btn-primary {
    background: #D32F2F;
    color: #1F2933;
    border-color: #D32F2F;
    box-shadow: 0 4px 12px rgba(211, 47, 47, 0.3);
}

.btn-primary:hover {
    background: #EF5350;
    color: #1F2933;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(211, 47, 47, 0.4);
}

.btn-secondary {
    background: white;
    color: #1F2933;
    border-color: #e2e8f0;
}

.btn-secondary:hover {
    background: #F9FAFB;
    border-color: #D32F2F;
    color: #D32F2F;
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

.btn-danger {
    background: #dc3545;
    color: white;
    border-color: #dc3545;
}

.btn-danger:hover {
    background: #c82333;
    border-color: #bd2130;
}

.badge {
    display: inline-block;
    padding: 0.3rem 0.8rem;
    border-radius: 15px;
    font-size: 0.85rem;
    font-weight: 600;
    background: #D32F2F;
    color: #1F2933;
    white-space: nowrap;
}

.filters {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.filter-btn {
    padding: 0.7rem 1.5rem;
    background: white;
    border: 2px solid #e2e8f0;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
    text-decoration: none;
    display: inline-block;
    color: #1F2933;
}

.filter-btn:hover {
    border-color: #D32F2F;
    background: #FFEBEE;
    color: #D32F2F;
}

.filter-btn.active {
    background: #D32F2F;
    border-color: #D32F2F;
    color: white;
    box-shadow: 0 2px 8px rgba(211,47,47,0.3);
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-group label,
.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: #1F2933;
    font-size: 0.95rem;
}

.form-hint {
    display: block;
    font-size: 0.8rem;
    color: #718096;
    margin-top: 0.3rem;
}

.form-control,
.admin-form-control {
    width: 90%;
    padding: 0.875rem 1rem;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    font-size: 1rem;
    transition: all 0.3s ease;
    background: white;
    font-family: inherit;
    color: #1F2933;
    line-height: 1.5;
}

.form-control:focus,
.admin-form-control:focus {
    outline: none;
    border-color: #D32F2F;
    box-shadow: 0 0 0 3px rgba(211, 47, 47, 0.1);
    background: #FFFEF8;
}

.form-control::placeholder,
.admin-form-control::placeholder {
    color: #a0aec0;
}

textarea.form-control,
textarea.admin-form-control {
    min-height: 120px;
    resize: vertical;
}

.stars {
    display: inline-flex !important;
    flex-direction: row !important;
    gap: 0.25rem;
    align-items: center;
    flex-wrap: nowrap !important;
}

.stars img,
.stars svg {
    width: 1.25rem !important;
    height: 1.25rem !important;
    flex-shrink: 0;
    display: inline-block !important;
}

.rating {
    display: flex !important;
    align-items: center;
    gap: 0.75rem;
    margin: 0.75rem 0;
    flex-wrap: wrap;
}

@media (max-width: 850px) {

    .admin-container {
        padding: 0 1rem;
    }

    .admin-mobile-toggle {
        display: flex;
    }

    .admin-header {
        padding: 1rem 0;
        position: sticky;
        top: 0;
        transform: none !important;
    }

    .admin-header.hidden {
        display: block !important;
        transform: none !important;
    }

    .admin-header-content {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }

    .admin-title {
        font-size: 1.2rem;
    }

    .admin-header-right {
        position: fixed;
        top: 0;
        right: -100%;
        width: 85%;
        max-width: 320px;
        height: 100vh;
        background: var(--deep-charcoal);
        flex-direction: column;
        align-items: stretch;
        padding: 5rem 1.5rem 2rem;
        gap: 1rem;
        box-shadow: -5px 0 15px rgba(0, 0, 0, 0.3);
        transition: right 0.3s ease;
        z-index: 1001;
        overflow-y: auto;
    }

    .admin-header-right.active {
        right: 0;
    }

    .admin-welcome {
        display: block;
        padding: 1rem;
        background: rgba(255, 255, 255, 0.1);
        border-radius: 8px;
        text-align: center;
    }

    .admin-role-badge {
        display: block;
        margin: 0.5rem auto 0;
        width: fit-content;
    }

    .admin-header-right .btn {
        width: 100%;
        text-align: center;
    }

    .admin-nav {
        position: sticky;
        top: 0;
        overflow-x: scroll;
        overflow-y: hidden;
    }

    .admin-nav ul {
        flex-direction: row;
        padding: 0 0.5rem;
    }

    .admin-nav a {
        padding: 0.875rem 1rem;
        font-size: 0.9rem;
    }

    .admin-nav img {
        width: 16px;
        height: 16px;
    }

    .admin-stats-grid,
    .stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 1rem;
    }

    .admin-stat-card {
        padding: 1rem;
        flex-direction: column;
        text-align: center;
        gap: 0.75rem;
        min-height: 130px;
    }

    .admin-stat-card .stat-icon {
        width: 48px;
        height: 48px;
        font-size: 1.5rem;
        margin: 0 auto;
    }

    .admin-stat-card .stat-value {
        font-size: 1.75rem;
    }

    .admin-stat-card .stat-label {
        font-size: 0.85rem;
    }

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

    .content-grid {
        grid-template-columns: 1fr !important;
    }

    .admin-card {
        padding: 1rem;
    }

    .admin-table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 0 -1rem;
        padding: 0 1rem;
    }

    .admin-table {
        min-width: 100%;
        font-size: 0.85rem;
    }

    .admin-table th,
    .admin-table td {
        padding: 0.75rem 0.5rem;
        white-space: nowrap;
    }

    .admin-table td:last-child,
    .admin-table th:last-child {
        position: sticky;
        right: 0;
        background: white;
        box-shadow: -2px 0 4px rgba(0,0,0,0.05);
        z-index: 10;
    }

    .admin-table a[href*="edit"].btn-sm,
    .admin-table a[href*="delete"].btn-sm,
    .admin-table a[onclick*="delete"].btn-sm,
    .admin-table form[action*="delete"] button.btn-sm,
    .admin-table .btn-danger.btn-sm {
        font-size: 0 !important;
        width: 38px !important;
        height: 38px !important;
        padding: 0 !important;
        border-radius: 8px;
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
        gap: 0;
    }

    .admin-table a[href*="edit"].btn-sm img,
    .admin-table a[href*="delete"].btn-sm img,
    .admin-table .btn-danger.btn-sm img,
    .admin-table a[href*="edit"].btn-sm svg,
    .admin-table a[href*="delete"].btn-sm svg,
    .admin-table .btn-danger.btn-sm svg {
        width: 18px !important;
        height: 18px !important;
        display: block !important;
        margin: 0 !important;
        opacity: 1 !important;
        visibility: visible !important;
    }

    .admin-table .btn-sm:not([href*="edit"]):not([href*="delete"]):not([onclick*="delete"]):not(.btn-danger) {
        width: auto !important;
        height: auto !important;
        padding: 0.5rem 0.75rem !important;
        font-size: 0.8rem !important;
    }

    .admin-table td:last-child > div,
    .admin-table td:last-child > form {
        display: inline-flex !important;
        gap: 0.4rem;
        flex-wrap: nowrap !important;
        align-items: center;
    }

    .filters {
        flex-wrap: nowrap;
        overflow-x: auto;
        gap: 0.5rem;
        padding-bottom: 0.5rem;
        -webkit-overflow-scrolling: touch;
    }

    .filter-btn {
        white-space: nowrap;
        flex-shrink: 0;
        padding: 0.6rem 1.25rem;
        font-size: 0.9rem;
    }

    .form-control,
    .admin-form-control {
        font-size: 16px !important;
        padding: 1rem;
        width: 90%;
        border-radius: 10px;
    }

    .visitor-banner {
        padding: 1.25rem;
    }

    .visitor-banner > div {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 1rem;
    }

    .visitor-stat-box {
        padding: 1rem;
    }

    .visitor-stat-box .stat-value {
        font-size: 1.75rem;
    }

    .weekly-chart {
        padding: 1.25rem;
        overflow-x: auto;
    }

    .weekly-chart table {
        font-size: 0.85rem;
    }

    .weekly-chart th,
    .weekly-chart td {
        padding: 0.75rem 0.5rem;
    }

    .stars img,
    .stars svg {
        width: 16px !important;
        height: 16px !important;
    }

    .rating {
        flex-direction: row;
        gap: 0.5rem;
    }

    .badge {
        padding: 0.25rem 0.6rem;
        font-size: 0.75rem;
    }
}

@media (max-width: 480px) {
    .admin-stats-grid,
    .stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    .visitor-banner {
        padding: 1rem;
    }

    .visitor-banner > div {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    .visitor-stat-box .stat-value {
        font-size: 1.5rem;
    }

}
.inbox-container {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 2rem;
    min-height: 600px;
}

.inbox-sidebar {
    background: white;
    border-radius: 15px;
    padding: 1.5rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    border: 1px solid #e2e8f0;
}

.inbox-filters {
    margin-bottom: 1.5rem;
}

.filter-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.filter-tab {
    flex: 1;
    padding: 0.75rem 1rem;
    background: #F9FAFB;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    color: #4a5568;
    text-align: center;
}

.filter-tab:hover {
    background: #FFEBEE;
    border-color: #D32F2F;
    color: #1F2933;
}

.filter-tab.active {
    background: linear-gradient(135deg, #D32F2F 0%, #EF5350 100%);
    border-color: #D32F2F;
    color: #1F2933;
    box-shadow: 0 4px 12px rgba(211, 47, 47, 0.3);
}

.inbox-search {
    width: 100%;
    padding: 0.875rem 1rem;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    font-size: 0.95rem;
    transition: all 0.3s ease;
    background: white;
}

.inbox-search:focus {
    outline: none;
    border-color: #D32F2F;
    box-shadow: 0 0 0 3px rgba(211, 47, 47, 0.1);
    background: #FFFEF8;
}

.message-list {
    max-height: 600px;
    overflow-y: auto;
    margin-top: 1rem;
}

.message-list::-webkit-scrollbar {
    width: 6px;
}

.message-list::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.message-list::-webkit-scrollbar-thumb {
    background: #D32F2F;
    border-radius: 10px;
}

.message-item {
    padding: 1rem;
    border-bottom: 1px solid #e2e8f0;
    cursor: pointer;
    transition: all 0.3s ease;
    border-left: 3px solid transparent;
}

.message-item:hover {
    background: #F9FAFB;
    border-left-color: #D32F2F;
    transform: translateX(3px);
}

.message-item.active {
    background: #FFEBEE;
    border-left-color: #D32F2F;
    box-shadow: inset 0 0 0 1px rgba(211, 47, 47, 0.2);
}

.message-item.unread {
    background: #F9FAFB;
    font-weight: 600;
    border-left-color: #17a2b8;
}

.message-item .from {
    font-weight: 600;
    color: #1F2933;
    margin-bottom: 0.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.message-item .subject {
    font-size: 0.9rem;
    color: #4a5568;
    margin-bottom: 0.25rem;
    font-weight: 500;
}

.message-item .preview {
    font-size: 0.85rem;
    color: #718096;
    margin-bottom: 0.25rem;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.message-item .time {
    font-size: 0.75rem;
    color: #a0aec0;
    margin-top: 0.5rem;
}

.message-viewer {
    background: white;
    border-radius: 15px;
    padding: 2rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    border: 1px solid #e2e8f0;
    min-height: 600px;
    display: flex;
    flex-direction: column;
}

.empty-state {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #a0aec0;
    font-size: 1.1rem;
    flex-direction: column;
    gap: 1rem;
}

.empty-state::before {
    content: '📧';
    font-size: 4rem;
    opacity: 0.5;
}

.message-header {
    border-bottom: 2px solid #e2e8f0;
    padding-bottom: 1.5rem;
    margin-bottom: 2rem;
}

.message-header h2 {
    color: #1F2933;
    margin-bottom: 1rem;
    font-size: 1.5rem;
}

.message-meta {
    display: flex;
    gap: 2rem;
    padding: 1rem 1.5rem;
    background: linear-gradient(135deg, #F9FAFB 0%, #ffffff 100%);
    border-radius: 10px;
    margin-bottom: 2rem;
    font-size: 0.9rem;
    color: #4a5568;
    border: 1px solid #e2e8f0;
}

.message-meta span {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.message-meta span::before {
    content: '👤';
    font-size: 1rem;
}

.message-meta span:last-child::before {
    content: '✉️';
}

.message-thread {
    margin-bottom: 2rem;
    flex: 1;
    overflow-y: auto;
}

.thread-message {
    padding: 1.5rem;
    border-radius: 10px;
    margin-bottom: 1rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
}

.thread-message:hover {
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.thread-message.incoming {
    background: linear-gradient(135deg, #F9FAFB 0%, #ffffff 100%);
    border-left: 3px solid #D32F2F;
}

.thread-message.outgoing {
    background: linear-gradient(135deg, #E8F5E9 0%, #ffffff 100%);
    border-left: 3px solid #1F7A5C;
}

.message-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    font-size: 0.9rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.message-info strong {
    color: #1F2933;
    font-weight: 600;
}

.message-info span {
    color: #718096;
    font-size: 0.85rem;
}

.message-body {
    color: #4a5568;
    line-height: 1.6;
    font-size: 0.95rem;
}

.reply-form {
    border-top: 2px solid #e2e8f0;
    padding-top: 2rem;
    margin-top: auto;
}

.reply-form textarea {
    width: 100%;
    min-height: 120px;
    padding: 1rem;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    margin-bottom: 1rem;
    font-family: inherit;
    font-size: 0.95rem;
    transition: all 0.3s ease;
    resize: vertical;
}

.reply-form textarea:focus {
    outline: none;
    border-color: #D32F2F;
    box-shadow: 0 0 0 3px rgba(211, 47, 47, 0.1);
    background: #FFFEF8;
}

.reply-form textarea::placeholder {
    color: #a0aec0;
}

.reply-form .btn {
    width: auto;
    padding: 0.875rem 2rem;
}

.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.25rem 0.6rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 700;
    background: #ff4444;
    color: white;
    min-width: 20px;
    height: 20px;
}

@media (max-width: 850px) {
    .inbox-container {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .inbox-sidebar {
        padding: 1rem;
    }

    .filter-tabs {
        flex-direction: column;
        gap: 0.5rem;
    }

    .filter-tab {
        width: 100%;
    }

    .message-list {
        max-height: 400px;
    }

    .message-viewer {
        padding: 1rem;
        min-height: auto;
    }

    .message-header h2 {
        font-size: 1.25rem;
    }

    .message-meta {
        flex-direction: column;
        gap: 0.5rem;
        padding: 1rem;
    }

    .thread-message {
        padding: 1rem;
    }

    .message-info {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.25rem;
    }

    .reply-form {
        padding-top: 1.5rem;
    }

    .reply-form textarea {
        font-size: 16px !important;
        min-height: 100px;
    }

    .reply-form .btn {
        width: 100%;
    }
}

@media (max-width: 640px) {
    .inbox-search {
        font-size: 16px !important;
    }

    .message-item {
        padding: 0.875rem;
    }

    .message-header h2 {
        font-size: 1.1rem;
    }

    .thread-message {
        padding: 0.875rem;
    }
}
.profile-grid {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 2rem;
}

.profile-card {
    background: white;
    border-radius: 15px;
    padding: 2rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    border: 1px solid #e2e8f0;
}

.profile-avatar {
    width: 120px;
    height: 120px;
    background: linear-gradient(135deg, #D32F2F, #1F7A5C);
    border-radius: 50%;
    margin: 0 auto 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 3rem;
    font-weight: 700;
    box-shadow: 0 4px 12px rgba(211, 47, 47, 0.3);
}

.profile-name {
    text-align: center;
    margin-bottom: 1rem;
    font-size: 1.5rem;
    color: #1F2933;
}

.profile-role-badge {
    background: #5B738B;
    color: white;
    padding: 0.5rem 1rem;
    font-size: 1rem;
    border-radius: 25px;
    display: inline-block;
}

.profile-info-item {
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #e2e8f0;
}

.profile-info-item:last-child {
    border-bottom: none;
}

.profile-info-label {
    font-weight: 600;
    color: #718096;
    margin-bottom: 0.25rem;
    font-size: 0.9rem;
}

.profile-info-value {
    color: #2d3748;
    font-size: 1rem;
}

.profile-stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
}

.profile-stat-card {
    text-align: center;
    padding: 1.5rem;
    background: #f7fafc;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
}

.profile-stat-value {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.profile-stat-label {
    color: #718096;
    font-size: 0.9rem;
}

.profile-activity-item {
    padding: 1rem;
    background: #f7fafc;
    border-radius: 10px;
    border-left: 4px solid #1F7A5C;
    margin-bottom: 1rem;
}

.profile-activity-title {
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: #1F2933;
}

.profile-activity-desc {
    color: #718096;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.profile-activity-time {
    font-size: 0.85rem;
    color: #a0aec0;
}

.profile-edit-form {
    max-width: 800px;
    margin: 0 auto;
}

.profile-form-section {
    margin-bottom: 2rem;
    padding-bottom: 2rem;
    border-bottom: 2px solid #e2e8f0;
}

.profile-form-section:last-child {
    border-bottom: none;
}

.profile-form-section h3 {
    margin-bottom: 1.5rem;
    color: #1F2933;
    font-size: 1.25rem;
}

.profile-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}

.profile-form-group {
    margin-bottom: 1rem;
}

.profile-form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: #2d3748;
    font-size: 0.95rem;
}

.profile-form-input {
    width: 100%;
    padding: 0.875rem 1rem;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    font-size: 16px;
    transition: all 0.3s ease;
    font-family: inherit;
    box-sizing: border-box;
    max-width: 100%;
}

.profile-form-input:focus {
    outline: none;
    border-color: #D32F2F;
    box-shadow: 0 0 0 3px rgba(211, 47, 47, 0.1);
}

.profile-form-input:disabled {
    background: #f7fafc;
    cursor: not-allowed;
    color: #718096;
}

.profile-form-help {
    color: #718096;
    font-size: 0.85rem;
    margin-top: 0.25rem;
    display: block;
}

.profile-form-actions {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
    flex-wrap: wrap;
}

.alert {
    padding: 1rem 1.25rem;
    border-radius: 10px;
    margin-bottom: 1.5rem;
    border-left: 4px solid;
}

.alert-error {
    background: #fee;
    border-color: #dc3545;
    color: #721c24;
}

.alert-success {
    background: #d4edda;
    border-color: #28a745;
    color: #155724;
}

@media (max-width: 850px) {
    .profile-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .profile-card {
        padding: 1.5rem;
    }

    .profile-avatar {
        width: 100px;
        height: 100px;
        font-size: 2.5rem;
        margin-bottom: 1rem;
    }

    .profile-name {
        font-size: 1.25rem;
    }

    .profile-role-badge {
        padding: 0.4rem 0.875rem;
        font-size: 0.9rem;
    }

    .profile-stats-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .profile-stat-card {
        padding: 1.25rem;
    }

    .profile-stat-value {
        font-size: 1.75rem;
    }

    .profile-activity-item {
        padding: 0.875rem;
    }

    .profile-edit-form {
        padding: 0 1rem;
    }

    .profile-form-section {
        padding-bottom: 1.5rem;
    }

    .profile-form-section h3 {
        font-size: 1.15rem;
    }

    .profile-form-row {
        grid-template-columns: 1fr;
        gap: 0;
    }

    .profile-form-input {
        font-size: 16px !important;
    }

    .profile-form-actions {
        flex-direction: column;
    }

    .profile-form-actions .btn {
        width: 100%;
        text-align: center;
    }

    .profile-info-item {
        padding-bottom: 0.875rem;
    }
}

@media (max-width: 480px) {
    .profile-card {
        padding: 1rem;
    }

    .profile-avatar {
        width: 80px;
        height: 80px;
        font-size: 2rem;
    }

    .profile-name {
        font-size: 1.1rem;
    }

    .profile-stat-value {
        font-size: 1.5rem;
    }

    .profile-stat-label {
        font-size: 0.8rem;
    }

    .profile-form-section h3 {
        font-size: 1rem;
    }

    .alert {
        padding: 0.875rem 1rem;
        font-size: 0.9rem;
    }
}

@media (min-width: 851px) and (max-width: 1024px) {
    .profile-grid {
        grid-template-columns: 350px 1fr;
        gap: 1.5rem;
    }

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

.filter-tab.active {
    color: white !important;
}

.chat-operator-container,
.chat-logs-container {
    display: grid;
    grid-template-columns: 300px 1fr;
    background: white;
    border-radius: 14px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 2px 10px rgba(0,0,0,0.07);
    overflow: hidden;
    min-height: 540px;
    height: calc(100vh - 260px);
}

.sessions-panel,
.sessions-sidebar {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #fafbfc;
    border-right: 1px solid #e2e8f0;
}

.sessions-header {
    padding: 0.875rem 1rem;
    font-weight: 700;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #718096;
    border-bottom: 1px solid #e2e8f0;
    background: white;
    flex-shrink: 0;
}

.sessions-list {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}

.chat-window,
.chat-viewer {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: white;
}

.back-to-list {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.875rem;
    margin: 0.75rem 1.25rem 0;
    background: #f0f4f8;
    color: #4a5568;
    border-radius: 8px;
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: background 0.2s;
    flex-shrink: 0;
    width: fit-content;
}
.back-to-list:hover { background: #e2e8f0; color: #1F2933; }

@media (max-width: 1024px) {
    .chat-operator-container {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .sessions-panel {
        max-height: 350px;
    }

    .chat-window {
        min-height: 500px;
    }
}

@media (max-width: 850px) {

    .chat-operator-header {
        padding: 1.25rem;
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
    }

    .availability-status {
        justify-content: space-between;
        width: 100%;
    }

    .sessions-panel {
        max-height: 300px;
    }

    .sessions-header {
        padding: 1rem;
        font-size: 1rem;
    }

    .message-list {
        max-height: 250px;
    }

    .session-item {
        padding: 1rem;
    }

    .session-user-name {
        font-size: 0.95rem;
    }

    .session-last-message {
        font-size: 0.8rem;
    }

    .session-time {
        font-size: 0.7rem;
    }

    .chat-window {
        min-height: 450px;
    }

    .chat-window-header {
        padding: 1rem 1.25rem;
    }

    .chat-window-user-info {
        gap: 0.5rem;
    }

    .chat-window-avatar {
        width: 36px;
        height: 36px;
        font-size: 1rem;
    }

    .chat-window-messages {
        padding: 1.25rem;
        gap: 0.875rem;
    }

    .message-item {
        gap: 0.4rem;
    }

    .message-content {
        max-width: 80%;
        padding: 0.75rem 1rem;
        font-size: 0.9rem;
    }

    .message-meta {
        font-size: 0.7rem;
    }

    .chat-window-input {
        padding: 1rem 1.25rem;
    }

    .chat-window-input input {
        font-size: 16px !important;
        padding: 0.875rem 1rem;
    }

    .chat-window-input button {
        padding: 0.875rem 1.5rem;
        font-size: 0.9rem;
    }

    .toggle-switch {
        width: 56px;
        height: 28px;
    }

    .toggle-slider:before {
        height: 20px;
        width: 20px;
    }

    input:checked + .toggle-slider:before {
        transform: translateX(28px);
    }

    .status-badge {
        padding: 0.65rem 1rem;
        font-size: 0.9rem;
    }

    .status-indicator-dot {
        width: 10px;
        height: 10px;
    }
}

@media (max-width: 640px) {
    .chat-operator-header {
        padding: 1rem;
    }

    .availability-status {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .status-badge {
        padding: 0.5rem 0.875rem;
        font-size: 0.85rem;
    }

    .sessions-panel {
        max-height: 250px;
    }

    .session-item {
        padding: 0.875rem;
    }

    .chat-window {
        min-height: 400px;
    }

    .chat-window-header {
        padding: 0.875rem 1rem;
    }

    .chat-window-messages {
        padding: 1rem;
    }

    .message-content {
        max-width: 85%;
        padding: 0.65rem 0.875rem;
        font-size: 0.85rem;
    }

    .chat-window-input {
        padding: 0.875rem 1rem;
    }

    .chat-window-input input {
        padding: 0.75rem 0.875rem;
    }

    .chat-window-input button {
        padding: 0.75rem 1.25rem;
        font-size: 0.85rem;
    }

    .toggle-switch {
        width: 50px;
        height: 26px;
    }

    .toggle-slider:before {
        height: 18px;
        width: 18px;
    }

    input:checked + .toggle-slider:before {
        transform: translateX(24px);
    }
}

@media (max-width: 480px) {
    .chat-operator-header {
        padding: 0.875rem;
    }

    .sessions-header {
        font-size: 0.9rem;
    }

    .session-item {
        padding: 0.75rem;
    }

    .session-user-name {
        font-size: 0.9rem;
    }

    .chat-window-header {
        padding: 0.75rem 0.875rem;
    }

    .chat-window-avatar {
        width: 32px;
        height: 32px;
        font-size: 0.9rem;
    }

    .chat-window-close {
        width: 32px;
        height: 32px;
    }

    .chat-window-messages {
        padding: 0.875rem;
        gap: 0.75rem;
    }

    .message-content {
        padding: 0.6rem 0.8rem;
        font-size: 0.8rem;
    }

    .chat-window-input {
        padding: 0.75rem 0.875rem;
    }
}

@media (max-width: 850px) and (orientation: landscape) {
    .chat-operator-header {
        padding: 0.75rem 1rem;
    }

    .sessions-panel {
        max-height: 200px;
    }

    .chat-window {
        min-height: 350px;
    }

    .chat-window-messages {
        max-height: calc(100vh - 200px);
    }
}

@media (min-width: 851px) and (max-width: 1024px) {
    .chat-operator-container {
        grid-template-columns: 300px 1fr;
        gap: 1.5rem;
    }

    .sessions-panel {
        max-height: 550px;
    }

    .chat-window {
        min-height: 550px;
    }
}

@media (max-width: 850px) {
    .message-list {
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }

    .chat-window-messages {
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }
}

@supports (-webkit-touch-callout: none) {
    .chat-window-input input {
        font-size: 16px !important;
    }

    .chat-window-header {
        padding-top: calc(1rem + env(safe-area-inset-top, 0px));
    }
}

@media (max-width: 850px) {
    .session-item {
        min-height: 72px;
    }

    .chat-window-close,
    .chat-window-input button {
        min-width: 44px;
        min-height: 44px;
    }
}

@keyframes fadeInOut {
    0%, 100% { opacity: 0; }
    30%, 70% { opacity: 0.6; }
}
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    gap: 1rem;
    flex-wrap: wrap;
}

.page-header h1 {
    margin: 0;
    font-size: 2rem;
    font-weight: 700;
    color: var(--deep-charcoal, #1F2933);
}

.page-header p {
    color: #718096;
    margin-top: 0.5rem;
    font-size: 1rem;
}

@media (max-width: 850px) {
    .page-header {
        flex-direction: column;
        align-items: stretch;
    }

    .page-header h1 {
        font-size: 1.5rem;
        text-align: center;
    }

    .page-header .btn {
        width: 100%;
        text-align: center;
    }
}

.stat-cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.25rem;
    margin-bottom: 2rem;
}

@media (max-width: 900px) {
    .stat-cards { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 480px) {
    .stat-cards { grid-template-columns: 1fr; }
}

.stat-card {
    background: white;
    border-radius: 16px;
    padding: 1.5rem;
    border: 1px solid var(--border);
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.1);
}

.stat-card .stat-number {
    font-size: 2.25rem;
    font-weight: 800;
    line-height: 1;
    color: #1F2933;
}

.stat-card .stat-label {
    font-size: 0.85rem;
    color: #718096;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.stat-card .stat-label img {
    width: 16px;
    height: 16px;
    opacity: 0.6;
}

.stat-card.blue {
    border-top: 3px solid var(--red-primary);
}
.stat-card.blue .stat-number { color: var(--red-primary); }

.stat-card.green {
    border-top: 3px solid var(--green);
}
.stat-card.green .stat-number { color: var(--green); }

.stat-card.purple {
    border-top: 3px solid #6B46C1;
}
.stat-card.purple .stat-number { color: #6B46C1; }

.stat-card.orange {
    border-top: 3px solid var(--red-dark);
}
.stat-card.orange .stat-number { color: var(--red-dark); }

.trend-chart {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 0.5rem;
}

.trend-bars {
    display: flex;
    align-items: flex-end;
    gap: 4px;
    height: 180px;
    padding: 0 0.25rem;
    min-width: max-content;
}

.trend-bar {
    flex: 1 0 22px;
    min-width: 22px;
    max-width: 40px;
    background: var(--red-primary);
    border-radius: 4px 4px 0 0;
    position: relative;
    cursor: default;
    transition: background 0.2s;
    min-height: 2px;
}

.trend-bar:hover {
    background: var(--red-dark);
}

.trend-bar-value {
    position: absolute;
    top: -1.4rem;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.65rem;
    font-weight: 700;
    color: #1F2933;
    white-space: nowrap;
    display: none;
}

.trend-bar:hover .trend-bar-value {
    display: block;
}

.trend-bar-label {
    position: absolute;
    bottom: -1.4rem;
    left: 50%;
    transform: translateX(-50%) rotate(-45deg);
    font-size: 0.6rem;
    color: #1a1a1a;
    white-space: nowrap;
    transform-origin: top left;
}

.filter-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    padding: 1rem 1.25rem;
    background: white;
    border-radius: 12px;
    border: 1px solid var(--border);
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.visitor-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.25rem 0.6rem;
    border-radius: 12px;
    font-size: 0.78rem;
    font-weight: 600;
}

.visitor-badge img {
    width: 12px;
    height: 12px;
}

.visitor-badge.user {
    background: #FFEBEE;
    color: var(--red-primary);
}

.visitor-badge.user img {
    filter: invert(21%) sepia(93%) saturate(1572%) hue-rotate(342deg) brightness(87%) contrast(88%);
}

.visitor-badge.guest {
    background: #F3F4F6;
    color: #4a5568;
}

.pagination {
    display: flex;
    justify-content: center;
    gap: 0.4rem;
    flex-wrap: wrap;
    padding: 1.25rem 0 0;
    margin-top: 1rem;
    border-top: 1px solid var(--border);
}

.pagination a,
.pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 0.65rem;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    border: 1px solid var(--border);
    text-decoration: none;
    transition: all 0.2s;
    color: #4a5568;
    background: white;
}

.pagination a:hover {
    background: #FFEBEE;
    border-color: var(--red-primary);
    color: var(--red-primary);
}

.pagination span.active {
    background: var(--red-primary);
    border-color: var(--red-primary);
    color: white;
    font-weight: 700;
}

.weekly-chart table {
    width: 100%;
    border-collapse: collapse;
}

.weekly-chart table thead tr {
    background: #F9FAFB;
}

.weekly-chart table th {
    padding: 0.875rem 1rem;
    text-align: left;
    font-weight: 600;
    color: #1F2933;
    font-size: 0.875rem;
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}

.weekly-chart table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.875rem;
    color: #4a5568;
}

.weekly-chart table tbody tr:hover {
    background: #F9FAFB;
}

.weekly-chart table tbody tr:last-child td {
    border-bottom: none;
}

.show-more-btn {
    padding: 0.6rem 1.5rem;
    background: white;
    border: 2px solid var(--red-primary);
    border-radius: 25px;
    color: var(--red-primary);
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-block;
    text-align: center;
}

.show-more-btn:hover {
    background: var(--red-primary);
    color: white;
}

.trend-chart {
    padding-bottom: 2rem;
    margin-bottom: 0.5rem;
}

.hidden-row { display: none; }
