@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&family=Cairo:wght@300;400;600;700&display=swap');

:root {
    color-scheme: dark;
    --bg-dark: #09090e;
    --panel-bg: rgba(18, 18, 28, 0.55);
    --panel-border: rgba(250, 204, 21, 0.25);
    --panel-border-hover: rgba(250, 204, 21, 0.4);
    --accent: #facc15;
    --accent-glow: rgba(250, 204, 21, 0.35);
    --text-primary: #f3f4f6;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --header-bg: rgba(13, 13, 22, 0.8);
    --font-en: 'Outfit', sans-serif;
    --font-ar: 'Cairo', sans-serif;
    --btn-red: #e11d48;
    --active-gradient: linear-gradient(135deg, #ef4444, #e11d48);
    --border: rgba(255,255,255,0.1);
    --surface-hover: rgba(255,255,255,0.06);
    --surface: #181825;
    --bg-primary: #181825;
}

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

body {
    background-color: var(--bg-dark);
    background-image: 
        radial-gradient(at 10% 20%, rgba(99, 102, 241, 0.12) 0px, transparent 50%),
        radial-gradient(at 90% 80%, rgba(139, 92, 246, 0.1) 0px, transparent 50%);
    background-attachment: fixed;
    color: var(--text-primary);
    font-family: var(--font-en);
    height: 100vh;
    overflow: hidden;
    border: 1px solid var(--panel-border);
    border-radius: 12px;
    box-sizing: border-box;
}

body.rtl {
    font-family: var(--font-ar);
    direction: rtl;
}

button,
.nav-item,
.inner-tab,
.lang-btn,
.win-btn,
.composer-btn,
.chat-item,
.select-item,
.kanban-task-card,
.platform-badge,
.nav-badge,
.tab-badge {
    user-select: none;
    -webkit-user-select: none;
}

input,
textarea,
select,
.chat-feed,
.chat-feed *,
.order-card,
.order-card *,
.logs-body,
.logs-body *,
.premium-card,
.premium-card * {
    user-select: text;
    -webkit-user-select: text;
}

.app-container {
    display: flex;
    width: 100vw;
    height: 100vh;
}

/* Sidebar Styling */
.sidebar {
    width: 280px;
    background: rgba(11, 11, 19, 0.7);
    backdrop-filter: blur(20px);
    border-inline-end: none;
    display: flex;
    flex-direction: column;
    z-index: 10;
}

.sidebar-header {
    height: 150px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: none;
    box-sizing: border-box;
    -webkit-app-region: drag;
}

.sidebar-logo {
    height: 130px;
    width: 130px;
    object-fit: contain;
    border-radius: 16px;
    margin-top: 4px;
    animation: aura-pulse 6s ease-in-out infinite;
}

.sidebar-nav {
    margin-top: 0px;
}
@keyframes aura-pulse {
    0%, 100% { filter: drop-shadow(0 0 5px rgba(250, 204, 21, 0.2)); }
    50% { filter: drop-shadow(0 0 14px rgba(250, 204, 21, 0.45)); }
}

.sidebar-title-container {
    display: flex;
    flex-direction: column;
    margin-top: 16px;
}

.sidebar-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: 0.5px;
}

.sidebar-subtitle {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.sidebar-nav {
    flex: 1;
    padding: 8px 12px 20px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    overflow-y: auto;
}

.nav-section-title {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    padding: 12px;
    letter-spacing: 1px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: 10px;
    color: var(--text-secondary);
    text-decoration: none;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 0.95rem;
    font-weight: 500;
    position: relative;
}

.nav-item:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.03);
}

.nav-item.active {
    color: #fffdf5;
    background: linear-gradient(135deg, rgba(250, 204, 21, 0.18), rgba(250, 204, 21, 0.06));
    border: 1px solid rgba(250, 204, 21, 0.35);
    box-shadow: 0 4px 15px var(--accent-glow);
}

.nav-badge,
.tab-badge {
    min-width: 18px;
    height: 18px;
    padding: 0 6px;
    border-radius: 999px;
    display: none;
    align-items: center;
    justify-content: center;
    background: var(--accent);
    color: #111827;
    font-size: 0.68rem;
    font-weight: 800;
    box-shadow: 0 6px 14px rgba(250, 204, 21, 0.24);
}

.nav-badge.visible,
.tab-badge.visible {
    display: inline-flex;
}

.nav-badge {
    margin-inline-start: auto;
}

.nav-item svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    stroke-width: 2;
    fill: none;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--panel-border);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Mobile language toggle hidden on desktop */
.mobile-lang-toggle {
    display: none;
}

/* Window controls hidden by default (only needed in C++ host) */
.window-controls {
    display: none;
}

/* Lang Toggle Button */
.lang-toggle {
    display: flex;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    padding: 3px;
    border: 1px solid var(--panel-border);
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border: 1px solid var(--panel-border);
    border-radius: 6px;
    background: var(--surface);
    color: var(--text-primary);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    font-family: inherit;
}
.btn:hover {
    border-color: var(--panel-border-hover);
    background: var(--surface-hover);
    box-shadow: 0 0 12px var(--accent-glow);
}
.btn.primary {
    background: linear-gradient(135deg, var(--accent), #e6b800);
    color: #000;
    border-color: var(--accent);
    font-weight: 600;
}
.btn.primary:hover {
    box-shadow: 0 0 16px var(--accent-glow);
    filter: brightness(1.1);
}
.btn.mini {
    padding: 4px 10px;
    font-size: 0.76rem;
    border-radius: 5px;
}

.lang-btn {
    flex: 1;
    text-align: center;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;
    transition: all 0.2s;
    color: var(--text-secondary);
    -webkit-app-region: no-drag;
}

.lang-btn.active {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
}

/* Main Area */
.main-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
    background: rgba(11, 11, 19, 0.7);
    backdrop-filter: blur(20px);
}

/* Top Header Bar */
.top-bar {
    height: 72px;
    background: var(--header-bg);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--panel-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    z-index: 9;
    box-sizing: border-box;
    -webkit-app-region: drag;
}

.top-bar-title {
    font-size: 1.25rem;
    font-weight: 600;
    /* allow title to shrink when screen is narrow */
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.top-bar-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0; /* never squeeze controls */
}

.status-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--panel-border);
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
}

.status-indicator.online {
    background: var(--success);
    box-shadow: 0 0 8px var(--success);
}

.status-indicator.offline {
    background: var(--danger);
    box-shadow: 0 0 8px var(--danger);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 14px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--panel-border);
    border-radius: 8px;
}

.user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--active-gradient);
    display: none;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    color: white;
}

.user-name {
    font-size: 0.85rem;
    font-weight: 600;
}

.logout-btn {
    padding: 4px 9px;
    border-radius: 6px;
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(239, 68, 68, 0.25);
    color: var(--danger);
    font-size: 0.72rem;
    cursor: pointer;
    transition: all 0.2s;
    -webkit-app-region: no-drag;
    white-space: nowrap;
    flex-shrink: 0;
}

.logout-btn:hover {
    background: rgba(239, 68, 68, 0.25);
    color: #ef4444;
}

/* Inner Tabs Bar */
.inner-tabs-bar {
    display: flex;
    gap: 16px;
    margin-bottom: 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 4px;
}

.inner-tab {
    padding: 8px 16px;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.inner-tab:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.03);
}

.inner-tab.active {
    color: #fffdf5;
    background: rgba(250, 204, 21, 0.14);
    border: 1px solid rgba(250, 204, 21, 0.3);
}

/* User Info Layout Fix */
.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Window Controls (hidden in web view — only meaningful in native host) */
.window-controls {
    display: none;
    gap: 8px;
    margin-left: 12px;
}

.win-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    border-radius: 6px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 1rem;
    font-weight: 600;
    -webkit-app-region: no-drag;
}

.win-min:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
}

.win-close:hover {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.3);
}

.logout-btn:hover {
    background: rgba(239, 68, 68, 0.25);
}

/* Screen Shell */
.screen-container {
    flex: 1;
    padding: 0 24px 20px;
    overflow-y: auto;
    position: relative;
    background: #000000;
    border: 1px solid var(--panel-border);
    border-start-start-radius: 20px;
    border-end-start-radius: 20px;
    border-inline-end: none;
    margin: 0;
}

.screen {
    display: none;
    animation: fadeInUp 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    height: 100%;
}

.screen.active {
    display: flex;
    flex-direction: column;
}

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

/* Login Screen Glassmorphic Layout */
.login-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
}

