/* ============================================================
   SALES PORTAL - Modern Elegant Stylesheet
   ============================================================ */

/* ---------- RESET & BASE ---------- */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --sidebar-width: 260px;
    --sidebar-width-collapsed: 72px;
    --topbar-height: 64px;

    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;

    --sidebar-bg: #1e1b4b;
    --sidebar-bg-2: #312e81;
    --sidebar-text: #c7d2fe;
    --sidebar-text-hover: #ffffff;
    --sidebar-active-bg: rgba(99, 102, 241, 0.15);
    --sidebar-active-border: #818cf8;

    --bg-page: #f8fafc;
    --bg-card: #ffffff;
    --bg-hover: #f1f5f9;

    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;

    --border: #e2e8f0;
    --border-light: #f1f5f9;

    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #3b82f6;

    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
    --shadow: 0 4px 12px rgba(15, 23, 42, 0.06);
    --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.10);
    --shadow-xl: 0 20px 50px rgba(15, 23, 42, 0.15);

    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;

    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
    background: var(--bg-page);
    color: var(--text-primary);
    line-height: 1.6;
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: linear-gradient(180deg, var(--sidebar-bg) 0%, var(--sidebar-bg-2) 100%);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: width var(--transition), transform var(--transition);
    overflow: hidden;
    box-shadow: 4px 0 24px rgba(15, 23, 42, 0.08);
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px;
    border-bottom: 1px solid rgba(199, 210, 254, 0.1);
    min-height: 72px;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    overflow: hidden;
}

.logo-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.35);
}

.logo-text {
    font-weight: 700;
    font-size: 16px;
    color: #fff;
    letter-spacing: -0.3px;
    white-space: nowrap;
    opacity: 1;
    transition: opacity var(--transition);
}

.sidebar-collapse-btn {
    background: rgba(199, 210, 254, 0.1);
    border: none;
    color: var(--sidebar-text);
    width: 30px;
    height: 30px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    flex-shrink: 0;
}

.sidebar-collapse-btn:hover {
    background: rgba(199, 210, 254, 0.2);
    color: #fff;
}

.sidebar-collapse-btn svg {
    transition: transform var(--transition);
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px 12px;
}

.sidebar-nav::-webkit-scrollbar {
    width: 6px;
}
.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(199, 210, 254, 0.15);
    border-radius: 3px;
}
.sidebar-nav::-webkit-scrollbar-thumb:hover {
    background: rgba(199, 210, 254, 0.3);
}

/* Sidebar links */
.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 2px;
    transition: var(--transition);
    position: relative;
    white-space: nowrap;
}

.sidebar-link:hover {
    background: rgba(199, 210, 254, 0.08);
    color: var(--sidebar-text-hover);
}

.sidebar-link.active {
    background: var(--sidebar-active-bg);
    color: #fff;
    font-weight: 600;
}

.sidebar-link.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 20px;
    background: var(--sidebar-active-border);
    border-radius: 0 3px 3px 0;
}

.sidebar-icon {
    font-size: 18px;
    width: 24px;
    text-align: center;
    flex-shrink: 0;
    display: inline-flex;
    justify-content: center;
    align-items: center;
}

.sidebar-label {
    overflow: hidden;
    text-overflow: ellipsis;
    opacity: 1;
    transition: opacity var(--transition);
}

/* Sidebar group */
.sidebar-group {
    margin-top: 16px;
}

.sidebar-group-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 12px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: rgba(199, 210, 254, 0.5);
    cursor: default;
    user-select: none;
}

.sidebar-group-title .group-caret {
    display: none;
    transition: transform var(--transition);
}

.sidebar-group-items {
    display: block;
}

/* Sidebar footer */
.sidebar-footer {
    padding: 16px 12px;
    border-top: 1px solid rgba(199, 210, 254, 0.1);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-radius: var(--radius-sm);
    background: rgba(199, 210, 254, 0.05);
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 13px;
    color: #fff;
    flex-shrink: 0;
    letter-spacing: 0.5px;
}

.user-info {
    overflow: hidden;
    white-space: nowrap;
}

