/* =============================================================================
   TRILOCK WEB V2 - Theme Stylesheet
   =============================================================================
   Copyrighted(c) by TriLock, LLC 2026

   CSS Variables, Login Styles, Form Elements, Shared Components
   Ported from V1 site.css + components.css
   ============================================================================= */

/* =============================================================================
   CSS RESET & BASE STYLES
   ============================================================================= */

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

body {
    margin: 0;
    padding: 0;
    font-family: var(--font-family);
    font-size: var(--font-content);
    background: var(--color-bg-body);
    color: var(--color-text);
    min-height: 100vh;
}

/* When V2 runs inside Portal iframe, lock the document so only inner panels scroll */
body.in-iframe {
    overflow: hidden;
    height: 100vh;
    overscroll-behavior: none;
}

/* Messages fullscreen: hide topbar, expand icon rail + msg-app to full viewport */
.topbar.topbar-hidden {
    display: none;
}
body:has(.topbar-hidden) .v2-icon-rail {
    top: 0;
    height: 100vh;
}
body:has(.topbar-hidden) .msg-app {
    height: 100vh;
}

/* =============================================================================
   ICON RAIL — Left sidebar navigation (48px fixed strip)
   ============================================================================= */

.v2-icon-rail {
    position: fixed;
    top: 49px; /* topbar 48px + 1px border */
    left: 0;
    width: 48px;
    height: calc(100vh - 49px);
    background: var(--color-bg-surface);
    border-right: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px 0;
    z-index: 90;
    overflow-y: auto;
    overflow-x: hidden;
}

.v2-rail-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md, 6px);
    color: var(--color-text-muted);
    text-decoration: none;
    border: none;
    background: none;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    position: relative;
    flex-shrink: 0;
    padding: 0;
}

.v2-rail-icon svg {
    width: 20px;
    height: 20px;
}

.v2-rail-icon:hover {
    background: rgba(255,255,255,0.10);
    color: var(--color-brand);
}

.v2-rail-icon.active {
    background: color-mix(in srgb, var(--color-brand) 18%, transparent);
    color: var(--color-brand);
}

.v2-rail-separator {
    width: 28px;
    height: 1px;
    background: var(--color-border);
    margin: 4px 0;
    flex-shrink: 0;
}

.v2-rail-badge {
    position: absolute;
    top: 2px;
    right: 1px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    font-size: 10px;
    font-weight: 700;
    line-height: 16px;
    text-align: center;
    color: #fff;
    background: #28a745;
    border-radius: 8px;
}

/* Light theme hover override */
[data-theme="theme-light"] .v2-rail-icon:hover {
    background: rgba(0,0,0,0.06);
}

.page {
    font-size: var(--font-content);
    background: var(--color-bg-body);
    color: var(--color-text);
    min-height: 100vh;
}

/* =============================================================================
   TOPBAR PREFERENCES — Icon Buttons (A-/A+ and Sun/Moon)
   ============================================================================= */

.topbar-prefs {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-right: 10px;
}

.topbar-font-control {
    display: flex;
    align-items: center;
    gap: 2px;
}

.topbar-font-label {
    font-size: var(--font-topbar);
    font-weight: 600;
    min-width: 16px;
    text-align: center;
    color: var(--color-text-topbar);
}

.topbar-btn-icon {
    background: none;
    border: 1px solid rgba(255,255,255,0.25);
    border-radius: var(--radius-md);
    cursor: pointer;
    padding: 3px 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-topbar);
    transition: all var(--transition-normal);
}
.topbar-btn-icon:hover:not(:disabled) {
    background: rgba(255,255,255,0.12);
    color: var(--color-white);
    border-color: rgba(255,255,255,0.4);
}
.topbar-btn-icon:disabled {
    opacity: 0.3;
    cursor: default;
}

.topbar-theme-toggle {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: var(--radius-md);
    color: var(--color-text-topbar);
    display: flex;
    align-items: center;
    transition: background var(--transition-normal);
}
.topbar-theme-toggle:hover {
    background: rgba(255,255,255,0.12);
    color: var(--color-white);
}
.topbar-theme-toast {
    position: fixed;
    bottom: 24px;
    right: 16px;
    background: var(--color-bg-card);
    color: var(--color-text);
    border: 1px solid var(--color-border);
    border-left: 3px solid var(--color-brand);
    padding: 8px 16px;
    border-radius: var(--radius-lg);
    font-size: var(--font-content-sm);
    box-shadow: var(--shadow-lg);
    z-index: 9999;
    animation: themeToastSlide 0.3s ease-out;
    pointer-events: none;
}
@keyframes themeToastSlide {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}
.topbar-pin-btn {
    margin-right: var(--space-sm);
    color: var(--color-text-topbar);
    transition: color var(--transition-normal), transform var(--transition-normal);
}
.topbar-pin-btn:hover:not(:disabled) {
    color: var(--color-brand);
}

/* =============================================================================
   LOGIN PAGE
   ============================================================================= */

.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: var(--space-xl);
}

.login-box {
    background: var(--color-bg-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xl);
    padding: var(--space-4xl);
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
}

.login-header {
    text-align: center;
    margin-bottom: var(--space-3xl);
}

.login-header h1 {
    margin: 0;
    font-size: var(--font-heading);
    color: var(--color-brand);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.login-header .icon {
    font-size: 28px;
}

/* =============================================================================
   FORM ELEMENTS
   ============================================================================= */

.form-group {
    margin-bottom: var(--space-xl);
}

.form-group label {
    display: block;
    margin-bottom: var(--space-sm);
    color: var(--color-text-secondary);
    font-size: var(--font-button);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-group input {
    width: 100%;
    padding: 12px 15px;
    background: var(--color-bg-input);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    color: var(--color-text);
    font-family: inherit;
    font-size: inherit;
    transition: border-color var(--transition-normal), box-shadow var(--transition-normal);
}

.form-group input:focus {
    outline: none;
    border-color: var(--color-brand);
    box-shadow: var(--shadow-focus);
}

.form-group input::placeholder {
    color: var(--color-text-muted);
}

/* =============================================================================
   BUTTONS
   ============================================================================= */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-md) var(--space-2xl);
    background: var(--color-btn-bg);
    color: var(--color-btn-text);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--transition-normal), transform 0.1s;
    text-decoration: none;
}

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

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background: var(--color-brand);
    color: var(--color-on-brand);
    border-color: var(--color-brand);
}

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

.btn-full {
    width: 100%;
}

/* =============================================================================
   MESSAGES
   ============================================================================= */

.error-message {
    background: rgba(255, 68, 68, 0.1);
    border: 1px solid var(--color-danger);
    border-radius: var(--radius-md);
    padding: 12px 15px;
    margin-bottom: var(--space-xl);
    color: var(--color-danger);
    font-size: var(--font-button);
    white-space: pre-line;
}

.success-message {
    background: rgba(0, 204, 102, 0.1);
    border: 1px solid var(--color-success);
    border-radius: var(--radius-md);
    padding: 12px 15px;
    margin-bottom: var(--space-xl);
    color: var(--color-success);
    font-size: var(--font-button);
}

/* =============================================================================
   LETTER AVATAR
   ============================================================================= */

.letter-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-circle);
    color: var(--color-white);
    font-weight: 600;
    text-transform: uppercase;
    flex-shrink: 0;
    user-select: none;
    line-height: 1;
}

/* =============================================================================
   LOGIN FOOTER
   ============================================================================= */

.login-footer {
    margin-top: var(--space-3xl);
    text-align: center;
    color: var(--color-text-muted);
    font-size: var(--font-content-sm);
}

/* =============================================================================
   LAYOUT: HORIZONTAL TOP BAR
   ============================================================================= */

.topbar {
    display: flex;
    align-items: center;
    height: 48px;
    padding: 0 16px;
    background: var(--color-bg-header);
    border-bottom: 1px solid var(--color-border);
    gap: var(--space-lg);
    position: sticky;
    top: 0;
    z-index: 100;
    font-size: var(--font-topbar);
}

.topbar-portal-back {
    background: none;
    border: none;
    color: var(--color-text-topbar);
    cursor: pointer;
    padding: 4px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    opacity: 0.8;
}
.topbar-portal-back:hover {
    opacity: 1;
    background: rgba(255,255,255,0.12);
}

.topbar-brand {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    flex-shrink: 0;
    text-decoration: none;
    color: inherit;
    cursor: pointer;
}

.topbar-brand img {
    width: 24px;
    height: 24px;
}

.topbar-brand-name {
    font-weight: 700;
    color: var(--color-topbar-brand, var(--color-brand));
    font-size: 15px;
    white-space: nowrap;
}

.topbar-version {
    color: var(--color-text-muted);
    font-size: var(--font-badge);
    white-space: nowrap;
}

.topbar-hamburger {
    display: none;
    background: none;
    border: none;
    color: var(--color-text);
    font-size: var(--font-heading);
    cursor: pointer;
    padding: var(--space-xs) var(--space-sm);
}

.topbar-nav {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    margin-left: var(--space-sm);
}

.topbar-nav-link {
    padding: 6px 14px;
    color: var(--color-text-topbar);
    text-decoration: none;
    font-size: var(--font-button);
    font-weight: 500;
    border-radius: var(--radius-md);
    white-space: nowrap;
    transition: color var(--transition-normal), background var(--transition-normal);
}

.topbar-nav-link:hover {
    color: var(--color-white);
    background: rgba(255,255,255,0.12);
}

.topbar-nav-link.active {
    color: var(--color-brand);
    background: color-mix(in srgb, var(--color-brand) 12%, transparent);
}
[data-theme="theme-light"] .topbar-nav-link.active {
    color: var(--color-brand);
    background: #ffffff;
}

.topbar-nav-link.nav-disabled {
    opacity: 0.4;
    cursor: default;
    pointer-events: none;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    margin-left: auto;
    flex-shrink: 0;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    text-decoration: none;
    color: inherit;
    cursor: default;
}

.topbar-username {
    font-weight: 600;
    color: var(--color-text);
    font-size: var(--font-button);
    white-space: nowrap;
}

.topbar-role-badge {
    font-size: var(--font-tiny);
    font-weight: 700;
    padding: 2px 8px;
    border-radius: var(--radius-pill);
    text-transform: uppercase;
    white-space: nowrap;
}
.topbar-role-badge.badge-super {
    background: var(--color-danger);
    color: var(--color-white);
    font-weight: 800;
}
.topbar-role-badge.badge-lsuper {
    background: var(--color-danger);
    color: var(--color-white);
    font-weight: 800;
}
.topbar-role-badge.badge-master {
    background: var(--color-role-master);
    color: var(--color-white);
}

.topbar-logout {
    font-size: var(--font-content-sm);
    padding: var(--space-xs) var(--space-md);
}

.main-content {
    flex: 1;
    overflow: hidden;
    margin-left: 48px;
}

/* =============================================================================
   RESPONSIVE (Login)
   ============================================================================= */

@media (max-width: 480px) {
    .login-box {
        padding: var(--space-3xl) var(--space-xl);
    }

    .login-header h1 {
        font-size: var(--font-heading);
    }
}

/* =============================================================================
   COMMAND CENTER: TWO PANEL LAYOUT
   ============================================================================= */

.cc-main-panels { display: flex; height: calc(100vh - 48px); }

.cc-splitter {
    width: 5px;
    cursor: col-resize;
    background: var(--color-border);
    flex-shrink: 0;
    position: relative;
    z-index: 2;
    transition: background var(--transition-fast);
}
.cc-splitter:hover,
.cc-splitter.dragging {
    background: var(--color-brand);
}

.cc-right-panel { flex: 1; display: flex; flex-direction: column; overflow-y: auto; overscroll-behavior: contain; }

/* =============================================================================
   COMMAND CENTER: DEVICE TREE PANEL
   ============================================================================= */

.cc-tree-panel {
    width: var(--tree-width, 280px);
    min-width: 200px;
    background: var(--color-bg-surface);
    border-right: none;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.cc-tree-header {
    padding: 10px 16px;
    font-weight: 600;
    color: var(--color-brand);
    font-size: var(--font-sidebar);
    border-bottom: 1px solid var(--color-border);
    background: var(--color-bg-card);
    flex-shrink: 0;
}

.cc-tree-list {
    flex: 1;
    overflow-y: auto;
    padding: 6px 0;
}

.cc-tree-device {
    display: flex;
    align-items: center;
    padding: var(--space-sm) var(--space-md) var(--space-sm) 0;
    cursor: default;
    border-left: 3px solid transparent;
    transition: border-color var(--transition-normal), background var(--transition-normal);
}

.cc-tree-device:hover {
    background: rgba(255,255,255,0.03);
}

.cc-tree-device.selected {
    border-left-color: var(--color-brand);
    background: color-mix(in srgb, var(--color-brand) 8%, transparent);
}

.cc-tree-device-row {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    flex-wrap: wrap;
}

.cc-tree-arrow {
    display: inline-block;
    cursor: pointer;
    font-size: var(--font-tiny);
    color: var(--color-text-muted);
    transition: transform var(--transition-normal) ease;
    width: 14px;
    text-align: center;
    user-select: none;
    flex-shrink: 0;
}

.cc-tree-arrow.open {
    transform: rotate(90deg);
}

.cc-tree-arrow-spacer {
    display: inline-block;
    width: 14px;
    flex-shrink: 0;
}

.cc-tree-status {
    font-size: var(--font-sidebar-header);
    color: var(--color-text-muted);
    padding-left: 18px;
    margin-top: 2px;
}

.cc-tree-status.status-ok { color: var(--color-success); }
.cc-tree-status.status-warning { color: var(--color-warning); }
.cc-tree-status.status-critical { color: var(--color-danger); }
.cc-tree-status.status-offline { color: var(--color-danger); font-weight: 600; }

.cc-tree-meta {
    font-size: var(--font-sidebar-header);
    color: var(--color-text-muted);
    padding-left: 18px;
    margin-top: 1px;
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.topbar-avatar {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-circle);
    object-fit: cover;
    flex-shrink: 0;
}

.cc-tree-count {
    color: var(--color-text-muted);
    font-size: var(--font-sidebar-header);
    margin-left: 6px;
    flex-shrink: 0;
}

/* =============================================================================
   COMMAND CENTER: SELECTED DEVICE BAR
   ============================================================================= */

.cc-selected-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-sm) var(--space-xl);
    background: var(--color-bg-card);
    border-bottom: 1px solid var(--color-border);
    font-size: var(--font-sidebar);
    color: var(--color-text);
}

.cc-selected-bar strong {
    color: var(--color-brand);
}

.cc-clear-btn {
    font-size: var(--font-content-sm);
    padding: var(--space-xs) var(--space-md);
}

/* =============================================================================
   COMMAND CENTER: DEVICE PHONE + BADGES
   ============================================================================= */

.cc-device-phone { font-weight: 400; color: var(--color-text-muted); cursor: pointer; font-size: var(--font-sidebar-header); }
.cc-device-phone:hover { text-decoration: underline; color: var(--color-brand); }

.cc-badge { display: inline-block; padding: 2px 8px; border-radius: var(--radius-sm); font-size: var(--font-tiny); font-weight: bold; text-transform: uppercase; }
.cc-badge-queue { background: var(--color-warning); color: var(--color-black); }
.cc-badge-msg { background: var(--color-brand); color: var(--color-black); text-decoration: none; font-size: var(--font-tiny); }
.cc-badge-msg:hover { opacity: 0.8; }
.cc-badge-offline { background: var(--color-danger); color: var(--color-white); font-size: 9px; padding: 1px 5px; border-radius: var(--radius-sm); font-weight: 600; letter-spacing: 0.5px; margin-left: var(--space-xs); animation: offlinePulse 2s ease-in-out infinite; }

@keyframes offlinePulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.6; } }

.cc-signalr-dot { display: inline-block; width: 7px; height: 7px; border-radius: var(--radius-circle); margin-left: var(--space-xs); vertical-align: middle; flex-shrink: 0; }
.cc-signalr-up { background: var(--color-success); }
.cc-signalr-down { background: var(--color-text-muted); }
.cc-signalr-proxy { background: var(--color-info); }
.cc-signalr-error { background: var(--color-danger); }

/* =============================================================================
   COMMAND CENTER: NO DEVICES ERROR
   ============================================================================= */

.cc-no-devices { padding: var(--space-3xl) var(--space-lg); text-align: center; }
.cc-no-devices .error-icon { font-size: 36px; margin-bottom: 10px; }
.cc-no-devices .error-title { font-size: var(--font-heading-sm); font-weight: bold; color: var(--color-danger); margin-bottom: var(--space-sm); }
.cc-no-devices .error-message { color: var(--color-text); font-size: var(--font-button); margin-bottom: var(--space-sm); }
.cc-no-devices .error-contact { color: var(--color-text-muted); font-size: var(--font-content-sm); }

/* =============================================================================
   COMMAND CENTER: COMPANY-CENTRIC TREE (sidebar)
   ============================================================================= */

.cc-tree-company {
    border-bottom: 1px solid var(--color-border);
}

.cc-tree-company-row {
    display: flex;
    align-items: center;
    padding: var(--space-sm) var(--space-md);
    cursor: pointer;
    font-size: var(--font-sidebar);
    font-weight: 600;
    color: var(--color-text);
    transition: background var(--transition-fast);
}

.cc-tree-company-row:hover {
    background: rgba(255,255,255,0.03);
}

.cc-tree-company-logo {
    width: 20px;
    height: 20px;
    border-radius: var(--radius-md);
    object-fit: contain;
    margin-right: 6px;
    flex-shrink: 0;
}

.cc-tree-company-row .letter-avatar {
    margin-right: 6px;
    flex-shrink: 0;
}

.cc-tree-company-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cc-tree-company-children {
    padding: 0 0 6px 16px;
}

/* Inactive company — strikethrough name + red badge */
.cc-tree-inactive {
    text-decoration: line-through;
    opacity: 0.6;
}
.cc-tree-inactive-badge {
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--color-danger);
    margin-left: 6px;
    flex-shrink: 0;
}

/* Company contact detail card */
.cc-tree-detail-card {
    padding: 4px 12px 6px 32px;
}
.cc-tree-detail-row {
    display: flex;
    gap: 8px;
    padding: 1px 0;
    font-size: 0.78rem;
    line-height: 1.4;
}
.cc-tree-detail-label {
    color: var(--color-text-muted);
    min-width: 52px;
    flex-shrink: 0;
    text-align: right;
}
.cc-tree-detail-value {
    color: var(--color-text);
    word-break: break-word;
}

/* Loading spinner for lazy-load */
.cc-tree-detail-loading {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px 8px 32px;
    font-size: 0.78rem;
    color: var(--color-text-muted);
}
.cc-tree-spinner {
    width: 14px;
    height: 14px;
    border: 2px solid var(--color-border);
    border-top-color: var(--color-brand);
    border-radius: 50%;
    animation: cc-spin 0.6s linear infinite;
    flex-shrink: 0;
}
@keyframes cc-spin {
    to { transform: rotate(360deg); }
}

/* Larger spinner for right panel loading */
.cc-spinner-lg {
    width: 28px;
    height: 28px;
    border-width: 3px;
}

/* Selected company row highlight */
.cc-tree-selected {
    background: rgba(var(--color-brand-rgb, 59,130,246), 0.12);
}

/* Right panel: company loading state */
.cc-company-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 80px 40px;
    font-size: 1rem;
    color: var(--color-text-muted);
}

/* Right panel: company detail view */
.cc-company-detail-panel {
    padding: 0;
}
.cc-company-detail-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 20px 12px;
    border-bottom: 1px solid var(--color-border);
}
.cc-company-detail-logo {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-md);
    object-fit: contain;
    flex-shrink: 0;
}
.cc-company-detail-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0;
    color: var(--color-text);
}
.cc-back-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: transparent;
    color: var(--color-text-muted);
    cursor: pointer;
    flex-shrink: 0;
    transition: background var(--transition-fast), color var(--transition-fast);
}
.cc-back-btn:hover {
    background: rgba(255,255,255,0.06);
    color: var(--color-text);
}
.cc-company-detail-body {
    padding: 16px 20px 20px;
}
.cc-detail-field {
    display: flex;
    gap: 12px;
    padding: 4px 0;
    font-size: 0.88rem;
    line-height: 1.5;
}
.cc-detail-label {
    color: var(--color-text-muted);
    min-width: 64px;
    flex-shrink: 0;
    text-align: right;
    font-weight: 500;
}
.cc-detail-value {
    color: var(--color-text);
    word-break: break-word;
}

.cc-tree-company-summary {
    font-size: var(--font-sidebar-header);
    color: var(--color-text-muted);
    padding: 4px 12px 2px;
}

.cc-tree-summary-sep {
    margin: 0 6px;
    color: var(--color-border);
}

.cc-device-type-label {
    font-size: var(--font-sidebar-header);
    color: var(--color-text-muted);
    margin-left: 6px;
    white-space: nowrap;
}
.cc-device-version {
    font-size: var(--font-tiny);
    color: var(--color-text-muted);
    margin-left: 6px;
    opacity: 0.7;
    white-space: nowrap;
}

.cc-device-role-badge {
    font-size: 9px;
    font-weight: 600;
    padding: 1px 5px;
    border-radius: var(--radius-sm);
    margin-left: var(--space-xs);
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.cc-device-role-badge.primary {
    background: rgba(0, 200, 83, 0.15);
    color: var(--color-success);
    border: 1px solid rgba(0, 200, 83, 0.3);
}
.cc-device-role-badge.notused {
    background: rgba(255, 152, 0, 0.12);
    color: var(--color-warning);
    border: 1px solid rgba(255, 152, 0, 0.25);
}

.cc-unread-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: var(--radius-pill);
    background: var(--color-danger);
    color: var(--color-white);
    font-size: var(--font-tiny);
    font-weight: 700;
    margin-left: 6px;
    flex-shrink: 0;
    line-height: 1;
}