.login-card {
    background: rgba(17, 17, 27, 0.65);
    backdrop-filter: blur(25px);
    border: 1px solid var(--panel-border);
    padding: 24px 30px;
    border-radius: 20px;
    width: 380px;
    text-align: center;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.login-logo {
    width: 96px;
    height: 96px;
    object-fit: contain;
    border-radius: 22px;
    animation: aura-pulse 2.6s ease-in-out infinite;
}

/* Advertising workspace */
.advertising-tabs {
    flex: 0 0 auto;
}

.advertising-live-strip {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    padding: 10px 14px;
    margin: 12px 0;
    border: 1px solid var(--panel-border);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.025);
}

.advertising-status-pill {
    padding: 4px 10px;
    border-radius: 999px;
    border: 1px solid rgba(16, 185, 129, 0.34);
    background: rgba(16, 185, 129, 0.1);
    color: #86efac;
    font-size: 0.72rem;
    font-weight: 700;
}

.advertising-status-pill.warning {
    border-color: rgba(245, 158, 11, 0.4);
    background: rgba(245, 158, 11, 0.1);
    color: #fbbf24;
}

.advertising-status-copy {
    margin-inline-start: auto;
    color: var(--text-muted);
    font-size: 0.76rem;
}

.advertising-pane {
    min-height: 0;
    flex: 1;
    overflow: auto;
    padding-bottom: 18px;
}

.advertising-workspace {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 310px;
    gap: 14px;
    align-items: start;
}

.advertising-main-column,
.advertising-side-column {
    display: flex;
    flex-direction: column;
    gap: 14px;
    min-width: 0;
}

.advertising-side-column {
    position: sticky;
    top: 0;
}

.advertising-section-card {
    padding: 16px;
    border: 1px solid var(--panel-border);
    border-radius: 14px;
    background: var(--panel-bg);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.12);
}

.advertising-section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
    color: var(--text-primary);
    font-size: 0.95rem;
    font-weight: 700;
}

.advertising-section-heading.compact {
    margin-top: 16px;
    margin-bottom: 10px;
}

.advertising-subheading {
    margin: 2px 0 10px;
    color: var(--accent);
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.advertising-subheading.spaced {
    margin-top: 16px;
}

.advertising-form-grid {
    display: grid;
    gap: 10px 12px;
}

.advertising-form-grid.two {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.advertising-form-grid.three {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.advertising-form-grid.two-one {
    grid-template-columns: minmax(0, 2fr) minmax(180px, 1fr);
}

.advertising-field {
    margin-bottom: 12px;
    min-width: 0;
}

.advertising-field label {
    display: block;
    margin-bottom: 5px;
    color: var(--text-secondary);
    font-size: 0.74rem;
    font-weight: 600;
}

.advertising-input,
.advertising-textarea {
    width: 100%;
    border: 1px solid var(--panel-border);
    border-radius: 9px;
    outline: none;
    background: rgba(4, 4, 10, 0.46);
    color: var(--text-primary);
    font: inherit;
    font-size: 0.82rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.advertising-input {
    min-height: 40px;
    padding: 8px 10px;
}

.advertising-textarea {
    min-height: 84px;
    padding: 10px;
    resize: vertical;
}

.advertising-textarea.small {
    min-height: 64px;
}

.advertising-textarea.tall {
    min-height: 126px;
}

.advertising-textarea.preview {
    min-height: 118px;
    font-family: Consolas, monospace;
    font-size: 0.74rem;
}

.advertising-input:focus,
.advertising-textarea:focus {
    border-color: rgba(250, 204, 21, 0.72);
    box-shadow: 0 0 0 3px rgba(250, 204, 21, 0.08);
}

.advertising-input:disabled,
.advertising-textarea:disabled,
.advertising-btn:disabled {
    cursor: not-allowed;
    opacity: 0.48;
}

.advertising-button-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.advertising-button-row.footer-actions {
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--panel-border);
}

.advertising-btn {
    min-height: 30px;
    padding: 5px 10px;
    border: 1px solid var(--panel-border);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-primary);
    font: inherit;
    font-size: 0.73rem;
    font-weight: 650;
    cursor: pointer;
    transition: 0.18s ease;
}

.advertising-btn:hover:not(:disabled) {
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(250, 204, 21, 0.08);
}

.advertising-btn.primary {
    border-color: rgba(250, 204, 21, 0.7);
    background: linear-gradient(135deg, var(--accent), #e6b800);
    color: #000;
    font-weight: 700;
}

.advertising-btn.primary:hover:not(:disabled) {
    box-shadow: 0 0 16px var(--accent-glow);
    filter: brightness(1.1);
    color: #000;
}

.advertising-btn.accent {
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(250, 204, 21, 0.08);
}

.advertising-btn.accent:hover:not(:disabled) {
    box-shadow: 0 0 12px var(--accent-glow);
    filter: brightness(1.1);
}

.advertising-btn.danger {
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(250, 204, 21, 0.08);
}

.advertising-btn.mini {
    min-height: 24px;
    padding: 2px 7px;
    font-size: 0.65rem;
}

.advertising-media-list,
.advertising-target-list,
.advertising-record-list,
.advertising-validation-box {
    min-height: 66px;
    padding: 10px;
    border: 1px solid var(--panel-border);
    border-radius: 9px;
    background: rgba(4, 4, 10, 0.34);
    color: var(--text-muted);
    font-size: 0.76rem;
}

.advertising-media-item,
.advertising-target-item,
.advertising-record-item {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 8px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.025);
}

.advertising-media-item + .advertising-media-item,
.advertising-target-item + .advertising-target-item,
.advertising-record-item + .advertising-record-item {
    margin-top: 7px;
}

.advertising-record-main {
    flex: 1;
    min-width: 0;
}

.advertising-record-title {
    overflow: hidden;
    color: var(--text-primary);
    font-weight: 700;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.advertising-record-meta {
    margin-top: 3px;
    color: var(--text-muted);
    font-size: 0.68rem;
}

.advertising-ai-result {
    margin-bottom: 12px;
    padding: 12px;
    border: 1px solid rgba(59, 130, 246, 0.35);
    border-radius: 9px;
    background: rgba(59, 130, 246, 0.07);
    color: #bfdbfe;
    font-size: 0.76rem;
    white-space: pre-wrap;
}

.advertising-inline-status {
    min-height: 20px;
    margin-top: 8px;
    color: var(--text-secondary);
    font-size: 0.75rem;
}

.advertising-safety-toolbar {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 12px;
    padding: 12px;
    border: 1px solid var(--panel-border);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.025);
}

.advertising-check-grid {
    display: flex;
    gap: 18px;
    flex-wrap: wrap;
    padding: 12px;
    border: 1px solid var(--panel-border);
    border-radius: 9px;
    background: rgba(4, 4, 10, 0.34);
    color: var(--text-secondary);
    font-size: 0.78rem;
}

.advertising-checkbox-line {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 10px 0;
    color: var(--text-secondary);
    font-size: 0.78rem;
}

.advertising-multi-select {
    min-height: 104px;
}

.warning-text {
    color: #fbbf24 !important;
}

@media (max-width: 1180px) {
    .advertising-workspace {
        grid-template-columns: 1fr;
    }

    .advertising-side-column {
        position: static;
    }
}

@media (max-width: 850px) {
    .advertising-form-grid.two,
    .advertising-form-grid.three,
    .advertising-form-grid.two-one {
        grid-template-columns: 1fr;
    }
}

.pin-display {
    width: 100%;
    height: 54px;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    letter-spacing: 8px;
    color: white;
    font-weight: 700;
}

.pin-pad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    width: 100%;
}

.pin-btn {
    height: 46px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pin-btn:hover {
    background: rgba(250, 204, 21, 0.08);
    border-color: var(--accent);
    box-shadow: 0 0 12px var(--accent-glow);
    color: var(--accent);
}

.pin-btn.action {
    background: linear-gradient(135deg, var(--accent), #e6b800);
    color: #000;
    border-color: var(--accent);
    font-weight: 700;
}

.pin-btn.action:hover {
    box-shadow: 0 0 16px var(--accent-glow);
    filter: brightness(1.1);
    color: #000;
}

.login-error {
    color: var(--danger);
    font-size: 0.85rem;
    min-height: 20px;
}

.modern-input {
    width: 100%;
    height: 44px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    padding: 0 14px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.9rem;
    outline: none;
    transition: all 0.2s;
}

.modern-input:focus {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--accent);
    box-shadow: 0 0 10px rgba(99, 102, 241, 0.2);
}

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

select.modern-input option,
select option {
    background: var(--surface);
    color: var(--text-primary);
}

select optgroup {
    background: var(--bg-dark);
    color: var(--accent);
    font-weight: 700;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.1);
    transition: .3s;
    border-radius: 24px;
    border: 1px solid var(--panel-border);
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    transition: .3s;
    border-radius: 50%;
}

.toggle-switch input:checked + .toggle-slider {
    background-color: #007aff; /* iOS blue from user's image */
    border-color: #007aff;
}

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

/* Metric Cards */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.metric-card {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    padding: 20px;
    border-radius: 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: all 0.25s ease;
}

.metric-card:hover {
    transform: translateY(-2px);
    border-color: var(--panel-border-hover);
    box-shadow: 0 6px 20px rgba(0,0,0,0.2);
}

.metric-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
}

