/**
 * Components CSS - Buttons, Forms, Cards, Toasts, Modals, Badges, Tables
 * All colors reference tokens.css custom properties.
 */

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

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 36px;
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius);
    font-family: var(--font-sans);
    font-size: 14px;
    font-weight: 500;
    line-height: 1;
    cursor: pointer;
    transition: background 0.15s, box-shadow 0.15s;
    text-decoration: none;
    gap: var(--space-2);
}

.btn:hover {
    text-decoration: none;
}

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

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

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

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

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

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

.btn-secondary {
    background: var(--bg-muted);
    color: var(--text-primary);
}

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

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

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

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-primary);
}

.btn-outline:hover {
    border-color: var(--border-strong);
    background: var(--bg-muted);
}

.btn-ghost {
    background: transparent;
    color: var(--text-primary);
}

.btn-ghost:hover {
    background: var(--bg-muted);
}

.btn-sm {
    height: 32px;
    padding: 6px 12px;
    font-size: 12px;
    border-radius: 6px;
}

.btn-lg {
    height: 44px;
    padding: 10px 24px;
}

.btn-full {
    width: 100%;
}

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

.btn-group {
    display: flex;
    gap: var(--space-2);
    flex-wrap: wrap;
}

.action-buttons {
    display: flex;
    gap: var(--space-2);
    margin-top: var(--space-4);
}

.action-buttons .btn {
    flex: 1;
}

/* ============================================
   FORMS
   ============================================ */

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

.form-group label {
    display: block;
    margin-bottom: var(--space-1);
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

input, textarea, select {
    width: 100%;
    height: 36px;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-surface);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 14px;
    transition: border-color 0.15s, box-shadow 0.15s;
}

textarea {
    height: auto;
    resize: vertical;
    min-height: 80px;
}

input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-muted);
}

input:disabled, textarea:disabled, select:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

input::placeholder, textarea::placeholder {
    color: var(--text-muted);
}

select option {
    background: var(--bg-surface);
    color: var(--text-primary);
}

.form-row {
    display: flex;
    gap: var(--space-3);
}

.form-row .form-group {
    flex: 1;
}

.form-actions {
    margin-top: var(--space-5);
}

/* Search box */
.search-box {
    display: flex;
    gap: var(--space-2);
    margin-bottom: var(--space-4);
}

.search-box input {
    flex: 1;
}

/* ============================================
   CARDS
   ============================================ */

.card {
    background: var(--bg-surface);
    border-radius: var(--radius);
    padding: var(--space-6);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    margin-bottom: var(--space-6);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-4);
    padding-bottom: var(--space-4);
    border-bottom: 1px solid var(--border);
}

.card-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

/* ============================================
   BADGES
   ============================================ */

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 500;
    line-height: 1.4;
}

.badge-online {
    background: var(--success-bg);
    color: var(--success-text);
}

.badge-offline {
    background: var(--bg-muted);
    color: var(--text-muted);
}

.badge-banned {
    background: var(--error-bg);
    color: var(--error-text);
}

.badge-tempban,
.badge-warning {
    background: var(--warning-bg);
    color: var(--warning-text);
}

.badge-admin {
    background: var(--primary-muted);
    color: var(--primary);
}

.badge-superadmin {
    background: var(--error-bg);
    color: var(--error-text);
}

.badge-user {
    background: var(--bg-muted);
    color: var(--text-secondary);
}

/* ============================================
   TOAST NOTIFICATIONS
   ============================================ */

/* Container for stacking toasts */
.toast-container {
    position: fixed;
    bottom: var(--space-6);
    right: var(--space-6);
    z-index: 1001;
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    pointer-events: none;
}

.toast {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius);
    color: #fff;
    font-size: 14px;
    max-width: 400px;
    min-width: 280px;
    animation: toastSlideIn 0.3s ease;
    box-shadow: var(--shadow-lg);
    pointer-events: auto;
    cursor: pointer;
    overflow: hidden;
}

.toast.removing {
    animation: toastSlideOut 0.3s ease forwards;
}

/* Toast icon */
.toast-icon {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.toast-icon svg {
    width: 18px;
    height: 18px;
}

/* Toast content area */
.toast-content {
    flex: 1;
    min-width: 0;
}

.toast-message {
    word-wrap: break-word;
}

/* Toast close button */
.toast-close {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.15s;
    padding: 0;
    margin: -2px -4px -2px 0;
}

.toast-close:hover {
    opacity: 1;
}

.toast-close svg {
    width: 14px;
    height: 14px;
}

/* Toast action button */
.toast-action {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: var(--radius-sm);
    color: inherit;
    font-size: 12px;
    font-weight: 500;
    padding: 4px 10px;
    margin-top: var(--space-2);
    cursor: pointer;
    transition: background 0.15s;
}

.toast-action:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Progress bar */
.toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: rgba(255, 255, 255, 0.3);
    overflow: hidden;
}

.toast-progress-bar {
    height: 100%;
    background: rgba(255, 255, 255, 0.7);
    width: 100%;
    transform-origin: left;
    animation: toastProgress linear forwards;
}

.toast.paused .toast-progress-bar {
    animation-play-state: paused;
}

/* Toast type colors */
.toast.success {
    background: var(--success);
}

.toast.error {
    background: var(--error);
}

.toast.warning {
    background: var(--warning);
}

.toast.info {
    background: var(--info);
}

/* Animations */
@keyframes toastSlideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes toastSlideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

@keyframes toastProgress {
    from {
        transform: scaleX(1);
    }
    to {
        transform: scaleX(0);
    }
}

/* ============================================
   MODALS
   ============================================ */

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--overlay-backdrop);
    z-index: 1002;
    align-items: center;
    justify-content: center;
}

.modal.open, .modal.active {
    display: flex;
}

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

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-5);
    padding-bottom: var(--space-4);
    border-bottom: 1px solid var(--border);
}

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

.modal-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: none;
    border: none;
    border-radius: 6px;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 20px;
}

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

.modal-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: var(--space-4);
}

.modal-buttons {
    display: flex;
    gap: var(--space-2);
    margin-top: var(--space-6);
}

.modal-buttons .btn {
    flex: 1;
}

/* ============================================
   TABLES
   ============================================ */

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

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

th {
    background: var(--bg-muted);
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 12px;
    text-transform: uppercase;
    position: sticky;
    top: 0;
    z-index: 1;
}

tr:hover {
    background: var(--bg-muted);
    transition: background 0.15s;
}

tr.clickable-row {
    cursor: pointer;
}

tr.clickable-row:hover {
    background: var(--primary-muted);
}

tr.clickable-row:active {
    background: var(--border);
}

thead tr:hover {
    background: var(--bg-muted);
}

/* Table responsive wrapper */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: var(--space-4);
}

.table-responsive table {
    min-width: 100%;
}

/* Scroll shadow indicators for horizontal scroll */
.table-responsive.has-scroll {
    background:
        linear-gradient(to right, var(--bg-surface) 30%, transparent),
        linear-gradient(to left, var(--bg-surface) 30%, transparent),
        linear-gradient(to right, rgba(0, 0, 0, 0.08), transparent 15px),
        linear-gradient(to left, rgba(0, 0, 0, 0.08), transparent 15px);
    background-position: left center, right center, left center, right center;
    background-repeat: no-repeat;
    background-size: 20px 100%, 20px 100%, 15px 100%, 15px 100%;
    background-attachment: local, local, scroll, scroll;
}

/* Column visibility utilities - responsive priority */
.col-priority-1 { } /* Always visible */
.col-priority-2 { } /* Hide on small mobile */
.col-priority-3 { } /* Hide on mobile */
.col-priority-4 { } /* Hide on tablet and below */

/* Truncate long text in cells */
.cell-truncate {
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Numeric columns - right align and monospace */
.cell-numeric {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* Actions column - no wrap */
.cell-actions {
    white-space: nowrap;
    text-align: right;
}

/* ============================================
   INFO GRID (profile/detail views)
   ============================================ */

.info-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-4);
}

.info-item {
    padding: var(--space-3);
    background: var(--bg-muted);
    border-radius: var(--radius);
}

.info-label {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: var(--space-1);
}

.info-value {
    font-size: 14px;
    color: var(--text-primary);
}

/* ============================================
   MESSAGE BOXES
   ============================================ */

.message {
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius);
    margin-bottom: var(--space-5);
    font-size: 14px;
}

.message.success {
    background: var(--success-bg);
    border: 1px solid var(--success-border);
    color: var(--success-text);
}

.message.error {
    background: var(--error-bg);
    border: 1px solid var(--error-border);
    color: var(--error-text);
}

/* ============================================
   BACK LINK
   ============================================ */

.back-link {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    margin-bottom: var(--space-4);
}

.back-link:hover {
    color: var(--text-primary);
    text-decoration: none;
}

/* ============================================
   SERVER ITEMS
   ============================================ */

