/* ==========================================
   2026 Dark Glossy Theme
   ========================================== */

:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-tertiary: #1a1a2e;
    --surface: rgba(255, 255, 255, 0.03);
    --surface-hover: rgba(255, 255, 255, 0.06);
    --glass: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-shine: rgba(255, 255, 255, 0.12);
    --text-primary: #f0f0f5;
    --text-secondary: #b0b0c8;
    --text-muted: #7a7a95;
    --accent: #6c5ce7;
    --accent-light: #a29bfe;
    --accent-glow: rgba(108, 92, 231, 0.3);
    --success: #00d2a0;
    --danger: #ff6b6b;
    --warning: #ffd93d;
    --sidebar-width: 260px;
    --topbar-height: 64px;
    --radius: 16px;
    --radius-sm: 10px;
    --radius-xs: 6px;
    --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

/* ==========================================
   Login Page
   ========================================== */

.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: var(--bg-primary);
}

.login-container {
    position: relative;
    width: 100%;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-bg-orbs {
    position: fixed;
    inset: 0;
    z-index: 0;
    overflow: hidden;
    pointer-events: none;
}

.orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(100px);
    opacity: 0.4;
    animation: orbFloat 20s ease-in-out infinite;
}

.orb-1 {
    width: 500px;
    height: 500px;
    background: var(--accent);
    top: -10%;
    left: -5%;
    animation-delay: 0s;
}

.orb-2 {
    width: 400px;
    height: 400px;
    background: #e84393;
    bottom: -10%;
    right: -5%;
    animation-delay: -7s;
}

.orb-3 {
    width: 300px;
    height: 300px;
    background: #00cec9;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    animation-delay: -14s;
}

@keyframes orbFloat {
    0%, 100% { transform: translate(0, 0) scale(1); }
    25% { transform: translate(30px, -40px) scale(1.05); }
    50% { transform: translate(-20px, 20px) scale(0.95); }
    75% { transform: translate(15px, 30px) scale(1.02); }
}

.login-card {
    position: relative;
    z-index: 1;
    width: 420px;
    padding: 48px 40px;
    background: linear-gradient(
        135deg,
        rgba(255, 255, 255, 0.08) 0%,
        rgba(255, 255, 255, 0.02) 100%
    );
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    backdrop-filter: blur(40px) saturate(1.5);
    -webkit-backdrop-filter: blur(40px) saturate(1.5);
    box-shadow:
        0 0 0 1px rgba(255, 255, 255, 0.05) inset,
        0 20px 60px rgba(0, 0, 0, 0.5),
        0 0 100px var(--accent-glow);
}

.login-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--glass-shine), transparent);
    border-radius: 24px 24px 0 0;
}

.login-logo {
    text-align: center;
    margin-bottom: 36px;
}

.login-avatar {
    width: 100px;
    height: 100px;
    margin: 0 auto 20px;
    border-radius: 20px;
    object-fit: cover;
    display: block;
    box-shadow: 0 8px 32px var(--accent-glow);
    border: 2px solid var(--glass-border);
}

.logo-icon {
    width: 72px;
    height: 72px;
    margin: 0 auto 20px;
    background: linear-gradient(135deg, var(--accent), var(--accent-light));
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    color: #fff;
    box-shadow: 0 8px 32px var(--accent-glow);
    position: relative;
}

.logo-icon::after {
    content: '';
    position: absolute;
    inset: -2px;
    border-radius: 22px;
    background: linear-gradient(135deg, rgba(255,255,255,0.3), transparent);
    mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    mask-composite: exclude;
    -webkit-mask-composite: xor;
    padding: 1px;
}

.login-logo h1 {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, var(--text-primary), var(--text-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.login-logo p {
    color: var(--text-secondary);
    font-size: 14px;
    margin-top: 6px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-wrapper i {
    position: absolute;
    left: 16px;
    color: var(--text-muted);
    font-size: 14px;
    transition: color var(--transition);
    z-index: 1;
}

.input-wrapper input {
    width: 100%;
    padding: 14px 16px 14px 44px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 15px;
    font-family: inherit;
    transition: all var(--transition);
    outline: none;
}

.input-wrapper input:focus {
    border-color: var(--accent);
    background: rgba(108, 92, 231, 0.05);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.input-wrapper input:focus + i,
.input-wrapper input:focus ~ i {
    color: var(--accent-light);
}

.input-wrapper:has(input:focus) i {
    color: var(--accent-light);
}

.btn-primary {
    width: 100%;
    padding: 14px 24px;
    background: linear-gradient(135deg, var(--accent), #7c6cf0);
    border: none;
    border-radius: var(--radius-sm);
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    position: relative;
    overflow: hidden;
}

.btn-primary::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 50%;
    background: linear-gradient(to bottom, rgba(255,255,255,0.15), transparent);
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px var(--accent-glow);
}

.btn-primary:active {
    transform: translateY(0);
}

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

.error-message {
    background: rgba(255, 107, 107, 0.1);
    border: 1px solid rgba(255, 107, 107, 0.2);
    color: var(--danger);
    padding: 10px 14px;
    border-radius: var(--radius-xs);
    font-size: 13px;
    margin-bottom: 12px;
}

.success-message {
    background: rgba(0, 210, 160, 0.1);
    border: 1px solid rgba(0, 210, 160, 0.2);
    color: var(--success);
    padding: 10px 14px;
    border-radius: var(--radius-xs);
    font-size: 13px;
    margin-bottom: 12px;
}

.login-back-link {
    position: absolute;
    top: 24px;
    left: 32px;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    padding: 10px 18px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    transition: all 0.3s ease;
}

.login-back-link:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--glass-shine);
    transform: translateX(-4px);
}

.login-lang-selector {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 24px;
}

.lang-btn {
    padding: 6px 14px;
    background: transparent;
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    font-family: inherit;
}

.lang-btn:hover,
.lang-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

/* ==========================================
   App Layout
   ========================================== */

.app-body {
    overflow: hidden;
}

.app-layout {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ==========================================
   Sidebar
   ========================================== */

.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    height: 100vh;
    background: linear-gradient(
        180deg,
        rgba(255, 255, 255, 0.04) 0%,
        rgba(255, 255, 255, 0.01) 100%
    );
    border-right: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    position: relative;
}

.sidebar::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 1px;
    background: linear-gradient(180deg, var(--glass-shine), transparent, var(--glass-shine));
}

.sidebar-logo {
    padding: 24px 20px;
    display: flex;
    align-items: center;
    gap: 14px;
    border-bottom: 1px solid var(--glass-border);
}

.sidebar-avatar {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    object-fit: cover;
    box-shadow: 0 4px 16px var(--accent-glow);
    border: 2px solid var(--glass-border);
    flex-shrink: 0;
}

.logo-icon-sm {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--accent), var(--accent-light));
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: #fff;
    box-shadow: 0 4px 16px var(--accent-glow);
    position: relative;
}

.logo-icon-sm::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 50%;
    background: linear-gradient(to bottom, rgba(255,255,255,0.2), transparent);
    border-radius: 12px 12px 0 0;
}

.logo-text {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.3px;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: all var(--transition);
    position: relative;
    overflow: hidden;
}

.nav-item::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, var(--accent-glow), transparent);
    opacity: 0;
    transition: opacity var(--transition);
}

.nav-item i {
    font-size: 18px;
    width: 24px;
    text-align: center;
    position: relative;
    z-index: 1;
}

.nav-item span {
    position: relative;
    z-index: 1;
}

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

.nav-item.active {
    color: var(--accent-light);
    background: rgba(108, 92, 231, 0.1);
}

.nav-item.active::before {
    opacity: 1;
}

.nav-item.active::after {
    content: '';
    position: absolute;
    left: 0;
    top: 20%;
    height: 60%;
    width: 3px;
    background: var(--accent);
    border-radius: 0 3px 3px 0;
    box-shadow: 0 0 12px var(--accent-glow);
}

/* ─── Collapsible Nav Group ─── */
.nav-group {
    display: flex;
    flex-direction: column;
}

.nav-group-toggle {
    cursor: pointer;
    user-select: none;
}

.nav-group-toggle .nav-group-arrow {
    margin-left: auto;
    font-size: 12px;
    transition: transform 0.3s ease;
    width: auto;
}

.nav-group.open .nav-group-toggle .nav-group-arrow {
    transform: rotate(180deg);
}

.nav-group-items {
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow: hidden;
    max-height: 0;
    transition: max-height 0.3s ease;
}

.nav-group.open .nav-group-items {
    max-height: 200px;
}

.nav-sub-item {
    padding-left: 40px !important;
    font-size: 13px !important;
}

.nav-sub-item i {
    font-size: 14px !important;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--glass-border);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    color: var(--text-secondary);
}

.sidebar-user i {
    font-size: 20px;
    color: var(--accent-light);
}

/* ==========================================
   Top Bar
   ========================================== */

.main-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.topbar {
    height: var(--topbar-height);
    min-height: var(--topbar-height);
    padding: 0 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--glass-border);
    background: rgba(10, 10, 15, 0.95);
    position: relative;
    z-index: 1100;
}

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
}

.breadcrumb-item {
    color: var(--text-muted);
    cursor: default;
}

.breadcrumb-item.active {
    color: var(--text-primary);
    font-weight: 500;
}

.breadcrumb-sep {
    color: var(--text-muted);
    font-size: 10px;
}

/* User Dropdown */
.topbar-right {
    display: flex;
    align-items: center;
    margin-right: 100px;
}

.user-dropdown {
    position: relative;
}

.user-dropdown-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    background: var(--surface);
    border: 1px solid var(--glass-border);
    border-radius: 40px;
    color: var(--text-primary);
    cursor: pointer;
    font-family: inherit;
    font-size: 13px;
    transition: all var(--transition);
}

.user-dropdown-btn:hover {
    background: var(--surface-hover);
    border-color: var(--glass-shine);
}

.user-avatar {
    font-size: 22px;
    color: var(--accent-light);
}

.user-dropdown-btn .fa-chevron-down {
    font-size: 10px;
    color: var(--text-muted);
    transition: transform var(--transition);
}

.user-dropdown.open .fa-chevron-down {
    transform: rotate(180deg);
}

.dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 220px;
    background: linear-gradient(
        135deg,
        rgba(30, 30, 50, 0.95) 0%,
        rgba(20, 20, 35, 0.98) 100%
    );
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    padding: 8px;
    backdrop-filter: blur(40px);
    -webkit-backdrop-filter: blur(40px);
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px) scale(0.96);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 9999;
}

.dropdown-menu::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--glass-shine), transparent);
}

.user-dropdown.open .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: var(--radius-xs);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 13px;
    cursor: pointer;
    transition: all var(--transition);
}

.dropdown-item:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
}

.dropdown-item i {
    width: 18px;
    text-align: center;
    font-size: 14px;
}

.dropdown-logout:hover {
    color: var(--danger);
}

.dropdown-divider {
    height: 1px;
    background: var(--glass-border);
    margin: 6px 0;
}

/* Submenus */
.dropdown-submenu {
    position: relative;
}

.submenu {
    display: none;
    position: absolute;
    right: calc(100% + 4px);
    top: -4px;
    min-width: 180px;
    background: linear-gradient(
        135deg,
        rgba(30, 30, 50, 0.95) 0%,
        rgba(20, 20, 35, 0.98) 100%
    );
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    padding: 6px;
    backdrop-filter: blur(40px);
    -webkit-backdrop-filter: blur(40px);
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.4);
    z-index: 10000;
}

.dropdown-submenu:hover .submenu {
    display: block;
}

.submenu-item {
    display: block;
    padding: 8px 14px;
    border-radius: var(--radius-xs);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 13px;
    transition: all var(--transition);
}

.submenu-item:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
}

.submenu-item.active-lang,
.submenu-item.active-tz {
    color: var(--accent-light);
}

/* ==========================================
   Content Area
   ========================================== */

.content {
    flex: 1;
    padding: 28px;
    overflow-y: auto;
    overflow-x: hidden;
    position: relative;
    background:
        radial-gradient(ellipse at 20% 50%, rgba(108, 92, 231, 0.04) 0%, transparent 70%),
        radial-gradient(ellipse at 80% 20%, rgba(0, 206, 201, 0.03) 0%, transparent 60%),
        var(--bg-primary);
}

.content::-webkit-scrollbar {
    width: 6px;
}

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

.content::-webkit-scrollbar-thumb {
    background: var(--glass-border);
    border-radius: 3px;
}

.page {
    display: none;
}

.page.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.page-header {
    margin-bottom: 24px;
}

.page-header h2 {
    font-size: 26px;
    font-weight: 700;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, var(--text-primary), var(--accent-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* ==========================================
   Glass Cards
   ========================================== */

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.glass-card {
    background: linear-gradient(
        135deg,
        rgba(255, 255, 255, 0.06) 0%,
        rgba(255, 255, 255, 0.02) 100%
    );
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    padding: 28px;
    position: relative;
    overflow: hidden;
    transition: all var(--transition);
}

.glass-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--glass-shine), transparent);
}

.glass-card::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 50%;
    background: linear-gradient(to bottom, rgba(255,255,255,0.03), transparent);
    pointer-events: none;
    border-radius: var(--radius) var(--radius) 0 0;
}

.glass-card:hover {
    border-color: var(--glass-shine);
    transform: translateY(-2px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.card-icon {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--accent-glow), rgba(108, 92, 231, 0.1));
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: var(--accent-light);
    margin-bottom: 16px;
    position: relative;
    z-index: 1;
}

.glass-card h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 8px;
    position: relative;
    z-index: 1;
}

.glass-card p {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
    position: relative;
    z-index: 1;
}

/* ==========================================
   Connections
   ========================================== */

.connection-card {
    position: relative;
}

.connection-status {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    z-index: 2;
}

.connection-status.online {
    background: var(--success);
    box-shadow: 0 0 12px rgba(0, 210, 160, 0.5);
}

.connection-status.offline {
    background: var(--danger);
    box-shadow: 0 0 12px rgba(255, 107, 107, 0.5);
}

.connection-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.badge-green {
    background: rgba(0, 210, 160, 0.1);
    color: var(--success);
    border: 1px solid rgba(0, 210, 160, 0.2);
}

.badge-red {
    background: rgba(255, 107, 107, 0.1);
    color: var(--danger);
    border: 1px solid rgba(255, 107, 107, 0.2);
}

/* ==========================================
   Map
   ========================================== */

.map-card {
    padding: 0 !important;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

#leafletMap {
    width: 100%;
    height: calc(100vh - 180px);
    min-height: 400px;
    z-index: 1;
}

/* Override Leaflet controls to match dark theme */
.leaflet-control-zoom a {
    background: var(--bg-secondary) !important;
    color: var(--text-primary) !important;
    border-color: var(--glass-border) !important;
}

.leaflet-control-zoom a:hover {
    background: var(--bg-tertiary) !important;
}

.leaflet-control-attribution {
    background: rgba(10, 10, 15, 0.8) !important;
    color: var(--text-muted) !important;
    font-size: 10px !important;
}

.leaflet-control-attribution a {
    color: var(--accent-light) !important;
}

/* Leaflet popup dark theme */
.leaflet-popup-content-wrapper {
    background: var(--bg-secondary) !important;
    color: var(--text-primary) !important;
    border-radius: var(--radius-sm) !important;
    border: 1px solid var(--glass-border) !important;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4) !important;
}

.leaflet-popup-tip {
    background: var(--bg-secondary) !important;
}

.leaflet-popup-content {
    margin: 12px 16px !important;
    font-family: 'Inter', sans-serif !important;
    font-size: 13px !important;
    line-height: 1.5 !important;
}

/* Layer toggle button */
.map-layer-toggle {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-xs);
    background: var(--bg-secondary);
    border: 1px solid var(--glass-border);
    color: var(--text-secondary);
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.map-layer-toggle:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-color: var(--accent);
}

.map-layer-toggle.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent-light);
}

/* Fullscreen map */
.map-body-fullscreen {
    overflow: hidden;
}

.map-body-fullscreen .sidebar,
.map-body-fullscreen .topbar {
    display: none !important;
}

.map-body-fullscreen .content {
    padding: 0;
}

.map-page-fullscreen {
    padding: 0 !important;
}

.map-page-fullscreen .page-header {
    display: none;
}

.map-card.map-fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9999;
    border-radius: 0;
    margin: 0;
    padding: 0;
}

.map-card.map-fullscreen #leafletMap,
.map-card.map-fullscreen #historyMap {
    height: 100vh !important;
    min-height: 100vh;
    border-radius: 0;
}

/* Darken map tiles to match theme */
.leaflet-tile-pane {
    filter: brightness(0.85) contrast(1.1) saturate(0.8);
}

@media (max-width: 768px) {
    #leafletMap {
        height: calc(100vh - 150px);
        min-height: 300px;
    }

    .leaflet-control-attribution {
        font-size: 8px !important;
        max-width: 200px;
    }
}

/* Tracker marker icons */
.tracker-marker-icon {
    background: transparent !important;
    border: none !important;
    position: relative;
}

.tracker-marker {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 3px solid rgba(255, 255, 255, 0.9);
    position: relative;
}

.tracker-marker span {
    color: #fff;
    font-weight: 700;
    font-size: 14px;
    font-family: 'Inter', sans-serif;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.tracker-marker-pin {
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 10px solid #6c5ce7;
    margin: -2px auto 0;
}

/* Stale tracker warning badge (>24h old) */
.tracker-stale-badge {
    position: absolute;
    top: -4px;
    right: -6px;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.tracker-stale-badge i {
    color: #f1c40f;
    font-size: 16px;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.6));
}

/* Tracker popup styling */
.tracker-popup-inner {
    font-family: 'Inter', sans-serif;
}

.tracker-popup-name {
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--glass-border);
    color: var(--accent-light);
}

.tracker-popup-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 3px 0;
    font-size: 13px;
    color: var(--text-secondary);
}

.tracker-popup-row i {
    width: 16px;
    text-align: center;
    color: var(--accent-light);
    font-size: 12px;
    flex-shrink: 0;
}

.tracker-popup-coords {
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid var(--glass-border);
    font-size: 11px;
    color: var(--text-muted);
}

/* ==========================================
   Trips Page
   ========================================== */

.trips-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.trips-toolbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}
.trips-th-check,
.trips-td-check {
    width: 36px;
    text-align: center !important;
    padding-left: 10px !important;
    padding-right: 4px !important;
}
.trips-th-check input,
.trips-td-check input {
    cursor: pointer;
    accent-color: var(--accent);
    width: 15px;
    height: 15px;
}

.trips-search-wrap {
    position: relative;
    flex: 1;
    min-width: 200px;
}

.trips-search-wrap > i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    font-size: 14px;
    pointer-events: none;
}

.trips-search-wrap .form-input {
    padding-left: 36px;
    width: 100%;
}

.trips-per-page-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.trips-per-page-wrap label {
    font-size: 13px;
    color: var(--text-secondary);
}

.trips-per-page-wrap .form-input {
    width: 80px;
    padding: 6px 10px;
}

.trips-address-cell {
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.trip-show-more {
    background: none;
    border: none;
    color: var(--accent);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background 0.2s;
}

.trip-show-more:hover {
    background: rgba(108, 92, 231, 0.15);
}

/* Trips Pagination */
.trips-pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0 0;
    gap: 12px;
    flex-wrap: wrap;
}

.trips-pagination-info {
    font-size: 13px;
    color: var(--text-secondary);
}

.trips-pagination-buttons {
    display: flex;
    align-items: center;
    gap: 4px;
}

.btn-page {
    background: var(--surface);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
    min-width: 34px;
    text-align: center;
}

.btn-page:hover:not([disabled]) {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.btn-page.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    font-weight: 600;
}

.btn-page[disabled] {
    opacity: 0.3;
    cursor: not-allowed;
}

.pagination-dots {
    color: var(--text-secondary);
    padding: 0 4px;
    font-size: 13px;
}

/* Trip Detail Modal */
.trip-detail-modal {
    max-width: 520px;
    width: 90vw;
}

.trip-detail-grid {
    padding: 16px;
}

.trip-detail-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    gap: 12px;
}

.trip-detail-row:last-child {
    border-bottom: none;
}

.trip-detail-label {
    font-size: 13px;
    color: var(--text-secondary);
    flex-shrink: 0;
    min-width: 120px;
}

.trip-detail-value {
    font-size: 13px;
    color: var(--text-primary);
    text-align: right;
    word-break: break-word;
}

@media (max-width: 768px) {
    .trips-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .trips-per-page-wrap {
        justify-content: flex-end;
    }

    .trips-address-cell {
        max-width: 120px;
    }

    .trips-pagination {
        flex-direction: column;
        align-items: center;
    }

    .trip-detail-row {
        flex-direction: column;
        gap: 4px;
    }

    .trip-detail-value {
        text-align: left;
    }
}

/* Trip actions cell */
.trips-actions-cell {
    white-space: nowrap;
    display: flex;
    gap: 4px;
}

.trip-delete-btn {
    color: var(--text-muted) !important;
}

