/* ============================================================================
   Ksymena Dashboard - Styles
   Elegant, practical light theme with warm accents
   ============================================================================ */

:root {
    /* Colors (Dark Mode - default when data-theme is not "light") */
    --bg-primary: #15120f;
    --bg-secondary: #1d1915;
    --bg-tertiary: #241f1a;
    --bg-card: #1a1612;
    --bg-hover: #2a241e;
    
    --text-primary: #f6f2ed;
    --text-secondary: #c2bbb1;
    --text-muted: #8e857a;
    
    --accent-primary: #e6c175;
    --accent-secondary: #8e857a;
    --accent-glow: rgba(230, 193, 117, 0.25);
    
    --success: #22c55e;
    --warning: #eab308;
    --error: #ef4444;
    --info: #0ea5e9;
    
    --border-color: #3a322a;
    --border-light: #4a4137;
    
    /* Typography */
    --font-main: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'IBM Plex Mono', monospace;
    --font-email: 'Open Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --font-email-size: 16px;
    
    /* Spacing */
    --sidebar-width: 260px;
    --header-height: 80px;
    
    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.55);
    --shadow-glow: 0 0 40px var(--accent-glow);
}

/* Light Mode Theme */
[data-theme="light"] {
    --bg-primary: #faf8f5;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f3eee8;
    --bg-card: #ffffff;
    --bg-hover: #f0ebe4;
    
    --text-primary: #1f1a15;
    --text-secondary: #4e463d;
    --text-muted: #8e857a;
    
    --accent-primary: #e6c175;
    --accent-secondary: #8e857a;
    --accent-glow: rgba(230, 193, 117, 0.18);
    
    --border-color: #e6ded3;
    --border-light: #d8d0c6;
    
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 6px 16px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 12px 34px rgba(0, 0, 0, 0.12);
    --shadow-glow: 0 0 40px var(--accent-glow);
}

/* Theme transition for smooth switching */
body, .sidebar, .main-content, .card, .modal-content, .btn, input, select, textarea, table {
    transition: background-color var(--transition-normal), 
                color var(--transition-normal), 
                border-color var(--transition-normal),
                box-shadow var(--transition-normal);
}

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

html {
    font-size: 16px;
}

body {
    font-family: var(--font-main);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

/* ============================================================================
   Toasts
   ========================================================================== */

#toast-container {
  position: fixed;
  right: 16px;
  bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 99999;
  pointer-events: none;
}