.server-item {
    background: var(--bg-muted);
    border-radius: var(--radius);
    padding: var(--space-4);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.server-name {
    font-weight: 500;
}

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

.server-stats {
    text-align: right;
    font-size: 14px;
}

.server-users {
    color: var(--primary);
    font-weight: 600;
}

.server-status {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.server-status.online {
    background: var(--color-online);
    box-shadow: 0 0 8px rgba(22, 163, 74, 0.4);
}

.server-status.offline {
    background: var(--error);
    box-shadow: 0 0 8px rgba(220, 38, 38, 0.4);
}

/* ============================================
   TARGET INDICATOR
   ============================================ */

.target-indicator {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: var(--space-2);
}

.target-indicator .target-name {
    color: var(--primary);
    font-weight: 500;
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 767px) {
    /* Modals: nearly full-width on mobile */
    .modal-content {
        max-width: calc(100vw - var(--space-8));
        margin: var(--space-4);
    }

    /* Modal buttons stack vertically */
    .modal-buttons {
        flex-direction: column;
    }

    /* Cards: reduce padding */
    .card {
        padding: 0;
    }
    .card-header {
        flex-direction: column;
        gap: var(--space-2);
        align-items: flex-start;
    }

    /* Forms: stack form-row children */
    .form-row {
        flex-direction: column;
        gap: var(--space-4);
    }

    /* Info grid: single column */
    .info-grid {
        grid-template-columns: 1fr;
    }
    .info-item[style*="grid-column: span 2"] {
        grid-column: span 1 !important;
    }

    /* Toast: full width at bottom */
    .toast-container {
        left: var(--space-4);
        right: var(--space-4);
    }
    .toast {
        max-width: none;
        min-width: 0;
    }

    /* Action buttons stack */
    .action-buttons {
        flex-direction: column;
        gap: var(--space-2);
    }
    .action-buttons .btn {
        width: 100%;
    }
}

@media (max-width: 480px) {
    /* Smaller form inputs */
    input, select, textarea {
        font-size: 16px; /* Prevents iOS zoom on focus */
    }
}

/* ============================================
   PAGINATION BAR
   ============================================ */

.pagination-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-3);
    padding: var(--space-3) 0;
    margin-top: var(--space-2);
}

.pagination-info {
    font-size: 12px;
    color: var(--text-muted);
    min-width: 100px;
    text-align: center;
}

/* ============================================
   UTILITY CLASSES
   ============================================ */

/* Section dividers */
.section-divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: var(--space-4) 0;
}

/* Scrollable containers */
.scroll-box {
    max-height: 200px;
    overflow-y: auto;
}

.scroll-box-lg {
    max-height: 400px;
    overflow-y: auto;
}

/* Game Data: fill viewport height via flex chain.
   .gamedata-fill is added to the container in gamedata.html.
   Chain: container → tab-content → grid → card → scroll-box-lg */
.gamedata-fill {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 48px);  /* minus topbar */
    overflow-y: auto;
}
.gamedata-fill .page-header,
.gamedata-fill .tabs {
    flex-shrink: 0;
}
.gamedata-fill .tab-content.active {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}
.gamedata-fill .tab-content > .grid {
    flex: 1;
    min-height: 0;
    grid-template-rows: 1fr;
}
.gamedata-fill .grid > .card {
    display: flex;
    flex-direction: column;
    min-height: 0;
    margin-bottom: 0;
}
.gamedata-fill .card-header,
.gamedata-fill .search-box,
.gamedata-fill .filter-row,
.gamedata-fill .results-info {
    flex-shrink: 0;
}
.gamedata-fill .scroll-box-lg {
    flex: 1;
    min-height: 100px;
    max-height: none;
}
.gamedata-fill .item-detail-card,
.gamedata-fill .monster-detail-card,
.gamedata-fill .map-detail-card,
.gamedata-fill .npc-detail-card {
    max-height: none;
}

/* GM Permission checkboxes */
.perm-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: var(--space-1) var(--space-3);
    margin-bottom: var(--space-4);
}

.perm-check {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-1) var(--space-2);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 13px;
    color: var(--text-primary);
    user-select: none;
    transition: background 0.1s;
}

.perm-check:hover {
    background: var(--bg-muted);
}

.perm-check input[type="checkbox"] {
    width: 16px;
    height: 16px;
    min-width: 16px;
    padding: 0;
    border: none;
    accent-color: var(--primary);
    cursor: pointer;
}

.perm-check .perm-id {
    font-size: 11px;
    color: var(--text-muted);
    min-width: 16px;
}

/* GM Permission account cards */
.perm-account {
    background: var(--bg-muted);
    border-radius: var(--radius);
    margin-bottom: var(--space-3);
}

.perm-account-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-3) var(--space-4);
}

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

.perm-account-meta {
    font-size: 12px;
    color: var(--text-muted);
    margin-left: var(--space-2);
    font-weight: 400;
}

.perm-account-body {
    padding: 0 var(--space-4) var(--space-3);
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-1);
}

.perm-tag {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: 2px 10px;
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 500;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    color: var(--text-secondary);
}

.perm-tag .perm-tag-delete {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    font-size: 12px;
    line-height: 1;
    cursor: pointer;
    color: var(--text-muted);
    transition: color 0.15s, background 0.15s;
    background: none;
    border: none;
    padding: 0;
    margin-left: 2px;
}

.perm-tag .perm-tag-delete:hover {
    color: var(--error-text);
    background: var(--error-bg);
}

/* Overflow "+N more" tag */
.perm-tag-overflow {
    color: var(--text-muted);
    font-style: italic;
    border-style: dashed;
}

/* Restriction permission tags (inverted logic - blocks the account) */
.perm-tag-restriction {
    background: var(--error-bg);
    border-color: var(--error-text);
    color: var(--error-text);
}

/* Restriction checkbox label in the add form */
.perm-check-restriction {
    color: var(--error-text);
}

/* Divider between grant and restriction sections in checkbox list */
.perm-section-divider {
    grid-column: 1 / -1;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--error-text);
    padding: var(--space-2) 0 var(--space-1);
    margin-top: var(--space-2);
    border-top: 1px solid var(--border);
}

/* Filter/toolbar rows */
.filter-row {
    display: flex;
    gap: var(--space-2);
    margin-bottom: var(--space-3);
    flex-wrap: wrap;
    align-items: end;
}

/* Compact input widths */
.input-xs { width: 70px; }
.input-sm { width: 100px; }
.input-md { width: 140px; }

/* Autocomplete dropdown */
.autocomplete-wrapper { position: relative; flex: 1; }
.autocomplete-list {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 50;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    box-shadow: var(--shadow-md);
    max-height: 200px;
    overflow-y: auto;
    display: none;
}
.autocomplete-list.open { display: block; }
.autocomplete-item {
    padding: 6px 12px;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-primary);
}
.autocomplete-item:hover, .autocomplete-item.active {
    background: var(--bg-muted);
}

/* ============================================
   LOADING STATES
   ============================================ */

/* Spinning indicator */
.loading-spinner {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    color: var(--text-muted);
    font-size: 14px;
    padding: var(--space-4);
}

.loading-spinner::before {
    content: '';
    width: 18px;
    height: 18px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Centered loading spinner for containers */
.loading-spinner-center {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 120px;
}

/* Loading overlay for sections */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--overlay-bg, rgba(255, 255, 255, 0.8));
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    border-radius: var(--radius);
}

/* Container needs position relative for overlay */
.loading-container {
    position: relative;
    min-height: 80px;
}

/* Skeleton loading placeholder for tables */
.skeleton {
    background: linear-gradient(90deg, var(--bg-muted) 25%, var(--bg-inset) 50%, var(--bg-muted) 75%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s ease-in-out infinite;
    border-radius: var(--radius-sm);
}

.skeleton-row {
    display: flex;
    gap: var(--space-3);
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
}

.skeleton-cell {
    height: 16px;
    background: linear-gradient(90deg, var(--bg-muted) 25%, var(--bg-inset) 50%, var(--bg-muted) 75%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s ease-in-out infinite;
    border-radius: var(--radius-sm);
}

.skeleton-cell-sm { width: 60px; }
.skeleton-cell-md { width: 120px; }
.skeleton-cell-lg { flex: 1; max-width: 200px; }

@keyframes skeleton-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ============================================
   EMPTY STATES
   ============================================ */

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-8) var(--space-4);
    text-align: center;
    color: var(--text-muted);
}

.empty-state-icon {
    font-size: 48px;
    margin-bottom: var(--space-3);
    opacity: 0.5;
}

.empty-state-title {
    font-size: 16px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: var(--space-1);
}

.empty-state-message {
    font-size: 14px;
    color: var(--text-muted);
    max-width: 300px;
}

/* Compact empty state for inline use */
.empty-state-compact {
    padding: var(--space-4);
}

.empty-state-compact .empty-state-icon {
    font-size: 32px;
    margin-bottom: var(--space-2);
}

.empty-state-compact .empty-state-title {
    font-size: 14px;
}

.empty-state-compact .empty-state-message {
    font-size: 12px;
}

/* ============================================
   DATE RANGE GROUP
   ============================================ */

.date-range-group {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.date-range-group label {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
}

.date-range-group input[type="date"] {
    width: 140px;
}

/* ============================================
   PAGINATION CONTROLS
   ============================================ */

.pagination-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-4);
    margin-top: var(--space-4);
    padding-top: var(--space-4);
    border-top: 1px solid var(--border);
}

.pagination-info {
    font-size: 14px;
    color: var(--text-secondary);
    min-width: 80px;
    text-align: center;
}

/* ============================================
   LOG TABLE STYLES
   ============================================ */

.log-table {
    font-size: 13px;
    width: 100%;
}

.log-table th {
    font-size: 11px;
    padding: 8px 10px;
}

.log-table td {
    padding: 6px 10px;
    vertical-align: middle;
}

.log-table .nowrap {
    white-space: nowrap;
}