.trip-delete-btn:hover {
    background: rgba(231, 76, 60, 0.15) !important;
    color: #e74c3c !important;
    border-color: rgba(231, 76, 60, 0.3) !important;
}

/* Trip date group divider */
.trips-date-divider td {
    background: rgba(108, 92, 231, 0.12);
    color: var(--primary-color);
    font-weight: 600;
    font-size: 13px;
    padding: 8px 16px !important;
    border-bottom: 2px solid rgba(108, 92, 231, 0.25);
    letter-spacing: 0.3px;
}

.trips-date-divider td i {
    margin-right: 8px;
    opacity: 0.7;
}

/* Trip Map Modal — resizable */
.trip-map-modal {
    max-width: 900px;
    width: 80vw;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    resize: both;
    overflow: hidden;
    min-width: 400px;
    min-height: 350px;
    transition: none;
    z-index: 2001;
    position: relative;
}

.trip-map-modal .modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.trip-map-header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.trip-map-info {
    display: flex;
    flex-wrap: wrap;
    gap: 12px 24px;
    padding: 10px 20px;
    font-size: 13px;
    color: var(--text-secondary);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    background: rgba(255, 255, 255, 0.02);
}

.trip-map-info-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.trip-map-info-item i {
    width: 14px;
    text-align: center;
    color: var(--accent);
    font-size: 12px;
}

.trip-map-info-item span {
    color: var(--text-primary);
}

.trip-map-container {
    flex: 1;
    min-height: 0;
}

#tripMapLeaflet {
    width: 100%;
    height: 100%;
    min-height: 300px;
    border-radius: 0 0 12px 12px;
}

/* Trip Map Fullscreen */
.trip-map-modal.trip-map-fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw !important;
    height: 100vh !important;
    max-width: none;
    max-height: none;
    border-radius: 0;
    margin: 0;
    resize: none;
}

.trip-map-modal.trip-map-fullscreen #tripMapLeaflet {
    border-radius: 0;
}

@media (max-width: 768px) {
    .trip-map-modal {
        width: 98vw;
        max-height: 95vh;
        min-width: 300px;
    }
}

/* ==========================================
   Geofence Report Page
   ========================================== */

#page-report-geofence.active {
    display: flex;
    flex-direction: column;
    height: calc(100vh - var(--topbar-height) - 56px);
    overflow: hidden;
}
#page-report-geofence .page-header {
    flex-shrink: 0;
    margin-bottom: 16px;
}

.report-gf-layout {
    display: flex;
    gap: 16px;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.report-gf-panel {
    width: 340px;
    min-width: 300px;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    flex-shrink: 0;
}
.report-gf-panel-section {
    padding: 16px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}
.report-gf-panel-section h4 {
    margin: 0 0 12px;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
}

.report-gf-toolbar {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
    align-items: center;
}
.report-gf-search-wrap {
    flex: 1;
    position: relative;
}
.report-gf-search-wrap i {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    font-size: 12px;
}
.report-gf-search-wrap input {
    width: 100%;
    padding: 6px 10px 6px 30px;
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--glass-border);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 12px;
    outline: none;
}
.report-gf-search-wrap input:focus {
    border-color: var(--accent);
}

.report-gf-panel-section .report-gf-toolbar #reportGfToggleAll {
    padding: 4px 8px;
    font-size: 11px;
    gap: 4px;
    white-space: nowrap;
    flex-shrink: 0;
    margin-left: 4px;
}
.report-gf-panel-section .report-gf-toolbar #reportGfToggleAll i {
    font-size: 10px;
}

.report-gf-device-list {
    max-height: 260px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.report-gf-device-check {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text-primary);
    transition: background 0.15s;
}
.report-gf-device-check:hover {
    background: rgba(255,255,255,0.04);
}
.report-gf-device-check input[type="checkbox"] {
    accent-color: var(--accent);
    width: 15px;
    height: 15px;
    flex-shrink: 0;
}
.report-gf-no-devices {
    color: var(--text-secondary);
    font-size: 13px;
    padding: 12px 0;
    text-align: center;
}

.report-gf-results {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.report-gf-results-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    flex-shrink: 0;
}
.report-gf-results-header h4 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}
.report-gf-count {
    font-size: 12px;
    color: var(--text-secondary);
    background: rgba(255,255,255,0.06);
    padding: 3px 10px;
    border-radius: 10px;
}

.report-gf-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 18px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    flex-shrink: 0;
}
.report-gf-toolbar-left {
    flex: 1;
    min-width: 0;
}
.report-gf-toolbar-right {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}
.report-gf-filter-wrap {
    position: relative;
    max-width: 280px;
}
.report-gf-filter-wrap i {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    font-size: 12px;
    pointer-events: none;
}
.report-gf-filter {
    width: 100%;
    padding: 7px 12px 7px 30px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s;
}
.report-gf-filter:focus {
    border-color: var(--accent);
}
.report-gf-filter::placeholder {
    color: var(--text-secondary);
}
.report-gf-export-wrap {
    position: relative;
    display: inline-block;
}
.report-gf-export-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 12px;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}
.report-gf-export-btn:hover {
    background: rgba(255,255,255,0.1);
    border-color: var(--accent);
}
.report-gf-export-arrow {
    font-size: 10px;
    opacity: 0.6;
    transition: transform 0.2s;
}
.report-gf-export-wrap.open .report-gf-export-arrow {
    transform: rotate(180deg);
}
.report-gf-export-menu {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    min-width: 140px;
    background: #1e1e2e;
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.6);
    z-index: 50;
    overflow: hidden;
}
.report-gf-export-wrap.open .report-gf-export-menu {
    display: block;
}
.report-gf-export-menu button {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 9px 14px;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 13px;
    cursor: pointer;
    transition: background 0.15s;
    text-align: left;
}
.report-gf-export-menu button:hover {
    background: rgba(255,255,255,0.08);
}
.report-gf-export-menu button i {
    width: 16px;
    text-align: center;
}
.report-gf-export-menu button[data-format="csv"] i { color: #22c55e; }
.report-gf-export-menu button[data-format="excel"] i { color: #16a34a; }
.report-gf-export-menu button[data-format="word"] i { color: #3b82f6; }
.report-gf-export-menu button[data-format="pdf"] i { color: #ef4444; }

.report-gf-pagesize-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
}
.report-gf-pagesize-select {
    padding: 5px 8px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 12px;
    cursor: pointer;
    outline: none;
}
.report-gf-pagesize-select:focus {
    border-color: var(--accent);
}

.report-gf-table-wrap {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}
.report-gf-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.report-gf-table thead th {
    position: sticky;
    top: 0;
    background: var(--card-bg);
    padding: 10px 14px;
    text-align: left;
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    z-index: 2;
}
.report-gf-table tbody tr {
    border-bottom: 1px solid rgba(255,255,255,0.04);
    transition: background 0.15s;
}
.report-gf-table tbody tr:hover {
    background: rgba(255,255,255,0.03);
}
.report-gf-table td {
    padding: 10px 14px;
    color: var(--text-primary);
    white-space: nowrap;
}
/* Geofence Report — Action column */
.report-gf-td-action {
    text-align: center;
    width: 60px;
}
.report-gf-delete-btn {
    color: var(--danger) !important;
    margin: 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.report-gf-delete-btn:hover {
    background: rgba(255, 107, 107, 0.12) !important;
    color: var(--danger) !important;
}

/* Messages Report — center all columns */
#page-report-messages .report-gf-table thead th {
    text-align: center;
}
#page-report-messages .report-gf-table td {
    text-align: center;
}
#page-report-messages .report-gf-table td .btn-icon {
    margin: 0 auto;
    display: flex;
    justify-content: center;
    align-items: center;
}

.report-gf-td-time {
    font-family: 'Courier New', monospace;
    font-size: 13px;
    color: var(--text-primary) !important;
}
.report-gf-td-imei {
    font-size: 11px;
    color: var(--text-secondary) !important;
}

.report-gf-fence-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 6px;
    vertical-align: middle;
}

.report-gf-th-check,
.report-gf-td-check {
    width: 36px;
    text-align: center !important;
    padding-left: 10px !important;
    padding-right: 4px !important;
}
.report-gf-th-check input,
.report-gf-td-check input {
    cursor: pointer;
    accent-color: var(--accent);
    width: 15px;
    height: 15px;
}

.report-gf-td-duration {
    font-weight: 600;
    color: var(--accent);
    white-space: nowrap;
}

.report-gf-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 10px 18px;
    border-top: 1px solid rgba(255,255,255,0.06);
    flex-shrink: 0;
}
.report-gf-page-btn {
    min-width: 32px;
    height: 32px;
    padding: 0 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 12px;
    cursor: pointer;
    transition: all 0.15s;
}
.report-gf-page-btn:hover:not([disabled]):not(.active) {
    background: rgba(255,255,255,0.1);
    color: var(--text-primary);
}
.report-gf-page-btn.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
    font-weight: 600;
}
.report-gf-page-btn[disabled] {
    opacity: 0.3;
    cursor: default;
}
.report-gf-page-dots {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    color: var(--text-secondary);
    font-size: 12px;
}

.report-gf-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 200px;
    color: var(--text-secondary);
    gap: 12px;
}
.report-gf-empty i {
    font-size: 40px;
    opacity: 0.3;
}
.report-gf-empty p {
    font-size: 14px;
    margin: 0;
}

@media (max-width: 900px) {
    #page-report-geofence {
        height: auto;
        overflow: visible;
    }
    .report-gf-layout {
        flex-direction: column;
    }
    .report-gf-panel {
        width: 100%;
        min-width: 0;
        max-height: 300px;
    }
    .report-gf-results {
        min-height: 400px;
    }
}

/* ==========================================
   History Page (geofence-style layout)
   ========================================== */

#page-history.active {
    display: flex;
    flex-direction: column;
    height: calc(100vh - var(--topbar-height) - 56px);
    overflow: hidden;
}

#page-history .page-header {
    flex-shrink: 0;
    margin-bottom: 16px;
}

.history-layout {
    display: flex;
    gap: 16px;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.history-panel {
    width: 340px;
    min-width: 300px;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    flex-shrink: 0;
}

.history-panel-section {
    padding: 16px 18px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

.history-panel-section:last-child {
    border-bottom: none;
}

.history-panel-section h4 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 12px 0;
}

.history-tracker-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: 220px;
    overflow-y: auto;
    padding-right: 4px;
}

.history-tracker-list::-webkit-scrollbar {
    width: 4px;
}

.history-tracker-list::-webkit-scrollbar-thumb {
    background: var(--glass-border);
    border-radius: 4px;
}

.history-tracker-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
    font-size: 13px;
    color: var(--text-secondary);
}

.history-tracker-checkbox:hover {
    background: rgba(255,255,255,0.05);
}

.history-tracker-checkbox input[type="checkbox"] {
    accent-color: var(--accent);
    width: 15px;
    height: 15px;
    cursor: pointer;
}

.history-tracker-color {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.history-select-all {
    font-weight: 600;
    color: var(--text-primary);
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: 6px;
    margin-bottom: 2px;
}

.history-no-trackers {
    text-align: center;
    padding: 20px;
    color: var(--text-muted);
}

.history-no-trackers i {
    font-size: 24px;
    margin-bottom: 8px;
    display: block;
}

.history-date-inputs {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 14px;
}

.history-date-inputs .form-group {
    margin-bottom: 0;
}

.history-date-inputs .input-wrapper input {
    font-size: 13px;
}

.history-show-btn {
    width: 100%;
}

.history-map-wrapper {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    position: relative;
}

#historyMap {
    width: 100%;
    height: 100%;
    border-radius: 12px;
}

.history-marker-icon {
    background: transparent !important;
    border: none !important;
}

.history-popup {
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    line-height: 1.6;
}

.history-popup i {
    color: var(--accent-light);
    font-size: 12px;
}

/* Flatpickr dark theme overrides */
.flatpickr-calendar {
    background: #1a1a2e !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.7) !important;
    border-radius: 12px !important;
}
.flatpickr-months .flatpickr-month,
.flatpickr-current-month .flatpickr-monthDropdown-months {
    background: transparent !important;
    color: var(--text-primary) !important;
}
.flatpickr-current-month input.cur-year {
    color: var(--text-primary) !important;
}
.flatpickr-months .flatpickr-prev-month svg,
.flatpickr-months .flatpickr-next-month svg {
    fill: var(--text-secondary) !important;
}
.flatpickr-months .flatpickr-prev-month:hover svg,
.flatpickr-months .flatpickr-next-month:hover svg {
    fill: var(--accent) !important;
}
span.flatpickr-weekday {
    color: var(--text-secondary) !important;
    background: transparent !important;
}
.flatpickr-day {
    color: var(--text-primary) !important;
    border-radius: 8px !important;
}
.flatpickr-day:hover {
    background: var(--accent) !important;
    border-color: var(--accent) !important;
    color: #fff !important;
}
.flatpickr-day.selected,
.flatpickr-day.selected:hover {
    background: var(--accent) !important;
    border-color: var(--accent) !important;
    color: #fff !important;
}
.flatpickr-day.today {
    border-color: var(--accent-light) !important;
}
.flatpickr-day.prevMonthDay,
.flatpickr-day.nextMonthDay {
    color: var(--text-secondary) !important;
    opacity: 0.4;
}
.flatpickr-time {
    border-top: 1px solid var(--border) !important;
}
.flatpickr-time input {
    color: var(--text-primary) !important;
    background: transparent !important;
}
.flatpickr-time .flatpickr-time-separator {
    color: var(--text-secondary) !important;
}
.flatpickr-time .flatpickr-am-pm {
    color: var(--text-primary) !important;
    background: transparent !important;
}
.numInputWrapper span {
    border-color: var(--border) !important;
}
.numInputWrapper span svg path {
    fill: var(--text-secondary) !important;
}
.numInputWrapper:hover span svg path {
    fill: var(--accent) !important;
}

@media (max-width: 900px) {
    #page-history {
        height: auto;
        overflow: visible;
    }

    .history-layout {
        flex-direction: column;
    }

    .history-panel {
        width: 100%;
        min-width: 0;
    }

    .history-map-wrapper {
        min-height: 350px;
        height: 50vh;
    }
}

/* ==========================================
   WhatsApp-like Chat
   ========================================== */

/* Override page padding for chat */
#page-chat {
    position: absolute;
    inset: 0;
    padding: 0 !important;
    margin: 0;
}

#page-chat.active {
    display: flex !important;
}

.chat-app {
    display: flex;
    width: 100%;
    height: 100%;
    background: var(--bg-secondary);
    overflow: hidden;
}

/* Left Panel */
.chat-sidebar-panel {
    width: 360px;
    min-width: 360px;
    border-right: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    background: rgba(255, 255, 255, 0.02);
}

.chat-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--glass-border);
    background: rgba(255, 255, 255, 0.03);
    min-height: 60px;
}

.chat-sidebar-header h3 {
    font-size: 20px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--text-primary), var(--accent-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.btn-new-chat {
    background: rgba(108, 92, 231, 0.1) !important;
    border-color: rgba(108, 92, 231, 0.2) !important;
    color: var(--accent-light) !important;
}

.btn-new-chat:hover {
    background: rgba(108, 92, 231, 0.2) !important;
    transform: scale(1.05);
}

.chat-search-wrapper {
    position: relative;
    padding: 8px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.chat-search-wrapper i {
    position: absolute;
    left: 24px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 13px;
}

.chat-search-wrapper input {
    width: 100%;
    padding: 10px 12px 10px 38px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 13px;
    font-family: inherit;
    outline: none;
    transition: all var(--transition);
}

.chat-search-wrapper input:focus {
    border-color: var(--accent);
    background: rgba(108, 92, 231, 0.05);
}

.chat-search-wrapper input::placeholder {
    color: var(--text-muted);
}

/* Conversations List */
.chat-conversations-list {
    flex: 1;
    overflow-y: auto;
}

.chat-conversations-list::-webkit-scrollbar {
    width: 4px;
}

.chat-conversations-list::-webkit-scrollbar-thumb {
    background: var(--glass-border);
    border-radius: 2px;
}

.chat-conv-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 20px;
    cursor: pointer;
    transition: background var(--transition);
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    position: relative;
}

.chat-conv-item:hover {
    background: rgba(255, 255, 255, 0.04);
}

.chat-conv-item.active {
    background: rgba(108, 92, 231, 0.08);
    border-left: 3px solid var(--accent);
}

.chat-conv-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, #2d5f4e, #1a3a30);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.chat-conv-avatar span {
    font-size: 18px;
    font-weight: 600;
    color: #00d2a0;
}

.chat-conv-info {
    flex: 1;
    min-width: 0;
}

.chat-conv-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.chat-conv-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-conv-time {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
    margin-left: 8px;
}

.chat-conv-item.active .chat-conv-time,
.chat-conv-time.has-unread {
    color: #00d2a0;
}

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

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

.chat-conv-badge {
    background: #00d2a0;
    color: #000;
    font-size: 11px;
    font-weight: 700;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
    margin-left: 8px;
    flex-shrink: 0;
}

.chat-no-conversations {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.chat-no-conversations i {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.2;
}

/* Right Panel */
.chat-main-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    background:
        radial-gradient(ellipse at 30% 70%, rgba(0, 100, 80, 0.03) 0%, transparent 60%),
        radial-gradient(ellipse at 70% 30%, rgba(108, 92, 231, 0.02) 0%, transparent 50%),
        var(--bg-primary);
}

/* Chat wallpaper pattern */
.chat-main-panel::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.015'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    pointer-events: none;
    z-index: 0;
}

/* Empty State */
.chat-empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    position: relative;
    z-index: 1;
}

.chat-empty-icon {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 24px;
}

.chat-empty-icon i {
    font-size: 48px;
    color: var(--accent-light);
    opacity: 0.4;
}

.chat-empty-state h3 {
    font-size: 22px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.chat-empty-state p {
    font-size: 14px;
    color: var(--text-muted);
}

/* Active Chat */
.chat-active {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 1;
    min-height: 0;
    overflow: hidden;
}

/* Chat Header */
.chat-main-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    background: rgba(255, 255, 255, 0.03);
    border-bottom: 1px solid var(--glass-border);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    min-height: 60px;
}

.chat-header-user {
    display: flex;
    align-items: center;
    gap: 14px;
}

.chat-header-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: linear-gradient(135deg, #2d5f4e, #1a3a30);
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-header-avatar span {
    font-size: 16px;
    font-weight: 600;
    color: #00d2a0;
}

.chat-header-info {
    display: flex;
    flex-direction: column;
}

.chat-header-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}

.chat-header-status {
    font-size: 12px;
    color: #00d2a0;
}