.toast {
  min-width: 220px;
  max-width: 360px;
  background: rgba(20, 20, 20, 0.92);
  color: #fff;
  padding: 10px 12px;
  border-radius: 10px;
  box-shadow: 0 12px 30px rgba(0,0,0,0.25);
  font-size: 13px;
  line-height: 1.3;
  transform: translateY(8px);
  opacity: 0;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.toast-show {
  transform: translateY(0);
  opacity: 1;
}

.toast-success { border-left: 4px solid #2ecc71; }
.toast-error   { border-left: 4px solid #e74c3c; }
.toast-warning { border-left: 4px solid #f1c40f; }
.toast-info    { border-left: 4px solid #3498db; }

/* Utility Classes */
.hidden {
    display: none !important;
}

/* ============================================================================
   Login Screen
   ============================================================================ */

.login-screen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: 
        radial-gradient(ellipse at 30% 20%, rgba(230, 193, 117, 0.12) 0%, transparent 50%),
        radial-gradient(ellipse at 70% 80%, rgba(230, 193, 117, 0.08) 0%, transparent 50%),
        linear-gradient(180deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
    padding: 2rem;
}

.login-container {
    width: 100%;
    max-width: 420px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 3rem;
    box-shadow: var(--shadow-lg);
}

.login-header {
    text-align: center;
    margin-bottom: 2.5rem;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.logo-img {
    height: 44px;
    width: auto;
    display: block;
    filter: drop-shadow(0 0 10px var(--accent-glow));
}

.logo-icon {
    font-size: 2rem;
    filter: drop-shadow(0 0 10px var(--accent-glow));
}

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

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

.login-form {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-group input {
    padding: 0.875rem 1rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 1rem;
    transition: var(--transition-fast);
}

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

.error-message {
    color: var(--error);
    font-size: 0.875rem;
    text-align: center;
    min-height: 1.5rem;
}

/* ============================================================================
   Buttons
   ============================================================================ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.875rem 1.5rem;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 500;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: var(--transition-fast);
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    color: #0c1220;
    box-shadow: 0 4px 16px var(--accent-glow);
}

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

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

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

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

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

.btn-block {
    width: 100%;
}

.btn-arrow {
    transition: transform var(--transition-fast);
}

.btn:hover .btn-arrow {
    transform: translateX(4px);
}

/* ============================================================================
   Dashboard Layout
   ============================================================================ */

.dashboard {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 100;
}

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

.sidebar-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.sidebar-collapse-btn {
    padding: 0.5rem;
    width: 42px;
    height: 42px;
    justify-content: center;
}

.sidebar-header .logo {
    justify-content: flex-start;
    margin-bottom: 0;
}

.sidebar-header .logo-img {
    height: 28px;
}

.sidebar-nav {
    flex: 1;
    padding: 1rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 10px;
    transition: var(--transition-fast);
}

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

.nav-item.active {
    background: linear-gradient(135deg, rgba(230, 193, 117, 0.15), rgba(230, 193, 117, 0.08));
    color: var(--accent-primary);
    border: 1px solid rgba(230, 193, 117, 0.3);
}

.nav-item {
    position: relative;
}

.nav-icon {
    font-size: 1.25rem;
    width: 1.5rem;
    text-align: center;
}

.nav-label {
    font-weight: 500;
}

.nav-badge {
    margin-left: auto;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    background: var(--error);
    border: 1px solid rgba(0, 0, 0, 0.25);
    color: #ffffff;
    font-size: 0.75rem;
    font-weight: 700;
}

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

/* Main Content */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 2rem;
    min-height: 100vh;
}

/* Sidebar manual collapse (desktop) */
body.sidebar-collapsed .sidebar {
    width: 80px;
}

body.sidebar-collapsed .sidebar-header-row {
    flex-direction: column;
    justify-content: center;
}

body.sidebar-collapsed .sidebar-header .logo {
    display: none;
}

body.sidebar-collapsed .nav-label,
body.sidebar-collapsed .sidebar-footer span:not(.nav-icon) {
    display: none;
}

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

body.sidebar-collapsed .nav-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    margin-left: 0;
    min-width: 20px;
    height: 18px;
    padding: 0 5px;
    font-size: 0.7rem;
}

body.sidebar-collapsed .main-content {
    margin-left: 80px;
}

/* ============================================================================
   Views
   ============================================================================ */

.view {
    display: none;
    animation: fadeIn 0.3s ease;
}

.view.active {
    display: block;
}

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

.view-header {
    margin-bottom: 2rem;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.view-header h1 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
    color: var(--text-primary);
}

.view-subtitle {
    color: var(--text-secondary);
}

.view-actions {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.view-actions select {
    padding: 0.75rem 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.875rem;
}

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

/* ============================================================================
   Stats Grid
   ============================================================================ */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2.5rem;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 1.5rem;
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    transition: var(--transition-normal);
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
}

.stat-card.highlight {
    background: linear-gradient(135deg, rgba(230, 193, 117, 0.1), rgba(230, 193, 117, 0.03));
    border-color: rgba(230, 193, 117, 0.3);
}

.stat-icon {
    font-size: 2rem;
    padding: 0.75rem;
    background: var(--bg-tertiary);
    border-radius: 10px;
}

.stat-content {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    font-family: var(--font-mono);
    color: var(--text-primary);
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* ============================================================================
   Status Grid
   ============================================================================ */

.status-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2.5rem;
}

.status-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 1.5rem;
}

.status-card h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.status-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

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

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

.status-item .status-name {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
}

.status-item .status-count {
    font-family: var(--font-mono);
    font-weight: 600;
    color: var(--text-primary);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.status-dot.pending { background: var(--warning); }
.status-dot.processing { background: var(--info); }
.status-dot.on-hold { background: var(--text-muted); }
.status-dot.completed { background: var(--success); }
.status-dot.cancelled { background: var(--error); }
.status-dot.refunded { background: #a855f7; }
.status-dot.failed { background: var(--error); }

/* ============================================================================
   Tables
   ============================================================================ */

.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 1.25rem;
}

.table-container {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    overflow: hidden;
}

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

thead {
    background: var(--bg-tertiary);
}

th {
    padding: 1rem 1.25rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
}

td {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.95rem;
}

tr:last-child td {
    border-bottom: none;
}

tbody tr {
    transition: background var(--transition-fast);
}

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

.clickable-row {
    cursor: pointer;
}

.row-selected {
    background: rgba(230, 193, 117, 0.08);
}

.amount {
    font-family: var(--font-mono);
    font-weight: 500;
}

.amount.positive {
    color: var(--success);
}

/* ============================================================================
   Filters
   ============================================================================ */

.filters {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.search-box {
    position: relative;
    flex: 1;
    min-width: 280px;
}

.search-box input {
    width: 100%;
    padding: 0.875rem 1rem 0.875rem 2.75rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.95rem;
    transition: var(--transition-fast);
}

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

.search-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1rem;
    color: var(--text-muted);
}

.filter-group {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.filter-group input[type="date"],
.filter-group select {
    padding: 0.75rem 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.875rem;
}

.filter-group input[type="date"]:focus,
.filter-group select:focus {
    outline: none;
    border-color: var(--accent-primary);
}

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

.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    padding: 1.5rem;
}

.pagination button {
    padding: 0.5rem 1rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.875rem;
    cursor: pointer;
    transition: var(--transition-fast);
}

.pagination button:hover:not(:disabled) {
    background: var(--bg-hover);
    color: var(--text-primary);
}

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

.pagination button.active {
    background: var(--accent-primary);
    color: #0c1220;
    border-color: var(--accent-primary);
}

.pagination-info {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin: 0 1rem;
}

/* ============================================================================
   Badges
   ============================================================================ */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-radius: 20px;
}

.badge-success {
    background: rgba(34, 197, 94, 0.15);
    color: var(--success);
}

.badge-warning {
    background: rgba(234, 179, 8, 0.15);
    color: var(--warning);
}

.badge-error {
    background: rgba(239, 68, 68, 0.15);
    color: var(--error);
}

.badge-info {
    background: rgba(14, 165, 233, 0.15);
    color: var(--info);
}

.badge-muted {
    background: rgba(100, 116, 139, 0.15);
    color: var(--text-muted);
}

/* Order status badges */
.badge-pending { background: rgba(234, 179, 8, 0.15); color: var(--warning); }
.badge-processing { background: rgba(14, 165, 233, 0.15); color: var(--info); }
.badge-on-hold { background: rgba(100, 116, 139, 0.15); color: var(--text-muted); }
.badge-completed { background: rgba(34, 197, 94, 0.15); color: var(--success); }
.badge-cancelled { background: rgba(239, 68, 68, 0.15); color: var(--error); }
.badge-refunded { background: rgba(168, 85, 247, 0.15); color: #a855f7; }
.badge-failed { background: rgba(239, 68, 68, 0.15); color: var(--error); }

/* ============================================================================
   Sync Section
   ============================================================================ */

.sync-status-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 1.5rem;
    margin-bottom: 2rem;
}

.sync-status-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
}

.sync-status-header h3 {
    font-size: 1.125rem;
    font-weight: 600;
}

.sync-info {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.sync-info-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.sync-info-item .label {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.sync-info-item .value {
    font-size: 1rem;
    color: var(--text-primary);
    font-weight: 500;
}

.sync-actions {
    display: flex;
    gap: 1rem;
}

.sync-logs-section {
    margin-top: 2rem;
}

.sync-logs-section h3 {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

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

.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    /* Prevent scroll chaining to the page behind modals */
    overscroll-behavior: contain;
}

.modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    overflow: hidden; /* ensure children (sidebar backgrounds, etc) don't break rounding */
    width: 100%;
    max-width: 900px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
    animation: modalIn 0.3s ease;
}

.modal-header {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 0;
    overscroll-behavior: contain;
}

/* Wide modal with sidebar */
.modal-content-wide {
    max-width: 1600px;
    width: 96vw;
    /* Use a definite height so nested flex/scroll regions work reliably (esp. stacked popups) */
    height: calc(100vh - 4rem);
    max-height: calc(100vh - 4rem);
}

.modal-body-with-sidebar {
    display: flex;
    gap: 0;
}

.modal-body-with-sidebar > .order-detail,
.modal-body-with-sidebar > .customer-detail {
    flex: 1;
    min-width: 0;
    padding: 1.5rem;
    overflow-y: auto;
}

.modal-body-with-sidebar > .deal-detail {
    flex: 1;
    min-width: 0;
    padding: 1.5rem;
    overflow-y: auto;
}

.modal-sidebar {
    width: 420px;
    flex-shrink: 0;
    background: var(--bg-tertiary);
    border-left: 1px solid var(--border-color);
    padding: 1rem;
    overflow-y: auto;
    max-height: calc(100vh - 4rem - 60px);
}

.modal-sidebar h4 {
    margin: 0 0 1rem 0;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
}

/* Deals modal: dual sidebars (Parts/Offer + Conversations/Notes) */
.form-detail {
    display: flex;
    flex-direction: column;
    min-height: 0;
}
.form-detail .deal-modal-layout {
    flex: 1;
    min-height: 0;
}
.form-detail .deal-sidebars {
    display: flex;
    flex-direction: row;
    flex-shrink: 0;
}
.form-detail .deal-sidebars .deal-sidebar-actions {
    width: clamp(380px, 32vw, 520px);
}
.form-detail .deal-sidebars .deal-sidebar-comms {
    width: clamp(320px, 26vw, 420px);
}
.form-detail .deal-action-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
}
.form-detail .deal-action-btn {
    width: 100%;
    justify-content: center;
    padding: 0.55rem 0.75rem;
    font-size: 0.85rem;
}
.form-detail .deal-action-row {
    display: flex;
    gap: 0.5rem;
}
.form-detail .deal-action-row .deal-action-btn {
    flex: 1;
    width: auto;
}

.inline-copy {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.inline-copy .btn.btn-sm {
    padding: 0.25rem 0.5rem;
}

@media (max-width: 1200px) {
    .form-detail .deal-sidebars {
        flex-direction: column;
        width: 420px;
    }
    .form-detail .deal-sidebars .modal-sidebar {
        width: 100% !important;
        max-height: calc(45vh - 20px);
    }
    .form-detail .deal-sidebars .deal-sidebar-comms {
        border-top: 1px solid var(--border-color);
    }
}

/* Segmented control */
.segmented {
    display: inline-flex;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    overflow: hidden;
    background: var(--bg-card);
}
.segmented-btn {
    padding: 0.45rem 0.75rem;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    font-weight: 600;
    font-size: 0.85rem;
}
.segmented-btn.active {
    background: var(--accent-primary);
    color: #111827;
}

/* Kanban */
.kanban-board {
    display: grid;
    grid-template-columns: repeat(6, minmax(140px, 1fr));
    gap: 12px;
    padding: 10px 0;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-gutter: stable both-edges;
    padding-bottom: 14px; /* keep horizontal scrollbar off the cards */
    -webkit-overflow-scrolling: touch;
}
.kanban-col {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    height: 70vh;
    overflow: hidden; /* Fix inner edges bleeding past rounded corners */
}
.kanban-col-header {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}
.kanban-col-title {
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--text-primary);
}
.kanban-col-actions {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.kanban-col-count {
    font-size: 0.8rem;
    color: var(--text-muted);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    padding: 2px 8px;
    border-radius: 999px;
}
.kanban-col-body {
    padding: 10px;
    overflow-y: auto;
    flex: 1;
    min-height: 0; /* Allow flex child to scroll instead of expanding */
}
.deal-card {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 10px;
    margin-bottom: 10px;
    cursor: pointer;
}
.deal-card:hover {
    border-color: rgba(234, 179, 8, 0.55);
}
.deal-card-top {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 6px;
}
.deal-card-plate {
    font-weight: 800;
    letter-spacing: 0.02em;
}
.deal-card-date {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
}
.deal-card-company {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}
.deal-card-meta {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
.logistics-card {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 10px;
    margin-bottom: 10px;
    cursor: pointer;
}
.logistics-card:hover {
    border-color: rgba(234, 179, 8, 0.55);
}
.logistics-card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
}
.logistics-card-title {
    font-weight: 800;
    letter-spacing: 0.02em;
}
.logistics-card-tracking {
    font-size: 0.75rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 999px;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    color: var(--text-secondary);
}
.logistics-card-tracking.logistics-tracking-complete {
    background: rgba(34, 197, 94, 0.18);
    border-color: rgba(34, 197, 94, 0.4);
    color: #22c55e;
}
.logistics-card-meta {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
.logistics-company-pill {
    font-size: 0.75rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 999px;
    border: 1px solid rgba(0, 0, 0, 0.15);
}
.logistics-pill {
    font-size: 0.75rem;
    padding: 2px 8px;
    border-radius: 999px;
    border: 1px solid var(--border-color);
}
.logistics-pill-muted {
    background: var(--bg-card);
    color: var(--text-secondary);
}
.logistics-pill-delivered {
    background: rgba(34, 197, 94, 0.18);
    border-color: rgba(34, 197, 94, 0.5);
    color: #22c55e;
    font-weight: 700;
}

/* Logistics detail modal */
.logistics-modal .modal-body {
    padding: 1.25rem;
}
#logistics-card-title {
    display: none;
}
.logistics-detail-grid {
    display: grid;
    grid-template-columns: minmax(0, 2.5fr) minmax(220px, 0.9fr);
    gap: 12px;
}
.logistics-detail-main {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.logistics-detail-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}
.logistics-detail-title {
    font-size: 1.45rem;
    font-weight: 800;
    margin-bottom: 4px;
}
.logistics-title-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.logistics-title-edit input {
    min-width: 220px;
    padding: 0.45rem 0.7rem;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 1rem;
}
.logistics-detail-subtitle {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.logistics-inline-field {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 999px;
    font-size: 0.7rem;
}
.logistics-inline-field span {
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.logistics-inline-field select {
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 0.8rem;
    font-weight: 600;
    padding: 0;
}
.logistics-inline-field select:focus {
    outline: none;
}
.logistics-inline-field select:disabled {
    opacity: 0.7;
}
.logistics-detail-tracking {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 6px 10px;
    text-align: right;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.logistics-detail-tracking-label {
    display: flex;
    align-items: center;
    gap: 6px;
    justify-content: flex-end;
}
.logistics-detail-section {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 10px;
}
.logistics-detail-section h4 {
    margin: 0;
    font-size: 0.85rem;
}
.logistics-detail-section > h4 {
    margin-bottom: 8px;
}
.logistics-section-header,
.logistics-detail-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
}
.logistics-section-actions {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.logistics-view-only {
    display: block;
}
.logistics-edit-only {
    display: block;
}
.logistics-section.is-editing .logistics-view-only {
    display: none;
}
.logistics-section:not(.is-editing) .logistics-edit-only {
    display: none;
}
.logistics-compact-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 6px 12px;
}
.logistics-compact-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 0.85rem;
}
.logistics-compact-item-wide {
    grid-column: span 2;
}
.logistics-compact-label {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
}
.logistics-compact-value {
    color: var(--text-primary);
    font-weight: 600;
}
.logistics-detail-fields {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 8px;
}
.logistics-detail-fields .span-2 {
    grid-column: span 2;
}
.logistics-detail-section .form-group {
    margin-bottom: 0;
}
.logistics-detail-section .form-group label {
    font-size: 0.7rem;
    margin-bottom: 0.35rem;
    letter-spacing: 0.04em;
}
.logistics-detail-section .form-group input,
.logistics-detail-section .form-group select {
    padding: 0.5rem 0.65rem;
    border-radius: 8px;
    font-size: 0.85rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    font-family: inherit;
}
.logistics-detail-section .form-group input[disabled],
.logistics-detail-section .form-group select[disabled] {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    opacity: 0.85;
}
.logistics-section:not(.is-editing) .logistics-field-optional[data-empty="true"] {
    display: none;
}
.logistics-detail-actions {
    display: flex;
    justify-content: flex-end;
}

.logistics-line-editor {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.logistics-line-row {
    display: grid;
    grid-template-columns: minmax(70px, 0.7fr) 60px minmax(0, 1.4fr) minmax(160px, 1fr) 30px;
    gap: 6px;
    align-items: center;
}
.logistics-line-cell {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.logistics-line-row input {
    min-width: 0;
    padding: 0.5rem 0.65rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.85rem;
    transition: var(--transition-fast);
}
.logistics-line-row input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-glow);
}
.logistics-line-row input:disabled {
    color: var(--text-secondary);
    opacity: 0.85;
    cursor: not-allowed;
}
.logistics-line-tracking {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}
.logistics-line-tracking-input {
    flex: 1;
    min-width: 0;
}
.logistics-line-delivered-btn,
.logistics-line-undelivered-btn {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--bg-tertiary);
    font-size: 0.9rem;
    cursor: pointer;
    transition: var(--transition-fast);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.logistics-line-delivered-btn:hover,
.logistics-line-undelivered-btn:hover {
    border-color: var(--accent-primary);
}
.logistics-line-delivered-btn.active {
    background: rgba(34, 197, 94, 0.18);
    border-color: rgba(34, 197, 94, 0.5);
}
.logistics-line-row[data-delivered="false"] .logistics-line-undelivered-btn {
    display: none;
}
.logistics-line-product {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.logistics-line-text {
    font-size: 0.8rem;
    color: var(--text-primary);
    font-weight: 600;
}
.logistics-line-link {
    font-size: 0.75rem;
    color: var(--accent-primary);
    text-decoration: none;
}
.logistics-line-link:hover {
    text-decoration: underline;
}
.logistics-section[data-section="products"]:not(.is-editing) .logistics-line-name-input {
    display: none;
}
.logistics-section[data-section="products"].is-editing .logistics-line-name-link {
    display: none;
}
.logistics-line-remove {
    width: 30px;
    height: 30px;
    padding: 0;
}
.logistics-section[data-section="products"]:not(.is-editing) #logistics-detail-add-line,
.logistics-section[data-section="products"]:not(.is-editing) .logistics-line-remove {
    display: none;
}
.logistics-section[data-section="products"]:not(.is-editing) .logistics-line-sku,
.logistics-section[data-section="products"]:not(.is-editing) .logistics-line-qty,
.logistics-section[data-section="products"]:not(.is-editing) .logistics-line-name-input {
    display: none;
}
.logistics-section[data-section="products"]:not(.is-editing) .logistics-line-text,
.logistics-section[data-section="products"]:not(.is-editing) .logistics-line-name-link {
    display: block;
}
.logistics-section[data-section="products"].is-editing .logistics-line-text,
.logistics-section[data-section="products"].is-editing .logistics-line-name-link {
    display: none;
}
.logistics-line-empty {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.logistics-label-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px dashed var(--border-color);
}
.logistics-label-row:last-child {
    border-bottom: none;
}
.logistics-label-title {
    font-weight: 700;
    margin-bottom: 4px;
}
.logistics-label-row.logistics-label-return.has-label {
    border-bottom-color: rgba(239, 68, 68, 0.35);
}
.logistics-label-row.logistics-label-return.has-label .logistics-label-title {
    color: var(--error);
}
.logistics-label-row.logistics-label-return.has-label .muted {
    color: rgba(239, 68, 68, 0.75);
}
.logistics-label-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}
.btn-download {
    background: #22c55e;
    border: 1px solid rgba(34, 197, 94, 0.6);
    color: #ffffff;
    font-weight: 700;
    padding: 0.45rem 0.9rem;
}
.btn-download:hover {
    background: #16a34a;
    border-color: #16a34a;
}

.logistics-detail-notes {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 65vh;
    overflow-y: auto;
}
.logistics-notes-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.logistics-note-item {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 8px;
}
.logistics-note-meta {
    display: flex;
    gap: 6px;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 6px;
}
.logistics-note-body {
    font-size: 0.85rem;
}
.logistics-note-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.logistics-note-form textarea {
    min-height: 70px;
    padding: 0.6rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.85rem;
}

.logistics-companies-settings {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 10px;
}
.logistics-company-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 90px auto;
    gap: 10px;
    align-items: center;
}
.logistics-company-row input[type="text"] {
    padding: 0.6rem 0.75rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.9rem;
}
.logistics-company-row input[type="color"] {
    width: 100%;
    height: 40px;
    padding: 0;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: var(--bg-tertiary);
}

@media (max-width: 1200px) {
    .logistics-detail-grid {
        grid-template-columns: 1fr;
    }
    .logistics-detail-notes {
        max-height: none;
    }
    .logistics-compact-item-wide {
        grid-column: span 1;
    }
}
@media (max-width: 900px) {
    .logistics-detail-fields .span-2 {
        grid-column: span 1;
    }
    .logistics-line-row {
        grid-template-columns: 1fr 1fr;
        grid-auto-rows: auto;
    }
    .logistics-line-row .logistics-line-cell,
    .logistics-line-row .logistics-line-product,
    .logistics-line-row .logistics-line-tracking {
        grid-column: span 1;
    }
    .logistics-line-row .logistics-line-tracking {
        grid-column: span 2;
    }
    .logistics-line-row .logistics-line-remove {
        grid-column: span 2;
        justify-self: flex-end;
    }
}

/* Inline Parts editor in Deal sidebar */
.deal-part-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr) 42px 42px 42px;
    gap: 8px;
    align-items: center;
    margin-bottom: 8px;
}
.deal-part-row input {
    min-width: 0;
    padding: 0.875rem 1rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.95rem;
    transition: var(--transition-fast);
}
.deal-part-row input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-glow);
}
.deal-part-row .btn-danger-inline {
    width: 42px;
    height: 42px;
}
.deal-part-row .btn-secondary-inline {
    width: 42px;
    height: 42px;
}
.deal-input-with-btn {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 42px;
    gap: 8px;
    align-items: center;
}

