/* ============================================================
   UStyle QC Dashboard - Dark Mode Stylesheet
   ============================================================ */

/* --- Custom Properties --- */
:root {
    --color-bg: #0d1117;
    --color-surface: #161b22;
    --color-surface-raised: #1c2129;
    --color-border: #30363d;
    --color-border-light: #21262d;
    --color-text-primary: #e6edf3;
    --color-text-secondary: #8b949e;
    --color-text-muted: #6e7681;
    --color-accent: #58a6ff;
    --color-accent-hover: #79c0ff;
    --color-accent-muted: rgba(56, 139, 253, 0.15);
    --color-success: #3fb950;
    --color-success-muted: rgba(63, 185, 80, 0.15);
    --color-warning: #d29922;
    --color-warning-muted: rgba(210, 153, 34, 0.15);
    --color-error: #f85149;
    --color-error-muted: rgba(248, 81, 73, 0.15);
    --color-info: #58a6ff;
    --color-info-muted: rgba(56, 139, 253, 0.15);
    --color-purple: #bc8cff;
    --color-purple-muted: rgba(188, 140, 255, 0.15);

    --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Noto Sans, Helvetica, Arial, sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;

    --sidebar-width: 240px;
    --topbar-height: 60px;
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- Reset & Base --- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-sans);
    background-color: var(--color-bg);
    color: var(--color-text-primary);
    line-height: 1.5;
    min-height: 100vh;
}

a {
    color: var(--color-accent);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover { color: var(--color-accent-hover); }

/* --- Page Loader --- */
.page-loader {
    position: fixed;
    inset: 0;
    background: var(--color-bg);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.4s ease, visibility 0.4s ease;
}

.page-loader.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.page-loader-inner {
    position: relative;
    width: 64px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.page-loader-logo {
    width: 36px;
    height: 36px;
    object-fit: contain;
    filter: brightness(1.8);
    animation: loaderPulse 1.8s ease-in-out infinite;
}

.page-loader-ring {
    position: absolute;
    inset: 0;
    border: 2px solid var(--color-border);
    border-top-color: var(--color-accent);
    border-radius: 50%;
    animation: loaderSpin 1s linear infinite;
}

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

@keyframes loaderPulse {
    0%, 100% { opacity: 0.6; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.08); }
}

img { max-width: 100%; display: block; }

/* --- Sidebar --- */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background-color: var(--color-surface);
    border-right: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform var(--transition-base);
}

.sidebar-header {
    padding: 20px 16px 16px;
    border-bottom: 1px solid var(--color-border);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-icon {
    width: 28px;
    height: 28px;
    color: var(--color-accent);
    flex-shrink: 0;
}

.logo-text {
    font-size: 16px;
    font-weight: 600;
    color: var(--color-text-primary);
    letter-spacing: -0.01em;
}

.sidebar-nav {
    flex: 1;
    padding: 12px 8px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-md);
    color: var(--color-text-secondary);
    font-size: 14px;
    font-weight: 500;
    transition: all var(--transition-fast);
    cursor: pointer;
}

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

.nav-item.active {
    color: var(--color-text-primary);
    background-color: var(--color-accent-muted);
}

.nav-item.active .nav-icon { color: var(--color-accent); }

.nav-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.sidebar-footer {
    padding: 12px 8px;
    border-top: 1px solid var(--color-border);
}

.sidebar-user-info {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    margin-bottom: 4px;
}

.sidebar-user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--color-accent-muted);
    color: var(--color-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    flex-shrink: 0;
}

.sidebar-user-details {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

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

.sidebar-user-role {
    font-size: 10px;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

body.sidebar-collapsed .sidebar-user-info .sidebar-user-details { display: none; }
body.sidebar-collapsed .sidebar-user-info { justify-content: center; padding: 8px 4px; }

.nav-logout { color: var(--color-text-muted); }

.nav-logout:hover {
    color: var(--color-error);
    background-color: var(--color-error-muted);
}

/* --- Nav Section Labels & Collapsible Toggles --- */
.nav-section-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-text-muted);
    padding: 0;
    pointer-events: none;
}

.nav-section-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    background: none;
    border: none;
    padding: 10px 12px 4px;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: background var(--transition-fast);
}

.nav-section-toggle:first-child { padding-top: 4px; }

.nav-section-toggle:hover { background: var(--color-surface-raised); }

.nav-section-chevron {
    width: 14px;
    height: 14px;
    color: var(--color-text-muted);
    transition: transform var(--transition-base);
    flex-shrink: 0;
}

.nav-section-toggle[aria-expanded="false"] .nav-section-chevron {
    transform: rotate(-90deg);
}

.nav-section-items {
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow: hidden;
    transition: max-height var(--transition-base), opacity var(--transition-fast);
    max-height: 500px;
    opacity: 1;
}

.nav-section-items.collapsed {
    max-height: 0;
    opacity: 0;
    pointer-events: none;
}

/* --- Sidebar Collapse --- */
.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sidebar-collapse-btn {
    background: none;
    border: none;
    color: var(--color-text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
}

.sidebar-collapse-btn svg {
    width: 16px;
    height: 16px;
    transition: transform var(--transition-base);
}

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

body.sidebar-collapsed .sidebar {
    width: 56px;
}

body.sidebar-collapsed .sidebar .logo-text,
body.sidebar-collapsed .sidebar .nav-item span,
body.sidebar-collapsed .sidebar .nav-section-label {
    display: none;
}

body.sidebar-collapsed .sidebar .sidebar-header {
    padding: 16px 8px;
    justify-content: center;
}

body.sidebar-collapsed .sidebar .sidebar-collapse-btn svg {
    transform: rotate(180deg);
}

body.sidebar-collapsed .sidebar .nav-item {
    justify-content: center;
    padding: 10px;
}

body.sidebar-collapsed .main-wrapper {
    margin-left: 56px;
}

body.sidebar-collapsed .dashboard-main {
    margin-left: 56px;
}

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

/* --- Main Layout --- */
.main-wrapper {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* --- Top Bar --- */
.topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    height: var(--topbar-height);
    background-color: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 16px;
    backdrop-filter: blur(8px);
    background-color: rgba(22, 27, 34, 0.85);
}

.topbar-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--color-text-primary);
    white-space: nowrap;
}

.topbar-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 12px;
}

.hamburger {
    display: none;
    background: none;
    border: none;
    color: var(--color-text-secondary);
    cursor: pointer;
    padding: 4px;
    border-radius: var(--radius-sm);
    transition: color var(--transition-fast);
}

.hamburger:hover { color: var(--color-text-primary); }
.hamburger svg { width: 22px; height: 22px; }

/* --- Main Content --- */
.main-content {
    padding: 24px;
    padding-bottom: 48px;
    flex: 1;
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    font-size: 13px;
    font-weight: 500;
    font-family: var(--font-sans);
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
    text-decoration: none;
    line-height: 1.4;
}

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

.btn-primary {
    background-color: var(--color-accent);
    color: #fff;
    border-color: var(--color-accent);
}

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

.btn-secondary {
    background-color: var(--color-surface-raised);
    color: var(--color-text-primary);
    border-color: var(--color-border);
}

.btn-secondary:hover {
    background-color: var(--color-surface);
    border-color: var(--color-text-muted);
}

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

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

.btn-danger {
    background-color: var(--color-error);
    color: #fff;
    border-color: var(--color-error);
}

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

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

.btn-success:hover {
    background-color: #2ea043;
    border-color: #2ea043;
}