.log-table .truncate {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ip-address {
    font-family: var(--font-mono);
    font-size: 12px;
}

/* Badge variants for log actions */
.badge-default {
    background: var(--bg-muted);
    color: var(--text-secondary);
}

.badge-danger {
    background: var(--error-bg);
    color: var(--error-text);
}

.badge-success {
    background: var(--success-bg);
    color: var(--success-text);
}

/* ============================================
   ACCOUNT FLAGS / TAGS
   ============================================ */

.account-flags {
    display: inline-flex;
    gap: 4px;
    flex-wrap: wrap;
}

.badge-flag {
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 3px;
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.badge-flag-suspicious {
    background: #fef3c7;
    color: #92400e;
}

.badge-flag-vip {
    background: #dbeafe;
    color: #1e40af;
}

.badge-flag-bot {
    background: #fee2e2;
    color: #991b1b;
}

.badge-flag-trusted {
    background: #d1fae5;
    color: #065f46;
}

.badge-flag-watch {
    background: #fce7f3;
    color: #9d174d;
}

/* Flag buttons */
.flag-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.flag-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    font-size: 11px;
    border-radius: 4px;
    border: 1px solid var(--border);
    background: var(--bg-surface);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s;
}

.flag-btn:hover {
    border-color: var(--border-strong);
    background: var(--bg-muted);
}

.flag-btn.active {
    border-color: transparent;
}

.flag-btn.active[data-flag="suspicious"] {
    background: #fef3c7;
    color: #92400e;
}

.flag-btn.active[data-flag="vip"] {
    background: #dbeafe;
    color: #1e40af;
}

.flag-btn.active[data-flag="bot"] {
    background: #fee2e2;
    color: #991b1b;
}

.flag-btn.active[data-flag="trusted"] {
    background: #d1fae5;
    color: #065f46;
}

.flag-btn.active[data-flag="watch"] {
    background: #fce7f3;
    color: #9d174d;
}

/* Notes section */
.notes-section {
    margin-top: 16px;
}

.notes-textarea {
    width: 100%;
    min-height: 80px;
    resize: vertical;
}

.notes-history {
    margin-top: 12px;
    max-height: 200px;
    overflow-y: auto;
}

.note-entry {
    padding: 8px;
    margin-bottom: 8px;
    background: var(--bg-inset);
    border-radius: 4px;
    font-size: 12px;
}

.note-entry-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
    font-size: 11px;
    color: var(--text-muted);
}

.note-entry-text {
    color: var(--text-primary);
    white-space: pre-wrap;
}

/* Note templates */
.note-templates {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 8px;
}

.note-template-btn {
    padding: 3px 8px;
    font-size: 10px;
    background: var(--bg-muted);
    border: 1px solid var(--border);
    border-radius: 3px;
    cursor: pointer;
    transition: all 0.15s;
}

.note-template-btn:hover {
    background: var(--bg-inset);
    border-color: var(--border-strong);
}

/* Watchlist styles */
.watchlist-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 8px;
    transition: all 0.15s;
}

.watchlist-item:hover {
    border-color: var(--border-strong);
    box-shadow: var(--shadow-sm);
}

.watchlist-item-info {
    flex: 1;
    min-width: 0;
}

.watchlist-item-name {
    font-weight: 500;
    color: var(--text-primary);
    cursor: pointer;
}

.watchlist-item-name:hover {
    color: var(--primary);
}

.watchlist-item-details {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

.watchlist-item-actions {
    display: flex;
    gap: 6px;
}

/* Flag statistics */
.flag-stats {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.flag-stat-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.flag-stat-count {
    font-size: 24px;
    font-weight: 600;
    color: var(--text-primary);
}

.flag-stat-label {
    font-size: 12px;
    color: var(--text-secondary);
}

/* ============================================
   GUILD EMBLEM DISPLAY
   ============================================ */

.guild-emblem {
    width: 48px;
    height: 48px;
    flex-shrink: 0;
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--bg-muted);
}

.guild-emblem img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.guild-emblem-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px dashed var(--border);
}

.guild-emblem-icon {
    font-size: 24px;
    color: var(--text-muted);
}

/* ============================================
   ACTION CELL IN TABLES
   ============================================ */

.action-cell {
    white-space: nowrap;
}

.action-cell .btn {
    padding: 4px 8px;
    font-size: 11px;
    margin-left: 4px;
}

.action-cell .btn:first-child {
    margin-left: 0;
}

/* ============================================
   SORTABLE TABLE HEADERS
   ============================================ */

th.sortable {
    cursor: pointer;
    user-select: none;
    transition: background 0.15s;
}

th.sortable:hover {
    background: var(--border);
}

/* ============================================
   RESULTS INFO BAR
   ============================================ */

.results-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-2) 0;
    margin-bottom: var(--space-2);
    font-size: 12px;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
}

.results-info .pagination {
    display: flex;
    gap: var(--space-1);
}

.results-info .pagination button {
    min-width: 28px;
    height: 28px;
    padding: 4px 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-surface);
    color: var(--text-secondary);
    font-size: 12px;
    cursor: pointer;
    transition: all 0.15s;
}

.results-info .pagination button:hover:not(:disabled) {
    border-color: var(--primary);
    color: var(--primary);
}

.results-info .pagination button.active {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--primary-foreground);
}

.results-info .pagination button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ============================================
   ITEM/MONSTER DETAIL CARDS (inline panels)
   ============================================ */

.item-detail-card,
.monster-detail-card,
.map-detail-card,
.npc-detail-card {
    overflow-y: auto;
}

.item-detail-card .info-grid,
.monster-detail-card .info-grid,
.map-detail-card .info-grid,
.npc-detail-card .info-grid {
    grid-template-columns: repeat(2, 1fr);
}

/* Monster detail panel */
.mob-detail-header {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 6px;
}
.mob-detail-sprite {
    flex-shrink: 0;
    width: 64px;
    height: 64px;
    object-fit: contain;
}
.mob-detail-header-info {
    flex: 1;
    min-width: 0;
}
.mob-detail-name {
    font-size: 14px;
    font-weight: 600;
    line-height: 1.3;
}
.mob-detail-dbname {
    font-size: 10px;
    color: var(--text-muted);
}
.mob-header-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 2px 10px;
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 4px;
}
.mob-header-stats b {
    color: var(--text-primary);
}
.mob-detail-muted {
    font-size: 11px;
    color: var(--text-muted);
}
/* 2-pair stat table (label|value|label|value) */
.mob-stat-table {
    width: 100%;
    font-size: 11px;
    border-collapse: collapse;
    margin-bottom: 6px;
    border-top: 1px solid var(--border);
}
.mob-stat-table tr:nth-child(even) td {
    background: var(--bg-subtle);
}
.mob-stat-table td {
    padding: 3px 4px;
    border-bottom: 1px solid color-mix(in srgb, var(--border) 50%, transparent);
    white-space: nowrap;
}
.mob-base-stats {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-secondary);
}
.mob-base-stats b {
    color: var(--text-primary);
    margin-right: 2px;
}
.mob-stat-label {
    color: var(--text-muted);
    font-weight: 500;
    margin-right: 4px;
}
.mob-stat-ratio {
    color: var(--text-muted);
    font-size: 10px;
}
/* Sections (drops, skills, spawns) */
.mob-detail-section {
    border-top: 1px solid var(--border);
    padding-top: 6px;
    margin-top: 6px;
}
.mob-detail-section-title {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 4px;
}
.mob-detail-table {
    width: 100%;
    font-size: 11px;
    border-collapse: collapse;
}
.mob-detail-table td {
    padding: 2px 4px;
    vertical-align: middle;
}
.mob-detail-table tr.clickable:hover td {
    background: var(--bg-subtle);
}
.mob-mvp-drops-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--warning);
    margin-bottom: 4px;
}
.mob-skill-state {
    font-weight: 600;
    color: var(--text-muted);
    font-size: 10px;
    padding-top: 4px !important;
}

@media (max-width: 900px) {
    .item-detail-card .info-grid,
    .monster-detail-card .info-grid,
    .map-detail-card .info-grid,
    .npc-detail-card .info-grid {
        grid-template-columns: 1fr;
    }

    /* Detail cards become fixed overlays on smaller screens */
    .item-detail-card,
    .monster-detail-card,
    .map-detail-card,
    .npc-detail-card {
        position: fixed !important;
        top: 0;
        right: -100%;
        width: 100%;
        max-width: 400px;
        height: 100vh;
        max-height: 100vh;
        z-index: 1000;
        background: var(--bg-surface);
        box-shadow: -4px 0 24px rgba(0, 0, 0, 0.2);
        transition: right 0.25s ease;
        border-radius: 0;
        margin: 0;
    }

    .item-detail-card.open,
    .monster-detail-card.open,
    .map-detail-card.open,
    .npc-detail-card.open {
        right: 0;
    }

    /* Backdrop overlay behind detail panel */
    .detail-card-backdrop {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.4);
        z-index: 999;
        opacity: 0;
        transition: opacity 0.25s ease;
        pointer-events: none;
    }

    .detail-card-backdrop.open {
        opacity: 1;
        pointer-events: auto;
    }
}

/* Code styling for IPs etc */
code {
    font-family: var(--font-mono);
    font-size: 12px;
    background: var(--bg-muted);
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    color: var(--text-primary);
}

/* Text utilities */
.text-success {
    color: var(--success-text);
}

.text-danger {
    color: var(--error-text);
}

/* ============================================
   KEYBOARD SHORTCUTS
   ============================================ */

/* Keyboard selected row in tables */
tr.keyboard-selected {
    background: var(--primary-muted) !important;
    outline: 2px solid var(--primary);
    outline-offset: -2px;
}

tr.keyboard-selected td {
    background: inherit;
}

/* Keyboard help modal */
.keyboard-help-modal .modal-content {
    max-width: 600px;
    max-height: 80vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.keyboard-help-body {
    overflow-y: auto;
    flex: 1;
    padding-right: var(--space-2);
}

.keyboard-help-section {
    margin-bottom: var(--space-5);
}

.keyboard-help-section:last-child {
    margin-bottom: 0;
}

.keyboard-help-section-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: var(--space-3);
    padding-bottom: var(--space-2);
    border-bottom: 1px solid var(--border);
}

.keyboard-help-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.keyboard-help-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2) 0;
}

.keyboard-help-keys {
    min-width: 120px;
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}

.keyboard-help-desc {
    color: var(--text-secondary);
    font-size: 14px;
}