.metric-card svg {
    width: 22px;
    height: 22px;
    color: var(--accent);
}

.metric-val {
    font-size: 1.8rem;
    font-weight: 700;
    color: #ffffff;
}

.metric-footer {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Pipeline styling */
.pipeline-card {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 24px;
}

.pipeline-header {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 20px;
}

.pipeline-flow {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    overflow-x: auto;
    padding-bottom: 12px;
}

.pipeline-step {
    flex: 1;
    min-width: 140px;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--panel-border);
    border-radius: 10px;
    padding: 14px;
    text-align: center;
    position: relative;
}

.pipeline-step.active {
    border-color: var(--accent);
    background: rgba(99, 102, 241, 0.05);
}

.pipeline-step-title {
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 6px;
}

.pipeline-step-val {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--accent);
}

.pipeline-step-state {
    display: inline-block;
    padding: 2px 8px;
    font-size: 0.65rem;
    border-radius: 10px;
    background: rgba(255,255,255,0.05);
    margin-top: 6px;
    color: var(--text-secondary);
}

.pipeline-step.active .pipeline-step-state {
    background: rgba(99, 102, 241, 0.15);
    color: #a5b4fc;
}

/* Pulse / Insights */
.insights-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.insight-panel {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 16px;
    padding: 24px;
}