/* Messages Area */
.chat-messages-area {
    flex: 1;
    overflow-y: auto;
    padding: 16px 60px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.chat-messages-area::-webkit-scrollbar {
    width: 5px;
}

.chat-messages-area::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

/* Date Separator */
.chat-date-separator {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px 0;
}

.chat-date-separator span {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    padding: 5px 14px;
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

/* Message Bubbles */
.chat-bubble {
    max-width: 65%;
    padding: 8px 12px 6px;
    border-radius: 8px;
    position: relative;
    animation: bubbleIn 0.2s ease;
    margin-bottom: 2px;
}

@keyframes bubbleIn {
    from { opacity: 0; transform: scale(0.95) translateY(4px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.chat-bubble.sent {
    align-self: flex-end;
    background: linear-gradient(135deg, #005c4b, #00493d);
    border-radius: 8px 8px 2px 8px;
}

.chat-bubble.received {
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 8px 8px 8px 2px;
}

.chat-bubble-content {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 8px;
}

.chat-bubble-text {
    font-size: 14px;
    line-height: 1.45;
    color: var(--text-primary);
    word-break: break-word;
    white-space: pre-wrap;
}

.chat-bubble-meta {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: auto;
    flex-shrink: 0;
}

.chat-bubble-time {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.45);
}

.chat-sent-tick {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.4);
}

.chat-read {
    font-size: 12px;
    color: #53bdeb !important;
}

/* Input Area */
.chat-input-area {
    padding: 12px 20px;
    background: rgba(255, 255, 255, 0.03);
    border-top: 1px solid var(--glass-border);
}

.chat-input-container {
    display: flex;
    align-items: center;
    gap: 10px;
}

.chat-input-container input {
    flex: 1;
    padding: 12px 18px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 24px;
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: all var(--transition);
}

.chat-input-container input:focus {
    border-color: rgba(108, 92, 231, 0.3);
    background: rgba(255, 255, 255, 0.06);
}

.chat-input-container input::placeholder {
    color: var(--text-muted);
}

.chat-send-btn {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, #00d2a0, #00a880);
    border: none;
    border-radius: 50%;
    color: #fff;
    font-size: 16px;
    cursor: pointer;
    transition: all var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.chat-send-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 16px rgba(0, 210, 160, 0.3);
}

.chat-send-btn:active {
    transform: scale(0.95);
}

/* Loading & Error */
.chat-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: var(--accent-light);
    font-size: 20px;
}

.chat-error {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: var(--text-muted);
    font-size: 14px;
}

/* Sidebar Badge */
.chat-sidebar-badge {
    position: absolute;
    top: 6px;
    right: 10px;
    background: #00d2a0;
    color: #000;
    font-size: 10px;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
    z-index: 2;
}

/* New Chat Modal */
.new-chat-modal {
    width: 420px;
    max-width: 90vw;
    max-height: 70vh;
    display: flex;
    flex-direction: column;
}

.modal-search {
    border-bottom: none;
    padding: 0 0 12px 0;
}

.modal-search i {
    left: 12px;
}

.contacts-list {
    flex: 1;
    overflow-y: auto;
    max-height: 400px;
    margin: 0 -28px -28px;
    padding: 0;
}

.contacts-list::-webkit-scrollbar {
    width: 4px;
}

.contacts-list::-webkit-scrollbar-thumb {
    background: var(--glass-border);
    border-radius: 2px;
}

.contact-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 24px;
    cursor: pointer;
    transition: background var(--transition);
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.contact-item:hover {
    background: rgba(255, 255, 255, 0.04);
}

.contact-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, #2d5f4e, #1a3a30);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.contact-avatar span {
    font-size: 16px;
    font-weight: 600;
    color: #00d2a0;
}

.contact-info {
    display: flex;
    flex-direction: column;
}

.contact-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

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

.chat-no-contacts {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: var(--text-muted);
    font-size: 14px;
}

/* Context Menu */
.chat-context-menu {
    position: fixed;
    z-index: 10000;
    background: rgba(30, 30, 46, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 6px 0;
    min-width: 150px;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    animation: ctxMenuIn 0.15s ease;
}

@keyframes ctxMenuIn {
    from { opacity: 0; transform: scale(0.92); }
    to   { opacity: 1; transform: scale(1); }
}

.chat-ctx-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    font-size: 13px;
    color: var(--text-primary);
    cursor: pointer;
    transition: background 0.15s ease;
}

.chat-ctx-item:hover {
    background: rgba(255, 255, 255, 0.08);
}

.chat-ctx-item i {
    font-size: 13px;
    width: 16px;
    text-align: center;
    color: var(--text-secondary);
}

.chat-ctx-danger {
    color: var(--danger);
}

.chat-ctx-danger i {
    color: var(--danger);
}

.chat-ctx-danger:hover {
    background: rgba(255, 107, 107, 0.12);
}

/* Reply Quote inside bubble */
.chat-reply-quote {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 6px 10px;
    margin-bottom: 4px;
    border-left: 3px solid var(--accent-light);
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.06);
    cursor: pointer;
    transition: background 0.15s ease;
    max-width: 100%;
}

.chat-reply-quote:hover {
    background: rgba(255, 255, 255, 0.1);
}

.chat-reply-quote-sender {
    font-size: 12px;
    font-weight: 600;
    color: var(--accent-light);
}

.chat-reply-quote-text {
    font-size: 12.5px;
    color: rgba(255, 255, 255, 0.5);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 300px;
}

.chat-reply-quote-text em {
    font-style: italic;
    opacity: 0.6;
}

/* Reply Preview bar (above input) */
.chat-reply-preview {
    padding: 0 20px;
    display: flex;
}

.chat-reply-preview-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    padding: 8px 14px;
    background: rgba(255, 255, 255, 0.04);
    border-left: 3px solid var(--accent-light);
    border-radius: 8px 8px 0 0;
    animation: replySlideIn 0.2s ease;
}

@keyframes replySlideIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.chat-reply-preview-content {
    display: flex;
    flex-direction: column;
    gap: 1px;
    overflow: hidden;
    flex: 1;
}

.chat-reply-preview-sender {
    font-size: 12px;
    font-weight: 600;
    color: var(--accent-light);
}

.chat-reply-preview-text {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.45);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-reply-preview-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 4px;
    font-size: 14px;
    transition: all 0.15s ease;
    flex-shrink: 0;
}

.chat-reply-preview-close:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.08);
}

/* Bubble highlight when scrolled to via reply */
.chat-bubble-highlight {
    animation: bubbleHighlight 1.5s ease;
}

@keyframes bubbleHighlight {
    0%   { box-shadow: 0 0 0 2px rgba(162, 155, 254, 0.6); }
    100% { box-shadow: none; }
}

/* Back button (hidden on desktop, visible on mobile) */
.chat-back-btn {
    display: none;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 18px;
    cursor: pointer;
    padding: 6px;
    border-radius: 8px;
    transition: all 0.15s ease;
    flex-shrink: 0;
}

.chat-back-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.08);
}

/* Mobile responsive - Chat */
@media (max-width: 768px) {
    .chat-app {
        position: relative;
    }

    /* Conversations panel: full width on mobile */
    .chat-sidebar-panel {
        width: 100%;
        min-width: 100%;
        position: absolute;
        inset: 0;
        z-index: 2;
        background: var(--bg-secondary);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    /* Messages panel: full width on mobile */
    .chat-main-panel {
        width: 100%;
        position: absolute;
        inset: 0;
        z-index: 1;
        overflow: hidden;
        background: var(--bg-primary);
    }

    /* When a conversation is open, slide the sidebar out */
    .chat-app.chat-conv-open .chat-sidebar-panel {
        transform: translateX(-100%);
    }

    .chat-app.chat-conv-open .chat-main-panel {
        z-index: 3;
    }

    /* Show back button on mobile */
    .chat-back-btn {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Hide empty state on mobile (conversations list is default view) */
    .chat-empty-state {
        display: none !important;
    }

    /* Smaller padding for messages on mobile */
    .chat-messages-area {
        padding: 12px 14px;
    }

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

    /* Conversation list items: slightly more compact */
    .chat-conv-item {
        padding: 12px 16px;
    }

    .chat-conv-avatar {
        width: 44px;
        height: 44px;
    }

    .chat-conv-avatar span {
        font-size: 16px;
    }

    /* Compact header on mobile */
    .chat-main-header {
        padding: 10px 14px;
        min-height: 54px;
    }

    .chat-header-avatar {
        width: 36px;
        height: 36px;
    }

    .chat-header-avatar span {
        font-size: 14px;
    }

    .chat-header-name {
        font-size: 14px;
    }

    .chat-header-status {
        font-size: 11px;
    }

    /* Chat input area on mobile */
    .chat-input-area {
        padding: 8px 12px;
    }

    .chat-input-container input {
        padding: 10px 14px;
        font-size: 14px;
    }

    .chat-send-btn {
        width: 40px;
        height: 40px;
        font-size: 14px;
    }

    /* Reply preview on mobile */
    .chat-reply-preview {
        padding: 0 12px;
    }

    /* Reply quote text shorter on mobile */
    .chat-reply-quote-text {
        max-width: 180px;
    }

    /* Search bar on mobile */
    .chat-sidebar-header {
        padding: 12px 16px;
        min-height: 52px;
    }

    .chat-sidebar-header h3 {
        font-size: 18px;
    }

    .chat-search-wrapper {
        padding: 6px 12px;
    }

    /* Context menu positioning on mobile */
    .chat-context-menu {
        min-width: 140px;
    }
}

/* ==========================================
   Modal
   ========================================== */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.modal-overlay.show {
    display: flex;
}

.modal {
    width: 400px;
    max-width: 90vw;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.modal-header h3 {
    font-size: 20px;
    font-weight: 600;
}

.modal-close {
    width: 32px;
    height: 32px;
    background: var(--surface);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    font-size: 14px;
}

.modal-close:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
}

/* ==========================================
   Toast Notifications
   ========================================== */

.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 3000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 14px 20px;
    background: linear-gradient(
        135deg,
        rgba(30, 30, 50, 0.95) 0%,
        rgba(20, 20, 35, 0.98) 100%
    );
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    color: var(--text-primary);
    font-size: 13px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    animation: slideIn 0.3s ease;
    display: flex;
    align-items: center;
    gap: 10px;
}

.toast.success {
    border-left: 3px solid var(--success);
}

.toast.error {
    border-left: 3px solid var(--danger);
}

@keyframes slideIn {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}

/* ==========================================
   Users Page
   ========================================== */

.users-page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.btn-accent {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: linear-gradient(135deg, var(--accent), #7c6cf0);
    border: none;
    border-radius: var(--radius-sm);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--transition);
    position: relative;
    overflow: hidden;
}

.btn-accent::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 50%;
    background: linear-gradient(to bottom, rgba(255,255,255,0.15), transparent);
}

.btn-accent:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 20px var(--accent-glow);
}

/* Data Table */
.users-table-card {
    overflow: hidden;
}

.users-search-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 20px 0 20px;
}

.users-search-wrapper i {
    color: var(--text-secondary);
    font-size: 14px;
}

.users-search-wrapper input {
    flex: 1;
    max-width: 360px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 14px;
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.users-search-wrapper input:focus {
    border-color: var(--accent);
}

.users-search-wrapper input::placeholder {
    color: var(--text-secondary);
    opacity: 0.6;
}

.table-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 16px;
    padding: 0 4px;
    position: relative;
    z-index: 1;
}

.table-responsive {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    position: relative;
    z-index: 1;
}

.data-table thead th {
    padding: 12px 16px;
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--glass-border);
    white-space: nowrap;
}

.data-table tbody td {
    padding: 12px 16px;
    font-size: 13px;
    color: var(--text-secondary);
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    white-space: nowrap;
}

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

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

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

.table-loading,
.table-empty {
    text-align: center;
    padding: 40px 16px !important;
    color: var(--text-muted);
}

.table-loading i {
    font-size: 20px;
    color: var(--accent-light);
}

.user-cell {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-primary);
    font-weight: 500;
}

.user-cell i {
    color: var(--accent-light);
    font-size: 18px;
}

.badge-purple {
    background: rgba(108, 92, 231, 0.15);
    color: var(--accent-light);
    border: 1px solid rgba(108, 92, 231, 0.3);
}

.badge-blue {
    background: rgba(0, 150, 255, 0.1);
    color: #64b5f6;
    border: 1px solid rgba(0, 150, 255, 0.2);
}

.badge-gray {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
    border: 1px solid var(--glass-border);
}

.badge-orange {
    background: rgba(255, 165, 0, 0.1);
    color: #ffa500;
    border: 1px solid rgba(255, 165, 0, 0.2);
}

.badge-gold {
    background: rgba(255, 215, 0, 0.15);
    color: #ffd700;
    border: 1px solid rgba(255, 215, 0, 0.3);
}

.btn-icon {
    width: 32px;
    height: 32px;
    background: transparent;
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    transition: all var(--transition);
}

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

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

.btn-edit-user:hover {
    border-color: rgba(108, 92, 231, 0.3);
    color: var(--accent-light);
    background: rgba(108, 92, 231, 0.08);
}

.btn-delete-user:hover {
    border-color: rgba(255, 107, 107, 0.3);
    color: var(--danger);
    background: rgba(255, 107, 107, 0.08);
}

.btn-caretaker-assign:hover {
    border-color: rgba(0, 184, 148, 0.3);
    color: #00b894;
    background: rgba(0, 184, 148, 0.08);
}

/* Caretaker Customers Tabs */
#page-caretaker-customers.active {
    display: flex;
    flex-direction: column;
    height: calc(100vh - var(--topbar-height) - 56px);
    overflow: hidden;
}
#page-caretaker-customers .page-header {
    flex-shrink: 0;
    margin-bottom: 16px;
}
.caretaker-cust-right {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.caretaker-cust-tabs {
    display: flex;
    gap: 0;
    flex-shrink: 0;
    border-bottom: 1px solid var(--glass-border);
}

.caretaker-cust-tab {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 9px 12px;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}
.caretaker-cust-tab i {
    font-size: 0.8rem;
}

.caretaker-cust-tab:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.04);
}

.caretaker-cust-tab.active {
    color: var(--accent-light);
    border-bottom-color: var(--accent);
}

.caretaker-cust-tab-content {
    flex: 1 1 0;
    overflow-y: auto;
    min-height: 0;
}

.caretaker-cust-tab-pane {
    display: none;
}

.caretaker-cust-tab-pane.active {
    display: block;
}

.caretaker-cust-tab-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 60px 20px;
    color: var(--text-muted);
    text-align: center;
}

.caretaker-cust-tab-empty i {
    font-size: 2.5rem;
    opacity: 0.3;
}

.caretaker-cust-tab-empty p {
    font-size: 0.95rem;
    margin: 0;
}

#page-caretaker-customers .report-gf-panel-section {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}
#page-caretaker-customers .report-gf-device-list,
#page-connectors .report-gf-device-list {
    max-height: none;
    flex: 1;
    min-height: 0;
}
#page-connectors .report-gf-panel-section {
    display: flex;
    flex-direction: column;
    height: 100%;
}
#page-connectors .report-gf-panel {
    min-height: 500px;
}

/* Caretaker radio button styling */
.caretaker-cust-radio-item input[type="radio"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
    cursor: pointer;
    flex-shrink: 0;
}

/* Caretaker Assign Modal */
.caretaker-assign-modal {
    width: 480px;
    max-width: 95vw;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.caretaker-search-wrapper {
    position: relative;
    margin-bottom: 12px;
    flex-shrink: 0;
}

.caretaker-search-wrapper i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.85rem;
}

.caretaker-search-wrapper input {
    width: 100%;
    padding: 10px 12px 10px 36px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s;
}

.caretaker-search-wrapper input:focus {
    border-color: var(--accent);
}

.caretaker-users-list {
    flex: 1 1 auto;
    overflow-y: auto;
    min-height: 100px;
    max-height: 400px;
    background: rgba(0, 0, 0, 0.15);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    padding: 6px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.caretaker-user-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
}

.caretaker-user-item:hover {
    background: rgba(255, 255, 255, 0.06);
}

.caretaker-user-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: #00b894;
    cursor: pointer;
    flex-shrink: 0;
}

.caretaker-user-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.caretaker-user-name {
    font-size: 0.92rem;
    font-weight: 500;
    color: var(--text-primary);
}

.caretaker-user-meta {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.caretaker-assign-footer {
    flex-shrink: 0;
    padding-top: 16px;
    display: flex;
    justify-content: flex-end;
}

/* Edit User Modal */
.edit-user-modal {
    width: 860px;
    max-width: 95vw;
    max-height: 92vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.edit-user-modal .modal-header {
    flex-shrink: 0;
}

.edit-user-modal #editUserForm {
    flex: 1 1 auto;
    overflow-y: auto;
    padding-right: 6px;
    min-height: 0;
}

.edit-user-modal .form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.edit-user-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    align-items: start;
}

.edit-user-main,
.edit-user-side {
    min-width: 0;
}

.edit-user-side .device-checkbox-list {
    max-height: none;
}

@media (max-width: 820px) {
    .edit-user-grid {
        grid-template-columns: 1fr;
    }
}

.input-disabled {
    opacity: 0.5;
    cursor: not-allowed !important;
}

/* Device checkbox list in Edit User modal */
.device-checkbox-list {
    max-height: 200px;
    overflow-y: auto;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.device-checkbox-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
}

.device-checkbox-item:hover {
    background: rgba(255, 255, 255, 0.08);
}

.device-checkbox-item input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
    cursor: pointer;
    flex-shrink: 0;
}

.device-checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.device-checkbox-label i {
    color: var(--accent);
    font-size: 0.85rem;
}

.device-checkbox-empty {
    color: var(--text-muted);
    font-size: 0.85rem;
    text-align: center;
    padding: 12px;
}

/* Add User Subpage */
.subpage-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.subpage-header h3 {
    font-size: 20px;
    font-weight: 600;
}

.btn-back {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--surface);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-xs);
    color: var(--text-secondary);
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--transition);
}

.btn-back:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
}

.add-user-card {
    max-width: 700px;
}

.add-user-form .form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.form-select {
    width: 100%;
    padding: 14px 16px 14px 44px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 15px;
    font-family: inherit;
    transition: all var(--transition);
    outline: none;
    appearance: none;
    cursor: pointer;
}

.form-select option {
    background: #1a1a2e;
    color: var(--text-primary);
}

.form-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

/* Delete Modal */
.modal-body-text {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 8px;
    position: relative;
    z-index: 1;
}

.modal-body-username {
    color: var(--text-primary);
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 24px;
    position: relative;
    z-index: 1;
}

.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    position: relative;
    z-index: 1;
}

.btn-cancel {
    padding: 10px 20px;
    background: var(--surface);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-xs);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--transition);
}

.btn-cancel:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
}

.btn-danger {
    padding: 10px 20px;
    background: linear-gradient(135deg, var(--danger), #ff8787);
    border: none;
    border-radius: var(--radius-xs);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--transition);
    position: relative;
    overflow: hidden;
}

.btn-danger::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 50%;
    background: linear-gradient(to bottom, rgba(255,255,255,0.15), transparent);
}

.btn-danger:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(255, 107, 107, 0.3);
}

/* Breadcrumb link */
.breadcrumb-link {
    cursor: pointer;
    transition: color var(--transition);
}

.breadcrumb-link:hover {
    color: var(--accent-light);
}

/* ==========================================
   Pagination
   ========================================== */

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 16px 0 4px;
    position: relative;
    z-index: 1;
}

.pagination-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: var(--surface);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--transition);
}

.pagination-btn:hover:not(:disabled) {
    background: var(--surface-hover);
    color: var(--text-primary);
    border-color: var(--glass-shine);
}

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

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

/* ==========================================
   Security Settings
   ========================================== */

.security-settings-card {
    max-width: 500px;
}

.glass-card.clickable-card {
    cursor: pointer;
}

.glass-card.clickable-card:hover {
    border-color: var(--accent);
    box-shadow: 0 8px 32px var(--accent-glow);
}

.form-hint {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 6px;
    position: relative;
    z-index: 1;
}

/* ==========================================
   Admin Page
   ========================================== */

.admin-section .section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.admin-section .section-header h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.admin-table-card {
    overflow: hidden;
}

.admin-table-card .data-table {
    margin: 0;
}

.company-name-cell {
    font-weight: 600;
    color: var(--text-primary);
}

/* Company action buttons */
.btn-company-users:hover {
    border-color: rgba(0, 184, 148, 0.3);
    color: #00b894;
    background: rgba(0, 184, 148, 0.08);
}

.btn-edit-company:hover {
    border-color: rgba(108, 92, 231, 0.3);
    color: var(--accent-light);
    background: rgba(108, 92, 231, 0.08);
}

.btn-delete-company:hover:not(:disabled) {
    border-color: rgba(255, 107, 107, 0.3);
    color: var(--danger);
    background: rgba(255, 107, 107, 0.08);
}

.btn-delete-company:disabled,
.btn-delete-company.disabled {
    opacity: 0.35;
    cursor: not-allowed;
    pointer-events: auto;
}

.btn-delete-company:disabled:hover,
.btn-delete-company.disabled:hover {
    border-color: var(--glass-border);
    color: var(--text-muted);
    background: transparent;
}

/* Company Users Modal */
.company-users-modal {
    width: 600px;
    max-width: 90vw;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}

.company-users-title-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.company-users-title-row i {
    color: var(--accent);
    font-size: 18px;
}

.company-users-title-row h3 {
    font-size: 20px;
    font-weight: 600;
}

.company-users-count {
    font-size: 14px;
    color: var(--text-muted);
    font-weight: 400;
}

.company-users-modal .table-responsive {
    overflow-y: auto;
    flex: 1;
    margin-top: 8px;
}

.company-users-modal .data-table {
    margin: 0;
}

.company-users-modal .data-table td {
    padding: 10px 16px;
}

/* ─── User Devices Modal ─── */
.user-devices-modal {
    width: 550px;
    max-width: 90vw;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}

.user-devices-title-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-devices-title-row i {
    color: var(--accent);
    font-size: 18px;
}

.user-devices-title-row h3 {
    font-size: 20px;
}

.user-devices-username {
    font-size: 13px;
    color: var(--text-secondary);
    background: rgba(108, 92, 231, 0.12);
    padding: 2px 10px;
    border-radius: 12px;
    margin-left: 4px;
}

.user-devices-list {
    overflow-y: auto;
    flex: 1;
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 400px;
}

.user-device-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    transition: background var(--transition);
}

.user-device-row:hover {
    background: rgba(255, 255, 255, 0.06);
}

.user-device-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-device-info > i {
    color: var(--accent);
    font-size: 16px;
}

.user-device-details {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.user-device-name {
    font-weight: 500;
    color: var(--text-primary);
    font-size: 0.95rem;
}

.user-device-meta {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.btn-disconnect-device {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: transparent;
    border: 1px solid rgba(255, 107, 107, 0.25);
    border-radius: var(--radius-xs);
    color: var(--text-secondary);
    font-size: 12px;
    cursor: pointer;
    transition: all var(--transition);
}

.btn-disconnect-device:hover {
    background: rgba(255, 107, 107, 0.1);
    border-color: rgba(255, 107, 107, 0.5);
    color: var(--danger);
}

.btn-disconnect-device i {
    font-size: 12px;
}

.user-devices-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 32px 16px;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.user-devices-empty i {
    font-size: 24px;
    color: var(--text-muted);
}

.btn-devices-user:hover {
    border-color: rgba(0, 210, 160, 0.3);
    color: var(--success);
    background: rgba(0, 210, 160, 0.08);
}

/* ─── Device Form ─── */
.form-section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--accent-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 20px 0 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--glass-border);
}