/* Keyboard key styling */
.kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    height: 24px;
    padding: 2px 8px;
    background: var(--bg-muted);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 500;
    color: var(--text-primary);
    box-shadow: 0 1px 0 var(--border);
}

.kbd-plus {
    color: var(--text-muted);
    font-size: 10px;
    margin: 0 2px;
}

.kbd-or {
    color: var(--text-muted);
    font-size: 11px;
    margin: 0 6px;
}

/* Responsive keyboard help */
@media (max-width: 480px) {
    .keyboard-help-modal .modal-content {
        max-height: 90vh;
    }

    .keyboard-help-item {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-1);
    }

    .keyboard-help-keys {
        min-width: auto;
    }
}

/* ============================================
   BULK OPERATIONS
   ============================================ */

.bulk-toolbar {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    padding: var(--space-3) var(--space-4);
    background: var(--primary-muted);
    border-radius: var(--radius);
    margin-bottom: var(--space-3);
    animation: slideIn 0.2s ease;
}

.bulk-count {
    font-size: 14px;
    font-weight: 500;
    color: var(--primary);
}

/* Row checkbox styling */
.row-checkbox {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--primary);
}

/* Selected row highlight */
tr.selected {
    background: var(--primary-muted) !important;
}

/* ============================================
   CHARACTER COMPARISON VIEW
   ============================================ */

.compare-body {
    max-height: 500px;
    overflow-y: auto;
}

.compare-grid {
    display: grid;
    gap: var(--space-4);
}

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

.compare-grid-3 {
    grid-template-columns: repeat(3, 1fr);
}

.compare-grid-4 {
    grid-template-columns: repeat(4, 1fr);
}

@media (max-width: 700px) {
    .compare-grid-2,
    .compare-grid-3,
    .compare-grid-4 {
        grid-template-columns: 1fr;
    }
}

.compare-card {
    background: var(--bg-muted);
    border-radius: var(--radius);
    padding: var(--space-4);
}

.compare-card-header {
    text-align: center;
    padding-bottom: var(--space-3);
    border-bottom: 1px solid var(--border);
    margin-bottom: var(--space-3);
}

.compare-card-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-1);
}

.compare-card-job {
    font-size: 12px;
}

.compare-section {
    margin-top: var(--space-4);
}

.compare-section-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: var(--space-2);
}

.compare-row {
    display: flex;
    justify-content: space-between;
    padding: var(--space-1) 0;
    font-size: 13px;
}

.compare-label {
    color: var(--text-secondary);
}

.compare-value {
    font-weight: 500;
    color: var(--text-primary);
}

.compare-value.best {
    color: var(--success-text);
    font-weight: 600;
}

.compare-value.worst {
    color: var(--text-muted);
}

/* ============================================
   EQUIPMENT SLOT VISUALIZATION
   ============================================ */

.equipment-body {
    padding: var(--space-2);
}

.equipment-grid {
    display: grid;
    grid-template-columns: 1fr 100px 1fr;
    grid-template-rows: repeat(5, auto);
    gap: var(--space-2);
    max-width: 400px;
    margin: 0 auto;
}

.equip-slot {
    background: var(--bg-muted);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: var(--space-2) var(--space-3);
    min-height: 50px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}

.equip-slot:hover {
    border-color: var(--primary);
    background: var(--bg-surface);
}

.equip-slot.empty {
    border-style: dashed;
    opacity: 0.6;
}

.equip-slot.empty:hover {
    opacity: 1;
}

.equip-slot-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 2px;
}

.equip-slot-item {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.equip-slot-item .refine {
    color: var(--primary);
}

/* Grid positioning for equipment slots */
.equip-head-top { grid-column: 2; grid-row: 1; }
.equip-head-mid { grid-column: 1; grid-row: 2; }
.equip-head-low { grid-column: 3; grid-row: 2; }
.equip-armor { grid-column: 2; grid-row: 2; }
.equip-weapon { grid-column: 1; grid-row: 3; }
.equip-shield { grid-column: 3; grid-row: 3; }
.equip-garment { grid-column: 2; grid-row: 3; }
.equip-shoes { grid-column: 2; grid-row: 4; }
.equip-acc-l { grid-column: 1; grid-row: 4; }
.equip-acc-r { grid-column: 3; grid-row: 4; }

/* Character silhouette placeholder in center */
.equip-center {
    grid-column: 2;
    grid-row: 2 / 5;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 48px;
    opacity: 0.3;
    pointer-events: none;
}

/* Equipment detail tooltip */
.equip-detail {
    position: absolute;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: var(--space-3);
    box-shadow: var(--shadow-lg);
    z-index: 100;
    min-width: 200px;
    font-size: 12px;
}

.equip-detail-name {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-2);
}

.equip-detail-stat {
    display: flex;
    justify-content: space-between;
    padding: 2px 0;
    color: var(--text-secondary);
}

/* ============================================
   INVENTORY SEARCH
   ============================================ */

.inventory-search {
    display: flex;
    gap: var(--space-2);
    margin-bottom: var(--space-3);
}

.inventory-search input {
    flex: 1;
    height: 32px;
    font-size: 13px;
}

.inventory-item.highlight {
    background: var(--warning-bg);
    border-radius: var(--radius-sm);
}

.inventory-item.dimmed {
    opacity: 0.4;
}

/* ============================================
   OFFLINE BANNER
   ============================================ */

.offline-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1100;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-4);
    background: var(--warning);
    color: #fff;
    font-size: 14px;
    font-weight: 500;
    transform: translateY(-100%);
    transition: transform 0.3s ease;
}

.offline-banner.visible {
    transform: translateY(0);
}

.offline-banner-icon {
    display: flex;
    align-items: center;
}

.offline-banner-icon svg {
    width: 18px;
    height: 18px;
}

/* ============================================
   FORM VALIDATION ERRORS
   ============================================ */

.field-error {
    border-color: var(--error) !important;
    background: var(--error-bg) !important;
}

.field-error:focus {
    box-shadow: 0 0 0 2px var(--error-bg) !important;
    border-color: var(--error) !important;
}

.field-error-message {
    color: var(--error-text);
    font-size: 12px;
    margin-top: var(--space-1);
    display: flex;
    align-items: center;
    gap: var(--space-1);
}

.field-error-message::before {
    content: '';
    display: inline-block;
    width: 14px;
    height: 14px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23B91C1C' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cline x1='12' y1='8' x2='12' y2='12'/%3E%3Cline x1='12' y1='16' x2='12.01' y2='16'/%3E%3C/svg%3E") no-repeat center;
    background-size: contain;
    flex-shrink: 0;
}

/* ============================================
   CONNECTION STATUS INDICATOR
   ============================================ */

.connection-indicator {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: 4px 10px;
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.connection-indicator-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    transition: background 0.2s ease;
}

.connection-indicator-text {
    white-space: nowrap;
}

/* Connected state */
.connection-connected {
    background: var(--success-bg);
    color: var(--success-text);
}

.connection-connected .connection-indicator-dot {
    background: var(--success);
    box-shadow: 0 0 6px var(--success);
}

/* Disconnected state */
.connection-disconnected {
    background: var(--error-bg);
    color: var(--error-text);
    cursor: pointer;
}

.connection-disconnected:hover {
    background: var(--error-border);
}

.connection-disconnected .connection-indicator-dot {
    background: var(--error);
}

/* Reconnecting state */
.connection-reconnecting {
    background: var(--warning-bg);
    color: var(--warning-text);
}

.connection-reconnecting .connection-indicator-dot {
    background: var(--warning);
}

/* Pulse animation for reconnecting */
.connection-indicator-dot.pulse {
    animation: connection-pulse 1.5s ease-in-out infinite;
}

@keyframes connection-pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.5;
        transform: scale(0.8);
    }
}

/* ============================================
   ERROR STATE (for sections)
   ============================================ */

.error-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-8) var(--space-4);
    text-align: center;
    color: var(--error-text);
    background: var(--error-bg);
    border-radius: var(--radius);
    border: 1px solid var(--error-border);
}

.error-state-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--error);
    color: #fff;
    font-size: 24px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: var(--space-3);
}

.error-state-message {
    font-size: 14px;
    margin-bottom: var(--space-4);
    max-width: 300px;
}

.error-state-retry {
    margin-top: var(--space-2);
}

/* Compact error state for inline use */
.error-state-compact {
    padding: var(--space-4);
    flex-direction: row;
    gap: var(--space-3);
}

.error-state-compact .error-state-icon {
    width: 32px;
    height: 32px;
    font-size: 16px;
    margin-bottom: 0;
}

.error-state-compact .error-state-message {
    margin-bottom: 0;
    text-align: left;
}

/* ============================================
   DISABLED STATE FOR OFFLINE
   ============================================ */

[data-requires-network].disabled,
[data-requires-network]:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* ============================================
   RESPONSIVE: Connection indicator
   ============================================ */

@media (max-width: 767px) {
    .connection-indicator-text {
        display: none;
    }

    .connection-indicator {
        padding: 6px;
    }

    .offline-banner {
        font-size: 13px;
        padding: var(--space-2) var(--space-3);
    }
}

/* ============================================
   COMMAND PALETTE
   ============================================ */

.command-palette {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1100;
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding-top: 10vh;
}

.command-palette.open {
    display: flex;
}

.command-palette-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--overlay-backdrop);
    animation: cmdPaletteFadeIn 0.15s ease;
}

.command-palette-dialog {
    position: relative;
    width: 100%;
    max-width: 560px;
    max-height: 70vh;
    margin: 0 var(--space-4);
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    display: flex;
    flex-direction: column;
    animation: cmdPaletteSlideIn 0.15s ease;
    overflow: hidden;
}

.command-palette-header {
    padding: var(--space-3);
    border-bottom: 1px solid var(--border);
}