.insight-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.insight-item {
    padding: 10px 0;
    border-bottom: 1px solid rgba(255,255,255,0.03);
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

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

/* Custom Scrollbars */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

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

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Inbox Screen Specific Styles */
.inbox-layout {
    display: flex;
    height: calc(100vh - 120px);
    gap: 20px;
}

.inbox-sidebar {
    width: 320px;
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

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

.inbox-filter {
    display: flex;
    background: rgba(0,0,0,0.2);
    border-radius: 8px;
    padding: 2px;
}

.inbox-filter-item {
    flex: 1;
    padding: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    border-radius: 6px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.inbox-filter-item.active {
    background: rgba(250, 204, 21, 0.12);
    color: #fffdf5;
}

.chat-list {
    flex: 1;
    overflow-y: auto;
}

.chat-item {
    padding: 16px;
    border-bottom: 1px solid rgba(255,255,255,0.03);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
}

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

.chat-item.active {
    background: rgba(250, 204, 21, 0.12);
    border-inline-start: 4px solid var(--accent);
}

.chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255,255,255,0.04);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.95rem;
    position: relative;
}

.platform-badge {
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6rem;
    background: #25d366; /* default whatsapp green */
    color: white;
    box-shadow: 0 0 4px rgba(0,0,0,0.5);
}

body.rtl .platform-badge {
    right: auto;
    left: -2px;
}

.platform-badge.telegram {
    background: #0088cc;
}

.chat-details {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

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

.chat-name {
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-item.active .chat-name {
    color: var(--accent);
}

.chat-time {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.chat-preview {
    font-size: 0.75rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-preview-meta {
    color: var(--accent);
    opacity: 0.9;
    font-size: 0.68rem;
}

.unread-badge {
    background: var(--accent);
    color: #111827;
    font-size: 0.65rem;
    font-weight: 800;
    padding: 2px 6px;
    border-radius: 10px;
}

/* Chat window pane */
.chat-window {
    flex: 1;
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-window-header {
    height: 64px;
    padding: 0 20px;
    border-bottom: 1px solid var(--panel-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(0,0,0,0.1);
}

.chat-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-header-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--accent);
}

.chat-header-platform {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.chat-feed {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 14px;
    background: rgba(0, 0, 0, 0.15);
}

.message-bubble {
    max-width: 70%;
    padding: 12px 16px;
    border-radius: 14px;
    font-size: 0.85rem;
    line-height: 1.45;
    position: relative;
    animation: bubbleIn 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

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

.message-bubble.incoming {
    align-self: flex-start;
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--panel-border);
    color: var(--text-primary);
    border-top-left-radius: 2px;
}

.message-reply-snippet {
    margin-bottom: 8px;
    padding: 8px 10px;
    border-radius: 10px;
    background: rgba(250, 204, 21, 0.08);
    border-inline-start: 3px solid rgba(250, 204, 21, 0.65);
    color: var(--text-secondary);
    font-size: 0.72rem;
}

body.rtl .message-bubble.incoming {
    border-top-left-radius: 14px;
    border-top-right-radius: 2px;
}

.message-bubble.outgoing {
    align-self: flex-end;
    background: var(--active-gradient);
    color: white;
    border-top-right-radius: 2px;
    box-shadow: 0 3px 12px rgba(99,102,241,0.2);
}

body.rtl .message-bubble.outgoing {
    border-top-right-radius: 14px;
    border-top-left-radius: 2px;
}

.message-media {
    position: relative;
}
.message-media:has(img) .optimistic-loading {
    position: absolute;
    inset: 0;
    min-height: 0;
}
.message-media img {
    max-width: 150px;
    max-height: 150px;
    border-radius: 8px;
    margin-bottom: 6px;
    cursor: pointer;
}

.message-time {
    font-size: 0.65rem;
    color: rgba(255,255,255,0.4);
    margin-top: 4px;
    text-align: end;
}

.message-bubble.incoming .message-time {
    color: var(--text-muted);
}

.chat-composer {
    height: 72px;
    padding: 14px 20px;
    border-top: 1px solid var(--panel-border);
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(0,0,0,0.1);
}

.composer-input {
    flex: 1;
    background: rgba(0,0,0,0.3);
    border: 1px solid var(--panel-border);
    border-radius: 10px;
    padding: 10px 14px;
    color: white;
    font-size: 16px; /* MUST be >=16px to prevent iOS auto-zoom on focus */
    outline: none;
    /* Prevent double-tap zoom on input */
    touch-action: manipulation;
}

.composer-input:focus {
    border-color: var(--accent);
    font-size: 16px; /* keep >=16px even on focus */
}

.composer-btn {
    height: 40px;
    width: 40px;
    border-radius: 10px;
    background: var(--active-gradient);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: 0 2px 10px rgba(99,102,241,0.2);
}

.composer-btn:hover {
    transform: scale(1.02);
}

.composer-btn svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.5;
}

/* Orders and Clients Tab */
.search-bar-row {
    margin-bottom: 20px;
    display: flex;
    gap: 16px;
}

.search-input {
    flex: 1;
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    padding: 12px 16px;
    border-radius: 10px;
    color: white;
    font-size: 0.9rem;
    outline: none;
}

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

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

.orders-section-title {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 8px 0 -4px;
    padding: 12px 14px;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 12px;
    background: linear-gradient(135deg, rgba(59,130,246,0.13), rgba(15,23,42,0.72));
    color: var(--text-primary);
    font-weight: 800;
    letter-spacing: 0.02em;
}

.orders-section-title strong {
    min-width: 30px;
    text-align: center;
    padding: 3px 8px;
    border-radius: 999px;
    background: rgba(255,255,255,0.09);
    color: var(--accent);
    font-size: 0.76rem;
}

.order-card {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 14px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.order-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    padding-bottom: 10px;
}

.order-num {
    font-weight: 700;
    font-size: 0.95rem;
}

.order-date {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-left: auto;
    margin-right: 12px;
}

.order-badge {
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 700;
}

.order-badge.active { background: rgba(99,102,241,0.15); color: #a5b4fc; }
.order-badge.pending { background: rgba(250,204,21,0.16); color: #fde68a; }
.order-badge.delivered { background: rgba(16,185,129,0.15); color: #6ee7b7; }
.order-badge.cancelled { background: rgba(239,68,68,0.15); color: #fca5a5; }
.order-badge.returned { background: rgba(245, 158, 11, 0.16); color: #fcd34d; }

.review-card {
    min-height: 180px;
}

.review-stars {
    color: var(--accent);
    font-weight: 800;
    letter-spacing: 0.08em;
}

.review-text {
    padding: 10px;
    border-radius: 8px;
    background: rgba(0,0,0,0.14);
    color: var(--text-primary);
    font-size: 0.82rem;
    line-height: 1.5;
    max-height: 96px;
    overflow-y: auto;
}

.order-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
}

.order-row-lbl { color: var(--text-secondary); }
.order-row-val { font-weight: 600; }

.order-lines-list {
    background: rgba(0,0,0,0.15);
    border-radius: 8px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 120px;
    overflow-y: auto;
}

.order-line-item {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.order-card-actions {
    display: flex;
    gap: 10px;
    margin-top: 6px;
}

.customer-wardrobe {
    background: rgba(250, 204, 21, 0.06);
    border: 1px solid rgba(250, 204, 21, 0.14);
    border-radius: 10px;
    padding: 10px 12px;
}

.customer-wardrobe-title {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.customer-wardrobe-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.customer-wardrobe-item {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    font-size: 0.76rem;
    color: var(--text-secondary);
}

.customer-wardrobe-item span {
    color: var(--text-primary);
    font-weight: 700;
}

.action-btn {
    flex: 1;
    padding: 6px;
    border-radius: 6px;
    font-size: 0.76rem;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    border: 1px solid transparent;
}

.action-btn.primary {
    background: linear-gradient(135deg, var(--accent), #e6b800);
    border-color: var(--accent);
    color: #000;
    font-weight: 700;
}

.action-btn.primary:hover {
    box-shadow: 0 0 16px var(--accent-glow);
    filter: brightness(1.1);
    color: #000;
}

.action-btn.warning {
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(250, 204, 21, 0.08);
}

.action-btn.warning:hover {
    box-shadow: 0 0 12px var(--accent-glow);
    filter: brightness(1.1);
}

.action-btn.danger {
    background: linear-gradient(135deg, var(--accent), #e6b800);
    border-color: var(--accent);
    color: #000;
    font-weight: 700;
}

.action-btn.danger:hover {
    box-shadow: 0 0 16px var(--accent-glow);
    filter: brightness(1.1);
    color: #000;
}

.action-btn.details {
    background: rgba(250, 204, 21, 0.08);
    border-color: var(--accent);
    color: var(--accent);
}

.action-btn.details:hover {
    box-shadow: 0 0 12px var(--accent-glow);
    filter: brightness(1.1);
}

.premium-custom-card {
    background: linear-gradient(135deg, var(--panel-bg) 0%, rgba(99, 102, 241, 0.05) 100%) !important;
    border: 1px solid rgba(99, 102, 241, 0.2) !important;
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.08) !important;
    position: relative;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

.premium-custom-card:hover {
    transform: translateY(-4px);
    border-color: rgba(99, 102, 241, 0.4) !important;
    box-shadow: 0 8px 30px rgba(99, 102, 241, 0.15) !important;
}

.premium-custom-card::before {
    content: "CUSTOM";
    position: absolute;
    top: 10px;
    right: -25px;
    background: var(--accent);
    color: #fff;
    font-size: 0.55rem;
    font-weight: 900;
    padding: 4px 30px;
    transform: rotate(45deg);
    box-shadow: 0 2px 4px rgba(0,0,0,0.25);
    letter-spacing: 0.1em;
    z-index: 10;
}

.order-attach-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    border: 1px solid rgba(250,204,21,0.3);
    border-radius: 6px;
    background: rgba(250,204,21,0.08);
    color: var(--accent);
    font-size: 0.72rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.order-attach-btn:hover {
    background: rgba(250,204,21,0.18);
    border-color: var(--accent);
}

.order-custom-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 6px;
}

/* Order Details Modal */
.order-details-modal-container {
    position: relative;
    max-width: 520px;
    width: 90vw;
    max-height: 85vh;
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 16px;
    padding: 28px 24px 20px;
    overflow-y: auto;
    backdrop-filter: blur(16px);
    box-shadow: 0 12px 48px rgba(0,0,0,0.5);
}

.order-details-modal-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 16px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--panel-border);
}

.order-details-body {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.order-details-section {
    padding: 12px;
    background: rgba(0,0,0,0.15);
    border-radius: 10px;
}

.order-details-label {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.order-details-field {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.82rem;
    color: var(--text-primary);
    padding: 4px 0;
}

.order-details-field + .order-details-field {
    border-top: 1px solid rgba(255,255,255,0.04);
}

.order-details-thumb {
    max-width: 100%;
    max-height: 160px;
    border-radius: 8px;
    cursor: pointer;
    display: block;
    transition: opacity 0.2s;
}

.order-details-thumb:hover {
    opacity: 0.85;
}

.order-details-notes {
    font-size: 0.82rem;
    color: var(--text-secondary);
    line-height: 1.5;
    white-space: pre-wrap;
    max-height: 200px;
    overflow-y: auto;
    padding: 8px;
    background: rgba(0,0,0,0.12);
    border-radius: 6px;
}

.order-details-lines {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.order-details-line {
    display: flex;
    justify-content: space-between;
    font-size: 0.78rem;
    color: var(--text-secondary);
    padding: 4px 0;
    border-bottom: 1px solid rgba(255,255,255,0.03);
}

/* Image modal overlay */
.image-modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    backdrop-filter: blur(4px);
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.image-modal-container {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.image-modal-loading {
    padding: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.image-modal-loading .spinner {
    width: 32px;
    height: 32px;
    border: 3px solid rgba(255,255,255,0.15);
    border-top-color: var(--accent, #818cf8);
    border-radius: 50%;
    animation: image-modal-spin 0.7s linear infinite;
}
@keyframes image-modal-spin {
    to { transform: rotate(360deg); }
}
.image-modal-img {
    max-width: 100%;
    max-height: 85vh;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.5);
    cursor: default;
    user-select: all;
    -webkit-user-drag: auto;
}

.image-modal-img.zoomable {
    cursor: grab;
    transition: none;
    transform-origin: center center;
    -webkit-user-drag: auto;
    user-select: none;
}

.image-modal-img.zoomable:active {
    cursor: grabbing;
}

.chat-media-img {
    background: var(--panel-bg);
    min-height: 60px;
}

.order-card-thumb-wrapper {
    padding: 8px 0;
    text-align: center;
}

.order-card-thumb {
    max-width: 100%;
    max-height: 140px;
    border-radius: 6px;
    cursor: pointer;
    object-fit: contain;
    background: rgba(0,0,0,0.15);
    transition: opacity 0.2s;
}

.order-card-thumb:hover {
    opacity: 0.85;
}

.order-details-thumb {
    max-width: 100%;
    max-height: 260px;
    border-radius: 6px;
    cursor: pointer;
    object-fit: contain;
    background: rgba(0,0,0,0.15);
}

.image-modal-close {
    position: fixed;
    top: 20px;
    right: 30px;
    background: rgba(255,255,255,0.1);
    border: none;
    color: #fff;
    font-size: 2rem;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    z-index: 10001;
}

.image-modal-close:hover {
    background: rgba(255,255,255,0.2);
}

.image-modal-save {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 10px 24px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: opacity 0.2s;
    z-index: 10001;
}

.image-modal-save:hover {
    opacity: 0.85;
    color: #fff;
}

/* Operational columns kanban styling */
.kanban-layout {
    display: flex;
    gap: 16px;
    overflow-x: auto;
    height: calc(100vh - 120px);
}

.kanban-column {
    flex: 1;
    min-width: 240px;
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.kanban-column-header {
    padding: 16px;
    border-bottom: 1px solid var(--panel-border);
    background: rgba(0,0,0,0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.kanban-column-title {
    font-size: 0.85rem;
    font-weight: 700;
}

.kanban-column-count {
    background: rgba(255,255,255,0.06);
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 700;
}

.kanban-task-list {
    flex: 1;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow-y: auto;
}

.kanban-task-card {
    background: rgba(0,0,0,0.2);
    border: 1px solid var(--panel-border);
    border-radius: 10px;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.kanban-task-card:hover {
    border-color: var(--panel-border-hover);
    background: rgba(255,255,255,0.02);
}

.task-title {
    font-size: 0.8rem;
    font-weight: 700;
}

.task-meta-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.7rem;
    color: var(--text-muted);
}

.task-assignee {
    color: var(--accent);
    font-weight: 600;
}

/* Logs and Activity lists */
.logs-panel {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 16px;
    padding: 20px;
    height: calc(100vh - 120px);
    display: flex;
    flex-direction: column;
}

.logs-header {
    margin-bottom: 14px;
}

.logs-body {
    flex: 1;
    background: rgba(0,0,0,0.4);
    border: 1px solid var(--panel-border);
    border-radius: 10px;
    padding: 16px;
    overflow-y: auto;
    font-family: monospace;
    font-size: 0.8rem;
    line-height: 1.5;
    color: var(--text-secondary);
}

.log-line {
    margin-bottom: 6px;
    border-bottom: 1px solid rgba(255,255,255,0.01);
    padding-bottom: 4px;
}

.log-line.error { color: var(--danger); }
.log-line.warning { color: var(--warning); }
.log-line.info { color: var(--success); }
.log-line.debug { color: var(--text-muted); }

.select-item { padding: 12px 14px; cursor: pointer; transition: background 0.2s; }
.select-item:hover { background: rgba(99, 102, 241, 0.2); color: white; }

.premium-card { background: linear-gradient(145deg, rgba(30, 30, 46, 0.8), rgba(20, 20, 32, 0.9)); border: 1px solid var(--panel-border); border-radius: 16px; padding: 24px; box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3); transition: transform 0.3s, box-shadow 0.3s; }
.premium-card:hover { transform: translateY(-4px); box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5); border-color: var(--accent); }
.grid-container { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px; padding: 20px 0; }
.grid-container > *:last-child { margin-bottom: 0; }

.production-panel {
    background: linear-gradient(145deg, rgba(30, 30, 46, 0.82), rgba(15, 15, 24, 0.92));
    border: 1px solid var(--panel-border);
    border-radius: 18px;
    padding: 22px;
    margin-bottom: 22px;
    box-shadow: 0 16px 45px rgba(0, 0, 0, 0.22);
}

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

.production-panel-header h3 {
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--text-primary);
}

.production-panel-note {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin: -4px 0 16px;
}

.production-table-wrap {
    width: 100%;
    overflow: auto;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    background: rgba(0, 0, 0, 0.22);
}

.production-table {
    width: 100%;
    min-width: 900px;
    border-collapse: collapse;
}

.production-table th,
.production-table td {
    padding: 10px 10px;
    text-align: start;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    font-size: 0.74rem;
    vertical-align: middle;
}

.production-table th {
    color: var(--text-secondary);
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    background: rgba(0, 0, 0, 0.24);
}

.production-table td span {
    display: block;
    margin-top: 3px;
    color: var(--text-secondary);
    font-size: 0.66rem;
}

.production-name-cell strong,
.production-media-cell strong {
    display: block;
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.production-name-cell span,
.production-media-cell span {
    display: -webkit-box;
    overflow: hidden;
    text-overflow: ellipsis;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    max-width: 168px;
    font-size: 0.62rem !important;
    line-height: 1.25;
}

.production-name-cell {
    width: 210px;
}

.production-media-cell {
    width: 165px;
    max-width: 165px;
}

.production-color-dot {
    display: inline-block !important;
    width: 18px;
    height: 18px;
    border-radius: 5px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    margin: 0 8px 0 0 !important;
    vertical-align: middle;
}

.production-actions-col {
    width: 90px;
    min-width: 90px;
    text-align: center !important;
    vertical-align: middle;
}

.production-row-actions {
    display: none;
    justify-content: center;
    gap: 5px;
    white-space: nowrap;
}

.production-table tbody tr:hover .production-row-actions {
    display: flex;
}

.production-row-placeholder {
    display: block;
    color: var(--text-muted);
    font-size: 0.78rem;
}

.production-table tbody tr:hover .production-row-placeholder {
    display: none;
}

.production-hover-btn {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: var(--text-primary);
    border-radius: 6px;
    padding: 3px 6px;
    cursor: pointer;
    font-size: 0.64rem;
    font-weight: 700;
    transition: all 0.2s ease;
}

.production-hover-btn.edit:hover {
    background: rgba(250, 204, 21, 0.18);
    border-color: rgba(250, 204, 21, 0.4);
    color: #fff7cc;
}

.production-hover-btn.del:hover {
    background: rgba(239, 68, 68, 0.18);
    border-color: rgba(239, 68, 68, 0.4);
    color: #fecaca;
}

.production-empty-row {
    text-align: center !important;
    color: var(--text-muted);
    padding: 26px !important;
}

.production-empty-card {
    display: flex;
    flex-direction: column;
    gap: 8px;
    color: var(--text-secondary);
}

.production-empty-card strong {
    color: var(--text-primary);
    font-size: 1.1rem;
}

.production-add-btn {
    width: auto;
    height: 46px;
    padding: 0 22px;
    color: white;
}

.production-muted {
    color: var(--text-muted) !important;
}

.catalog-modal-card {
    position: relative;
    width: min(520px, calc(100vw - 42px));
    max-height: calc(100vh - 48px);
    overflow: auto;
    text-align: start;
    align-items: stretch;
    gap: 14px;
    padding: 22px;
}

.catalog-modal-card h3 {
    font-size: 1.08rem;
    font-weight: 800;
}

.catalog-modal-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.catalog-modal-grid label,
.catalog-modal-wide {
    display: flex;
    flex-direction: column;
    gap: 6px;
    color: var(--text-secondary);
    font-size: 0.69rem;
    font-weight: 700;
}

.catalog-modal-grid input,
.catalog-modal-wide textarea {
    width: 100%;
    background: rgba(0, 0, 0, 0.32);
    border: 1px solid var(--panel-border);
    color: var(--text-primary);
    padding: 10px 11px;
    border-radius: 10px;
    outline: none;
    font-family: inherit;
    font-size: 0.78rem;
}

.catalog-modal-wide textarea {
    min-height: 76px;
    resize: vertical;
}

.catalog-modal-check {
    justify-content: flex-start;
    flex-direction: row !important;
    align-items: center;
    gap: 8px;
}

.catalog-modal-check input {
    width: auto;
}

.catalog-stock-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 10px;
    background: rgba(0, 0, 0, 0.22);
    padding: 14px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.catalog-stock-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.catalog-stock-item label {
    color: #27a1ff;
    font-size: 0.92rem;
    font-weight: 800;
}

.catalog-stock-item input {
    width: 100%;
    text-align: center;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.22);
    color: var(--text-primary);
    border-radius: 6px;
    padding: 7px 6px;
    font-size: 0.76rem;
    font-family: inherit;
    outline: none;
}

.catalog-stock-total {
    margin-top: 8px;
    text-align: right;
    color: var(--text-primary);
    font-size: 0.82rem;
    font-weight: 800;
}

.catalog-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.catalog-modal-actions button {
    min-width: 150px;
    height: 44px;
}

.production-media-upload-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.production-media-file-input {
    display: none;
}

.production-media-upload-btn {
    width: auto;
    min-width: 0 !important;
    padding: 0 16px;
    font-size: 0.82rem;
}

.production-media-upload-note {
    color: var(--text-secondary);
    font-size: 0.74rem;
}

/* ── Color Picker ── */
.color-picker-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.color-picker-select {
    flex: 1;
    background: rgba(0, 0, 0, 0.32);
    border: 1px solid var(--panel-border);
    color: var(--text-primary);
    padding: 10px 11px;
    border-radius: 10px;
    outline: none;
    font-family: inherit;
    font-size: 0.78rem;
    cursor: pointer;
}

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

.color-picker-add-btn {
    width: auto;
    min-width: 0 !important;
    padding: 0 16px;
    font-size: 0.82rem;
    white-space: nowrap;
}

.color-tags-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 10px;
    min-height: 32px;
}

.color-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    padding: 4px 10px 4px 6px;
    border-radius: 20px;
    font-size: 0.76rem;
    color: var(--text-primary);
    font-weight: 600;
}

.color-tag-swatch {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--color-swatch, #888);
    border: 1px solid rgba(255, 255, 255, 0.25);
    flex-shrink: 0;
}

.color-tag-remove {
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    opacity: 0.6;
    padding: 0 2px;
}

.color-tag-remove:hover {
    opacity: 1;
    color: #ff5252;
}

/* ── Per-Color Stock Table ── */
.color-stock-table {
    background: rgba(0, 0, 0, 0.22);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    overflow: hidden;
}

.color-stock-header,
.color-stock-row,
.color-stock-footer {
    display: grid;
    grid-template-columns: 1.5fr repeat(5, 1fr) 0.8fr;
    gap: 0;
    align-items: center;
    padding: 8px 12px;
}

.color-stock-header {
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-secondary);
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.color-stock-row {
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    font-size: 0.76rem;
}

.color-stock-row:last-child {
    border-bottom: none;
}

.color-stock-row .color-stock-col-color {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
    font-size: 0.78rem;
}

.color-stock-row .color-stock-col-color .color-tag-swatch {
    width: 12px;
    height: 12px;
}

.color-stock-footer {
    background: rgba(39, 161, 255, 0.08);
    border-top: 1px solid rgba(39, 161, 255, 0.15);
    font-size: 0.78rem;
    font-weight: 700;
}

.color-stock-col-size input {
    width: 100%;
    max-width: 65px;
    text-align: center;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: var(--text-primary);
    border-radius: 6px;
    padding: 5px 4px;
    font-size: 0.76rem;
    font-family: inherit;
    outline: none;
}

.color-stock-col-size input:focus {
    border-color: #27a1ff;
}

.color-stock-col-total {
    text-align: center;
    font-weight: 700;
    color: #27a1ff;
}

.production-media-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 8px;
}

.production-media-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.22);
}

.production-media-kind-btn {
    min-width: 56px;
    text-align: center;
    border-radius: 999px;
    padding: 2px 8px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    color: var(--text-secondary);
    font-size: 0.64rem;
    text-transform: uppercase;
    background: transparent;
    cursor: pointer;
}

.production-media-kind-btn:hover {
    color: #9cc9ff;
    border-color: #4d79c7;
}

.production-media-name-btn {
    flex: 1;
    min-width: 0;
    font-size: 0.72rem;
    color: var(--text-primary);
    background: transparent;
    border: none;
    text-align: left;
    padding: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: pointer;
}

.production-media-name-btn:hover {
    color: #9cc9ff;
    text-decoration: underline;
}

.production-media-actions {
    display: flex;
    gap: 6px;
}

.production-media-btn {
    padding: 3px 7px;
    font-size: 0.68rem;
    border-radius: 6px;
    cursor: pointer;
    color: var(--text-primary);
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.06);
    transition: all 0.2s ease;
}

.production-media-btn:hover,
.production-media-btn.primary {
    background: rgba(250, 204, 21, 0.18);
    border-color: rgba(250, 204, 21, 0.35);
    color: #fff7cc;
}

.production-media-btn.del:hover {
    background: rgba(239, 68, 68, 0.18);
    border-color: rgba(239, 68, 68, 0.35);
    color: #fecaca;
}

.production-media-empty {
    font-size: 0.76rem;
    color: var(--text-muted);
    padding: 10px 0 2px;
}

.production-media-preview-card {
    width: min(980px, calc(100vw - 44px));
    max-height: calc(100vh - 44px);
    padding: 0;
    overflow: hidden;
    align-items: stretch;
    gap: 0;
}

.production-media-preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 18px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.production-media-preview-header h3 {
    font-size: 1rem;
    line-height: 1.35;
    word-break: break-word;
}

/* Unified headless close (X) button for all popups — hover turns red */
.modal-close-x {
    background: transparent !important;
    border: none !important;
    color: var(--text-muted) !important;
    cursor: pointer;
    font-size: 1.4rem !important;
    line-height: 1;
    padding: 4px 10px !important;
    border-radius: 8px;
    transition: color 0.18s, background 0.18s;
}
.modal-close-x:hover {
    color: #ef4444 !important;
    background: rgba(239, 68, 68, 0.12) !important;
}

.close-btn {
    position: absolute;
    top: 14px;
    right: 16px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.6rem;
    line-height: 1;
    cursor: pointer;
    z-index: 5;
    transition: color 0.18s, background 0.18s;
}
.close-btn:hover {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.12);
}

/* Generic fixed modal overlay (used by customer-edit-modal) */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.65);
    z-index: 1000;
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    padding: 16px;
    box-sizing: border-box;
}

.modal-content {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 24px;
    width: 100%;
    max-width: 440px;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.4);
    position: relative;
}

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

.modal-header h2 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-main);
}

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

.production-media-preview-close {
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 1.8rem;
    line-height: 1;
    cursor: pointer;
    transition: color 0.18s, background 0.18s;
}

.production-media-preview-close:hover {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.12);
}

.production-media-preview-body {
    padding: 18px;
}

.production-media-preview-host {
    width: 100%;
    min-height: 280px;
    height: min(72vh, calc(100vh - 220px));
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 14px;
    overflow: auto;
    overscroll-behavior: contain;
    position: relative;
}

.production-media-preview-stage {
    min-width: 100%;
    min-height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px;
    box-sizing: border-box;
}

.production-media-preview-host img {
    display: block;
    width: auto;
    height: auto;
    max-width: none;
    max-height: none;
    background: #06080e;
    user-select: none;
    -webkit-user-drag: none;
}

.production-media-preview-host video {
    display: block;
    max-width: 100%;
    max-height: 72vh;
    object-fit: contain;
    background: #06080e;
}

.production-media-preview-empty {
    padding: 24px;
    color: var(--text-secondary);
    font-size: 0.82rem;
    text-align: center;
}

@media (max-width: 780px) {
    .production-panel {
        padding: 16px;
    }

    .production-panel-header,
    .catalog-modal-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .catalog-modal-actions {
        padding-bottom: calc(70px + env(safe-area-inset-bottom, 0px));
    }

    #sheets-options-content > div:first-child {
        grid-template-columns: 1fr !important;
    }
    #sheets-auto-interval {
        width: 100%;
        max-width: 100%;
    }

    .catalog-modal-grid {
        grid-template-columns: 1fr;
    }

    .catalog-stock-grid {
        grid-template-columns: repeat(auto-fit, minmax(62px, 1fr));
    }

    .production-media-row {
        flex-wrap: wrap;
    }

    .production-media-actions {
        width: 100%;
        justify-content: flex-end;
    }
}