.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* --- Forms --- */
.form-group { margin-bottom: 16px; }

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text-primary);
    margin-bottom: 6px;
}

.form-input {
    width: 100%;
    background-color: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 10px 12px;
    color: var(--color-text-primary);
    font-size: 14px;
    font-family: var(--font-sans);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

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

.form-input:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px var(--color-accent-muted);
}

.form-select {
    background-color: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 6px 30px 6px 10px;
    color: var(--color-text-primary);
    font-size: 12px;
    font-family: var(--font-sans);
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238b949e' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

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

.input-wrapper { position: relative; }
.input-wrapper .form-input { padding-left: 40px; }

.input-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: var(--color-text-muted);
    pointer-events: none;
}

/* --- Search --- */
.search-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: 10px;
    width: 16px;
    height: 16px;
    color: var(--color-text-muted);
    pointer-events: none;
}

.search-input {
    background-color: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 6px 12px 6px 34px;
    color: var(--color-text-primary);
    font-size: 13px;
    font-family: var(--font-sans);
    width: 200px;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

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

.search-input:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px var(--color-accent-muted);
}

/* --- Badges --- */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.badge-success { background-color: var(--color-success-muted); color: var(--color-success); }
.badge-warning { background-color: var(--color-warning-muted); color: var(--color-warning); }
.badge-error { background-color: var(--color-error-muted); color: var(--color-error); }
.badge-info { background-color: var(--color-info-muted); color: var(--color-info); }
.badge-secondary { background-color: rgba(139, 148, 158, 0.15); color: var(--color-text-secondary); }

/* --- Toggle Buttons --- */
.toggle-btn {
    padding: 5px 12px;
    font-size: 12px;
    font-family: var(--font-sans);
    font-weight: 500;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    color: var(--color-text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
    border-radius: var(--radius-md);
}

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

.toggle-btn.active {
    background-color: var(--color-accent-muted);
    color: var(--color-accent);
    border-color: var(--color-accent);
}

/* --- Login Page --- */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background-color: var(--color-bg);
}

.login-wrapper {
    width: 100%;
    max-width: 400px;
    padding: 24px;
}

.login-card {
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xl);
    padding: 32px;
}

.login-header {
    text-align: center;
    margin-bottom: 28px;
}

.login-logo {
    width: 48px;
    height: 48px;
    color: var(--color-accent);
    margin: 0 auto 16px;
}

.login-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--color-text-primary);
    margin-bottom: 4px;
}

.login-subtitle {
    font-size: 14px;
    color: var(--color-text-secondary);
}

.login-divider {
    text-align: center;
    margin: 16px 0 8px;
    position: relative;
}

.login-divider::before {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    height: 1px;
    background: var(--color-border);
}

.login-divider span {
    background: var(--color-surface);
    padding: 0 12px;
    position: relative;
    font-size: 12px;
    color: var(--color-text-muted);
}

.login-error {
    background-color: var(--color-error-muted);
    border: 1px solid rgba(248, 81, 73, 0.3);
    color: var(--color-error);
    padding: 10px 14px;
    border-radius: var(--radius-md);
    font-size: 13px;
    margin-bottom: 16px;
}

.login-form .btn-block {
    margin-top: 8px;
    padding: 12px;
    font-size: 14px;
    font-weight: 600;
}

.login-footer-text {
    text-align: center;
    margin-top: 24px;
    font-size: 12px;
    color: var(--color-text-muted);
}

/* ============================================================
   Gallery Page Styles
   ============================================================ */

/* --- Gallery Controls (topbar) --- */
.gallery-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

.gallery-stats {
    display: flex;
    gap: 16px;
    margin-left: 8px;
}

.gallery-stat {
    text-align: center;
}

.gallery-stat-value {
    font-size: 18px;
    font-weight: 700;
    line-height: 1.1;
}

.gallery-stat-label {
    font-size: 10px;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* --- Gallery Filter Bar --- */
.gallery-filter-bar {
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 14px 16px;
    margin-bottom: 20px;
}

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

.filter-group-inline {
    display: flex;
    gap: 4px;
    align-items: center;
}

.filter-actions {
    margin-left: auto;
    display: flex;
    gap: 6px;
}

/* --- Batch Regeneration --- */
.batch-regen-section {
    margin-top: 14px;
    padding: 14px;
    background-color: var(--color-bg);
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border-light);
}

.batch-regen-header {
    font-weight: 600;
    font-size: 13px;
    color: var(--color-accent);
    margin-bottom: 10px;
}

.batch-feedback {
    resize: vertical;
    min-height: 50px;
    font-size: 13px;
}

.batch-regen-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

.job-status { margin-top: 12px; }

.job-status-text {
    font-size: 12px;
    color: var(--color-text-secondary);
    margin-bottom: 6px;
}

.progress-bar-track {
    background-color: var(--color-surface);
    border-radius: var(--radius-sm);
    overflow: hidden;
    height: 6px;
}

.progress-bar-fill {
    height: 100%;
    background-color: var(--color-accent);
    transition: width 0.3s ease;
}

.job-details {
    font-size: 11px;
    color: var(--color-text-muted);
    margin-top: 4px;
}

/* --- Gallery Placeholder --- */
.gallery-placeholder {
    text-align: center;
    padding: 80px 20px;
    color: var(--color-text-muted);
    font-size: 15px;
}

/* --- Try-on Card Grid --- */
.tryon-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
    gap: 20px;
}