.deal-input-with-btn .btn-secondary-inline {
    width: 42px;
    height: 42px;
}

.deal-input-with-btn-2 {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 42px 42px;
    gap: 8px;
    align-items: center;
}

.deal-input-with-btn-2 input {
    min-width: 0;
}

.deal-input-with-btn-2 .btn-secondary-inline {
    width: 42px;
    height: 42px;
}
.deal-input-with-btn input {
    min-width: 0;
}
.btn-secondary-inline {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition-fast);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.btn-secondary-inline:hover {
    background: var(--bg-hover);
    border-color: var(--border-light);
}
.btn-danger-inline {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.35);
    color: rgba(239, 68, 68, 0.95);
    border-radius: 8px;
    width: 30px;
    height: 30px;
    cursor: pointer;
}
.btn-danger-inline:hover {
    background: rgba(239, 68, 68, 0.25);
}
.deal-pill {
    font-size: 0.75rem;
    padding: 2px 8px;
    border-radius: 999px;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-secondary);
}
.kanban-drop-hover {
    outline: 2px dashed rgba(234, 179, 8, 0.7);
    outline-offset: -2px;
}

.sidebar-conversations-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.sidebar-conversation-item {
    padding: 0.75rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition-fast);
}

.sidebar-conversation-item:hover {
    border-color: var(--accent-primary);
    background: var(--bg-secondary);
}

.sidebar-conversation-item .conv-subject {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-conversation-item .conv-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-conversation-item .conv-snippet {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-conversation-item .conv-unread {
    background: var(--accent-primary);
    color: white;
    font-size: 0.625rem;
    padding: 0.125rem 0.375rem;
    border-radius: 10px;
    font-weight: 600;
}

.sidebar-empty {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--text-muted);
    font-size: 0.875rem;
}

@media (max-width: 900px) {
    .modal-body-with-sidebar {
        flex-direction: column;
    }
    
    .modal-sidebar {
        width: 100%;
        border-left: none;
        border-top: 1px solid var(--border-color);
        max-height: 300px;
    }
}

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

.modal-close {
    width: 32px;
    height: 32px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 1.25rem;
    cursor: pointer;
    transition: var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

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

/* Detail Views */
.order-detail, .customer-detail, .shipment-detail {
    padding: 2rem;
}

.detail-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.detail-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.detail-subtitle {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

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

.detail-amount .value {
    font-size: 2rem;
    font-weight: 700;
    font-family: var(--font-mono);
    color: var(--accent-primary);
}

.detail-amount .label {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 2rem;
    margin-bottom: 2rem;
}

.detail-section h4 {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.75rem;
}

.detail-section p {
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.detail-section .muted {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.line-items-table {
    margin-top: 1.5rem;
}

.line-items-table h4 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

/* ============================================================================
   Loading
   ============================================================================ */

.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    color: var(--text-secondary);
}

.loading::before {
    content: '';
    width: 24px;
    height: 24px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-right: 0.75rem;
}

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

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

@media (max-width: 1024px) {
    .sidebar {
        width: 80px;
    }
    
    .sidebar-header .logo-text,
    .nav-label,
    .sidebar-footer span:not(.nav-icon) {
        display: none;
    }
    
    .sidebar-header .logo {
        display: none;
    }

    .sidebar-header-row {
        flex-direction: column;
        justify-content: center;
    }
    
    .nav-item {
        justify-content: center;
    }

    .nav-badge {
        position: absolute;
        top: 10px;
        right: 10px;
        margin-left: 0;
        min-width: 20px;
        height: 18px;
        padding: 0 5px;
        font-size: 0.7rem;
    }
    
    .main-content {
        margin-left: 80px;
    }
    
    .detail-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .filters {
        flex-direction: column;
    }
    
    .search-box {
        min-width: 100%;
    }
    
    .filter-group {
        flex-wrap: wrap;
    }
    
    .sync-actions {
        flex-direction: column;
    }
}

/* Recent Section */
.recent-section {
    margin-top: 2rem;
}

.recent-section h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

/* Tracking Button */
.btn-track {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.35rem 0.75rem;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    border: none;
    border-radius: 6px;
    color: var(--bg-primary);
    font-size: 0.75rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: var(--transition-fast);
    white-space: nowrap;
}

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

/* Print Label Button */
.btn-label {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.35rem 0.75rem;
    background: linear-gradient(135deg, #0ea5e9, #38bdf8);
    border: none;
    border-radius: 6px;
    color: white;
    font-size: 0.75rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: var(--transition-fast);
    white-space: nowrap;
}

.btn-label:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(14, 165, 233, 0.4);
}

/* Action buttons container */
.action-buttons {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.detail-actions {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.7rem;
}
.btn-download.btn-sm {
    padding: 0.45rem 0.9rem;
    font-size: 0.8rem;
}

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

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

.btn-track-lookup {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.35rem 0.75rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-fast);
}

.btn-track-lookup:hover {
    background: var(--bg-hover);
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

.btn-track-lookup:disabled,
.btn-disabled {
    opacity: 0.5;
    cursor: default;
}

/* Order Link in Shipments Table */
.order-link {
    color: var(--accent-primary);
    text-decoration: none;
    font-weight: 600;
    transition: var(--transition-fast);
}

.order-link:hover {
    color: var(--accent-secondary);
    text-decoration: underline;
}

/* Tracking Banner in Order Detail */
.tracking-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.1), rgba(34, 197, 94, 0.05));
    border: 1px solid rgba(34, 197, 94, 0.3);
    border-radius: 12px;
    margin-bottom: 1.5rem;
}

.tracking-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.tracking-icon {
    font-size: 2rem;
}

.tracking-info strong {
    color: var(--success);
    font-size: 1rem;
}

.tracking-info .muted {
    font-size: 0.85rem;
    margin-top: 0.25rem;
}

/* Favro Status Badges */
.favro-status {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-decoration: none;
    color: white;
    transition: opacity var(--transition-fast), transform var(--transition-fast);
}

.favro-status:hover {
    opacity: 0.85;
    transform: translateY(-1px);
}

.favro-banner {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: var(--bg-tertiary);
    border-radius: 8px;
    margin-bottom: 1rem;
    border: 1px solid var(--border-color);
}

.favro-banner .btn {
    white-space: nowrap;
}

.badge-gray {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

/* Form Detail View */
.form-detail {
    padding: 0;
}

.form-detail-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

.form-detail-header .detail-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.form-detail-header .detail-subtitle {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.form-detail-header .modal-close {
    background: none;
    border: none;
    font-size: 1.75rem;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 0;
    line-height: 1;
    transition: color 0.2s;
}

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

.form-detail-content {
    padding: 2rem;
}

.form-detail .detail-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 2rem;
    margin-bottom: 2rem;
}

.form-detail .detail-section {
    background: var(--bg-tertiary);
    padding: 1.25rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.form-detail .detail-section h4 {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.form-detail .detail-section p {
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
}

.form-detail .detail-section p:last-child {
    margin-bottom: 0;
}

.form-detail .detail-section a {
    color: var(--accent-primary);
    text-decoration: none;
}

.form-detail .detail-section a:hover {
    text-decoration: underline;
}

/* Hide the outer modal-header close button for form modal */
#form-modal > .modal-content > .modal-header {
    display: none;
}

/* =============================================================================
   EMAIL VIEW STYLES
   ============================================================================= */

html.email-view,
html.email-view body {
    overflow: hidden;
    height: 100%;
}

html.email-view .main-content {
    height: 100vh;
    overflow: hidden;
}

#view-email.view.active {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.email-layout {
    display: flex;
    gap: 0;
    flex: 1;
    min-height: 0;
    background: var(--bg-secondary);
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border-color);
    /* Full width to use extra space for context sidebar */
}

/* Email Sidebar (Folders) */
.email-sidebar {
    width: 160px;
    background: var(--bg-tertiary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.email-folders {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem;
}

.email-folders a,
.email-folders a:link,
.email-folders a:visited,
.email-folders a:hover,
.email-folders a:active {
    color: inherit !important;
    text-decoration: none !important;
}

.folder-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none !important;
    color: var(--text-secondary) !important;
    padding: 0.625rem 0.75rem;
    border-radius: 6px;
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.15s ease;
    margin-bottom: 2px;
}

.folder-item:hover {
    background: var(--bg-secondary);
    color: var(--text-primary) !important;
    text-decoration: none !important;
}

.folder-item.active {
    background: var(--accent-primary);
    color: white !important;
}

.folder-item.active:hover {
    color: white !important;
}

.folder-icon {
    font-size: 1rem;
}

.folder-name {
    flex: 1;
    font-size: 0.875rem;
}

.folder-badge {
    background: var(--accent-primary);
    color: white;
    padding: 0.125rem 0.5rem;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 600;
}

.folder-item.active .folder-badge {
    background: rgba(255, 255, 255, 0.3);
}

/* Email List Container */
.email-list-container {
    width: 350px;
    min-width: 280px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg-primary);
    border-right: 1px solid var(--border-color);
    min-height: 0;
}

.email-list {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
}

/* Compose body signature styling */
#compose-body .email-signature {
    margin-top: 1rem;
    padding-top: 1rem;
}

#compose-body .email-signature table {
    border-collapse: collapse;
}

#compose-body .email-signature img {
    max-width: 100%;
    height: auto;
}

.email-list-container .filters {
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-secondary);
    border-radius: 0;
    margin: 0;
    padding: 0.75rem 1rem;
}

.email-folders .muted,
.email-list .empty-state {
    padding: 2rem;
    text-align: center;
    color: var(--text-secondary);
}

/* Email List Items */
.email-item {
    display: flex;
    align-items: flex-start;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background 0.15s ease;
    background: var(--bg-primary);
}

.email-item:hover {
    background: var(--bg-secondary);
}

.email-item.unread {
    background: var(--bg-tertiary);
    border-left: 3px solid var(--accent-primary);
}

.email-item.unread .email-sender,
.email-item.unread .email-item-subject {
    font-weight: 600;
}

/* New message highlight animation */
.email-item.new-message {
    animation: newMessagePulse 2s ease-out;
}

@keyframes newMessagePulse {
    0% {
        background: rgba(255, 204, 0, 0.3);
        transform: translateX(-10px);
        opacity: 0;
    }
    20% {
        transform: translateX(0);
        opacity: 1;
    }
    100% {
        background: var(--bg-primary);
    }
}

.email-item-star {
    padding: 0.25rem;
    cursor: pointer;
    opacity: 0.5;
    transition: opacity 0.15s;
}

.email-item-star:hover {
    opacity: 1;
}

.email-item-content {
    flex: 1;
    min-width: 0;
    margin-left: 0.5rem;
}

.email-item-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 0.25rem;
}

.email-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.thread-count {
    background: var(--accent-primary);
    color: white;
    padding: 0.1rem 0.4rem;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: bold;
}

.email-sender {
    font-size: 0.875rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.email-date {
    font-size: 0.75rem;
    color: var(--text-secondary);
    white-space: nowrap;
    margin-left: 0.5rem;
}

.email-item-subject {
    font-size: 0.875rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 0.25rem;
}

.email-item-snippet {
    font-size: 0.8rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.email-item-icons {
    display: flex;
    gap: 0.25rem;
    margin-left: 0.5rem;
    opacity: 0.6;
}

/* Email Detail Panel */
.email-detail-panel {
    flex: 1;
    display: flex;
    flex-direction: row;
    overflow: hidden;
    background: var(--bg-primary);
    min-height: 0;
}

.email-detail-panel.hidden {
    display: none;
}

.email-thread-modal-body {
    padding: 0;
    overflow: hidden;
    height: 100%;
    display: flex;
    flex: 1;
    min-height: 0;
}

.email-thread-modal .modal-body {
    padding: 0;
    overflow: hidden;
}

.email-thread-modal #email-detail-panel {
    flex: 1;
    min-height: 0;
    height: 100%;
    width: 100%;
}

.notifications-modal-body {
    padding: 0;
    overflow: hidden;
    height: 100%;
    display: flex;
    flex: 1;
    min-height: 0;
}

.notifications-modal .modal-body {
    padding: 0;
    overflow: hidden;
}

.notifications-modal #view-notifications {
    display: block;
    height: 100%;
    overflow: auto;
    padding: 1.5rem;
}