.cc-tree-messages-row {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 10px;
    font-size: var(--font-sidebar-header);
    font-weight: 600;
    color: var(--color-brand);
    background: var(--bg-body);
    border: 1px solid var(--color-brand);
    border-radius: var(--radius-lg);
    margin: 4px 8px 2px 8px;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.cc-tree-connectors {
    padding-left: 20px;
}

.cc-tree-line {
    color: var(--color-border);
    font-family: monospace;
    font-size: 0.85rem;
    line-height: 1;
    margin-right: 4px;
    flex-shrink: 0;
    user-select: none;
}

.cc-tree-messages-row.clickable {
    cursor: pointer;
}

.cc-tree-messages-row.clickable:hover {
    background: var(--color-brand);
    color: var(--color-white);
}

.cc-tree-people-icon {
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
}

.cc-tree-messages-row.clickable:hover .cc-tree-people-icon {
    color: var(--color-white);
}

/* =============================================================================
   COMMAND CENTER: THEME SELECT (in topbar)
   ============================================================================= */

/* =============================================================================
   COMMAND CENTER: RESULT BANNER
   ============================================================================= */

.cc-result-banner { padding: var(--space-md) var(--space-xl); text-align: center; font-weight: 500; }
.cc-result-banner.success { background: var(--color-success); color: var(--color-white); }
.cc-result-banner.error { background: var(--color-danger); color: var(--color-white); }

/* =============================================================================
   COMMAND CENTER: STATS BAR
   ============================================================================= */

.cc-stats-bar {
    display: flex; gap: var(--space-xl); padding: 10px 15px; margin: 0 20px 10px;
    background: var(--color-bg-surface); border: 1px solid var(--color-border);
    border-radius: var(--radius-lg); font-size: var(--font-button); flex-wrap: wrap; align-items: center;
}
.cc-stats-bar .stat-val { font-weight: 600; color: var(--color-text); }
.cc-stats-bar .stat-lbl { color: var(--color-text-muted); }
.cc-stats-bar .stat-orphan { font-weight: 600; color: var(--color-danger); }
.cc-stats-bar .stat-orphan-link { color: var(--color-danger); text-decoration: underline; cursor: pointer; }
.cc-stats-bar .stat-orphan-link:hover { opacity: 0.8; }
.cc-stats-bar .stat-alert { font-weight: 600; color: var(--color-warning); }
.cc-stats-bar .stat-alert-link { color: var(--color-warning); text-decoration: underline; cursor: pointer; }
.cc-stats-bar .stat-alert-link:hover { opacity: 0.8; }
.cc-stats-bar .stat-scope { color: var(--color-text-muted); margin-left: auto; font-size: var(--font-content-sm); display: flex; align-items: center; gap: var(--space-xs); }

/* Alert badges in AlertsModal */
.alert-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: var(--radius-md);
    font-size: var(--font-badge);
    font-weight: 600;
    color: var(--alert-color);
    background: color-mix(in srgb, var(--alert-color) 12%, transparent);
    white-space: nowrap;
}

/* =============================================================================
   COMMAND CENTER: NEWS FEED (displayed on home page)
   ============================================================================= */

.cc-news-feed { margin: 0 20px 20px; }
.cc-news-item {
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xl);
    margin-bottom: var(--space-md);
    position: relative;
}
.cc-news-item.cc-news-pinned {
    border-color: var(--color-brand);
    background: color-mix(in srgb, var(--color-brand) 4%, transparent);
}
.cc-news-header {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-md) var(--space-lg);
    cursor: pointer;
    user-select: none;
    flex-wrap: wrap;
}
.cc-news-header:hover { background: rgba(128,128,128,0.06); border-radius: var(--radius-xl); }
.cc-news-toggle {
    font-size: var(--font-tiny);
    color: var(--color-text-muted);
    flex-shrink: 0;
    width: 14px;
    text-align: center;
}
.cc-news-pin-icon-inline {
    font-size: 1rem;
    opacity: 0.7;
    flex-shrink: 0;
}
.cc-news-title {
    margin: 0;
    font-size: 1.1em;
    font-weight: 600;
    color: var(--color-brand);
    flex-shrink: 0;
}
.cc-news-meta {
    display: flex;
    gap: var(--space-md);
    font-size: var(--font-tiny);
    color: var(--color-text-muted);
    margin-left: auto;
}
.cc-news-company {
    font-weight: 600;
    color: var(--color-text);
}
.cc-news-date {
    font-style: italic;
}
.cc-news-body {
    font-size: var(--font-button);
    line-height: 1.5;
    color: var(--color-text);
    max-height: var(--news-body-height, 15em);
    overflow-y: auto;
    padding: 0 16px 12px;
}
.cc-news-collapsed .cc-news-body { display: none; }
.cc-news-resize-handle {
    height: 6px;
    cursor: row-resize;
    background: var(--color-border);
    border-radius: 0 0 8px 8px;
    transition: background var(--transition-fast);
}
.cc-news-resize-handle:hover,
.cc-news-resize-handle.dragging {
    background: var(--color-brand);
}
.cc-news-collapsed .cc-news-resize-handle { display: none; }
.cc-news-body p { margin: 0 0 10px 0; }
.cc-news-body p:last-child { margin-bottom: 0; }
.cc-news-body a { color: var(--color-brand); text-decoration: underline; }
.cc-news-body a:hover { opacity: 0.8; }
.cc-news-body ul, .cc-news-body ol { margin: 8px 0; padding-left: 24px; }
.cc-news-body li { margin: 4px 0; }
.cc-news-body h1, .cc-news-body h2, .cc-news-body h3, .cc-news-body h4, .cc-news-body h5, .cc-news-body h6 {
    color: var(--color-brand);
    margin: 12px 0 8px 0;
    font-weight: 600;
}
.cc-news-body h1 { font-size: 1.3em; }
.cc-news-body h2 { font-size: 1.2em; }
.cc-news-body h3 { font-size: 1.1em; }
.cc-news-body blockquote {
    border-left: 3px solid var(--color-brand);
    padding-left: 12px;
    margin: 10px 0;
    font-style: italic;
    color: var(--color-text-muted);
}

/* =============================================================================
   COMMAND CENTER: TILES
   ============================================================================= */

.cc-tiles-container {
    flex: 1; padding: var(--space-xl);
    display: grid; grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr));
    gap: var(--space-xl); align-content: start;
}

.cc-tile {
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xl); padding: var(--space-xl);
}

.cc-tile-header { font-weight: 600; color: var(--color-brand); margin-bottom: 15px; padding-bottom: 10px; border-bottom: 1px solid var(--color-border); }
.cc-tile-description { color: var(--color-text-muted); font-size: var(--font-button); margin: 10px 0; }
.cc-tile-admin { grid-column: span 2; }

.cc-tile textarea {
    width: 100%; padding: 10px;
    background: var(--color-bg-input); border: 1px solid var(--color-border);
    border-radius: var(--radius-md); color: var(--color-text); font-family: inherit; resize: vertical; margin-bottom: 10px;
}

.cc-input-group { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.cc-input-group input { flex: 1; padding: 10px; background: var(--color-bg-input); border: 1px solid var(--color-border); border-radius: var(--radius-md); color: var(--color-text); }
.cc-input-suffix { color: var(--color-text-muted); font-size: var(--font-button); }

.cc-radio-group { display: flex; gap: 15px; margin-bottom: 10px; }
.cc-radio-group label { display: flex; align-items: center; gap: 5px; color: var(--color-text-muted); font-size: var(--font-button); cursor: pointer; }

/* =============================================================================
   COMMAND CENTER: ADMIN STATS GRID
   ============================================================================= */

.cc-stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 15px; }

.cc-stat { padding: 10px; background: var(--color-bg-input); border-radius: var(--radius-md); text-align: center; }
.cc-stat-label { display: block; font-size: var(--font-badge); color: var(--color-text-muted); margin-bottom: 5px; }
.cc-stat-value { font-size: var(--font-heading-sm); font-weight: 600; color: var(--color-text); }
.cc-stat-warning { background: rgba(255,193,7,0.2); }
.cc-stat-warning .cc-stat-value { color: var(--color-warning); }
.cc-stat-highlight .cc-stat-value { color: var(--color-brand); }
.cc-stat-error { background: rgba(220,53,69,0.2); }
.cc-stat-error .cc-stat-value { color: var(--color-danger); }

/* =============================================================================
   COMMAND CENTER: TILE TABS
   ============================================================================= */

.cc-tile-tabs { display: flex; gap: 0; border-bottom: 1px solid var(--color-border); margin-bottom: var(--space-md); }
.cc-tile-tab { padding: 6px 14px; font-size: var(--font-content-sm); font-weight: 600; cursor: pointer; border: none; background: none; color: var(--color-text-muted); border-bottom: 2px solid transparent; }
.cc-tile-tab:hover { color: var(--color-text); }
.cc-tile-tab.active { color: var(--color-brand); border-bottom-color: var(--color-brand); }

/* =============================================================================
   COMMAND CENTER: CONFIG GRID
   ============================================================================= */

.cc-config-grid { display: grid; grid-template-columns: auto 1fr; gap: var(--space-xs) var(--space-md); font-size: var(--font-content-sm); }
.cc-cfg-label { color: var(--color-text-muted); font-weight: 600; white-space: nowrap; }
.cc-cfg-value { color: var(--color-text); }


/* =============================================================================
   COMMAND CENTER: DEVICE MODAL
   ============================================================================= */

.cc-modal-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: var(--color-overlay-heavy); z-index: 2000; display: flex; align-items: center; justify-content: center; padding: var(--space-xl); }

.cc-modal {
    background: var(--color-bg-surface); border: 1px solid var(--color-border);
    border-radius: var(--radius-xl); max-width: 700px; width: 95%; max-height: 85vh;
    overflow: hidden; display: flex; flex-direction: column;
}
.cc-modal-header { display: flex; justify-content: space-between; align-items: center; padding: 15px 20px; border-bottom: 1px solid var(--color-border); }
.cc-modal-header h3 { margin: 0; color: var(--color-brand); }
.cc-modal-close { background: none; border: none; color: var(--color-text-muted); font-size: 1.5em; cursor: pointer; padding: 0; line-height: 1; }
.cc-modal-close:hover { color: var(--color-text); }
.cc-modal-body { padding: var(--space-xl); overflow-y: auto; flex: 1; }

.cc-modal-tabs { display: flex; gap: 0; border-bottom: 1px solid var(--color-border); margin-bottom: var(--space-md); }
.cc-modal-tab { padding: 6px 14px; font-size: var(--font-content-sm); font-weight: 600; cursor: pointer; border: none; background: none; color: var(--color-text-muted); border-bottom: 2px solid transparent; }
.cc-modal-tab:hover { color: var(--color-text); }
.cc-modal-tab.active { color: var(--color-brand); border-bottom-color: var(--color-brand); }

.cc-info-grid { display: grid; grid-template-columns: 140px 1fr; gap: 6px 12px; font-size: var(--font-content-sm); }
.cc-info-label { color: var(--color-text-muted); font-weight: 600; white-space: nowrap; }

.cc-status-online { display: inline-block; padding: var(--space-xs) var(--space-lg); border-radius: var(--radius-md); background: var(--color-success); color: var(--color-white); font-weight: 600; font-size: var(--font-content-sm); }
.cc-status-offline { display: inline-block; padding: var(--space-xs) var(--space-lg); border-radius: var(--radius-md); background: var(--color-danger); color: var(--color-white); font-weight: 600; font-size: var(--font-content-sm); }

.cc-modal-actions { margin-top: 15px; padding-top: 15px; border-top: 1px solid var(--color-border-light); display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: var(--space-sm); }
.cc-btn-action { border: none; padding: var(--space-sm) var(--space-lg); border-radius: var(--radius-md); cursor: pointer; font-weight: 600; font-size: var(--font-content-sm); }
.cc-btn-online { background: var(--color-success); color: var(--color-white); }
.cc-btn-offline { background: var(--color-danger); color: var(--color-white); }
.cc-btn-delete { background: var(--color-danger); color: var(--color-white); }
.cc-btn-ping { background: var(--color-brand); color: var(--color-white); font-size: var(--font-badge); padding: var(--space-xs) var(--space-md); border: none; border-radius: var(--radius-md); cursor: pointer; }
.cc-btn-ping:disabled { opacity: 0.5; cursor: not-allowed; }

/* =============================================================================
   COMMAND CENTER: DEVICE PICKER MODAL
   ============================================================================= */

.cc-picker-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: var(--color-overlay); z-index: 9999; display: flex; justify-content: center; align-items: center; }
.cc-picker { background: var(--color-bg-surface); border: 1px solid var(--color-border); border-radius: var(--radius-xl); max-width: 400px; width: 90%; max-height: 60vh; display: flex; flex-direction: column; }
.cc-picker-header { display: flex; justify-content: space-between; align-items: center; padding: 12px 15px; border-bottom: 1px solid var(--color-border); }
.cc-picker-header h3 { margin: 0; font-size: 1em; color: var(--color-brand); }
.cc-picker-close { background: none; border: none; color: var(--color-text-muted); font-size: 1.3em; cursor: pointer; }
.cc-picker-list { overflow-y: auto; flex: 1; }
.cc-picker-item { display: flex; justify-content: space-between; align-items: center; padding: 10px 15px; color: var(--color-text); border-bottom: 1px solid var(--color-border-light); cursor: pointer; }
.cc-picker-item:hover { background: var(--color-bg-input); }
.cc-picker-item-phone { font-weight: 600; }
.cc-picker-item-detail { color: var(--color-text-muted); font-size: var(--font-content-sm); }

/* =============================================================================
   COMMAND CENTER: LOADING SPINNER
   ============================================================================= */

.cc-loading { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: var(--space-4xl); }
.cc-spinner { width: 40px; height: 40px; border: 4px solid var(--color-border-light); border-top: 4px solid var(--color-brand); border-radius: var(--radius-circle); animation: ccSpin 0.8s linear infinite; }
.cc-loading-text { margin-top: var(--space-md); color: var(--color-text-muted); font-size: var(--font-button); }
@keyframes ccSpin { to { transform: rotate(360deg); } }

/* =============================================================================
   COMMAND CENTER: CONFIRM DIALOG
   ============================================================================= */

.cc-confirm-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.6); display: flex; align-items: center; justify-content: center; z-index: 10001; padding: var(--space-xl); }
.cc-confirm-box { background: var(--color-bg-card); border: 1px solid var(--color-border); border-radius: var(--radius-2xl); max-width: 420px; width: 100%; padding: var(--space-2xl); box-shadow: var(--shadow-xl); }
.cc-confirm-title { font-size: 1.1rem; font-weight: 600; color: var(--color-text); margin-bottom: 10px; }
.cc-confirm-message { color: var(--color-text-muted); font-size: var(--font-button); margin-bottom: var(--space-xl); line-height: 1.5; }
.cc-confirm-actions { display: flex; justify-content: flex-end; gap: 10px; }
.cc-confirm-btn { padding: var(--space-sm) var(--space-xl); border-radius: var(--radius-lg); border: 1px solid var(--color-border); cursor: pointer; font-size: var(--font-button); font-weight: 500; }
.cc-confirm-cancel { background: transparent; color: var(--color-text-muted); }
.cc-confirm-cancel:hover { background: var(--color-bg-surface); color: var(--color-text); }
.cc-confirm-ok { background: var(--color-danger); color: var(--color-white); border-color: var(--color-danger); }
.cc-confirm-ok:hover { opacity: 0.9; }

/* =============================================================================
   COMMAND CENTER: FOOTER
   ============================================================================= */

.cc-footer { padding: 15px 20px; background: var(--color-bg-card); border-top: 1px solid var(--color-border); text-align: center; color: var(--color-text-muted); font-size: var(--font-content-sm); }

/* =============================================================================
   COMMAND CENTER: TOAST
   ============================================================================= */

.cc-toast-container { position: fixed; top: 20px; right: 20px; z-index: 10002; display: flex; flex-direction: column; gap: var(--space-sm); }
.cc-toast { padding: var(--space-md) var(--space-xl); border-radius: var(--radius-lg); color: var(--color-white); font-size: var(--font-button); font-weight: 500; box-shadow: var(--shadow-lg); animation: ccToastIn 0.3s ease; }
.cc-toast-success { background: var(--color-success); }
.cc-toast-error { background: var(--color-danger); }
.cc-toast-warning { background: var(--color-warning); color: var(--color-black); }
@keyframes ccToastIn { from { opacity: 0; transform: translateY(-50px); } to { opacity: 1; transform: translateY(0); } }

/* --- New Message Toast Info --- */
.cc-toast-info { background: var(--color-brand); }
@keyframes ccToastOut { from { opacity: 1; transform: translateY(0); } to { opacity: 0; transform: translateY(-50px); } }
.cc-toast-out { animation: ccToastOut 0.3s ease forwards; }
.cc-toast-container-left { position: fixed; top: 20px; left: 20px; z-index: 10002; display: flex; flex-direction: column; gap: var(--space-sm); }
.cc-toast-alert { background: var(--color-danger); }

/* --- TopBar Notice Toggle --- */
.topbar-notice-toggle {
    display: flex; align-items: center; gap: var(--space-xs);
    font-size: var(--font-content-sm); cursor: pointer; color: var(--color-text-secondary);
    margin-right: var(--space-sm); user-select: none;
}
.topbar-notice-toggle input[type="checkbox"] { cursor: pointer; accent-color: var(--color-brand); }

/* =============================================================================
   SECURITY DEBUG BADGE (shared across all pages)
   ============================================================================= */

.sec-badge { display: inline-block; background: var(--color-security-bg); color: var(--color-security-text); border: 1px solid var(--color-security-border); border-radius: var(--radius-sm); padding: 1px 5px; font-size: 0.6rem; margin-left: var(--space-xs); vertical-align: middle; font-family: monospace; font-weight: 600; letter-spacing: 0.3px; }
.cc-tile-wrapper { position: relative; }
.cc-tile-badge { position: absolute; top: 6px; right: 6px; z-index: 1; }

/* =============================================================================
   COMMAND CENTER: RESPONSIVE
   ============================================================================= */

@media (max-width: 768px) {
    .topbar {
        padding: var(--space-sm) var(--space-md);
        gap: var(--space-sm);
    }

    .topbar-right {
        margin-left: auto;
        gap: var(--space-sm);
    }

    .v2-icon-rail { display: none; }
    .main-content { margin-left: 0; }

    .cc-main-panels { flex-direction: column; height: auto; min-height: calc(100vh - 48px); }
    .cc-splitter { display: none; }
    .cc-tree-panel { width: 100% !important; min-width: 100%; border-right: none; border-bottom: 1px solid var(--color-border); max-height: 40vh; }
    .cc-tiles-container { padding: var(--space-md); gap: var(--space-md); grid-template-columns: 1fr; }
    .cc-tile-admin { grid-column: span 1; }
    .cc-stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .cc-info-grid { grid-template-columns: 1fr; }
    .cc-stats-bar { margin: 0 12px 10px; }
}

@media (max-width: 480px) {
    .cc-tiles-container { padding: var(--space-sm); gap: var(--space-sm); }
    .cc-stats-grid { grid-template-columns: 1fr 1fr; gap: var(--space-sm); }
    .cc-stat { padding: var(--space-sm); }
    .cc-stat-value { font-size: var(--font-heading-sm); }
    .cc-stat-label { font-size: var(--font-tiny); }
    .cc-tree-header { padding: var(--space-sm) var(--space-md); font-size: var(--font-button); }
}

/* =============================================================================
   ANALYTICAL REPORT PAGE (ar- prefix)
   ============================================================================= */

.ar-page { padding: var(--space-xl); overflow-y: auto; }

.ar-title { color: var(--color-text); font-size: 1.1em; font-weight: 600; margin-bottom: var(--space-md); display: flex; align-items: center; gap: var(--space-md); }

/* Stats cards */
.ar-stats-row { display: flex; gap: var(--space-md); margin-bottom: var(--space-xl); flex-wrap: wrap; }
.ar-stat-card { background: var(--color-bg-card); border: 1px solid var(--color-border-light); border-radius: var(--radius-xl); padding: var(--space-lg) var(--space-xl); min-width: 120px; text-align: center; }
.ar-stat-card .ar-stat-value { font-size: 1.8em; font-weight: 700; color: var(--color-text); }
.ar-stat-card .ar-stat-label { font-size: var(--font-badge); color: var(--color-text-muted); margin-top: var(--space-xs); }
.ar-stat-card.green .ar-stat-value { color: var(--color-cls-human); }
.ar-stat-card.yellow .ar-stat-value { color: var(--color-cls-bot); }
.ar-stat-card.red .ar-stat-value { color: var(--color-cls-crawler); }
.ar-stat-card.blue .ar-stat-value { color: var(--color-info); }

/* Filters */
.ar-filters-bar { display: flex; gap: var(--space-md); margin-bottom: var(--space-lg); flex-wrap: wrap; align-items: flex-end; }
.ar-filter-group { display: flex; flex-direction: column; gap: var(--space-xs); }
.ar-filter-group label { font-size: var(--font-badge); color: var(--color-text-muted); }
.ar-filter-group input, .ar-filter-group select { background: var(--color-bg-input); border: 1px solid var(--color-border-light); color: var(--color-text); padding: 6px 10px; border-radius: var(--radius-md); font-size: var(--font-content-sm); }
.ar-btn-filter { background: var(--color-brand); color: var(--color-white); border: none; padding: var(--space-sm) var(--space-lg); border-radius: var(--radius-md); cursor: pointer; font-size: var(--font-content-sm); }
.ar-btn-filter:hover { opacity: 0.85; }
.ar-btn-clear { background: var(--color-bg-card); color: var(--color-text-muted); border: 1px solid var(--color-border-light); padding: var(--space-sm) var(--space-lg); border-radius: var(--radius-md); cursor: pointer; font-size: var(--font-content-sm); }
.ar-btn-clear:hover { opacity: 0.85; }