.command-palette-input-wrapper {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    background: var(--bg-muted);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: var(--space-2) var(--space-3);
    transition: border-color 0.15s, box-shadow 0.15s;
}

.command-palette-input-wrapper:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-muted);
}

.command-palette-search-icon {
    width: 18px;
    height: 18px;
    color: var(--text-muted);
    flex-shrink: 0;
}

.command-palette-input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 15px;
    color: var(--text-primary);
    outline: none;
    padding: 0;
    height: auto;
}

.command-palette-input::placeholder {
    color: var(--text-muted);
}

.command-palette-hint {
    flex-shrink: 0;
    padding: 2px 6px;
    font-size: 11px;
    font-family: var(--font-mono);
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
}

.command-palette-list {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-2);
    max-height: calc(70vh - 100px);
}

.command-palette-section {
    margin-bottom: var(--space-1);
}

.command-palette-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-2) var(--space-2);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.command-palette-section-header span {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.command-palette-section-header svg {
    width: 14px;
    height: 14px;
}

.command-palette-clear-recent {
    font-size: 11px;
    font-weight: 400;
    text-transform: none;
    letter-spacing: normal;
    color: var(--text-muted);
    background: none;
    border: none;
    padding: 2px 6px;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: background 0.15s, color 0.15s;
}

.command-palette-clear-recent:hover {
    background: var(--bg-muted);
    color: var(--text-primary);
}

.command-palette-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-2) var(--space-3);
    margin-bottom: 2px;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.1s;
}

.command-palette-item:hover,
.command-palette-item.active {
    background: var(--bg-muted);
}

.command-palette-item.active {
    background: var(--primary-muted);
    outline: 2px solid var(--primary);
    outline-offset: -2px;
}

.command-palette-item-content {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    min-width: 0;
    flex: 1;
}

.command-palette-item-label {
    font-size: 14px;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.command-palette-item-label mark {
    background: var(--warning-bg);
    color: inherit;
    padding: 0 1px;
    border-radius: 2px;
}

.command-palette-item-badge {
    font-size: 10px;
    font-weight: 500;
    padding: 2px 6px;
    border-radius: var(--radius-full);
    background: var(--bg-muted);
    color: var(--text-muted);
    white-space: nowrap;
}

.command-palette-item-badge.recent {
    background: var(--primary-muted);
    color: var(--primary);
}

.command-palette-item-shortcut {
    flex-shrink: 0;
    font-size: 11px;
    font-family: var(--font-mono);
    padding: 2px 8px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
}

.command-palette-empty {
    padding: var(--space-6);
    text-align: center;
    color: var(--text-muted);
    font-size: 14px;
}

.command-palette-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-4);
    padding: var(--space-2) var(--space-3);
    border-top: 1px solid var(--border);
    background: var(--bg-muted);
    font-size: 11px;
    color: var(--text-muted);
}

.command-palette-footer span {
    display: flex;
    align-items: center;
    gap: var(--space-1);
}

.command-palette-footer kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    font-size: 10px;
    font-family: var(--font-mono);
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 3px;
    color: var(--text-secondary);
}

/* Command palette animations */
@keyframes cmdPaletteFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes cmdPaletteSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Responsive command palette */
@media (max-width: 600px) {
    .command-palette {
        padding-top: var(--space-4);
    }

    .command-palette-dialog {
        max-height: calc(100vh - var(--space-8));
        margin: 0 var(--space-2);
        border-radius: var(--radius);
    }

    .command-palette-footer {
        flex-wrap: wrap;
        gap: var(--space-2);
    }
}

/* ============================================
   FAVORITES & RECENT ITEMS
   ============================================ */

/* Favorite button (star icon) */
.favorite-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s ease;
    flex-shrink: 0;
}

.favorite-btn:hover {
    border-color: var(--warning);
    color: var(--warning);
    background: var(--warning-bg);
}

.favorite-btn.active {
    border-color: var(--warning);
    color: var(--warning);
    background: var(--warning-bg);
}

.favorite-btn svg {
    width: 16px;
    height: 16px;
}

/* Favorite indicator in search results */
.favorite-indicator {
    display: inline-flex;
    align-items: center;
    color: var(--warning);
    margin-left: var(--space-1);
}

.favorite-indicator svg {
    width: 12px;
    height: 12px;
}

/* Favorites sidebar section */
.favorites-section {
    padding: var(--space-3);
    border-top: 1px solid var(--border);
}

.favorites-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-2) 0;
    margin-bottom: var(--space-2);
}

.favorites-section-title {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.favorites-section-title svg {
    width: 14px;
    height: 14px;
}

/* Favorites groups */
.favorites-group {
    margin-bottom: var(--space-3);
}

.favorites-group:last-child {
    margin-bottom: 0;
}

.favorites-group-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    padding: var(--space-1) var(--space-2);
    margin-bottom: var(--space-1);
}

/* Favorites item */
.favorites-item {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-2);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 13px;
    transition: background 0.15s, color 0.15s;
}

.favorites-item:hover {
    background: var(--bg-muted);
    color: var(--text-primary);
    text-decoration: none;
}

.favorites-item-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    color: var(--text-muted);
}

.favorites-item-icon svg {
    width: 14px;
    height: 14px;
}

.favorites-item-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.favorites-item-remove {
    display: none;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    background: none;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s, color 0.15s;
}

.favorites-item:hover .favorites-item-remove {
    display: flex;
}

.favorites-item-remove:hover {
    background: var(--error-bg);
    color: var(--error-text);
}

.favorites-item-remove svg {
    width: 12px;
    height: 12px;
}

/* Empty state for favorites */
.favorites-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-4);
    color: var(--text-muted);
    font-size: 12px;
    text-align: center;
}

.favorites-empty svg {
    width: 24px;
    height: 24px;
    opacity: 0.5;
}

/* Recent items header */
.recent-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-1) var(--space-2);
    margin-bottom: var(--space-1);
}

.recent-title {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.recent-clear {
    font-size: 10px;
    color: var(--text-muted);
    background: none;
    border: none;
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.recent-clear:hover {
    background: var(--bg-muted);
    color: var(--text-primary);
}

/* Quick access bar */
.quick-access-bar {
    display: none;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    background: var(--bg-muted);
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.quick-access-label {
    display: flex;
    align-items: center;
    color: var(--warning);
    flex-shrink: 0;
}

.quick-access-item {
    display: flex;
    align-items: center;
    gap: var(--space-1);
    padding: var(--space-1) var(--space-2);
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 12px;
    white-space: nowrap;
    transition: border-color 0.15s, color 0.15s;
}

.quick-access-item:hover {
    border-color: var(--primary);
    color: var(--text-primary);
    text-decoration: none;
}

.quick-access-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    color: var(--text-muted);
}

.quick-access-icon svg {
    width: 12px;
    height: 12px;
}

.quick-access-name {
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.quick-access-more {
    font-size: 11px;
    color: var(--text-muted);
    padding: 0 var(--space-2);
}

/* Detail panel header with favorite button */
.detail-header-with-favorite {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.detail-header-with-favorite h3 {
    flex: 1;
    margin: 0;
}

/* Favorites filter checkbox */
.favorites-filter {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
    user-select: none;
}

.favorites-filter input {
    accent-color: var(--warning);
}

/* Responsive favorites */
@media (max-width: 767px) {
    .quick-access-bar {
        padding: var(--space-2) var(--space-3);
    }

    .quick-access-name {
        display: none;
    }

    .quick-access-item {
        padding: var(--space-2);
    }

    .favorites-section {
        padding: var(--space-2);
    }
}

/* ============================================
   DATA EXPORT SYSTEM
   ============================================ */

/* Export format dropdown */
.export-format-dropdown {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    min-width: 180px;
    padding: var(--space-1);
    animation: dropdownFadeIn 0.15s ease;
}

@keyframes dropdownFadeIn {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.export-format-option {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    width: 100%;
    padding: var(--space-2) var(--space-3);
    border: none;
    background: transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    text-align: left;
    transition: background 0.15s;
}

.export-format-option:hover {
    background: var(--bg-muted);
}

.export-format-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 24px;
    font-size: 11px;
    font-weight: 700;
    background: var(--bg-muted);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-family: var(--font-mono);
}

.export-format-label {
    font-size: 13px;
    color: var(--text-primary);
}

/* Export button with dropdown arrow */
.export-btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
}

.export-btn-arrow {
    font-size: 10px;
    color: var(--text-muted);
    margin-left: var(--space-1);
}

/* Export page layout */
.export-page {
    max-width: 1000px;
}

.export-section {
    margin-bottom: var(--space-6);
}

.export-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-4);
}

.export-section-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

/* Data type cards */
.export-data-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: var(--space-4);
}

.export-data-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: var(--space-4);
    cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.export-data-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-sm);
}

.export-data-card.selected {
    border-color: var(--primary);
    background: var(--primary-muted);
}

.export-data-card-icon {
    font-size: 24px;
    margin-bottom: var(--space-2);
}

.export-data-card-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-1);
}

.export-data-card-desc {
    font-size: 12px;
    color: var(--text-muted);
}

/* Report templates */
.report-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: var(--space-4);
}

.report-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: var(--space-4);
    display: flex;
    flex-direction: column;
}

.report-card-header {
    margin-bottom: var(--space-3);
}

.report-card-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-1);
}

.report-card-desc {
    font-size: 12px;
    color: var(--text-muted);
}

.report-card-actions {
    margin-top: auto;
    padding-top: var(--space-3);
    display: flex;
    gap: var(--space-2);
}

/* Export history list */
.export-history-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.export-history-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3);
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.export-history-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: var(--bg-muted);
    border-radius: var(--radius);
    font-size: 11px;
    font-weight: 700;
    font-family: var(--font-mono);
    color: var(--text-muted);
}

.export-history-info {
    flex: 1;
    min-width: 0;
}