.email-detail-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 1.5rem;
    min-width: 400px;
    min-height: 0;
}

/* Email Context Sidebar (right side - customer info, orders, notes) */
.email-context-sidebar {
    width: 300px;
    flex-shrink: 0;
    background: var(--bg-tertiary);
    border-left: 1px solid var(--border-color);
    overflow-y: auto;
    padding: 1rem;
    min-height: 0;
}

.email-context-section {
    margin-bottom: 1.5rem;
}

.email-context-section h4 {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.email-context-section h4 .count {
    background: var(--accent-primary);
    color: white;
    padding: 0.125rem 0.5rem;
    border-radius: 10px;
    font-size: 0.7rem;
}

/* Internal Notes */
.internal-notes-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.internal-note {
    background: var(--bg-tertiary);
    border-radius: 8px;
    padding: 0.75rem;
    border-left: 3px solid var(--accent-primary);
}

.internal-note-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.internal-note-author {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-primary);
}

.internal-note-date {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.internal-note-content {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.internal-note-content .mention {
    color: var(--accent-primary);
    font-weight: 600;
}

/* Inline Notes in Conversation */
.inline-note {
    margin: 1rem 0;
    padding: 1rem;
    background: linear-gradient(135deg, rgba(234, 179, 8, 0.1) 0%, rgba(234, 179, 8, 0.05) 100%);
    border: 1px dashed rgba(234, 179, 8, 0.4);
    border-radius: 12px;
    position: relative;
}

.inline-note-badge {
    position: absolute;
    top: -10px;
    left: 1rem;
    background: var(--bg-card);
    padding: 0.125rem 0.5rem;
    font-size: 0.7rem;
    font-weight: 600;
    color: #eab308;
    border-radius: 4px;
    border: 1px dashed rgba(234, 179, 8, 0.4);
}

.inline-note-content {
    padding-top: 0.25rem;
}

.inline-note-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.inline-note-author {
    font-weight: 600;
    font-size: 0.875rem;
    color: #eab308;
}

.inline-note-date {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.inline-note-text {
    font-size: 0.9rem;
    color: var(--text-primary);
    line-height: 1.6;
}

.inline-note-text .mention {
    color: var(--accent-primary);
    font-weight: 600;
    background: rgba(var(--accent-primary-rgb), 0.1);
    padding: 0.125rem 0.25rem;
    border-radius: 4px;
}

/* Note button in header */
.btn-note {
    background: linear-gradient(135deg, rgba(234, 179, 8, 0.2) 0%, rgba(234, 179, 8, 0.1) 100%);
    border: 1px solid rgba(234, 179, 8, 0.4);
    color: #eab308;
}

.btn-note:hover {
    background: linear-gradient(135deg, rgba(234, 179, 8, 0.3) 0%, rgba(234, 179, 8, 0.2) 100%);
    border-color: #eab308;
}

/* Slide-down note input container */
.note-input-container {
    overflow: hidden;
    max-height: 300px;
    transition: max-height 0.3s ease, opacity 0.3s ease;
    opacity: 1;
}

.note-input-container.hidden {
    max-height: 0;
    opacity: 0;
}

.note-input-wrapper {
    padding: 1rem;
    margin: 0.5rem 0 1rem 0;
    background: linear-gradient(135deg, rgba(234, 179, 8, 0.1) 0%, rgba(234, 179, 8, 0.05) 100%);
    border: 1px dashed rgba(234, 179, 8, 0.4);
    border-radius: 12px;
}

.note-input-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: #eab308;
}

.note-hint {
    font-size: 0.75rem;
    font-weight: 400;
    color: var(--text-muted);
}

.note-textarea-container {
    position: relative;
}

.note-textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid rgba(234, 179, 8, 0.3);
    border-radius: 8px;
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 0.9rem;
    font-family: inherit;
    resize: vertical;
    min-height: 80px;
    transition: border-color 0.2s;
}

.note-textarea:focus {
    outline: none;
    border-color: #eab308;
}

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

.note-input-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

/* Mention dropdown */
.mention-dropdown {
    position: absolute;
    bottom: 100%;
    left: 0;
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    max-height: 200px;
    overflow-y: auto;
    z-index: 100;
    margin-bottom: 4px;
}

.mention-dropdown.hidden {
    display: none;
}

.mention-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 0.75rem;
    cursor: pointer;
    transition: background 0.15s;
}

.mention-item:hover,
.mention-item.selected {
    background: var(--bg-tertiary);
}

.mention-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent-primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.875rem;
}

.mention-info {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.mention-name {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
}

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

.add-note-form {
    margin-top: 0.75rem;
}

.add-note-input {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 0.85rem;
    resize: none;
    min-height: 60px;
}

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

.add-note-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

/* Customer Orders in Context */
.context-order-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.context-order-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem;
    background: var(--bg-tertiary);
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s ease;
}

.context-order-item:hover {
    background: var(--bg-hover);
}

.context-order-number {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--accent-primary);
}

.context-order-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.25rem;
}

.context-order-date {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Small badge variant */
.badge-sm {
    font-size: 0.65rem !important;
    padding: 0.1rem 0.4rem !important;
}

.context-order-amount {
    font-size: 0.85rem;
    font-weight: 600;
}

/* Customer Info Card */
.customer-info-card {
    background: var(--bg-tertiary);
    border-radius: 8px;
    padding: 1rem;
}

.customer-info-name {
    font-weight: 600;
    font-size: 1rem;
    margin-bottom: 0.5rem;
}

.customer-info-email {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.customer-info-phone {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.customer-info-stats {
    display: flex;
    gap: 1rem;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-color);
}

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

.customer-stat-value {
    font-weight: 600;
    font-size: 1rem;
    color: var(--accent-primary);
}

.customer-stat-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
}

.email-thread-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 1.25rem;
}

.thread-subject {
    flex: 1;
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
    color: var(--text-primary);
}

.thread-actions {
    display: flex;
    gap: 0.5rem;
}

.email-thread-layout {
    display: flex;
    gap: 1.5rem;
}

.email-thread-messages {
    flex: 1;
    min-width: 0;
    min-height: 0;
    overflow-y: auto;
}

/* Mixed timeline (emails + internal notes interleaved) */
.thread-timeline-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.thread-timeline-item .email-message,
.thread-timeline-item .inline-note {
    margin: 0;
}

/* Thread sections + tree layout (Conversation + Notes) */
.thread-section {
    margin-bottom: 1.25rem;
}

.thread-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin: 0.25rem 0 0.75rem 0;
}

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

.thread-section-count {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 700;
}

.email-tree,
.note-tree {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.email-tree .email-message,
.note-tree .inline-note {
    margin: 0;
}

.email-tree-children,
.note-tree-children {
    margin-top: 10px;
    padding-left: 12px;
    border-left: 1px solid rgba(148, 163, 184, 0.22);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.inline-note-reply-host {
    margin-top: 0.75rem;
}

/* Individual Email Message */
.email-message {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.25rem;
    margin-bottom: 1rem;
}

.email-message.sent {
    border-left: 3px solid var(--accent-success);
    background: rgba(34, 197, 94, 0.05);
}

.email-message-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.email-message-from strong {
    color: var(--text-primary);
}

.sent-badge {
    font-size: 0.7rem;
    background: var(--accent-success);
    color: white;
    padding: 0.125rem 0.375rem;
    border-radius: 4px;
    margin-left: 0.5rem;
}

.draft-badge {
    font-size: 0.75rem;
    background: #f59e0b;
    color: #000;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    margin-left: 0.5rem;
    font-weight: bold;
}

.email-message.draft {
    border: 2px dashed #f59e0b !important;
    background: rgba(245, 158, 11, 0.15) !important;
    position: relative;
}

.email-message.draft::before {
    content: "📝 DRAFT";
    position: absolute;
    top: -12px;
    left: 10px;
    background: #f59e0b;
    color: #000;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: bold;
}

.email-message-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.email-message-actions .btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
}

.email-message-date {
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.email-message-to {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
}

.email-message-attachments {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    /* Ensure attachments stay clickable above the email iframe */
    position: relative;
    z-index: 5;
}

.attachment-item {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.5rem;
    background: var(--bg-tertiary);
    border-radius: 4px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-decoration: none;
}

.attachment-item:hover {
    background: var(--bg-primary);
    color: var(--accent-primary);
}

.email-message-body {
    /* White background for email content */
    background: #ffffff;
    color: #1a1a1a;
    padding: 1rem;
    border-radius: 8px;
    margin: 0.5rem 0;
    /* Reset to browser defaults for proper email rendering */
    line-height: normal;
    font-size: medium;
    position: relative;
    z-index: 1;
}

/* Reset global table styles for email content */
.email-message-body table {
    width: auto;
    border-collapse: collapse;
}

.email-message-body td,
.email-message-body th {
    padding: 0;
    border: none;
    font-size: inherit;
}

.email-message-body tr {
    background: transparent;
}

.email-message-body tbody tr:hover {
    background: transparent;
}

/* Only limit very large images */
.email-message-body img {
    max-width: 100%;
}

.email-message-body a {
    color: #0066cc;
}

.email-message-body pre {
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* Email iframe for accurate rendering */
.email-iframe {
    width: 100%;
    border: none;
    min-height: 200px;
    background: white;
    border-radius: 4px;
    display: block;
    position: relative;
    z-index: 1;
}

.email-message-body .email-expand-btn {
    margin-top: 0.75rem;
}

/* Signature iframe in compose window */
.signature-iframe,
.signature-preview-iframe {
    width: 100%;
    border: none;
    min-height: 150px;
    background: white;
    display: block;
}

/* Signature in compose body */
.compose-body .email-signature {
    margin-top: 1rem;
    padding-top: 0.5rem;
}

.compose-body .email-signature img {
    display: inline-block !important;
    max-width: 100%;
    height: auto;
}

.compose-body .email-signature table {
    border-collapse: collapse;
}

.compose-body .email-signature a {
    color: #0066cc;
    text-decoration: none;
}

/* Customer Sidebar */
.email-customer-sidebar {
    width: 280px;
    flex-shrink: 0;
    background: var(--bg-secondary);
    border-radius: 8px;
    padding: 1.25rem;
    border: 1px solid var(--border-color);
}

.email-customer-sidebar h3 {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
    font-weight: 600;
}

.email-customer-sidebar h4 {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    margin: 1.25rem 0 0.75rem;
    font-weight: 600;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.customer-info p {
    margin: 0.375rem 0;
    font-size: 0.875rem;
    color: var(--text-primary);
}

.customer-stats {
    display: flex;
    gap: 1.5rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.customer-stats .stat {
    display: flex;
    flex-direction: column;
}

.customer-stats .value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.customer-stats .label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    margin-top: 0.125rem;
}

.order-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.order-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 0.75rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.875rem;
    background: var(--bg-tertiary);
    margin-bottom: 0.5rem;
    transition: background 0.15s ease;
}

.order-item:hover {
    background: var(--bg-primary);
}

.order-item:last-child {
    margin-bottom: 0;
}

.order-number {
    font-weight: 600;
    color: var(--text-primary);
}

.order-total {
    margin-left: auto;
    color: var(--text-secondary);
    font-weight: 500;
}

/* Email Compose Modal */
.email-compose-modal {
    width: 700px;
    max-width: 90vw;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    border-radius: 12px;
    overflow: hidden;
}

.compose-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-secondary);
    border-radius: 0;
}

.compose-header h2 {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 600;
}

.compose-form {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
    min-height: 0; /* Allow editor to shrink and body to scroll */
}

.compose-field {
    display: flex;
    align-items: center;
    padding: 0.75rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.compose-field label {
    width: 50px;
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.compose-field input {
    flex: 1;
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-size: 0.875rem;
    padding: 0.5rem;
}

.compose-field input:focus {
    outline: none;
}

.compose-editor {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative; /* For emoji picker positioning */
    min-height: 0; /* Required for nested flex scrolling */
}

#compose-toolbar {
    display: flex;
    gap: 0.25rem;
    padding: 0.5rem 1rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

#compose-toolbar button {
    padding: 0.375rem 0.625rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: var(--bg-primary);
    color: var(--text-primary);
    cursor: pointer;
    font-size: 0.875rem;
}

#compose-toolbar button:hover {
    background: var(--bg-tertiary);
}

#compose-toolbar button.compose-compatibility-btn {
    background: #22c55e;
    border-color: #22c55e;
    color: #0b1a0f;
    font-weight: 700;
}