.user-name {
    font-weight: 600;
    font-size: 13px;
    color: #fff;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    font-size: 11px;
    color: rgba(199, 210, 254, 0.7);
    text-transform: capitalize;
}

.sidebar-logout {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: rgba(252, 165, 165, 0.9);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: var(--transition);
    white-space: nowrap;
}

.sidebar-logout:hover {
    background: rgba(239, 68, 68, 0.15);
    color: #fca5a5;
}

/* ---------- COLLAPSED SIDEBAR (desktop) ---------- */
body.sidebar-collapsed .sidebar {
    width: var(--sidebar-width-collapsed);
}

body.sidebar-collapsed .sidebar-header {
    padding: 20px 12px;
    justify-content: center;
}

body.sidebar-collapsed .sidebar-collapse-btn {
    display: none;
}

body.sidebar-collapsed .logo-text,
body.sidebar-collapsed .sidebar-label,
body.sidebar-collapsed .user-info,
body.sidebar-collapsed .sidebar-group-title span {
    opacity: 0;
    pointer-events: none;
    width: 0;
}

body.sidebar-collapsed .sidebar-link,
body.sidebar-collapsed .sidebar-logout {
    justify-content: center;
    padding: 10px;
}

body.sidebar-collapsed .sidebar-user {
    justify-content: center;
    padding: 6px;
}

body.sidebar-collapsed .sidebar-group-title {
    padding: 6px;
    justify-content: center;
    height: 10px;
    overflow: hidden;
}

body.sidebar-collapsed .sidebar-group {
    margin-top: 8px;
}

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

body.sidebar-collapsed .main-wrapper {
    margin-left: var(--sidebar-width-collapsed);
}

/* ---------- TOPBAR ---------- */
.topbar {
    height: var(--topbar-height);
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: var(--shadow-sm);
}

.sidebar-toggle {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.sidebar-toggle:hover {
    background: var(--bg-hover);
    color: var(--primary);
}

.topbar-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.3px;
    flex: 1;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 10px;
}

.topbar-badge {
    background: linear-gradient(135deg, #eef2ff, #e0e7ff);
    color: var(--primary-dark);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
}

/* ---------- MAIN CONTENT ---------- */
.main-content {
    flex: 1;
    padding: 28px;
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
}

/* ============================================================
   CARDS
   ============================================================ */
.card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 28px;
    box-shadow: var(--shadow);
    margin-bottom: 24px;
    border: 1px solid var(--border-light);
    transition: var(--transition);
}

.card:hover {
    box-shadow: var(--shadow-lg);
}

.card h2 {
    margin-bottom: 20px;
    color: var(--text-primary);
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.3px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ============================================================
   GRID
   ============================================================ */
.grid { display: grid; gap: 20px; }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }

/* ============================================================
   STAT CARDS
   ============================================================ */
.stat-card {
    color: #fff;
    padding: 24px;
    border-radius: var(--radius-lg);
    position: relative;
    overflow: hidden;
    transition: var(--transition);
    box-shadow: var(--shadow);
}

.stat-card::after {
    content: '';
    position: absolute;
    top: -50%;
    right: -30%;
    width: 180px;
    height: 180px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 50%;
    pointer-events: none;
}

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

.stat-card h3 {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    opacity: 0.9;
    margin-bottom: 10px;
    font-weight: 600;
    position: relative;
}

.stat-card .value {
    font-size: 28px;
    font-weight: 800;
    letter-spacing: -0.5px;
    position: relative;
}