.form-section-title:first-of-type {
    margin-top: 0;
}

.form-section-title i {
    font-size: 13px;
    opacity: 0.8;
}

.input-wrapper select {
    width: 100%;
    padding: 14px 16px 14px 44px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 15px;
    font-family: inherit;
    transition: all var(--transition);
    outline: none;
    appearance: none;
    cursor: pointer;
}

.input-wrapper select option {
    background: #1a1a2e;
    color: var(--text-primary);
}

.input-wrapper select:focus {
    border-color: var(--accent);
    background: rgba(108, 92, 231, 0.05);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.input-wrapper:has(select:focus) i {
    color: var(--accent-light);
}

.input-wrapper-textarea {
    align-items: flex-start;
}

.input-wrapper-textarea i {
    top: 16px;
}

.input-wrapper textarea {
    width: 100%;
    padding: 14px 16px 14px 44px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    font-family: 'Courier New', monospace;
    transition: all var(--transition);
    outline: none;
    resize: vertical;
    min-height: 60px;
}

.input-wrapper textarea:focus {
    border-color: var(--accent);
    background: rgba(108, 92, 231, 0.05);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.input-wrapper:has(textarea:focus) i {
    color: var(--accent-light);
}

.device-name-cell {
    font-weight: 600;
    color: var(--text-primary);
}

.device-name-cell i {
    margin-right: 8px;
    color: var(--accent);
}

.btn-edit-device:hover {
    border-color: rgba(108, 92, 231, 0.3);
    color: var(--accent-light);
    background: rgba(108, 92, 231, 0.08);
}

.btn-delete-device:hover {
    border-color: rgba(255, 107, 107, 0.3);
    color: var(--danger);
    background: rgba(255, 107, 107, 0.08);
}

@media (max-width: 768px) {
    .admin-section .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
}

/* ==========================================
   Responsive
   ========================================== */

@media (max-width: 768px) {
    .sidebar {
        width: 72px;
        min-width: 72px;
    }

    .sidebar-logo .logo-text,
    .nav-item span,
    .sidebar-user span {
        display: none;
    }

    .sidebar-logo {
        justify-content: center;
        padding: 24px 0;
    }

    .nav-item {
        justify-content: center;
        padding: 14px;
    }

    .nav-item i {
        margin: 0;
    }

    .nav-sub-item {
        padding-left: 14px !important;
    }

    .nav-group-toggle .nav-group-arrow {
        display: none;
    }

    .sidebar-user {
        justify-content: center;
    }

    .topbar {
        padding: 0 12px;
    }

    .topbar-right {
        margin-right: 0;
    }

    .user-dropdown-btn span {
        display: none;
    }

    .content {
        padding: 12px;
    }

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

    .login-card {
        width: 90%;
        padding: 32px 24px;
    }

    /* Users table responsive */
    .data-table {
        font-size: 12px;
    }

    .data-table thead th,
    .data-table tbody td {
        padding: 8px 10px;
    }
}

/* ==========================================
   Audit Logs
   ========================================== */

.audit-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.audit-controls label {
    font-size: 13px;
    color: var(--text-secondary);
    white-space: nowrap;
}

.audit-page-select {
    width: auto;
    min-width: 70px;
    padding: 6px 10px;
    font-size: 13px;
}

/* Audit search bar */
.audit-search-bar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    flex-wrap: wrap;
}

.audit-search-input-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 200px;
}

.audit-search-input-wrap i {
    color: var(--text-secondary);
    font-size: 14px;
}

.audit-search-input-wrap input {
    flex: 1;
    max-width: 360px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 14px;
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.audit-search-input-wrap input:focus {
    border-color: var(--accent);
}

.audit-search-input-wrap input::placeholder {
    color: var(--text-secondary);
    opacity: 0.6;
}

.audit-date-range {
    display: flex;
    align-items: center;
    gap: 12px;
}

.audit-date-field {
    display: flex;
    align-items: center;
    gap: 6px;
}

.audit-date-field label {
    font-size: 13px;
    color: var(--text-secondary);
    white-space: nowrap;
}

.audit-datetime-input {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 6px 10px;
    color: var(--text-primary);
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s;
    color-scheme: dark;
}

.audit-datetime-input:focus {
    border-color: var(--accent);
}

.audit-pagination-buttons {
    display: flex;
    gap: 6px;
}

.audit-ts-cell {
    white-space: nowrap;
    font-size: 12px;
}

.audit-changes-cell {
    max-width: 220px;
}

.audit-summary {
    font-size: 12px;
    color: var(--text-secondary);
}

.btn-show-more {
    background: none;
    border: none;
    color: var(--accent);
    cursor: pointer;
    font-size: 12px;
    padding: 2px 6px;
    margin-left: 4px;
    text-decoration: underline;
    transition: color var(--transition);
}

.btn-show-more:hover {
    color: var(--accent-hover);
}

/* Audit Detail Modal */
.audit-detail-modal {
    max-width: 700px;
    width: 90vw;
    max-height: 80vh;
    overflow-y: auto;
}

.audit-detail-content {
    padding: 8px 0;
}

.audit-diff-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.audit-diff-table th {
    background: rgba(255, 255, 255, 0.05);
    padding: 10px 14px;
    text-align: left;
    font-weight: 600;
    color: var(--text-primary);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.audit-diff-table td {
    padding: 8px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
    word-break: break-word;
}

.audit-diff-key {
    font-weight: 500;
    color: var(--text-primary) !important;
}

.audit-diff-changed td {
    background: rgba(255, 255, 255, 0.03);
}

.audit-diff-changed td:nth-child(2) {
    color: var(--danger) !important;
    text-decoration: line-through;
    opacity: 0.7;
}

.audit-diff-changed td:nth-child(3) {
    color: var(--success) !important;
}

/* ==========================================
   Homepage
   ========================================== */

.home-body {
    overflow-x: hidden;
    overflow-y: auto;
    background: var(--bg-primary);
}

/* ─── Navbar ─── */

.home-navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    padding: 16px 0;
    transition: all 0.4s ease;
}

.home-navbar.scrolled {
    background: rgba(10, 10, 15, 0.85);
    backdrop-filter: blur(20px) saturate(1.5);
    -webkit-backdrop-filter: blur(20px) saturate(1.5);
    border-bottom: 1px solid var(--glass-border);
    padding: 10px 0;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.3);
}

.home-nav-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.home-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
}

.home-brand-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.home-brand-logo {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 12px;
}

.home-brand-text {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

.home-nav-links {
    display: flex;
    align-items: center;
    gap: 8px;
}

.home-nav-link {
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    padding: 8px 16px;
    border-radius: 10px;
    transition: all 0.3s ease;
}

.home-nav-link:hover {
    color: var(--text-primary);
    background: var(--surface-hover);
}

.home-login-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    padding: 10px 24px;
    background: linear-gradient(135deg, var(--accent), var(--accent-light));
    border-radius: 12px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px var(--accent-glow);
    margin-left: 8px;
}

.home-login-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px var(--accent-glow);
}

.home-mobile-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 22px;
    cursor: pointer;
    padding: 8px;
}

.home-mobile-menu {
    display: none;
    position: fixed;
    top: 70px;
    left: 0;
    right: 0;
    background: rgba(10, 10, 15, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--glass-border);
    padding: 16px 32px;
    flex-direction: column;
    gap: 4px;
    z-index: 999;
    transform: translateY(-20px);
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s ease;
}

.home-mobile-menu.open {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
}

.home-mobile-link {
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 15px;
    font-weight: 500;
    padding: 12px 16px;
    border-radius: 10px;
    transition: all 0.3s ease;
}

.home-mobile-link:hover {
    color: var(--text-primary);
    background: var(--surface-hover);
}

.home-mobile-login {
    color: var(--accent-light);
    font-weight: 600;
}

/* ─── Hero Section ─── */

.home-hero {
    position: relative;
    min-height: 100vh;
    display: flex;
    align-items: center;
    padding: 120px 0 80px;
    overflow: hidden;
}

.home-hero-bg {
    position: absolute;
    inset: 0;
    z-index: 0;
    overflow: hidden;
    pointer-events: none;
}

.home-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(120px);
    opacity: 0.35;
    animation: homeOrbFloat 25s ease-in-out infinite;
}

.home-orb-1 {
    width: 600px;
    height: 600px;
    background: var(--accent);
    top: -15%;
    left: -10%;
    animation-delay: 0s;
}

.home-orb-2 {
    width: 500px;
    height: 500px;
    background: #e84393;
    bottom: -15%;
    right: -10%;
    animation-delay: -8s;
}

.home-orb-3 {
    width: 350px;
    height: 350px;
    background: #00cec9;
    top: 40%;
    right: 20%;
    animation-delay: -16s;
}

.home-orb-4 {
    width: 250px;
    height: 250px;
    background: #fdcb6e;
    bottom: 20%;
    left: 30%;
    animation-delay: -12s;
    opacity: 0.2;
}

@keyframes homeOrbFloat {
    0%, 100% { transform: translate(0, 0) scale(1); }
    25% { transform: translate(40px, -50px) scale(1.06); }
    50% { transform: translate(-30px, 30px) scale(0.94); }
    75% { transform: translate(20px, 40px) scale(1.03); }
}

.home-hero-content {
    position: relative;
    z-index: 1;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 32px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 64px;
    align-items: center;
}

.home-hero-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 24px;
}

.home-hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: rgba(108, 92, 231, 0.15);
    border: 1px solid rgba(108, 92, 231, 0.3);
    border-radius: 50px;
    font-size: 13px;
    font-weight: 500;
    color: var(--accent-light);
}

.home-hero-badge-pro {
    background: rgba(0, 210, 160, 0.12);
    border-color: rgba(0, 210, 160, 0.3);
    color: #00d2a0;
}

.home-hero-title {
    font-size: clamp(40px, 5vw, 64px);
    font-weight: 900;
    line-height: 1.1;
    color: var(--text-primary);
    margin-bottom: 20px;
    letter-spacing: -2px;
}

.home-gradient-text {
    background: linear-gradient(135deg, var(--accent-light), #e84393, #00cec9);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.home-hero-subtitle {
    font-size: 17px;
    line-height: 1.7;
    color: var(--text-secondary);
    margin-bottom: 32px;
    max-width: 480px;
}

.home-hero-actions {
    display: flex;
    gap: 16px;
    margin-bottom: 48px;
    flex-wrap: wrap;
}

.home-btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 14px 32px;
    background: linear-gradient(135deg, var(--accent), var(--accent-light));
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    text-decoration: none;
    border-radius: 14px;
    transition: all 0.3s ease;
    box-shadow: 0 6px 25px var(--accent-glow);
}

.home-btn-primary:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 40px var(--accent-glow);
}

.home-btn-primary i {
    transition: transform 0.3s ease;
}

.home-btn-primary:hover i {
    transform: translateX(4px);
}

.home-btn-lg {
    padding: 18px 40px;
    font-size: 16px;
    border-radius: 16px;
}

.home-btn-secondary {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 14px 28px;
    background: var(--surface);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    font-size: 15px;
    font-weight: 500;
    text-decoration: none;
    border-radius: 14px;
    transition: all 0.3s ease;
}

.home-btn-secondary:hover {
    background: var(--surface-hover);
    border-color: var(--glass-shine);
    transform: translateY(-2px);
}

.home-hero-stats {
    display: flex;
    align-items: center;
    gap: 24px;
}

.home-stat {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.home-stat-number {
    font-size: 22px;
    font-weight: 800;
    color: var(--text-primary);
}

.home-stat-label {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.home-stat-divider {
    width: 1px;
    height: 36px;
    background: var(--glass-border);
}

/* Hero Visual / Image */

.home-hero-visual {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

.home-hero-image-wrapper {
    position: relative;
    width: 100%;
    max-width: 460px;
    border-radius: 24px;
    overflow: hidden;
    box-shadow:
        0 0 0 1px var(--glass-border),
        0 25px 70px rgba(0, 0, 0, 0.6),
        0 0 100px rgba(108, 92, 231, 0.15);
}

.home-hero-img {
    width: 100%;
    height: 520px;
    object-fit: cover;
    display: block;
    filter: brightness(0.85) saturate(1.1);
}

.home-hero-image-glow {
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, transparent 50%, rgba(10, 10, 15, 0.8) 100%);
    pointer-events: none;
}

.home-float-card {
    position: absolute;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    background: rgba(18, 18, 26, 0.9);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 14px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
    animation: homeCardFloat 6s ease-in-out infinite;
    white-space: nowrap;
}

.home-float-card i {
    font-size: 16px;
}

.home-float-card-1 {
    top: 10%;
    left: -30px;
    animation-delay: 0s;
}

.home-float-card-1 i {
    color: #ff6b6b;
}

.home-float-card-2 {
    bottom: 25%;
    right: -20px;
    animation-delay: -2s;
}

.home-float-card-2 i {
    color: #00d2a0;
}

.home-float-card-3 {
    bottom: 8%;
    left: 10%;
    animation-delay: -4s;
}

.home-float-card-3 i {
    color: #fdcb6e;
}

@keyframes homeCardFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

/* ─── Sections shared ─── */

.home-section-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 32px;
}

.home-section-header {
    text-align: center;
    margin-bottom: 56px;
}

.home-section-badge {
    display: inline-block;
    padding: 6px 16px;
    background: rgba(108, 92, 231, 0.12);
    border: 1px solid rgba(108, 92, 231, 0.25);
    border-radius: 50px;
    font-size: 12px;
    font-weight: 600;
    color: var(--accent-light);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: 16px;
}

.home-section-title {
    font-size: clamp(28px, 3.5vw, 42px);
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -1px;
    margin-bottom: 12px;
}

.home-section-subtitle {
    font-size: 16px;
    color: var(--text-secondary);
    max-width: 540px;
    margin: 0 auto;
    line-height: 1.6;
}

/* ─── Features Section ─── */

.home-features {
    padding: 100px 0;
    position: relative;
}

.home-features::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--glass-border), transparent);
}

.home-features-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
}

.home-feature-card {
    padding: 36px 28px;
    background: linear-gradient(
        135deg,
        rgba(255, 255, 255, 0.04) 0%,
        rgba(255, 255, 255, 0.01) 100%
    );
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    transition: all 0.4s ease;
    position: relative;
    overflow: hidden;
}

.home-feature-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--glass-shine), transparent);
    opacity: 0;
    transition: opacity 0.4s ease;
}

.home-feature-card:hover {
    transform: translateY(-6px);
    border-color: var(--glass-shine);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.home-feature-card:hover::before {
    opacity: 1;
}

.home-feature-icon {
    width: 56px;
    height: 56px;
    border-radius: 16px;
    background: rgba(108, 92, 231, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    color: var(--icon-color, var(--accent));
    margin-bottom: 20px;
    transition: all 0.3s ease;
}

.home-feature-card:hover .home-feature-icon {
    transform: scale(1.1);
    box-shadow: 0 0 30px rgba(108, 92, 231, 0.2);
}

.home-feature-card h3 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 10px;
}

.home-feature-card p {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.6;
}

/* ─── Showcase Section ─── */

.home-showcase {
    padding: 100px 0;
}

.home-showcase-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 64px;
    align-items: center;
    margin-bottom: 80px;
}

.home-showcase-row:last-child {
    margin-bottom: 0;
}

.home-showcase-row-reverse {
    direction: rtl;
}

.home-showcase-row-reverse > * {
    direction: ltr;
}

.home-showcase-image {
    position: relative;
    border-radius: 20px;
    overflow: hidden;
    box-shadow:
        0 0 0 1px var(--glass-border),
        0 20px 60px rgba(0, 0, 0, 0.5);
}

.home-showcase-img {
    width: 100%;
    height: 340px;
    object-fit: cover;
    display: block;
    filter: brightness(0.8) saturate(1.2);
    transition: transform 0.6s ease;
}

.home-showcase-image:hover .home-showcase-img {
    transform: scale(1.05);
}

.home-showcase-img-glow {
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(108, 92, 231, 0.1), transparent);
    pointer-events: none;
}

.home-showcase-text h2 {
    margin-bottom: 16px;
}

.home-showcase-text p {
    font-size: 15px;
    color: var(--text-secondary);
    line-height: 1.7;
    margin-bottom: 24px;
}

.home-check-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.home-check-list li {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    color: var(--text-secondary);
}

.home-check-list li i {
    color: var(--success);
    font-size: 16px;
}

/* ─── Gallery Section ─── */

.home-gallery {
    padding: 100px 0;
    position: relative;
}

.home-gallery::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--glass-border), transparent);
}

.home-gallery-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: auto auto;
    gap: 16px;
}

.home-gallery-item {
    position: relative;
    border-radius: 16px;
    overflow: hidden;
    cursor: pointer;
    box-shadow: 0 0 0 1px var(--glass-border);
}

.home-gallery-item img {
    width: 100%;
    height: 220px;
    object-fit: cover;
    display: block;
    filter: brightness(0.7) saturate(1.2);
    transition: all 0.5s ease;
}

.home-gallery-item:hover img {
    transform: scale(1.08);
    filter: brightness(0.85) saturate(1.3);
}

.home-gallery-large {
    grid-column: span 2;
}

.home-gallery-large img {
    height: 280px;
}

.home-gallery-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, transparent 40%, rgba(10, 10, 15, 0.85) 100%);
    display: flex;
    align-items: flex-end;
    padding: 20px;
    pointer-events: none;
}

.home-gallery-overlay span {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

/* ─── CTA Section ─── */

.home-cta {
    padding: 100px 0;
}

.home-cta-card {
    position: relative;
    padding: 80px 40px;
    background: linear-gradient(
        135deg,
        rgba(108, 92, 231, 0.12) 0%,
        rgba(232, 67, 147, 0.08) 100%
    );
    border: 1px solid rgba(108, 92, 231, 0.2);
    border-radius: 32px;
    overflow: hidden;
    text-align: center;
}

.home-cta-bg {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
}

.home-orb-cta-1 {
    width: 300px;
    height: 300px;
    background: var(--accent);
    top: -30%;
    right: -5%;
    filter: blur(100px);
    opacity: 0.25;
}

.home-orb-cta-2 {
    width: 250px;
    height: 250px;
    background: #e84393;
    bottom: -30%;
    left: -5%;
    filter: blur(100px);
    opacity: 0.2;
}

.home-cta-content {
    position: relative;
    z-index: 1;
}

.home-cta-content h2 {
    font-size: clamp(28px, 4vw, 40px);
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 16px;
    letter-spacing: -1px;
}

.home-cta-content p {
    font-size: 16px;
    color: var(--text-secondary);
    margin-bottom: 32px;
    line-height: 1.6;
}

/* ─── Footer ─── */

.home-footer {
    padding: 32px 0;
    border-top: 1px solid var(--glass-border);
}

.home-footer-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.home-footer-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
}

.home-footer-brand .home-brand-icon {
    width: 34px;
    height: 34px;
    font-size: 14px;
    border-radius: 10px;
}

.home-footer-text {
    font-size: 13px;
    color: var(--text-muted);
}

/* ─── Animations ─── */

.home-animate {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.7s ease, transform 0.7s ease;
}

.home-visible {
    opacity: 1;
    transform: translateY(0);
}

.home-feature-card.home-animate:nth-child(2) { transition-delay: 0.1s; }
.home-feature-card.home-animate:nth-child(3) { transition-delay: 0.2s; }
.home-feature-card.home-animate:nth-child(4) { transition-delay: 0.3s; }
.home-feature-card.home-animate:nth-child(5) { transition-delay: 0.4s; }
.home-feature-card.home-animate:nth-child(6) { transition-delay: 0.5s; }

/* ─── Language Dropdown ─── */

.home-lang-dropdown {
    position: relative;
}

.home-lang-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: var(--surface);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
}

.home-lang-btn:hover {
    color: var(--text-primary);
    background: var(--surface-hover);
    border-color: var(--glass-shine);
}

.home-lang-arrow {
    font-size: 10px;
    transition: transform 0.3s ease;
}

.home-lang-menu.open + .home-lang-btn .home-lang-arrow,
.home-lang-btn:focus .home-lang-arrow {
    transform: rotate(180deg);
}

.home-lang-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 160px;
    background: rgba(18, 18, 26, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 6px;
    display: none;
    flex-direction: column;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.5);
    z-index: 1001;
}

.home-lang-menu.open {
    display: flex;
}

.home-lang-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s ease;
    font-family: inherit;
    text-align: left;
    width: 100%;
}

.home-lang-option:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
}

.home-lang-option.active {
    color: var(--accent-light);
    background: rgba(108, 92, 231, 0.1);
}

.home-mobile-lang {
    display: flex;
    gap: 4px;
    padding: 8px 16px;
    flex-wrap: wrap;
}

.home-mobile-lang .home-lang-option {
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid var(--glass-border);
    width: auto;
    font-size: 12px;
}

.home-mobile-lang .home-lang-option.active {
    border-color: var(--accent);
}

/* ─── Homepage Responsive ─── */