.tryon-card {
    background-color: var(--color-surface);
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 1px solid var(--color-border);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.tryon-card:hover {
    border-color: var(--color-border-light);
    box-shadow: var(--shadow-md);
}

.tryon-card.selected {
    border-color: var(--color-accent);
    box-shadow: 0 0 0 2px var(--color-accent-muted);
}

.tryon-header {
    padding: 12px 16px;
    background-color: var(--color-surface-raised);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.tryon-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.tryon-title {
    font-weight: 600;
    font-size: 13px;
    color: var(--color-text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tryon-variant-id {
    font-size: 11px;
    color: var(--color-accent);
    font-family: var(--font-mono);
}

.outfit-checkbox {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--color-accent);
    flex-shrink: 0;
}

/* --- Status Badges --- */
.status-badge {
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.status-passed { background-color: var(--color-success-muted); color: var(--color-success); }
.status-failed { background-color: var(--color-error-muted); color: var(--color-error); }
.status-pending_evaluation,
.status-pending_eval { background-color: var(--color-warning-muted); color: var(--color-warning); }
.status-pending_regeneration { background-color: var(--color-purple-muted); color: var(--color-purple); }
.status-fixe { background-color: rgba(124, 45, 18, 0.4); color: #fed7aa; }
.status-trash { background-color: rgba(139, 148, 158, 0.15); color: var(--color-text-muted); }
.status-whole_item_trash { background-color: rgba(153, 27, 27, 0.3); color: #fecaca; }
.status-needs_regeneration { background-color: var(--color-info-muted); color: var(--color-info); }

/* --- Tryon Images Section --- */
.tryon-images {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1px;
    background-color: var(--color-border-light);
}

.main-tryon {
    grid-column: 1 / -1;
    display: flex;
    justify-content: center;
    padding: 16px;
    background-color: var(--color-bg);
}

.tryon-image-wrapper {
    position: relative;
    display: inline-block;
}

.tryon-image-wrapper img {
    max-width: 100%;
    max-height: 400px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: opacity var(--transition-fast);
}

.tryon-image-wrapper img:hover { opacity: 0.9; }

.reload-btn-overlay {
    position: absolute;
    top: 8px;
    right: 8px;
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.tryon-image-wrapper:hover .reload-btn-overlay { opacity: 1; }

.image-section {
    background-color: var(--color-bg);
    padding: 12px;
}

.section-label {
    font-size: 10px;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 8px;
    font-weight: 600;
}

.product-images {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.product-images img {
    width: 55px;
    height: 70px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    cursor: pointer;
    border: 2px solid transparent;
    transition: border-color var(--transition-fast);
}

.product-images img:hover { border-color: var(--color-accent); }

.product-meta {
    margin-top: 6px;
    font-size: 11px;
    color: var(--color-text-muted);
}

/* --- Outfit Items --- */
.outfit-items {
    padding: 12px 16px;
    border-top: 1px solid var(--color-border-light);
}

.outfit-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 0;
    border-bottom: 1px solid var(--color-border-light);
}

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

.outfit-item-images {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.outfit-item-images img {
    width: 36px;
    height: 46px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    cursor: pointer;
}

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

.outfit-item-title {
    font-size: 12px;
    color: var(--color-text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.outfit-item-meta {
    font-size: 11px;
    color: var(--color-text-muted);
}

/* --- Evaluation Info --- */
.eval-info {
    padding: 8px 16px;
    background-color: var(--color-surface-raised);
    font-size: 12px;
}

.eval-issues { color: var(--color-error); }

/* --- Feedback Section --- */
.feedback-section {
    padding: 12px 16px;
    border-top: 1px solid var(--color-border-light);
}

.feedback-input {
    width: 100%;
    padding: 8px 10px;
    background-color: var(--color-bg);
    border: 1px solid var(--color-border);
    color: var(--color-text-primary);
    border-radius: var(--radius-md);
    font-size: 12px;
    font-family: var(--font-sans);
    resize: vertical;
    min-height: 50px;
    transition: border-color var(--transition-fast);
}

.feedback-input:focus {
    outline: none;
    border-color: var(--color-accent);
}

.feedback-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    flex-wrap: wrap;
}

/* --- Image Modal --- */
.image-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.image-modal.active {
    display: flex;
}

.image-modal img {
    max-width: 90vw;
    max-height: 90vh;
    border-radius: var(--radius-md);
}

.image-modal-close {
    position: absolute;
    top: 20px;
    right: 30px;
    font-size: 32px;
    color: #fff;
    cursor: pointer;
    background: none;
    border: none;
    line-height: 1;
    transition: opacity var(--transition-fast);
}

.image-modal-close:hover { opacity: 0.7; }

/* --- Empty State --- */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 20px;
    text-align: center;
}

.empty-state-icon {
    width: 64px;
    height: 64px;
    color: var(--color-text-muted);
    margin-bottom: 20px;
}

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

.empty-state-text {
    font-size: 14px;
    color: var(--color-text-secondary);
    max-width: 400px;
}

/* --- Date Badge --- */
.date-badge {
    font-size: 10px;
    color: var(--color-text-muted);
    font-family: var(--font-mono);
    white-space: nowrap;
}

.date-badge.recent {
    color: var(--color-success);
    font-weight: 600;
}

.tryon-card.recent-card {
    border-color: rgba(63, 185, 80, 0.3);
}

/* --- Spinner Overlay --- */
.spinner-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: none;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    border-radius: var(--radius-md);
    z-index: 10;
}

.spinner-overlay.active { display: flex; }

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--color-border);
    border-top-color: var(--color-accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.spinner-text {
    color: #fff;
    margin-top: 8px;
    font-size: 12px;
}

/* --- Reload Prompt --- */
.reload-prompt {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    border-radius: var(--radius-md);
    z-index: 10;
}

.reload-prompt.active { display: flex; }

.reload-prompt-text {
    color: var(--color-success);
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 10px;
}

/* --- Action Button Variants --- */
.btn-warning {
    background-color: var(--color-warning);
    color: #fff;
    border-color: var(--color-warning);
}

.btn-warning:hover {
    background-color: #b8860b;
    border-color: #b8860b;
}

.btn-fixe {
    background-color: #7c2d12;
    color: #fed7aa;
    border-color: #7c2d12;
}

.btn-fixe:hover {
    background-color: #9a3412;
    border-color: #9a3412;
}

.btn-trash {
    background-color: #4c1d95;
    color: #c4b5fd;
    border-color: #4c1d95;
}

.btn-trash:hover {
    background-color: #5b21b6;
    border-color: #5b21b6;
}

.btn-whole-trash {
    background-color: #991b1b;
    color: #fecaca;
    border-color: #991b1b;
}

.btn-whole-trash:hover {
    background-color: #b91c1c;
    border-color: #b91c1c;
}

/* --- Notification Toast --- */
.notification-toast {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 12px 18px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 10000;
    font-size: 13px;
    color: #fff;
    max-width: 350px;
    transition: opacity 0.3s ease;
}

.notification-toast.success { background-color: var(--color-success); }
.notification-toast.error { background-color: var(--color-error); }
.notification-toast.info { background-color: var(--color-accent); }

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

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

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

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

    .main-wrapper {
        margin-left: 0;
    }

    .hamburger {
        display: block;
    }

    .topbar-actions {
        gap: 8px;
    }

    .gallery-controls {
        flex-wrap: wrap;
        gap: 8px;
    }

    .gallery-stats {
        display: none;
    }

    .main-content {
        padding: 16px;
    }

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

    .filter-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .filter-actions {
        margin-left: 0;
    }
}

/* ============================================================
   Bot Analytics Styles (from Dashboard)
   ============================================================ */
/* --- Section --- */
.section {
    margin-bottom: 32px;
}

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

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

/* --- Stat Cards --- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
}

.stat-card {
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 20px;
    display: flex;
    align-items: flex-start;
    gap: 16px;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

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

.stat-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

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

.stat-icon-shops {
    background-color: var(--color-accent-muted);
    color: var(--color-accent);
}

.stat-icon-users {
    background-color: var(--color-success-muted);
    color: var(--color-success);
}

.stat-icon-conversations {
    background-color: var(--color-warning-muted);
    color: var(--color-warning);
}

.stat-icon-images {
    background-color: rgba(188, 140, 255, 0.15);
    color: #bc8cff;
}

.stat-content {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.stat-number {
    font-size: 28px;
    font-weight: 700;
    line-height: 1.1;
    letter-spacing: -0.02em;
    color: var(--color-text-primary);
}

.stat-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--color-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* --- Activity List --- */
.activity-list {
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.activity-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--color-border-light);
    transition: background-color var(--transition-fast);
}

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

.activity-item:hover {
    background-color: var(--color-surface-raised);
}

.activity-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-top: 6px;
    flex-shrink: 0;
}

.activity-dot-message {
    background-color: var(--color-accent);
}

.activity-dot-image {
    background-color: #bc8cff;
}

.activity-body {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-width: 0;
}

.activity-text {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--color-text-primary);
    min-width: 0;
}

.activity-summary {
    color: var(--color-text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.activity-time {
    font-size: 12px;
    color: var(--color-text-muted);
    white-space: nowrap;
    flex-shrink: 0;
}

/* --- Tables --- */
.table-container {
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    overflow-x: auto;
}

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

.table thead th {
    padding: 12px 16px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-text-secondary);
    text-align: left;
    border-bottom: 1px solid var(--color-border);
    white-space: nowrap;
    background-color: var(--color-surface);
    position: sticky;
    top: 0;
}

.table tbody tr {
    border-bottom: 1px solid var(--color-border-light);
    transition: background-color var(--transition-fast);
}

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

.table tbody tr:nth-child(even) {
    background-color: rgba(22, 27, 34, 0.3);
}

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

.table td {
    padding: 12px 16px;
    font-size: 13px;
    color: var(--color-text-primary);
    vertical-align: middle;
}

.table-row-clickable {
    cursor: pointer;
}

.text-right {
    text-align: right;
}

/* --- Style Detail Row --- */
.style-detail-row {
    display: none;
}

.style-detail-row.open {
    display: table-row;
}

.style-detail-row td {
    padding: 0 16px 16px;
    background-color: var(--color-surface-raised);
}

.style-profile {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    padding: 12px;
    border-radius: var(--radius-md);
    background-color: var(--color-bg);
    border: 1px solid var(--color-border-light);
}

.style-tag {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.style-tag-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-text-muted);
}

.style-tag-value {
    font-size: 13px;
    color: var(--color-text-primary);
}

.icon-chevron {
    width: 14px;
    height: 14px;
    transition: transform var(--transition-fast);
}

.style-toggle.open .icon-chevron {
    transform: rotate(180deg);
}

/* --- Search --- */
.search-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: 10px;
    width: 16px;
    height: 16px;
    color: var(--color-text-muted);
    pointer-events: none;
}

.search-input {
    background-color: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 8px 12px 8px 34px;
    color: var(--color-text-primary);
    font-size: 13px;
    font-family: var(--font-sans);
    width: 220px;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

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

.search-input:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px var(--color-accent-muted);
}

/* --- Badges --- */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

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

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

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

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

.badge-secondary {
    background-color: rgba(139, 148, 158, 0.15);
    color: var(--color-text-secondary);
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    font-size: 13px;
    font-weight: 500;
    font-family: var(--font-sans);
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
    text-decoration: none;
    line-height: 1.4;
}

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

.btn-primary {
    background-color: var(--color-accent);
    color: #fff;
    border-color: var(--color-accent);
}

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

.btn-secondary {
    background-color: var(--color-surface-raised);
    color: var(--color-text-primary);
    border-color: var(--color-border);
}

.btn-secondary:hover {
    background-color: var(--color-surface);
    border-color: var(--color-text-muted);
}

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

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

.btn-danger {
    background-color: var(--color-error);
    color: #fff;
    border-color: var(--color-error);
}

.btn-danger:hover {
    background-color: #da3633;
    border-color: #da3633;
    color: #fff;
}

.btn-sm {
    padding: 5px 12px;
    font-size: 12px;
}

.btn-xs {
    padding: 2px 6px;
    font-size: 11px;
}

.btn-block {
    width: 100%;
}

.btn-icon-left {
    width: 14px;
    height: 14px;
}

.btn-icon-right {
    width: 14px;
    height: 14px;
}

/* --- Forms --- */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text-primary);
    margin-bottom: 6px;
}