.export-history-filename {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.export-history-meta {
    display: flex;
    gap: var(--space-3);
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}

.export-history-actions {
    display: flex;
    gap: var(--space-2);
    flex-shrink: 0;
}

/* Schedule cards */
.schedule-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: var(--space-4);
}

.schedule-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: var(--space-4);
}

.schedule-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-3);
}

.schedule-card-title {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

.schedule-card-status {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: var(--radius-full);
}

.schedule-card-status.active {
    background: var(--success-bg);
    color: var(--success-text);
}

.schedule-card-status.inactive {
    background: var(--bg-muted);
    color: var(--text-muted);
}

.schedule-card-details {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: var(--space-3);
}

.schedule-card-detail {
    display: flex;
    justify-content: space-between;
    padding: var(--space-1) 0;
}

.schedule-card-actions {
    display: flex;
    gap: var(--space-2);
    padding-top: var(--space-3);
    border-top: 1px solid var(--border);
}

/* Preview table */
.export-preview {
    margin-top: var(--space-4);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.export-preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-3);
    background: var(--bg-muted);
    border-bottom: 1px solid var(--border);
}

.export-preview-title {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}

.export-preview-count {
    font-size: 12px;
    color: var(--text-muted);
}

.export-preview-table {
    max-height: 300px;
    overflow: auto;
}

.export-preview-table table {
    font-size: 12px;
}

.export-preview-table th {
    position: sticky;
    top: 0;
    background: var(--bg-surface);
    z-index: 1;
}

/* Export modal */
.export-modal .modal-content {
    max-width: 600px;
}

.export-modal-filters {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-3);
    margin-bottom: var(--space-4);
}

.export-modal-filters .form-group {
    margin-bottom: 0;
}

@media (max-width: 500px) {
    .export-modal-filters {
        grid-template-columns: 1fr;
    }
}

/* Date range picker */
.export-date-range {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.export-date-range label {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
}

.export-date-range input[type="date"] {
    width: 140px;
}

/* Format selector inline */
.export-format-inline {
    display: flex;
    gap: var(--space-2);
}

.export-format-inline .format-option {
    display: flex;
    align-items: center;
    gap: var(--space-1);
    padding: var(--space-2) var(--space-3);
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.15s;
}

.export-format-inline .format-option:hover {
    border-color: var(--border-strong);
}

.export-format-inline .format-option.selected {
    border-color: var(--primary);
    background: var(--primary-muted);
}

.export-format-inline .format-option input {
    display: none;
}

/* Scheduled export notice */
.schedule-notice {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    background: var(--warning-bg);
    border: 1px solid var(--warning);
    border-radius: var(--radius);
    margin-bottom: var(--space-4);
}

.schedule-notice-icon {
    color: var(--warning-text);
}

.schedule-notice-text {
    flex: 1;
    font-size: 13px;
    color: var(--warning-text);
}

/* Empty history state */
.export-history-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: var(--space-6);
    text-align: center;
    color: var(--text-muted);
}

.export-history-empty-icon {
    font-size: 32px;
    margin-bottom: var(--space-2);
    opacity: 0.5;
}

.export-history-empty-text {
    font-size: 14px;
}

/* Responsive export */
@media (max-width: 767px) {
    .export-data-grid {
        grid-template-columns: 1fr;
    }

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

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

    .export-history-item {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-2);
    }

    .export-history-actions {
        width: 100%;
        justify-content: flex-end;
    }

    .export-date-range {
        flex-direction: column;
        align-items: stretch;
    }

    .export-date-range input[type="date"] {
        width: 100%;
    }
}

/* ============================================
   SESSION TIMEOUT MODALS
   ============================================ */

/* Warning modal styling */
.session-warning-modal .modal-content,
.session-expired-modal .modal-content {
    max-width: 380px;
    text-align: center;
}

.session-warning-body {
    padding: var(--space-4) 0;
}

.session-warning-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: var(--warning-bg);
    color: var(--warning);
    margin-bottom: var(--space-4);
}

.session-warning-icon-expired {
    background: var(--error-bg);
    color: var(--error);
}

.session-warning-message,
.session-expired-message {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: var(--space-3);
}

.session-countdown {
    font-size: 48px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--text-primary);
    margin: var(--space-4) 0;
    line-height: 1;
}

.session-countdown.countdown-urgent {
    color: var(--error);
    animation: countdown-pulse 1s ease-in-out infinite;
}

@keyframes countdown-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

.session-warning-hint {
    font-size: 13px;
    color: var(--text-muted);
    margin: 0;
}

/* Ensure session modals are above everything */
.session-warning-modal,
.session-expired-modal {
    z-index: 2000;
}

/* Session modal buttons */
.session-warning-modal .modal-buttons,
.session-expired-modal .modal-buttons {
    justify-content: center;
    padding-top: var(--space-4);
    border-top: 1px solid var(--border);
}

/* ============================================
   CHAT LOGS
   ============================================ */

/* Chat not enabled notice */
.chat-not-enabled {
    text-align: center;
    padding: var(--space-8) var(--space-4);
    max-width: 500px;
    margin: 0 auto;
}

.chat-not-enabled .notice-icon {
    color: var(--text-muted);
    margin-bottom: var(--space-4);
}

.chat-not-enabled h4 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-2);
}

.chat-not-enabled > p {
    color: var(--text-secondary);
    margin-bottom: var(--space-4);
}

.chat-not-enabled .notice-details {
    text-align: left;
    background: var(--bg-muted);
    border-radius: var(--radius);
    padding: var(--space-4);
    margin-top: var(--space-4);
}

.chat-not-enabled .notice-details p {
    margin-bottom: var(--space-2);
    font-size: 13px;
}

.chat-not-enabled .notice-details ol {
    margin: var(--space-2) 0;
    padding-left: var(--space-5);
}

.chat-not-enabled .notice-details li {
    margin-bottom: var(--space-1);
    font-size: 13px;
    color: var(--text-secondary);
}

.chat-not-enabled code {
    background: var(--bg-inset);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 12px;
}

/* Chat log list */
.chat-log-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.chat-message {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: var(--space-3);
    transition: background 0.15s;
}

.chat-message:hover {
    background: var(--bg-muted);
}

/* Chat type-specific left border colors */
.chat-message.chat-type-0 { border-left: 3px solid var(--text-secondary); }  /* Public - gray */
.chat-message.chat-type-1 { border-left: 3px solid #ec4899; }  /* Whisper - pink */
.chat-message.chat-type-2 { border-left: 3px solid #3b82f6; }  /* Party - blue */
.chat-message.chat-type-3 { border-left: 3px solid #f59e0b; }  /* Guild - amber */
.chat-message.chat-type-4 { border-left: 3px solid #10b981; }  /* Trade - emerald */
.chat-message.chat-type-5 { border-left: 3px solid #ef4444; }  /* Broadcast - red */

.chat-meta {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin-bottom: var(--space-1);
}

.chat-time {
    font-size: 11px;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

.chat-content {
    font-size: 13px;
    line-height: 1.5;
}

.chat-sender {
    font-weight: 600;
    color: var(--primary);
}

.chat-receiver {
    font-weight: 600;
    color: #ec4899;
}

.chat-arrow {
    color: var(--text-muted);
    margin: 0 var(--space-1);
}

.chat-text {
    color: var(--text-primary);
}

/* Chat type badges */
.badge-whisper {
    background: #fce7f3;
    color: #be185d;
}

.badge-party {
    background: #dbeafe;
    color: #1d4ed8;
}

.badge-guild {
    background: #fef3c7;
    color: #b45309;
}

.badge-trade {
    background: #d1fae5;
    color: #047857;
}

.badge-broadcast {
    background: #fee2e2;
    color: #b91c1c;
}

/* Whisper conversation view */
.whisper-thread {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.whisper-thread-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-3);
    background: var(--bg-muted);
    border-bottom: 1px solid var(--border);
}

.whisper-thread-participants {
    font-weight: 600;
}

.whisper-thread-messages {
    max-height: 400px;
    overflow-y: auto;
    padding: var(--space-3);
}

.whisper-message {
    margin-bottom: var(--space-3);
}

.whisper-message.sent {
    text-align: right;
}

.whisper-message.sent .whisper-bubble {
    background: var(--primary);
    color: var(--primary-foreground);
    margin-left: 20%;
}

.whisper-message.received .whisper-bubble {
    background: var(--bg-muted);
    color: var(--text-primary);
    margin-right: 20%;
}

.whisper-bubble {
    display: inline-block;
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius);
    max-width: 80%;
}

.whisper-time {
    font-size: 10px;
    color: var(--text-muted);
    margin-top: var(--space-1);
}

/* Chat filters */
.chat-filters {
    margin-bottom: var(--space-4);
}

.input-lg {
    width: 250px;
}

/* ==================== WoE (War of Emperium) Components ==================== */

/* Investment bars */
.investment-bar {
    position: relative;
    width: 100px;
    height: 18px;
    background: var(--bg-muted);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.investment-fill {
    height: 100%;
    transition: width 0.3s ease;
}

.investment-fill.bar-economy {
    background: linear-gradient(90deg, #fbbf24, #f59e0b);
}

.investment-fill.bar-defense {
    background: linear-gradient(90deg, #60a5fa, #3b82f6);
}

.investment-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 11px;
    font-weight: 600;
    color: var(--text-primary);
    text-shadow: 0 0 2px var(--bg-surface);
}

/* Treasure chest status */
.chest-status {
    display: flex;
    align-items: center;
    gap: 2px;
}

.chest-icon {
    width: 14px;
    height: 14px;
    border-radius: 2px;
    display: inline-block;
}

.chest-icon.chest-visible {
    background: #22c55e;
}

.chest-icon.chest-hidden {
    background: var(--bg-muted);
    border: 1px solid var(--border);
}

.chest-count {
    font-size: 11px;
    color: var(--text-muted);
    margin-left: 4px;
}

/* Chest grid in detail panel */
.chest-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-2);
}

.chest-detail {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: var(--space-2);
    border-radius: var(--radius-sm);
    text-align: center;
}

.chest-detail.chest-visible {
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid #22c55e;
}

.chest-detail.chest-hidden {
    background: var(--bg-muted);
    border: 1px solid var(--border);
}

.chest-number {
    font-weight: 600;
    font-size: 14px;
}

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

/* ============================================
   WoE SCHEDULE — Countdown Hero
   ============================================ */
.woe-countdown-hero {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-8) var(--space-6);
    margin-bottom: var(--space-6);
    text-align: center;
    position: relative;
    overflow: hidden;
}

.woe-countdown-hero::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse 60% 80% at 50% 20%, var(--gold-wash) 0%, transparent 70%);
    pointer-events: none;
}

.woe-countdown-hero.woe-active {
    border-color: var(--success-border);
}

.woe-countdown-hero.woe-active::before {
    background: radial-gradient(ellipse 60% 80% at 50% 20%, rgba(60,127,92,.06) 0%, transparent 70%);
}

.woe-countdown-inner {
    position: relative;
}

.woe-status-line {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    margin-bottom: var(--space-3);
}

.woe-status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.woe-status-dot.inactive {
    background: var(--text-muted);
}

.woe-status-dot.active {
    background: var(--success);
    box-shadow: 0 0 8px rgba(60,127,92,.5);
    animation: woePulse 2s ease-in-out infinite;
}

@keyframes woePulse {
    0%, 100% { opacity: 1; box-shadow: 0 0 8px rgba(60,127,92,.5); }
    50% { opacity: .7; box-shadow: 0 0 16px rgba(60,127,92,.3); }
}

.woe-status-text {
    font-size: 13px;
    color: var(--text-secondary);
    letter-spacing: .02em;
    text-transform: uppercase;
    font-weight: 500;
}

.woe-countdown-label {
    font-family: var(--font-display);
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .12em;
    margin-bottom: var(--space-1);
}

.woe-countdown-timer {
    font-family: var(--font-mono);
    font-size: 40px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: .04em;
    line-height: 1;
    margin-bottom: var(--space-2);
}

.woe-countdown-timer.woe-now {
    color: var(--success);
}

.woe-countdown-edition {
    font-size: 13px;
    color: var(--text-muted);
}

.woe-countdown-edition .edition-tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .04em;
    margin-right: var(--space-1);
    vertical-align: middle;
}