@media (max-width: 1024px) {
    .home-hero-content {
        grid-template-columns: 1fr;
        gap: 48px;
        text-align: center;
    }

    .home-hero-subtitle {
        margin: 0 auto 32px;
    }

    .home-hero-actions {
        justify-content: center;
    }

    .home-hero-stats {
        justify-content: center;
    }

    .home-hero-visual {
        max-width: 400px;
        margin: 0 auto;
    }

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

    .home-showcase-row,
    .home-showcase-row-reverse {
        grid-template-columns: 1fr;
        gap: 32px;
    }

    .home-showcase-row-reverse {
        direction: ltr;
    }
}

@media (max-width: 768px) {
    .home-nav-links {
        display: none;
    }

    .home-mobile-toggle {
        display: block;
    }

    .home-mobile-menu {
        display: flex;
    }

    .home-hero {
        padding: 100px 0 60px;
    }

    .home-hero-title {
        font-size: 36px;
        letter-spacing: -1px;
    }

    .home-features-grid {
        grid-template-columns: 1fr;
    }

    .home-gallery-grid {
        grid-template-columns: 1fr 1fr;
    }

    .home-gallery-large {
        grid-column: span 2;
    }

    .home-float-card {
        display: none;
    }

    .home-hero-img {
        height: 360px;
    }

    .home-footer-content {
        flex-direction: column;
        gap: 12px;
        text-align: center;
    }

    .home-cta-card {
        padding: 48px 24px;
    }
}

@media (max-width: 480px) {
    .home-hero-stats {
        flex-direction: column;
        gap: 16px;
    }

    .home-stat-divider {
        width: 40px;
        height: 1px;
    }

    .home-gallery-grid {
        grid-template-columns: 1fr;
    }

    .home-gallery-large {
        grid-column: span 1;
    }

    .home-gallery-large img,
    .home-gallery-item img {
        height: 200px;
    }

    .home-hero-actions {
        flex-direction: column;
        align-items: center;
    }
}

/* ==========================================
   TFA Styles
   ========================================== */

/* TFA shield icons in users table */
.tfa-cell {
    text-align: center;
}

.tfa-icon {
    font-size: 1.1rem;
    transition: var(--transition);
}

.tfa-icon.tfa-on {
    color: var(--success);
    filter: drop-shadow(0 0 4px rgba(0, 210, 160, 0.4));
}

.tfa-icon.tfa-off {
    color: var(--text-muted);
    opacity: 0.4;
}

/* TFA Section in Personal Settings Modal */
.tfa-section {
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--glass-border);
}

.tfa-section-header h4 {
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 600;
    margin: 0 0 16px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.tfa-section-header h4 i {
    color: var(--accent-light);
}

.tfa-status-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.tfa-status-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.tfa-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: var(--radius-xs);
    font-size: 0.85rem;
    font-weight: 500;
}

.tfa-badge-off {
    background: rgba(122, 122, 149, 0.15);
    color: var(--text-muted);
}

.tfa-badge-on {
    background: rgba(0, 210, 160, 0.15);
    color: var(--success);
}

.btn-sm {
    padding: 8px 16px;
    font-size: 0.85rem;
}

/* TFA Setup / QR Code area */
.tfa-setup-content {
    margin-top: 16px;
    padding: 20px;
    background: var(--surface);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
}

.tfa-setup-content p {
    color: var(--text-secondary);
    margin: 0 0 12px 0;
    font-size: 0.9rem;
}

.tfa-qr-wrapper {
    display: flex;
    justify-content: center;
    margin: 16px 0;
}

.tfa-qr-img {
    width: 200px;
    height: 200px;
    border-radius: var(--radius-sm);
    background: #fff;
    padding: 8px;
}

.tfa-secret-display {
    text-align: center;
    margin-bottom: 16px;
}

.tfa-secret-display small {
    display: block;
    color: var(--text-muted);
    margin-bottom: 6px;
    font-size: 0.8rem;
}

.tfa-secret-code {
    display: inline-block;
    padding: 6px 16px;
    background: rgba(108, 92, 231, 0.1);
    border: 1px solid var(--accent);
    border-radius: var(--radius-xs);
    color: var(--accent-light);
    font-family: 'Courier New', monospace;
    font-size: 0.95rem;
    letter-spacing: 2px;
    user-select: all;
}

.tfa-setup-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 16px;
}

/* TFA Login Page styles */
.tfa-login-header {
    text-align: center;
    margin-bottom: 24px;
}

.tfa-login-icon {
    font-size: 3rem;
    color: var(--accent-light);
    margin-bottom: 12px;
    display: block;
    filter: drop-shadow(0 0 12px var(--accent-glow));
}

.tfa-login-header h2 {
    color: var(--text-primary);
    font-size: 1.3rem;
    font-weight: 600;
    margin: 0 0 8px 0;
}

.tfa-login-header p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin: 0;
}

#tfaLoginCode {
    text-align: center;
    font-size: 1.5rem;
    letter-spacing: 8px;
    font-family: 'Courier New', monospace;
}

.btn-back-login {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 16px;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.85rem;
    transition: var(--transition);
    width: 100%;
}

.btn-back-login:hover {
    color: var(--text-primary);
}

/* ==========================================
   WebRTC Call Styles
   ========================================== */

/* Chat header call buttons */
.chat-header-actions {
    display: flex;
    gap: 8px;
    margin-left: auto;
}

.chat-call-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--surface);
    border: 1px solid var(--glass-border);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    font-size: 0.85rem;
}

.chat-call-btn:hover {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
    transform: scale(1.1);
}

/* ── SIP Call Overlay ── */
.sip-call-overlay {
    position: fixed;
    inset: 0;
    z-index: 10001;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}