/* Intelligence Sidebar */
.intelligence-sidebar {
    width: 320px;
    background: linear-gradient(180deg, var(--panel-bg) 0%, rgba(10, 11, 16, 0.95) 100%);
    border-left: 1px solid var(--panel-border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex-shrink: 0;
    transition: width 0.3s ease;
}

.intel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    border-bottom: 1px solid var(--panel-border);
    background: rgba(0,0,0,0.2);
}

.intel-header h3 {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.intel-close-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}

.intel-close-btn:hover {
    color: var(--text-primary);
    background: rgba(255,255,255,0.1);
}

.intel-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.intel-empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.intel-section {
    background: rgba(255,255,255,0.02);
    border: 1px solid rgba(255,255,255,0.05);
    border-radius: 12px;
    padding: 14px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.intel-section-title {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.intel-stat-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    margin-bottom: 8px;
    color: var(--text-secondary);
}

.intel-stat-row:last-child {
    margin-bottom: 0;
}

.intel-stat-row span:last-child {
    color: var(--text-primary);
    font-weight: 500;
}

.intel-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.intel-tag {
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 6px;
    padding: 4px 8px;
    font-size: 0.75rem;
    color: var(--text-primary);
}

.intel-tag.color-tag {
    background: rgba(236, 72, 153, 0.1);
    border-color: rgba(236, 72, 153, 0.3);
    color: #fbcfe8;
}

.intel-tag.style-tag {
    background: rgba(59, 130, 246, 0.1);
    border-color: rgba(59, 130, 246, 0.3);
    color: #bfdbfe;
}

.intel-owned-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.intel-owned-item {
    background: rgba(0,0,0,0.2);
    padding: 8px 10px;
    border-radius: 6px;
    border-left: 2px solid var(--accent);
}

.intel-owned-name {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.intel-owned-meta {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.intel-suggestion-card {
    background: linear-gradient(145deg, rgba(99, 102, 241, 0.1), rgba(139, 92, 246, 0.05));
    border: 1px solid rgba(139, 92, 246, 0.2);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 10px;
}

.intel-suggestion-card:last-child {
    margin-bottom: 0;
}

.intel-suggestion-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: #c4b5fd;
    margin-bottom: 4px;
}

.intel-suggestion-reason {
    font-size: 0.75rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

.intel-note-box {
    background: rgba(245, 158, 11, 0.05);
    border: 1px solid rgba(245, 158, 11, 0.2);
    border-radius: 6px;
    padding: 10px;
    font-size: 0.8rem;
    color: #fcd34d;
    line-height: 1.4;
    white-space: pre-wrap;
}

.intel-toggle-btn {
    background: rgba(99, 102, 241, 0.15);
    border: 1px solid rgba(99, 102, 241, 0.3);
    color: #c4b5fd;
    border-radius: 8px;
    padding: 6px 12px;
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.intel-toggle-btn:hover {
    background: rgba(99, 102, 241, 0.25);
    color: #ddd6fe;
}

/* Finance Modal Premium */
.finance-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.finance-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.finance-field label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 0.3px;
    text-transform: uppercase;
}

.finance-field input,
.finance-field select,
.finance-field textarea {
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 14px;
    color: var(--text-primary);
    font-size: 0.9rem;
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
    outline: none;
}

.finance-field input:focus,
.finance-field select:focus,
.finance-field textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.finance-field textarea {
    min-height: 80px;
    resize: vertical;
}

/* Premium modal action buttons */
.finance-form .btn {
    padding: 10px 20px;
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid var(--border);
    background: var(--panel-bg);
    color: var(--text-primary);
}

.finance-form .btn:hover {
    background: var(--surface-hover);
    border-color: var(--panel-border-hover);
}

.finance-form .btn.primary {
    background: linear-gradient(135deg, var(--accent), #e6b800);
    border: 1px solid var(--accent);
    color: #000;
    font-weight: 700;
    box-shadow: 0 4px 14px rgba(250, 204, 21, 0.3);
}

.finance-form .btn.primary:hover {
    box-shadow: 0 6px 20px rgba(250, 204, 21, 0.45);
    transform: translateY(-1px);
}

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

.mobile-sidebar-toggle {
    display: none;
}

.sidebar-overlay {
    display: none;
}

@media (max-width: 768px) {
    body.keyboard-open {
        position: fixed !important;
        width: 100% !important;
        height: 100% !important;
        overflow: hidden !important;
    }
    .mobile-sidebar-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 36px;
        height: 36px;
        background: transparent;
        border: none;
        color: var(--text-primary);
        cursor: pointer;
        margin-inline-end: 8px;
        border-radius: 8px;
        transition: background 0.2s;
    }
    .mobile-sidebar-toggle:hover {
        background: rgba(255,255,255,0.05);
    }
    .mobile-sidebar-toggle svg {
        width: 22px;
        height: 22px;
        stroke: currentColor;
        fill: none;
        stroke-width: 2;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        z-index: 1000;
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4,0,0.2,1);
        width: 280px;
        overflow-y: auto;
    }
    .sidebar .sidebar-nav {
        flex: 1;
        overflow-y: auto;
        min-height: 0;
    }
    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-overlay {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.5);
        z-index: 999;
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s ease;
    }
    .sidebar-overlay.open {
        opacity: 1;
        visibility: visible;
    }

    body.rtl .sidebar {
        left: auto;
        right: 0;
        transform: translateX(100%);
    }
    body.rtl .sidebar.open {
        transform: translateX(0);
    }

    .main-area {
        width: 100%;
        margin-left: 0;
        padding-top: 56px; /* offset fixed top-bar */
    }

    .screen-container {
        padding: 2px 8px 60px;
        border-start-start-radius: 0;
        border-end-start-radius: 0;
    }

    .top-bar-controls .window-controls {
        display: none;
    }
    .top-bar-controls .status-badge {
        display: none;
    }

    .user-profile {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 4px 10px;
    }
    .user-info {
        display: flex;
        align-items: center;
        gap: 8px;
    }
    .user-name {
        display: none;
    }
    .user-avatar {
        display: flex;
        width: 32px;
        height: 32px;
        font-size: 0.9rem;
    }
    .logout-btn {
        font-size: 0.75rem;
        padding: 4px 10px;
        border-radius: 6px;
        background: rgba(255,255,255,0.08);
        cursor: pointer;
        color: var(--text-muted);
        font-weight: 600;
    }

    .sidebar-footer {
        display: none;
    }

    .mobile-lang-toggle {
        display: flex;
        align-items: center;
        gap: 2px;
        background: rgba(255,255,255,0.08);
        border-radius: 999px;
        padding: 2px;
    }
    .mobile-lang-toggle .mob-lang-btn {
        padding: 2px 7px;
        font-size: 0.62rem;
        min-height: 22px;
        border-radius: 999px;
        border: none;
        background: transparent;
        color: var(--text-muted);
        font-weight: 700;
        cursor: pointer;
    }
    .mobile-lang-toggle .mob-lang-btn.active {
        background: var(--accent);
        color: #111827;
    }
    .screen > .inner-tabs-bar {
        display: none;
    }

    .top-bar {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 400;
        height: 56px;
        padding: 0 12px;
    }

    /* Mobile top-bar: compact layout so long nav titles fit */
    .top-bar {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 500;   /* above intel overlay (450) and chat window (400) */
        height: 56px;
        padding: 0 10px 0 8px;
        gap: 6px;
    }
    .top-bar-title {
        font-size: 0.82rem !important;  /* smaller on mobile to fit long Arabic names */
        font-weight: 700;
        flex: 1;
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    body.rtl .top-bar-title {
        font-size: 0.78rem !important;
    }
    .mobile-lang-toggle {
        flex-shrink: 0;
    }
    .user-profile {
        padding: 3px 6px;
        gap: 4px;
        border: 1px solid rgba(239,68,68,0.2);
        background: transparent;
    }
    .logout-btn {
        padding: 3px 7px;
        font-size: 0.68rem;
    }

    .status-badge {
        display: none;
    }

    .inner-tabs-bar {
        overflow-x: auto;
        gap: 8px;
        padding-bottom: 6px;
        -webkit-overflow-scrolling: touch;
    }

    .inner-tab {
        white-space: nowrap;
        font-size: 0.75rem;
        padding: 7px 12px;
    }

    /* Bottom navigation for mobile inner tabs */
    .mobile-bottom-nav {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 100;
        background: rgba(11, 11, 19, 0.95);
        backdrop-filter: blur(12px);
        border-top: 1px solid var(--panel-border);
        padding: 6px 0 env(safe-area-inset-bottom, 6px) 0;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        gap: 2px;
    }
    .mobile-bottom-nav .inner-tab {
        flex: none;
        text-align: center;
        justify-content: center;
        flex-direction: column;
        gap: 3px;
        padding: 10px 14px;
        font-size: 0.75rem;
        font-weight: 700;
        border-radius: 0;
        border: none;
        background: transparent;
        color: var(--text-muted);
        white-space: nowrap;
        position: relative;
    }
    .mobile-bottom-nav .inner-tab.active {
        color: var(--accent);
        background: rgba(250, 204, 21, 0.13);
        border-radius: 8px;
        box-shadow: 0 0 0 1.5px rgba(250, 204, 21, 0.35);
    }
    .mobile-bottom-nav .inner-tab .tab-badge {
        font-size: 0.6rem;
        min-width: 16px;
        height: 16px;
        padding: 0 4px;
        border-radius: 999px;
        background: var(--accent);
        color: #111827;
        font-weight: 800;
        display: none;
        align-items: center;
        justify-content: center;
        position: absolute;
        top: 0;
        right: 4px;
        transform: translateY(-2px);
        box-shadow: 0 4px 10px rgba(250, 204, 21, 0.3);
        z-index: 2;
    }
    .mobile-bottom-nav .inner-tab .tab-badge.visible {
        display: flex;
    }
    body.rtl .mobile-bottom-nav .inner-tab .tab-badge {
        right: auto;
        left: 4px;
    }

    .screen {
        padding-bottom: 80px;
    }

    .metrics-grid {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    /* Mobile inbox: WhatsApp-style full screen views */
    .inbox-platforms-header {
        display: none;
    }
    .mobile-inbox-nav {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 200;
        background: rgba(11, 11, 19, 0.97);
        backdrop-filter: blur(14px);
        border-top: 1px solid var(--panel-border);
        padding: 8px 0 calc(8px + env(safe-area-inset-bottom, 0px)) 0;
        justify-content: space-around;
    }
    .mobile-inbox-nav .mob-inav-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 4px;
        padding: 4px 6px;
        cursor: pointer;
        color: var(--text-muted);
        font-size: 0.62rem;
        font-weight: 600;
        background: transparent;
        border: none;
        transition: color 0.2s;
        min-width: 0;
        flex: 1;
        max-width: 64px;
        position: relative;
    }
    .mobile-inbox-nav .mob-inav-item.active {
        color: var(--accent);
        background: rgba(250, 204, 21, 0.12);
        border-radius: 10px;
        box-shadow: 0 0 0 1.5px rgba(250, 204, 21, 0.35);
    }
    .mobile-inbox-nav .mob-inav-item[data-platform="all"] .mob-inav-svg {
        stroke: var(--accent);
    }
    .mobile-inbox-nav .mob-inav-item.active .mob-inav-label {
        color: var(--accent);
    }
    .mobile-inbox-nav .mob-inav-item .mob-inav-icon,
    .mobile-inbox-nav .mob-inav-item .mob-inav-svg {
        width: 26px;
        height: 26px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    .mobile-inbox-nav .mob-inav-item .mob-inav-svg {
        fill: none;
        stroke: currentColor;
        stroke-width: 2;
        stroke-linecap: round;
        stroke-linejoin: round;
    }
    .mobile-inbox-nav .mob-inav-item .mob-inav-label {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 100%;
        line-height: 1.1;
    }
    .mobile-inbox-nav .mob-inav-item .mob-inav-badge {
        font-size: 0.55rem;
        min-width: 14px;
        height: 14px;
        padding: 0 4px;
        border-radius: 999px;
        background: var(--accent);
        color: #111827;
        font-weight: 800;
        display: none;
        align-items: center;
        justify-content: center;
        position: absolute;
        top: 0;
        right: 4px;
    }

    .inbox-layout {
        height: 100% !important;  /* override inline calc(100vh-160px) */
        display: flex;
        flex-direction: column;
    }

    /* On mobile, chat list fills screen when no active conversation */
    .inbox-sidebar {
        width: 100% !important;
        height: 100% !important;
        max-height: none !important;
    }

    .inbox-sidebar .chat-list {
        /* pad bottom = platform nav height + safe-area */
        padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px));
    }

    .chat-window {
        width: 100% !important;
        border-radius: 0;
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        height: 100vh;
        height: 100dvh; /* ponytail: dvh tracks real visible viewport on iOS/Android */
        overflow: hidden !important;
        z-index: 300;
        background: var(--bg, #000);
    }
    .chat-window.mobile-full {
        display: flex;
        flex-direction: column;
        /* Lift the entire chat window up by the approximate height of the iOS URL bar */
        padding-bottom: calc(65px + env(safe-area-inset-bottom, 0px));
    }
    body.keyboard-open .chat-window.mobile-full {
        padding-bottom: 0 !important;
    }
    .chat-window.mobile-full .chat-window-header {
        flex-shrink: 0;
        height: 56px;
        border-bottom: 1px solid var(--panel-border);
        background: rgba(11,11,19,0.97);
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
        padding: 0 12px;
    }
    .chat-window.mobile-full .chat-feed {
        flex: 1;
        overflow-y: auto;
        padding: 8px;
        padding-bottom: 8px;
    }
    /* Composer stays at bottom of the fixed chat-window via flex layout.
       Using flex-shrink:0 inside the already position:fixed chat-window
       avoids the iOS Safari gap that position:fixed;bottom:0 causes. */
    .chat-window.mobile-full .chat-composer {
        flex-shrink: 0;
        padding: 8px;
        height: auto;
        min-height: 56px;
        box-sizing: border-box;
        background: rgba(11,11,19,0.97);
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
        border-top: 1px solid var(--panel-border);
        display: flex;
        align-items: center;
        gap: 8px;
    }

    .chat-window-header .mobile-chat-back {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 36px;
        height: 36px;
        background: transparent;
        border: none;
        color: var(--text-primary);
        cursor: pointer;
        margin-inline-end: 4px;
        border-radius: 50%;
    }
    .chat-window-header .mobile-chat-back:hover {
        background: rgba(255,255,255,0.08);
    }
    .chat-window-header .mobile-chat-back svg {
        width: 22px;
        height: 22px;
        stroke: currentColor;
        fill: none;
        stroke-width: 2;
    }

    .chat-feed {
        flex: 1;
        overflow-y: auto;
        padding: 8px;
    }
    .message-bubble {
        max-width: 85%;
        padding: 10px 14px;
        font-size: 0.85rem;
    }

    /* Composer: hidden in list mode */
    .chat-window:not(.mobile-full) .chat-composer {
        display: none;
    }
    .chat-window-header {
        height: 56px;
        padding: 0 12px;
    }

    /* Full-screen chat list when platform filter is selected */
    .inbox-sidebar.mobile-full-list {
        height: 100% !important;
        max-height: none !important;
    }

    /* Mobile language toggle in top bar */
    .mobile-lang-toggle {
        display: flex;
        align-items: center;
        gap: 4px;
        background: rgba(255,255,255,0.06);
        border-radius: 999px;
        padding: 3px;
    }
    .mobile-lang-toggle .mob-lang-btn {
        background: transparent;
        border: none;
        color: var(--text-muted);
        font-size: 0.7rem;
        font-weight: 700;
        padding: 4px 8px;
        border-radius: 999px;
        cursor: pointer;
        line-height: 1;
    }
    .mobile-lang-toggle .mob-lang-btn.active {
        background: var(--accent);
        color: #111827;
    }

    .chat-list-header-back {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 8px 12px;
        border-bottom: 1px solid var(--panel-border);
        font-weight: 600;
        font-size: 1rem;
    }
    .chat-list-header-back button {
        background: transparent;
        border: none;
        color: var(--text-primary);
        cursor: pointer;
        padding: 4px 6px;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    .chat-list-header-back button:hover {
        background: rgba(255,255,255,0.08);
    }
    /* Back arrow: flip in RTL (Arabic) */
    body.rtl .mobile-chat-back svg {
        transform: scaleX(-1);
    }

    /* Customer Intel full-screen overlay: starts BELOW the fixed navbar */
    .intel-fullscreen-overlay {
        display: none;
        position: fixed;
        top: 56px;      /* below navbar */
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 450;   /* above content but below navbar (navbar is 400) */
        background: var(--bg-dark);
        flex-direction: column;
        overflow: hidden;
        animation: intelSlideIn 0.25s cubic-bezier(0.16,1,0.3,1) forwards;
    }
    @keyframes intelSlideIn {
        from { transform: translateX(100%); opacity: 0.8; }
        to   { transform: translateX(0);   opacity: 1;   }
    }
    body.rtl .intel-fullscreen-overlay {
        animation-name: intelSlideInRtl;
    }
    @keyframes intelSlideInRtl {
        from { transform: translateX(-100%); opacity: 0.8; }
        to   { transform: translateX(0);    opacity: 1;   }
    }
    .intel-fullscreen-overlay.open {
        display: flex;
    }
    .intel-fullscreen-header {
        display: flex;
        align-items: center;
        gap: 10px;
        height: 56px;
        padding: 0 12px;
        background: rgba(11,11,19,0.97);
        backdrop-filter: blur(12px);
        border-bottom: 1px solid var(--panel-border);
        flex-shrink: 0;
    }
    .intel-fullscreen-back {
        background: transparent;
        border: none;
        color: var(--text-primary);
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        width: 36px;
        height: 36px;
        border-radius: 50%;
    }
    .intel-fullscreen-back svg {
        width: 22px; height: 22px;
        stroke: currentColor; fill: none; stroke-width: 2;
    }
    body.rtl .intel-fullscreen-back svg {
        transform: scaleX(-1);
    }
    .intel-fullscreen-title {
        font-size: 1rem;
        font-weight: 700;
        color: var(--text-primary);
        flex: 1;
    }
    .intel-fullscreen-body {
        flex: 1;
        overflow-y: auto;
        padding: 16px;
        display: flex;
        flex-direction: column;
        gap: 16px;
    }

    .insights-row {
        flex-direction: column;
    }

    .login-wrap {
        padding: 16px;
    }
    .login-card {
        padding: 24px;
        width: 100%;
    }

    #app-container {
        padding-bottom: 48px;
    }
}

/* Dynamic viewport height for mobile (keyboard-aware) */
@supports (height: 100dvh) {
    body, .app-container, .main-area, #app-container { height: 100dvh; }
    .chat-window.mobile-full { height: 100dvh; }
}

/* Viewport meta enforcement: no zoom on iOS when tapping inputs */
@media (max-width: 768px) {
    input, textarea, select {
        font-size: 16px !important;
        /* iOS won't zoom if font-size >= 16px */
    }

    /* Image save: allow long-press context menu on images in mobile chat */
    .message-media img,
    .order-card-thumb,
    .image-modal-img {
        -webkit-touch-callout: default !important; /* allow iOS save/copy menu */
        pointer-events: auto;
    }
}

/* Tablet intermediate */
@media (min-width: 769px) and (max-width: 1024px) {
    .sidebar {
        width: 220px;
    }
    .screen-container {
        padding: 16px;
    }
    .metrics-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Optimistic message loading spinner */
.optimistic-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    min-height: 80px;
}
.optimistic-loading .spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--panel-border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: optimisticSpin 0.7s linear infinite;
}
@keyframes optimisticSpin {
    to { transform: rotate(360deg); }
}
.message-bubble.optimistic {
    opacity: 0.85;
}