.form-input {
    width: 100%;
    background-color: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 10px 12px;
    color: var(--color-text-primary);
    font-size: 14px;
    font-family: var(--font-sans);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

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

.form-input:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px var(--color-accent-muted);
}

.form-input-date,
input[type="date"] {
    width: auto;
    padding: 6px 10px;
    font-size: 12px;
    color-scheme: dark;
    cursor: pointer;
}

input[type="date"]::-webkit-calendar-picker-indicator {
    filter: invert(0.7);
    cursor: pointer;
}

.note-date-input {
    color-scheme: dark;
    min-width: 130px;
    cursor: pointer;
}

.form-select {
    background-color: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 6px 30px 6px 10px;
    color: var(--color-text-primary);
    font-size: 12px;
    font-family: var(--font-sans);
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238b949e' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

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

.input-wrapper {
    position: relative;
}

.input-wrapper .form-input {
    padding-left: 40px;
}

.input-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: var(--color-text-muted);
    pointer-events: none;
}

/* --- Code --- */
.code-inline {
    font-family: var(--font-mono);
    font-size: 12px;
    background-color: var(--color-bg);
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    color: var(--color-text-secondary);
}

/* --- Breadcrumb --- */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 20px;
    font-size: 13px;
}

.breadcrumb-link {
    color: var(--color-text-secondary);
}

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

.breadcrumb-sep {
    width: 14px;
    height: 14px;
    color: var(--color-text-muted);
}

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

/* --- Conversation --- */
.conversation-header {
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 16px 20px;
    margin-bottom: 20px;
}

.conversation-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 24px;
}

.meta-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.meta-label {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-text-muted);
}