#compose-toolbar button.compose-compatibility-btn:hover {
    background: #16a34a;
    border-color: #16a34a;
}

.toolbar-separator {
    width: 1px;
    background: var(--border-color);
    margin: 0 0.25rem;
}

.compose-body {
    flex: 1;
    padding: 1rem 1.5rem;
    overflow-y: auto;
    min-height: 200px;
    /* White background for compose like email clients */
    background: #ffffff;
    color: #1a1a1a;
    font-family: var(--font-email);
    font-size: var(--font-email-size);
    line-height: 1.6;
}

.compose-body,
.compose-body * {
    font-family: var(--font-email) !important;
    font-size: var(--font-email-size) !important;
    line-height: inherit !important;
}

.compose-body:focus {
    outline: none;
}

.compose-body:empty::before {
    content: attr(placeholder);
    color: #888;
    opacity: 0.6;
}

/* Typing area indicator */
.compose-body > p:first-child {
    min-height: 1.6em;
}

/* Signature separator */
.compose-body .email-signature {
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: none;
}

/* Ensure images in compose body load and display */
.compose-body img {
    max-width: 100%;
    height: auto;
    display: inline-block;
}

.compose-body table {
    border-collapse: collapse;
}

.compose-body a {
    color: #0066cc;
}

/* Emoji picker - full featured */
.emoji-picker {
    position: absolute;
    top: 45px;
    right: 10px;
    width: 320px;
    max-height: 400px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    z-index: 100;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.emoji-picker.hidden {
    display: none;
}

.emoji-categories {
    display: flex;
    gap: 2px;
    padding: 4px 8px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-tertiary);
}

.emoji-categories button {
    flex: 1;
    padding: 6px;
    background: none;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    cursor: pointer;
    transition: background 0.15s;
}

.emoji-categories button:hover {
    background: var(--bg-hover);
}

.emoji-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
    max-height: 280px;
}

.emoji-category {
    margin-bottom: 12px;
}

.emoji-category-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    padding: 4px 0;
    margin-bottom: 4px;
    position: sticky;
    top: 0;
    background: var(--bg-secondary);
}

.emoji-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 2px;
}

.emoji-grid span {
    font-size: 22px;
    padding: 4px;
    cursor: pointer;
    text-align: center;
    border-radius: 6px;
    transition: background 0.1s, transform 0.1s;
}

.emoji-grid span:hover {
    background: var(--bg-hover);
    transform: scale(1.2);
}

.emoji-empty {
    text-align: center;
    color: var(--text-muted);
    padding: 20px;
}

.compose-signature {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1.5rem;
    border-top: 1px solid var(--border-color);
    font-size: 0.875rem;
}

.compose-signature label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.compose-signature select {
    padding: 0.375rem 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.8rem;
}

.compose-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

/* Empty state */
.empty-state {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 200px;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* =============================================================================
   ADMIN PANEL STYLES
   ============================================================================= */

.admin-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 1.5rem;
    background: var(--bg-secondary);
    border-radius: 8px;
    padding: 0.25rem;
    width: fit-content;
}

.admin-tab {
    padding: 0.625rem 1.25rem;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.875rem;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.15s ease;
    font-weight: 500;
}

.admin-tab:hover {
    color: var(--text-primary);
}

.admin-tab.active {
    background: var(--accent-primary);
    color: white;
}

.admin-tab-content {
    display: none;
}

.admin-tab-content.active {
    display: block;
}

/* Users Table */
#users-table table {
    width: 100%;
}

.badge-admin {
    background: var(--accent-warning) !important;
    color: #000 !important;
}

/* Roles Grid */
.roles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1rem;
}

.role-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    transition: border-color 0.15s ease;
}

.role-card:hover {
    border-color: var(--accent-primary);
}

.role-card-header {
    padding: 1rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-tertiary);
}

.role-badge {
    display: inline-block;
    padding: 0.375rem 0.875rem;
    border-radius: 6px;
    font-weight: 600;
    color: white;
    font-size: 0.875rem;
    width: fit-content;
}

.system-badge {
    font-size: 0.7rem;
    background: var(--bg-secondary);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.role-card-body {
    padding: 1.25rem;
}

.role-code {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.role-description {
    font-size: 0.875rem;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
    line-height: 1.4;
}

.role-stats {
    font-size: 0.8rem;
    color: var(--text-secondary);
    display: flex;
    gap: 1rem;
}

.role-card-actions {
    padding: 0.875rem 1.25rem;
    background: var(--bg-primary);
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 0.5rem;
}

/* User Modal */
.user-modal {
    width: 520px;
    max-width: 90vw;
}

.user-form {
    padding: 1.5rem;
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="password"],
.form-group textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 0.9rem;
    transition: border-color 0.15s ease, background 0.15s ease;
}

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

.form-group input[readonly] {
    background: var(--bg-secondary);
    color: var(--text-secondary);
    cursor: not-allowed;
}

.form-hint {
    display: block;
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.375rem;
}

.form-row {
    display: flex;
    gap: 1rem;
}

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

.checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    padding: 0.375rem 0.625rem;
    background: var(--bg-tertiary);
    border-radius: 6px;
    transition: background 0.15s ease;
}

.checkbox-item:hover {
    background: var(--bg-secondary);
}

.checkbox-item input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.role-badge-small {
    padding: 0.25rem 0.625rem;
    border-radius: 4px;
    font-size: 0.75rem;
    color: white;
    font-weight: 500;
}

.toggle-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.9rem;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-top: 1.5rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border-color);
}

/* Role Modal */
.role-modal {
    width: 650px;
    max-width: 90vw;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
}

.role-form {
    padding: 1.5rem;
    overflow-y: auto;
}

.permissions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.75rem;
    max-height: 300px;
    overflow-y: auto;
    padding: 1rem;
    background: var(--bg-tertiary);
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.permission-group {
    background: var(--bg-secondary);
    padding: 1rem;
    border-radius: 6px;
    border: 1px solid var(--border-color);
}

.permission-group h4 {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--accent-primary);
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
}

.permission-group .checkbox-item {
    margin-bottom: 0.375rem;
    font-size: 0.8rem;
    padding: 0.25rem 0;
    background: transparent;
}

.permission-group .checkbox-item:hover {
    background: transparent;
}

/* Hide admin nav for non-admins (initially shown, JS hides if not admin) */
.nav-item.admin-only {
    display: flex;
}

/* ============================================================================
   Settings Section
   ============================================================================ */

.settings-tab {
    padding: 0.75rem 1.5rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: var(--transition-fast);
}

.settings-tab:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.settings-tab.active {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: var(--bg-primary);
}

.settings-tab-content {
    display: none;
    padding: 1.5rem 0;
}

.settings-tab-content.active {
    display: block;
}

.settings-section {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.settings-section h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1.25rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

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

.logo-upload {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1.5rem;
}

.logo-preview {
    width: 180px;
    height: 96px;
    border: 1px dashed var(--border-color);
    border-radius: 12px;
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem;
}

.logo-preview-img {
    max-height: 60px;
    width: auto;
    filter: drop-shadow(0 0 8px var(--accent-glow));
}

.logo-upload-controls {
    flex: 1;
    min-width: 220px;
    margin-bottom: 0;
}

.logo-upload-controls input[type="file"] {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px dashed var(--border-color);
    border-radius: 8px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

.logo-upload-controls .btn {
    margin-top: 0.75rem;
}

.settings-hint {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

#settings-email-signature {
    width: 100%;
    min-height: 150px;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    color: var(--text-primary);
    resize: vertical;
}

#settings-email-signature:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.signature-preview {
    margin-top: 1rem;
}

.signature-preview h4 {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.signature-preview-box {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    min-height: 80px;
    color: #333;
    font-size: 0.9rem;
}

/* Settings - Sync Status Indicators */
.sync-status-indicator {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
}

.sync-status-indicator.connected {
    background: rgba(34, 197, 94, 0.15);
    color: var(--success);
}

.sync-status-indicator.disconnected {
    background: rgba(239, 68, 68, 0.15);
    color: var(--error);
}

.sync-actions {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.sync-actions .btn {
    min-width: 180px;
}

/* ============================================================================
   Theme Toggle (Sidebar)
   ============================================================================ */

.theme-toggle-sidebar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.theme-toggle-sidebar .icon-sun,
.theme-toggle-sidebar .icon-moon,
.theme-toggle-sidebar .theme-label-light,
.theme-toggle-sidebar .theme-label-dark {
    transition: opacity var(--transition-normal);
}

/* Dark mode - show sun icon and "Light Mode" label */
.theme-toggle-sidebar .icon-sun {
    opacity: 1;
}

.theme-toggle-sidebar .icon-moon {
    opacity: 0;
    display: none;
}

.theme-toggle-sidebar .theme-label-light {
    opacity: 1;
}

.theme-toggle-sidebar .theme-label-dark {
    opacity: 0;
    display: none;
}

/* Light mode - show moon icon and "Dark Mode" label */
[data-theme="light"] .theme-toggle-sidebar .icon-sun {
    opacity: 0;
    display: none;
}

[data-theme="light"] .theme-toggle-sidebar .icon-moon {
    opacity: 1;
    display: inline;
}

[data-theme="light"] .theme-toggle-sidebar .theme-label-light {
    opacity: 0;
    display: none;
}

[data-theme="light"] .theme-toggle-sidebar .theme-label-dark {
    opacity: 1;
    display: inline;
}

/* Light mode specific fixes */
[data-theme="light"] .login-box {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
}

[data-theme="light"] .sidebar {
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
}

[data-theme="light"] .nav-link {
    color: var(--text-secondary);
}

[data-theme="light"] .nav-link:hover,
[data-theme="light"] .nav-link.active {
    background: var(--bg-hover);
    color: var(--text-primary);
}

[data-theme="light"] table th {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

[data-theme="light"] table td {
    border-color: var(--border-color);
}

[data-theme="light"] table tbody tr:hover {
    background: var(--bg-hover);
}

[data-theme="light"] .card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
}

[data-theme="light"] .modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
}

[data-theme="light"] input,
[data-theme="light"] select,
[data-theme="light"] textarea {
    background: var(--bg-tertiary);
    border-color: var(--border-color);
    color: var(--text-primary);
}

[data-theme="light"] input:focus,
[data-theme="light"] select:focus,
[data-theme="light"] textarea:focus {
    border-color: var(--accent-primary);
    background: var(--bg-secondary);
}

[data-theme="light"] .btn {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-color: var(--border-color);
}

[data-theme="light"] .btn:hover {
    background: var(--bg-hover);
}

[data-theme="light"] .btn-primary {
    background: var(--accent-primary);
    color: white;
    border-color: var(--accent-primary);
}

[data-theme="light"] .btn-primary:hover {
    background: var(--accent-secondary);
}

[data-theme="light"] .badge {
    border: 1px solid var(--border-light);
}

[data-theme="light"] .stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
}

[data-theme="light"] .view-header {
    border-bottom: 1px solid var(--border-color);
}

[data-theme="light"] .email-sidebar {
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
}

[data-theme="light"] .email-layout {
    background: var(--bg-secondary);
}

[data-theme="light"] .email-list-container {
    background: var(--bg-card);
}

[data-theme="light"] .email-detail-panel {
    background: var(--bg-card);
}

[data-theme="light"] .email-context-sidebar {
    background: var(--bg-secondary);
}

[data-theme="light"] .email-item {
    border-bottom: 1px solid var(--border-color);
}

[data-theme="light"] .email-item:hover {
    background: var(--bg-hover);
}

[data-theme="light"] .email-thread-header {
    border-bottom: 1px solid var(--border-color);
}

[data-theme="light"] .email-message-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
}

[data-theme="light"] .compose-modal-content {
    background: var(--bg-card);
}

[data-theme="light"] .customer-info-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
}

[data-theme="light"] .internal-note {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
}

[data-theme="light"] .inline-note {
    background: linear-gradient(135deg, rgba(234, 179, 8, 0.15) 0%, rgba(234, 179, 8, 0.08) 100%);
    border-color: rgba(180, 140, 8, 0.5);
}

[data-theme="light"] .inline-note-badge {
    background: white;
    border-color: rgba(180, 140, 8, 0.5);
    color: #b48c08;
}

[data-theme="light"] .inline-note-author {
    color: #b48c08;
}

[data-theme="light"] .add-note-inline-form {
    background: var(--bg-secondary);
}