.stat-card       { background: linear-gradient(135deg, #6366f1, #8b5cf6); }
.stat-card.green { background: linear-gradient(135deg, #10b981, #34d399); }
.stat-card.orange{ background: linear-gradient(135deg, #f59e0b, #fbbf24); }
.stat-card.pink  { background: linear-gradient(135deg, #ec4899, #f472b6); }
.stat-card.blue  { background: linear-gradient(135deg, #3b82f6, #60a5fa); }
.stat-card.purple{ background: linear-gradient(135deg, #8b5cf6, #a78bfa); }

/* ============================================================
   TABLES
   ============================================================ */
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
    font-size: 14px;
}

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

th {
    background: #f8fafc;
    font-size: 12px;
    text-transform: uppercase;
    color: var(--text-secondary);
    font-weight: 700;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--border);
}

tr:hover td {
    background: #fafbff;
}

/* ============================================================
   FORMS
   ============================================================ */
input, select, textarea, button {
    font-family: inherit;
    font-size: 14px;
}

input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="date"], select, textarea {
    width: 100%;
    padding: 11px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 14px;
    transition: var(--transition);
    background: #fff;
    color: var(--text-primary);
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
}

label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    font-size: 13px;
    color: var(--text-secondary);
    letter-spacing: 0.1px;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 11px 22px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    transition: var(--transition);
    text-decoration: none;
    white-space: nowrap;
    box-shadow: 0 2px 6px rgba(99, 102, 241, 0.2);
}

.btn:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(99, 102, 241, 0.3);
}

.btn:active { transform: translateY(0); }

.btn-green     { background: var(--success); box-shadow: 0 2px 6px rgba(16,185,129,0.2); }
.btn-green:hover{ background: #059669; box-shadow: 0 6px 16px rgba(16,185,129,0.3); }

.btn-danger     { background: var(--danger); box-shadow: 0 2px 6px rgba(239,68,68,0.2); }
.btn-danger:hover{ background: #dc2626; box-shadow: 0 6px 16px rgba(239,68,68,0.3); }

.btn-warning     { background: var(--warning); box-shadow: 0 2px 6px rgba(245,158,11,0.2); }
.btn-warning:hover{ background: #d97706; box-shadow: 0 6px 16px rgba(245,158,11,0.3); }

.btn-info     { background: var(--info); box-shadow: 0 2px 6px rgba(59,130,246,0.2); }
.btn-info:hover{ background: #2563eb; box-shadow: 0 6px 16px rgba(59,130,246,0.3); }

.btn-purple     { background: #8b5cf6; box-shadow: 0 2px 6px rgba(139,92,246,0.2); }
.btn-purple:hover{ background: #7c3aed; box-shadow: 0 6px 16px rgba(139,92,246,0.3); }

.btn-secondary     { background: #64748b; box-shadow: 0 2px 6px rgba(100,116,139,0.2); }
.btn-secondary:hover{ background: #475569; box-shadow: 0 6px 16px rgba(100,116,139,0.3); }

.btn-primary     { background: #1e3a5f; box-shadow: 0 2px 6px rgba(30,58,95,0.2); }
.btn-primary:hover{ background: #0f2942; box-shadow: 0 6px 16px rgba(30,58,95,0.3); }

.btn-sm { padding: 7px 14px; font-size: 12.5px; border-radius: 6px; }
.btn-block { display: flex; width: 100%; text-align: center; }

/* ============================================================
   ALERTS
   ============================================================ */
.alert {
    padding: 14px 18px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
}

.alert-success { background: #f0fdf4; color: #166534; border-left: 4px solid var(--success); }
.alert-error   { background: #fef2f2; color: #991b1b; border-left: 4px solid var(--danger); }
.alert-info    { background: #eff6ff; color: #1e40af; border-left: 4px solid var(--info); }

/* ============================================================
   AUTH PAGE (login/register/forgot)
   ============================================================ */
.auth-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    position: relative;
}

.auth-container::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        radial-gradient(circle at 20% 30%, rgba(255,255,255,0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 70%, rgba(255,255,255,0.08) 0%, transparent 50%);
    pointer-events: none;
}

.auth-wrap {
    width: 100%;
    max-width: 440px;
    position: relative;
    z-index: 1;
}

.auth-wrap .card {
    padding: 36px 32px;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    border: none;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(10px);
    margin-bottom: 0;
}

.auth-wrap .card h2 {
    justify-content: center;
    font-size: 24px;
    margin-bottom: 24px;
}

.auth-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 24px;
    background: var(--bg-page);
    padding: 4px;
    border-radius: var(--radius);
}

.auth-tabs button {
    flex: 1;
    padding: 10px;
    background: transparent;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    color: var(--text-secondary);
    transition: var(--transition);
    font-size: 13px;
}

.auth-tabs button.active {
    background: #fff;
    color: var(--primary);
    box-shadow: var(--shadow-sm);
}

.auth-panel { display: none; }
.auth-panel.active { display: block; animation: fadeIn 0.3s ease; }

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

/* ============================================================
   GALLERY
   ============================================================ */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 18px;
}

.gallery-item {
    background: var(--bg-card);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: var(--transition);
    border: 1px solid var(--border-light);
}

.gallery-item:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.gallery-item img, .gallery-item video {
    width: 100%;
    height: 170px;
    object-fit: cover;
    display: block;
    background: #0f172a;
}

.gallery-item .info {
    padding: 12px 14px;
    font-size: 12px;
    color: var(--text-muted);
}

.gallery-item .info strong {
    display: block;
    color: var(--text-primary);
    font-size: 13px;
    margin-bottom: 4px;
    word-break: break-all;
    font-weight: 600;
}

/* ============================================================
   BADGES & STATUS
   ============================================================ */
.badge {
    background: linear-gradient(135deg, #eef2ff, #e0e7ff);
    color: var(--primary-dark);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    display: inline-block;
}

.status {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    display: inline-block;
    letter-spacing: 0.2px;
}
.status-draft    { background: #fef3c7; color: #92400e; }
.status-sent     { background: #dbeafe; color: #1e40af; }
.status-accepted { background: #d1fae5; color: #065f46; }
.status-rejected { background: #fee2e2; color: #991b1b; }
.status-paid     { background: #d1fae5; color: #065f46; }
.status-cancelled{ background: #f1f5f9; color: #475569; }

.role-badge {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    display: inline-block;
}
.role-admin { background: linear-gradient(135deg, var(--primary), var(--primary-light)); color: #fff; }
.role-sales { background: #e2e8f0; color: var(--text-secondary); }

/* Rank medals */
.rank-1, .rank-2, .rank-3 {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-weight: 700;
    font-size: 13px;
}
.rank-1 { background: linear-gradient(135deg, #fbbf24, #fcd34d); color: #78350f; box-shadow: 0 4px 12px rgba(251,191,36,0.4); }
.rank-2 { background: linear-gradient(135deg, #cbd5e1, #e2e8f0); color: #334155; box-shadow: 0 4px 12px rgba(148,163,184,0.3); }
.rank-3 { background: linear-gradient(135deg, #d97706, #f59e0b); color: #fff; box-shadow: 0 4px 12px rgba(217,119,6,0.3); }

/* ============================================================
   UTILITIES
   ============================================================ */
.flex-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.hint {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: -8px;
    margin-bottom: 14px;
}

.inline-form {
    display: flex;
    gap: 8px;
    align-items: center;
}
.inline-form select {
    margin-bottom: 0;
    width: auto;
    padding: 7px 12px;
    font-size: 13px;
}

.tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}
.tabs a {
    padding: 8px 16px;
    background: var(--bg-hover);
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    transition: var(--transition);
}
.tabs a:hover { background: var(--border); }
.tabs a.active { background: var(--primary); color: #fff; }

/* ============================================================
   QUOTATION ITEMS TABLE
   ============================================================ */
.items-table-form {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border-radius: var(--radius);
    overflow: hidden;
}

.items-table-form th {
    background: #f1f5f9;
    padding: 12px 8px;
    text-align: center;
    font-size: 12px;
    border: 1px solid var(--border);
}

.items-table-form td {
    padding: 10px 6px;
    border: 1px solid var(--border);
    vertical-align: middle;
}

.items-table-form input {
    width: 100%;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    margin-bottom: 0;
}

.item-image-preview {
    width: 55px;
    height: 55px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    cursor: pointer;
    display: block;
    margin: 0 auto 5px;
}

.image-upload-btn {
    background: var(--info);
    color: white;
    border: none;
    padding: 4px 10px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 11px;
    margin-top: 5px;
    font-weight: 600;
    transition: var(--transition);
}
.image-upload-btn:hover { background: #2563eb; }

.discount-summary {
    background: #f0fdf4;
    border: 2px solid #86efac;
    border-radius: var(--radius);
    padding: 14px 18px;
    margin-top: 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}
.discount-summary .label { font-weight: 600; color: #166534; }
.discount-summary .value { font-weight: 700; color: #dc2626; font-size: 16px; }

/* ============================================================
   QUOTATION PAPER (print preview)
   ============================================================ */
.quotation-paper {
    font-family: 'Segoe UI', Arial, sans-serif;
    max-width: 100%;
    background: white;
    color: #1e293b;
    line-height: 1.4;
    padding: 20px;
    border-radius: var(--radius);
}

.quotation-paper .header-section {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    border-bottom: 2px solid #1e3a5f;
    padding-bottom: 15px;
    margin-bottom: 20px;
}
.quotation-paper .company-area {
    display: flex;
    gap: 15px;
    align-items: center;
    flex-wrap: wrap;
}
.quotation-paper .company-logo-img {
    max-width: 100px;
    max-height: 75px;
    object-fit: contain;
}
.quotation-paper .company-area h2 { font-size: 18px; margin: 0; color: #1e3a5f; }
.quotation-paper .company-area p { font-size: 9px; margin: 2px 0; }
.quotation-paper .title-area { text-align: right; }
.quotation-paper .title-area h3 { color: #1e3a5f; font-size: 16px; margin-bottom: 5px; }
.quotation-paper .title-area p { font-size: 9px; margin: 2px 0; }
.quotation-paper .customer-block,
.quotation-paper .terms-block { margin-bottom: 12px; font-size: 9px; }
.quotation-paper table.items-table {
    width: 100%;
    border-collapse: collapse;
    margin: 15px 0;
    font-size: 8px;
}
.quotation-paper .items-table th {
    background: #1e3a5f;
    color: white;
    padding: 6px 4px;
    text-align: center;
    font-size: 8px;
    font-weight: 600;
}
.quotation-paper .items-table td {
    border: 1px solid #cbd5e1;
    padding: 5px 4px;
    vertical-align: middle;
    font-size: 8px;
}
.quotation-paper .totals { text-align: right; margin-top: 10px; font-size: 9px; }
.quotation-paper .totals p { margin: 2px 0; font-size: 9px; }
.quotation-paper .totals h3 { font-size: 10px; color: #0f3b5c; margin-top: 5px; }
.quotation-paper .bank-box {
    background: #eef2ff;
    padding: 8px 10px;
    border-radius: 8px;
    margin: 15px 0;
    font-size: 8px;
}
.quotation-paper .signatures {
    display: flex;
    justify-content: space-between;
    margin-top: 20px;
    font-size: 9px;
}
.quotation-paper .additional-note {
    background: #fffbeb;
    border-left: 3px solid #f59e0b;
    padding: 8px 10px;
    border-radius: 6px;
    margin: 12px 0;
    font-size: 8px;
    white-space: pre-line;
}

/* ============================================================
   SELECT PICKER
   ============================================================ */
.selectpicker {
    appearance: none;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="%236c757d" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="6 9 12 15 18 9"></polyline></svg>');
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 16px;
    padding-right: 2.5rem;
    cursor: pointer;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    z-index: 99;
    backdrop-filter: blur(2px);
}

@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
        width: var(--sidebar-width);
        box-shadow: 4px 0 24px rgba(15, 23, 42, 0.15);
    }
    body.sidebar-mobile-open .sidebar {
        transform: translateX(0);
    }
    body.sidebar-mobile-open .sidebar-overlay {
        display: block;
        animation: fadeIn 0.2s ease;
    }
    .main-wrapper {
        margin-left: 0;
    }
    body.sidebar-collapsed .main-wrapper {
        margin-left: 0;
    }
    .sidebar-collapse-btn {
        display: none;
    }
    .sidebar-group-title {
        cursor: pointer;
    }
    .sidebar-group-title .group-caret {
        display: block;
    }
    .sidebar-group.open .group-caret {
        transform: rotate(180deg);
    }
    .sidebar-group.open .sidebar-group-items {
        display: block;
    }
    .sidebar-group:not(.open) .sidebar-group-items {
        display: none;
    }
    /* Ensure collapsed styles don't apply on mobile */
    body.sidebar-collapsed .sidebar { width: var(--sidebar-width); }
    body.sidebar-collapsed .logo-text,
    body.sidebar-collapsed .sidebar-label,
    body.sidebar-collapsed .user-info { opacity: 1; width: auto; }
}

@media (max-width: 640px) {
    .main-content { padding: 20px 16px; }
    .card { padding: 20px; }
    .topbar { padding: 0 16px; }
    .topbar-title { font-size: 16px; }
    .topbar-badge { display: none; }
    .form-row { grid-template-columns: 1fr; }
    th, td { padding: 10px 8px; font-size: 13px; }
    .stat-card .value { font-size: 22px; }
    .auth-wrap .card { padding: 26px 22px; }
}

/* ============================================================
   PRINT
   ============================================================ */
@media print {
    body { background: white !important; }
    .sidebar, .topbar, .btn, .no-print, .alert { display: none !important; }
    .main-wrapper { margin-left: 0 !important; }
    .main-content { padding: 0 !important; }
    .card { box-shadow: none !important; padding: 0 !important; border: none !important; }
    .quotation-paper { margin: 0 !important; padding: 0.15in !important; }
    .quotation-paper * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
    @page { size: A4 portrait; margin: 0.3in; }
}

/* ============================================================
   ANIMATIONS
   ============================================================ */
@keyframes spin { to { transform: rotate(360deg); } }
.loading { text-align: center; padding: 40px; color: var(--text-muted); }
.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--primary);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 15px;
}
/* ============================================================
   PROJECT PIPELINE — status colors
   ============================================================ */
.status-won  { background: #d1fae5; color: #065f46; font-weight:600; }
.status-lost { background: #fee2e2; color: #991b1b; font-weight:600; }
.status-hold { background: #fef3c7; color: #92400e; font-weight:600; }

/* ============================================================
   PROJECT PIPELINE — stale warning (over 4 weeks without update)
   ============================================================ */
.pipeline-stale {
    background: linear-gradient(90deg, #fef2f2 0%, #fff5f5 100%) !important;
    border-left: 4px solid #dc2626 !important;
}

.pipeline-stale td {
    border-bottom: 1px solid #fecaca !important;
}

.pipeline-stale:hover td {
    background: #fee2e2 !important;
}

@keyframes stalePulse {
    0%, 100% { background: linear-gradient(90deg, #fef2f2 0%, #fff5f5 100%); }
    50%      { background: linear-gradient(90deg, #fee2e2 0%, #fef2f2 100%); }
}

.pipeline-stale {
    animation: stalePulse 2.5s ease-in-out infinite;
}

.stale-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: #dc2626;
    color: #fff;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 10px;
    font-weight: 700;
    margin-left: 6px;
}
/* ============================================================
   FOLLOW-UP CALENDAR
   ============================================================ */
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 6px;
    background: #e2e8f0;
    padding: 6px;
    border-radius: 12px;
    border: 1px solid #cbd5e1;
}

.calendar-weekday {
    background: #f1f5f9;
    padding: 10px 6px;
    text-align: center;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #475569;
    border-radius: 6px;
}

.calendar-cell {
    background: #fff;
    border-radius: 8px;
    min-height: 110px;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    transition: box-shadow 0.2s ease;
    position: relative;
}

.calendar-cell:hover {
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
}

.calendar-empty {
    background: #f8fafc;
    opacity: 0.5;
}

.calendar-today {
    background: #eef2ff;
    border: 2px solid #818cf8;
    box-shadow: 0 0 0 3px rgba(129, 140, 248, 0.15);
}

.calendar-today .calendar-daynum {
    color: #4f46e5;
}

.calendar-has-overdue {
    background: linear-gradient(180deg, #fff 0%, #fef2f2 100%);
    border: 1px solid #fecaca;
}

.calendar-daynum {
    font-size: 13px;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 2px;
}

.calendar-items {
    display: flex;
    flex-direction: column;
    gap: 3px;
    overflow: hidden;
}

.calendar-item {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 4px 6px;
    border-radius: 5px;
    font-size: 11px;
    font-weight: 500;
    text-decoration: none;
    color: #1e293b;
    background: #f1f5f9;
    border-left: 3px solid #94a3b8;
    transition: all 0.15s ease;
    overflow: hidden;
    white-space: nowrap;
}

.calendar-item:hover {
    transform: translateX(2px);
    background: #e0e7ff;
}

.calendar-item .cal-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #94a3b8;
    flex-shrink: 0;
}

.calendar-item .cal-text {
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

/* Status colors */
.calendar-item.cal-hold {
    background: #fef3c7;
    border-left-color: #f59e0b;
}
.calendar-item.cal-hold .cal-dot { background: #f59e0b; }

.calendar-item.cal-won {
    background: #d1fae5;
    border-left-color: #10b981;
}
.calendar-item.cal-won .cal-dot { background: #10b981; }

.calendar-item.cal-lost {
    background: #fee2e2;
    border-left-color: #ef4444;
}
.calendar-item.cal-lost .cal-dot { background: #ef4444; }

/* Overdue variant (Hold + past date) */
.calendar-item.cal-overdue {
    background: #fef2f2;
    border-left-color: #dc2626;
    font-weight: 700;
    color: #991b1b;
    animation: calPulse 2s ease-in-out infinite;
}
.calendar-item.cal-overdue .cal-dot {
    background: #dc2626;
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.2);
}

@keyframes calPulse {
    0%, 100% { box-shadow: inset 0 0 0 0 rgba(220, 38, 38, 0); }
    50%      { box-shadow: inset 0 0 0 2px rgba(220, 38, 38, 0.15); }
}

.calendar-more {
    font-size: 10px;
    color: #64748b;
    text-align: center;
    padding: 2px 4px;
    font-weight: 600;
    background: #f1f5f9;
    border-radius: 5px;
    margin-top: 2px;
}

/* Mobile responsive */
@media (max-width: 900px) {
    .calendar-grid {
        grid-template-columns: repeat(7, minmax(60px, 1fr));
        gap: 3px;
        padding: 3px;
    }
    .calendar-cell {
        min-height: 80px;
        padding: 4px;
    }
    .calendar-weekday {
        padding: 6px 2px;
        font-size: 10px;
    }
    .calendar-daynum {
        font-size: 11px;
    }
    .calendar-item {
        font-size: 9px;
        padding: 3px 4px;
    }
    .calendar-item .cal-text {
        display: none; /* Hide text, keep dots on small screens */
    }
    .calendar-item {
        justify-content: center;
    }
}
/* ============================================================
   KPI TARGETS — Progress bars, cards, achievement colors
   ============================================================ */

/* KPI progress card */
.kpi-card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 16px 18px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: box-shadow 0.2s ease, transform 0.15s ease;
}
.kpi-card:hover {
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.08);
    transform: translateY(-1px);
}

.kpi-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #64748b;
}

.kpi-values {
    display: flex;
    align-items: baseline;
    gap: 6px;
    flex-wrap: wrap;
}

.kpi-current {
    font-size: 24px;
    font-weight: 800;
    color: #0f172a;
    letter-spacing: -0.5px;
    line-height: 1.1;
}

.kpi-target {
    font-size: 13px;
    color: #94a3b8;
    font-weight: 600;
}

.kpi-percent {
    margin-left: auto;
    font-size: 14px;
    font-weight: 800;
    padding: 3px 10px;
    border-radius: 20px;
    white-space: nowrap;
}

/* Achievement colors */
.kpi-percent.kpi-green  { background: #d1fae5; color: #065f46; }
.kpi-percent.kpi-yellow { background: #fef3c7; color: #92400e; }
.kpi-percent.kpi-orange { background: #fed7aa; color: #9a3412; }
.kpi-percent.kpi-red    { background: #fee2e2; color: #991b1b; }
.kpi-percent.kpi-gray   { background: #f1f5f9; color: #64748b; }

/* Progress bar track */
.kpi-bar {
    width: 100%;
    height: 10px;
    background: #f1f5f9;
    border-radius: 20px;
    overflow: hidden;
    position: relative;
}

/* Progress bar fill */
.kpi-bar-fill {
    height: 100%;
    border-radius: 20px;
    transition: width 0.6s ease;
    position: relative;
    overflow: hidden;
}

.kpi-bar-fill.kpi-green  { background: linear-gradient(90deg, #10b981, #34d399); }
.kpi-bar-fill.kpi-yellow { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.kpi-bar-fill.kpi-orange { background: linear-gradient(90deg, #f97316, #fb923c); }
.kpi-bar-fill.kpi-red    { background: linear-gradient(90deg, #dc2626, #ef4444); }
.kpi-bar-fill.kpi-gray   { background: #cbd5e1; }

/* Subtle shimmer on the fill for "achieved" status */
.kpi-bar-fill.kpi-green::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(255,255,255,0.35) 50%,
        transparent 100%
    );
    animation: kpiShimmer 2.4s ease-in-out infinite;
}

@keyframes kpiShimmer {
    0%   { transform: translateX(-100%); }
    100% { transform: translateX(200%); }
}

/* Footer note (e.g., "5 more to go") */
.kpi-note {
    font-size: 11.5px;
    color: #64748b;
    margin-top: 2px;
}

/* Rep container — one section per sales user */
.kpi-rep-section {
    background: #f8fafc;
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 20px;
    border: 1px solid #e2e8f0;
}

.kpi-rep-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 2px solid #e2e8f0;
}

.kpi-rep-name {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 17px;
    font-weight: 700;
    color: #0f172a;
}

.kpi-rep-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1, #818cf8);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
    font-size: 13px;
    letter-spacing: 0.5px;
    flex-shrink: 0;
}

.kpi-rep-period {
    font-size: 12px;
    color: #64748b;
    font-weight: 600;
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
}

/* Placeholder when no target set */
.kpi-no-target {
    background: #fff;
    border: 2px dashed #cbd5e1;
    border-radius: 12px;
    padding: 24px;
    text-align: center;
    color: #64748b;
}
.kpi-no-target .icon {
    font-size: 32px;
    margin-bottom: 8px;
    opacity: 0.6;
}
.kpi-no-target .title {
    font-size: 14px;
    font-weight: 700;
    color: #334155;
    margin-bottom: 4px;
}
.kpi-no-target .subtitle {
    font-size: 12px;
}
.kpi-no-target a {
    color: #6366f1;
    text-decoration: none;
    font-weight: 600;
}
.kpi-no-target a:hover {
    text-decoration: underline;
}

/* Mini KPI cards on dashboard */
.kpi-mini-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
}

/* Section header for dashboard mini widget */
.kpi-dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 14px;
}

.kpi-dashboard-header h2 {
    margin-bottom: 0;
    font-size: 18px;
}

.kpi-dashboard-period {
    font-size: 12px;
    color: #64748b;
    font-weight: 600;
    background: #f1f5f9;
    padding: 4px 12px;
    border-radius: 20px;
}

/* Badge for KPI achievement level */
.kpi-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.kpi-badge.kpi-green  { background: #d1fae5; color: #065f46; }
.kpi-badge.kpi-yellow { background: #fef3c7; color: #92400e; }
.kpi-badge.kpi-orange { background: #fed7aa; color: #9a3412; }
.kpi-badge.kpi-red    { background: #fee2e2; color: #991b1b; }

/* Mobile tweaks */
@media (max-width: 640px) {
    .kpi-current { font-size: 20px; }
    .kpi-grid { grid-template-columns: 1fr; }
    .kpi-rep-section { padding: 14px; }
    .kpi-rep-header { flex-direction: column; align-items: flex-start; }
}
/* ============================================================
   TRIAL REPORT ITEMS IN CALENDAR
   ============================================================ */
.calendar-item.cal-trial {
    background: #f3e8ff;
    border-left-color: #a855f7;
    color: #6b21a8;
}
.calendar-item.cal-trial .cal-dot {
    background: #a855f7;
}
.calendar-item.cal-trial:hover {
    background: #e9d5ff;
}