/* --- Chat --- */
/* ── Telegram-style Conversation View ── */
.chat-container {
    background: linear-gradient(180deg, #0e1621 0%, #17212b 100%);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.chat-load-more {
    display: flex;
    justify-content: center;
    padding: 12px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

.chat-messages {
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 75vh;
    overflow-y: auto;
}

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

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

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

.chat-bubble {
    max-width: 75%;
    display: flex;
    flex-direction: column;
    gap: 2px;
    position: relative;
}

.chat-bubble-user {
    align-self: flex-end;
}

.chat-bubble-assistant {
    align-self: flex-start;
}

.chat-bubble-content {
    padding: 8px 12px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.chat-bubble-user .chat-bubble-content {
    background-color: #2b5278;
    color: #e1e8ef;
    border-top-right-radius: 12px;
    border-top-left-radius: 12px;
    border-bottom-left-radius: 12px;
    border-bottom-right-radius: 4px;
}

.chat-bubble-assistant .chat-bubble-content {
    background-color: #182533;
    color: #e1e8ef;
    border: 1px solid rgba(255,255,255,0.06);
    border-top-right-radius: 12px;
    border-top-left-radius: 12px;
    border-bottom-right-radius: 12px;
    border-bottom-left-radius: 4px;
}

.chat-bubble-assistant .chat-bubble-content::before {
    content: "🤖 Assistant";
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: #6ab3f3;
    margin-bottom: 4px;
}

.chat-timestamp {
    font-size: 10px;
    color: rgba(255,255,255,0.35);
    padding: 0 6px;
    margin-top: 1px;
}

.chat-bubble-user .chat-timestamp {
    align-self: flex-end;
}

.chat-bubble-assistant .chat-timestamp {
    align-self: flex-start;
}

.chat-images {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 6px;
}

.chat-image {
    max-width: 240px;
    max-height: 320px;
    border-radius: 8px;
    cursor: pointer;
    transition: opacity 0.15s ease;
    object-fit: cover;
}

.chat-image:hover {
    opacity: 0.85;
}

.chat-image-missing {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    max-width: 240px;
    min-width: 120px;
    height: 80px;
    border-radius: 8px;
    background: #1e1e2e;
    border: 1px dashed #444;
    color: #666;
    font-size: 11px;
    padding: 8px 12px;
    text-align: center;
}

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

/* --- Filter Bar --- */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 16px;
    padding: 16px 20px;
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    margin-bottom: 20px;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.filter-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-text-muted);
}

.filter-apply {
    margin-left: auto;
}

.toggle-group {
    display: flex;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.toggle-btn {
    padding: 5px 12px;
    font-size: 12px;
    font-family: var(--font-sans);
    font-weight: 500;
    background: transparent;
    border: none;
    color: var(--color-text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
    border-right: 1px solid var(--color-border);
}

.toggle-btn:last-child {
    border-right: none;
}

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

.toggle-btn.active {
    background-color: var(--color-accent-muted);
    color: var(--color-accent);
}

/* --- Image Grid --- */
.image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 16px;
}

.image-card {
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.image-card:hover {
    border-color: var(--color-border-light);
    box-shadow: var(--shadow-md);
}

.image-card-visuals {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    border-bottom: 1px solid var(--color-border-light);
}

.image-input {
    flex-shrink: 0;
}

.img-thumb {
    width: 150px;
    height: 150px;
    object-fit: cover;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: opacity var(--transition-fast);
}

.img-thumb:hover {
    opacity: 0.85;
}

.img-thumb-sm {
    width: 100px;
    height: 100px;
    object-fit: cover;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: opacity var(--transition-fast);
}

.img-thumb-sm:hover {
    opacity: 0.85;
}

.img-placeholder {
    width: 150px;
    height: 150px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background-color: var(--color-bg);
    border: 1px dashed var(--color-border);
    border-radius: var(--radius-md);
    color: var(--color-text-muted);
    font-size: 11px;
}

.img-placeholder svg {
    width: 24px;
    height: 24px;
}

.img-placeholder-sm {
    width: 100px;
    height: 100px;
}

.image-arrow {
    flex-shrink: 0;
    color: var(--color-text-muted);
}

.image-arrow svg {
    width: 20px;
    height: 20px;
}

.image-outputs {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.image-card-info {
    padding: 12px 16px;
}

.image-instruction {
    font-size: 12px;
    color: var(--color-text-secondary);
    margin-bottom: 10px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.image-card-footer {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

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

/* --- Modal --- */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    z-index: 200;
    align-items: center;
    justify-content: center;
    padding: 40px;
    cursor: pointer;
    backdrop-filter: blur(4px);
}

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

.modal-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    cursor: default;
}

.modal-image {
    max-width: 100%;
    max-height: 85vh;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
}

.modal-close {
    position: absolute;
    top: -40px;
    right: 0;
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    opacity: 0.8;
    transition: opacity var(--transition-fast);
    padding: 4px;
}

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

.modal-close svg {
    width: 24px;
    height: 24px;
}

/* --- Empty State --- */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 24px;
    text-align: center;
}

.empty-icon {
    width: 48px;
    height: 48px;
    color: var(--color-text-muted);
    margin-bottom: 16px;
}

.empty-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--color-text-primary);
    margin-bottom: 4px;
}

.empty-text {
    font-size: 13px;
    color: var(--color-text-secondary);
    max-width: 360px;
}

/* --- Copyable --- */
.copyable {
    cursor: pointer;
    position: relative;
}

.copyable:hover {
    text-decoration: underline;
    text-decoration-style: dotted;
    text-underline-offset: 3px;
}

.copy-tooltip {
    position: absolute;
    top: -28px;
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--color-text-primary);
    color: var(--color-bg);
    padding: 3px 8px;
    border-radius: var(--radius-sm);
    font-size: 11px;
    font-weight: 500;
    white-space: nowrap;
    pointer-events: none;
    animation: tooltipFade 1.5s ease-out forwards;
    z-index: 10;
}

@keyframes tooltipFade {
    0% { opacity: 1; transform: translateX(-50%) translateY(0); }
    70% { opacity: 1; }
    100% { opacity: 0; transform: translateX(-50%) translateY(-6px); }
}

/* --- Loading Spinner --- */
.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--color-border);
    border-top-color: var(--color-accent);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

.spinner-lg {
    width: 32px;
    height: 32px;
    border-width: 3px;
}

/* --- Counts --- */
.msg-count {
    font-weight: 600;
    font-size: 13px;
    color: var(--color-text-primary);
}

.user-count {
    font-weight: 600;
}

/* --- Login Page --- */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 24px;
}

.login-wrapper {
    width: 100%;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.login-card {
    width: 100%;
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xl);
    padding: 32px;
    box-shadow: var(--shadow-lg);
}

.login-header {
    text-align: center;
    margin-bottom: 28px;
}

.login-logo {
    width: 40px;
    height: 40px;
    color: var(--color-accent);
    margin: 0 auto 12px;
}

.login-title {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 4px;
}

.login-subtitle {
    font-size: 13px;
    color: var(--color-text-secondary);
}

.login-form .btn-primary {
    margin-top: 8px;
    padding: 10px 16px;
    font-size: 14px;
}

.login-flash-container {
    margin-bottom: 16px;
}

.login-flash {
    padding: 10px 14px;
    border-radius: var(--radius-md);
    font-size: 13px;
    border: 1px solid;
    margin-bottom: 8px;
}

.login-flash-error,
.login-flash-danger {
    background-color: var(--color-error-muted);
    border-color: rgba(248, 81, 73, 0.3);
    color: var(--color-error);
}

.login-footer-text {
    margin-top: 24px;
    font-size: 12px;
    color: var(--color-text-muted);
}

/* --- Card List (Mobile) --- */
.card-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.shop-card,
.user-card {
    display: block;
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 14px 16px;
    text-decoration: none;
    color: var(--color-text-primary);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.shop-card:hover,
.user-card:hover {
    border-color: var(--color-accent);
    box-shadow: var(--shadow-sm);
    color: var(--color-text-primary);
}

.shop-card-header,
.user-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.shop-card-meta,
.user-card-meta {
    display: flex;
    align-items: center;
    gap: 16px;
}

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

.meta-icon {
    width: 14px;
    height: 14px;
}

.shop-domain {
    font-weight: 500;
}

/* --- Responsive --- */
.desktop-only {
    display: block;
}

.mobile-only {
    display: none;
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

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

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

    .main-wrapper {
        margin-left: 0;
    }

    .hamburger {
        display: flex;
    }

    .main-content {
        padding: 16px;
    }

    .topbar {
        padding: 0 16px;
    }

    .topbar-filters {
        flex-wrap: wrap;
    }

    .search-input {
        width: 160px;
    }

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

    .stat-card {
        padding: 14px;
        gap: 10px;
    }

    .stat-number {
        font-size: 22px;
    }

    .desktop-only {
        display: none;
    }

    .mobile-only {
        display: block;
    }

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

    .chat-image {
        max-width: 180px;
        max-height: 240px;
    }

    .chat-messages {
        padding: 10px 8px;
    }

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

    .image-card-visuals {
        flex-direction: column;
        align-items: flex-start;
    }

    .image-arrow {
        transform: rotate(90deg);
        align-self: center;
    }

    .filter-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .filter-apply {
        margin-left: 0;
    }

    .conversation-meta {
        flex-direction: column;
        gap: 12px;
    }

    .activity-body {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }

    .breadcrumb {
        font-size: 12px;
    }

    .modal-overlay {
        padding: 16px;
    }
}

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

    .topbar-actions {
        gap: 6px;
    }

    .topbar-actions .search-wrapper {
        display: none;
    }

    .topbar-add-btn span {
        display: none;
    }
}

/* --- Utility Classes --- */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-4 { gap: 4px; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.gap-24 { gap: 24px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.p-16 { padding: 16px; }
.p-24 { padding: 24px; }
.text-sm { font-size: 12px; }
.text-muted { color: var(--color-text-secondary); }
.text-center { text-align: center; }
.font-mono { font-family: var(--font-mono); }
.w-full { width: 100%; }
.hidden { display: none; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* --- Select Wrapper --- */
.select-wrapper {
    position: relative;
}

/* --- Clickable Stat Cards --- */
.stat-card-clickable {
    text-decoration: none;
    color: inherit;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
}
.stat-card-clickable:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.3);
    border-color: var(--color-accent);
}
.stat-card-clickable:active {
    transform: translateY(-2px);
}

/* --- Overview Columns --- */
.overview-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-top: 8px;
}
@media (max-width: 900px) {
    .overview-columns {
        grid-template-columns: 1fr;
    }
}