[data-theme="light"] .note-input-wrapper {
    background: linear-gradient(135deg, rgba(234, 179, 8, 0.15) 0%, rgba(234, 179, 8, 0.08) 100%);
    border-color: rgba(180, 140, 8, 0.5);
}

[data-theme="light"] .note-input-header {
    color: #b48c08;
}

[data-theme="light"] .note-textarea {
    background: white;
    border-color: rgba(180, 140, 8, 0.3);
}

[data-theme="light"] .note-textarea:focus {
    border-color: #b48c08;
}

[data-theme="light"] .btn-note {
    background: linear-gradient(135deg, rgba(234, 179, 8, 0.25) 0%, rgba(234, 179, 8, 0.15) 100%);
    border-color: rgba(180, 140, 8, 0.5);
    color: #b48c08;
}

[data-theme="light"] .mention-dropdown {
    background: white;
    border-color: var(--border-color);
}

[data-theme="light"] .mention-item:hover,
[data-theme="light"] .mention-item.selected {
    background: var(--bg-secondary);
}

/* Sidebar Notes List */
.sidebar-notes-list {
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
}

.sidebar-note-item {
    padding: 0.625rem;
    background: linear-gradient(135deg, rgba(234, 179, 8, 0.1) 0%, rgba(234, 179, 8, 0.05) 100%);
    border: 1px solid rgba(234, 179, 8, 0.2);
    border-radius: 8px;
    border-left: 3px solid #eab308;
}

.sidebar-note-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.375rem;
}

.sidebar-note-author {
    font-weight: 600;
    font-size: 0.8rem;
    color: #eab308;
}

.sidebar-note-date {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.sidebar-note-content {
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.4;
    word-break: break-word;
}

[data-theme="light"] .sidebar-note-item {
    background: linear-gradient(135deg, rgba(234, 179, 8, 0.15) 0%, rgba(234, 179, 8, 0.08) 100%);
    border-color: rgba(180, 140, 8, 0.3);
}

[data-theme="light"] .sidebar-note-author {
    color: #b48c08;
}

[data-theme="light"] .add-note-input {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
}

[data-theme="light"] .context-order-item {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
}

/* =============================================================================
   Drag and Drop File Upload
   ============================================================================= */

.drop-zone {
    position: relative;
    transition: all 0.2s ease;
}

.drop-zone.drag-over {
    background: rgba(230, 193, 117, 0.1) !important;
    border-color: var(--accent-primary) !important;
    box-shadow: inset 0 0 20px rgba(230, 193, 117, 0.15);
}

.drop-overlay {
    position: absolute;
    inset: 0;
    background: rgba(12, 18, 32, 0.9);
    border: 2px dashed var(--accent-primary);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    pointer-events: none;
}

.drop-overlay.hidden {
    display: none;
}

.drop-overlay-content {
    font-size: 1.25rem;
    color: var(--accent-primary);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Attachment Preview */
.attachment-preview-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.5rem 0;
}

.attachment-preview-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0.625rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.attachment-thumb {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: 4px;
    border: 1px solid var(--border-light);
}

.attachment-icon {
    font-size: 1.2rem;
}

.attachment-name {
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.attachment-remove {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.1rem;
    line-height: 1;
    padding: 0 0.25rem;
    transition: color 0.15s ease;
}

.attachment-remove:hover {
    color: var(--error);
}

/* Compose body specific */
.compose-body-wrapper {
    position: relative;
    flex: 1;
    display: flex;
    flex-direction: column;
    border: 2px solid transparent;
    border-radius: 8px;
    transition: border-color 0.2s ease, background 0.2s ease;
    min-height: 0; /* Ensure compose-body can become scroll container */
}

.compose-body-wrapper.drag-over {
    border-color: var(--accent-primary);
    background: rgba(230, 193, 117, 0.05);
}

.compose-body.drop-zone {
    flex: 1;
}

/* Note textarea container */
.note-textarea-container {
    position: relative;
}

.note-textarea-container.drop-zone {
    border: 2px dashed transparent;
    border-radius: 8px;
    transition: border-color 0.2s ease, background 0.2s ease;
}

.note-textarea-container.drop-zone.drag-over {
    border-color: var(--accent-primary);
}

/* Light theme adjustments */
[data-theme="light"] .drop-overlay {
    background: rgba(255, 255, 255, 0.9);
}

[data-theme="light"] .attachment-preview-item {
    background: var(--bg-secondary);
}

/* Note attachments display in timeline */
.note-attachments-display {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-color);
}

.note-attachment-image {
    max-width: 150px;
    max-height: 100px;
    object-fit: cover;
    border-radius: 6px;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    border: 1px solid var(--border-color);
}

.note-attachment-image:hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-md);
}

.note-attachment-file {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.375rem 0.625rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-decoration: none;
    transition: background 0.15s ease;
}

.note-attachment-file:hover {
    background: var(--bg-hover);
    color: var(--accent-primary);
}

/* Note actions (edit, delete buttons) */
.note-actions {
    display: flex;
    gap: 0.25rem;
    margin-left: auto;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.inline-note:hover .note-actions {
    opacity: 1;
}

/* Show note actions in sidebar/internal notes */
.internal-note .note-actions {
    opacity: 1;
}

.note-reply-btn,
.note-edit-btn,
.note-delete-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.85rem;
    padding: 0.25rem;
    opacity: 0.6;
    transition: opacity 0.15s ease;
}

.note-reply-btn:hover,
.note-edit-btn:hover,
.note-delete-btn:hover {
    opacity: 1;
}

/* Note edited indicator */
.note-edited {
    color: var(--text-muted);
    font-size: 0.7rem;
    margin-left: 0.5rem;
}

/* Note edit form */
.note-edit-textarea {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid rgba(234, 179, 8, 0.4);
    border-radius: 6px;
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 0.9rem;
    font-family: inherit;
    resize: vertical;
    min-height: 60px;
}

.note-edit-textarea:focus {
    outline: none;
    border-color: #eab308;
}

.note-edit-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

/* Image preview modal */
.image-preview-modal {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.image-preview-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    cursor: pointer;
}

.image-preview-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    z-index: 1;
}

.image-preview-content img {
    max-width: 100%;
    max-height: 85vh;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.image-preview-close {
    position: absolute;
    top: -12px;
    right: -12px;
    width: 32px;
    height: 32px;
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    border-radius: 50%;
    color: var(--text-primary);
    font-size: 1.25rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease;
}

.image-preview-close:hover {
    background: var(--error);
    border-color: var(--error);
}

.image-preview-name {
    text-align: center;
    margin-top: 0.75rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

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

/* Compose signature container */
#compose-signature-container {
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border-color);
}

#compose-signature-container:empty {
    display: none;
}

#compose-signature-container .email-signature-preview {
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
}

/* Compose attachments in editor */
#compose-attachments:not(:empty) {
    margin: 0.75rem 0;
    padding: 0.75rem;
    background: var(--bg-tertiary);
    border-radius: 8px;
    border: 1px dashed var(--border-color);
}

/* ============================================================================
   Inline editing (Deals / WPForms detail)
   ============================================================================ */

.editable-value {
    cursor: pointer;
    border-bottom: 1px dashed var(--border-light);
    transition: background var(--transition-fast), border-color var(--transition-fast);
    padding: 1px 2px;
    border-radius: 4px;
}

.editable-value:hover {
    background: var(--bg-hover);
    border-bottom-color: var(--accent-primary);
}

.editable-value.editable-multiline {
    white-space: pre-wrap;
    display: inline-block;
}

.editable-value.saving {
    opacity: 0.7;
    pointer-events: none;
}

.inline-edit-input {
    width: 100%;
    min-width: 220px;
    max-width: 100%;
    font: inherit;
    color: var(--text-primary);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 6px 8px;
    outline: none;
}

.inline-edit-input:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

/* ============================================================================
   Manual deal create modal layout
   ============================================================================ */

.deal-create-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}

.deal-create-form .deal-message-group {
    margin-top: 12px;
}

.deal-create-form textarea#deal-message {
    min-height: 140px;
    resize: vertical;
}

@media (max-width: 900px) {
    .deal-create-grid {
        grid-template-columns: 1fr;
    }
    .modal-content-wide {
        width: 100%;
    }
}

/* ============================================================================
   Deal items modal (parts / offer / notes)
   ============================================================================ */

.deal-items-table input {
    width: 100%;
}

.deal-items-table .btn-danger-inline {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    border-radius: 8px;
    padding: 6px 10px;
    cursor: pointer;
}

.deal-items-table .btn-danger-inline:hover {
    border-color: var(--error);
    color: var(--error);
}

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

.deal-cell-meta .pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 8px;
    border: 1px solid var(--border-color);
    border-radius: 999px;
    color: var(--text-secondary);
    font-size: 0.8rem;
    white-space: nowrap;
}

.deal-cell-meta .pill a {
    color: inherit;
    text-decoration: none;
}