.edition-tag-fe {
    background: var(--gold-pale);
    color: var(--gold);
}

.edition-tag-se {
    background: var(--blue-pale);
    color: var(--blue);
}

/* ============================================
   WoE SCHEDULE — Weekly Calendar
   ============================================ */
.woe-calendar {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0;
    margin-bottom: var(--space-3);
}

.cal-hours {
    display: grid;
    grid-template-columns: 48px 1fr;
    border-bottom: 1px solid var(--border-subtle);
}

.cal-corner {
    /* empty top-left cell */
}

.cal-hour-labels {
    display: flex;
    position: relative;
    height: 20px;
}

.cal-hour-label {
    position: absolute;
    font-size: 10px;
    color: var(--text-muted);
    font-family: var(--font-mono);
    transform: translateX(-50%);
    white-space: nowrap;
}

.cal-day {
    display: grid;
    grid-template-columns: 48px 1fr;
    align-items: center;
    border-bottom: 1px solid var(--border-subtle);
    min-height: 36px;
}

.cal-day:last-child {
    border-bottom: none;
}

.cal-day-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    padding-left: var(--space-2);
    text-transform: uppercase;
    letter-spacing: .05em;
}

.cal-day-label.cal-today {
    color: var(--gold);
}

.cal-day-track {
    position: relative;
    height: 28px;
    background: var(--bg-muted);
    border-radius: 4px;
    overflow: hidden;
    margin: 3px 0;
}

.cal-slot {
    position: absolute;
    top: 3px;
    bottom: 3px;
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: .03em;
    cursor: default;
    transition: filter .15s;
}

.cal-slot:hover {
    filter: brightness(1.1);
}

.cal-slot-fe {
    background: var(--gold);
    color: var(--gold-fg);
}

.cal-slot-se {
    background: var(--blue);
    color: #fff;
}

.cal-now-line {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--red);
    z-index: 2;
    pointer-events: none;
}

.cal-now-line::before {
    content: '';
    position: absolute;
    top: -3px;
    left: -3px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--red);
}

.time-format-toggle {
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-muted);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all .15s;
    line-height: 1.4;
}

.time-format-toggle:hover {
    border-color: var(--border-strong);
    color: var(--text-primary);
}

.woe-calendar-legend {
    display: flex;
    gap: var(--space-4);
    padding: 0 var(--space-2) var(--space-2);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: var(--space-1);
    font-size: 12px;
    color: var(--text-secondary);
}

.legend-swatch {
    width: 12px;
    height: 12px;
    border-radius: 3px;
}

.legend-fe { background: var(--gold); }
.legend-se { background: var(--blue); }

/* ============================================
   WoE SCHEDULE — Edition Detail Cards
   ============================================ */
.woe-editions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: var(--space-4);
}

.woe-edition-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    display: flex;
    box-shadow: var(--shadow-sm);
}

.edition-accent {
    width: 4px;
    flex-shrink: 0;
}

.woe-edition-fe .edition-accent { background: var(--gold); }
.woe-edition-se .edition-accent { background: var(--blue); }

.edition-body {
    padding: var(--space-4) var(--space-5);
    flex: 1;
}

.edition-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-3);
}

.edition-header h4 {
    font-family: var(--font-display);
    font-size: 15px;
    margin: 0;
}

.edition-badge {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .08em;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
}

.edition-badge-fe {
    background: var(--gold-pale);
    color: var(--gold);
}

.edition-badge-se {
    background: var(--blue-pale);
    color: var(--blue);
}

.edition-sessions {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    margin-bottom: var(--space-3);
    padding-bottom: var(--space-3);
    border-bottom: 1px solid var(--border-subtle);
}

.edition-session {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.session-day {
    font-weight: 600;
    font-size: 13px;
    color: var(--text-primary);
}

.session-time {
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--text-secondary);
}

.edition-details {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.edition-detail-row {
    display: flex;
    gap: var(--space-2);
    font-size: 12px;
    line-height: 1.4;
}

.detail-label {
    color: var(--text-muted);
    flex-shrink: 0;
    min-width: 56px;
    font-weight: 500;
}

.detail-value {
    color: var(--text-secondary);
}

/* Rankings badges */
.rank-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 600;
    background: var(--bg-muted);
    color: var(--text-secondary);
}

.rank-badge.rank-1 {
    background: linear-gradient(135deg, #ffd700, #ffb800);
    color: #000;
}

.rank-badge.rank-2 {
    background: linear-gradient(135deg, #c0c0c0, #a0a0a0);
    color: #000;
}

.rank-badge.rank-3 {
    background: linear-gradient(135deg, #cd7f32, #b8690b);
    color: #fff;
}

.badge-castle {
    background: var(--primary);
    color: var(--primary-foreground);
}

/* History list */
.history-list {
    max-height: 300px;
    overflow-y: auto;
}

.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-2) 0;
    border-bottom: 1px solid var(--border);
}

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

.history-time {
    font-size: 12px;
    color: var(--text-muted);
    min-width: 140px;
}

.history-guild {
    flex: 1;
    padding: 0 var(--space-2);
}

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

/* Empty owner state */
.empty-owner {
    text-align: center;
    padding: var(--space-4);
    background: var(--bg-muted);
    border-radius: var(--radius);
}

/* ============================================
   BATTLE STATISTICS
   ============================================ */

/* Rank badges */
.rank-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    font-size: 12px;
    font-weight: 600;
    background: var(--bg-muted);
    color: var(--text-secondary);
}

.rank-gold {
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    color: #1a1a2e;
}

.rank-silver {
    background: linear-gradient(135deg, #cbd5e1, #94a3b8);
    color: #1a1a2e;
}

.rank-bronze {
    background: linear-gradient(135deg, #d97706, #b45309);
    color: #fff;
}

/* Chart container */
.class-chart-container {
    padding: var(--space-4);
    min-height: 280px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Distribution bar */
.bar-container {
    position: relative;
    height: 22px;
    background: var(--bg-muted);
    border-radius: var(--radius);
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    background: #6366f1;
    border-radius: var(--radius);
    transition: width 0.4s ease;
}

.bar-fill-pvp {
    background: #ef4444;
}

.bar-label {
    position: absolute;
    top: 50%;
    left: 8px;
    transform: translateY(-50%);
    font-size: 11px;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
}

/* ============================================
   MAP VIEWER
   ============================================ */

.map-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: var(--space-4);
}

.map-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: border-color 0.15s, box-shadow 0.15s;
    overflow: hidden;
}

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

.map-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-3) var(--space-4);
    cursor: pointer;
    user-select: none;
    transition: background 0.15s;
}

.map-card-header:hover {
    background: var(--bg-muted);
}

.map-card-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    font-family: var(--font-mono);
}

.map-card-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 24px;
    padding: 0 8px;
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 600;
}

.map-card-players {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.25s ease;
    border-top: 0 solid var(--border);
}

.map-card-players.expanded {
    max-height: 600px;
    overflow-y: auto;
    border-top-width: 1px;
}

.map-player-list {
    padding: var(--space-2) var(--space-4) var(--space-3);
}

.map-player-item {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) 0;
    font-size: 13px;
    border-bottom: 1px solid var(--border);
}

.map-player-item:last-child {
    border-bottom: none;
}