/* --- Chart Cards (Shop Activity) --- */
.chart-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
}
.chart-card {
    display: block;
    text-decoration: none;
    color: inherit;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: 20px;
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
    cursor: pointer;
}
.chart-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.25);
    border-color: var(--color-accent);
}
.chart-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}
.chart-card-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text);
    margin: 0;
}
.chart-bars {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.chart-bar-row {
    display: flex;
    align-items: center;
    gap: 10px;
}
.chart-bar-label {
    font-size: 12px;
    color: var(--color-text-secondary);
    width: 65px;
    flex-shrink: 0;
}
.chart-bar-track {
    flex: 1;
    height: 8px;
    background: var(--color-bg);
    border-radius: 4px;
    overflow: hidden;
}
.chart-bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.6s ease;
    min-width: 2px;
}
.chart-bar-users { background: linear-gradient(90deg, #3fb950, #2ea043); }
.chart-bar-messages { background: linear-gradient(90deg, #58a6ff, #388bfd); }
.chart-bar-images { background: linear-gradient(90deg, #d2a8ff, #bc8cff); }
.chart-bar-value {
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text);
    width: 35px;
    text-align: right;
    flex-shrink: 0;
}
.chart-card-footer {
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid var(--color-border);
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

/* --- Top Users --- */
.top-users-list {
    display: flex;
    flex-direction: column;
}
.top-user-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    text-decoration: none;
    color: inherit;
    border-bottom: 1px solid var(--color-border);
    transition: background 0.15s;
    cursor: pointer;
}
.top-user-item:last-child { border-bottom: none; }
.top-user-item:hover { background: rgba(88, 166, 255, 0.06); }
.top-user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #58a6ff, #388bfd);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
}
.top-user-info {
    flex: 1;
    min-width: 0;
}
.top-user-name {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--color-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.top-user-shop {
    display: block;
    font-size: 12px;
    color: var(--color-text-secondary);
}
.top-user-stats {
    text-align: right;
    flex-shrink: 0;
}
.top-user-count {
    display: block;
    font-size: 18px;
    font-weight: 700;
    color: var(--color-accent);
}
.top-user-label {
    display: block;
    font-size: 11px;
    color: var(--color-text-secondary);
    text-transform: uppercase;
}

/* --- Clickable Activity Items --- */
.activity-item-clickable {
    display: flex;
    text-decoration: none;
    color: inherit;
    cursor: pointer;
    transition: background 0.15s;
    padding: 12px 16px;
    border-radius: 8px;
}
.activity-item-clickable:hover {
    background: rgba(88, 166, 255, 0.06);
}
.activity-arrow {
    width: 16px;
    height: 16px;
    color: var(--color-text-secondary);
    flex-shrink: 0;
    align-self: center;
    opacity: 0;
    transition: opacity 0.15s;
}
.activity-item-clickable:hover .activity-arrow {
    opacity: 1;
}
.badge-sm {
    font-size: 10px;
    padding: 2px 6px;
}

/* --- Style Tags --- */
.style-tag {
    display: inline-block;
    font-size: 11px;
    padding: 3px 8px;
    border-radius: 4px;
    background: rgba(88, 166, 255, 0.1);
    color: var(--color-accent);
    font-weight: 500;
}

/* ============================================================
   CRM — Customer Management
   ============================================================ */

/* --- Filter Bar --- */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
    padding: 12px 16px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    align-items: center;
}

.filter-select {
    min-width: 120px;
    flex: 1;
    max-width: 160px;
    font-size: 12px;
    padding: 6px 24px 6px 8px;
    height: 32px;
    background-size: 10px;
}

@media (max-width: 768px) {
    .filter-bar { padding: 10px; }
    .filter-select { min-width: 0; flex: 1 1 calc(50% - 4px); max-width: none; }
}

/* --- Customer Cards Grid --- */
.customer-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
    padding: 0 0 24px;
}

.customer-card {
    display: block;
    text-decoration: none;
    color: inherit;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 20px;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast), border-color var(--transition-fast);
    cursor: pointer;
}

.customer-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    border-color: var(--color-accent);
    color: inherit;
}

.customer-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 12px;
}

.customer-card-identity {
    display: flex;
    align-items: center;
    gap: 10px;
}

.customer-avatar {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: var(--color-bg);
    object-fit: contain;
    flex-shrink: 0;
}

.customer-avatar-fallback {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: var(--color-accent-muted);
    color: var(--color-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    flex-shrink: 0;
}

.customer-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--color-text-primary);
    display: block;
    line-height: 1.2;
}

.customer-domain {
    font-size: 11px;
    color: var(--color-text-muted);
    display: block;
}

.customer-card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 12px;
}

.customer-card-info {
    font-size: 12px;
    color: var(--color-text-secondary);
    margin-bottom: 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.customer-card-info span {
    display: flex;
    align-items: center;
    gap: 6px;
}

.customer-card-stats {
    display: flex;
    justify-content: space-between;
    padding-top: 12px;
    border-top: 1px solid var(--color-border-light);
    font-size: 12px;
    color: var(--color-text-secondary);
}

.customer-card-stats .stat-val {
    font-weight: 600;
    color: var(--color-text-primary);
}

/* --- CRM Status Badges --- */
.badge-active { background-color: var(--color-success-muted); color: var(--color-success); }
.badge-trial { background-color: var(--color-info-muted); color: var(--color-info); }
.badge-prospect { background: rgba(139, 148, 158, 0.15); color: var(--color-text-secondary); }
.badge-paused { background-color: var(--color-warning-muted); color: var(--color-warning); }
.badge-churned { background-color: var(--color-error-muted); color: var(--color-error); }

/* --- Platform Badges --- */
.platform-badge {
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 10px;
    font-weight: 600;
    text-transform: uppercase;
}
.platform-badge-shopify { background: rgba(150, 91, 255, 0.2); color: #bc8cff; }
.platform-badge-woocommerce { background: rgba(56, 139, 253, 0.15); color: #58a6ff; }
.platform-badge-bot { background: rgba(63, 185, 80, 0.15); color: var(--color-success); }
.platform-badge-both { background: rgba(210, 153, 34, 0.15); color: var(--color-warning); }

/* --- Customer Detail Layout --- */
.customer-detail-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

@media (max-width: 900px) {
    .customer-detail-columns { grid-template-columns: 1fr; }
}

/* --- Detail Cards --- */
.detail-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 16px;
}

.detail-card-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text-primary);
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--color-border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.detail-field {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--color-border-light);
}

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

.detail-field-label {
    font-size: 13px;
    color: var(--color-text-secondary);
    font-weight: 500;
}

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

.detail-field-value .badge { vertical-align: middle; }

/* --- Notes Timeline (connected vertical) --- */
.notes-timeline {
    position: relative;
    padding-left: 24px;
}

/* Vertical spine */
.notes-timeline::before {
    content: '';
    position: absolute;
    left: 7px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--color-border);
}

/* Date group header */
.timeline-date-group {
    position: relative;
    padding: 8px 0 4px;
}