.deal-cell-snippet {
    max-width: 360px;
    color: var(--text-secondary);
    font-size: 0.85rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

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

.notifications-feed {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.notification-item {
    padding: 12px 14px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.notification-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.notification-item.unread {
    border-color: rgba(230, 193, 117, 0.45);
    background: rgba(230, 193, 117, 0.06);
}

.notification-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
}

.notification-title {
    font-weight: 700;
    color: var(--text-primary);
}

.notification-body {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.notification-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.notification-actions {
    display: flex;
    gap: 6px;
    justify-content: flex-end;
}

.notification-actions .btn {
    padding: 0.35rem 0.6rem;
    font-size: 0.8rem;
}

/* =============================================================================
   Activity
   ============================================================================= */

.activity-feed {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.activity-group-header {
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.02);
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-secondary);
}

.activity-group-header .muted {
    color: var(--text-muted);
    font-weight: 600;
    letter-spacing: normal;
    text-transform: none;
}

.activity-subgroup-header {
    padding: 4px 8px;
    margin-top: 4px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.activity-subgroup-header .muted {
    color: var(--text-muted);
    font-weight: 500;
}

.activity-item {
    padding: 12px 14px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    cursor: pointer;
}

.activity-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.activity-summary {
    font-weight: 600;
    color: var(--text-primary);
}

.activity-meta {
    margin-top: 6px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

/* ============================================================================
   Service Center
   ========================================================================== */

.service-center {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.service-results {
    display: grid;
    grid-template-columns: 360px minmax(0, 1fr);
    gap: 1.25rem;
    align-items: start;
}

.service-results-list,
.service-results-detail {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 0.75rem;
    min-height: 360px;
    max-height: calc(100vh - 280px);
    overflow: auto;
}

.service-results-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.service-group-item {
    width: 100%;
    text-align: left;
    appearance: none;
    border: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.02);
    border-radius: 12px;
    padding: 10px 12px;
    cursor: pointer;
    color: var(--text-primary);
    transition: background var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.service-group-item:hover {
    background: rgba(255, 255, 255, 0.04);
    border-color: var(--border-light);
}

.service-group-item.active {
    border-color: rgba(230, 193, 117, 0.5);
    background: rgba(230, 193, 117, 0.06);
    box-shadow: 0 0 0 2px rgba(230, 193, 117, 0.12);
}

.service-group-title {
    font-weight: 700;
    font-size: 0.95rem;
    line-height: 1.25;
}

.service-group-subtitle {
    margin-top: 2px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.service-group-badges {
    margin-top: 8px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.service-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 8px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.service-detail-header {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 6px 6px 12px 6px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 12px;
}

.service-detail-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.service-detail-title {
    font-weight: 800;
    font-size: 1.1rem;
    letter-spacing: -0.2px;
}

.service-detail-subtitle {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.service-detail-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 4px;
}

.service-sections {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.service-section-header {
    font-weight: 700;
    font-size: 0.85rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.service-email-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.service-email-item {
    width: 100%;
    text-align: left;
    appearance: none;
    border: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.02);
    border-radius: 12px;
    padding: 10px 12px;
    cursor: pointer;
    color: var(--text-primary);
    transition: background var(--transition-fast), border-color var(--transition-fast);
}

.service-email-item:hover {
    background: rgba(255, 255, 255, 0.04);
    border-color: var(--border-light);
}

.service-email-subject {
    font-weight: 700;
    font-size: 0.9rem;
    line-height: 1.25;
    margin-bottom: 4px;
}

.service-email-meta {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.service-email-unread {
    color: var(--accent-secondary);
    font-weight: 700;
}

.service-email-snippet {
    margin-top: 6px;
    font-size: 0.82rem;
    color: var(--text-muted);
}

@media (max-width: 980px) {
    .service-results {
        grid-template-columns: 1fr;
    }
    .service-results-list,
    .service-results-detail {
        max-height: none;
        overflow: visible;
    }
}

/* ============================================================================
   Calendar
   ============================================================================ */

.calendar-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.calendar-nav {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.calendar-month-label {
    font-weight: 700;
    font-size: 1.05rem;
    padding-left: 0.5rem;
    color: var(--text-primary);
    text-transform: capitalize;
}

.calendar-filters {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.calendar-search {
    min-width: 280px;
}

.calendar-source-select {
    padding: 0.7rem 0.9rem;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 0.9rem;
}

.calendar-source-select:focus {
    outline: none;
    border-color: var(--accent-primary);
    background: var(--bg-primary);
}

.calendar-weekdays {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 6px;
    margin-bottom: 6px;
}

.calendar-weekday {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    padding: 0 0.25rem;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 6px;
}

.calendar-day {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 0.5rem;
    min-height: 120px;
    cursor: pointer;
    transition: box-shadow var(--transition-fast), transform var(--transition-fast), border-color var(--transition-fast);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

.calendar-day:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
    border-color: var(--border-light);
}

.calendar-grid.calendar-range-mode .calendar-day {
    cursor: crosshair;
}

.calendar-day-range {
    border-color: rgba(230, 193, 117, 0.55);
    background: rgba(230, 193, 117, 0.08);
}

.calendar-day-range-start,
.calendar-day-range-end {
    border-color: rgba(230, 193, 117, 0.9);
    box-shadow: 0 0 0 2px rgba(230, 193, 117, 0.18);
}

.calendar-day-range .calendar-day-number {
    color: var(--text-primary);
}

.calendar-day-outside {
    opacity: 0.55;
}

.calendar-day-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 0.5rem;
}

.calendar-day-number {
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--text-primary);
}

.calendar-day-body {
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow: hidden;
    min-width: 0;
}

.calendar-event-pill {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 6px;
    border-radius: 10px;
    background: rgba(230, 193, 117, 0.1);
    border: 1px solid rgba(230, 193, 117, 0.25);
    color: var(--text-primary);
    font-size: 0.72rem;
    line-height: 1.2;
    overflow: hidden;
    min-width: 0;
}

.calendar-event-pill:hover {
    background: rgba(230, 193, 117, 0.14);
    border-color: rgba(230, 193, 117, 0.35);
}

.calendar-event-source-wedding {
    background: rgba(142, 133, 122, 0.14);
    border-color: rgba(142, 133, 122, 0.35);
}

.calendar-event-source-wedding:hover {
    background: rgba(142, 133, 122, 0.18);
    border-color: rgba(142, 133, 122, 0.45);
}

.calendar-event-source-woocommerce {
    border-left: 4px solid #E6DED3;
}

.calendar-event-source-google_calendar {
    background: rgba(66, 133, 244, 0.10);
    border-color: rgba(66, 133, 244, 0.30);
    border-left: 4px solid #4285F4;
}

.calendar-event-source-google_calendar:hover {
    background: rgba(66, 133, 244, 0.16);
    border-color: rgba(66, 133, 244, 0.40);
}

.calendar-event-status-expired,
.calendar-event-status-cancelled {
    opacity: 0.55;
}

.calendar-event-status-expired .calendar-event-title,
.calendar-event-status-cancelled .calendar-event-title {
    text-decoration: line-through;
}

.calendar-event-time {
    font-family: var(--font-mono);
    font-size: 0.68rem;
    color: var(--text-secondary);
    white-space: nowrap;
    flex-shrink: 0;
}

.calendar-event-title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

.calendar-more {
    margin-top: 2px;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.calendar-event-modal {
    max-width: 640px;
}

.calendar-details-modal {
    max-width: 720px;
}

.calendar-details-body {
    padding: 1.25rem 1.5rem;
}

.calendar-details-grid {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.calendar-details-row {
    display: grid;
    grid-template-columns: 180px 1fr;
    gap: 1rem;
    align-items: start;
}

.calendar-details-label {
    font-size: 0.72rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding-top: 0.15rem;
}

.calendar-details-value {
    color: var(--text-primary);
    font-weight: 500;
    white-space: pre-wrap;
}

.calendar-details-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
    background: var(--bg-tertiary);
}

.calendar-details-actions-left {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.calendar-block-mini {
    margin-top: 0.5rem;
    margin-bottom: 0.25rem;
}

.calendar-block-mini-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.6rem;
}

.calendar-block-mini-label {
    font-weight: 700;
    font-size: 1rem;
    color: var(--text-primary);
    text-transform: capitalize;
}

.calendar-block-mini-btn {
    min-width: 44px;
    padding: 0.35rem 0.6rem;
}

.calendar-mini-weekdays {
    gap: 6px;
    margin-bottom: 6px;
}

.calendar-block-mini .calendar-weekday {
    text-align: center;
    padding: 0;
}

.calendar-mini-grid {
    gap: 6px;
}

.calendar-block-mini .calendar-day {
    min-height: 44px;
    padding: 0.35rem;
    border-radius: 14px;
    align-items: center;
    justify-content: center;
}

.calendar-block-mini .calendar-day:hover {
    transform: none;
    box-shadow: none;
}

.calendar-block-mini .calendar-day-header {
    width: 100%;
    justify-content: center;
    margin: 0;
}

.calendar-block-mini .calendar-day-body {
    display: none;
}

.calendar-block-mini .calendar-day-number {
    font-size: 0.9rem;
}

@media (max-width: 600px) {
    .calendar-details-row {
        grid-template-columns: 1fr;
        gap: 0.35rem;
    }

    .calendar-details-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .calendar-details-actions-left {
        width: 100%;
    }

    .calendar-details-actions .btn {
        width: 100%;
        justify-content: center;
    }
}

.calendar-event-form {
    padding: 1.5rem;
}

#calendar-event-delete-btn {
    color: var(--error);
    border: 1px solid rgba(239, 68, 68, 0.35);
}

#calendar-event-delete-btn:hover {
    background: rgba(239, 68, 68, 0.08);
}

#calendar-ics-url {
    flex: 1 1 420px;
    min-width: 280px;
}

/* ============================================================================
   Clients (Klientki)
   ========================================================================== */

.clients-layout {
    display: grid;
    grid-template-columns: 1.25fr 0.75fr;
    gap: 1.5rem;
    align-items: start;
}

.client-profile-card {
    padding: 0;
}

.client-profile-header {
    padding: 1.25rem 1.25rem 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

.client-profile-empty {
    padding: 1.25rem;
}

.client-profile {
    padding: 1.25rem;
}

.profile-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1rem;
}

.profile-name {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.profile-sub {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.profile-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.profile-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.75rem;
}

.profile-item {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 0.85rem 0.9rem;
}

.profile-label {
    font-size: 0.72rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.profile-value {
    margin-top: 0.25rem;
    font-size: 0.95rem;
    color: var(--text-primary);
}

.customer-modal {
    max-width: 740px;
}

@media (max-width: 1100px) {
    .clients-layout {
        grid-template-columns: 1fr;
    }
}

/* ============================================================================
   Shop (Sklep)
   ========================================================================== */

.shop-layout {
    display: grid;
    grid-template-columns: 1.25fr 0.75fr;
    gap: 1.5rem;
    align-items: start;
}

.shop-order-card {
    padding: 0;
}

.shop-order-detail {
    padding: 1.25rem;
}

.shop-order-summary {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1rem;
}

.shop-order-number {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary);
}

.shop-order-status {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.shop-order-sections {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.9rem;
}

.shop-order-section-title {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 0.35rem;
}

.shop-order-box {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 0.85rem 0.9rem;
}

.shop-bookings-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.shop-booking-item {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.65rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.6);
}

.shop-booking-item.selected {
    border: 2px solid rgba(230, 193, 117, 0.9);
    box-shadow: 0 10px 24px rgba(230, 193, 117, 0.18);
}

html:not([data-theme="light"]) .shop-booking-item {
    background: rgba(0, 0, 0, 0.25);
}

.shop-booking-title {
    font-weight: 600;
    color: var(--text-primary);
}

.shop-booking-time {
    color: var(--text-muted);
    white-space: nowrap;
}

@media (max-width: 1100px) {
    .shop-layout {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 980px) {
    .calendar-nav {
        width: 100%;
        justify-content: space-between;
    }
    .calendar-filters {
        width: 100%;
    }
    .calendar-search {
        flex: 1;
        min-width: 200px;
    }
    .calendar-weekdays,
    .calendar-grid {
        gap: 8px;
    }
    .calendar-day {
        min-height: 110px;
    }
}

/* ============================================================================
   WhatsApp Messaging Center
   ============================================================================ */

.wa-container {
    display: flex;
    height: calc(100vh - 160px);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
    background: var(--bg-card);
}

.wa-sidebar {
    width: 340px;
    min-width: 280px;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    background: var(--bg-secondary);
}

.wa-sidebar-header {
    display: flex;
    gap: 0.5rem;
    padding: 0.75rem;
    border-bottom: 1px solid var(--border-color);
    align-items: center;
}

.wa-sidebar-header .wa-search {
    flex: 1;
}

.wa-conversations {
    flex: 1;
    overflow-y: auto;
}

.wa-conv-item {
    display: flex;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    cursor: pointer;
    transition: background var(--transition-speed);
    border-bottom: 1px solid var(--border-color);
    align-items: center;
}

.wa-conv-item:hover {
    background: var(--bg-hover);
}

.wa-conv-item.active {
    background: var(--accent-glow);
    border-left: 3px solid var(--accent-primary);
}

.wa-conv-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--accent-glow);
    color: var(--accent-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.wa-conv-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.wa-conv-top {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}

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

.wa-conv-time {
    font-size: 0.75rem;
    color: var(--text-muted);
    flex-shrink: 0;
    margin-left: 0.5rem;
}

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

.wa-conv-preview {
    font-size: 0.82rem;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

.wa-unread-badge {
    background: var(--accent-primary);
    color: var(--bg-primary);
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.15rem 0.45rem;
    border-radius: 10px;
    flex-shrink: 0;
    margin-left: 0.5rem;
}

/* Nav unread badge */
.nav-badge {
    background: var(--accent-primary);
    color: var(--bg-primary);
    font-size: 0.65rem;
    font-weight: 700;
    padding: 0.1rem 0.4rem;
    border-radius: 10px;
    margin-left: auto;
}

/* Chat area */
.wa-chat {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.wa-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

.wa-chat-contact {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.wa-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--accent-glow);
    color: var(--accent-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 1rem;
}

.wa-chat-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-primary);
}

.wa-chat-phone {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Messages area */
.wa-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.wa-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    text-align: center;
    gap: 0.5rem;
}

.wa-empty-icon {
    font-size: 3rem;
    opacity: 0.5;
}

.wa-empty-state h3 {
    margin: 0;
    font-size: 1.1rem;
    color: var(--text-secondary);
}

.wa-empty-state p {
    margin: 0;
    font-size: 0.85rem;
}

.wa-msg {
    display: flex;
    max-width: 70%;
}

.wa-msg-in {
    align-self: flex-start;
}

.wa-msg-out {
    align-self: flex-end;
}

.wa-msg-bubble {
    padding: 0.5rem 0.75rem;
    border-radius: 12px;
    font-size: 0.9rem;
    line-height: 1.4;
    word-break: break-word;
}

.wa-msg-in .wa-msg-bubble {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
}

.wa-msg-out .wa-msg-bubble {
    background: var(--accent-primary);
    color: var(--bg-primary);
    border-bottom-right-radius: 4px;
}

.wa-msg-meta {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.3rem;
    margin-top: 0.2rem;
}

.wa-msg-time {
    font-size: 0.7rem;
    opacity: 0.7;
}

.wa-status-check {
    font-size: 0.7rem;
    opacity: 0.7;
}

.wa-status-check.read {
    color: #34b7f1;
    opacity: 1;
}

.wa-status-check.failed {
    color: var(--error);
    opacity: 1;
}

.wa-status-check.pending {
    font-size: 0.65rem;
}

/* Input bar */
.wa-input-bar {
    display: flex;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--border-color);
    background: var(--bg-secondary);
    align-items: center;
}

.wa-input-bar input {
    flex: 1;
    padding: 0.6rem 1rem;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-primary);
    font-family: var(--font-main);
    font-size: 0.9rem;
    outline: none;
}

.wa-input-bar input:focus {
    border-color: var(--accent-primary);
}

.wa-input-bar .btn {
    border-radius: 50%;
    width: 38px;
    height: 38px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* Templates list */
.wa-templates-list {
    max-height: 400px;
    overflow-y: auto;
}

.wa-template-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid var(--border-color);
    transition: background var(--transition-speed);
}

.wa-template-item:hover {
    background: var(--bg-hover);
}

.wa-template-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.wa-template-meta {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 0.15rem;
}

/* WhatsApp status dot */
.wa-status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

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

.wa-status-dot.disconnected {
    background: var(--text-muted);
}

/* Mobile responsive */
@media (max-width: 768px) {
    .wa-container {
        flex-direction: column;
        height: calc(100vh - 120px);
    }

    .wa-sidebar {
        width: 100%;
        max-height: 200px;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }

    .wa-msg {
        max-width: 85%;
    }
}

/* =========================================================================
   MESSENGER SECTION
   Mirrors WhatsApp layout with Messenger blue branding (#0084FF)
   ========================================================================= */

.msng-container {
    display: flex;
    height: calc(100vh - 140px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--bg-card);
}

.msng-sidebar {
    width: 320px;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.msng-sidebar-header {
    padding: 0.75rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.msng-sidebar-header .msng-search {
    flex: 1;
}

.msng-conversations {
    flex: 1;
    overflow-y: auto;
}

.msng-conv-item {
    display: flex;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid var(--border-color);
    transition: background var(--transition-speed);
    align-items: center;
}

.msng-conv-item:hover {
    background: var(--bg-hover);
}

.msng-conv-item.active {
    background: var(--bg-hover);
    border-left: 3px solid #0084FF;
}

.msng-conv-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    flex-shrink: 0;
    overflow: hidden;
    background: #0084FF;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 600;
    font-size: 1rem;
}

.msng-conv-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.msng-conv-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.msng-conv-top {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.5rem;
}

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

.msng-conv-time {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
    flex-shrink: 0;
}

.msng-conv-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
}

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

.msng-unread-badge {
    background: #0084FF;
    color: #fff;
    border-radius: 10px;
    padding: 0.1rem 0.5rem;
    font-size: 0.72rem;
    font-weight: 700;
    flex-shrink: 0;
    min-width: 20px;
    text-align: center;
}

/* Chat area */
.msng-chat {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.msng-chat-header {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-secondary);
}

.msng-chat-contact {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.msng-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #0084FF;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1rem;
    overflow: hidden;
    flex-shrink: 0;
}

.msng-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.msng-chat-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-primary);
}

.msng-chat-info {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Messages */
.msng-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.msng-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
}

.msng-empty-icon {
    font-size: 3rem;
    margin-bottom: 0.5rem;
}

.msng-empty-state h3 {
    margin: 0;
    color: var(--text-primary);
}

.msng-empty-state p {
    margin: 0.25rem 0 0;
    font-size: 0.9rem;
}

.msng-msg {
    max-width: 70%;
}

.msng-msg-in {
    align-self: flex-start;
}

.msng-msg-out {
    align-self: flex-end;
}

.msng-msg-bubble {
    padding: 0.5rem 0.85rem;
    border-radius: 18px;
    font-size: 0.9rem;
    line-height: 1.4;
    word-wrap: break-word;
}

.msng-msg-in .msng-msg-bubble {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
}

.msng-msg-out .msng-msg-bubble {
    background: #0084FF;
    color: #fff;
    border-bottom-right-radius: 4px;
}

.msng-msg-meta {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    margin-top: 0.15rem;
    justify-content: flex-end;
}

.msng-msg-time {
    font-size: 0.72rem;
    color: var(--text-muted);
}

.msng-status-check {
    font-size: 0.72rem;
    color: var(--text-muted);
}

.msng-status-check.read {
    color: #0084FF;
}

.msng-status-check.failed {
    color: var(--danger);
}

.msng-status-check.pending {
    opacity: 0.5;
}

/* Input bar */
.msng-input-bar {
    display: flex;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--border-color);
    background: var(--bg-secondary);
    align-items: center;
}

.msng-input-bar input {
    flex: 1;
    padding: 0.6rem 1rem;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-primary);
    font-family: var(--font-main);
    font-size: 0.9rem;
    outline: none;
}

.msng-input-bar input:focus {
    border-color: #0084FF;
}

.msng-input-bar .btn {
    border-radius: 50%;
    width: 38px;
    height: 38px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: #0084FF;
    border-color: #0084FF;
}

.msng-input-bar .btn:hover {
    background: #006FD6;
    border-color: #006FD6;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .msng-container {
        flex-direction: column;
        height: calc(100vh - 120px);
    }

    .msng-sidebar {
        width: 100%;
        max-height: 200px;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }

    .msng-msg {
        max-width: 85%;
    }
}

/* ==========================================================================
   Products (Produkty)
   ========================================================================== */

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

.products-table th {
    text-align: left;
    padding: 10px 12px;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    border-bottom: 2px solid var(--border-color);
    white-space: nowrap;
}

.products-table td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
    font-size: 0.9rem;
}

.product-row:hover {
    background: var(--hover-bg, rgba(0,0,0,0.02));
}

[data-theme="dark"] .product-row:hover {
    background: rgba(255,255,255,0.04);
}

.product-thumb {
    width: 50px;
    height: 50px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid var(--border-color);
}

.product-thumb-empty {
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary, #f5f5f5);
    border-radius: 6px;
    font-size: 1.5rem;
    border: 1px solid var(--border-color);
}

.product-img-cell {
    width: 60px;
    padding: 4px 8px !important;
}

.product-name {
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.3;
    max-width: 320px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.product-sku {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-family: 'JetBrains Mono', monospace;
}

.price-sale {
    text-decoration: line-through;
    color: var(--text-muted);
    font-size: 0.85em;
    margin-right: 4px;
}

.product-stock-badge {
    font-size: 0.82rem;
    white-space: nowrap;
}

.product-stock-badge.outofstock {
    color: var(--color-error, #dc3545);
}

.product-stock-badge.instock {
    color: var(--color-success, #28a745);
}

.product-stock-badge.onbackorder {
    color: var(--color-warning, #ffc107);
}

/* Product Edit Modal */
.product-edit-modal {
    width: 560px;
    max-width: 95vw;
    max-height: 85vh;
    overflow-y: auto;
}

.form-row {
    display: flex;
    gap: 16px;
}

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

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

.form-group label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.form-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-primary, #fff);
    color: var(--text-primary);
    font-size: 0.9rem;
    transition: border-color 0.2s;
    box-sizing: border-box;
}

.form-input:focus {
    outline: none;
    border-color: var(--color-primary, #c9a96e);
    box-shadow: 0 0 0 2px rgba(201, 169, 110, 0.15);
}

textarea.form-input {
    resize: vertical;
    font-family: inherit;
}

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

.pagination-ellipsis {
    padding: 4px 8px;
    color: var(--text-muted);
}

@media (max-width: 768px) {
    .products-table th:nth-child(4),
    .products-table td:nth-child(4),
    .products-table th:nth-child(5),
    .products-table td:nth-child(5) {
        display: none;
    }
    .product-name {
        max-width: 180px;
    }
    .form-row {
        flex-direction: column;
        gap: 0;
    }
}

/* ═══════════════════════════════════════════════════════════════
   Suknie — Model tabs & Image tabs
   ═══════════════════════════════════════════════════════════════ */

.sk-model-tabs, .sk-img-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 12px;
    border-bottom: 2px solid var(--border);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.sk-model-tab, .sk-img-tab {
    padding: 8px 16px;
    border: none;
    background: none;
    color: var(--text-muted);
    font-size: 0.9em;
    font-weight: 500;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    white-space: nowrap;
    min-height: 44px; /* touch target */
    transition: all 0.15s;
}
.sk-model-tab:hover, .sk-img-tab:hover {
    color: var(--text);
}
.sk-model-tab.active, .sk-img-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    font-weight: 600;
}
.sk-model-tab.has-data {
    color: var(--text);
}
.sk-model-tab.selected::after {
    content: ' ✓';
    color: #4CAF50;
}

/* Model panel */
.sk-model-panel {
    padding: 12px;
    background: var(--bg-secondary);
    border-radius: 8px;
    border: 1px solid var(--border);
    margin-bottom: 8px;
}
.sk-model-panel .form-row {
    display: flex;
    gap: 12px;
}
.sk-model-panel .form-group {
    flex: 1;
    min-width: 0;
}
.sk-model-panel .sk-model-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    flex-wrap: wrap;
}

/* Image panel */
.sk-img-panel {
    margin-bottom: 12px;
}
.sk-img-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 8px;
}
.sk-img-preview .sk-img-thumb {
    position: relative;
    width: 80px;
    height: 80px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border);
}
.sk-img-preview .sk-img-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.sk-img-preview .sk-img-thumb .sk-img-del {
    position: absolute;
    top: 2px;
    right: 2px;
    background: rgba(0,0,0,0.6);
    color: white;
    border: none;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    font-size: 13px;
    cursor: pointer;
    line-height: 22px;
    text-align: center;
}

/* ═══════════════════════════════════════════════════════════════
   Mobile responsiveness — Global
   ═══════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
    /* Sidebar collapse */
    .sidebar {
        position: fixed;
        left: -260px;
        top: 0;
        bottom: 0;
        z-index: 10000;
        width: 260px;
        transition: left 0.25s ease;
    }
    .sidebar.mobile-open {
        left: 0;
        box-shadow: 4px 0 20px rgba(0,0,0,0.3);
    }
    .main-content {
        margin-left: 0 !important;
        width: 100% !important;
    }
    .top-bar {
        padding: 8px 12px;
    }

    /* Full-width modals */
    .modal-content {
        width: 100% !important;
        max-width: 100% !important;
        height: 100vh !important;
        max-height: 100vh !important;
        border-radius: 0 !important;
        margin: 0 !important;
    }
    .modal-overlay {
        padding: 0 !important;
    }
    .modal-body {
        padding: 12px !important;
    }
    .modal-header {
        padding: 12px !important;
        position: sticky;
        top: 0;
        background: var(--bg);
        z-index: 10;
    }
    .modal-footer {
        padding: 12px !important;
        position: sticky;
        bottom: 0;
        background: var(--bg);
        z-index: 10;
        flex-wrap: wrap;
    }

    /* Touch-friendly inputs */
    .form-input, input, select, textarea {
        font-size: 16px !important; /* prevent iOS zoom */
        min-height: 44px;
        padding: 10px 12px;
    }
    .btn {
        min-height: 44px;
        padding: 10px 16px;
        font-size: 0.9em;
    }
    .btn-sm {
        min-height: 38px;
        padding: 8px 12px;
    }

    /* Stacked form rows */
    .form-row {
        flex-direction: column;
        gap: 0;
    }

    /* Model panel mobile */
    .sk-model-panel .form-row {
        flex-direction: column;
        gap: 0;
    }

    /* Table horizontal scroll */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Cards full width */
    .card {
        margin: 0 0 8px 0;
    }

    /* Stats row */
    .stats-row {
        flex-wrap: wrap;
        gap: 8px;
    }
    .stat-card {
        flex: 1 1 45%;
        min-width: 120px;
    }

    /* Hamburger menu button */
    .mobile-menu-btn {
        display: flex !important;
    }

    /* View header responsive */
    .view-header {
        flex-direction: column;
        gap: 8px;
        align-items: flex-start !important;
    }
}