.map-player-name {
    font-weight: 500;
    color: var(--text-primary);
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.map-player-job {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
}

.map-player-level {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
}

.map-player-coords {
    font-size: 11px;
    color: var(--text-muted);
    font-family: var(--font-mono);
    white-space: nowrap;
}

/* Heat coloring for map cards */
.map-heat-empty {
    border-left: 3px solid var(--text-muted);
}

.map-heat-empty .map-card-count {
    background: var(--bg-muted);
    color: var(--text-muted);
}

.map-heat-low {
    border-left: 3px solid #22c55e;
}

.map-heat-low .map-card-count {
    background: #d1fae5;
    color: #065f46;
}

.map-heat-medium {
    border-left: 3px solid #f59e0b;
}

.map-heat-medium .map-card-count {
    background: #fef3c7;
    color: #92400e;
}

.map-heat-high {
    border-left: 3px solid #ef4444;
}

.map-heat-high .map-card-count {
    background: #fee2e2;
    color: #991b1b;
}

.map-heat-critical {
    border-left: 3px solid #7c3aed;
}

.map-heat-critical .map-card-count {
    background: #ede9fe;
    color: #5b21b6;
}

/* Map toolbar */
.map-toolbar {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin-bottom: var(--space-4);
    flex-wrap: wrap;
}

.map-toolbar .form-input {
    max-width: 280px;
    height: 36px;
}

.map-toolbar select {
    height: 36px;
    min-width: 160px;
}

.map-stats-bar {
    display: flex;
    gap: var(--space-4);
    font-size: 13px;
    color: var(--text-secondary);
    margin-left: auto;
}

.map-stats-bar strong {
    color: var(--text-primary);
}

/* Map refresh indicator */
.map-refresh-indicator {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    font-size: 11px;
    color: var(--text-muted);
}

.map-refresh-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--success);
    animation: pulse 2s infinite;
}

/* Map expand/collapse chevron */
.map-card-chevron {
    width: 16px;
    height: 16px;
    color: var(--text-muted);
    transition: transform 0.2s ease;
    flex-shrink: 0;
    margin-left: var(--space-2);
}

.map-card-header.expanded .map-card-chevron {
    transform: rotate(180deg);
}

/* Popular maps bar chart */
.popular-map-row {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2) 0;
    border-bottom: 1px solid var(--border);
}

.popular-map-row:last-child {
    border-bottom: none;
}

.popular-map-rank {
    min-width: 28px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    text-align: center;
}

.popular-map-name {
    min-width: 140px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    font-family: var(--font-mono);
}

.popular-map-bar-container {
    flex: 1;
    height: 20px;
    background: var(--bg-muted);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.popular-map-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), #60a5fa);
    border-radius: var(--radius-sm);
    transition: width 0.3s ease;
    min-width: 2px;
}

.popular-map-count {
    min-width: 40px;
    text-align: right;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

@media (max-width: 767px) {
    .map-grid {
        grid-template-columns: 1fr;
    }

    .map-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .map-toolbar .form-input,
    .map-toolbar select {
        max-width: 100%;
    }

    .map-stats-bar {
        margin-left: 0;
    }
}

/* ============================================
   NPC SHOP BROWSER
   ============================================ */

/* NPC detail card uses same styles as other detail cards */

/* ============================================
   QUEST TRACKING
   ============================================ */

.quest-summary {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
}

.quest-badge {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 500;
}

.quest-badge-active {
    background: var(--warning-bg, #fff3cd);
    color: var(--warning-text, #856404);
}

.quest-badge-completed {
    background: var(--success-bg, #d4edda);
    color: var(--success-text, #155724);
}

.quest-state {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
}

.quest-state-active {
    background: #ffc107;
    color: #000;
}

.quest-state-complete {
    background: #28a745;
    color: #fff;
}

.quest-state-removed {
    background: #6c757d;
    color: #fff;
}

.quest-filter-btn.active {
    background: var(--primary, #4a90d9);
    color: #fff;
}


/* ============================================
   DATABASE BACKUPS
   ============================================ */

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

.backup-table th,
.backup-table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}

.backup-table th {
    font-weight: 600;
    color: var(--text-muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.backup-table tbody tr:hover {
    background: var(--bg-muted);
}

.backup-size {
    display: inline-block;
    padding: 2px 8px;
    background: var(--bg-muted);
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    font-family: var(--font-mono, monospace);
}

.backup-actions {
    display: flex;
    gap: var(--space-2);
    white-space: nowrap;
}

.backup-creating {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    background: var(--bg-muted);
    border-radius: var(--radius);
    color: var(--text-secondary);
    font-size: 14px;
    animation: backup-pulse 1.5s ease-in-out infinite;
}

@keyframes backup-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* ==================== Minimap Overlay ==================== */

.minimap-overlay {
    position: relative;
    display: inline-block;
}

.minimap-zoom-btn {
    width: 22px;
    height: 22px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg-secondary);
    color: var(--text);
    font-size: 12px;
    line-height: 20px;
    text-align: center;
    padding: 0;
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.15s;
    margin-left: auto;
    flex-shrink: 0;
}

.minimap-zoom-btn:hover {
    opacity: 1;
}

.minimap-dot {
    position: absolute;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    border: 1px solid rgba(255, 255, 255, 0.9);
    box-shadow: 0 0 2px rgba(0, 0, 0, 0.8);
    pointer-events: auto;
    cursor: help;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    z-index: 2;
}

/* Invisible padding ring for easier hover targeting */
.minimap-dot::before {
    content: '';
    position: absolute;
    top: -6px;
    left: -6px;
    right: -6px;
    bottom: -6px;
    border-radius: 50%;
}

.minimap-dot:hover {
    transform: translate(-50%, -50%) scale(2.5);
    box-shadow: 0 0 6px rgba(0, 0, 0, 0.9);
    z-index: 10;
}

/* Deconflicted dots have inline transform from JS (calc offsets) which
   overrides the stylesheet :hover transform — use separate scale property. */
.minimap-dot[data-deconflict-offset]:hover {
    scale: 2.5;
}

.minimap-dot-highlight {
    z-index: 9;
    animation: minimap-ping 0.8s ease-out 3;
}

@keyframes minimap-ping {
    0% { box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.9); }
    100% { box-shadow: 0 0 0 10px rgba(255, 255, 255, 0); }
}

.minimap-dot-random {
    animation: minimap-shake 2s ease-in-out infinite;
}

@keyframes minimap-shake {
    0%, 100% { translate: -50% -50%; }
    20% { translate: calc(-50% + 2px) calc(-50% - 1px); }
    40% { translate: calc(-50% - 2px) calc(-50% + 1px); }
    60% { translate: calc(-50% + 1px) calc(-50% + 2px); }
    80% { translate: calc(-50% - 1px) calc(-50% - 2px); }
}

.minimap-dot-shop {
    cursor: pointer;
}

.minimap-tip {
    position: fixed;
    transform: translate(-50%, -100%);
    background: rgba(0, 0, 0, 0.85);
    color: #fff;
    font-size: 11px;
    padding: 3px 8px;
    border-radius: 4px;
    white-space: nowrap;
    pointer-events: none;
    z-index: 9999;
}

/* Rich tooltip for spawn/MVP dots */
.minimap-tip.minimap-tip-rich {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    white-space: normal;
    border-radius: 6px;
    backdrop-filter: blur(4px);
}

.minimap-tip-rich img {
    flex-shrink: 0;
}

.minimap-tip-info {
    min-width: 0;
}

.minimap-tip-name {
    font-weight: 600;
    font-size: 12px;
    line-height: 1.3;
}

.minimap-tip-dbname {
    font-size: 9px;
    color: rgba(255, 255, 255, 0.4);
    font-family: monospace;
}

.minimap-tip-stats {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.8);
    margin-top: 2px;
}

.minimap-tip-props {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.55);
    margin-top: 1px;
}

.minimap-tip-exp {
    font-size: 9px;
    color: rgba(255, 255, 255, 0.4);
    margin-top: 1px;
}

.mvp-badge {
    color: #f39c12;
    font-size: 10px;
    font-weight: 700;
    margin-left: 4px;
}

.minimap-dot-npc {
    width: 1.95%;
    height: 1.95%;
    background: #4a90d9;
}

.minimap-dot-shop {
    width: 1.95%;
    height: 1.95%;
    background: #2ecc71;
}

.minimap-dot-spawn {
    width: 1.95%;
    height: 1.95%;
    background: #1abc9c;
    opacity: 0.7;
}

.minimap-dot-boss {
    width: 1.95%;
    height: 1.95%;
    background: #f39c12;
    opacity: 1;
}

.minimap-legend {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
    font-size: 11px;
    color: var(--text-secondary);
}

.minimap-legend label {
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

.minimap-legend input[type="checkbox"] {
    width: 14px;
    height: 14px;
    min-width: 14px;
    flex-shrink: 0;
    margin: 0;
}

.minimap-legend-dot {
    display: inline-block;
    width: 12px;
    height: 12px;
    min-width: 12px;
    border-radius: 50%;
    border: 1px solid rgba(0, 0, 0, 0.2);
}

.minimap-legend-dot-npc { background: #4a90d9; }
.minimap-legend-dot-shop { background: #2ecc71; }
.minimap-legend-dot-spawn { background: #1abc9c; }
.minimap-legend-dot-boss { background: #f39c12; }
.minimap-legend-dot-warp { background: #fc0404; }

.minimap-dot-warp {
    /* Match the 10px/512px red dots baked into minimap PNGs */
    width: 1.95%;
    height: 1.95%;
    background: #fc0404;
    cursor: pointer;
}

/* NPC list fallback icon for missing sprites */
.npc-icon-fallback {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--border);
    margin: 4px;
    vertical-align: middle;
}