.timeline-date-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding-left: 4px;
}

/* Timeline dot on the spine */
.timeline-date-group::before {
    content: '';
    position: absolute;
    left: -21px;
    top: 12px;
    width: 10px;
    height: 10px;
    background: var(--color-surface);
    border: 2px solid var(--color-accent);
    border-radius: 50%;
    z-index: 1;
}

.note-item {
    position: relative;
    padding: 10px 12px 10px 4px;
    margin-left: 0;
    border-radius: var(--radius-md);
    transition: background var(--transition-fast);
}

.note-item:hover { background: var(--color-surface-raised); }

/* Small dot for each note */
.note-item::before {
    content: '';
    position: absolute;
    left: -20px;
    top: 18px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    z-index: 1;
}

.note-item.note-type-call::before { background: var(--color-info); }
.note-item.note-type-email::before { background: var(--color-success); }
.note-item.note-type-meeting::before { background: var(--color-purple); }
.note-item.note-type-internal::before { background: var(--color-text-muted); }
.note-item.note-type-negotiation::before { background: var(--color-warning); }

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

.note-meta {
    display: flex;
    align-items: center;
    gap: 8px;
}

.note-type-badge {
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 600;
}
.note-type-call { background: var(--color-info-muted); color: var(--color-info); }
.note-type-email { background: var(--color-success-muted); color: var(--color-success); }
.note-type-meeting { background: var(--color-purple-muted); color: var(--color-purple); }
.note-type-internal { background: rgba(139, 148, 158, 0.15); color: var(--color-text-secondary); }
.note-type-negotiation { background: var(--color-warning-muted); color: var(--color-warning); }

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

.note-content {
    font-size: 13px;
    color: var(--color-text-primary);
    line-height: 1.6;
    white-space: pre-wrap;
}

.note-urgency-badge {
    font-size: 9px;
    padding: 1px 6px;
    border-radius: 8px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.urgency-low { background: rgba(139,148,158,0.15); color: var(--color-text-secondary); }
.urgency-medium { background: var(--color-info-muted); color: var(--color-info); }
.urgency-high { background: var(--color-warning-muted); color: var(--color-warning); }
.urgency-urgent { background: var(--color-error-muted); color: var(--color-error); }

.note-author {
    font-size: 11px;
    color: var(--color-text-muted);
    margin-top: 4px;
    font-style: italic;
}

.note-delete-btn {
    background: none;
    border: none;
    color: var(--color-text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: var(--radius-sm);
    opacity: 0;
    transition: opacity var(--transition-fast), color var(--transition-fast);
}

.note-item:hover .note-delete-btn { opacity: 1; }
.note-delete-btn:hover { color: var(--color-error); }

.timeline-empty {
    text-align: center;
    padding: 24px 0;
    color: var(--color-text-muted);
    font-size: 13px;
}

/* --- Add Note Form --- */
.add-note-form {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 16px;
    margin-bottom: 16px;
}

.add-note-form textarea {
    width: 100%;
    min-height: 80px;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    color: var(--color-text-primary);
    font-family: var(--font-sans);
    font-size: 13px;
    padding: 10px 12px;
    resize: vertical;
    transition: border-color var(--transition-fast);
}

.add-note-form textarea:focus {
    outline: none;
    border-color: var(--color-accent);
}

.add-note-form textarea::placeholder {
    color: var(--color-text-muted);
}

.form-row {
    display: flex;
    gap: 8px;
    margin-top: 10px;
    align-items: center;
}

.form-select {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    color: var(--color-text-primary);
    font-size: 13px;
    padding: 6px 10px;
    cursor: pointer;
}

.form-select:focus {
    outline: none;
    border-color: var(--color-accent);
}

/* --- Modal --- */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 500;
    justify-content: center;
    align-items: flex-start;
    padding: 60px 20px;
    overflow-y: auto;
}

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

.modal-content {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xl);
    padding: 24px;
    width: 100%;
    max-width: 540px;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
}

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

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

.modal-close {
    background: none;
    border: none;
    color: var(--color-text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: var(--radius-sm);
}

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

.modal-form-group {
    margin-bottom: 14px;
}

.modal-form-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--color-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 4px;
}

.modal-form-group input,
.modal-form-group select,
.modal-form-group textarea {
    width: 100%;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    color: var(--color-text-primary);
    font-family: var(--font-sans);
    font-size: 13px;
    padding: 8px 10px;
}

.modal-form-group input:focus,
.modal-form-group select:focus,
.modal-form-group textarea:focus {
    outline: none;
    border-color: var(--color-accent);
}

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

.modal-form-checkboxes {
    display: flex;
    gap: 16px;
    padding: 4px 0;
}

.modal-form-checkboxes label {
    display: flex;
    align-items: center;
    gap: 6px;
    text-transform: none;
    letter-spacing: normal;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
}

.modal-form-checkboxes input[type="checkbox"] {
    width: auto;
    accent-color: var(--color-accent);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--color-border-light);
}

/* --- Inline Edit (customer detail) --- */
.edit-field {
    display: none;
    width: 100%;
}

.edit-mode .edit-field { display: block; }
.edit-mode .detail-field-value:not(.edit-field) { display: none; }

.edit-field input,
.edit-field select {
    width: 100%;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    color: var(--color-text-primary);
    font-size: 13px;
    padding: 4px 8px;
    text-align: right;
}

.edit-field input:focus,
.edit-field select:focus {
    outline: none;
    border-color: var(--color-accent);
}

/* --- Subscription History Timeline --- */
.sub-history {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--color-border-light);
}

.sub-history-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-text-muted);
    margin-bottom: 8px;
}

.sub-history-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 6px 0;
    font-size: 12px;
}

.sub-history-date {
    color: var(--color-text-muted);
    white-space: nowrap;
    min-width: 72px;
}

.sub-history-action {
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 8px;
    font-weight: 600;
    white-space: nowrap;
}

.sub-history-action.plan_changed { background: var(--color-info-muted); color: var(--color-info); }
.sub-history-action.price_changed { background: var(--color-warning-muted); color: var(--color-warning); }
.sub-history-action.started { background: var(--color-success-muted); color: var(--color-success); }
.sub-history-action.renewed { background: var(--color-purple-muted); color: var(--color-purple); }
.sub-history-action.cancelled { background: var(--color-error-muted); color: var(--color-error); }

.sub-history-details {
    color: var(--color-text-secondary);
    flex: 1;
}

/* --- Trial / Renewal Badges on Cards --- */
.card-alert-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 8px;
    margin-top: 4px;
}

.card-alert-badge svg { width: 12px; height: 12px; }
.card-alert-badge.trial-warning { background: var(--color-warning-muted); color: var(--color-warning); }
.card-alert-badge.trial-danger { background: var(--color-error-muted); color: var(--color-error); }
.card-alert-badge.renewal-soon { background: var(--color-info-muted); color: var(--color-info); }
.card-alert-badge.renewal-danger { background: var(--color-warning-muted); color: var(--color-warning); }

/* --- Quick Links --- */
.quick-links {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.quick-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: var(--color-bg);
    border: 1px solid var(--color-border-light);
    border-radius: var(--radius-md);
    font-size: 13px;
    color: var(--color-text-secondary);
    transition: all var(--transition-fast);
}

.quick-link:hover {
    color: var(--color-accent);
    border-color: var(--color-accent);
    background: var(--color-accent-muted);
}