/* Report table */
.ar-table-container { overflow-x: auto; }
.ar-table { width: 100%; border-collapse: collapse; font-size: var(--font-badge); }
.ar-table th { background: var(--color-bg-surface); color: var(--color-text-muted); padding: 8px 10px; text-align: left; border-bottom: 2px solid var(--color-border); position: sticky; top: 0; z-index: 5; white-space: nowrap; cursor: pointer; user-select: none; }
.ar-table th:hover { color: var(--color-text); }
[data-theme="theme-light"] .ar-table th { background: var(--color-bg-header); color: #ffffff; }
[data-theme="theme-light"] .ar-table th:hover { color: #e0e0e0; }
.ar-table th .ar-sort-arrow { font-size: var(--font-tiny); margin-left: var(--space-xs); opacity: 0.4; }
.ar-table th.ar-sort-active .ar-sort-arrow { opacity: 1; color: var(--color-brand); }
.ar-table td { padding: 6px 10px; border-bottom: 1px solid var(--color-border-light); vertical-align: top; }
.ar-table tr:hover { background: color-mix(in srgb, var(--color-brand) 5%, transparent); }

/* Classification colors */
.ar-cls-human { color: var(--color-cls-human); font-weight: 600; }
.ar-cls-suspected_bot { color: var(--color-cls-bot); font-weight: 600; }
.ar-cls-crawler { color: var(--color-cls-crawler); font-weight: 600; }
.ar-cls-headless { color: var(--color-cls-crawler); font-weight: 600; }
.ar-cls-honeypot_bot { color: var(--color-cls-crawler); font-weight: 600; }
.ar-cls-unknown { color: var(--color-text-muted); }

/* Row background by classification */
.ar-row-human {}
.ar-row-suspected_bot { background: rgba(243,156,18,0.05); }
.ar-row-crawler { background: rgba(231,76,60,0.05); }
.ar-row-headless { background: rgba(231,76,60,0.08); }
.ar-row-honeypot_bot { background: rgba(231,76,60,0.1); }

/* Badges */
.ar-badge-blocked { background: var(--color-cls-crawler); color: white; padding: 1px 6px; border-radius: var(--radius-sm); font-size: var(--font-badge); }
.ar-badge-success { background: var(--color-cls-human); color: white; padding: 1px 6px; border-radius: var(--radius-sm); font-size: var(--font-badge); }
.ar-badge-method { background: var(--color-bg-surface); color: var(--color-text-muted); padding: 1px 6px; border-radius: var(--radius-sm); font-size: var(--font-badge); }

/* Truncated text cells */
.ar-ua-text { display: inline-block; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: help; }
.ar-reasons-text { display: inline-block; max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: help; font-size: var(--font-content-sm); color: var(--color-text-muted); }
.ar-url-text { display: inline-block; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: help; font-size: var(--font-content-sm); }
.ar-ref-text { display: inline-block; max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: help; font-size: var(--font-content-sm); color: var(--color-text-muted); }

/* Pagination */
.ar-pagination { display: flex; gap: var(--space-sm); justify-content: center; margin-top: var(--space-lg); align-items: center; }
.ar-page-link { background: var(--color-bg-card); color: var(--color-text); border: 1px solid var(--color-border-light); padding: 6px 12px; border-radius: var(--radius-md); font-size: var(--font-content-sm); cursor: pointer; }
.ar-page-link:hover:not(:disabled) { background: var(--color-bg-surface); }
.ar-page-link.active { background: var(--color-brand); color: white; border-color: var(--color-brand); }
.ar-page-link:disabled { opacity: 0.4; cursor: default; }
.ar-page-info { color: var(--color-text-muted); font-size: var(--font-content-sm); }

/* Purge button */
.ar-btn-purge { background: var(--color-cls-crawler); color: white; border: none; padding: 5px 14px; border-radius: var(--radius-md); cursor: pointer; font-size: var(--font-badge); font-weight: 600; }
.ar-btn-purge:hover { background: var(--color-danger); }
.ar-btn-purge:disabled { opacity: 0.5; cursor: default; }

/* Print button */
.ar-btn-print { background: var(--color-brand); color: white; border: none; padding: 5px 14px; border-radius: var(--radius-md); cursor: pointer; font-size: var(--font-badge); font-weight: 600; }
.ar-btn-print:hover { opacity: 0.85; }

/* =============================================================================
   ANALYTICAL REPORT - PRINT STYLES
   ============================================================================= */
@media print {
    .topbar, .v2-icon-rail, .ar-filters-bar, .ar-pagination, .ar-btn-purge, .ar-btn-print,
    .ar-btn-filter, .ar-btn-clear, .toast-container, .modal-backdrop, .modal { display: none !important; }

    body, .ar-page { background: white !important; color: #000 !important; padding: 0 !important; margin: 0 !important; }
    .main-content { padding: 0 !important; }
    .ar-title { font-size: 14pt !important; color: #000 !important; border-bottom: 2px solid var(--color-black); padding-bottom: 6px; margin-bottom: var(--space-md); }

    .ar-stats-row { gap: 6px !important; margin-bottom: 12px !important; }
    .ar-stat-card { border: 1px solid #999 !important; background: #f9f9f9 !important; padding: 8px 12px !important; min-width: 80px !important; }
    .ar-stat-card .ar-stat-value { font-size: 1.2em !important; color: #000 !important; }
    .ar-stat-card .ar-stat-label { color: #555 !important; }
    .ar-stat-card.green .ar-stat-value { color: #1a7a3a !important; }
    .ar-stat-card.yellow .ar-stat-value { color: #b87a00 !important; }
    .ar-stat-card.red .ar-stat-value { color: #c0392b !important; }
    .ar-stat-card.blue .ar-stat-value { color: #2471a3 !important; }

    .ar-page-info { color: #555 !important; }
    .ar-table-container { overflow: visible !important; }
    .ar-table { font-size: 7pt !important; }
    .ar-table th { background: #eee !important; color: #000 !important; border-bottom: 2px solid #000 !important; padding: 4px 4px !important; position: static !important; }
    .ar-table th .ar-sort-arrow { display: none !important; }
    .ar-table td { padding: 3px 4px !important; border-bottom: 1px solid #ccc !important; color: #000 !important; }
    .ar-table tr:hover { background: none !important; }

    .ar-row-crawler, .ar-row-headless, .ar-row-honeypot_bot { background: #fde8e8 !important; }
    .ar-row-suspected_bot { background: #fef5e0 !important; }
    .ar-cls-human { color: #1a7a3a !important; }
    .ar-cls-suspected_bot { color: #b87a00 !important; }
    .ar-cls-crawler, .ar-cls-headless, .ar-cls-honeypot_bot { color: #c0392b !important; }

    .ar-badge-blocked { background: #c0392b !important; }
    .ar-badge-success { background: #1a7a3a !important; }
    .ar-badge-method { background: #eee !important; color: #333 !important; }

    .ar-ua-text, .ar-reasons-text, .ar-url-text, .ar-ref-text { max-width: none !important; white-space: normal !important; word-break: break-all !important; overflow: visible !important; text-overflow: clip !important; }

    @page { size: landscape; margin: 0.4in; }
}

/* Analytical Report responsive */
@media (max-width: 768px) {
    .ar-page { padding: var(--space-md); }
    .ar-stat-card { min-width: 90px; padding: 10px 12px; }
    .ar-stat-card .ar-stat-value { font-size: 1.3em; }
    .ar-filters-bar { flex-direction: column; }
    .ar-filter-group { width: 100%; }
    .ar-filter-group input, .ar-filter-group select { width: 100%; }
}

/* =============================================================================
   TICKERS MANAGEMENT PAGE (tk- prefix)
   ============================================================================= */

.tk-page { padding: var(--space-xl) var(--space-2xl); }
.tk-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: var(--space-xl); flex-wrap: wrap; gap: 10px; }
.tk-header h2 { margin: 0; font-size: 1.3em; color: var(--color-brand); }
.tk-header-buttons { display: flex; gap: 10px; }

/* Stats bar */
.tk-stats-bar { display: flex; gap: var(--space-xl); margin-bottom: var(--space-xl); }
.tk-stat-item { background: var(--color-bg-surface); border: 1px solid var(--color-border-light); border-radius: var(--radius-xl); padding: var(--space-md) var(--space-xl); text-align: center; }
.tk-stat-value { font-size: 1.5rem; font-weight: 700; color: var(--color-brand); }
.tk-stat-label { font-size: var(--font-tiny); color: var(--color-text-muted); text-transform: uppercase; }

/* Buttons */
.tk-btn { background: var(--color-brand); color: var(--color-black); border: none; padding: var(--space-sm) var(--space-lg); border-radius: var(--radius-md); cursor: pointer; font-size: var(--font-content-sm); font-weight: 600; }
.tk-btn:hover { opacity: 0.85; }
.tk-btn-secondary { background: var(--color-bg-card); color: var(--color-text); border: 1px solid var(--color-border); padding: var(--space-sm) var(--space-lg); border-radius: var(--radius-md); cursor: pointer; font-size: var(--font-content-sm); }
.tk-btn-secondary:hover { border-color: var(--color-brand); }
.tk-btn-small { border: 1px solid var(--color-border-light); background: var(--color-bg-card); color: var(--color-text); padding: 4px 10px; border-radius: var(--radius-md); cursor: pointer; font-size: var(--font-badge); }
.tk-btn-small:hover { background: var(--color-bg-surface); border-color: var(--color-brand); }
.tk-btn-danger { color: var(--color-danger); border-color: var(--color-danger); }
.tk-btn-danger:hover { background: rgba(220,53,69,0.15); }

/* Table */
.tk-table-scroll { overflow-x: auto; max-height: 500px; overflow-y: auto; border: 1px solid var(--color-border); border-radius: var(--radius-lg); }
.tk-table { width: 100%; border-collapse: collapse; font-size: var(--font-content-sm); }
.tk-table th { background: var(--color-bg-card); color: var(--color-text-muted); font-weight: 600; text-transform: uppercase; font-size: var(--font-tiny); padding: 8px 10px; text-align: left; position: sticky; top: 0; z-index: 1; border-bottom: 2px solid var(--color-border); border-right: 1px solid var(--color-border); }
.tk-table th:last-child { border-right: none; }
[data-theme="theme-light"] .tk-table th { background: var(--color-bg-header); color: #ffffff; }
.tk-table td { padding: 8px 10px; border-bottom: 1px solid var(--color-border); border-right: 1px solid var(--color-border-light); vertical-align: middle; }
.tk-table td:last-child { border-right: none; }
.tk-table tr:hover { background: rgba(255,255,255,0.03); }
.tk-table td .tk-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* Ticker code + URL */
.tk-ticker-code { font-family: 'Consolas', 'Courier New', monospace; font-size: var(--font-badge); max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--color-brand); text-decoration: none; }
.tk-ticker-code:hover { text-decoration: underline; }
.tk-ticker-url { font-family: 'Consolas', 'Courier New', monospace; font-size: var(--font-tiny); max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--color-text-muted); display: inline-block; }

/* Thumbnail */
.tk-thumb { width: 80px; height: 42px; object-fit: cover; border-radius: var(--radius-sm); border: 1px solid var(--color-border-light); cursor: pointer; transition: transform var(--transition-normal); }
.tk-thumb:hover { transform: scale(2.5); z-index: 100; position: relative; }

/* Counts */
.tk-hit-count { color: var(--color-success); font-weight: 600; }
.tk-render-count { color: var(--color-brand); }

/* Create section */
.tk-create-section { background: var(--color-bg-surface); border: 1px solid var(--color-border); border-radius: var(--radius-xl); padding: var(--space-xl); margin-bottom: var(--space-xl); }
.tk-create-section h3 { margin: 0 0 15px 0; color: var(--color-brand); font-size: 1.1em; }
.tk-form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; margin-bottom: 15px; }
.tk-form-group { margin-bottom: var(--space-md); }
.tk-form-group label { display: block; font-size: var(--font-badge); color: var(--color-text-muted); margin-bottom: var(--space-xs); text-transform: uppercase; }
.tk-form-group input, .tk-form-group textarea, .tk-form-group select { width: 100%; padding: var(--space-sm) var(--space-md); background: var(--color-bg-input); border: 1px solid var(--color-border); border-radius: var(--radius-md); color: var(--color-text); font-size: var(--font-button); }
.tk-form-group input:focus, .tk-form-group textarea:focus, .tk-form-group select:focus { outline: none; border-color: var(--color-brand); }
.tk-form-group textarea { min-height: 80px; resize: vertical; }
.tk-checkbox-label { display: flex; align-items: center; gap: var(--space-sm); cursor: pointer; font-size: var(--font-button); color: var(--color-text); }
.tk-checkbox-label input[type="checkbox"] { width: auto; }
.tk-managed-fields { padding-left: 20px; border-left: 2px solid var(--color-brand); margin-left: 10px; margin-top: var(--space-md); }
.tk-form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 15px; }

/* Image upload */
.tk-upload-area { border: 2px dashed var(--color-border); border-radius: var(--radius-xl); padding: var(--space-3xl); text-align: center; cursor: pointer; transition: border-color var(--transition-normal); position: relative; }
.tk-upload-area:hover { border-color: var(--color-brand); }
.tk-upload-area p { color: var(--color-text-muted); margin: 0; }
.tk-image-preview { max-width: 600px; max-height: 315px; margin: 10px auto; border-radius: var(--radius-lg); border: 1px solid var(--color-border-light); display: block; }
.tk-image-info { font-size: var(--font-badge); color: var(--color-text-muted); margin-top: var(--space-sm); }

/* Result banner */
.tk-result-banner { padding: var(--space-md) var(--space-xl); border-radius: var(--radius-lg); margin-bottom: var(--space-xl); font-weight: 500; }
.tk-result-banner.success { background: rgba(40,167,69,0.15); border: 1px solid var(--color-success); color: var(--color-success); }
.tk-result-banner.error { background: rgba(220,53,69,0.15); border: 1px solid var(--color-danger); color: var(--color-danger); }

/* URL box (created ticker) */
.tk-url-box { display: flex; align-items: center; gap: 10px; margin-top: 10px; background: var(--color-bg-card); padding: 10px 14px; border-radius: var(--radius-lg); border: 1px solid var(--color-border-light); }
.tk-url-box input { flex: 1; background: transparent; border: none; color: var(--color-brand); font-family: 'Consolas', monospace; font-size: var(--font-button); outline: none; }
.tk-url-box .tk-btn-copy { background: var(--color-brand); color: var(--color-black); border: none; padding: 6px 14px; border-radius: var(--radius-md); cursor: pointer; font-size: var(--font-badge); font-weight: 600; }
.tk-url-box .tk-btn-copy:hover { opacity: 0.85; }

/* Modals */
.tk-modal-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.6); z-index: 9000; display: flex; justify-content: center; align-items: center; }
.tk-modal { background: var(--color-bg-surface); border: 1px solid var(--color-border); border-radius: var(--radius-xl); max-width: 700px; width: 95%; max-height: 80vh; display: flex; flex-direction: column; }
.tk-modal.wide { max-width: 900px; }
.tk-modal-header { display: flex; justify-content: space-between; align-items: center; padding: 12px 18px; border-bottom: 1px solid var(--color-border); }
.tk-modal-header h3 { margin: 0; font-size: 1em; color: var(--color-brand); }
.tk-modal-close { background: none; border: none; color: var(--color-text-muted); font-size: 1.4em; cursor: pointer; padding: 0 4px; }
.tk-modal-close:hover { color: var(--color-text); }
.tk-modal-body { padding: 18px; overflow-y: auto; flex: 1; }

/* Detail grid (details modal) */
.tk-detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-md); }
.tk-detail-item { padding: 8px 0; }
.tk-detail-item.full { grid-column: 1 / -1; }
.tk-detail-label { font-size: var(--font-tiny); color: var(--color-text-muted); text-transform: uppercase; margin-bottom: var(--space-xs); }
.tk-detail-value { font-size: var(--font-button); color: var(--color-text); word-break: break-word; }
.tk-detail-value.mono { font-family: 'Consolas', monospace; font-size: var(--font-content-sm); }

/* Last hit section */
.tk-last-hit-section { margin-top: var(--space-lg); padding-top: 16px; border-top: 1px solid var(--color-border); }
.tk-last-hit-section h4 { font-size: var(--font-content-sm); color: var(--color-text-muted); margin: 0 0 10px 0; }

/* History log table */
.tk-log-table { width: 100%; border-collapse: collapse; font-size: var(--font-tiny); }
.tk-log-table th, .tk-log-table td { padding: 4px 6px; text-align: left; border-bottom: 1px solid var(--color-border); border-right: 1px solid var(--color-border-light); white-space: nowrap; }
.tk-log-table th:last-child, .tk-log-table td:last-child { border-right: none; }
.tk-log-table th { background: var(--color-bg-card); font-weight: 600; color: var(--color-text-muted); text-transform: uppercase; font-size: 0.6rem; }
[data-theme="theme-light"] .tk-log-table th { background: var(--color-bg-header); color: #ffffff; }
.tk-log-referer { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 120px; }
.tk-event-render { color: var(--color-brand); font-weight: 600; }
.tk-event-hit { color: var(--color-success); font-weight: 600; }

/* Images grid */
.tk-images-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: var(--space-md); }
.tk-image-card { background: var(--color-bg-card); border: 1px solid var(--color-border-light); border-radius: var(--radius-lg); overflow: hidden; }
.tk-image-card img { width: 100%; height: 120px; object-fit: cover; display: block; cursor: pointer; }
.tk-image-card img:hover { opacity: 0.85; }
.tk-image-card-info { padding: var(--space-sm); font-size: var(--font-tiny); }
.tk-image-card-name { color: var(--color-text); word-break: break-all; }
.tk-image-card-meta { color: var(--color-text-muted); margin-top: 3px; }

/* Empty state */
.tk-empty-state { text-align: center; padding: var(--space-4xl); color: var(--color-text-muted); }
.tk-empty-state p { margin: 10px 0; }

/* Security badge (inline) — uses shared .sec-badge */
.tk-security-badge { display: inline-block; background: var(--color-security-bg); color: var(--color-security-text); border: 1px solid var(--color-security-border); border-radius: var(--radius-sm); padding: 1px 5px; font-size: 0.6rem; margin-left: var(--space-xs); vertical-align: middle; font-family: monospace; font-weight: 600; letter-spacing: 0.3px; }

/* Responsive */
@media (max-width: 768px) {
    .tk-page { padding: var(--space-md); }
    .tk-stats-bar { flex-direction: column; gap: 10px; }
    .tk-stats-bar .tk-stat-item { padding: 10px 16px; width: 100%; }
    .tk-form-row { grid-template-columns: 1fr; }
    .tk-detail-grid { grid-template-columns: 1fr; }
    .tk-thumb:hover { transform: none; z-index: auto; position: static; }
    .tk-header { flex-direction: column; align-items: flex-start; }
    .tk-header-buttons { flex-direction: column; width: 100%; }
    .tk-header-buttons .tk-btn, .tk-header-buttons .tk-btn-secondary { width: 100%; text-align: center; }
    .tk-images-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
}
@media (max-width: 480px) {
    .tk-stat-item { padding: var(--space-sm) var(--space-md); }
    .tk-stat-value { font-size: 1.2rem; }
}

/* =============================================================================
   NEWS FEED MANAGEMENT PAGE (nf- prefix)
   ============================================================================= */

.nf-page { padding: var(--space-xl) var(--space-2xl); }
.nf-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: var(--space-xl); }
.nf-header h2 { margin: 0; font-size: 1.3em; color: var(--color-brand); }

/* Buttons */
.nf-btn { background: var(--color-brand); color: var(--color-black); border: none; padding: var(--space-sm) var(--space-lg); border-radius: var(--radius-md); cursor: pointer; font-size: var(--font-content-sm); font-weight: 600; }
.nf-btn:hover { opacity: 0.85; }
.nf-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.nf-btn-secondary { background: var(--color-bg-card); color: var(--color-text); border: 1px solid var(--color-border); padding: var(--space-sm) var(--space-lg); border-radius: var(--radius-md); cursor: pointer; font-size: var(--font-content-sm); }
.nf-btn-secondary:hover { border-color: var(--color-brand); }
.nf-btn-icon { background: none; border: none; cursor: pointer; padding: var(--space-xs) var(--space-sm); border-radius: var(--radius-md); display: inline-flex; align-items: center; transition: background var(--transition-fast), transform 0.1s; }
.nf-btn-icon:hover { background: rgba(128,128,128,0.12); transform: scale(1.15); }
.nf-btn-icon:active { transform: scale(0.95); }
.nf-btn-icon svg { display: block; }
.nf-btn-edit { color: var(--color-link); }
.nf-btn-edit:hover { color: var(--color-brand-highlight); background: rgba(59,130,246,0.12); }
.nf-btn-pin { color: var(--color-text-secondary); }
.nf-btn-pin:hover { color: var(--color-warning); background: rgba(245,158,11,0.12); }
.nf-btn-pin.pinned { color: var(--color-warning); }
.nf-btn-pin.pinned:hover { color: var(--color-brand-hover); background: rgba(245,158,11,0.12); }
.nf-btn-delete { color: var(--color-danger); }
.nf-btn-delete:hover { color: var(--color-danger); opacity: 0.8; background: var(--color-bg-danger-subtle); }

/* Banners */
.nf-banner { padding: var(--space-md) var(--space-xl); border-radius: var(--radius-lg); margin-bottom: var(--space-xl); font-weight: 500; }
.nf-banner.success { background: rgba(40,167,69,0.15); border: 1px solid var(--color-success); color: var(--color-success); }
.nf-banner.error { background: rgba(220,53,69,0.15); border: 1px solid var(--color-danger); color: var(--color-danger); }

/* Form */
.nf-form-section { background: var(--color-bg-surface); border: 1px solid var(--color-border); border-radius: var(--radius-xl); padding: var(--space-xl); margin-bottom: var(--space-xl); }
.nf-form-section h3 { margin: 0 0 15px 0; color: var(--color-brand); font-size: 1.1em; }
.nf-form-group { margin-bottom: 15px; }
.nf-form-group label { display: block; font-size: var(--font-badge); color: var(--color-text-muted); margin-bottom: var(--space-xs); text-transform: uppercase; }
.nf-form-group input[type="text"],
.nf-form-group input[type="datetime-local"],
.nf-form-group textarea,
.nf-form-group select { width: 100%; padding: var(--space-sm) var(--space-md); background: var(--color-bg-input); border: 1px solid var(--color-border); border-radius: var(--radius-md); color: var(--color-text); font-size: var(--font-button); }
.nf-form-group input:focus,
.nf-form-group textarea:focus,
.nf-form-group select:focus { outline: none; border-color: var(--color-brand); }
.nf-form-group textarea { min-height: 120px; resize: vertical; font-family: 'Consolas', 'Courier New', monospace; }
.nf-form-group input[readonly] { background: var(--color-bg-card); color: var(--color-text-muted); cursor: not-allowed; }
.nf-form-group small { display: block; margin-top: var(--space-xs); }
.nf-form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
.nf-form-buttons { display: flex; gap: 10px; justify-content: flex-end; margin-top: 15px; }

/* Company Picker */
.nf-company-picker { background: var(--color-bg-input); border: 1px solid var(--color-border); border-radius: var(--radius-lg); padding: var(--space-sm); }
.nf-picker-controls { display: flex; gap: var(--space-sm); margin-bottom: var(--space-sm); padding-bottom: 6px; border-bottom: 1px solid var(--color-border); }
.nf-picker-link { background: none; border: none; color: var(--color-brand); font-size: var(--font-badge); cursor: pointer; padding: 2px 6px; text-decoration: underline; }
.nf-picker-link:hover { opacity: 0.8; }
.nf-picker-list { max-height: 200px; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.nf-picker-check { display: flex; align-items: center; gap: var(--space-sm); padding: 4px 6px; border-radius: var(--radius-sm); cursor: pointer; font-size: var(--font-content-sm); color: var(--color-text); }
.nf-picker-check:hover { background: rgba(255,255,255,0.05); }

/* Table */
.nf-table-container { overflow-x: auto; border: 1px solid var(--color-border); border-radius: var(--radius-lg); }
.nf-table { width: 100%; border-collapse: collapse; font-size: var(--font-content-sm); }
.nf-table th { background: var(--color-bg-card); color: var(--color-text-muted); font-weight: 600; text-transform: uppercase; font-size: var(--font-tiny); padding: 8px 10px; text-align: left; border-bottom: 2px solid var(--color-border); border-right: 1px solid var(--color-border); }
.nf-table th:last-child { border-right: none; }
[data-theme="theme-light"] .nf-table th { background: var(--color-bg-header); color: #ffffff; }
.nf-table td { padding: 8px 10px; border-bottom: 1px solid var(--color-border); border-right: 1px solid var(--color-border-light); vertical-align: middle; }
.nf-table td:last-child { border-right: none; }
.nf-table tr:hover { background: rgba(255,255,255,0.03); }
.nf-table tr.nf-inactive { opacity: 0.5; }
.nf-actions { display: flex; gap: 6px; align-items: center; }

/* Badges */
.nf-badge { display: inline-flex; align-items: center; gap: 3px; background: var(--color-bg-card); color: var(--color-text-muted); border: 1px solid var(--color-border-light); border-radius: var(--radius-sm); padding: 2px 6px; font-size: 0.65rem; margin-left: var(--space-xs); vertical-align: middle; }
.nf-badge svg { vertical-align: middle; }
.nf-badge-pin { background: var(--color-bg-warning-subtle); color: var(--color-warning); border-color: var(--color-warning); }
.nf-badge-inactive { background: var(--color-bg-danger-subtle); color: var(--color-danger); border-color: var(--color-danger); }

/* States */
.nf-loading { text-align: center; padding: var(--space-4xl); color: var(--color-text-muted); }
.nf-empty { text-align: center; padding: var(--space-4xl); color: var(--color-text-muted); }

/* Responsive */
@media (max-width: 768px) {
    .nf-page { padding: var(--space-md); }
    .nf-form-row { grid-template-columns: 1fr; }
    .nf-header { flex-direction: column; align-items: flex-start; gap: 10px; }
    .nf-table { font-size: var(--font-tiny); }
}

/* =====================================================================
   ACCOUNT / USERS PAGE (up- prefix)
   Build 113 — Phase 4
   ===================================================================== */

/* Page layout */
.up-page { padding: var(--space-lg) var(--space-2xl); max-width: 1400px; }
.up-page.up-printing { visibility: hidden; height: 0; overflow: hidden; }

.up-header { display: flex; justify-content: flex-start; align-items: center; margin-bottom: var(--space-lg); flex-wrap: wrap; gap: var(--space-sm); }
.up-header-title { display: flex; align-items: center; gap: 10px; }
.up-header-title h2 { color: var(--color-brand); margin: 0; font-size: 1.4rem; }
.up-header-logo { width: 32px; height: 32px; border-radius: var(--radius-lg); object-fit: contain; border: 1px solid var(--color-border); }
.up-header h2 { color: var(--color-brand); margin: 0; font-size: 1.4rem; }
.up-header-buttons { display: flex; gap: 6px; flex-wrap: wrap; }
.up-device-icon-cell { text-align: center; }

/* Tab bar */
.up-tabs { display: flex; border-bottom: 2px solid var(--color-border); margin-bottom: var(--space-lg); gap: 0; }
.up-tab {
    background: none; border: none; padding: var(--space-sm) var(--space-lg); cursor: pointer;
    color: var(--color-text-muted); font-size: var(--font-content); font-weight: 500;
    border-bottom: 2px solid transparent; margin-bottom: -2px; transition: all var(--transition-normal);
}
.up-tab:hover { color: var(--color-text); }
.up-tab.active { color: var(--color-brand); border-bottom-color: var(--color-brand); }

.up-tab-actions { display: flex; align-items: center; gap: var(--space-md); margin-bottom: var(--space-md); }

/* Sub-tabs (inside Security tab) */
.up-subtabs { display: flex; gap: 0; margin-bottom: var(--space-lg); border-bottom: 1px solid var(--color-border); }
.up-subtab {
    background: none; border: none; padding: 6px 14px; cursor: pointer;
    color: var(--color-text-muted); font-size: var(--font-button); font-weight: 500;
    border-bottom: 2px solid transparent; margin-bottom: -1px; transition: all var(--transition-normal);
}
.up-subtab:hover { color: var(--color-text); }
.up-subtab.active { color: var(--color-brand); border-bottom-color: var(--color-brand); }
.up-subtab-actions { display: flex; align-items: center; gap: var(--space-md); margin-top: var(--space-sm); }

/* Buttons */
.up-btn {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 6px 14px; border: none; border-radius: var(--radius-md); cursor: pointer;
    font-size: var(--font-button); font-weight: 500; transition: opacity var(--transition-fast); white-space: nowrap;
}
.up-btn:hover { opacity: 0.85; }
.up-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.up-btn-primary { background: var(--color-brand); color: var(--color-white); }
.up-btn-secondary { background: var(--color-bg-surface); color: var(--color-text); border: 1px solid var(--color-border); }
.up-btn-danger { background: var(--color-danger); color: var(--color-white); }
.up-btn-restore { background: var(--color-success); color: var(--color-white); }
.up-btn-small { padding: 3px 8px; font-size: var(--font-content-sm); }
.up-btn-fixed { min-width: 62px; text-align: center; }

/* Tables */
.up-table-scroll { overflow-x: auto; max-height: 740px; overflow-y: auto; border: 1px solid var(--color-border); border-radius: var(--radius-lg); }
.up-table {
    width: 100%; border-collapse: collapse; font-size: var(--font-table);
}
.up-table thead { position: sticky; top: 0; z-index: 2; }
.up-table th {
    background: var(--color-bg-surface); color: var(--color-text-muted); text-align: left;
    padding: 8px 10px; font-weight: 600; font-size: var(--font-table-header); text-transform: uppercase;
    border-bottom: 2px solid var(--color-border); border-right: 1px solid var(--color-border); white-space: nowrap;
}
.up-table th:last-child { border-right: none; }
[data-theme="theme-light"] .up-table th { background: var(--color-bg-header); color: #ffffff; }
.up-table td { padding: 7px 10px; border-bottom: 1px solid var(--color-border); border-right: 1px solid var(--color-border-light); color: var(--color-text); vertical-align: middle; }
.up-table td:last-child { border-right: none; }
.up-table tbody tr:hover { background: rgba(var(--color-brand-rgb, 100,100,255), 0.05); }
.up-action-cell { white-space: nowrap; display: flex; gap: var(--space-xs); flex-wrap: wrap; }
.up-deleted-row { opacity: 0.5; }
.up-deleted-row td { text-decoration: line-through; }
.up-deleted-row .up-action-cell { text-decoration: none; }

/* Status dots */
.up-status-dot { display: inline-block; width: 8px; height: 8px; border-radius: var(--radius-circle); margin-right: var(--space-xs); vertical-align: middle; }
.up-status-dot.status-ok { background: var(--color-success); }
.up-status-dot.status-warning { background: var(--color-warning); }
.up-status-dot.status-critical { background: var(--color-danger); }
.up-status-dot.status-offline { background: var(--color-secondary); }

/* Stale elapsed time highlights */
.elapsed-warning { background: rgba(234, 179, 8, 0.25); }
.elapsed-critical { background: rgba(239, 68, 68, 0.25); }

/* Role badges */
.up-role-badge {
    display: inline-block; padding: 2px 8px; border-radius: var(--radius-pill);
    font-size: var(--font-badge); font-weight: 600; text-transform: uppercase;
}
.up-role-super { background: var(--color-danger); color: var(--color-white); font-weight: 800; }
.up-role-lsuper { background: var(--color-danger); color: var(--color-white); font-weight: 800; }
.up-role-master { background: var(--color-role-master); color: var(--color-white); }
.up-role-user { background: var(--color-bg-surface); color: var(--color-text-muted); border: 1px solid var(--color-border); }

/* Status badges */
.up-status-badge { display: inline-block; padding: 2px 6px; border-radius: var(--radius-sm); font-size: var(--font-badge); font-weight: 600; }
.up-status-inactive { background: var(--color-danger); color: var(--color-white); }

/* Modal overlay */
.up-modal-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.6); z-index: 1050;
    display: flex; align-items: center; justify-content: center;
    padding: var(--space-xl);
}
.up-modal {
    background: var(--color-bg-surface); border-radius: var(--radius-xl);
    width: 100%; max-width: 560px; max-height: 85vh; overflow-y: auto;
    box-shadow: var(--shadow-xl);
}
.up-modal-wide { max-width: 800px; }
.up-modal-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 14px 20px; border-bottom: 1px solid var(--color-border);
}
.up-modal-header h3 { margin: 0; font-size: 1.1rem; color: var(--color-brand); }
.up-modal-close { background: none; border: none; font-size: 22px; color: var(--color-text-muted); cursor: pointer; padding: 0 4px; }
.up-modal-close:hover { color: var(--color-text); }
.up-modal-body { padding: var(--space-lg) var(--space-xl); }
.up-modal-footer { display: flex; justify-content: flex-end; gap: var(--space-sm); padding: var(--space-md) var(--space-xl); border-top: 1px solid var(--color-border); }

/* Modal sub-tabs */
.up-modal-tabs { display: flex; border-bottom: 2px solid var(--color-border); margin-bottom: var(--space-lg); gap: 0; }
.up-modal-tab {
    background: none; border: none; padding: 6px 14px; cursor: pointer;
    color: var(--color-text-muted); font-size: var(--font-button); font-weight: 500;
    border-bottom: 2px solid transparent; margin-bottom: -2px; transition: all var(--transition-normal);
}
.up-modal-tab:hover { color: var(--color-text); }
.up-modal-tab.active { color: var(--color-brand); border-bottom-color: var(--color-brand); }

/* Delete confirmation modals */
.up-delete-stats { width: 100%; border-collapse: collapse; margin-bottom: 14px; font-size: var(--font-button); }
.up-delete-stats td { padding: 5px 8px; border-bottom: 1px solid var(--color-border); color: var(--color-text-muted); }
.up-delete-stat-val { font-weight: 700; color: var(--color-text); font-family: monospace; text-align: right; min-width: 60px; }
.up-delete-rule { display: flex; align-items: flex-start; gap: var(--space-sm); padding: 10px 12px; background: rgba(var(--color-brand-rgb, 100,100,255), 0.05); border-radius: var(--radius-lg); margin-bottom: var(--space-md); font-size: var(--font-button); color: var(--color-text); line-height: 1.5; }
.up-delete-rule-icon { font-size: var(--font-tiny); margin-top: 3px; flex-shrink: 0; }
.up-delete-warning { padding: 10px 12px; background: rgba(220,53,69,0.08); border: 1px solid rgba(220,53,69,0.2); border-radius: var(--radius-lg); font-size: var(--font-content-sm); color: var(--color-danger); line-height: 1.5; }
.up-delete-status-line { font-size: var(--font-button); color: var(--color-text-muted); margin-bottom: 10px; padding: 0 4px; }

/* Forms */
.up-form-group { margin-bottom: var(--space-md); }
.up-form-group label { display: block; font-size: var(--font-content-sm); font-weight: 600; color: var(--color-text-muted); margin-bottom: var(--space-xs); text-transform: uppercase; }
.up-form-group input[type="text"],
.up-form-group input[type="email"],
.up-form-group input[type="password"],
.up-form-group input[type="number"],
.up-form-group select,
.up-form-group textarea {
    width: 100%; padding: 7px 10px; border: 1px solid var(--color-border); border-radius: var(--radius-md);
    background: var(--color-bg-input); color: var(--color-text); font-size: var(--font-input);
    box-sizing: border-box;
}
.up-form-group input:focus, .up-form-group select:focus { border-color: var(--color-brand); outline: none; box-shadow: 0 0 0 2px rgba(var(--color-brand-rgb, 100,100,255), 0.15); }
.up-form-group input[type="checkbox"] { width: auto; margin-right: 6px; }
.up-form-row { display: flex; gap: var(--space-md); }
.up-form-row .up-form-group { flex: 1; min-width: 0; }

.up-hint { display: block; font-size: var(--font-badge); color: var(--color-text-muted); margin-top: 2px; }
.up-hint-warning { color: var(--color-warning); }
.up-error { color: var(--color-danger); font-size: var(--font-button); margin-top: var(--space-sm); padding: var(--space-sm); background: rgba(220,53,69,0.1); border-radius: var(--radius-md); }
.up-info { color: var(--color-info); font-size: var(--font-button); margin-bottom: 10px; padding: var(--space-sm); background: var(--color-bg-info-subtle); border-radius: var(--radius-md); }

/* Permissions grid */
.up-permissions-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: var(--space-xs) var(--space-md); }
.up-permission-item {
    display: flex; align-items: center; padding: 3px 0; font-size: var(--font-button); color: var(--color-text); cursor: pointer;
}
.up-permission-item input[type="checkbox"] { margin-right: 6px; }
.up-permission-item input:disabled { opacity: 0.4; }
.up-sec-badge {
    display: inline-block; margin-left: var(--space-xs); padding: 0 4px; border-radius: var(--radius-sm);
    font-size: var(--font-tiny); font-weight: 600; background: var(--color-warning); color: var(--color-black);
}

/* Photo upload */
.up-photo-area { text-align: center; padding: 20px 0; }
.up-photo-preview { width: 120px; height: 120px; border-radius: var(--radius-xl); object-fit: cover; border: 2px solid var(--color-border); }
.up-logo-preview { width: 120px; height: 120px; border-radius: var(--radius-xl); object-fit: contain; border: 2px solid var(--color-border); background: var(--color-white); }

/* Group detail two-column */
/* Dual-listbox (GroupDetailModal) */
.up-dlb-section-title { margin: 0 0 6px; font-size: var(--font-content); color: var(--color-brand); }
.up-dlb-container { display: flex; gap: 0; align-items: stretch; margin-bottom: var(--space-xs); }
.up-dlb-panel { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.up-dlb-label { font-size: var(--font-content-sm); font-weight: 600; color: var(--color-text-muted); margin-bottom: var(--space-xs); }
.up-dlb-list {
    flex: 1; min-height: 200px; max-height: 260px;
    border: 1px solid var(--color-border); border-radius: var(--radius-md);
    background: var(--color-bg-input); color: var(--color-text);
    font-size: var(--font-button); padding: 2px; overflow-y: auto;
}
.up-dlb-list option { padding: 3px 6px; }
.up-dlb-list option:checked { background: var(--color-brand); color: var(--color-white); }
.up-dlb-checklist {
    flex: 1; min-height: 200px; max-height: 260px;
    border: 1px solid var(--color-border); border-radius: var(--radius-md);
    background: var(--color-bg-input); color: var(--color-text);
    font-size: var(--font-button); padding: var(--space-xs); overflow-y: auto;
}
.up-dlb-check-item {
    display: flex; align-items: center; gap: var(--space-sm);
    padding: 4px 6px; cursor: pointer; border-radius: var(--radius-sm);
}
.up-dlb-check-item:hover { background: var(--bg-hover, rgba(0,0,0,0.05)); }
.up-dlb-check-item input[type="checkbox"] {
    width: 16px; height: 16px; margin: 0; cursor: pointer;
    accent-color: var(--color-brand);
}
.up-dlb-check-item span { flex: 1; user-select: none; }
.up-dlb-empty { color: var(--color-text-muted); text-align: center; padding: var(--space-lg); font-size: var(--font-content-sm); }
.up-dlb-buttons {
    display: flex; flex-direction: column; justify-content: center;
    gap: 6px; padding: 0 8px;
}
.up-dlb-btn {
    padding: 4px 10px; border: 1px solid var(--color-border); border-radius: var(--radius-md);
    background: var(--color-bg-surface); color: var(--color-text);
    font-size: var(--font-content); font-weight: 700; cursor: pointer;
    min-width: 40px; text-align: center;
}
.up-dlb-btn:hover:not(:disabled) { background: var(--color-brand); color: var(--color-white); }
.up-dlb-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* Legacy group styles (kept for potential reuse) */
.up-group-empty { color: var(--color-text-muted); text-align: center; padding: var(--space-lg); margin: 0; font-size: var(--font-button); }

/* Company devices */
.up-company-devices { border: 1px solid var(--color-border); border-radius: var(--radius-md); }

/* Security grid */
.up-security-grid, .up-trash-grid { max-width: 600px; }

/* Sessions table */
.up-sessions-table td, .up-sessions-table th { font-size: var(--font-content-sm); padding: 6px 8px; }

/* Regular user profile card */
.up-profile-card {
    max-width: 480px; margin: 40px auto; padding: 32px;
    background: var(--color-bg-surface); border-radius: var(--radius-2xl); border: 1px solid var(--color-border);
    text-align: center;
}
.up-profile-card h2 { color: var(--color-brand); margin: 12px 0 4px; }
.up-profile-avatar { margin-bottom: var(--space-sm); }
.up-profile-info { text-align: left; margin: 16px auto; max-width: 300px; }
.up-profile-row { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid var(--color-border); font-size: var(--font-content); }
.up-profile-row span:first-child { color: var(--color-text-muted); font-weight: 500; }

/* =====================================================================
   PRINT REPORTS (up-print- prefix)
   V1-matching format with headers, stats, company sections, device details
   ===================================================================== */

/* Print container — hidden on screen */
.up-print-container { display: none; }

/* Print header */
.up-print-header { margin-bottom: var(--space-lg); border-bottom: 2px solid #333; padding-bottom: 10px; }
.up-print-header h1 { font-size: 18px; margin: 0 0 4px; color: #111; }
.up-print-meta { font-size: var(--font-badge); color: #666; }
.up-print-role { display: inline-block; padding: 1px 6px; border-radius: var(--radius-sm); font-size: var(--font-tiny); font-weight: 700; text-transform: uppercase; margin-left: var(--space-xs); }
.up-print-role.super { background: #7c3aed; color: var(--color-white); }
.up-print-role.lsuper { background: #8b5cf6; color: var(--color-white); }
.up-print-role.master { background: #2563eb; color: var(--color-white); }

/* Summary stats */
.up-print-stats { display: flex; gap: var(--space-lg); margin-bottom: var(--space-xl); flex-wrap: wrap; }
.up-print-stat { text-align: center; padding: 10px 20px; border: 1px solid #ccc; border-radius: var(--radius-lg); background: #fafafa; min-width: 80px; }
.up-print-stat-val { font-size: 22px; font-weight: 700; color: #333; }
.up-print-stat-lbl { font-size: var(--font-tiny); text-transform: uppercase; color: #888; margin-top: 2px; }

/* Company section */
.up-print-company { margin-bottom: 24px; border: 1px solid #ddd; border-radius: var(--radius-lg); padding: var(--space-md) var(--space-lg); page-break-inside: avoid; }
.up-print-company-hdr { margin-bottom: 10px; }
.up-print-company-title { display: flex; align-items: center; gap: 10px; }
.up-print-company-title h2 { font-size: 15px; margin: 0; color: #222; }
.up-print-company-logo { width: 32px; height: 32px; border-radius: var(--radius-md); object-fit: contain; border: 1px solid #ddd; }
.up-print-letter-avatar { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: var(--radius-md); background: #2563eb; color: var(--color-white); font-weight: 700; font-size: var(--font-content); }
.up-print-company-detail { font-size: var(--font-badge); color: #666; margin-top: var(--space-xs); }
.up-print-company-detail span { margin-right: 12px; }
.up-print-company-stats { display: flex; gap: var(--space-md); flex-wrap: wrap; font-size: var(--font-badge); color: #555; margin-bottom: 10px; padding: 6px 10px; background: #f8f8f8; border-radius: var(--radius-md); }
.up-print-company-stats span { white-space: nowrap; }

/* Print tables */
.up-print-table { width: 100%; border-collapse: collapse; font-size: var(--font-badge); margin-bottom: var(--space-md); }
.up-print-table th, .up-print-table td { border: 1px solid #ccc; padding: 3px 6px; text-align: left; }
.up-print-table th { background: #f0f0f0; font-weight: 600; font-size: var(--font-tiny); text-transform: uppercase; }
.up-print-perms { font-size: 9px; color: #555; max-width: 150px; word-break: break-word; }
.up-print-deleted td { text-decoration: line-through; opacity: 0.5; }
.up-print-inactive td { opacity: 0.7; }
.up-print-empty { color: #888; font-size: var(--font-badge); text-align: center; padding: var(--space-md); font-style: italic; }
.up-print-warn { color: var(--color-danger); font-weight: 600; }

/* Device detail sections */
.up-print-devices-hdr { font-size: var(--font-button); font-weight: 700; margin: 12px 0 6px; padding-bottom: 2px; border-bottom: 1px solid #aaa; }
.up-print-device { margin-bottom: var(--space-md); padding: var(--space-sm); border: 1px solid #ddd; border-radius: var(--radius-md); background: #fdfdfd; page-break-inside: avoid; }
.up-print-device-title { font-size: var(--font-content-sm); font-weight: 700; color: #333; margin-bottom: var(--space-xs); }
.up-print-device-tbl { width: 100%; border-collapse: collapse; font-size: var(--font-tiny); }
.up-print-device-tbl td, .up-print-device-tbl th { border: 1px solid #ddd; padding: 2px 5px; }
.up-print-device-tbl td.l { font-weight: 600; color: #555; width: 110px; background: #f9f9f9; }
.up-print-di-grp { background: #e8e8e8 !important; font-weight: 700; text-align: center; text-transform: uppercase; font-size: 9px; letter-spacing: 0.5px; padding: 3px !important; }
.up-print-hw-grid { display: grid; grid-template-columns: auto 1fr auto 1fr; gap: 1px 8px; font-size: var(--font-tiny); padding: var(--space-xs); background: #f8f8f8; border: 1px solid #ddd; border-radius: var(--radius-sm); }
.up-print-hw-lbl { font-weight: 600; color: #555; }
.up-print-hw-val { color: #333; }

/* Contacts report */
.up-print-contacts-device { margin-bottom: var(--space-xl); padding: var(--space-md); border: 1px solid #ddd; border-radius: var(--radius-lg); page-break-inside: avoid; }
.up-print-contacts-hdr { margin-bottom: 10px; }
.up-print-contacts-sub { font-size: var(--font-badge); color: #666; }
.up-print-contact-name { font-weight: 600; }
.up-print-contact-count { font-size: var(--font-badge); color: #555; margin-top: var(--space-xs); text-align: right; }

/* Footer */
.up-print-footer { margin-top: 24px; padding-top: 8px; border-top: 1px solid #999; font-size: var(--font-tiny); color: #888; text-align: center; }

@media print {
    body * { visibility: hidden !important; }
    .up-print-container, .up-print-container * { visibility: visible !important; }
    .td-print-overlay, .td-print-overlay * { visibility: visible !important; }
    .up-print-container { position: absolute; top: 0; left: 0; width: 100%; z-index: 9999; background: var(--color-white); color: var(--color-black); padding: 15px; overflow: visible; }
    .up-print-container { display: block !important; }
    .up-print-header, .up-print-stats, .up-print-company, .up-print-company-hdr,
    .up-print-company-title, .up-print-company-detail, .up-print-company-stats,
    .up-print-device, .up-print-contacts-device, .up-print-contacts-hdr,
    .up-print-footer, .up-print-meta, .up-print-hw-grid { display: block !important; }
    .up-print-stats { display: flex !important; }
    .up-print-company-title { display: flex !important; }
    .up-print-company-stats { display: flex !important; }
    .up-print-hw-grid { display: grid !important; }
    .up-print-table, .up-print-device-tbl { display: table !important; page-break-inside: auto; }
    .up-print-table thead, .up-print-device-tbl thead { display: table-header-group !important; }
    .up-print-table tbody, .up-print-device-tbl tbody { display: table-row-group !important; }
    .up-print-table tr, .up-print-device-tbl tr { display: table-row !important; page-break-inside: avoid; }
    .up-print-table th, .up-print-table td, .up-print-device-tbl th, .up-print-device-tbl td { display: table-cell !important; }
    .up-print-company { page-break-inside: avoid; }
    .up-print-role, .up-print-letter-avatar, .up-print-company-logo { display: inline-block !important; }
    img.up-print-company-logo { display: inline !important; }
    @page { size: landscape; margin: 0.5in; }
}

/* Responsive */
@media (max-width: 768px) {
    .up-page { padding: var(--space-md) var(--space-lg); }
    .up-header { flex-direction: column; align-items: flex-start; }
    .up-header-buttons { width: 100%; }
    .up-header-buttons .up-btn { flex: 1; text-align: center; }
    .up-tabs { overflow-x: auto; }
    .up-tab { padding: var(--space-sm) var(--space-md); font-size: var(--font-button); }
    .up-form-row { flex-direction: column; gap: 0; }
    .up-dlb-container { flex-direction: column; }
    .up-dlb-buttons { flex-direction: row; justify-content: center; padding: 6px 0; }
    .up-modal { max-width: 95vw; }
    .up-modal-wide { max-width: 95vw; }
    .up-permissions-grid { grid-template-columns: 1fr; }
    .up-action-cell { flex-direction: column; }
}
@media (max-width: 480px) {
    .up-header h2 { font-size: 1.1rem; }
    .up-tab { padding: 6px 8px; font-size: var(--font-content-sm); }
}

/* =============================================================================
   SCREEN ID BADGES (Build 115)
   ============================================================================= */
.screen-id {
    font-size: 9px;
    font-family: 'Courier New', monospace;
    color: var(--color-text-muted);
    opacity: 0.5;
    vertical-align: super;
    margin-left: 6px;
    font-weight: normal;
    letter-spacing: 0.5px;
    user-select: all;
}

/* =============================================================================
   DEVICE TYPE ICONS (Build 115)
   ============================================================================= */
.cc-device-type-icon {
    display: inline-flex;
    align-items: center;
    vertical-align: middle;
    margin-right: var(--space-xs);
    flex-shrink: 0;
}

/* =============================================================================
   MESSAGES PAGE (Build 118) — msg- prefix
   ============================================================================= */

/* Layout */
.msg-app {
    display: flex;
    height: calc(100vh - 49px);
    overflow: hidden;
    background: var(--bg-body);
}

/* Contact Panel (Left) */
.msg-contact-panel {
    flex: 0 0 320px;
    min-width: 200px;
    max-width: 85%;
    display: flex;
    flex-direction: column;
    background: var(--color-bg-card);
    border-right: 1px solid var(--color-border-light);
    overflow: hidden;
}
.msg-contact-header {
    padding: 14px 16px 10px;
    border-bottom: 1px solid var(--color-border-light);
    flex-shrink: 0;
}
.msg-contact-header h2 {
    margin: 0;
    font-size: 1.1em;
    color: var(--color-brand);
    font-weight: 600;
    display: flex;
    align-items: center;
}
.msg-header-back {
    color: var(--color-brand);
    text-decoration: none;
    margin-right: var(--space-sm);
    display: inline-flex;
    align-items: center;
    transition: opacity var(--transition-fast);
}
.msg-header-back:hover { opacity: 0.7; }
/* (info banner removed — stats moved to conversation header) */
.msg-device-info {
    font-size: var(--font-badge);
    color: var(--color-text-muted);
    margin-top: 0;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-xs);
}
.msg-company-stats {
    font-size: var(--font-tiny);
    color: var(--color-text-muted);
    margin-top: 2px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.msg-company-logo {
    width: 20px;
    height: 20px;
    border-radius: var(--radius-md);
    object-fit: contain;
    flex-shrink: 0;
}
.msg-company-stats span {
    color: var(--color-brand);
    font-weight: 600;
}
.msg-header-icon-btn {
    background: none;
    border: 1px solid var(--color-border-light);
    color: var(--color-text-muted);
    border-radius: var(--radius-md);
    padding: 3px 5px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    transition: all var(--transition-fast);
}
.msg-header-icon-btn:hover {
    color: var(--color-brand);
    border-color: var(--color-brand);
    background: color-mix(in srgb, var(--color-brand) 10%, transparent);
}
.msg-header-icon-btn.filter-active {
    color: var(--color-brand);
    border-color: var(--color-brand);
    background: color-mix(in srgb, var(--color-brand) 18%, transparent);
}

/* Action Bar — labeled icon buttons */
.msg-action-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: var(--space-xs);
    padding-top: 4px;
    border-top: 1px solid var(--color-border-light);
}
.msg-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 12px;
    font-size: var(--font-button);
    font-weight: 700;
    color: var(--color-brand);
    background: var(--bg-body);
    border: 1px solid var(--color-brand);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}
.msg-action-btn svg {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
}
.msg-action-btn:hover {
    background: var(--color-brand);
    color: var(--color-white);
}
.msg-action-btn:hover svg {
    stroke: var(--color-white);
}

/* Search */
.msg-search-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px 3px;
    flex-shrink: 0;
}
.msg-search-clear {
    background: none;
    border: none;
    color: var(--color-text-muted);
    cursor: pointer;
    padding: 0 4px;
    display: inline-flex;
    align-items: center;
}
.msg-search-clear:hover { color: var(--color-brand); }
.msg-search-count {
    font-size: var(--font-tiny);
    color: var(--color-text-muted);
    white-space: nowrap;
}

/* Sort Bar */
.msg-sort-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 12px 6px;
    font-size: var(--font-sidebar-header);
    color: var(--color-text-muted);
}
.msg-sort-bar .msg-trash-btn {
    margin-left: auto;
}
.msg-sort-option {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    white-space: nowrap;
    user-select: none;
}
.msg-sort-option::before {
    content: '';
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid var(--color-text-muted);
    border-radius: 50%;
    flex-shrink: 0;
}
.msg-sort-option.active::before {
    background: var(--color-brand);
    border-color: var(--color-brand);
}
.msg-sort-option.active {
    color: var(--color-text);
}

/* Trash button (used in sort bar) */
.msg-trash-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--color-text-muted);
    padding: 2px 4px;
    border-radius: var(--radius-md);
    transition: color var(--transition-fast), background var(--transition-fast);
}
.msg-trash-btn:hover {
    color: var(--color-danger);
    background: rgba(220,53,69,0.08);
}
.msg-trash-btn.active {
    color: var(--color-danger);
    background: rgba(220,53,69,0.08);
}

/* Tab Bar — contact sidebar filter tabs */
.msg-tab-bar {
    display: flex;
    align-items: center;
    gap: 0;
    border-bottom: 1px solid var(--color-border-light);
    margin-top: 6px;
}
.msg-tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-xs);
    padding: 5px 0;
    font-size: var(--font-tiny);
    font-weight: 600;
    color: var(--color-text-muted);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}
.msg-tab:hover {
    color: var(--color-text);
    background: rgba(255,255,255,0.03);
}
.msg-tab.active {
    color: var(--color-text);
    border-bottom-color: var(--color-brand);
}
.msg-tab-icon {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}
.msg-tab-badge {
    background: var(--color-success);
    color: var(--color-white);
    font-size: var(--font-content-sm);
    font-weight: 700;
    padding: 0 5px;
    border-radius: var(--radius-pill);
    min-width: 16px;
    text-align: center;
    line-height: 16px;
}
.msg-tab-readall {
    flex-shrink: 0;
    background: none;
    border: none;
    color: var(--color-text-muted);
    cursor: pointer;
    padding: 2px 6px;
    border-radius: var(--radius-md);
    transition: color var(--transition-fast);
    display: flex;
    align-items: center;
}
.msg-tab-readall:hover {
    color: var(--color-success);
}

/* Inline delete confirmation bar */
.msg-confirm-bar {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: 6px 12px;
    border-bottom: 1px solid var(--color-border-light);
    background: var(--color-bg-confirm);
    font-size: var(--font-content-sm);
    font-weight: 600;
}
.msg-confirm-bar span { flex: 1; color: var(--color-text-confirm); }
.msg-confirm-yes {
    background: var(--color-danger);
    color: var(--color-text);
    border: none;
    border-radius: var(--radius-md);
    padding: 3px 12px;
    font-size: var(--font-content-sm);
    font-weight: 600;
    cursor: pointer;
}
.msg-confirm-yes:hover { opacity: 0.85; color: var(--color-white); }
.msg-confirm-no {
    background: var(--color-brand);
    color: var(--color-text);
    border: none;
    border-radius: var(--radius-md);
    padding: 3px 12px;
    font-size: var(--font-content-sm);
    font-weight: 600;
    cursor: pointer;
}
.msg-confirm-no:hover { opacity: 0.85; color: var(--color-white); }

/* Bulk action panel — slides in when checkboxes selected */
.msg-bulk-panel {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: 5px 12px;
    background: var(--color-bg-input);
    border-bottom: 1px solid var(--color-brand);
    font-size: var(--font-content-sm);
    animation: msgBulkSlideIn 0.2s ease-out;
}
@keyframes msgBulkSlideIn {
    from { max-height: 0; opacity: 0; padding: 0 12px; }
    to { max-height: 40px; opacity: 1; padding: 5px 12px; }
}
.msg-bulk-btn {
    background: none;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 2px 8px;
    font-size: var(--font-badge);
    cursor: pointer;
    color: var(--color-text-secondary);
}
.msg-bulk-btn:hover { border-color: var(--color-brand); color: var(--color-brand); }
.msg-bulk-count { color: var(--color-text-muted); font-size: var(--font-badge); }
.msg-bulk-trash {
    margin-left: auto;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--color-danger);
    padding: 2px 4px;
}
.msg-bulk-trash:hover { color: var(--color-danger); opacity: 0.85; }
.msg-bulk-confirm-text { color: var(--color-text-confirm); font-weight: 600; flex: 1; }

/* Conversation header — device stats */
.msg-conv-stats {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    font-size: var(--font-tiny);
    color: var(--color-text-muted);
    margin-left: var(--space-sm);
    line-height: 1.3;
    white-space: nowrap;
}
.msg-conv-stats-device { font-weight: 500; }
.msg-conv-stats-counts span { color: var(--color-brand); font-weight: 600; }

/* Deleted contact styling */
.msg-contact-item.deleted-contact {
    opacity: 0.7;
    background: var(--color-bg-deleted);
}
.msg-contact-item.deleted-contact:hover {
    background: var(--color-bg-deleted);
    opacity: 0.9;
}
.msg-deleted-label {
    font-size: 9px;
    font-weight: 700;
    color: var(--color-danger);
    background: rgba(220,53,69,0.1);
    padding: 1px 4px;
    border-radius: var(--radius-sm);
    margin-left: var(--space-xs);
}
.msg-restore-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--color-success);
    padding: 2px;
    border-radius: var(--radius-sm);
    transition: background var(--transition-fast);
}
.msg-restore-btn:hover {
    background: rgba(40,167,69,0.12);
}

/* Conversation trash button */
.msg-conv-trash-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--color-text-muted);
    padding: 4px 6px;
    border-radius: var(--radius-md);
    transition: color var(--transition-fast), background var(--transition-fast);
}
.msg-conv-trash-btn:hover {
    color: var(--color-text);
    background: rgba(0,0,0,0.06);
}
.msg-conv-trash-btn.active {
    color: var(--color-danger);
    background: rgba(220,53,69,0.08);
}

/* Contact List */
.msg-contact-list {
    flex: 1;
    overflow-y: auto;
    overscroll-behavior: contain;
    overflow-x: hidden;
}
.msg-contact-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    cursor: pointer;
    border-bottom: 1px solid var(--color-border-light);
    transition: background 0.12s;
}
.msg-contact-item:hover {
    background: color-mix(in srgb, var(--color-brand) 8%, transparent);
}
.msg-contact-item.active {
    background: color-mix(in srgb, var(--color-brand) 15%, transparent);
    border-left: 3px solid var(--color-brand);
    padding-left: 11px;
}
.msg-contact-item.orphan {
    background: var(--color-bg-orphan);
    color: var(--color-text-orphan);
    font-weight: 600;
}
.msg-contact-item.orphan .msg-contact-add-btn {
    color: var(--color-black);
}
.msg-contact-item.orphan .msg-contact-name,
.msg-contact-item.orphan .msg-contact-phone-label,
.msg-contact-item.orphan .msg-contact-preview,
.msg-contact-item.orphan .msg-contact-time,
.msg-contact-item.orphan .msg-contact-badge {
    color: var(--color-text-orphan);
}
.msg-contact-item.orphan:hover {
    background: var(--color-bg-orphan);
    opacity: 0.9;
}
.msg-contact-item.orphan.active {
    background: var(--color-bg-orphan);
    opacity: 0.85;
}
.msg-contact-avatar-img {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-circle);
    object-fit: cover;
    flex-shrink: 0;
}
.msg-contact-info {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}
.msg-contact-name {
    font-weight: 600;
    font-size: var(--font-contact, 0.9em);
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.msg-contact-phone-label {
    font-size: calc(var(--font-contact, 12px) - 2px);
    color: var(--color-text-muted);
    margin-top: 1px;
}
.msg-contact-preview {
    font-size: calc(var(--font-contact, 12px) - 1px);
    color: var(--color-text-muted);
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.msg-contact-meta {
    text-align: right;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: var(--space-xs);
}
.msg-contact-time {
    font-size: var(--font-tiny);
    color: var(--color-text-muted);
    white-space: nowrap;
}
.msg-unread-badge {
    background: var(--color-danger);
    color: var(--color-white);
    font-size: var(--font-tiny);
    font-weight: 700;
    padding: 2px 6px;
    border-radius: var(--radius-pill);
    min-width: 18px;
    text-align: center;
}
.msg-contact-badge {
    font-size: var(--font-tiny);
    color: var(--color-brand);
    opacity: 0.7;
}
.msg-contact-edit-icon {
    cursor: pointer;
    color: var(--color-brand);
    opacity: 0.6;
    transition: opacity var(--transition-fast);
    display: inline-flex;
    align-items: center;
}
.msg-contact-edit-icon:hover { opacity: 1; }
.msg-contact-pin {
    cursor: pointer;
    opacity: 0.5;
    transition: opacity var(--transition-fast), color var(--transition-fast);
    display: inline-flex;
    align-items: center;
    color: var(--color-text-muted);
}
.msg-contact-pin:hover { opacity: 0.85; }
.msg-contact-pin.pinned {
    opacity: 0.85;
    color: var(--color-brand);
}
.msg-contact-pin.pinned:hover { opacity: 1; }

/* --- Pinned section header + separator --- */
.msg-pinned-header {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 0 6px; margin-left: 6px; cursor: pointer;
    font-size: var(--font-content-sm); color: var(--color-text-muted);
    user-select: none;
}
.msg-pinned-header:hover { color: var(--color-text-secondary); }
.msg-pinned-toggle { font-size: 0.65em; width: 12px; text-align: center; }
.msg-pinned-separator { height: 2px; background: var(--color-border); margin: 0; }
.msg-contact-item.pinned-bg { background: var(--color-bg-body); }
.msg-contact-item.pinned-bg:hover { background: color-mix(in srgb, var(--color-brand) 8%, var(--color-bg-body)); }

.msg-contact-add-btn {
    background: none;
    border: 1px solid var(--color-brand);
    color: var(--color-brand);
    width: 18px;
    height: 18px;
    border-radius: var(--radius-circle);
    font-size: var(--font-content-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}
.msg-contact-add-btn:hover {
    background: var(--color-brand);
    color: var(--color-bg-card);
}
.msg-no-unread {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-4xl) var(--space-xl);
    color: var(--color-text-muted);
    text-align: center;
}

/* Resize Handle */
.msg-resize-handle {
    width: 4px;
    padding: 0 3px;
    margin: 0 -3px;
    cursor: col-resize;
    background: var(--color-border-light);
    background-clip: content-box;
    transition: background var(--transition-fast);
    flex-shrink: 0;
    z-index: 5;
    position: relative;
}
.msg-resize-handle:hover,
.msg-resize-handle.active,
.msg-resize-handle.dragging {
    background: var(--color-brand);
}

/* Conversation Panel (Right) */
.msg-conversation-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-body);
    min-width: 0;
    position: relative;
}
.msg-no-conversation {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    flex: 1;
    color: var(--color-text-muted);
    font-size: 1.1em;
}

/* Conversation Header */
.msg-conversation-header {
    display: flex;
    align-items: center;
    padding: 10px 16px;
    border-bottom: 1px solid var(--color-border-light);
    background: var(--color-bg-card);
    gap: var(--space-sm);
    flex-shrink: 0;
}
.msg-conv-header-name {
    font-weight: 600;
    font-size: var(--font-button);
    display: flex;
    align-items: center;
    gap: 6px;
}
.msg-conv-header-phone {
    font-size: var(--font-badge);
    color: var(--color-text-muted);
}
.msg-mobile-back {
    display: none;
    background: none;
    border: none;
    color: var(--color-brand);
    cursor: pointer;
    padding: 0 8px 0 0;
    align-items: center;
}
.msg-fontsize-control {
    display: flex;
    align-items: center;
    gap: 2px;
    margin-left: auto;
}
.msg-fontsize-btn {
    background: none;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    cursor: pointer;
    padding: 3px 5px;
    color: var(--color-text-secondary);
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.msg-fontsize-btn:hover:not(:disabled) {
    background: var(--color-bg-input);
    color: var(--color-text);
    border-color: var(--color-brand);
}
.msg-fontsize-btn:disabled {
    opacity: 0.3;
    cursor: default;
}
.msg-fontsize-label {
    font-size: var(--font-content-sm);
    font-weight: 600;
    min-width: 14px;
    text-align: center;
    color: var(--color-text-secondary);
}
.msg-show-deleted {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    font-size: var(--font-badge);
    color: var(--color-text-muted);
    margin-left: var(--space-sm);
}
.msg-show-deleted.active label {
    color: var(--color-brand);
}
.msg-select-btn {
    background: none;
    border: 1px solid var(--color-border-light);
    color: var(--color-text-muted);
    border-radius: var(--radius-md);
    padding: 3px 7px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.msg-select-btn:hover {
    color: var(--color-brand);
    border-color: var(--color-brand);
}

/* Delete Toolbar */
.msg-delete-toolbar {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-lg);
    background: var(--color-bg-card);
    border-bottom: 1px solid var(--color-border-light);
    font-size: var(--font-content-sm);
    flex-shrink: 0;
}

/* Message List */
.msg-messages-container {
    flex: 1;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: var(--space-lg);
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
    font-size: var(--font-msg);
}
.msg-loading-spinner {
    width: 32px; height: 32px;
    border: 3px solid var(--color-border-light);
    border-top: 3px solid var(--color-brand);
    border-radius: var(--radius-circle);
    animation: ccSpin 0.8s linear infinite;
}
.msg-load-more {
    text-align: center;
    padding: var(--space-sm);
    font-size: var(--font-content-sm);
}
.msg-load-more button {
    color: var(--color-brand);
    background: none;
    border: none;
    cursor: pointer;
    font-size: inherit;
    font-family: inherit;
    padding: 0;
}
.msg-load-more button:hover { text-decoration: underline; }

/* Date Separator */
.msg-date-separator {
    text-align: center;
    margin: 12px 0 8px;
}
.msg-date-separator span {
    background: var(--color-bg-card);
    padding: 3px 12px;
    border-radius: var(--radius-pill);
    font-size: var(--font-tiny);
    color: var(--color-text-muted);
    border: 1px solid var(--color-border-light);
}

/* Message Bubbles */
.msg-message-wrapper {
    display: flex;
    align-items: flex-start;
    gap: 6px;
}
.msg-message-wrapper.outgoing { justify-content: flex-end; }
.msg-message-wrapper.incoming { justify-content: flex-start; }
.msg-message-wrapper.selected { background: color-mix(in srgb, var(--color-brand) 8%, transparent); border-radius: var(--radius-xl); padding: 2px 4px; }
.msg-checkbox {
    margin-top: var(--space-sm);
    flex-shrink: 0;
}
.msg-bubble {
    max-width: 70%;
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-2xl);
    font-size: var(--font-msg);
    line-height: 1.4;
    word-wrap: break-word;
    position: relative;
}
.msg-bubble.incoming {
    background: var(--color-bg-card);
    border: 1px solid var(--color-border-light);
    border-bottom-left-radius: 4px;
}
.msg-bubble.outgoing {
    background: var(--color-bg-bubble-out);
    border: 1px solid var(--color-border-bubble-out);
    border-bottom-right-radius: 4px;
}
.msg-bubble.sending {
    opacity: 0.7;
}
.msg-bubble.failed {
    border-color: var(--color-danger);
    background: rgba(220, 53, 69, 0.08);
}
.msg-bubble.deleted {
    opacity: 0.5;
    border-style: dashed;
}
.msg-bubble.email-msg.incoming {
    background: var(--color-bg-email-in);
    border-color: var(--color-border-email-in);
}
.msg-bubble.email-msg.outgoing {
    background: var(--color-bg-email-out);
    border-color: var(--color-border-email-out);
}

/* Email preview in bubble */
.email-preview {
    font-size: var(--font-button);
}
.email-preview-header {
    font-size: var(--font-content-sm);
    color: var(--color-text-muted);
    margin-bottom: 6px;
    line-height: 1.4;
}
.email-preview-header div {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.email-preview-body {
    white-space: pre-wrap;
    word-break: break-word;
    margin-bottom: 6px;
    line-height: 1.4;
}
.email-preview-link {
    font-size: var(--font-content-sm);
    color: var(--color-email-link);
    cursor: pointer;
    text-decoration: underline;
}
.email-preview-link:hover {
    color: var(--color-email-link);
    opacity: 0.85;
}

/* Email modal */
.email-modal {
    max-width: 800px !important;
    width: 90%;
}
.email-modal-header-info {
    padding: var(--space-md) var(--space-lg);
    border-bottom: 1px solid var(--color-border-light);
    font-size: var(--font-button);
    line-height: 1.6;
    background: var(--color-bg-secondary);
}
.email-modal-header-info strong {
    color: var(--color-text-muted);
    min-width: 60px;
    display: inline-block;
}
.email-modal-body {
    flex: 1;
    overflow-y: auto;
    max-height: 60vh;
}
.email-modal-body iframe {
    width: 100%;
    min-height: 300px;
    border: none;
    background: var(--color-white);
}

.msg-deleted-badge {
    font-size: 0.65em;
    color: var(--color-danger);
    font-weight: 700;
    margin-bottom: 2px;
}
.msg-text {
    white-space: pre-wrap;
    word-break: break-word;
}

/* MMS Attachments */
.msg-mms-image {
    max-width: 100%;
    max-height: 300px;
    border-radius: var(--radius-xl);
    cursor: pointer;
    margin-bottom: var(--space-xs);
    display: block;
}
.msg-mms-video {
    max-width: 100%;
    max-height: 300px;
    border-radius: var(--radius-xl);
    margin-bottom: var(--space-xs);
}
.msg-mms-file {
    display: inline-block;
    padding: 6px 10px;
    background: color-mix(in srgb, var(--color-brand) 10%, transparent);
    border-radius: var(--radius-lg);
    font-size: var(--font-content-sm);
    color: var(--color-brand);
    text-decoration: none;
    margin-bottom: var(--space-xs);
}
.msg-mms-file:hover { text-decoration: underline; }

/* Message Meta */
.msg-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: var(--space-xs);
    font-size: var(--font-tiny);
    color: var(--color-text-muted);
}
.msg-status-check {
    color: var(--color-brand);
    display: inline-flex;
    align-items: center;
}
.msg-translate-link {
    cursor: pointer;
    color: var(--color-brand);
    opacity: 0.7;
}
.msg-translate-link:hover { opacity: 1; }

/* Metadata Link & Block (Master only) */
.msg-metadata-link {
    cursor: pointer;
    color: var(--color-text-muted);
    opacity: 0.6;
    font-size: var(--font-tiny);
}
.msg-metadata-link:hover {
    color: var(--color-brand);
    opacity: 1;
    text-decoration: underline;
}
.msg-metadata {
    margin-top: 4px;
    padding: 6px 10px;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    background: var(--color-bg-secondary);
    font-size: var(--font-tiny);
    color: var(--color-text-muted);
    line-height: 1.6;
}
.msg-metadata-label {
    font-weight: 600;
    color: var(--color-text);
}

/* Status Text */
.msg-status-text {
    font-size: var(--font-tiny);
    margin-top: 2px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.status-sending { color: var(--color-text-muted); }
.status-failed {
    color: var(--color-danger);
    cursor: pointer;
}
.msg-retry:hover { text-decoration: underline; }
.msg-status-cancel {
    color: var(--color-text-muted);
    cursor: pointer;
    opacity: 0.6;
    display: inline-flex;
    align-items: center;
}
.msg-status-cancel:hover { opacity: 1; color: var(--color-danger); }

/* Translated Text */
.msg-translated {
    display: none;
    margin-top: var(--space-xs);
    padding: var(--space-xs) var(--space-sm);
    background: color-mix(in srgb, var(--color-brand) 8%, transparent);
    border-left: 2px solid var(--color-brand);
    border-radius: 0 4px 4px 0;
    font-size: var(--font-content-sm);
    color: var(--color-text-muted);
}
.msg-translated.active { display: block; }
.msg-translated-label {
    font-size: var(--font-tiny);
    color: var(--color-brand);
    font-weight: 600;
    margin-bottom: 2px;
}

/* Translation Bar */
.msg-translate-bar {
    display: none;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--color-bg-card);
    border-top: 1px solid var(--color-border-light);
    font-size: var(--font-badge);
    flex-shrink: 0;
}
.msg-translate-bar.active { display: flex; }

/* Attachment Preview */
.msg-attachment-preview {
    display: none;
    padding: var(--space-sm) var(--space-md);
    background: var(--color-bg-card);
    border-top: 1px solid var(--color-border-light);
    flex-shrink: 0;
}
.msg-attachment-preview.active { display: block; }
.msg-attachment-inner {
    display: flex;
    align-items: center;
    gap: 10px;
}
.msg-attachment-thumb {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-lg);
    object-fit: cover;
}
.msg-attachment-placeholder {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: color-mix(in srgb, var(--color-brand) 10%, transparent);
    border-radius: var(--radius-lg);
}
.msg-attachment-info {
    flex: 1;
    font-size: var(--font-content-sm);
    min-width: 0;
    overflow: hidden;
}
.msg-attachment-remove {
    background: none;
    border: none;
    color: var(--color-text-muted);
    cursor: pointer;
    padding: 0 4px;
    display: inline-flex;
    align-items: center;
}
.msg-attachment-remove:hover { color: var(--color-danger); }

/* Compose Area */
.msg-compose-area {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    padding: 10px 12px;
    border-top: 1px solid var(--color-border-light);
    background: var(--color-bg-card);
    flex-shrink: 0;
}
.msg-compose-btn {
    background: none;
    border: none;
    color: var(--color-text-muted);
    cursor: pointer;
    padding: var(--space-xs);
    border-radius: var(--radius-md);
    flex-shrink: 0;
    transition: color var(--transition-fast);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.msg-compose-btn svg {
    width: calc(var(--font-msg, 14px) + 4px) !important;
    height: calc(var(--font-msg, 14px) + 4px) !important;
}
.msg-compose-btn:hover { color: var(--color-brand); }
.msg-compose-btn.active { color: var(--color-brand); }
.msg-compose-btn.has-attachment { color: var(--color-brand); }
.msg-compose-input {
    flex: 1;
    border: 1px solid var(--color-border-light);
    border-radius: var(--radius-xl);
    padding: var(--space-sm) var(--space-md);
    font-size: var(--font-msg);
    background: var(--bg-body);
    color: var(--color-text);
    resize: none;
    min-height: 36px;
    max-height: 120px;
    outline: none;
    font-family: inherit;
    line-height: 1.4;
}
.msg-compose-input:focus {
    border-color: var(--color-brand);
}
.msg-send-btn {
    background: var(--color-brand);
    border: none;
    color: var(--color-bg-card);
    width: calc(var(--font-msg, 14px) + 22px);
    height: calc(var(--font-msg, 14px) + 22px);
    border-radius: var(--radius-circle);
    cursor: pointer;
    font-size: 1.1em;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: opacity var(--transition-fast);
}
.msg-send-btn svg {
    width: calc(var(--font-msg, 14px) + 4px) !important;
    height: calc(var(--font-msg, 14px) + 4px) !important;
}
.msg-send-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}
.msg-send-btn:not(:disabled):hover {
    opacity: 0.85;
}
.msg-char-count {
    font-size: var(--font-tiny);
    color: var(--color-text-muted);
    text-align: right;
    margin-top: 2px;
}

/* Drop Zone Overlay */
.msg-drop-zone-overlay {
    display: none;
    position: absolute;
    inset: 0;
    background: color-mix(in srgb, var(--color-brand) 10%, transparent);
    border: 2px dashed var(--color-brand);
    border-radius: var(--radius-xl);
    z-index: 100;
    align-items: center;
    justify-content: center;
}
.msg-drop-zone-overlay.active { display: flex; }
.msg-drop-zone-content { text-align: center; }

/* Emoji Picker */
.msg-emoji-picker {
    display: flex;
    position: absolute;
    bottom: 100%;
    left: 0;
    right: 0;
    max-height: 360px;
    background: var(--color-bg-card);
    border: 1px solid var(--color-border-light);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    z-index: 50;
    overflow: hidden;
    flex-direction: column;
}
.msg-emoji-tabs {
    display: flex;
    border-bottom: 1px solid var(--color-border-light);
    flex-shrink: 0;
    overflow-x: auto;
    scrollbar-width: none;
}
.msg-emoji-tabs::-webkit-scrollbar { display: none; }
.msg-emoji-tab {
    flex: 0 0 auto;
    background: none;
    border: none;
    color: var(--color-text-muted);
    padding: 6px 6px;
    cursor: pointer;
    font-size: 1.1em;
    text-align: center;
    min-width: 32px;
}
.msg-emoji-tab.active {
    background: color-mix(in srgb, var(--color-brand) 12%, transparent);
    border-bottom: 2px solid var(--color-brand);
}
.msg-emoji-pin {
    margin-left: auto;
    color: var(--color-text-muted);
}
.msg-emoji-pin.active {
    color: var(--color-brand);
}
.msg-emoji-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(36px, 1fr));
    gap: 2px;
    padding: var(--space-sm);
    overflow-y: auto;
    flex: 1;
}
.msg-emoji-btn {
    background: none;
    border: none;
    font-size: 1.5em;
    cursor: pointer;
    padding: var(--space-xs);
    border-radius: var(--radius-md);
    text-align: center;
}
.msg-emoji-btn:hover {
    background: color-mix(in srgb, var(--color-brand) 15%, transparent);
}

/* Image Lightbox */
.msg-lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.9);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
.msg-lightbox img {
    max-width: 95vw;
    max-height: 95vh;
    object-fit: contain;
    border-radius: var(--radius-md);
}
.msg-lightbox-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: none;
    border: none;
    color: var(--color-white);
    cursor: pointer;
    opacity: 0.7;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity var(--transition-fast);
    z-index: 10000;
}
.msg-lightbox-close:hover { opacity: 1; }

/* Modals (Messages page) */
.msg-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}
.msg-modal-overlay.active { display: flex; }
.msg-modal {
    position: relative;
    background: var(--color-bg-card);
    border: 1px solid var(--color-border-light);
    border-radius: var(--radius-xl);
    width: 90%;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-xl);
}
.msg-resize-grip {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 20px;
    height: 20px;
    cursor: nwse-resize;
    z-index: 11;
    opacity: 0.25;
    transition: opacity 0.15s;
    border-radius: 0 0 var(--radius-xl) 0;
}
.msg-resize-grip:hover {
    opacity: 0.7;
    background: rgba(0, 149, 255, 0.1);
}
.msg-modal-header {
    display: flex;
    align-items: center;
    padding: var(--space-md) var(--space-lg);
    border-bottom: 1px solid var(--color-border-light);
    gap: var(--space-sm);
}
.msg-modal-header h3 {
    margin: 0;
    font-size: 1em;
    flex: 1;
}
.msg-modal-close {
    background: none;
    border: none;
    color: var(--color-text-muted);
    cursor: pointer;
    padding: 0 4px;
    display: inline-flex;
    align-items: center;
}
.msg-modal-close:hover { color: var(--color-danger); }
.msg-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-sm);
    padding: var(--space-md) var(--space-lg);
    border-top: 1px solid var(--color-border-light);
}
.msg-delete-confirm {
    text-align: center;
    padding: var(--space-xl) var(--space-lg);
    border-top: 1px solid var(--color-border-light);
    background: var(--color-bg-card);
}
.msg-delete-confirm-icon {
    margin-bottom: var(--space-sm);
}

/* Buttons */
.msg-btn-primary {
    background: var(--color-brand);
    color: var(--color-bg-card);
    border: none;
    padding: 6px 16px;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: var(--font-content-sm);
    font-weight: 600;
}
.msg-btn-primary:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
.msg-btn-cancel {
    background: none;
    border: 1px solid var(--color-border-light);
    color: var(--color-text-muted);
    padding: 6px 16px;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: var(--font-content-sm);
}
.msg-btn-cancel:hover { border-color: var(--color-brand); color: var(--color-brand); }
.msg-btn-danger {
    background: var(--color-danger);
    color: var(--color-white);
    border: none;
    padding: 6px 14px;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: var(--font-content-sm);
}
.msg-btn-success {
    background: var(--color-success);
    color: var(--color-white);
    border: none;
    padding: 6px 14px;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: var(--font-content-sm);
}
.msg-btn-small {
    background: none;
    border: 1px solid var(--color-border-light);
    color: var(--color-text-muted);
    padding: 3px 10px;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: var(--font-badge);
}
.msg-btn-small:hover { border-color: var(--color-brand); color: var(--color-brand); }

/* Forms */
.msg-form-input {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid var(--color-border-light);
    border-radius: var(--radius-md);
    background: var(--bg-body);
    color: var(--color-text);
    font-size: var(--font-content-sm);
    outline: none;
    font-family: inherit;
}
.msg-form-input:focus { border-color: var(--color-brand); }
.msg-form-input[readonly] { opacity: 0.6; cursor: default; }
.msg-form-group {
    margin-bottom: var(--space-sm);
}
.msg-form-group label {
    display: block;
    font-size: var(--font-badge);
    color: var(--color-text-muted);
    margin-bottom: 3px;
    font-weight: 600;
}
.msg-form-row {
    display: flex;
    gap: 10px;
}
.msg-form-row > .msg-form-group { flex: 1; }

/* Tab Bar */
.msg-tab-bar {
    display: flex;
    border-bottom: 1px solid var(--color-border-light);
    padding: 0 8px;
}
.msg-tab {
    background: none;
    border: none;
    color: var(--color-text-muted);
    padding: 8px 14px;
    cursor: pointer;
    font-size: var(--font-content-sm);
    border-bottom: 2px solid transparent;
}
.msg-tab.active {
    color: var(--color-brand);
    border-bottom-color: var(--color-brand);
}
.msg-tab:hover { color: var(--color-text); }

/* Stats Row */
.msg-stat-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: 1px solid var(--color-border-light);
    font-size: var(--font-content-sm);
}
.msg-stat-row:last-child { border-bottom: none; }
.msg-stat-row span:first-child { color: var(--color-text-muted); }
.msg-stat-row span:last-child { font-weight: 600; }

/* Contact Profile (in modal) */
.msg-contact-profile {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    margin-bottom: var(--space-md);
}
.msg-contact-profile-img {
    width: 72px;
    height: 72px;
    border-radius: var(--radius-circle);
    object-fit: cover;
    flex-shrink: 0;
}
.msg-contact-profile-actions {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}
.msg-contact-profile-actions button {
    background: none;
    border: 1px solid var(--color-border-light);
    color: var(--color-brand);
    padding: 3px 10px;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: var(--font-badge);
}
.msg-contact-profile-actions button:hover {
    background: color-mix(in srgb, var(--color-brand) 10%, transparent);
}

/* Deleted Badge in modal */
.msg-deleted-badge {
    background: rgba(220, 53, 69, 0.15);
    color: var(--color-danger);
    font-size: var(--font-tiny);
    font-weight: 700;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
}

/* Broadcast List */
.msg-broadcast-compose {
    padding: 12px 16px 0;
}
.msg-broadcast-bar {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-lg);
    border-bottom: 1px solid var(--color-border-light);
}
.msg-broadcast-count {
    font-size: var(--font-badge);
    color: var(--color-text-muted);
}
.msg-broadcast-modal {
    max-width: 480px;
}
.msg-broadcast-modal .msg-form-input,
.msg-broadcast-modal textarea.msg-form-input {
    font-size: inherit;
}
@media (min-width: 768px) {
    .msg-broadcast-modal {
        max-width: 560px;
    }
}
.msg-broadcast-list {
    padding: 0 8px;
}
.msg-broadcast-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 8px;
    cursor: pointer;
    border-radius: var(--radius-md);
}
.msg-broadcast-row:hover {
    background: color-mix(in srgb, var(--color-brand) 8%, transparent);
}
.msg-broadcast-info { flex: 1; min-width: 0; }
.msg-broadcast-name {
    font-size: var(--font-content-sm);
    font-weight: 600;
}
.msg-broadcast-phone {
    font-size: var(--font-tiny);
    color: var(--color-text-muted);
}

/* Debug ID Badges (yellow/black PK) */
.msg-debug-id {
    display: inline-block;
    background: var(--color-warning);
    color: var(--color-black);
    font-family: 'Courier New', monospace;
    font-size: 0.65em;
    font-weight: 700;
    padding: 1px 4px;
    border-radius: var(--radius-sm);
    line-height: 1;
}
.msg-meta .msg-debug-id {
    margin-right: var(--space-xs);
}

/* Broadcast Checkbox on Contact Sidebar */
.msg-broadcast-check {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--color-brand);
    margin-left: var(--space-xs);
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .msg-app {
        position: relative;
    }
    .msg-contact-panel {
        position: absolute;
        left: 0;
        top: 0;
        bottom: 0;
        width: 100% !important;
        max-width: 100% !important;
        z-index: 10;
        transition: transform var(--transition-normal);
    }
    .msg-app.msg-contact-hidden .msg-contact-panel {
        transform: translateX(-100%);
    }
    .msg-resize-handle { display: none; }
    .msg-mobile-back { display: block; }
    .msg-conversation-panel { width: 100%; }
    .msg-bubble { max-width: 85%; }
}

/* =============================================================================
   DEVICE LOG TABLE (Build 173) — dl- prefix
   ============================================================================= */

.dl-table-scroll {
    overflow-x: auto;
    overflow-y: auto;
    max-height: 65vh;
    border: 1px solid var(--color-border);
    border-radius: 0;
}
.dl-table {
    width: max-content;
    min-width: 100%;
    border-collapse: collapse;
    font-size: var(--font-content-sm);
    font-family: 'Consolas', 'Courier New', monospace;
}
.dl-table thead { position: sticky; top: 0; z-index: 3; }
.dl-table th {
    background: var(--color-bg-surface);
    color: var(--color-text-muted);
    text-align: left;
    padding: 6px 8px;
    font-weight: 600;
    font-size: var(--font-tiny);
    text-transform: uppercase;
    border-bottom: 2px solid var(--color-border);
    border-right: 1px solid var(--color-border);
    white-space: nowrap;
}
.dl-table th:last-child { border-right: none; }
.dl-table td {
    padding: var(--space-xs) var(--space-sm);
    border-bottom: 1px solid var(--color-border);
    border-right: 1px solid var(--color-border-light);
    color: var(--color-text);
    vertical-align: middle;
}
.dl-table td:last-child { border-right: none; }
.dl-table tbody tr:nth-child(even) { background: rgba(var(--color-brand-rgb, 100,100,255), 0.03); }
.dl-table tbody tr:hover { background: rgba(var(--color-brand-rgb, 100,100,255), 0.07); }
.dl-sticky-col {
    position: sticky;
    left: 0;
    z-index: 2;
    background: var(--color-bg-surface);
}
.dl-table tbody td.dl-sticky-col { background: var(--color-bg-surface); }
.dl-table tbody tr:nth-child(even) td.dl-sticky-col { background: var(--color-bg-surface); }
.dl-table tbody tr:hover td.dl-sticky-col { background: rgba(var(--color-brand-rgb, 100,100,255), 0.07); }
.dl-mono { font-family: 'Consolas', 'Courier New', monospace; }
.dl-nowrap { white-space: nowrap; }
.dl-truncate { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dl-new-row { background: rgba(var(--color-brand-rgb, 100,200,100), 0.12) !important; }
.dl-new-row td.dl-sticky-col { background: rgba(var(--color-brand-rgb, 100,200,100), 0.12) !important; }
.dl-purge-confirm { display:flex; align-items:center; gap:10px; padding:10px 14px; background:rgba(220,53,69,0.08); border-bottom:1px solid rgba(220,53,69,0.2); font-size:var(--font-button); color:var(--color-text); }
.up-modal-header select option { background:var(--color-bg-input); color:var(--color-text); }

/* ===== Report Viewer Modal (Build 297) — rv- prefix ===== */
.rv-search { height:28px; border:1px solid var(--color-border); border-radius:var(--radius-sm); background:var(--color-bg-input); color:var(--color-text); padding:0 8px; font-size:12px; min-width:180px; outline:none; }
.rv-search:focus { border-color:var(--color-brand); }
.rv-row-count { display:inline-block; background:var(--color-bg-surface); border:1px solid var(--color-border); border-radius:10px; padding:1px 8px; font-size:11px; font-weight:normal; color:var(--color-text-muted); margin-left:8px; vertical-align:middle; }
.rv-footer { padding:6px 12px; font-size:11px; color:var(--color-text-muted); display:flex; justify-content:space-between; }

/* ===== Command Queue (0x19) ===== */
.cq-create-form { border:1px solid var(--color-border); border-radius:var(--radius-lg); padding:16px; margin-bottom:16px; background:var(--color-bg-surface); }
.cq-form-row { display:flex; gap:12px; margin-bottom:10px; flex-wrap:wrap; }
.cq-form-field { display:flex; flex-direction:column; gap:4px; min-width:180px; }
.cq-form-field label { font-size:var(--font-content-sm); font-weight:600; color:var(--color-text-muted); }
.cq-queue-header { display:flex; justify-content:space-between; align-items:center; margin-bottom:10px; flex-wrap:wrap; gap:8px; }
.cq-urgent-label { display:inline-flex; align-items:center; gap:6px; font-size:var(--font-button); cursor:pointer; }
@media (max-width: 768px) {
    .cq-form-row { flex-direction:column; }
    .cq-form-field { min-width:100%; }
    .cq-queue-header { flex-direction:column; align-items:flex-start; }
}

/* ===== Company Tree — Detail Card & Inactive (TAP Build 18) ===== */
.cc-tree-selected { background:var(--color-bg-surface); }
.cc-tree-inactive { text-decoration:line-through; opacity:0.6; }
.cc-tree-inactive-badge { font-size:10px; color:#dc3545; font-weight:600; margin-left:6px; }
.cc-tree-company-children { padding:4px 0 6px 28px; }
.cc-tree-detail-loading { display:flex; align-items:center; gap:8px; padding:6px 8px; font-size:12px; color:var(--color-text-muted); }
.cc-tree-spinner { display:inline-block; width:14px; height:14px; border:2px solid var(--color-border); border-top-color:var(--color-brand); border-radius:50%; animation:cc-spin 0.8s linear infinite; }
@keyframes cc-spin { to { transform:rotate(360deg); } }
.cc-tree-detail-card { padding:6px 8px; font-size:12px; }
.cc-tree-detail-row { display:flex; gap:8px; padding:2px 0; }
.cc-tree-detail-label { min-width:56px; color:var(--color-text-muted); font-weight:600; flex-shrink:0; }
.cc-tree-detail-value { color:var(--color-text); }

/* ===== Gem Loading Animation (TAP Build 18) ===== */
.cc-data-loading { display:flex; flex-direction:column; align-items:center; justify-content:center; padding:80px 20px 40px; }
.cc-data-loading-text { margin-top:16px; font-size:14px; color:var(--color-text-muted); letter-spacing:0.5px; }

/* Bounce outlines */
@keyframes cc-bounce {
    0%, 100% { translate:0px 36px; }
    50% { translate:0px 46px; }
}
@keyframes cc-bounce2 {
    0%, 100% { translate:0px 46px; }
    50% { translate:0px 56px; }
}
.cc-gem-bounce1 { animation:cc-bounce 4s ease-in-out infinite; translate:0px 36px; }
.cc-gem-bounce2 { animation:cc-bounce2 4s ease-in-out infinite; translate:0px 46px; animation-delay:0.5s; }

/* Glow pulse on gradient stops */
@keyframes cc-umbral {
    0%   { stop-color:#d3a5102e; }
    50%  { stop-color:rgba(211,165,16,0.519); }
    100% { stop-color:#d3a5102e; }
}
.cc-gem-glow { animation:cc-umbral 4s infinite; }

/* Particle glitter */
@keyframes cc-glitter {
    0%, 100% { translate:0px 16px; opacity:1; }
    30% { opacity:0.1; }
    50% { translate:0px 6px; opacity:0.9; }
    80% { opacity:0.15; }
}
.cc-gem-particle { animation:cc-glitter 4s ease-in-out infinite; will-change:transform, opacity; }
.cc-gp2  { animation-duration:3.5s; animation-delay:0.4s; }
.cc-gp3  { animation-duration:4.5s; animation-delay:0.8s; }
.cc-gp4  { animation-duration:3s;   animation-delay:1.2s; }
.cc-gp5  { animation-duration:5s;   animation-delay:0.6s; }
.cc-gp6  { animation-duration:3.5s; animation-delay:1.8s; }
.cc-gp7  { animation-duration:4s;   animation-delay:1.0s; }
.cc-gp8  { animation-duration:4.5s; animation-delay:2.2s; }
.cc-gp9  { animation-duration:3s;   animation-delay:0.2s; }
.cc-gp10 { animation-duration:3.8s; animation-delay:1.5s; }
.cc-gp11 { animation-duration:4.2s; animation-delay:2.8s; }
.cc-gp12 { animation-duration:3.2s; animation-delay:0.9s; }

/* Floating TriLock icon */
@keyframes cc-hover-float {
    0%, 100% { transform:translateY(0px); }
    50% { transform:translateY(-8px); }
}
.cc-gem-icon { animation:cc-hover-float 3s ease-in-out infinite; transform-box:fill-box; transform-origin:center; }

/* ===== TAP Device Grid (td- prefix, Build 21) ===== */
.td-grid-container { display:flex; flex-direction:column; height:100%; overflow:hidden; }
.td-command-bar { display:flex; align-items:center; gap:10px; padding:8px 12px; border-bottom:1px solid var(--color-border); flex-shrink:0; }
.td-row-count { font-size:13px; font-weight:600; color:var(--color-text-muted); }
.td-btn { display:inline-flex; align-items:center; gap:5px; padding:4px 10px; border:1px solid var(--color-border); border-radius:var(--radius-sm); background:var(--color-bg-surface); color:var(--color-text); font-size:12px; cursor:pointer; }
.td-btn:hover { background:var(--color-bg-hover); }
.td-btn:disabled { opacity:0.5; cursor:not-allowed; }
.td-icon { width:14px; height:14px; flex-shrink:0; }
.td-spin { animation:cc-spin 0.8s linear infinite; }
.td-scroll-wrapper { flex:1; overflow:auto; }
.td-table { border-collapse:collapse; white-space:nowrap; width:max-content; min-width:100%; }
.td-th { position:sticky; top:0; z-index:2; padding:6px 10px; font-size:11px; font-weight:700; letter-spacing:0.5px; color:var(--color-text-muted); background:var(--color-bg-surface); border:1px solid var(--color-border-light); border-bottom:2px solid var(--color-border); cursor:pointer; user-select:none; text-align:left; }
.td-th:hover { color:var(--color-text); background:var(--color-bg-hover); }
.td-th-check { width:36px; min-width:36px; text-align:center; cursor:default; }
.td-th-sorted { color:var(--color-brand, #d3a410); }
.td-col-highlight { background:rgba(211, 164, 16, 0.10); }
.td-th-dragging { opacity:0.4; }
.td-th-dragover { border-left:2px solid var(--color-brand, #d3a410); }
.td-th-text { pointer-events:none; }
.td-sort-icon { font-size:9px; margin-left:4px; }
.td-td { padding:5px 10px; font-size:12px; color:var(--color-text); border:1px solid var(--color-border-light); }
.td-td-check { width:36px; min-width:36px; text-align:center; }
.td-td-geo { max-width:200px; overflow-x:auto; white-space:nowrap; }
.td-td-json { max-width:150px; overflow-x:auto; white-space:nowrap; font-size:10px; font-family:monospace; color:var(--color-text-muted); }
.td-row-selected { background:rgba(211,164,16,0.08); }
.td-row-pending { background:rgba(128,128,128,0.15); }
.td-row-pending td { color:#cccc00 !important; }
.td-row-pending.td-row-selected { background:rgba(128,128,128,0.22); }
.td-row-blue-days td { color:#1a5276 !important; }
.td-row-blue-days.td-row-pending td { color:#cccc00 !important; }
.td-row-uninstalled td { text-decoration:line-through; }
.td-row-lock-green { background:rgba(40,167,69,0.12); }
.td-row-lock-green.td-row-selected { background:rgba(40,167,69,0.18); }
.td-row-lock-purple { background:rgba(128,0,128,0.12); }
.td-row-lock-purple.td-row-selected { background:rgba(128,0,128,0.18); }
.td-row-lock-blue { background:rgba(13,71,161,0.12); }
.td-row-lock-blue.td-row-selected { background:rgba(13,71,161,0.18); }
.td-row-lock-red { background:rgba(220,53,69,0.22); }
.td-row-lock-red.td-row-selected { background:rgba(220,53,69,0.28); }
.td-btn-separator { display:inline-block; width:1px; height:20px; background:var(--color-border); margin:0 4px; vertical-align:middle; }
.td-empty { padding:40px; text-align:left; color:var(--color-text-muted); font-style:italic; }
.td-table tbody tr:nth-child(even) { background:rgba(0,0,0,0.02); }
.td-table tbody tr:hover { background:var(--color-bg-hover); }

/* Bitmask clickable cell */
.td-bitmask-cell { cursor:pointer; color:var(--color-accent); text-decoration:underline; }
.td-bitmask-cell:hover { color:var(--color-accent-hover, #e0b800); }

/* Bitmask popup */
.td-bitmask-overlay { position:fixed; inset:0; background:rgba(0,0,0,0.5); z-index:1000; display:flex; align-items:center; justify-content:center; }
.td-bitmask-overlay.td-z-top { z-index:1002; }
.td-bitmask-popup { background:var(--color-bg-card); border:1px solid var(--color-border); border-radius:8px; min-width:380px; max-width:500px; box-shadow:0 8px 32px rgba(0,0,0,0.4); }
.td-bitmask-header { display:flex; align-items:center; justify-content:space-between; padding:10px 14px; font-size:13px; font-weight:600; color:var(--color-text); border-bottom:1px solid var(--color-border); cursor:move; user-select:none; }
.td-bitmask-close { cursor:pointer; font-size:18px; color:var(--color-text-muted); line-height:1; }
.td-bitmask-close:hover { color:var(--color-danger); }
.td-bitmask-body { padding:8px 0; max-height:400px; overflow-y:auto; }
.td-bitmask-row { display:flex; align-items:center; gap:8px; padding:4px 14px; font-size:12px; color:var(--color-text-muted); }
.td-bitmask-row.td-bitmask-set { color:var(--color-text); background:rgba(211,164,16,0.08); }
.td-bitmask-bit { min-width:32px; text-align:right; font-family:monospace; font-size:11px; color:var(--color-text-muted); }
.td-bitmask-name { min-width:90px; font-weight:600; }
.td-bitmask-desc { flex:1; }
.td-bitmask-status { min-width:16px; text-align:center; font-size:14px; }
.td-bitmask-row.td-bitmask-set .td-bitmask-status { color:var(--color-success, #4caf50); }
.td-bitmask-row:not(.td-bitmask-set) .td-bitmask-status { color:var(--color-text-muted); opacity:0.4; }

/* InfoBit popup — wider for grouped flags */
.td-infobit-popup { min-width:480px; max-width:600px; }
.td-infobit-popup .td-bitmask-body { max-height:520px; }
.td-infobit-section { font-size:11px; font-weight:700; color:var(--color-brand, #d3a410); padding:8px 14px 2px; letter-spacing:0.4px; text-transform:uppercase; border-top:1px solid var(--color-border); }
.td-infobit-section:first-child { border-top:none; padding-top:4px; }
.td-infobit-bit { min-width:24px; }

/* Advanced Commands popup */
.td-adv-popup { background:var(--color-bg-card); border:1px solid var(--color-border); border-radius:8px; min-width:320px; max-width:420px; box-shadow:0 8px 32px rgba(0,0,0,0.4); }
.td-adv-body { padding:12px 14px; }
.td-adv-section { margin-bottom:12px; }
.td-adv-section:last-child { margin-bottom:0; }
.td-adv-label { display:block; font-size:11px; font-weight:600; color:var(--color-text-muted); margin-bottom:6px; letter-spacing:0.3px; }
.td-adv-buttons { display:flex; flex-wrap:wrap; gap:6px; }
.td-btn-adv-cmd { background:var(--color-bg-surface); border:1px solid var(--color-border); color:var(--color-text); padding:5px 12px; border-radius:var(--radius-sm); font-size:12px; cursor:pointer; }
.td-btn-adv-cmd:hover { background:var(--color-bg-hover); border-color:var(--color-brand, #d3a410); }
.td-btn-adv-danger { background:var(--color-bg-surface); border:1px solid rgba(220,53,69,0.4); color:#dc3545; padding:5px 12px; border-radius:var(--radius-sm); font-size:12px; cursor:pointer; }
.td-btn-adv-danger:hover { background:rgba(220,53,69,0.15); border-color:#dc3545; }
.td-adv-utilities { border-top:1px solid var(--color-border); padding-top:10px; }
.td-minutes-popup { min-width:260px; max-width:320px; }

/* Info link in grid row */
.td-th-info { width:105px; min-width:105px; text-align:center; cursor:default; }
.td-td-info { width:105px; min-width:105px; text-align:center; padding:2px 4px; white-space:nowrap; }
.td-info-link { cursor:pointer; color:var(--color-accent); font-size:11px; text-decoration:underline; }
.td-info-link:hover { color:var(--color-accent-hover, #e0b800); }
/* ===== Device Dashboard ===== */
.td-dash-overlay { position:fixed; inset:0; background:rgba(0,0,0,0.6); z-index:10000; display:flex; align-items:center; justify-content:center; }
/* Ensure modals/toasts render above dashboard */
.modal-backdrop { z-index:10001 !important; }
.modal { z-index:10002 !important; }
.td-dash-popup { position:relative; background:var(--color-bg-card); border:1px solid var(--color-border); border-radius:10px; width:820px; max-width:95vw; max-height:90vh; display:flex; flex-direction:column; box-shadow:0 12px 48px rgba(0,0,0,0.5); }
.td-dash-header-bar { display:flex; align-items:center; justify-content:space-between; padding:12px 16px; border-bottom:1px solid var(--color-border); cursor:move; user-select:none; }
.td-dash-title { display:flex; align-items:center; gap:8px; font-size:14px; font-weight:700; color:var(--color-text); }
.td-dash-tabs { display:flex; gap:0; border-bottom:2px solid var(--color-border); padding:0 8px; overflow-x:auto; flex-shrink:0; }
.td-dash-tab { background:none; border:none; padding:8px 14px; font-size:12px; font-weight:600; color:var(--color-text-muted); cursor:pointer; border-bottom:2px solid transparent; margin-bottom:-2px; white-space:nowrap; transition:color 0.15s, border-color 0.15s; }
.td-dash-tab:hover { color:var(--color-text); }
.td-dash-tab.active { color:var(--color-accent, #c9a227); border-bottom-color:var(--color-accent, #c9a227); }
.td-dash-body { flex:1; overflow-y:auto; padding:16px 20px; min-height:300px; }
.td-dash-footer { display:flex; gap:8px; padding:10px 16px; border-top:1px solid var(--color-border); justify-content:flex-end; align-items:center; }

/* Dashboard poll controls */
.td-dash-poll-control { display:flex; align-items:center; gap:4px; margin-right:auto; font-size:12px; }
.td-dash-poll-dot { width:8px; height:8px; border-radius:50%; flex-shrink:0; transition:background 0.3s; }
.td-dash-poll-idle { background:#4caf50; }
.td-dash-poll-active { background:#f44336; animation:td-poll-pulse 0.6s ease-in-out; }
@keyframes td-poll-pulse { 0%,100% { opacity:1; } 50% { opacity:0.4; } }
.td-dash-poll-arrow { background:none; border:1px solid var(--color-border); color:var(--color-text-muted); width:22px; height:22px; border-radius:3px; cursor:pointer; font-size:9px; display:flex; align-items:center; justify-content:center; padding:0; }
.td-dash-poll-arrow:hover:not(:disabled) { color:var(--color-text); border-color:var(--color-text-muted); }
.td-dash-poll-arrow:disabled { opacity:0.3; cursor:default; }
.td-dash-poll-value { min-width:30px; text-align:center; font-weight:600; color:var(--color-text); font-size:12px; }
.td-dash-poll-off { background:none; border:1px solid var(--color-border); color:var(--color-text-muted); padding:2px 8px; border-radius:3px; cursor:pointer; font-size:11px; }
.td-dash-poll-off:hover { color:var(--color-text); border-color:var(--color-text-muted); }
.td-dash-poll-off.active { color:#f44336; border-color:#f44336; }

/* Dashboard: Status banner */
.td-dash-status-banner { display:flex; align-items:center; gap:16px; padding:16px 20px; border-radius:8px; margin-bottom:16px; }
.td-dash-state-normal { background:rgba(76,175,80,0.15); border:1px solid rgba(76,175,80,0.3); }
.td-dash-state-normal .td-dash-status-icon { color:#4caf50; }
.td-dash-state-normal .td-dash-status-label { color:#4caf50; }
.td-dash-state-green { background:rgba(76,175,80,0.15); border:1px solid rgba(76,175,80,0.3); }
.td-dash-state-green .td-dash-status-icon { color:#4caf50; }
.td-dash-state-green .td-dash-status-label { color:#4caf50; }
.td-dash-state-red { background:rgba(244,67,54,0.15); border:1px solid rgba(244,67,54,0.3); }
.td-dash-state-red .td-dash-status-icon { color:#f44336; }
.td-dash-state-red .td-dash-status-label { color:#f44336; }
.td-dash-state-blue { background:rgba(33,150,243,0.15); border:1px solid rgba(33,150,243,0.3); }
.td-dash-state-blue .td-dash-status-icon { color:#2196f3; }
.td-dash-state-blue .td-dash-status-label { color:#2196f3; }
.td-dash-state-purple { background:rgba(156,39,176,0.15); border:1px solid rgba(156,39,176,0.3); }
.td-dash-state-purple .td-dash-status-icon { color:#9c27b0; }
.td-dash-state-purple .td-dash-status-label { color:#9c27b0; }
.td-dash-status-text { display:flex; flex-direction:column; gap:2px; }
.td-dash-status-label { font-size:18px; font-weight:700; letter-spacing:0.5px; }
.td-dash-status-sub { font-size:12px; color:var(--color-text-muted); }

/* Dashboard: Sections and grids */
.td-dash-section { margin-bottom:16px; }
.td-dash-section-title { font-size:12px; font-weight:700; color:var(--color-accent, #c9a227); text-transform:uppercase; letter-spacing:0.5px; padding-bottom:4px; border-bottom:1px solid var(--color-border); margin-bottom:8px; }
.td-dash-grid { display:grid; grid-template-columns:1fr 1fr; gap:4px 24px; }
.td-dash-field { display:flex; gap:8px; padding:4px 0; border-bottom:1px solid rgba(255,255,255,0.04); font-size:12px; }
.td-dash-label { font-weight:600; color:var(--color-text-muted); min-width:120px; flex-shrink:0; }
.td-dash-value { color:var(--color-text); word-break:break-word; }
.td-dash-pwd { font-family:monospace; font-size:14px; font-weight:700; color:var(--color-accent, #c9a227); letter-spacing:1px; }
.td-dash-empty { padding:20px; text-align:center; color:var(--color-text-muted); font-style:italic; font-size:12px; }
.td-dash-ok { color:#4caf50; font-weight:600; }
.td-dash-warn { color:#f44336; font-weight:600; }

/* Dashboard: Command bar */
.td-dash-cmd-bar { display:flex; gap:8px; padding:12px 0 4px; border-top:1px solid var(--color-border); margin-top:8px; }
.td-dash-cmd-scroll { overflow-x:auto; padding:8px 0 4px; }
.td-dash-cmd-row { display:flex; gap:6px; align-items:center; white-space:nowrap; }
.td-dash-cmd-sep { display:inline-block; width:1px; height:24px; background:var(--color-border); margin:0 2px; flex-shrink:0; }
.td-dash-resize { position:absolute; bottom:4px; right:6px; cursor:nwse-resize; color:var(--color-text-muted); font-size:14px; line-height:1; user-select:none; opacity:0.5; }
.td-dash-resize:hover { opacity:1; }

/* Dashboard: Tables (software, hardware, network) */
.td-dash-table { width:100%; border-collapse:collapse; font-size:12px; }
.td-dash-table thead th { text-align:left; font-weight:700; color:var(--color-text-muted); padding:4px 8px; border-bottom:1px solid var(--color-border); font-size:11px; text-transform:uppercase; letter-spacing:0.3px; position:sticky; top:0; background:var(--color-bg-card); }
.td-dash-table tbody td { padding:3px 8px; border-bottom:1px solid rgba(255,255,255,0.03); color:var(--color-text); }
.td-dash-table tbody tr:hover { background:rgba(255,255,255,0.03); }

/* Dashboard: Diagnostic flags */
.td-dash-flags { display:flex; flex-direction:column; gap:1px; }
.td-dash-flag { display:flex; align-items:center; gap:8px; padding:3px 6px; font-size:12px; border-radius:3px; }
.td-dash-flag-set { background:rgba(201,162,39,0.1); }
.td-dash-flag-dot { width:14px; text-align:center; flex-shrink:0; }
.td-dash-flag-set .td-dash-flag-dot { color:var(--color-accent, #c9a227); }
.td-dash-flag-name { font-weight:600; min-width:140px; flex-shrink:0; color:var(--color-text); }
.td-dash-flag-desc { color:var(--color-text-muted); }
.td-dash-flag-group { font-size:11px; font-weight:700; color:var(--color-accent, #c9a227); text-transform:uppercase; letter-spacing:0.5px; padding:8px 6px 2px; }
.td-dash-note { padding:10px 12px; margin-top:8px; font-size:12px; color:var(--color-accent, #c9a227); background:rgba(201,162,39,0.08); border:1px solid rgba(201,162,39,0.2); border-radius:4px; }

/* Dashboard: light theme overrides */
[data-theme="theme-light"] .td-dash-field { border-bottom-color:rgba(0,0,0,0.06); }
[data-theme="theme-light"] .td-dash-flag-set { background:rgba(201,162,39,0.08); }
[data-theme="theme-light"] .td-dash-table tbody td { border-bottom-color:rgba(0,0,0,0.06); }
[data-theme="theme-light"] .td-dash-table tbody tr:hover { background:rgba(0,0,0,0.03); }

/* Dashboard: print support */
@media print {
    body * { visibility:hidden; }
    .td-dash-overlay, .td-dash-overlay * { visibility:visible !important; display:block !important; }
    .td-dash-overlay { position:absolute; top:0; left:0; width:100%; height:auto; background:white; z-index:99999; padding:0; overflow:visible; }
    .td-dash-popup { display:block !important; box-shadow:none; border-radius:0; width:100%; max-height:none; border:none; overflow:visible; }
    .td-dash-header-bar { display:flex !important; background:#1565c0; color:white; -webkit-print-color-adjust:exact; print-color-adjust:exact; padding:12px 20px; }
    .td-dash-title { color:white; font-size:16px; }
    .td-dash-tabs { display:none !important; }
    .td-dash-footer { display:none !important; }
    .td-dash-body { overflow:visible !important; max-height:none !important; padding:20px; color:#1a1a1a; }
    .td-dash-section { page-break-inside:avoid; }
    .td-dash-section-title { background:#1565c0; color:white; padding:4px 10px; border-radius:3px; -webkit-print-color-adjust:exact; print-color-adjust:exact; }
    .td-dash-status-banner { -webkit-print-color-adjust:exact; print-color-adjust:exact; }
    .td-dash-grid { display:grid !important; }
    .td-dash-field { display:flex !important; }
    .td-dash-label { color:#555; }
    .td-dash-value { color:#1a1a1a; }
    .td-dash-flags { display:flex !important; flex-direction:column !important; }
    .td-dash-flag { display:flex !important; }
    .td-dash-flag-set { -webkit-print-color-adjust:exact; print-color-adjust:exact; background:rgba(201,162,39,0.15) !important; }
    .td-dash-flag-group { -webkit-print-color-adjust:exact; print-color-adjust:exact; }
    .td-dash-flag-dot { -webkit-print-color-adjust:exact; print-color-adjust:exact; }
    .td-dash-cmd-bar { display:none !important; }
    .td-dash-poll-control { display:none !important; }
    .td-bitmask-close { display:none !important; }
    .td-dash-table { display:table !important; }
    .td-dash-table thead th { -webkit-print-color-adjust:exact; print-color-adjust:exact; }
    .td-dash-table tbody tr { display:table-row !important; }
    .td-dash-table tbody td { display:table-cell !important; }
    .td-dash-note { -webkit-print-color-adjust:exact; print-color-adjust:exact; }
}

/* ===== TriLock Gem Animation ===== */
@keyframes tl-gem-bounce { 0%,100% { translate:0px 25px; } 50% { translate:0px 32px; } }
@keyframes tl-gem-bounce2 { 0%,100% { translate:0px 32px; } 50% { translate:0px 39px; } }
@keyframes tl-gem-glow { 0% { stop-color:#d3a5102e; } 50% { stop-color:rgba(211,165,16,0.52); } 100% { stop-color:#d3a5102e; } }
@keyframes tl-gem-glitter { 0%,100% { translate:0px 11px; opacity:1; } 30% { opacity:0.1; } 50% { translate:0px 4px; opacity:0.9; } 80% { opacity:0.15; } }
@keyframes tl-gem-float { 0%,100% { transform:translateY(0px); } 50% { transform:translateY(-6px); } }
.tl-gem-bounce { animation:tl-gem-bounce 4s ease-in-out infinite; translate:0px 25px; }
.tl-gem-bounce2 { animation:tl-gem-bounce2 4s ease-in-out infinite; translate:0px 32px; animation-delay:0.5s; }
.tl-gem-particle { animation:tl-gem-glitter 4s ease-in-out infinite; will-change:transform,opacity; }
.tl-gem-glow { animation:tl-gem-glow 4s infinite; }
.tl-gem-icon { animation:tl-gem-float 3s ease-in-out infinite; transform-box:fill-box; transform-origin:center; }

.td-print-link { cursor:pointer; color:#a5d6a7; font-size:11px; text-decoration:underline; margin-left:6px; }
.td-print-link:hover { color:#c8e6c9; }
.td-geo-link { cursor:pointer; color:var(--td-accent, #4fc3f7); font-size:11px; text-decoration:underline; margin-left:6px; }
.td-geo-link:hover { color:#81d4fa; }

/* Light theme — darken links that wash out on white backgrounds */
[data-theme="theme-light"] .td-print-link { color:#2e7d32; }
[data-theme="theme-light"] .td-print-link:hover { color:#1b5e20; }
[data-theme="theme-light"] .td-geo-link { color:#0d47a1; }
[data-theme="theme-light"] .td-geo-link:hover { color:#1565c0; }
[data-theme="theme-light"] .td-info-link { color:#b8860b; }
[data-theme="theme-light"] .td-info-link:hover { color:#8b6508; }

/* Light theme — darker sidebar text + light blue bg on buttons/grid headers */
[data-theme="theme-light"] .cc-tree-company-name { color:#0a1a3a; font-weight:500; }
[data-theme="theme-light"] .td-btn { background:#eef3fb; border-color:#c8d6ec; }
[data-theme="theme-light"] .td-btn:hover { background:#dce6f5; }
[data-theme="theme-light"] .td-th { background:#eef3fb; color:#11234a; border-color:#c8d6ec; }
[data-theme="theme-light"] .td-th:hover { background:#dce6f5; }
[data-theme="theme-light"] .td-td { border-color:#c8d6ec; }

/* Device Log popup */
.td-log-popup { position:relative; background:var(--color-bg-card); border:1px solid var(--color-border); border-radius:8px; min-width:400px; width:700px; max-width:1400px; max-height:500px; display:flex; flex-direction:column; box-shadow:0 8px 32px rgba(0,0,0,0.4); }
.td-log-body { flex:1; overflow:auto; }
.td-log-table { width:max-content; min-width:100%; }
.td-log-resize-grip { position:absolute; bottom:0; right:0; width:16px; height:16px; cursor:nwse-resize; opacity:0.25; background:linear-gradient(135deg, transparent 50%, var(--color-text-muted) 50%, transparent 55%, var(--color-text-muted) 75%, transparent 75%); border-radius:0 0 8px 0; }
.td-log-resize-grip:hover { opacity:0.7; background:linear-gradient(135deg, transparent 50%, var(--color-accent) 50%, transparent 55%, var(--color-accent) 75%, transparent 75%); }

/* =========================================================================
   COMPANY CONFIG BUTTON
   ========================================================================= */
.cc-tree-config-row { padding:4px 12px 2px; }
.cc-tree-config-btn {
    display:inline-flex; align-items:center; gap:5px;
    padding:3px 10px; font-size:11px; cursor:pointer;
    background:var(--color-primary, #d3a410); color:#fff;
    border:1px solid var(--color-primary, #d3a410); border-radius:4px;
    transition:background 0.15s, color 0.15s, opacity 0.15s;
}
.cc-tree-config-btn:hover { opacity:0.85; }
.cc-tree-config-btn svg { flex-shrink:0; }

/* =========================================================================
   TAP TOOLS SIDEBAR BUTTONS
   ========================================================================= */
.cc-tree-tool-btn {
    display:flex; align-items:center; gap:8px; width:100%;
    padding:5px 10px; margin-bottom:2px; font-size:12px; cursor:pointer;
    background:transparent; color:var(--color-text);
    border:1px solid transparent; border-radius:4px;
    transition:background 0.15s, border-color 0.15s;
    text-align:left; font-family:inherit;
}
.cc-tree-tool-btn:hover {
    background:var(--color-bg-sidebar-hover, rgba(255,255,255,0.08));
    border-color:var(--color-border);
}
.cc-tree-tool-btn svg { flex-shrink:0; opacity:0.7; }
.cc-tree-tool-btn:hover svg { opacity:1; }

/* =========================================================================
   COMPANY CONFIG MODAL
   ========================================================================= */
.cc-config-overlay {
    position:fixed; inset:0; z-index:9000;
    background:rgba(0,0,0,0.5); display:flex; align-items:center; justify-content:center;
}
.cc-config-modal {
    background:var(--color-surface, #1e2026); border:1px solid var(--color-border, #3a3d45);
    border-radius:8px; width:420px; max-width:90vw; max-height:85vh;
    display:flex; flex-direction:column; box-shadow:0 8px 32px rgba(0,0,0,0.5);
}
.cc-config-header {
    display:flex; align-items:center; justify-content:space-between;
    padding:10px 16px; font-size:13px; font-weight:600;
    border-bottom:1px solid var(--color-border, #3a3d45);
    cursor:move; user-select:none;
    color:var(--color-text);
}
.cc-config-close { font-size:20px; cursor:pointer; color:var(--color-text-muted); line-height:1; }
.cc-config-close:hover { color:var(--color-danger, #ef5350); }
.cc-config-body { padding:12px 16px; overflow-y:auto; flex:1; }
.cc-config-footer {
    display:flex; justify-content:flex-end; gap:8px;
    padding:10px 16px; border-top:1px solid var(--color-border, #3a3d45);
}
.cc-config-badge {
    display:inline-block; padding:2px 10px; border-radius:3px;
    font-size:11px; font-weight:700; letter-spacing:0.5px; margin-bottom:10px;
}
.cc-config-badge-new { background:#2e7d32; color:#fff; }
.cc-config-badge-update { background:#1565c0; color:#fff; }
.cc-config-section {
    font-size:11px; font-weight:700; color:var(--color-primary, #d3a410);
    text-transform:uppercase; letter-spacing:0.5px;
    margin:12px 0 6px; padding-bottom:3px;
    border-bottom:1px solid var(--color-border, #3a3d45);
}
.cc-config-section:first-child { margin-top:0; }
.cc-config-form { display:flex; flex-direction:column; gap:6px; }
.cc-config-row { display:flex; flex-direction:column; gap:2px; }
.cc-config-row label { font-size:11px; color:var(--color-text-muted); }
.cc-config-row textarea {
    padding:5px 8px; font-size:12px; border-radius:4px;
    border:1px solid var(--color-border, #3a3d45);
    background:var(--color-bg, #16181c); color:var(--color-text);
    outline:none; resize:vertical; font-family:inherit;
}
.cc-config-row textarea:focus { border-color:var(--color-primary, #d3a410); }
.cc-config-row input[type="text"],
.cc-config-row input[type="number"] {
    padding:5px 8px; font-size:12px; border-radius:4px;
    border:1px solid var(--color-border, #3a3d45);
    background:var(--color-bg, #16181c); color:var(--color-text);
    outline:none;
}
.cc-config-row input:focus { border-color:var(--color-primary, #d3a410); }
.cc-config-row-split { display:flex; flex-direction:row; gap:8px; }
.cc-config-row-split > div { flex:1; display:flex; flex-direction:column; gap:2px; }
.cc-config-row-check label {
    display:flex; align-items:center; gap:6px; font-size:12px;
    color:var(--color-text); cursor:pointer;
}
.cc-config-row-check input[type="checkbox"] { width:16px; height:16px; accent-color:var(--color-primary, #d3a410); }

/* =========================================================================
   BUTTONS (modal footer)
   ========================================================================= */
.tl-btn {
    padding:6px 14px; font-size:12px; font-weight:500; border-radius:4px;
    border:1px solid transparent; cursor:pointer; transition:opacity 0.15s;
}
.tl-btn:disabled { opacity:0.5; cursor:not-allowed; }
.tl-btn-primary { background:var(--color-primary, #d3a410); color:#fff; border-color:var(--color-primary, #d3a410); }
.tl-btn-primary:hover:not(:disabled) { opacity:0.85; }
.tl-btn-secondary { background:var(--color-surface, #2a2d35); color:var(--color-text); border-color:var(--color-border, #3a3d45); }
.tl-btn-secondary:hover:not(:disabled) { background:var(--color-border, #3a3d45); }
.tl-btn-danger { background:#c62828; color:#fff; border-color:#c62828; }
.tl-btn-danger:hover:not(:disabled) { background:#b71c1c; border-color:#b71c1c; }

/* =========================================================================
   TOAST (shared)
   ========================================================================= */
.cc-toast-container { position:fixed; bottom:20px; right:20px; z-index:9500; }
.cc-toast {
    padding:10px 18px; border-radius:6px; font-size:13px; font-weight:500;
    color:#fff; box-shadow:0 4px 16px rgba(0,0,0,0.4);
    animation:cc-toast-slide 0.3s ease;
}
.cc-toast-success { background:#2e7d32; }
.cc-toast-error { background:#c62828; }
@keyframes cc-toast-slide { from { opacity:0; transform:translateY(20px); } to { opacity:1; transform:translateY(0); } }

/* ============================== Print Report ============================== */
.td-print-overlay { position:fixed; inset:0; background:rgba(0,0,0,0.7); z-index:10000; display:flex; align-items:flex-start; justify-content:center; padding-top:20px; overflow-y:auto; }
.td-print-popup { background:#fff; width:700px; max-width:95vw; border-radius:8px; box-shadow:0 8px 32px rgba(0,0,0,0.4); }
.td-print-toolbar { display:flex; gap:8px; padding:10px 16px; background:#333; border-radius:8px 8px 0 0; }
.td-print-page { padding:32px 40px; color:#1a1a1a; font-family:'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; }
.td-print-header { text-align:center; border-bottom:3px solid #1565c0; padding:20px 16px 16px; margin:-32px -40px 20px; border-radius:0 0 0 0; }
.td-print-title { font-size:24px; font-weight:700; letter-spacing:1px; }
.td-print-subtitle { font-size:16px; font-weight:600; margin-top:4px; }
.td-print-date { font-size:11px; margin-top:4px; }
.td-print-status-badge { display:inline-block; font-size:12px; font-weight:700; letter-spacing:1px; text-transform:uppercase; padding:3px 16px; border-radius:12px; margin-top:8px; }
.td-print-bg-green { background:#1b5e20; border-bottom-color:#2e7d32; }
.td-print-bg-green .td-print-title { color:#e8f5e9; }
.td-print-bg-green .td-print-subtitle { color:#c8e6c9; }
.td-print-bg-green .td-print-date { color:#a5d6a7; }
.td-print-bg-green .td-print-status-badge { background:#4caf50; color:#fff; }
.td-print-bg-red { background:#b71c1c; border-bottom-color:#c62828; }
.td-print-bg-red .td-print-title { color:#ffebee; }
.td-print-bg-red .td-print-subtitle { color:#ffcdd2; }
.td-print-bg-red .td-print-date { color:#ef9a9a; }
.td-print-bg-red .td-print-status-badge { background:#f44336; color:#fff; }
.td-print-bg-purple { background:#4a148c; border-bottom-color:#6a1b9a; }
.td-print-bg-purple .td-print-title { color:#f3e5f5; }
.td-print-bg-purple .td-print-subtitle { color:#e1bee7; }
.td-print-bg-purple .td-print-date { color:#ce93d8; }
.td-print-bg-purple .td-print-status-badge { background:#9c27b0; color:#fff; }
.td-print-bg-blue { background:#0d47a1; border-bottom-color:#1565c0; }
.td-print-bg-blue .td-print-title { color:#e3f2fd; }
.td-print-bg-blue .td-print-subtitle { color:#bbdefb; }
.td-print-bg-blue .td-print-date { color:#90caf9; }
.td-print-bg-blue .td-print-status-badge { background:#2196f3; color:#fff; }
.td-print-bg-white { background:#f5f5f5; border-bottom-color:#1565c0; }
.td-print-bg-white .td-print-title { color:#1565c0; }
.td-print-bg-white .td-print-subtitle { color:#333; }
.td-print-bg-white .td-print-date { color:#888; }
.td-print-bg-white .td-print-status-badge { background:#757575; color:#fff; }
.td-print-section { margin-bottom:16px; }
.td-print-section-title { font-size:13px; font-weight:700; color:#fff; background:#1565c0; padding:4px 10px; border-radius:3px; margin-bottom:8px; letter-spacing:0.5px; text-transform:uppercase; }
.td-print-grid { display:grid; grid-template-columns:1fr 1fr; gap:4px 24px; }
.td-print-field { display:flex; gap:6px; padding:3px 0; border-bottom:1px solid #e0e0e0; font-size:12px; }
.td-print-label { font-weight:600; color:#555; min-width:110px; flex-shrink:0; }
.td-print-value { color:#1a1a1a; word-break:break-word; }
.td-print-footer { text-align:center; margin-top:20px; padding-top:12px; border-top:2px solid #1565c0; font-size:10px; color:#888; letter-spacing:1px; }

@media print {
    .td-print-overlay, .td-print-overlay * { visibility:visible !important; display:block !important; }
    .td-print-overlay { position:fixed; top:0; left:0; width:100%; height:auto; background:white; z-index:99999; padding:0; overflow:visible; }
    .td-print-popup { display:block !important; box-shadow:none; border-radius:0; width:100%; }
    .td-print-toolbar { display:none !important; }
    .td-print-page { display:block !important; padding:20px; }
    .td-print-grid { display:grid !important; }
    .td-print-field { display:flex !important; }
    .td-print-section-title { -webkit-print-color-adjust:exact; print-color-adjust:exact; }
    .td-print-header { -webkit-print-color-adjust:exact; print-color-adjust:exact; }
    .td-print-status-badge { -webkit-print-color-adjust:exact; print-color-adjust:exact; }
    .td-print-bg-green, .td-print-bg-red, .td-print-bg-purple, .td-print-bg-blue, .td-print-bg-white { -webkit-print-color-adjust:exact; print-color-adjust:exact; }
    .td-print-footer { -webkit-print-color-adjust:exact; print-color-adjust:exact; }
}