/* Mobile menu button (hidden by default) */
.mobile-menu-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: none;
    background: none;
    color: var(--text);
    font-size: 1.4em;
    cursor: pointer;
    border-radius: 8px;
}
.mobile-menu-btn:hover {
    background: var(--bg-secondary);
}

/* Mobile overlay for sidebar */
.mobile-sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 9999;
}
.mobile-sidebar-overlay.active {
    display: block;
}

/* Ensure select elements same height as inputs */
select.form-input {
    height: auto;
    min-height: 44px;
    line-height: 1.4;
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23666' stroke-width='1.5' fill='none'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 12px;
    padding-right: 32px;
}

/* ═══════════════════════════════════════════
   Language Selector
   ═══════════════════════════════════════════ */

.lang-selector {
    position: relative;
    margin-bottom: 0.25rem;
}

.lang-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
    cursor: pointer;
    justify-content: center;
}

.lang-arrow {
    font-size: 0.6em;
    opacity: 0.6;
    margin-left: auto;
}

.lang-dropdown {
    position: absolute;
    bottom: 100%;
    left: 0;
    right: 0;
    background: var(--bg-secondary, #fff);
    border: 1px solid var(--border, #e0e0e0);
    border-radius: 8px;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.1);
    z-index: 100;
    overflow: hidden;
    margin-bottom: 4px;
}

.lang-option {
    display: block;
    width: 100%;
    padding: 0.6rem 0.75rem;
    background: none;
    border: none;
    text-align: left;
    font-size: 0.85rem;
    cursor: pointer;
    color: var(--text, #333);
    transition: background 0.15s;
}

.lang-option:hover {
    background: var(--bg-hover, #f5f5f5);
}

.lang-option + .lang-option {
    border-top: 1px solid var(--border, #e0e0e0);
}