.sip-call-overlay.show {
    display: flex;
}
.sip-call-container {
    background: var(--card-bg, #1e293b);
    border-radius: 24px;
    padding: 40px 36px 32px;
    min-width: 320px;
    max-width: 360px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
    animation: sipSlideUp 0.3s ease;
}
@keyframes sipSlideUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}
.sip-call-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent, #6366f1), #8b5cf6);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
    font-size: 2rem;
    font-weight: 700;
    color: #fff;
    position: relative;
}
.sip-call-overlay.show .sip-call-avatar::after {
    content: '';
    position: absolute;
    inset: -6px;
    border-radius: 50%;
    border: 2px solid var(--accent, #6366f1);
    animation: sipPulse 2s ease-in-out infinite;
}
@keyframes sipPulse {
    0%, 100% { opacity: 0.3; transform: scale(1); }
    50% { opacity: 0.8; transform: scale(1.08); }
}
.sip-call-peer-name {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary, #f1f5f9);
    margin-bottom: 4px;
}
.sip-call-peer-number {
    font-size: 0.9rem;
    color: var(--text-secondary, #94a3b8);
    margin-bottom: 12px;
}
.sip-call-status {
    font-size: 0.85rem;
    color: var(--accent, #6366f1);
    margin-bottom: 8px;
    min-height: 1.2em;
}
.sip-call-timer {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary, #f1f5f9);
    font-variant-numeric: tabular-nums;
    margin-bottom: 8px;
}
.sip-call-actions {
    display: flex;
    justify-content: center;
    gap: 24px;
    margin-top: 24px;
}
.sip-call-btn {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    transition: transform 0.15s, box-shadow 0.15s;
}
.sip-call-btn:hover {
    transform: scale(1.1);
}
.sip-call-btn-hangup {
    background: #ef4444;
    color: #fff;
    box-shadow: 0 4px 14px rgba(239, 68, 68, 0.4);
}
.sip-call-btn-hangup:hover {
    background: #dc2626;
}
.sip-call-btn-mute {
    background: var(--card-bg-hover, #334155);
    color: var(--text-primary, #f1f5f9);
    border: 1px solid var(--border, #334155);
}
.sip-call-btn-mute.muted {
    background: #f59e0b;
    color: #fff;
    border-color: #f59e0b;
}
.settings-divider {
    border-top: 1px solid var(--border, #334155);
    margin: 20px 0;
}
.settings-sub-header {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary, #f1f5f9);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}
/* Call Overlay */
.call-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
}

.call-overlay.show {
    display: flex;
}

.call-overlay-bg {
    position: absolute;
    inset: 0;
    background: rgba(10, 10, 15, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.call-container {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 32px;
    width: 100%;
    max-width: 480px;
    padding: 40px 24px;
    min-height: 100vh;
    min-height: 100dvh;
}

/* Avatar area (voice calls + ringing/calling) */
.call-avatar-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.call-type-icon {
    font-size: 1.2rem;
    color: var(--accent-light);
    margin-bottom: 8px;
}

.call-peer-avatar {
    position: relative;
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--accent-light));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    font-weight: 700;
    color: #fff;
}

.call-avatar-pulse {
    position: absolute;
    inset: -8px;
    border-radius: 50%;
    border: 2px solid var(--accent-light);
    opacity: 0;
    animation: callPulse 2s ease-out infinite;
}

@keyframes callPulse {
    0% { transform: scale(0.95); opacity: 0.5; }
    100% { transform: scale(1.15); opacity: 0; }
}

.call-overlay[data-state="active"] .call-avatar-pulse {
    animation: none;
    opacity: 0;
}

.call-peer-name {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
}

.call-status {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.call-timer {
    font-size: 1.1rem;
    color: var(--accent-light);
    font-variant-numeric: tabular-nums;
    min-height: 1.4em;
}

/* Video area */
.call-video-area {
    position: fixed;
    inset: 0;
    z-index: 1;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.call-remote-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.call-local-video {
    position: absolute;
    bottom: 120px;
    right: 20px;
    width: 140px;
    height: 105px;
    border-radius: var(--radius-sm);
    border: 2px solid var(--glass-border);
    object-fit: cover;
    z-index: 2;
    background: #111;
}

.call-video-info {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 3;
    padding: 6px 16px;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 20px;
    color: var(--text-primary);
    font-size: 0.9rem;
}

/* Call Action Buttons */
.call-actions {
    display: flex;
    align-items: center;
    gap: 24px;
    z-index: 5;
}

.call-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    color: #fff;
    transition: var(--transition);
}

.call-btn:hover {
    transform: scale(1.1);
}

.call-btn-accept {
    background: var(--success);
    box-shadow: 0 4px 20px rgba(0, 210, 160, 0.4);
}

.call-btn-reject,
.call-btn-hangup {
    background: var(--danger);
    box-shadow: 0 4px 20px rgba(255, 107, 107, 0.4);
}

.call-btn-control {
    background: var(--surface);
    border: 1px solid var(--glass-border);
    width: 50px;
    height: 50px;
    font-size: 1.1rem;
    color: var(--text-primary);
}

.call-btn-control:hover {
    background: var(--surface-hover);
}

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

.call-btn-hangup-lg {
    width: 72px;
    height: 72px;
    font-size: 1.5rem;
}

/* Ensure call actions are always on top in video mode */
.call-active-actions,
.call-calling-actions,
.call-incoming-actions {
    position: relative;
    z-index: 10;
}

/* Incoming call animations */
.call-overlay[data-state="ringing"] .call-peer-avatar {
    animation: callBounce 1s ease-in-out infinite;
}

@keyframes callBounce {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.call-overlay[data-state="calling"] .call-status {
    animation: callingDots 1.5s infinite;
}

@keyframes callingDots {
    0% { opacity: 0.3; }
    50% { opacity: 1; }
    100% { opacity: 0.3; }
}

/* Mobile responsive for calls */
@media (max-width: 768px) {
    .call-local-video {
        width: 100px;
        height: 75px;
        bottom: 140px;
        right: 12px;
    }

    .call-peer-avatar {
        width: 100px;
        height: 100px;
        font-size: 2.5rem;
    }

    .call-btn {
        width: 54px;
        height: 54px;
        font-size: 1.1rem;
    }

    .call-btn-control {
        width: 46px;
        height: 46px;
        font-size: 1rem;
    }
}

/* ==========================================
   Notifications Page
   ========================================== */
.notif-status-red {
    color: #ef4444;
}

.notif-status-yellow {
    color: #f59e0b;
}

.notif-status-green {
    color: #22c55e;
}

.notif-status-red .fa-circle-exclamation,
.notif-status-yellow .fa-triangle-exclamation,
.notif-status-green .fa-circle-check {
    font-size: 1.1rem;
}

.notif-type-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: capitalize;
}

.notif-type-notification {
    background: rgba(99, 102, 241, 0.15);
    color: var(--accent-light);
}

.notif-type-manual {
    background: rgba(34, 197, 94, 0.15);
    color: #22c55e;
}

.notif-map-btn {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    border: 1px solid var(--glass-border);
    background: var(--glass-bg);
    color: var(--accent-light);
    cursor: pointer;
    transition: all var(--transition-speed);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
}

.notif-map-btn:hover {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
    transform: scale(1.08);
}

.notif-map-btn-disabled {
    color: var(--text-muted);
    opacity: 0.35;
    cursor: not-allowed;
}

.notif-map-btn-disabled:hover {
    background: var(--glass-bg);
    color: var(--text-muted);
    border-color: var(--glass-border);
    transform: none;
}

#notifTable td:first-child,
#notifTable th:first-child {
    width: 50px;
    text-align: center;
}

#notifTable td:last-child,
#notifTable th:last-child {
    width: 70px;
    text-align: center;
}

.table-empty {
    text-align: center;
    padding: 40px 16px;
    color: var(--text-muted);
    font-style: italic;
}

/* Notifications header with summary badges */
.notif-page-header {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

.notif-pagesize-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
    flex-shrink: 0;
}
.notif-pagesize-wrap label {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
}
.notif-pagesize-select {
    padding: 4px 8px;
    background: var(--surface);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 12px;
    font-family: inherit;
    cursor: pointer;
}

.notif-summary {
    display: flex;
    align-items: center;
    gap: 8px;
}

.notif-summary-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 18px;
    border-radius: 22px;
    border: 1px solid var(--glass-border);
    background: var(--glass-bg);
    color: var(--text-muted);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-speed);
    white-space: nowrap;
}

.notif-summary-btn i {
    font-size: 1.15rem;
}

.notif-summary-btn:hover {
    border-color: var(--text-secondary);
    color: var(--text-primary);
}

.notif-summary-btn.active {
    border-color: var(--accent);
    background: rgba(99, 102, 241, 0.15);
    color: var(--accent-light);
}

.notif-summary-green i { color: #22c55e; }
.notif-summary-yellow i { color: #f59e0b; }
.notif-summary-red i { color: #ef4444; }

.notif-summary-green.active {
    border-color: #22c55e;
    background: rgba(34, 197, 94, 0.15);
    color: #22c55e;
}

.notif-summary-yellow.active {
    border-color: #f59e0b;
    background: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
}

.notif-summary-red.active {
    border-color: #ef4444;
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

.notif-summary-count {
    background: rgba(255, 255, 255, 0.08);
    padding: 1px 8px;
    border-radius: 10px;
    font-size: 0.78rem;
    min-width: 20px;
    text-align: center;
}

.notif-device-name {
    display: block;
    font-weight: 600;
    color: var(--text-primary);
}

.notif-device-id {
    display: block;
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 1px;
}

/* Users button in notification table */
.notif-users-btn {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    border: 1px solid var(--glass-border);
    background: var(--glass-bg);
    color: var(--accent-light);
    cursor: pointer;
    transition: all var(--transition-speed);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    position: relative;
}

.notif-users-btn:hover {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
    transform: scale(1.08);
}

.notif-users-btn-disabled {
    color: var(--text-muted);
    opacity: 0.35;
    cursor: not-allowed;
}

.notif-users-btn-disabled:hover {
    background: var(--glass-bg);
    color: var(--text-muted);
    border-color: var(--glass-border);
    transform: none;
}

.notif-users-count {
    position: absolute;
    top: -6px;
    right: -6px;
    background: var(--accent);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    min-width: 16px;
    height: 16px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    line-height: 1;
}

/* Users modal content */
.notif-users-device-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    padding: 0 4px 12px;
    border-bottom: 1px solid var(--glass-border);
    margin-bottom: 12px;
}

.notif-users-device-label i {
    color: var(--accent-light);
    margin-right: 6px;
}

.notif-users-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 400px;
    overflow-y: auto;
}

.notif-user-card {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 14px 16px !important;
    margin: 0 !important;
}

.notif-user-avatar {
    font-size: 2rem;
    color: var(--accent-light);
    line-height: 1;
    flex-shrink: 0;
}

.notif-user-info {
    flex: 1;
    min-width: 0;
}

.notif-user-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    align-self: center;
}

.notif-user-call-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(108, 92, 231, 0.12) !important;
    color: var(--accent-light) !important;
    border: 1px solid rgba(108, 92, 231, 0.28);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    cursor: pointer;
}

.notif-user-call-btn:hover {
    background: var(--accent) !important;
    color: #fff !important;
    border-color: var(--accent);
    transform: scale(1.06);
    box-shadow: 0 4px 12px var(--accent-glow);
}

.notif-user-call-btn i {
    font-size: 0.95rem;
}

.notif-user-name {
    font-weight: 700;
    font-size: 1rem;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.notif-user-role {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 2px 8px;
    border-radius: 10px;
    background: rgba(99, 102, 241, 0.15);
    color: var(--accent-light);
    margin-bottom: 6px;
}

.notif-user-detail {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

.notif-user-detail i {
    width: 18px;
    color: var(--text-muted);
    margin-right: 6px;
    font-size: 0.8rem;
}

.notif-users-empty {
    text-align: center;
    color: var(--text-muted);
    padding: 24px;
    font-size: 0.9rem;
}

/* Utility */
.text-center,
.data-table th.text-center,
.data-table td.text-center { text-align: center !important; }

/* Battery level in notification table */
.notif-battery {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
}

.notif-battery i {
    font-size: 1rem;
}

.notif-battery-na {
    color: var(--text-muted);
    opacity: 0.4;
}

/* Delete button in notification table */
.notif-delete-btn {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    border: 1px solid var(--glass-border);
    background: var(--glass-bg);
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition-speed);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
}

.notif-delete-btn:hover,
.notif-delete-btn:active {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
    border-color: #ef4444;
    transform: scale(1.08);
}

/* Delete confirmation modal */
.notif-delete-body {
    padding: 8px 4px 16px;
    font-size: 0.95rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

.notif-delete-body strong {
    color: var(--text-primary);
}

.notif-delete-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding-top: 8px;
    border-top: 1px solid var(--glass-border);
}

/* ==========================================
   Manual Page
   ========================================== */
.manual-search-wrapper {
    position: relative;
    flex-shrink: 0;
}

.manual-search-wrapper i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.85rem;
}

.manual-search-wrapper input {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    padding: 8px 12px 8px 34px;
    color: var(--text-primary);
    font-size: 0.85rem;
    width: 260px;
    outline: none;
    transition: border-color var(--transition-speed);
}

.manual-search-wrapper input:focus {
    border-color: var(--accent);
}

.manual-layout {
    display: flex;
    gap: 24px;
    align-items: flex-start;
}

.manual-sidebar {
    position: sticky;
    top: 24px;
    width: 260px;
    flex-shrink: 0;
    padding: 20px !important;
}

.manual-sidebar h4 {
    margin: 0 0 14px;
    font-size: 0.9rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.manual-index {
    list-style: none;
    padding: 0;
    margin: 0;
    counter-reset: manual-idx;
}

.manual-index li {
    counter-increment: manual-idx;
}

.manual-index li a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.84rem;
    transition: all var(--transition-speed);
}

.manual-index li a:hover {
    background: rgba(99, 102, 241, 0.1);
    color: var(--accent-light);
}

.manual-index li a i {
    width: 18px;
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.manual-index li a:hover i {
    color: var(--accent-light);
}

.manual-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.manual-section {
    padding: 28px !important;
    scroll-margin-top: 20px;
    transition: box-shadow 0.4s ease;
}

.manual-section.manual-highlight {
    box-shadow: 0 0 0 2px var(--accent), 0 0 20px rgba(99, 102, 241, 0.25);
}

.manual-section h3 {
    font-size: 1.2rem;
    margin: 0 0 4px;
    color: var(--text-primary);
    display: inline;
}

.manual-section h3 i {
    color: var(--accent-light);
    margin-right: 6px;
}

.manual-admin-badge {
    display: inline-block;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 3px 10px;
    border-radius: 10px;
    background: rgba(99, 102, 241, 0.15);
    color: var(--accent-light);
    margin-left: 10px;
    vertical-align: middle;
}

.manual-section p {
    color: var(--text-secondary);
    line-height: 1.7;
    margin: 16px 0;
    font-size: 0.92rem;
}

.manual-section h4 {
    font-size: 0.9rem;
    color: var(--text-primary);
    margin: 20px 0 10px;
}

.manual-section ul {
    margin: 0;
    padding-left: 20px;
}

.manual-section ul li {
    color: var(--text-secondary);
    font-size: 0.88rem;
    line-height: 1.8;
    padding: 2px 0;
}

/* Manual Screenshot Mockups */
.manual-screenshot {
    margin: 16px 0;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--glass-border);
}

.manual-mock {
    background: rgba(10, 10, 20, 0.6);
    padding: 20px;
    min-height: 140px;
    font-size: 0.78rem;
    color: var(--text-muted);
}

/* Login mockup */
.manual-mock-login {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 200px;
    background: linear-gradient(135deg, rgba(15, 10, 40, 0.8), rgba(20, 15, 50, 0.8));
}

.mock-card {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    padding: 28px 32px;
    width: 240px;
    text-align: center;
}

.mock-logo {
    font-size: 2rem;
    color: var(--accent-light);
    margin-bottom: 18px;
}

.mock-field {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    margin-bottom: 10px;
    text-align: left;
    color: var(--text-muted);
    font-size: 0.78rem;
}

.mock-field i {
    margin-right: 8px;
    color: var(--text-muted);
    width: 14px;
}

.mock-btn {
    background: var(--accent);
    color: #fff;
    border-radius: var(--radius-sm);
    padding: 8px 0;
    font-weight: 600;
    font-size: 0.8rem;
    margin-top: 6px;
}

/* Map mockup */
.manual-mock-map {
    padding: 0;
    min-height: 180px;
}

.mock-map-bg {
    background: linear-gradient(135deg, #1a2332, #162028, #1a2636);
    min-height: 180px;
    position: relative;
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.mock-map-bg::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        linear-gradient(90deg, rgba(99, 102, 241, 0.06) 1px, transparent 1px),
        linear-gradient(rgba(99, 102, 241, 0.06) 1px, transparent 1px);
    background-size: 40px 40px;
}

.mock-marker {
    position: absolute;
    color: #ef4444;
    font-size: 1.2rem;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
}

/* History mockup */
.manual-mock-history {
    padding: 0;
}

.mock-toolbar {
    display: flex;
    gap: 10px;
    align-items: center;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.02);
    border-bottom: 1px solid var(--glass-border);
    flex-wrap: wrap;
}

.mock-select, .mock-date, .mock-input {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    padding: 6px 12px;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.mock-select-sm {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    padding: 5px 10px;
    font-size: 0.72rem;
    color: var(--text-muted);
}

.mock-btn-sm {
    background: var(--accent);
    color: #fff;
    border-radius: var(--radius-sm);
    padding: 6px 14px;
    font-size: 0.75rem;
    font-weight: 600;
}

.mock-route {
    position: absolute;
    top: 25%;
    left: 20%;
    width: 60%;
    height: 50%;
    border: 2px dashed rgba(99, 102, 241, 0.4);
    border-radius: 40% 60% 50% 40%;
    transform: rotate(-5deg);
}

/* Table mockup */
.manual-mock-table {
    padding: 0;
}

.mock-table {
    padding: 0;
}

.mock-thead {
    padding: 10px 16px;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.03);
    border-bottom: 1px solid var(--glass-border);
    letter-spacing: 0.3px;
}

.mock-row {
    padding: 10px 16px;
    font-size: 0.75rem;
    color: var(--text-muted);
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.mock-row:last-child {
    border-bottom: none;
}

/* Badge mockups */
.mock-badge-green, .mock-badge-yellow, .mock-badge-red {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 12px;
    border-radius: 16px;
    font-size: 0.75rem;
    font-weight: 600;
}

.mock-badge-green {
    background: rgba(34, 197, 94, 0.15);
    color: #22c55e;
    border: 1px solid rgba(34, 197, 94, 0.3);
}

.mock-badge-yellow {
    background: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.mock-badge-red {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

/* Geofence mockup */
.manual-mock-geofence { padding: 0; }
.mock-geofence-layout {
    display: flex;
    height: 200px;
}
.mock-geofence-panel {
    width: 180px;
    background: rgba(255,255,255,0.03);
    border-right: 1px solid rgba(255,255,255,0.08);
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex-shrink: 0;
}
.mock-geofence-header {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    padding-bottom: 6px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}
.mock-geofence-item {
    font-size: 10px;
    color: var(--text-secondary);
    padding: 5px 8px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.mock-geofence-item.active {
    background: rgba(99,102,241,0.15);
    color: var(--text-primary);
}
.mock-gf-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}
.mock-gf-badge {
    margin-left: auto;
    font-size: 9px;
    opacity: 0.6;
}
.mock-polygon {
    position: absolute;
    border: 2px dashed;
    border-radius: 4px;
    background: rgba(255,255,255,0.05);
}

/* Geofence Report mockup */
.manual-mock-gf-report { padding: 0; }
.mock-gf-report-layout {
    display: flex;
    height: 220px;
}
.mock-gf-report-panel {
    width: 170px;
    background: rgba(255,255,255,0.03);
    border-right: 1px solid rgba(255,255,255,0.08);
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-shrink: 0;
    overflow: hidden;
}
.mock-gf-report-section {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.mock-gf-report-title {
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-secondary);
    letter-spacing: 0.04em;
    display: flex;
    align-items: center;
    gap: 5px;
}
.mock-gf-report-search {
    font-size: 9px;
    color: var(--text-secondary);
    background: rgba(255,255,255,0.04);
    padding: 4px 8px;
    border-radius: 4px;
    border: 1px solid rgba(255,255,255,0.06);
}
.mock-gf-report-device {
    font-size: 10px;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 2px 0;
}
.mock-gf-report-date {
    font-size: 9px;
    color: var(--text-primary);
    background: rgba(255,255,255,0.04);
    padding: 4px 8px;
    border-radius: 4px;
    border: 1px solid rgba(255,255,255,0.06);
    font-family: monospace;
}
.mock-gf-report-results {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    padding: 8px;
    gap: 6px;
}
.mock-pagination {
    display: flex;
    justify-content: center;
    gap: 4px;
    padding: 4px 0;
    font-size: 10px;
    color: var(--text-secondary);
}
.mock-pagination span {
    padding: 2px 6px;
    border-radius: 3px;
    cursor: default;
}
.mock-pagination span.active {
    background: var(--accent);
    color: #fff;
}

/* Chat mockup */
.manual-mock-chat {
    display: flex;
    padding: 0;
    min-height: 200px;
}

.mock-chat-sidebar {
    width: 140px;
    border-right: 1px solid var(--glass-border);
    padding: 10px;
    flex-shrink: 0;
}

.mock-chat-contact {
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.mock-chat-contact i {
    margin-right: 6px;
}

.mock-chat-contact.active {
    background: rgba(99, 102, 241, 0.15);
    color: var(--accent-light);
}

.mock-chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.mock-chat-header {
    padding: 10px 14px;
    border-bottom: 1px solid var(--glass-border);
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.mock-chat-header span {
    color: var(--text-muted);
    display: flex;
    gap: 12px;
}

.mock-chat-messages {
    flex: 1;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.mock-msg-left, .mock-msg-right {
    max-width: 70%;
    padding: 8px 12px;
    border-radius: 12px;
    font-size: 0.75rem;
}

.mock-msg-left {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-secondary);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.mock-msg-right {
    background: rgba(99, 102, 241, 0.2);
    color: var(--accent-light);
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.mock-chat-input {
    padding: 10px 14px;
    border-top: 1px solid var(--glass-border);
    font-size: 0.75rem;
    color: var(--text-muted);
}

.mock-chat-input i {
    margin-right: 8px;
    color: var(--accent-light);
}

/* ── Caretaker Customers mockup ── */
.manual-mock-caretaker { padding: 0; }
.mock-caretaker-layout { display: flex; height: 180px; }
.mock-caretaker-sidebar {
    width: 140px; flex-shrink: 0; border-right: 1px solid var(--glass-border);
    padding: 8px; display: flex; flex-direction: column; gap: 4px;
}
.mock-caretaker-customer {
    padding: 6px 8px; border-radius: 6px; font-size: 0.7rem; color: var(--text-secondary);
    display: flex; align-items: center; gap: 6px; cursor: default;
}
.mock-caretaker-customer.active {
    background: rgba(99, 102, 241, 0.15); color: var(--accent-light);
}
.mock-caretaker-customer i { font-size: 0.8rem; }
.mock-caretaker-main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.mock-caretaker-tabs {
    display: flex; gap: 0; border-bottom: 1px solid var(--glass-border);
    padding: 0 8px; flex-shrink: 0;
}
.mock-tab {
    padding: 7px 8px; font-size: 0.6rem; color: var(--text-muted);
    border-bottom: 2px solid transparent; display: flex; align-items: center; gap: 4px;
}
.mock-tab.active { color: var(--accent-light); border-bottom-color: var(--accent); }
.mock-tab i { font-size: 0.55rem; }
.mock-caretaker-content { flex: 1; padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.mock-med-card {
    display: flex; align-items: center; gap: 10px; padding: 8px 10px;
    border-radius: 8px; background: rgba(255,255,255,0.03); border: 1px solid var(--glass-border);
}
.mock-med-pill {
    width: 32px; height: 32px; border-radius: 8px; display: flex; align-items: center; justify-content: center;
    background: rgba(99, 102, 241, 0.15); color: var(--accent-light); font-size: 0.8rem;
}
.mock-med-info { flex: 1; display: flex; flex-direction: column; }
.mock-med-info strong { font-size: 0.7rem; color: var(--text-primary); }
.mock-med-info small { font-size: 0.6rem; color: var(--text-muted); }

/* ── Connectors mockup ── */
.manual-mock-connectors { padding: 0; }
.mock-connectors-layout { display: flex; height: 180px; }
.mock-connectors-sidebar {
    width: 150px; flex-shrink: 0; border-right: 1px solid var(--glass-border);
    padding: 8px; display: flex; flex-direction: column; gap: 2px;
}
.mock-connectors-item {
    padding: 6px 8px; border-radius: 6px; font-size: 0.65rem; color: var(--text-secondary);
    display: flex; align-items: center; gap: 6px; cursor: default;
}
.mock-connectors-item.active { background: rgba(99, 102, 241, 0.15); color: var(--accent-light); }
.mock-connectors-item i:first-child { width: 14px; text-align: center; font-size: 0.6rem; }
.mock-connectors-main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.mock-connectors-content { flex: 1; padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.mock-connectors-header {
    font-size: 0.75rem; color: var(--text-primary); display: flex; align-items: center; gap: 6px;
}
.mock-connectors-company {
    font-size: 0.65rem; color: var(--text-muted); display: flex; align-items: center; gap: 6px;
}
.mock-connectors-key {
    padding: 8px 10px; border-radius: 8px; background: rgba(255,255,255,0.03);
    border: 1px solid var(--glass-border); display: flex; flex-direction: column; gap: 4px;
}
.mock-connectors-key-row { display: flex; align-items: center; gap: 8px; font-size: 0.65rem; }
.mock-connectors-key-row small { color: var(--text-secondary); }

/* Manual responsive */
@media (max-width: 900px) {
    .manual-layout {
        flex-direction: column;
    }
    .manual-sidebar {
        position: static;
        width: 100%;
    }
}

/* ==========================================
   Geofence Page
   ========================================== */
#page-geofence.active {
    display: flex;
    flex-direction: column;
    height: calc(100vh - var(--topbar-height) - 56px);
    overflow: hidden;
}

#page-geofence .page-header {
    flex-shrink: 0;
    margin-bottom: 16px;
}

.geofence-layout {
    display: flex;
    gap: 16px;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.geofence-panel {
    width: 340px;
    min-width: 300px;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    flex-shrink: 0;
}

.geofence-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 18px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

.geofence-panel-header h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}

.geofence-panel-header .btn-sm {
    width: auto;
    padding: 4px 8px;
    font-size: 0.7rem;
    white-space: nowrap;
    gap: 3px;
}

.geofence-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

.geofence-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    color: var(--text-secondary);
    gap: 12px;
}

.geofence-empty i {
    font-size: 32px;
    opacity: 0.3;
}

.geofence-empty p {
    margin: 0;
    font-size: 13px;
}

.geofence-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    cursor: default;
    transition: background 0.15s;
}

.geofence-item:hover {
    background: rgba(255,255,255,0.03);
}

.geofence-item.geofence-inactive {
    opacity: 0.45;
}

.geofence-item-color {
    width: 10px;
    height: 36px;
    border-radius: 5px;
    flex-shrink: 0;
}

.geofence-item-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.geofence-item-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.geofence-item-meta {
    font-size: 11px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.geofence-item-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.geofence-item-actions .btn-icon {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    transition: all 0.15s;
}

.geofence-item-actions .btn-icon:hover {
    background: rgba(255,255,255,0.08);
    color: var(--text-primary);
}

.geofence-item-actions .geofence-delete-btn:hover {
    color: #ff6b6b;
    background: rgba(255,107,107,0.1);
}

/* ── Geofence form ── */
.geofence-form {
    border-top: 1px solid rgba(255,255,255,0.06);
    padding: 16px 18px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.geofence-form h4 {
    margin: 0 0 4px 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.geofence-form .form-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.geofence-form .form-group label {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.geofence-form .form-input {
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 8px;
    padding: 8px 12px;
    color: var(--text-primary);
    font-size: 13px;
    outline: none;
    transition: border-color 0.15s;
    font-family: inherit;
}

.geofence-form .form-input:focus {
    border-color: var(--accent);
}

.geofence-form textarea.form-input {
    resize: vertical;
    min-height: 48px;
}

.geofence-color-picker {
    display: flex;
    align-items: center;
    gap: 10px;
}

.geofence-color-input {
    width: 36px;
    height: 36px;
    border: 2px solid rgba(255,255,255,0.1);
    border-radius: 8px;
    background: transparent;
    cursor: pointer;
    padding: 2px;
}

.geofence-color-input::-webkit-color-swatch-wrapper {
    padding: 0;
}

.geofence-color-input::-webkit-color-swatch {
    border: none;
    border-radius: 4px;
}

#geofenceColorLabel {
    font-size: 12px;
    color: var(--text-secondary);
    font-family: 'Courier New', monospace;
}

.geofence-form-info {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 10px 12px;
    background: rgba(99,102,241,0.08);
    border: 1px solid rgba(99,102,241,0.15);
    border-radius: 8px;
    font-size: 12px;
    color: var(--accent-light);
    line-height: 1.4;
}

.geofence-form-info i {
    margin-top: 2px;
    flex-shrink: 0;
}

.geofence-linked-users {
    max-height: 180px;
    overflow-y: auto;
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    padding: 8px;
    background: rgba(255,255,255,0.03);
}
.geofence-user-group {
    margin-bottom: 6px;
}
.geofence-user-group-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: block;
    margin-bottom: 4px;
    padding-bottom: 2px;
    border-bottom: 1px solid var(--glass-border);
}
.geofence-user-check {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 3px 4px;
    font-size: 13px;
    color: var(--text-primary);
    cursor: pointer;
    border-radius: 4px;
}
.geofence-user-check:hover {
    background: rgba(255,255,255,0.05);
}
.geofence-user-check input[type="checkbox"] {
    accent-color: var(--accent);
    width: 14px;
    height: 14px;
}
.geofence-no-users {
    font-size: 12px;
    color: var(--text-secondary);
    padding: 8px;
}

.geofence-point-count {
    font-size: 12px;
    color: var(--text-secondary);
    min-height: 16px;
}

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

.geofence-form-actions .btn-cancel {
    padding: 8px 16px;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.1);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 13px;
    transition: all 0.15s;
}

.geofence-form-actions .btn-cancel:hover {
    background: rgba(255,255,255,0.05);
    color: var(--text-primary);
}

.geofence-form-actions .btn-primary {
    padding: 8px 20px;
    border-radius: 8px;
    border: none;
    background: var(--accent);
    color: #fff;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.15s;
}

.geofence-form-actions .btn-primary:hover {
    filter: brightness(1.15);
}

/* ── Geofence map ── */
.geofence-map-wrapper {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    position: relative;
}

.geofence-map-search {
    position: absolute;
    top: 12px;
    left: 12px;
    right: 60px;
    z-index: 1000;
    display: flex;
    align-items: center;
    background: rgba(30, 30, 40, 0.85);
    backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    padding: 0 4px 0 12px;
    max-width: 380px;
}
.geofence-map-search i:first-child {
    color: var(--text-secondary);
    font-size: 13px;
    flex-shrink: 0;
}
.geofence-map-search input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 13px;
    padding: 8px;
    outline: none;
    min-width: 0;
}
.geofence-map-search input::placeholder {
    color: var(--text-secondary);
}
.geofence-map-search-btn {
    background: var(--accent);
    border: none;
    color: #fff;
    width: 30px;
    height: 30px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    flex-shrink: 0;
    transition: background var(--transition);
}
.geofence-map-search-btn:hover {
    background: var(--accent-hover);
}
.geofence-search-marker {
    color: var(--accent);
    font-size: 24px;
    text-shadow: 0 2px 4px rgba(0,0,0,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
}

#geofenceMap {
    width: 100%;
    height: 100%;
    border-radius: 12px;
}

/* ── First point pulsing style ── */
.geofence-first-point {
    animation: geofence-pulse 1.5s ease-in-out infinite;
}

@keyframes geofence-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ── Toast notification ── */
.geofence-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    padding: 10px 24px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 500;
    z-index: 10000;
    opacity: 0;
    transition: all 0.3s ease;
    pointer-events: none;
}

.geofence-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.geofence-toast-success {
    background: rgba(0,210,160,0.9);
    color: #fff;
    backdrop-filter: blur(10px);
}

.geofence-toast-error {
    background: rgba(255,107,107,0.9);
    color: #fff;
    backdrop-filter: blur(10px);
}

/* ── Device Geofence Modal ── */
.device-geofence-modal {
    width: 500px;
    max-width: 95vw;
}
.device-geofence-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 12px;
}
.device-geofence-list {
    max-height: 350px;
    overflow-y: auto;
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    padding: 8px;
    background: rgba(255,255,255,0.03);
}
.device-geofence-group {
    margin-bottom: 6px;
}
.device-geofence-group-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: block;
    margin-bottom: 4px;
    padding-bottom: 2px;
    border-bottom: 1px solid var(--glass-border);
}
.device-geofence-check {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 6px;
    font-size: 13px;
    color: var(--text-primary);
    cursor: pointer;
    border-radius: 4px;
}
.device-geofence-check:hover {
    background: rgba(255,255,255,0.05);
}
.device-geofence-check input[type="checkbox"] {
    accent-color: var(--accent);
    width: 15px;
    height: 15px;
}
.device-geofence-color {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    flex-shrink: 0;
}
.device-geofence-empty {
    font-size: 13px;
    color: var(--text-secondary);
    padding: 16px;
    text-align: center;
}
.device-geofence-search-wrapper {
    position: relative;
    flex: 1;
}
.device-geofence-search-wrapper i {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    font-size: 12px;
}
.device-geofence-search-wrapper input {
    width: 100%;
    padding: 6px 10px 6px 30px;
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--glass-border);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 13px;
}
.device-geofence-search-wrapper input::placeholder {
    color: var(--text-secondary);
}
.device-geofence-toolbar {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 8px;
}
.btn-disabled {
    opacity: 0.35;
    cursor: not-allowed !important;
    pointer-events: auto;
}
.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid var(--glass-border);
}

/* ── Agenda Layout: calendar left, detail right ── */
.agenda-layout {
    display: flex;
    gap: 0;
    height: 100%;
    min-height: 0;
}
.agenda-calendar-wrap {
    padding: 12px;
    flex: 2;
    min-width: 0;
    border-right: 1px solid var(--glass-border);
    overflow-y: auto;
}
.agenda-cal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}
.agenda-cal-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
}
.agenda-cal-header .btn-icon {
    padding: 2px 4px;
    font-size: 10px;
}
.agenda-cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
}
.agenda-cal-day {
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s ease;
    position: relative;
    min-height: 26px;
    font-size: 11px;
}
.agenda-cal-day.header {
    font-size: 9px;
    font-weight: 600;
    color: var(--text-muted);
    cursor: default;
    aspect-ratio: auto;
    min-height: 18px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.agenda-cal-day.empty {
    cursor: default;
}
.agenda-cal-day:not(.empty):not(.header):hover {
    background: rgba(108, 92, 231, 0.15);
}
.agenda-cal-day.today .agenda-cal-num {
    background: var(--accent);
    color: #fff;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}
.agenda-cal-day.selected {
    background: rgba(108, 92, 231, 0.2);
    outline: 1px solid var(--accent);
}
.agenda-cal-day.has-entries .agenda-cal-num {
    font-weight: 600;
    color: var(--accent-light);
}
.agenda-cal-dots {
    display: flex;
    gap: 2px;
    margin-top: 1px;
}
.agenda-cal-dot {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--accent);
}

/* Day Detail — right side (33%) */
.agenda-day-detail {
    flex: 1;
    min-width: 0;
    padding: 12px;
    overflow-y: auto;
}
.btn-add-entry {
    width: 30px;
    height: 30px;
    padding: 0;
    font-size: 12px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.btn-add-entry span {
    display: none;
}
.agenda-day-detail-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    padding: 24px;
    gap: 8px;
    height: 100%;
}
.agenda-day-detail-empty i {
    font-size: 24px;
    opacity: 0.4;
}
.agenda-day-detail-empty.small {
    padding: 12px;
    height: auto;
}
.agenda-day-detail-empty.small i {
    display: none;
}
.agenda-day-detail-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}
.agenda-day-detail-header h4 {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

/* Entry Items */
.agenda-entries-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.agenda-entry-item {
    display: flex;
    gap: 10px;
    padding: 8px 10px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    align-items: flex-start;
    transition: background 0.15s ease;
}
.agenda-entry-item:hover {
    background: rgba(255, 255, 255, 0.07);
}
.agenda-entry-time {
    white-space: nowrap;
    font-size: 11px;
    color: var(--accent-light);
    font-weight: 500;
    min-width: 90px;
    padding-top: 1px;
}
.agenda-entry-time i {
    margin-right: 3px;
}
.agenda-entry-body {
    flex: 1;
    min-width: 0;
}
.agenda-entry-title {
    font-weight: 600;
    font-size: 12px;
    color: var(--text-primary);
    margin-bottom: 2px;
}
.agenda-entry-desc {
    font-size: 11px;
    color: var(--text-secondary);
    margin-bottom: 2px;
}
.agenda-entry-location {
    font-size: 10px;
    color: var(--text-muted);
    margin-bottom: 2px;
}
.agenda-entry-location i {
    margin-right: 3px;
    color: var(--accent);
}
.agenda-entry-caretaker {
    font-size: 10px;
    color: var(--text-muted);
}
.agenda-entry-caretaker i {
    margin-right: 3px;
}
.agenda-entry-actions {
    display: flex;
    gap: 2px;
    flex-shrink: 0;
}
.agenda-entry-actions .btn-icon {
    padding: 3px;
    font-size: 11px;
}
.agenda-entry-edit:hover {
    color: var(--accent-light) !important;
}
.agenda-entry-delete:hover {
    color: var(--danger) !important;
}

/* Agenda Entry Modal */
.agenda-entry-modal {
    width: 480px;
    max-width: 95vw;
}
.agenda-time-row {
    display: flex;
    gap: 12px;
}
.agenda-time-row .form-group {
    flex: 1;
}
.agenda-entry-modal textarea {
    width: 100%;
    padding: 10px 10px 10px 36px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
}
.agenda-entry-modal textarea::placeholder {
    color: var(--text-secondary);
}

/* ── Logbook ── */
.logbook-container {
    padding: 12px;
    height: 100%;
    display: flex;
    flex-direction: column;
}
.logbook-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    flex-shrink: 0;
}
.logbook-header h4 {
    margin: 0;
    font-size: 1rem;
    color: var(--text-primary);
}
.logbook-empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
}
.logbook-empty i {
    font-size: 2rem;
    margin-bottom: 10px;
    opacity: 0.4;
}
.logbook-entries {
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex: 1;
    overflow-y: auto;
}
.logbook-entry-card {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    padding: 14px;
    transition: background 0.15s ease;
}
.logbook-entry-card:hover {
    background: rgba(255, 255, 255, 0.07);
}
.logbook-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
    gap: 10px;
}
.logbook-card-datetime {
    font-size: 0.82rem;
    color: var(--accent-light);
    font-weight: 500;
}
.logbook-card-datetime i {
    margin-right: 4px;
}
.logbook-card-time {
    margin-left: 10px;
    color: var(--text-secondary);
}
.logbook-card-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}
.logbook-card-caretaker {
    font-size: 0.75rem;
    color: var(--text-secondary);
}
.logbook-card-caretaker i {
    margin-right: 3px;
}
.logbook-card-actions {
    display: flex;
    gap: 4px;
}
.logbook-card-actions .btn-icon {
    font-size: 0.75rem;
    padding: 4px 6px;
    opacity: 0.5;
    transition: opacity 0.15s;
}
.logbook-entry-card:hover .logbook-card-actions .btn-icon {
    opacity: 1;
}
.logbook-card-mood {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
    padding: 6px 10px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
}
.logbook-mood-emoji {
    font-size: 1.4rem;
}
.logbook-mood-label {
    font-weight: 500;
    font-size: 0.85rem;
    color: var(--text-primary);
}
.logbook-mood-note {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-style: italic;
}
.logbook-card-section {
    margin-bottom: 6px;
}
.logbook-card-section-label {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 3px;
}
.logbook-card-section-label i {
    margin-right: 4px;
}
.logbook-card-section-text {
    font-size: 0.85rem;
    color: var(--text-primary);
    white-space: pre-wrap;
    line-height: 1.5;
}
.logbook-card-important {
    background: rgba(239, 68, 68, 0.08);
    border-left: 3px solid #ef4444;
    padding: 8px 10px;
    border-radius: 0 6px 6px 0;
}
.logbook-card-important .logbook-card-section-label {
    color: #ef4444;
}
.logbook-card-files {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.logbook-card-file {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--glass-border);
    border-radius: 6px;
    font-size: 0.78rem;
    color: var(--accent-light);
    text-decoration: none;
    transition: background 0.15s;
}
.logbook-card-file:hover {
    background: rgba(255, 255, 255, 0.12);
}
.logbook-card-file .logbook-file-size {
    color: var(--text-secondary);
    font-size: 0.7rem;
}
.logbook-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid var(--glass-border);
    flex-shrink: 0;
}