.quick-link svg { width: 16px; height: 16px; flex-shrink: 0; }
.quick-link span { flex: 1; }
.quick-link .quick-link-arrow { color: var(--color-text-muted); }

/* --- Revenue Summary Stats --- */
.revenue-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.revenue-stat-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 16px;
    text-align: center;
}

.revenue-stat-value {
    font-size: 24px;
    font-weight: 700;
    line-height: 1.2;
}

.revenue-stat-label {
    font-size: 11px;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-top: 4px;
}

/* --- Analytics Charts Grid --- */
.analytics-charts-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-top: 16px;
}

.analytics-charts-grid canvas {
    width: 100% !important;
    max-height: 240px;
}

@media (max-width: 900px) {
    .analytics-charts-grid { grid-template-columns: 1fr; }
}

/* --- Customer Stats (loaded async) --- */
.customer-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 10px;
}

.customer-stat-card {
    text-align: center;
    padding: 12px 8px;
    background: var(--color-bg);
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border-light);
}

.customer-stat-value {
    font-size: 22px;
    font-weight: 700;
    line-height: 1.2;
}

.customer-stat-label {
    font-size: 10px;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-top: 2px;
}

.stats-loading {
    text-align: center;
    padding: 20px;
    color: var(--color-text-muted);
    font-size: 13px;
}

.stats-loading .spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--color-border);
    border-top-color: var(--color-accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 8px;
}

/* --- PostHog Analytics --- */
.posthog-section-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-text-muted);
    margin-bottom: 8px;
}

.posthog-countries,
.posthog-devices {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.posthog-country-row,
.posthog-device-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
}

.posthog-country-flag {
    font-size: 16px;
    width: 22px;
    text-align: center;
    flex-shrink: 0;
}

.posthog-country-name,
.posthog-device-name {
    width: 90px;
    color: var(--color-text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-shrink: 0;
}

.posthog-country-bar-track,
.posthog-device-bar-track {
    flex: 1;
    height: 8px;
    background: var(--color-bg);
    border-radius: 4px;
    overflow: hidden;
}

.posthog-country-bar-fill {
    height: 100%;
    background: var(--color-accent);
    border-radius: 4px;
    transition: width 0.5s ease;
}

.posthog-device-bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s ease;
}

.posthog-country-count {
    width: 50px;
    text-align: right;
    font-weight: 600;
    color: var(--color-text-primary);
    font-family: var(--font-mono);
    font-size: 11px;
    flex-shrink: 0;
}

.posthog-device-icon {
    font-size: 16px;
    width: 22px;
    text-align: center;
    flex-shrink: 0;
}

.posthog-device-pct {
    width: 42px;
    text-align: right;
    font-weight: 600;
    color: var(--color-text-primary);
    font-size: 11px;
    flex-shrink: 0;
}

/* --- Tasks --- */
.task-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 4px;
    border-bottom: 1px solid var(--color-border-light);
    transition: background var(--transition-fast);
}

.task-item:last-child { border-bottom: none; }
.task-item:hover { background: var(--color-surface-raised); }

.task-checkbox {
    background: none;
    border: none;
    cursor: pointer;
    padding: 2px;
    flex-shrink: 0;
}

.task-content {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.task-title {
    font-size: 13px;
    color: var(--color-text-primary);
}

.task-done .task-title {
    text-decoration: line-through;
    color: var(--color-text-muted);
}

.task-due {
    font-size: 10px;
    color: var(--color-text-muted);
    white-space: nowrap;
    padding: 1px 6px;
    border-radius: 8px;
    background: rgba(139,148,158,0.1);
}

.task-overdue {
    color: var(--color-error);
    background: var(--color-error-muted);
}

.task-done .task-due { opacity: 0.5; }

/* --- Topbar Add Button --- */
.topbar-add-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

/* ── Reports Section ── */
#reportsSection .btn-sm {
  font-size: 11px;
  padding: 3px 10px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}
#reportsSection .btn-sm:hover { opacity: 0.85; }
#reportsSection .btn-sm:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Floating Chat Widget ── */
.chat-widget { position: fixed; bottom: 24px; right: 24px; z-index: 1000; }

.chat-widget .chat-bubble {
  width: 56px; height: 56px; border-radius: 50%;
  background: #6C63FF;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(108,99,255,0.4);
  transition: transform 0.2s, box-shadow 0.2s;
  position: relative;
}
.chat-widget .chat-bubble:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 24px rgba(108,99,255,0.5);
}
.chat-unread {
  position: absolute; top: -2px; right: -2px;
  width: 14px; height: 14px; border-radius: 50%;
  background: #FF6B6B; border: 2px solid var(--bg);
}

.chat-widget .chat-window {
  width: 400px; height: 520px;
  background: #1a1a2e;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  display: flex; flex-direction: column;
  overflow: hidden;
}

.chat-widget .chat-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px;
  background: #252540;
  border-bottom: 1px solid #333;
}

.chat-widget .chat-messages {
  flex: 1; overflow-y: auto;
  padding: 12px 16px;
  display: flex; flex-direction: column; gap: 8px;
  background: #1a1a2e;
}

.chat-msg { display: flex; flex-direction: column; }
.chat-msg.user { align-items: flex-end; }
.chat-msg.assistant { align-items: flex-start; }

.chat-msg-bubble {
  max-width: 85%; padding: 8px 12px;
  border-radius: 12px; font-size: 13px; line-height: 1.5;
  word-wrap: break-word;
}
.chat-msg-bubble.user {
  background: #6C63FF; color: white;
  border-bottom-right-radius: 4px;
}
.chat-msg-bubble.assistant {
  background: #252540; color: var(--text);
  border-bottom-left-radius: 4px;
}

.chat-msg-time {
  font-size: 10px; color: var(--text-muted);
  margin-top: 2px; padding: 0 4px;
}

.chat-input-row {
  display: flex; gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid #333;
  background: #252540;
}
.chat-input-row input {
  flex: 1; padding: 8px 12px;
  background: var(--bg-card); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
  font-size: 13px; outline: none;
}
.chat-input-row input:focus { border-color: #6C63FF; }
.chat-input-row input:disabled { opacity: 0.5; }

.chat-send-btn {
  width: 36px; height: 36px;
  background: #6C63FF; color: white;
  border: none; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: opacity 0.2s;
}
.chat-send-btn:hover { opacity: 0.85; }

.chat-typing {
  color: var(--text-muted); font-style: italic; font-size: 12px;
}

/* Mobile responsive - chat widget */
@media (max-width: 768px) {
  .chat-widget { bottom: 12px; right: 12px; z-index: 9999; }
  .chat-widget .chat-bubble { width: 48px; height: 48px; }
  .chat-widget .chat-window {
    position: fixed !important;
    bottom: 0 !important;
    right: 0 !important;
    left: 0 !important;
    top: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    max-height: 100vh !important;
    border-radius: 0 !important;
    background: #1a1a2e !important;
    background-color: #1a1a2e !important;
    z-index: 99999 !important;
  }
  .chat-widget .chat-messages {
    background: #1a1a2e !important;
    background-color: #1a1a2e !important;
  }
  .chat-widget .chat-msg-bubble.assistant {
    background: #252540 !important;
  }
  .chat-widget .chat-header {
    background: #252540 !important;
    border-bottom: 1px solid #333 !important;
  }
  .chat-widget .chat-input-row {
    background: #252540 !important;
    border-top: 1px solid #333 !important;
    padding-bottom: env(safe-area-inset-bottom, 12px);
  }
}