/* Logbook Modal */
.logbook-entry-modal {
    width: 560px;
    max-width: 95vw;
    max-height: 90vh;
    overflow-y: auto;
}
.logbook-form-row {
    display: flex;
    gap: 12px;
}
.logbook-form-row .form-group {
    flex: 1;
}
.logbook-mood-picker {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 4px;
}
.logbook-mood-btn {
    width: 40px;
    height: 40px;
    border: 2px solid var(--glass-border);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.04);
    font-size: 1.3rem;
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
}
.logbook-mood-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: scale(1.1);
}
.logbook-mood-btn.active {
    border-color: var(--accent);
    background: rgba(var(--accent-rgb, 99, 102, 241), 0.15);
    transform: scale(1.15);
    box-shadow: 0 0 8px rgba(var(--accent-rgb, 99, 102, 241), 0.3);
}

/* File upload */
.logbook-file-upload {
    position: relative;
}
.logbook-file-upload input[type="file"] {
    position: absolute;
    width: 0;
    height: 0;
    opacity: 0;
}
.logbook-file-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px dashed var(--glass-border);
    border-radius: 8px;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.15s;
}
.logbook-file-label:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--accent);
    color: var(--accent-light);
}
.logbook-file-list {
    margin-top: 6px;
}
.logbook-file-item {
    font-size: 0.8rem;
    color: var(--text-secondary);
    padding: 3px 0;
}
.logbook-file-item i {
    margin-right: 4px;
    color: var(--accent-light);
}
.logbook-existing-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 600;
    margin-top: 8px;
    margin-bottom: 4px;
}
.logbook-existing-file {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    padding: 3px 0;
}
.logbook-existing-file i:first-child {
    color: var(--accent-light);
}
.logbook-existing-file .logbook-file-delete {
    font-size: 0.7rem;
    color: #ef4444;
    opacity: 0.6;
    padding: 2px 4px;
}
.logbook-existing-file .logbook-file-delete:hover {
    opacity: 1;
}
.logbook-entry-modal textarea {
    width: 100%;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 0.9rem;
    padding: 8px 12px 8px 36px;
    font-family: inherit;
    resize: vertical;
}
.logbook-entry-modal textarea::placeholder {
    color: var(--text-secondary);
}

/* ── Medical ── */
.medical-container {
    padding: 12px;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}
.medical-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    flex-shrink: 0;
}
.medical-header h4 { margin: 0; font-size: 1rem; color: var(--text-primary); }
.medical-reminders {
    background: rgba(245, 158, 11, 0.08);
    border: 1px solid rgba(245, 158, 11, 0.25);
    border-radius: 10px;
    padding: 12px;
    margin-bottom: 14px;
    flex-shrink: 0;
}
.medical-reminders-title {
    font-size: 0.82rem;
    font-weight: 600;
    color: #f59e0b;
    margin-bottom: 8px;
}
.medical-reminders-title i { margin-right: 5px; }
.medical-reminder-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 0;
    border-bottom: 1px solid rgba(245, 158, 11, 0.12);
}
.medical-reminder-item:last-child { border-bottom: none; }
.medical-reminder-time {
    font-size: 0.82rem;
    font-weight: 500;
    color: #f59e0b;
    white-space: nowrap;
}
.medical-reminder-name {
    flex: 1;
    font-size: 0.85rem;
    color: var(--text-primary);
}
.medical-reminder-name small { color: var(--text-secondary); }
.medical-section {
    margin-bottom: 16px;
}
.medical-section-title {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 8px;
}
.medical-section-title i { margin-right: 5px; }
.medical-section-inactive { opacity: 0.55; }
.medical-med-card {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    padding: 12px;
    margin-bottom: 8px;
    transition: background 0.15s;
}
.medical-med-card:hover { background: rgba(255, 255, 255, 0.07); }
.medical-med-inactive { border-style: dashed; }
.medical-med-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 6px;
    gap: 8px;
}
.medical-med-info { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.medical-med-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-primary);
}
.medical-med-name i { margin-right: 4px; color: var(--accent-light); }
.medical-med-dosage {
    font-size: 0.8rem;
    color: var(--accent-light);
    background: rgba(var(--accent-rgb, 99, 102, 241), 0.1);
    padding: 2px 8px;
    border-radius: 4px;
}
.medical-med-actions {
    display: flex;
    gap: 3px;
    flex-shrink: 0;
}
.medical-med-actions .btn-icon {
    font-size: 0.72rem;
    padding: 4px 5px;
    opacity: 0.4;
    transition: opacity 0.15s;
}
.medical-med-card:hover .medical-med-actions .btn-icon { opacity: 1; }
.medical-med-details {
    display: flex;
    gap: 14px;
    margin-bottom: 4px;
    flex-wrap: wrap;
}
.medical-med-freq, .medical-med-times {
    font-size: 0.78rem;
    color: var(--text-secondary);
}
.medical-med-freq i, .medical-med-times i { margin-right: 4px; }
.medical-med-instructions {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-style: italic;
    margin-bottom: 4px;
}
.medical-med-instructions i { margin-right: 4px; }
.medical-med-as-needed {
    font-size: 0.8rem;
    color: var(--accent-light);
    background: rgba(var(--accent-rgb, 99, 102, 241), 0.06);
    padding: 5px 8px;
    border-radius: 6px;
    margin-bottom: 4px;
}
.medical-med-as-needed i { margin-right: 4px; }
.medical-med-caretaker {
    font-size: 0.72rem;
    color: var(--text-secondary);
    margin-top: 4px;
}
.medical-med-caretaker i { margin-right: 3px; }
.medical-today-intakes {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    align-items: center;
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid var(--glass-border);
}
.medical-intakes-label {
    font-size: 0.72rem;
    color: var(--text-secondary);
    font-weight: 600;
}
.medical-intakes-label i { margin-right: 3px; }
.medical-intake-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.72rem;
    padding: 2px 8px;
    border-radius: 4px;
}
.medical-intake-taken { background: rgba(34, 197, 94, 0.12); color: #22c55e; }
.medical-intake-skipped { background: rgba(245, 158, 11, 0.12); color: #f59e0b; }
.medical-intake-refused { background: rgba(239, 68, 68, 0.12); color: #ef4444; }
.medical-intake-delete {
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    font-size: 0.85rem;
    opacity: 0.5;
    padding: 0 2px;
    line-height: 1;
}
.medical-intake-delete:hover { opacity: 1; }

/* Medical modal */
.medical-med-modal {
    width: 540px;
    max-width: 95vw;
    max-height: 90vh;
    overflow-y: auto;
}
.medical-med-modal textarea {
    width: 100%;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 0.9rem;
    padding: 8px 12px 8px 36px;
    font-family: inherit;
    resize: vertical;
}
.medical-med-modal textarea::placeholder { color: var(--text-secondary); }
.medical-checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    color: var(--text-primary);
    cursor: pointer;
}
.medical-checkbox-label input[type="checkbox"] {
    width: 16px; height: 16px;
    accent-color: var(--accent);
}
.medical-time-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
}
.medical-time-row .input-wrapper { margin-bottom: 0; }
.medical-time-remove { color: #ef4444; font-size: 0.8rem; }
.medical-status-picker {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
.medical-status-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 6px 12px;
    border: 2px solid var(--glass-border);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-secondary);
    font-size: 0.82rem;
    cursor: pointer;
    transition: all 0.15s;
}
.medical-status-btn:hover { background: rgba(255, 255, 255, 0.08); }
.medical-status-btn.active[data-status="taken"] { border-color: #22c55e; color: #22c55e; background: rgba(34, 197, 94, 0.1); }
.medical-status-btn.active[data-status="skipped"] { border-color: #f59e0b; color: #f59e0b; background: rgba(245, 158, 11, 0.1); }
.medical-status-btn.active[data-status="refused"] { border-color: #ef4444; color: #ef4444; background: rgba(239, 68, 68, 0.1); }
.medical-intake-med-name {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* ── Allergy ── */
.allergy-container {
    padding: 12px;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}
.allergy-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex: 1;
}
.allergy-card {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 16px;
    transition: background 0.15s;
}
.allergy-card:hover { background: rgba(255, 255, 255, 0.07); }
.allergy-card-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 10px;
}
.allergy-card-title-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.allergy-card-emoji { font-size: 1.5rem; }
.allergy-card-name {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-primary);
}
.allergy-confirmed-badge {
    font-size: 0.7rem;
    background: rgba(34, 197, 94, 0.12);
    color: #22c55e;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 500;
}
.allergy-confirmed-badge i { margin-right: 3px; }
.allergy-card-actions {
    display: flex;
    gap: 3px;
    flex-shrink: 0;
}
.allergy-card-actions .btn-icon {
    font-size: 0.72rem;
    padding: 4px 5px;
    opacity: 0.4;
    transition: opacity 0.15s;
}
.allergy-card:hover .allergy-card-actions .btn-icon { opacity: 1; }
.allergy-card-section {
    margin-bottom: 10px;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
}
.allergy-card-label {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 4px;
}
.allergy-card-label i { margin-right: 4px; }
.allergy-card-text {
    font-size: 0.85rem;
    color: var(--text-primary);
    white-space: pre-wrap;
    line-height: 1.6;
}
.allergy-card-confirmed-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    margin-bottom: 10px;
    font-size: 0.82rem;
    color: var(--text-primary);
}
.allergy-symptom-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 4px;
}
.allergy-symptom-tag {
    display: inline-block;
    padding: 3px 10px;
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: 12px;
    font-size: 0.78rem;
    color: #f87171;
}
.allergy-card-severity {
    margin-bottom: 8px;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
}
.allergy-severity-bar {
    height: 8px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 4px;
    overflow: hidden;
    margin: 6px 0 4px;
}
.allergy-severity-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.3s;
}
.allergy-severity-bar-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.65rem;
    color: var(--text-secondary);
}

/* Allergy modal */
.allergy-entry-modal {
    width: 560px;
    max-width: 95vw;
    max-height: 90vh;
    overflow-y: auto;
}
.allergy-entry-modal textarea {
    width: 100%;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 0.9rem;
    padding: 8px 12px 8px 36px;
    font-family: inherit;
    resize: vertical;
}
.allergy-entry-modal textarea::placeholder { color: var(--text-secondary); }
.allergy-emoji-picker {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}
.allergy-emoji-btn {
    width: 32px;
    height: 32px;
    border: 2px solid var(--glass-border);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.04);
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
}
.allergy-emoji-btn:hover { background: rgba(255, 255, 255, 0.1); transform: scale(1.1); }
.allergy-emoji-btn.active {
    border-color: var(--accent);
    background: rgba(var(--accent-rgb, 99, 102, 241), 0.15);
    transform: scale(1.15);
}
.allergy-severity-wrap { padding: 4px 0; }
.allergy-severity-slider {
    width: 100%;
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    outline: none;
}
.allergy-severity-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--text-primary);
    cursor: pointer;
    border: 2px solid var(--accent);
}
.allergy-severity-slider::-moz-range-thumb {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--text-primary);
    cursor: pointer;
    border: 2px solid var(--accent);
}
.allergy-severity-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-top: 4px;
}
.allergy-severity-value {
    font-size: 0.8rem;
    color: var(--text-primary);
    font-weight: 500;
    margin-top: 4px;
}

/* ── Conditions ── */
.condition-container {
    padding: 12px;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}
.condition-subtitle {
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin: -4px 0 14px;
    line-height: 1.5;
}
.condition-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
}
.condition-card {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 14px 16px;
    transition: background 0.15s;
}
.condition-card:hover { background: rgba(255, 255, 255, 0.07); }
.condition-card-icon {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: rgba(96, 165, 250, 0.12);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: #60a5fa;
    font-size: 1.1rem;
}
.condition-card-content {
    flex: 1;
    min-width: 0;
}
.condition-card-name {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 3px;
}
.condition-card-desc {
    font-size: 0.82rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 4px;
}
.condition-card-actions {
    display: flex;
    gap: 3px;
    flex-shrink: 0;
}
.condition-card-actions .btn-icon {
    font-size: 0.72rem;
    padding: 4px 5px;
    opacity: 0.4;
    transition: opacity 0.15s;
}
.condition-card:hover .condition-card-actions .btn-icon { opacity: 1; }

/* Condition modal */
.condition-entry-modal {
    width: 500px;
    max-width: 95vw;
    max-height: 90vh;
    overflow-y: auto;
}
.condition-entry-modal textarea {
    width: 100%;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 0.9rem;
    padding: 8px 12px 8px 36px;
    font-family: inherit;
    resize: vertical;
}
.condition-entry-modal textarea::placeholder { color: var(--text-secondary); }

/* ── Connectors ── */
.connectors-radio-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    cursor: pointer;
    border-radius: 8px;
    transition: background 0.15s;
    border: 1px solid transparent;
}
.connectors-radio-item:hover { background: rgba(255, 255, 255, 0.06); }
.connectors-radio-item.selected {
    background: rgba(var(--accent-rgb, 99, 102, 241), 0.1);
    border-color: rgba(var(--accent-rgb, 99, 102, 241), 0.3);
}
.connectors-radio {
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
    flex-shrink: 0;
    opacity: 0.5;
}
.connectors-radio-item.selected .connectors-radio { opacity: 1; }
.connectors-page-icon {
    width: 20px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.85rem;
    flex-shrink: 0;
}
.connectors-radio-item.selected .connectors-page-icon { color: var(--accent-light); }
.connectors-api-active {
    margin-left: auto;
    color: #22c55e;
    font-size: 0.85rem;
    flex-shrink: 0;
}

/* Connector tab content */
.connector-tab-content {
    padding: 16px;
    height: 100%;
    overflow-y: auto;
}
.connector-page-header {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    margin-bottom: 18px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--glass-border);
}
.connector-page-header > i {
    font-size: 1.6rem;
    color: var(--accent-light);
    margin-top: 2px;
}
.connector-page-header h4 { margin: 0 0 4px; font-size: 1.05rem; color: var(--text-primary); }
.connector-page-header p { margin: 0; font-size: 0.82rem; color: var(--text-secondary); }
.connector-unavailable {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}
.connector-unavailable i { font-size: 2.5rem; margin-bottom: 12px; opacity: 0.3; }
.connector-unavailable h4 { margin: 0 0 8px; color: var(--text-primary); }
.connector-unavailable p { font-size: 0.85rem; max-width: 400px; margin: 0 auto; }
.connector-company-select {
    margin-bottom: 18px;
}
.connector-company-select label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 6px;
}
.connector-company-select select {
    width: 100%;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 0.9rem;
    padding: 8px 12px 8px 36px;
    font-family: inherit;
    cursor: pointer;
}
.connector-company-select select option {
    background: var(--glass-bg, #1e1e2e);
    color: var(--text-primary);
}
.connector-hint {
    padding: 16px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-align: center;
}
.connector-hint i { margin-right: 6px; }
.connector-keys-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}
.connector-keys-header h5 {
    margin: 0;
    font-size: 0.9rem;
    color: var(--text-primary);
}
.connector-keys-header h5 i { margin-right: 6px; color: var(--accent-light); }
.connector-create-row {
    display: flex;
    gap: 8px;
    align-items: center;
}
.connector-label-input {
    background: rgba(255,255,255,0.06);
    border: 1px solid var(--glass-border);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.82rem;
    padding: 6px 10px;
    width: 160px;
    font-family: inherit;
}
.connector-label-input::placeholder { color: var(--text-secondary); }
.connector-empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
}
.connector-empty i { font-size: 2rem; margin-bottom: 10px; opacity: 0.25; }
.connector-empty p { font-size: 0.85rem; }
.connector-keys-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.connector-key-card {
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    padding: 14px;
    transition: background 0.15s;
}
.connector-key-card:hover { background: rgba(255,255,255,0.06); }
.connector-key-card.inactive { opacity: 0.55; border-style: dashed; }
.connector-key-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}
.connector-key-info { display: flex; align-items: center; gap: 10px; }
.connector-key-label { font-weight: 600; font-size: 0.92rem; color: var(--text-primary); }
.connector-key-status {
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 500;
}
.connector-key-status.active { background: rgba(34,197,94,0.12); color: #22c55e; }
.connector-key-status.disabled { background: rgba(239,68,68,0.12); color: #ef4444; }
.connector-key-actions { display: flex; gap: 4px; }
.connector-key-actions .btn-icon { font-size: 0.75rem; padding: 5px 6px; opacity: 0.5; }
.connector-key-card:hover .connector-key-actions .btn-icon { opacity: 1; }
.connector-key-detail { margin-bottom: 10px; }
.connector-key-field { margin-bottom: 8px; }
.connector-key-field-label {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 3px;
    display: block;
}
.connector-key-value {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(0,0,0,0.2);
    border: 1px solid var(--glass-border);
    border-radius: 6px;
    padding: 6px 10px;
}
.connector-key-value code {
    flex: 1;
    font-size: 0.75rem;
    color: var(--accent-light);
    word-break: break-all;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
}
.connector-key-value .btn-icon { font-size: 0.7rem; padding: 3px 5px; flex-shrink: 0; }
.connector-secret-note {
    font-size: 0.7rem;
    color: var(--text-secondary);
    font-style: italic;
    margin-left: 8px;
}
.connector-key-meta {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    font-size: 0.72rem;
    color: var(--text-secondary);
}
.connector-key-meta i { margin-right: 3px; }

/* Secret dialog modal */
.connector-secret-modal {
    width: 640px;
    max-width: 95vw;
    max-height: 90vh;
    overflow-y: auto;
}
.connector-secret-warning {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(245,158,11,0.1);
    border: 1px solid rgba(245,158,11,0.3);
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 16px;
    color: #f59e0b;
}
.connector-secret-warning i { font-size: 1.2rem; flex-shrink: 0; }
.connector-secret-warning p { margin: 0; font-size: 0.85rem; }
.connector-full-secret { font-size: 0.68rem !important; }
.connector-signing-key-value code { font-size: 0.68rem !important; }

/* Documentation styles */
.connector-docs { line-height: 1.65; }
.connector-doc-section {
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--glass-border);
}
.connector-doc-section:last-child { border-bottom: none; }
.connector-doc-section h5 {
    font-size: 0.95rem;
    color: var(--text-primary);
    margin: 0 0 10px;
}
.connector-doc-section h5 i { margin-right: 8px; color: var(--accent-light); }
.connector-doc-section p { font-size: 0.85rem; color: var(--text-secondary); margin: 0 0 10px; }
.connector-doc-section strong { color: var(--text-primary); }
.connector-doc-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
    margin: 10px 0;
}
.connector-doc-table th {
    text-align: left;
    padding: 8px 12px;
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--glass-border);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.connector-doc-table td {
    padding: 8px 12px;
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
}
.connector-doc-table code {
    background: rgba(0,0,0,0.2);
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 0.78rem;
    color: var(--accent-light);
}
.connector-code-block {
    background: rgba(0,0,0,0.3);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    padding: 12px 14px;
    margin: 8px 0;
    display: flex;
    align-items: flex-start;
    gap: 8px;
    overflow-x: auto;
}
.connector-code-block code, .connector-code-block pre {
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 0.78rem;
    color: #a5b4fc;
    margin: 0;
    white-space: pre;
    flex: 1;
}
.connector-code-block .btn-icon { flex-shrink: 0; font-size: 0.7rem; padding: 3px 5px; }
.connector-doc-step {
    display: flex;
    gap: 14px;
    margin: 12px 0;
    padding: 12px;
    background: rgba(255,255,255,0.03);
    border-radius: 8px;
    border: 1px solid var(--glass-border);
}
.connector-step-num {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.8rem;
    flex-shrink: 0;
}
.connector-doc-step div { font-size: 0.85rem; color: var(--text-secondary); }
.connector-doc-step strong { color: var(--text-primary); }
.connector-doc-step code {
    background: rgba(0,0,0,0.2);
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 0.78rem;
    color: var(--accent-light);
}
.connector-doc-step small { color: var(--text-secondary); font-size: 0.75rem; }
.connector-endpoint {
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    padding: 16px;
    margin: 12px 0;
}
.connector-endpoint-method {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}
.connector-method-badge {
    padding: 3px 10px;
    border-radius: 4px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.connector-method-badge.get { background: rgba(34,197,94,0.15); color: #22c55e; }
.connector-endpoint-method code {
    font-size: 0.85rem;
    color: var(--text-primary);
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
}
.connector-code-example { margin: 12px 0; }
.connector-code-title {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}
.connector-code-title i { margin-right: 6px; color: var(--accent-light); }
.connector-doc-list {
    padding-left: 0;
    list-style: none;
    margin: 10px 0;
}
.connector-doc-list li {
    font-size: 0.85rem;
    color: var(--text-secondary);
    padding: 6px 0 6px 24px;
    position: relative;
}
.connector-doc-list li::before {
    content: '\f058';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    position: absolute;
    left: 0;
    color: var(--accent-light);
    font-size: 0.8rem;
}
.connector-doc-list li strong { color: var(--text-primary); }

/* ── Contacts ── */
.contact-container {
    padding: 12px;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}
.contact-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
}
.contact-card {
    display: flex;
    align-items: center;
    gap: 14px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 12px 16px;
    transition: background 0.15s;
}
.contact-card:hover { background: rgba(255, 255, 255, 0.07); }
.contact-card-icon {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 1.1rem;
}
.contact-card-content {
    flex: 1;
    min-width: 0;
}
.contact-card-name {
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--text-primary);
}
.contact-card-phone {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 2px;
}
.contact-card-right {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}
.contact-card-right .btn-icon {
    font-size: 0.75rem;
    padding: 5px 6px;
    opacity: 0.5;
    transition: opacity 0.15s;
}
.contact-card:hover .contact-card-right .btn-icon { opacity: 1; }
.contact-card-right .contact-card-fav { opacity: 0.7; }
.contact-card-call {
    color: var(--text-secondary);
    text-decoration: none;
}
.contact-card-call:hover { color: var(--accent-light); }

/* Contact modal */
.contact-entry-modal {
    width: 480px;
    max-width: 95vw;
    max-height: 90vh;
    overflow-y: auto;
}
.contact-entry-modal select {
    width: 100%;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 0.9rem;
    padding: 8px 12px 8px 36px;
    font-family: inherit;
    cursor: pointer;
}
.contact-entry-modal select option {
    background: var(--glass-bg, #1e1e2e);
    color: var(--text-primary);
}

/* ── Responsive ── */
@media (max-width: 900px) {
    #page-geofence {
        height: auto;
        overflow: visible;
    }
    .geofence-layout {
        flex-direction: column;
        height: auto;
    }
    .geofence-panel {
        width: 100%;
        min-width: 0;
        max-height: 300px;
    }
    .geofence-map-wrapper {
        min-height: 400px;
    }
}

/* =========================================
   Demo user (role_id = 7) — read-only mode
   ========================================= */
body.is-demo-user .btn-primary.btn-add,
body.is-demo-user .btn-add-new,
body.is-demo-user [data-action="add"],
body.is-demo-user [data-action="edit"],
body.is-demo-user [data-action="delete"],
body.is-demo-user .btn-edit,
body.is-demo-user .btn-delete,
body.is-demo-user .add-btn,
body.is-demo-user .edit-btn,
body.is-demo-user .delete-btn,
body.is-demo-user .btn-agenda-add,
body.is-demo-user .btn-logbook-add,
body.is-demo-user .btn-medication-add,
body.is-demo-user .btn-allergy-add,
body.is-demo-user .btn-condition-add,
body.is-demo-user .btn-contact-add {
    display: none !important;
}

body.is-demo-user::before {
    content: "Demo modus — alleen lezen";
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(90deg, #8b5cf6, #6366f1);
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    padding: 4px 16px;
    border-radius: 0 0 8px 8px;
    z-index: 10000;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
    letter-spacing: 0.3px;
    pointer-events: none;
}

/* ─── Home contact modal ───────────────────────────────────── */
.home-cta-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    justify-content: center;
    align-items: center;
}

.home-modal {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.home-modal[hidden] { display: none; }

.home-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(8, 8, 20, 0.6);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

.home-modal-dialog {
    position: relative;
    width: 100%;
    max-width: 520px;
    background: var(--surface, #1a1a2e);
    color: var(--text, #fff);
    border-radius: 22px;
    padding: 36px 32px 28px;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.08);
    animation: homeModalIn 0.22s ease-out;
}
@keyframes homeModalIn {
    from { transform: translateY(20px) scale(0.97); opacity: 0; }
    to   { transform: translateY(0)    scale(1);    opacity: 1; }
}

.home-modal-close {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    border: none;
    color: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: background 0.2s ease;
}
.home-modal-close:hover { background: rgba(255, 255, 255, 0.15); }

.home-modal-title {
    margin: 0 0 6px;
    font-size: 22px;
    font-weight: 700;
}
.home-modal-sub {
    margin: 0 0 22px;
    color: var(--text-muted, #a0a0b8);
    font-size: 14px;
}

.home-contact-form { display: flex; flex-direction: column; gap: 16px; }

.home-field { display: flex; flex-direction: column; gap: 6px; }
.home-field label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted, #a0a0b8);
}
.home-field input,
.home-field textarea {
    width: 100%;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.04);
    color: inherit;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s ease, background 0.2s ease;
    box-sizing: border-box;
}
.home-field textarea { resize: vertical; min-height: 120px; }
.home-field input:focus,
.home-field textarea:focus {
    border-color: var(--accent, #6c5ce7);
    background: rgba(255, 255, 255, 0.07);
}

/* honeypot: off-screen for humans, visible to bots */
.home-honeypot {
    position: absolute;
    left: -10000px;
    top: auto;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

.home-contact-feedback {
    min-height: 20px;
    font-size: 13px;
    font-weight: 500;
}
.home-contact-feedback.ok  { color: #22c55e; }
.home-contact-feedback.err { color: #ef4444; }

.home-contact-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 6px;
}
.home-contact-actions .home-btn-secondary,
.home-contact-actions .home-btn-primary {
    padding: 12px 22px;
    font-size: 14px;
}

@media (max-width: 520px) {
    .home-modal-dialog { padding: 30px 20px 22px; border-radius: 18px; }
    .home-contact-actions { flex-direction: column-reverse; }
    .home-contact-actions button { width: 100%; justify-content: center; }
}

/* ─── Superadmin Messages page ─────────────────────────────── */
.messages-header-actions {
    display: flex;
    gap: 10px;
}

/* The messages page is a full-height layout — no page-header above it, so the
   thread pane starts at the very top of the content area and uses every
   available pixel. `.content` is a definite-height flex child of the app
   shell, so height: 100% resolves against it cleanly. */
.page.page-messages-full.active {
    display: flex;
    flex-direction: column;
    height: 100%;
}
.page.page-messages-full .messages-layout {
    flex: 1;
    height: auto;       /* override the generic rule below */
    min-height: 0;
}

.messages-layout {
    display: grid;
    grid-template-columns: 360px 1fr;
    gap: 18px;
    /* Fallback height when the page isn't in full-height mode. */
    height: calc(100dvh - 140px);
    min-height: 600px;
}
.messages-list {
    display: flex;
    flex-direction: column;
    min-height: 0;
    padding: 0;
    overflow: hidden;
}
.messages-list-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 12px 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.messages-list-header-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}
.messages-list-header-actions .btn-icon {
    width: 34px;
    height: 34px;
}
.messages-list-header-actions .btn-icon-primary {
    background: var(--accent, #6c5ce7);
    border-color: transparent;
    color: #fff;
}
.messages-list-header-actions .btn-icon-primary:hover {
    background: var(--accent-hover, #5a4bd1);
    color: #fff;
}
.messages-search {
    flex: 1;
    min-width: 0;
    padding: 8px 12px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.04);
    color: inherit;
    font-size: 13px;
    outline: none;
    box-sizing: border-box;
}
.messages-search:focus { border-color: var(--accent, #6c5ce7); }
.messages-list-body { flex: 1; overflow-y: auto; }

.messages-list-item {
    display: block;
    width: 100%;
    text-align: left;
    padding: 14px 16px;
    background: transparent;
    border: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    color: inherit;
    cursor: pointer;
    position: relative;
    transition: background 0.15s ease;
}
.messages-list-item:hover  { background: rgba(255, 255, 255, 0.04); }
.messages-list-item.active { background: rgba(108, 92, 231, 0.12); }
.messages-list-item.unread .mli-subject { font-weight: 700; }
.mli-top {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    font-size: 12px;
    color: var(--text-muted, #a0a0b8);
    margin-bottom: 4px;
}
.mli-who     { font-weight: 600; color: var(--text, #fff); }
.mli-date    { white-space: nowrap; flex-shrink: 0; }
.mli-subject { font-size: 14px; margin-bottom: 4px; }
.mli-snippet { font-size: 12px; color: var(--text-muted, #a0a0b8); line-height: 1.4; }
.mli-unread-dot {
    position: absolute;
    top: 16px; right: 14px;
    width: 8px; height: 8px;
    background: var(--accent, #6c5ce7);
    border-radius: 50%;
}

.messages-thread {
    display: flex;
    flex-direction: column;
    min-height: 0;
    padding: 0;
    overflow: hidden;
    position: relative; /* anchor for .messages-toast */
}
/* HTML's `hidden` attribute applies `display: none` at the UA level, but our
   explicit `display: flex` below would normally override it and keep the empty-
   state visible even when JS toggles `hidden=true`. Force `hidden` to win. */
.messages-thread-empty[hidden],
.messages-thread-content[hidden],
.messages-empty[hidden],
.messages-reply-panel[hidden],
.messages-nav-badge[hidden] { display: none !important; }

.messages-thread-empty,
.messages-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted, #a0a0b8);
    gap: 10px;
    padding: 40px 20px;
    text-align: center;
}
.messages-empty i  { font-size: 28px; opacity: 0.6; }
.messages-thread-empty i { font-size: 42px; opacity: 0.6; }
.messages-thread-loading { padding: 40px; text-align: center; color: var(--text-muted, #a0a0b8); font-size: 22px; }

.messages-thread-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}
.messages-thread-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    padding: 18px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.messages-thread-subject { margin: 0 0 4px; font-size: 17px; }
.messages-thread-meta    { font-size: 12px; color: var(--text-muted, #a0a0b8); }
.messages-thread-actions { flex-shrink: 0; }
.messages-thread-body {
    flex: 1;
    overflow-y: auto;
    padding: 18px 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.messages-bubble {
    border-radius: 14px;
    padding: 14px 16px;
    max-width: 80%;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}
.messages-bubble.in  { align-self: flex-start; background: rgba(255, 255, 255, 0.05); }
.messages-bubble.out { align-self: flex-end;   background: rgba(108, 92, 231, 0.18); }
.messages-bubble header {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    align-items: center;
    font-size: 11px;
    margin-bottom: 6px;
    color: var(--text-muted, #a0a0b8);
}
.mtb-who    { font-weight: 600; color: var(--text, #fff); }
.mtb-date   { white-space: nowrap; }
.mtb-body   { font-size: 14px; line-height: 1.55; word-break: break-word; }
.mtb-failed { color: #ef4444; font-weight: 600; }

.messages-reply-panel {
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    padding: 14px 20px 18px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: rgba(0, 0, 0, 0.15);
}
.messages-reply-panel label {
    font-size: 12px; font-weight: 600; color: var(--text-muted, #a0a0b8);
    margin-top: 4px;
}
.messages-reply-panel input,
.messages-reply-panel textarea {
    width: 100%;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.04);
    color: inherit;
    font-size: 13px;
    font-family: inherit;
    outline: none;
    box-sizing: border-box;
    resize: vertical;
}
.messages-reply-panel textarea { min-height: 120px; }
.messages-reply-panel input:focus,
.messages-reply-panel textarea:focus { border-color: var(--accent, #6c5ce7); }
.messages-reply-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 4px;
}
.messages-reply-feedback { font-size: 12px; min-height: 16px; }
.messages-reply-feedback.ok  { color: #22c55e; }
.messages-reply-feedback.err { color: #ef4444; }

/* Attachment picker row inside the reply panel. */
.messages-reply-attach-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 2px;
}
/* Use the same tokens as the rest of the admin chrome (btn-icon,
   home-btn-secondary) so the paperclip button feels native instead of
   showing the bare browser default. */
.messages-reply-attach-row .btn-attach {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    font-size: 12px;
    font-weight: 500;
    font-family: inherit;
    line-height: 1;
    color: var(--text-primary, #f0f0f5);
    background: var(--surface, rgba(255, 255, 255, 0.03));
    border: 1px solid var(--glass-border, rgba(255, 255, 255, 0.08));
    border-radius: 10px;
    cursor: pointer;
    transition: all var(--transition, 0.2s ease);
}
.messages-reply-attach-row .btn-attach i {
    color: var(--text-muted, #7a7a95);
    font-size: 13px;
    transition: color var(--transition, 0.2s ease);
}
.messages-reply-attach-row .btn-attach:hover {
    background: var(--surface-hover, rgba(255, 255, 255, 0.06));
    border-color: rgba(108, 92, 231, 0.4);
    color: var(--accent-light, #a29bfe);
}
.messages-reply-attach-row .btn-attach:hover i {
    color: var(--accent-light, #a29bfe);
}
.messages-reply-attach-row .btn-attach:active {
    transform: translateY(1px);
}
.messages-reply-attach-row .btn-attach:focus-visible {
    outline: none;
    border-color: var(--accent, #6c5ce7);
    box-shadow: 0 0 0 3px var(--accent-glow, rgba(108, 92, 231, 0.3));
}
.messages-attach-hint {
    font-size: 11px;
    color: var(--text-muted, #7a7a95);
}

/* Pill list of files the user has picked but not yet uploaded. */
.messages-reply-attachments {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 4px 0 2px;
}
.messages-reply-attachments[hidden] { display: none !important; }
.messages-attachment-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    max-width: 260px;
    padding: 5px 8px 5px 10px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
    font-size: 12px;
    color: var(--text, #fff);
}
.messages-attachment-pill i.fa-file { opacity: 0.7; }
.messages-attachment-pill .map-name {
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.messages-attachment-pill .map-size {
    color: var(--text-muted, #a0a0b8);
    font-size: 11px;
}
.messages-attachment-pill .map-remove {
    background: transparent;
    border: none;
    color: var(--text-muted, #a0a0b8);
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 50%;
    font-size: 11px;
    line-height: 1;
}
.messages-attachment-pill .map-remove:hover {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.08);
}

/* Download links under each bubble in the thread view. */
.messages-bubble-attachments {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px dashed rgba(255, 255, 255, 0.08);
}
.messages-bubble-attachments .mba-item {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 5px 8px;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.15);
    color: inherit;
    text-decoration: none;
    font-size: 12px;
    max-width: 100%;
}
.messages-bubble-attachments .mba-item:hover {
    background: rgba(108, 92, 231, 0.18);
}
.messages-bubble-attachments .mba-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    min-width: 0;
}
.messages-bubble-attachments .mba-size {
    color: var(--text-muted, #a0a0b8);
    font-size: 11px;
    flex-shrink: 0;
}

/* Transient toast above the thread — shown after a reply is sent so the user
   gets a visible confirmation even after the reply panel collapses. */
.messages-toast {
    position: absolute;
    top: 12px;
    left: 50%;
    transform: translateX(-50%) translateY(-8px);
    padding: 8px 14px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
    color: #fff;
    background: rgba(34, 197, 94, 0.95);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
    opacity: 0;
    pointer-events: none;
    transition: opacity 180ms ease, transform 180ms ease;
    z-index: 20;
}
.messages-toast.err { background: rgba(239, 68, 68, 0.95); }
.messages-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* Compose modal — same visual language as the home contact modal */
.messages-modal {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.messages-modal[hidden] { display: none; }
.messages-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(8, 8, 20, 0.6);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}
.messages-modal-dialog {
    position: relative;
    width: 100%;
    max-width: 560px;
    padding: 30px 28px 24px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.messages-modal-dialog h3 { margin: 0 0 10px; }
.messages-modal-dialog label {
    font-size: 12px; font-weight: 600;
    color: var(--text-muted, #a0a0b8); margin-top: 6px;
}
.messages-modal-dialog input,
.messages-modal-dialog textarea {
    width: 100%;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.04);
    color: inherit;
    font-size: 13px;
    font-family: inherit;
    outline: none;
    box-sizing: border-box;
    resize: vertical;
}
.messages-modal-close {
    position: absolute;
    top: 12px; right: 12px;
    width: 32px; height: 32px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    border: none; color: inherit; cursor: pointer;
}
.messages-modal-actions {
    display: flex; justify-content: flex-end; gap: 8px;
    margin-top: 14px;
}

/* Nav badge for unread count */
.messages-nav-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    margin-left: auto;
    border-radius: 10px;
    background: #ef4444;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
}

@media (max-width: 900px) {
    .messages-layout {
        grid-template-columns: 1fr;
        height: auto;
    }
    .messages-list { max-height: 280px; }
    .messages-bubble { max-width: 100%; }
}
