:root {
    --qs-primary: #1a1a2e;
    --qs-primary-light: #16213e;
    --qs-accent: #2563eb;
    --qs-accent-hover: #1d4ed8;
    --qs-success: #16a34a;
    --qs-success-light: #dcfce7;
    --qs-danger: #dc2626;
    --qs-danger-light: #fee2e2;
    --qs-warning: #f59e0b;
    --qs-warning-light: #fef3c7;
    --qs-info: #0ea5e9;
    --qs-info-light: #e0f2fe;
    --qs-gray-50: #f9fafb;
    --qs-gray-100: #f3f4f6;
    --qs-gray-200: #e5e7eb;
    --qs-gray-300: #d1d5db;
    --qs-gray-400: #9ca3af;
    --qs-gray-500: #6b7280;
    --qs-gray-600: #4b5563;
    --qs-gray-700: #374151;
    --qs-gray-800: #1f2937;
    --qs-gray-900: #111827;
    --qs-radius: 8px;
    --qs-radius-lg: 12px;
    --qs-shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --qs-shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
    --qs-shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
}

* { box-sizing: border-box; }

.qs-page {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--qs-gray-50);
    min-height: 100vh;
    color: var(--qs-gray-800);
    line-height: 1.6;
}

/* ---- Top Nav ---- */
.qs-topnav {
    background: var(--qs-primary);
    color: white;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--qs-shadow-md);
}
.qs-topnav-inner {
    padding: 0 24px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.qs-impersonation-banner {
    background: linear-gradient(90deg, #dc2626, #b91c1c);
    color: white;
    padding: 8px 24px;
    font-size: 13px;
    font-weight: 500;
    text-align: center;
}
.qs-impersonation-exit {
    background: rgba(255,255,255,0.2);
    border: 1px solid rgba(255,255,255,0.4);
    color: white;
    padding: 4px 14px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.15s;
    margin-left: 8px;
}
.qs-impersonation-exit:hover {
    background: rgba(255,255,255,0.35);
}
.qs-topnav-brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: white; }
.qs-topnav-brand img { height: 32px; }
.qs-topnav-brand span { font-weight: 700; font-size: 16px; letter-spacing: 0.5px; }
.qs-topnav-links { display: flex; align-items: center; gap: 8px; }
.qs-topnav-links a {
    color: rgba(255,255,255,0.85);
    text-decoration: none;
    padding: 8px 14px;
    border-radius: var(--qs-radius);
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
}
.qs-topnav-links a:hover, .qs-topnav-links a.active {
    background: rgba(255,255,255,0.15);
    color: white;
}
.qs-topnav-links a.qs-nav-help {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 36px;
    height: 36px;
    padding: 0;
}
.qs-topnav-links a.qs-nav-help svg { width: 18px; height: 18px; display: block; flex: none; }
.qs-nav-help-label { display: none; }
.qs-topnav-user {
    display: flex;
    align-items: center;
    gap: 10px;
    color: rgba(255,255,255,0.9);
    font-size: 14px;
}
.qs-topnav-user .qs-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--qs-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
}
.qs-btn-logout {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    color: white;
    padding: 6px 14px;
    border-radius: var(--qs-radius);
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
}
.qs-btn-logout:hover { background: rgba(255,255,255,0.2); }
.qs-btn-view-switch {
    background: rgba(255,255,255,0.12);
    border: 1px solid rgba(255,255,255,0.25);
    color: #93c5fd;
    padding: 5px 12px;
    border-radius: var(--qs-radius);
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    transition: all 0.2s;
    white-space: nowrap;
}
.qs-btn-view-switch:hover { background: rgba(255,255,255,0.22); color: white; }

/* ---- Main Content ---- */
.qs-main { max-width: 1280px; margin: 0 auto; padding: 24px; }
.qs-main-wide { max-width: 1440px; margin: 0 auto; padding: 24px; }

/* Compact back pill. Stays in the page header until that link scrolls
   under the nav, then the same pill follows in the left-hand gutter. */
.qs-back {
    display: inline-flex;
    align-items: center;
    width: fit-content;
    max-width: 100%;
    padding: 5px 11px;
    background: #fff;
    border: 1px solid var(--qs-gray-200);
    border-radius: 999px;
    color: var(--qs-gray-700);
    text-decoration: none;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.2;
    letter-spacing: -0.01em;
    white-space: nowrap;
    box-shadow: 0 1px 1px rgba(15, 23, 42, 0.04);
    transition: color .15s ease, border-color .15s ease, background .15s ease;
}
.qs-back:hover {
    color: var(--qs-accent);
    background: #f8fafc;
    border-color: #93c5fd;
}
.qs-back:focus-visible {
    outline: 2px solid var(--qs-accent);
    outline-offset: 2px;
}
.qs-back-float {
    position: fixed;
    top: calc(var(--qs-nav-h, 60px) + 12px);
    z-index: 90;
    /* Wide screens: empty gutter left of the 1440px column.
       Narrower screens: the max() pins it 12px from the left edge. */
    left: max(12px, calc((100vw - 1440px) / 2 - 248px));
    max-width: calc(100vw - 24px);
    box-shadow: var(--qs-shadow-md);
}
.qs-back-float[hidden] { display: none !important; }

/* ---- Cards ---- */
.qs-card {
    background: white;
    border-radius: var(--qs-radius-lg);
    box-shadow: var(--qs-shadow);
    padding: 24px;
    margin-bottom: 20px;
}
.qs-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--qs-gray-200);
}
.qs-card-header h2 { font-size: 18px; font-weight: 700; margin: 0; color: var(--qs-gray-900); }
.qs-card-header h3 { font-size: 16px; font-weight: 600; margin: 0; color: var(--qs-gray-900); }

/* ---- Stats Row ---- */
.qs-stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.qs-stat-card {
    background: white;
    border-radius: var(--qs-radius-lg);
    box-shadow: var(--qs-shadow);
    padding: 20px;
    text-align: center;
    transition: transform 0.15s, box-shadow 0.15s;
}
.qs-stat-card:hover { transform: translateY(-2px); box-shadow: var(--qs-shadow-md); }
.qs-stat-number { font-size: 32px; font-weight: 800; color: var(--qs-primary); }
.qs-stat-label { font-size: 13px; color: var(--qs-gray-500); margin-top: 4px; font-weight: 500; }
.qs-stat-card.accent .qs-stat-number { color: var(--qs-accent); }
.qs-stat-card.success .qs-stat-number { color: var(--qs-success); }
.qs-stat-card.warning .qs-stat-number { color: var(--qs-warning); }
.qs-stat-card.danger .qs-stat-number { color: var(--qs-danger); }

/* ---- Tables ---- */
.qs-table-wrap { overflow-x: auto; }
.qs-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
.qs-table thead tr { background: var(--qs-gray-50); }
.qs-table th {
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    color: var(--qs-gray-600);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--qs-gray-200);
}
.qs-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--qs-gray-100);
    vertical-align: middle;
}
.qs-table tbody tr { transition: background 0.15s; cursor: pointer; }
.qs-table tbody tr:hover { background: var(--qs-gray-50); }

/* ---- Status Badges ---- */
.qs-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    text-transform: capitalize;
}
.qs-badge-created { background: #bfdbfe; color: #1e40af; }
.qs-badge-pending { background: var(--qs-warning-light); color: #92400e; }
.qs-badge-accepted { background: #6ee7b7; color: #065f46; }
.qs-badge-declined { background: var(--qs-danger-light); color: #991b1b; }

/* ---- Buttons ---- */
.qs-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border-radius: var(--qs-radius);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
    text-decoration: none;
    line-height: 1.4;
}
.qs-btn-primary { background: var(--qs-accent); color: white; }
.qs-btn-primary:hover { background: var(--qs-accent-hover); }
.qs-btn-success { background: var(--qs-success); color: white; }
.qs-btn-success:hover { background: #15803d; }
.qs-btn-danger { background: var(--qs-danger); color: white; }
.qs-btn-danger:hover { background: #b91c1c; }
.qs-btn-outline {
    background: transparent;
    color: var(--qs-gray-700);
    border: 1px solid var(--qs-gray-300);
}
.qs-btn-outline:hover { background: var(--qs-gray-50); border-color: var(--qs-gray-400); }
.qs-btn-sm { padding: 6px 12px; font-size: 13px; }
.qs-btn-lg { padding: 14px 28px; font-size: 16px; }
.qs-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---- Forms ---- */
.qs-form-group { margin-bottom: 16px; }
.qs-form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--qs-gray-700);
    margin-bottom: 6px;
}
.qs-input, .qs-textarea, .qs-select {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--qs-gray-300);
    border-radius: var(--qs-radius);
    font-size: 14px;
    font-family: inherit;
    color: var(--qs-gray-800);
    background: white;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.qs-input:focus, .qs-textarea:focus, .qs-select:focus {
    outline: none;
    border-color: var(--qs-accent);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}
.qs-textarea { resize: vertical; min-height: 100px; }
.qs-input-error { border-color: var(--qs-danger); }
.qs-error-text { color: var(--qs-danger); font-size: 12px; margin-top: 4px; }

/* ---- Auth Pages ---- */
.qs-auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--qs-primary) 0%, var(--qs-primary-light) 100%);
    padding: 20px;
}
.qs-auth-container {
    width: 100%;
    max-width: 440px;
}
.qs-auth-logo {
    text-align: center;
    margin-bottom: 24px;
}
.qs-auth-logo img { height: 48px; }
.qs-auth-logo h1 { color: white; font-size: 20px; margin-top: 12px; font-weight: 600; }
.qs-auth-card {
    background: white;
    border-radius: var(--qs-radius-lg);
    box-shadow: var(--qs-shadow-lg);
    padding: 32px;
}
.qs-auth-card h2 { font-size: 22px; font-weight: 700; margin-bottom: 4px; color: var(--qs-gray-900); }
.qs-auth-card .qs-subtitle { color: var(--qs-gray-500); font-size: 14px; margin-bottom: 24px; }
.qs-auth-footer { text-align: center; margin-top: 20px; color: rgba(255,255,255,0.7); font-size: 14px; }
.qs-auth-footer a { color: white; font-weight: 600; text-decoration: none; }
.qs-auth-footer a:hover { text-decoration: underline; }
.qs-form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ---- Alerts ---- */
.qs-alert {
    padding: 12px 16px;
    border-radius: var(--qs-radius);
    font-size: 14px;
    margin-bottom: 16px;
    display: none;
}
.qs-alert.show { display: block; }
.qs-alert-success { background: var(--qs-success-light); color: #166534; border: 1px solid #bbf7d0; }
.qs-alert-error { background: var(--qs-danger-light); color: #991b1b; border: 1px solid #fecaca; }
.qs-alert-info { background: var(--qs-info-light); color: #0369a1; border: 1px solid #bae6fd; }
.qs-alert-warning { background: #fffbeb; color: #92400e; border: 1px solid #fcd34d; }

/* ---- File Upload Area ---- */
.qs-upload-area {
    border: 2px dashed var(--qs-gray-300);
    border-radius: var(--qs-radius-lg);
    padding: 32px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    background: var(--qs-gray-50);
}
.qs-upload-area:hover, .qs-upload-area.dragover {
    border-color: var(--qs-accent);
    background: rgba(37, 99, 235, 0.04);
}
.qs-upload-area svg { width: 48px; height: 48px; color: var(--qs-gray-400); margin-bottom: 12px; }
.qs-upload-area p { color: var(--qs-gray-500); font-size: 14px; margin: 0; }
.qs-upload-area .qs-upload-formats { font-size: 12px; color: var(--qs-gray-400); margin-top: 8px; }

/* ---- Part Items ---- */
.qs-part-item {
    border: 1px solid var(--qs-gray-200);
    border-radius: var(--qs-radius-lg);
    padding: 16px;
    margin-bottom: 12px;
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 16px;
    align-items: start;
    transition: box-shadow 0.15s;
}
.qs-part-item:hover { box-shadow: var(--qs-shadow); }
.qs-part-thumb {
    width: 80px;
    height: 80px;
    border-radius: var(--qs-radius);
    background: var(--qs-gray-100);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--qs-gray-400);
    font-size: 11px;
    text-transform: uppercase;
    font-weight: 700;
    overflow: hidden;
}
.qs-part-info { flex: 1; }
.qs-part-filename { font-weight: 600; font-size: 14px; color: var(--qs-gray-800); margin-bottom: 4px; }
.qs-part-meta { font-size: 12px; color: var(--qs-gray-500); }
.qs-part-actions { display: flex; flex-direction: column; gap: 8px; }

/* ---- Chat ---- */
.qs-chat-container {
    display: flex;
    flex-direction: column;
    height: 400px;
    border: 1px solid var(--qs-gray-200);
    border-radius: var(--qs-radius-lg);
    overflow: hidden;
}
.qs-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: var(--qs-gray-50);
}
.qs-chat-message {
    display: flex;
    flex-direction: column;
    margin-bottom: 12px;
    max-width: 75%;
}
.qs-chat-message.mine { align-self: flex-end; margin-left: auto; }
.qs-chat-message.theirs { align-self: flex-start; }
.qs-chat-bubble {
    position: relative;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.5;
    word-break: break-word;
}
.qs-chat-bubble:has(.qs-chat-bubble-actions) {
    padding-right: 46px;
}
.qs-chat-message.mine .qs-chat-bubble {
    background: var(--qs-accent);
    color: white;
    border-bottom-right-radius: 4px;
}
.qs-chat-message.theirs .qs-chat-bubble {
    background: white;
    color: var(--qs-gray-800);
    border: 1px solid var(--qs-gray-200);
    border-bottom-left-radius: 4px;
}
.qs-chat-sender { font-size: 11px; font-weight: 600; color: var(--qs-gray-500); margin-bottom: 3px; display: flex; align-items: center; gap: 6px; }
.qs-chat-time { font-size: 10px; color: var(--qs-gray-400); margin-top: 3px; }
.qs-chat-delete-btn {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--qs-gray-400);
    cursor: pointer;
    font-size: 13px;
    line-height: 1;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: all 0.15s;
    flex-shrink: 0;
}
.qs-chat-message:hover .qs-chat-delete-btn { opacity: 1; }
.qs-chat-delete-btn:hover { background: var(--qs-danger-light); color: var(--qs-danger); }

.qs-chat-msg-wrap {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    margin-bottom: 12px;
    width: 100%;
}
.qs-chat-msg-wrap.mine { justify-content: flex-end; }
.qs-chat-msg-wrap.theirs { justify-content: flex-start; }
.qs-chat-msg-wrap .qs-chat-message {
    margin-bottom: 0;
    margin-left: 0;
    align-self: auto;
}
.qs-chat-select-wrap {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    padding-top: 22px;
    cursor: pointer;
}
.qs-chat-select-cb {
    width: 15px;
    height: 15px;
    margin: 0;
    accent-color: #d97706;
    cursor: pointer;
}
.qs-chat-ping-one {
    position: relative;
    flex-shrink: 0;
    margin-top: 18px;
    width: 26px;
    height: 26px;
    padding: 0;
    border-radius: 6px;
    border: 1px solid #d97706;
    background: #fff;
    color: #d97706;
    cursor: pointer;
    font-size: 13px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.55;
    transition: opacity 0.15s, background 0.15s, border-color 0.15s, color 0.15s;
}
.qs-chat-msg-wrap:hover .qs-chat-ping-one,
.qs-chat-msg-wrap.selected .qs-chat-ping-one,
.qs-chat-ping-one.emailed {
    opacity: 1;
}
.qs-chat-ping-one:hover { background: #fff7ed; }
.qs-chat-ping-one:disabled { opacity: 0.4; cursor: default; }
.qs-chat-ping-one.emailed {
    border-color: #16a34a;
    color: #d97706;
}
.qs-chat-ping-mark {
    position: absolute;
    right: 1px;
    bottom: 0;
    font-size: 9px;
    font-weight: 800;
    line-height: 1;
    color: #16a34a;
    pointer-events: none;
}
.qs-chat-msg-wrap.selected .qs-chat-bubble {
    box-shadow: 0 0 0 2px #d97706;
}
.qs-chat-select-all-btn {
    background: none;
    border: none;
    padding: 0;
    font-size: 12px;
    color: var(--qs-gray-500);
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 2px;
    white-space: nowrap;
}
.qs-chat-select-all-btn:hover { color: #d97706; }
.qs-chat-bubble-actions {
    position: absolute;
    top: 3px;
    right: 3px;
    display: flex;
    align-items: center;
    gap: 3px;
    opacity: 0;
    pointer-events: none;
    z-index: 1;
}
.qs-chat-bubble:hover .qs-chat-bubble-actions {
    opacity: 1;
    pointer-events: auto;
}
.qs-chat-bubble-hide,
.qs-chat-bubble-x {
    width: 18px;
    height: 18px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: rgba(15, 23, 42, 0.35);
    color: #fff;
    cursor: pointer;
    font-size: 13px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.12s, color 0.12s;
}
.qs-chat-message.theirs .qs-chat-bubble-hide,
.qs-chat-message.theirs .qs-chat-bubble-x {
    background: rgba(15, 23, 42, 0.08);
    color: #475569;
}
.qs-chat-bubble-hide:hover { background: #d97706; color: #fff; }
.qs-chat-bubble-x:hover { background: #dc2626; color: #fff; }
.qs-chat-bubble-hide:disabled,
.qs-chat-bubble-x:disabled { opacity: 0.4; cursor: default; }
.qs-chat-msg-wrap.hidden-from-customer {
    opacity: 0.55;
}
.qs-chat-msg-wrap.hidden-from-customer .qs-chat-bubble {
    box-shadow: 0 0 0 2px #dc2626;
}
.qs-chat-hidden-badge {
    display: none;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: #b91c1c;
    margin-top: 3px;
}
.qs-chat-msg-wrap.hidden-from-customer .qs-chat-hidden-badge { display: block; }
.qs-chat-input-area {
    display: flex;
    gap: 8px;
    padding: 12px;
    background: white;
    border-top: 1px solid var(--qs-gray-200);
}
.qs-chat-input-area input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--qs-gray-300);
    border-radius: var(--qs-radius);
    font-size: 14px;
    font-family: inherit;
    min-width: 0;
}
.qs-chat-input-area input:focus { outline: none; border-color: var(--qs-accent); }

/* Chat file attachment button */
.qs-chat-attach-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: var(--qs-radius);
    border: 1px solid var(--qs-gray-300);
    background: white;
    cursor: pointer;
    color: var(--qs-gray-500);
    transition: all 0.15s;
    flex-shrink: 0;
    padding: 0;
}
.qs-chat-attach-btn:hover {
    border-color: var(--qs-accent);
    color: var(--qs-accent);
    background: rgba(37, 99, 235, 0.04);
}

/* Chat drop overlay */
.qs-chat-drop-overlay {
    display: none;
    position: absolute;
    inset: 0;
    background: rgba(37, 99, 235, 0.08);
    border: 2px dashed var(--qs-accent);
    border-radius: var(--qs-radius-lg);
    z-index: 10;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}
.qs-chat-drop-overlay.active { display: flex; }
.qs-chat-drop-label {
    background: white;
    padding: 12px 24px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 700;
    color: var(--qs-accent);
    box-shadow: 0 4px 20px rgba(37,99,235,0.15);
}

/* Chat file preview bar */
.qs-chat-file-preview {
    display: none;
    padding: 8px 12px;
    background: var(--qs-gray-50);
    border-top: 1px solid var(--qs-gray-200);
    align-items: center;
    gap: 10px;
    font-size: 12px;
    color: var(--qs-gray-600);
}
.qs-chat-file-preview.active { display: flex; }
.qs-chat-file-preview-thumb {
    width: 40px;
    height: 40px;
    border-radius: 6px;
    object-fit: cover;
    border: 1px solid var(--qs-gray-200);
}
.qs-chat-file-preview-icon {
    width: 40px;
    height: 40px;
    border-radius: 6px;
    background: var(--qs-gray-100);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 800;
    color: var(--qs-gray-500);
    text-transform: uppercase;
    flex-shrink: 0;
}
.qs-chat-file-preview-name {
    flex: 1;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.qs-chat-file-preview-remove {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: none;
    background: var(--qs-gray-200);
    color: var(--qs-gray-600);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    line-height: 1;
    transition: all 0.15s;
    flex-shrink: 0;
    padding: 0;
}
.qs-chat-file-preview-remove:hover {
    background: var(--qs-danger);
    color: white;
}

/* Chat bubble file attachments */
.qs-chat-bubble-image {
    max-width: 240px;
    border-radius: 8px;
    cursor: pointer;
    transition: opacity 0.15s;
    display: block;
    margin-top: 6px;
}
.qs-chat-bubble-image:hover { opacity: 0.85; }
.qs-chat-img-download {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-top: 4px;
    font-size: 11px;
    font-weight: 600;
    color: var(--qs-accent);
    text-decoration: none;
    opacity: 0.7;
    transition: opacity 0.15s;
}
.qs-chat-img-download:hover { opacity: 1; text-decoration: underline; }
.qs-chat-message.mine .qs-chat-img-download { color: rgba(255,255,255,0.75); }
.qs-chat-message.mine .qs-chat-img-download:hover { color: white; }
.qs-chat-file-attachment {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: rgba(0,0,0,0.06);
    border-radius: 8px;
    margin-top: 6px;
    text-decoration: none;
    color: inherit;
    font-size: 12px;
    font-weight: 600;
    transition: background 0.15s;
    max-width: 100%;
}
.qs-chat-file-attachment:hover { background: rgba(0,0,0,0.1); }
.qs-chat-message.mine .qs-chat-file-attachment {
    background: rgba(255,255,255,0.18);
    color: white;
}
.qs-chat-message.mine .qs-chat-file-attachment:hover {
    background: rgba(255,255,255,0.28);
}
.qs-chat-file-attachment-icon {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    background: rgba(0,0,0,0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    font-weight: 800;
    text-transform: uppercase;
    flex-shrink: 0;
}
.qs-chat-message.mine .qs-chat-file-attachment-icon {
    background: rgba(255,255,255,0.2);
}
.qs-chat-file-attachment-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.qs-chat-upload-progress {
    font-size: 11px;
    color: var(--qs-gray-400);
    padding: 4px 12px;
    display: none;
}
.qs-chat-upload-progress.active { display: block; }

/* ---- Pricing Table (Admin) ---- */
.qs-pricing-item {
    border: 1px solid var(--qs-gray-200);
    border-radius: var(--qs-radius-lg);
    padding: 20px;
    margin-bottom: 16px;
    background: white;
}
.qs-pricing-item-header {
    display: flex;
    align-items: start;
    justify-content: space-between;
    margin-bottom: 12px;
}
.qs-pricing-row {
    display: grid;
    grid-template-columns: 1fr 120px 120px 120px;
    gap: 12px;
    align-items: end;
}
.qs-line-total {
    font-size: 16px;
    font-weight: 700;
    color: var(--qs-primary);
    text-align: right;
    padding: 10px 0;
}
.qs-subtotal-bar {
    background: var(--qs-primary);
    color: white;
    padding: 16px 24px;
    border-radius: var(--qs-radius-lg);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 18px;
    font-weight: 700;
    margin-top: 16px;
}
.qs-subtotal-bar small { font-weight: 400; font-size: 12px; opacity: 0.7; }

/* ---- Detail Layout ---- */
.qs-detail-grid {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 24px;
}
/* A grid item defaults to min-width:auto, so it refuses to shrink below its
   widest unbreakable content: one long line anywhere inside the main column
   widens the whole column, and with it the page. Every truncation rule further
   down (text-overflow on a card header, a table set to 100%) is silently
   cancelled by it, which makes the symptom look like a broken card rather than
   a layout that cannot shrink. */
.qs-detail-grid > * { min-width: 0; }
@media (max-width: 900px) {
    .qs-detail-grid { grid-template-columns: 1fr; }
}

/* ---- Viewer Embed ---- */
.qs-viewer-frame {
    width: 100%;
    height: 300px;
    border: 1px solid var(--qs-gray-200);
    border-radius: var(--qs-radius);
    overflow: hidden;
}
.qs-viewer-frame iframe { width: 100%; height: 100%; border: none; }

/* ---- Loading ---- */
.qs-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: var(--qs-gray-400);
}
.qs-spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--qs-gray-200);
    border-top-color: var(--qs-accent);
    border-radius: 50%;
    animation: qs-spin 0.6s linear infinite;
    margin-right: 10px;
}
@keyframes qs-spin { to { transform: rotate(360deg); } }

/* ---- Empty State ---- */
.qs-empty {
    text-align: center;
    padding: 48px 24px;
    color: var(--qs-gray-400);
}
.qs-empty svg { width: 64px; height: 64px; margin-bottom: 12px; opacity: 0.5; }
.qs-empty p { font-size: 15px; margin: 0; }

/* ---- Utility ---- */
.qs-hidden { display: none !important; }
.qs-text-right { text-align: right; }
.qs-text-center { text-align: center; }
.qs-mt-8 { margin-top: 8px; }
.qs-mt-16 { margin-top: 16px; }
.qs-mt-24 { margin-top: 24px; }
.qs-mb-8 { margin-bottom: 8px; }
.qs-mb-16 { margin-bottom: 16px; }
.qs-flex { display: flex; }
.qs-flex-between { display: flex; justify-content: space-between; align-items: center; }
.qs-gap-8 { gap: 8px; }
.qs-gap-12 { gap: 12px; }

/* ---- Mobile Hamburger ---- */
.qs-mobile-toggle {
    display: none;
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 6px;
    line-height: 1;
    -webkit-tap-highlight-color: transparent;
}

@media (max-width: 768px) {
    .qs-topnav-inner {
        padding: 0 12px;
        flex-wrap: wrap;
        height: auto;
        min-height: 56px;
    }
    .qs-mobile-toggle { display: block; }
    .qs-topnav-brand span { font-size: 14px; }
    .qs-topnav-brand img { height: 28px; }

    .qs-topnav-links {
        display: none;
        width: 100%;
        flex-direction: column;
        gap: 0;
        padding: 4px 0 10px;
        order: 10;
    }
    .qs-topnav-links.open { display: flex; }
    .qs-topnav-links a {
        padding: 10px 12px;
        font-size: 14px;
        border-radius: 6px;
    }
    .qs-topnav-links a:hover,
    .qs-topnav-links a.active {
        background: rgba(255,255,255,0.12);
    }
    .qs-topnav-links a.qs-nav-help {
        width: auto;
        height: auto;
        padding: 10px 12px;
        justify-content: flex-start;
    }
    .qs-nav-help-label { display: inline; }

    .qs-topnav-user {
        display: none;
        width: 100%;
        justify-content: space-between;
        padding: 8px 0 10px;
        border-top: 1px solid rgba(255,255,255,0.1);
        order: 11;
    }
    .qs-topnav-user.open { display: flex; }

    .qs-main, .qs-main-wide { padding: 14px 12px; }

    .qs-stats-row {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    .qs-stat-card { padding: 14px 10px; }
    .qs-stat-number { font-size: 26px; }
    .qs-stat-label { font-size: 11px; }

    .qs-card { padding: 16px 12px; margin-bottom: 14px; }
    .qs-card-header { gap: 8px; }
    .qs-card-header h2 { font-size: 16px; }
    .qs-card-header h3 { font-size: 15px; }

    .qs-table th { padding: 10px 10px; font-size: 11px; }
    .qs-table td { padding: 10px 10px; font-size: 13px; }

    .qs-form-row { grid-template-columns: 1fr; }
    .qs-pricing-row { grid-template-columns: 1fr 1fr; }
    .qs-part-item { grid-template-columns: 1fr; }
    .qs-part-thumb { width: 100%; height: 60px; }

    .qs-empty { padding: 32px 16px; }

    .qs-subtotal-bar { padding: 12px 16px; font-size: 16px; flex-wrap: wrap; gap: 4px; }
    .qs-pricing-row { grid-template-columns: 1fr; }
    .qs-pricing-item { padding: 14px; }

    .qs-auth-card { padding: 24px 18px; }
    .qs-auth-card h2 { font-size: 20px; }
}

@media (max-width: 480px) {
    .qs-stats-row { gap: 8px; }
    .qs-stat-card { padding: 12px 8px; }
    .qs-stat-number { font-size: 22px; }
    .qs-stat-label { font-size: 10px; }
    .qs-main, .qs-main-wide { padding: 10px 8px; }
    .qs-card { padding: 12px 10px; }
}

/* ---- Part Card (New Quote) ---- */
.qs-part-card {
    border: 1px solid var(--qs-gray-200);
    border-radius: var(--qs-radius-lg);
    margin-bottom: 16px;
    background: white;
    transition: box-shadow 0.2s;
}
.qs-part-card:hover { box-shadow: var(--qs-shadow-md); }
.qs-part-card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--qs-gray-100);
    background: var(--qs-gray-50);
    border-radius: var(--qs-radius-lg) var(--qs-radius-lg) 0 0;
}
.qs-part-card-number {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--qs-accent);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
}
.qs-part-card-fields { flex: 1; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.qs-part-card-fields .qs-form-group { margin: 0; }
.qs-part-card-body { padding: 16px 20px; }
.qs-part-card-remove {
    background: none;
    border: none;
    color: var(--qs-gray-400);
    cursor: pointer;
    padding: 6px;
    border-radius: var(--qs-radius);
    transition: all 0.2s;
    flex-shrink: 0;
}
.qs-part-card-remove:hover { color: var(--qs-danger); background: var(--qs-danger-light); }

/* ---- File Thumbnail Grid ---- */
.qs-thumb-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 8px;
}
.qs-thumb-item {
    width: 100px;
    cursor: pointer;
    position: relative;
    border-radius: var(--qs-radius);
    transition: transform 0.15s;
}
.qs-thumb-item:hover { transform: translateY(-2px); }
.qs-thumb-preview {
    width: 100px;
    height: 80px;
    border-radius: var(--qs-radius);
    border: 1px solid var(--qs-gray-200);
    background: var(--qs-gray-50);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}
.qs-thumb-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.qs-thumb-icon {
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    color: var(--qs-gray-400);
    letter-spacing: 0.5px;
}
.qs-thumb-badge {
    position: absolute;
    top: 4px;
    left: 4px;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: white;
}
.qs-thumb-badge-3d { background: #6366f1; }
.qs-thumb-badge-2d { background: #0ea5e9; }
.qs-thumb-badge-pdf { background: #ef4444; }
.qs-thumb-badge-img { background: #22c55e; }
.qs-thumb-name {
    font-size: 11px;
    color: var(--qs-gray-600);
    margin-top: 4px;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100px;
}
.qs-thumb-remove {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--qs-danger);
    color: white;
    border: 2px solid white;
    font-size: 12px;
    line-height: 1;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 0;
}
.qs-thumb-item:hover .qs-thumb-remove { display: flex; }
.qs-thumb-spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--qs-gray-200);
    border-top-color: var(--qs-accent);
    border-radius: 50%;
    animation: qs-spin 0.6s linear infinite;
}

/* ---- Add File Dropzone (inside part card) ---- */
.qs-part-dropzone {
    width: 100px;
    height: 80px;
    border: 2px dashed var(--qs-gray-300);
    border-radius: var(--qs-radius);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--qs-gray-400);
    gap: 2px;
}
.qs-part-dropzone:hover {
    border-color: var(--qs-accent);
    color: var(--qs-accent);
    background: rgba(37, 99, 235, 0.04);
}
.qs-part-dropzone svg { width: 20px; height: 20px; }
.qs-part-dropzone span { font-size: 10px; font-weight: 600; }

/* ---- Viewer Modal ---- */
.qs-viewer-modal {
    /* inset:0 (not 100vw/100vh) — vw includes the scrollbar gutter on
       desktop and misbehaves on mobile when the page is zoomed. */
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(4px);
    display: none;
}
.qs-viewer-modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}
.qs-viewer-modal-container {
    position: relative;
    width: 96vw;
    height: 94vh;
    max-width: 1600px;
    border-radius: 14px;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.5);
    background: white;
}
.qs-viewer-modal-container iframe {
    width: 100%;
    height: 100%;
    min-height: 100%;
    border: none;
    display: block;
    background: white;
}
.qs-viewer-modal-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    border: none;
    font-size: 22px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10001;
    transition: background 0.2s;
    line-height: 1;
}
.qs-viewer-modal-close:hover { background: rgba(0, 0, 0, 0.85); }

/* ---- Document preview (spreadsheets / Word), see js/doc-preview.js ----
   A separate container from .qs-viewer-modal-container: that one scrolls as a
   whole because it holds an iframe, while a part list needs its header and
   footer pinned and only the table scrolling. */
.qs-doc-modal-container {
    position: relative;
    display: flex;
    flex-direction: column;
    width: 96vw;
    height: 94vh;
    max-width: 1400px;
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.5);
    background: white;
}
.qs-doc-head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 56px 14px 20px;
    border-bottom: 1px solid var(--qs-gray-200);
    background: var(--qs-gray-50);
    flex-shrink: 0;
}
.qs-doc-title {
    font-weight: 600;
    font-size: 15px;
    color: var(--qs-gray-900);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.qs-doc-meta {
    font-size: 12px;
    color: var(--qs-gray-500);
    white-space: nowrap;
    margin-left: auto;
}
.qs-doc-body {
    flex: 1;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    padding: 20px;
    background: white;
}
.qs-doc-foot {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    border-top: 1px solid var(--qs-gray-200);
    background: var(--qs-gray-50);
    flex-shrink: 0;
}
.qs-doc-note {
    font-size: 12px;
    color: var(--qs-gray-600);
    margin-right: auto;
}
.qs-doc-msg {
    padding: 40px 20px;
    text-align: center;
    color: var(--qs-gray-500);
    font-size: 14px;
}

/* Sheet tabs, shown only for a multi-sheet workbook. */
.qs-doc-tabs {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}
.qs-doc-tab {
    padding: 6px 14px;
    border: 1px solid var(--qs-gray-300);
    border-radius: 999px;
    background: white;
    color: var(--qs-gray-700);
    font-size: 13px;
    cursor: pointer;
    font-family: inherit;
}
.qs-doc-tab:hover { background: var(--qs-gray-100); }
.qs-doc-tab.active {
    background: var(--qs-accent);
    border-color: var(--qs-accent);
    color: white;
}

.qs-doc-sheet { overflow: auto; max-width: 100%; }
.qs-doc-table {
    border-collapse: collapse;
    font-size: 13px;
    /* Not width:100% — a wide part list should scroll rather than squeeze its
       description column into one character per line. */
    min-width: 100%;
}
.qs-doc-table th,
.qs-doc-table td {
    border: 1px solid var(--qs-gray-200);
    padding: 6px 10px;
    text-align: left;
    vertical-align: top;
    max-width: 420px;
    /* Cells hold part descriptions with no spaces ("ANSCHLUSSTEIL 1 - RTJ" is
       kind, "Dm54/24x62" is not), so long ones must be allowed to break. */
    overflow-wrap: break-word;
}
.qs-doc-table thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--qs-gray-100);
    font-weight: 600;
    color: var(--qs-gray-800);
    box-shadow: inset 0 -1px 0 var(--qs-gray-300);
}
.qs-doc-table tbody tr:nth-child(even) { background: var(--qs-gray-50); }
.qs-doc-table td.qs-doc-num { text-align: right; font-variant-numeric: tabular-nums; }
.qs-doc-rownum {
    background: var(--qs-gray-100);
    color: var(--qs-gray-400);
    font-size: 11px;
    text-align: right;
    user-select: none;
    position: sticky;
    left: 0;
}

/* Word / ODT blocks. */
.qs-doc-blocks { max-width: 820px; }
.qs-doc-blocks h3, .qs-doc-blocks h4, .qs-doc-blocks h5 {
    margin: 22px 0 8px;
    color: var(--qs-gray-900);
    line-height: 1.3;
}
.qs-doc-blocks h3 { font-size: 20px; }
.qs-doc-blocks h4 { font-size: 17px; }
.qs-doc-blocks h5 { font-size: 15px; }
.qs-doc-blocks h3:first-child, .qs-doc-blocks h4:first-child { margin-top: 0; }
.qs-doc-blocks p {
    margin: 0 0 10px;
    font-size: 14px;
    color: var(--qs-gray-700);
    line-height: 1.65;
}
.qs-doc-blocks .qs-doc-sheet { margin: 14px 0 20px; }
.qs-doc-pre {
    margin: 0;
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    font-size: 13px;
    line-height: 1.55;
    color: var(--qs-gray-800);
    white-space: pre-wrap;
    overflow-wrap: break-word;
}

@media (max-width: 640px) {
    .qs-doc-modal-container { width: 100vw; height: 100vh; border-radius: 0; }
    .qs-doc-body { padding: 12px; }
    .qs-doc-meta { display: none; }
}

/* ---- Add Part Button ---- */
.qs-add-part-btn {
    width: 100%;
    padding: 16px;
    border: 2px dashed var(--qs-gray-300);
    border-radius: var(--qs-radius-lg);
    background: transparent;
    color: var(--qs-gray-500);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-family: inherit;
}
.qs-add-part-btn:hover {
    border-color: var(--qs-accent);
    color: var(--qs-accent);
    background: rgba(37, 99, 235, 0.04);
}
.qs-add-part-btn svg { width: 20px; height: 20px; }

/* ---- Notification dot ---- */
.qs-notif-dot {
    width: 8px;
    height: 8px;
    background: var(--qs-danger);
    border-radius: 50%;
    display: inline-block;
    margin-left: 4px;
}

/* ---- Impersonation / Manual badges on quote rows ---- */
.qs-pill-impersonated {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fca5a5;
}
/* Quote raised for our own company (admin/quotes.html "+ Internal quote"). */
.qs-pill-internal {
    background: #ede9fe;
    color: #5b21b6;
    border: 1px solid #c4b5fd;
    font-weight: 700;
}
.qs-pill-manual {
    background: #f0f9ff;
    color: #0c4a6e;
    border: 1px solid #7dd3fc;
}

/* ---- Email delivery failure tooltip ----
   Driven by js/email-fail-tooltip.js. The panel is a single element parked on
   <body> and positioned with `fixed`, because the quotes table lives inside
   .qs-table-wrap (overflow-x: auto) which would clip an absolutely positioned
   child. */
[data-emailfail] { cursor: help; }
.sc-mail-warn {
    display: inline-flex;
    flex-direction: column;
    justify-content: center;
    line-height: 1.15;
    padding: 3px 8px;
    border-radius: 8px;
    cursor: help;
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fca5a5;
    font-size: 11px;
    font-weight: 700;
    white-space: nowrap;
}
.sc-mail-warn span { font-size: 10px; font-weight: 600; }
.qs-failtip {
    position: fixed;
    z-index: 100000;
    display: none;
    max-width: 420px;
    min-width: 260px;
    padding: 12px 14px;
    background: #fff;
    border: 1px solid var(--qs-gray-200, #e5e7eb);
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .18);
    font-size: 12px;
    line-height: 1.5;
    color: #1e293b;
    text-align: left;
    white-space: normal;
}
.qs-failtip.open { display: block; }
.qs-failtip-title {
    font-size: 11px;
    font-weight: 700;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: .5px;
    margin-bottom: 8px;
}
.qs-failtip-item {
    padding: 8px 0;
    border-bottom: 1px solid #f3f4f6;
}
.qs-failtip-item:last-child { border-bottom: none; }
.qs-failtip-who {
    display: flex;
    align-items: baseline;
    gap: 6px;
    flex-wrap: wrap;
}
.qs-failtip-role {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .4px;
    color: #6b7280;
    background: #f3f4f6;
    border-radius: 4px;
    padding: 1px 5px;
}
.qs-failtip-name { font-weight: 700; color: #1e293b; }
.qs-failtip-email { color: #6b7280; word-break: break-all; }
.qs-failtip-event {
    display: inline-block;
    margin-top: 3px;
    font-weight: 700;
    color: #dc2626;
}
.qs-failtip-when { color: #9ca3af; font-size: 11px; }
.qs-failtip-reason {
    margin-top: 2px;
    color: #475569;
    word-break: break-word;
}
.qs-failtip-note { color: #6b7280; font-style: italic; }

/* ---- Iskrex Signature Footer ---- */
.iskrex-signature {
    text-align: center;
    padding: 32px 20px 24px;
}
.iskrex-signature-company {
    font-size: 13px;
    color: var(--qs-gray-400);
    letter-spacing: 0.02em;
    margin-bottom: 10px;
}
.qs-auth-page .iskrex-signature-company {
    color: rgba(255,255,255,0.45);
}
.iskrex-signature-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(0,0,0,0.04);
    border: 1px solid rgba(0,0,0,0.06);
    border-radius: 20px;
    padding: 6px 16px;
    font-size: 11px;
    font-weight: 500;
    color: var(--qs-gray-400);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    text-decoration: none;
    transition: all 0.2s ease;
}
.qs-auth-page .iskrex-signature-badge {
    background: rgba(255,255,255,0.08);
    border-color: rgba(255,255,255,0.1);
    color: rgba(255,255,255,0.5);
}
.iskrex-signature-badge:hover {
    background: rgba(0,0,0,0.07);
    border-color: rgba(0,0,0,0.1);
    color: var(--qs-gray-600);
}
.qs-auth-page .iskrex-signature-badge:hover {
    background: rgba(255,255,255,0.14);
    border-color: rgba(255,255,255,0.18);
    color: rgba(255,255,255,0.75);
}
.iskrex-signature-badge .iskrex-name {
    font-weight: 700;
    color: var(--qs-gray-600);
    font-size: 12px;
}
.qs-auth-page .iskrex-signature-badge .iskrex-name {
    color: rgba(255,255,255,0.75);
}
.iskrex-signature-badge:hover .iskrex-name {
    color: var(--qs-gray-800);
}
.qs-auth-page .iskrex-signature-badge:hover .iskrex-name {
    color: white;
}
.iskrex-signature-badge .iskrex-bolt {
    font-size: 12px;
    color: #facc15;
}

/* ---- Language Selector ---- */
.qs-lang-selector { position: relative; display: inline-block; }
.qs-lang-trigger {
    display: flex; align-items: center; gap: 6px;
    padding: 7px 14px; border-radius: 8px;
    border: 1px solid var(--qs-gray-200); background: white;
    font-size: 13px; font-weight: 600; color: var(--qs-gray-700);
    cursor: pointer; font-family: inherit; transition: all 0.15s;
}
.qs-auth-page .qs-lang-trigger {
    background: rgba(255,255,255,0.08); border-color: rgba(255,255,255,0.15);
    color: rgba(255,255,255,0.85);
}
.qs-lang-trigger:hover { border-color: var(--qs-accent); }
.qs-auth-page .qs-lang-trigger:hover { border-color: rgba(255,255,255,0.35); }
.qs-lang-flag { font-size: 16px; line-height: 1; }
.qs-lang-label { white-space: nowrap; }
.qs-lang-arrow { transition: transform 0.2s; flex-shrink: 0; }
.qs-lang-dropdown {
    position: absolute; top: calc(100% + 4px); right: 0; z-index: 100;
    background: white; border: 1px solid var(--qs-gray-200);
    border-radius: 10px; box-shadow: 0 8px 30px rgba(0,0,0,0.12);
    min-width: 160px; padding: 4px;
    opacity: 0; visibility: hidden; transform: translateY(-6px);
    transition: all 0.15s ease;
}
.qs-auth-page .qs-lang-dropdown {
    background: #1e293b; border-color: rgba(255,255,255,0.1);
}
.qs-lang-dropdown.open { opacity: 1; visibility: visible; transform: translateY(0); }
.qs-lang-option {
    display: flex; align-items: center; gap: 8px; width: 100%;
    padding: 9px 12px; border: none; background: none;
    font-size: 13px; font-weight: 500; color: var(--qs-gray-700);
    cursor: pointer; border-radius: 7px; font-family: inherit; transition: all 0.1s;
    text-align: left;
}
.qs-auth-page .qs-lang-option { color: rgba(255,255,255,0.75); }
.qs-lang-option:hover { background: var(--qs-gray-50); }
.qs-auth-page .qs-lang-option:hover { background: rgba(255,255,255,0.08); }
.qs-lang-option.active {
    background: rgba(37,99,235,0.08); color: var(--qs-accent); font-weight: 700;
}
.qs-auth-page .qs-lang-option.active {
    background: rgba(59,130,246,0.15); color: #93c5fd;
}

/* ---- Mobile: full-screen 3D / drawing viewer modal ---- */
@media (max-width: 768px) {
    /* The modal itself is pinned to the visual viewport by JS while open
       (quote-detail.html), so the container just fills it completely. */
    .qs-viewer-modal-container {
        width: 100%;
        height: 100%;
        max-width: none;
        border-radius: 0;
    }
    .qs-viewer-modal-close {
        top: calc(env(safe-area-inset-top, 0px) + 6px);
        right: 6px;
        width: 42px;
        height: 42px;
        font-size: 26px;
        background: rgba(0, 0, 0, 0.72);
        border: 1.5px solid rgba(255, 255, 255, 0.4);
        box-shadow: 0 2px 12px rgba(0, 0, 0, 0.45);
    }

    /* Detail layout breathes a bit tighter on phones */
    .qs-detail-grid { gap: 14px; }
}

/* ---- Quote description / forwarded email body ----
   An inquiry imported from email carries the customer's whole message —
   signature, legal disclaimer, banner links — so the text is shown in a
   fixed-height window that scrolls on its own instead of pushing the parts
   table and the totals off the first screen. Markup: js/quote-desc-box.js */
.qd-desc {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--qs-gray-200);
}
.qd-desc-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 6px;
}
.qd-desc-toggle {
    flex-shrink: 0;
    padding: 4px 11px;
    border: 1px solid var(--qs-gray-200);
    border-radius: 6px;
    background: white;
    color: var(--qs-gray-600);
    font-family: inherit;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.qd-desc-toggle:hover { border-color: var(--qs-accent); color: var(--qs-accent); }
.qd-desc-wrap { position: relative; }
.qd-desc-scroll {
    /* Drag the bottom-right grip to resize; the height chosen is remembered
       per browser by js/quote-desc-box.js */
    height: 320px;
    min-height: 120px;
    resize: vertical;
    overflow-y: auto;
    /* Keep a flick inside the box from scrolling the page underneath it */
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding: 12px 14px;
    border: 1px solid var(--qs-gray-200);
    border-radius: 10px;
    background: var(--qs-gray-50);
    color: var(--qs-gray-600);
    font-size: 14px;
    line-height: 1.7;
    white-space: pre-line;
    overflow-wrap: anywhere; /* tracking URLs in signatures are one long word */
}
.qd-desc-scroll:focus-visible { outline: 2px solid var(--qs-accent); outline-offset: 2px; }
.qd-desc-scroll::-webkit-scrollbar { width: 10px; }
.qd-desc-scroll::-webkit-scrollbar-track { background: transparent; }
.qd-desc-scroll::-webkit-scrollbar-thumb {
    background: var(--qs-gray-300);
    background-clip: content-box;
    border: 3px solid transparent;
    border-radius: 10px;
}
.qd-desc-scroll::-webkit-scrollbar-thumb:hover { background: var(--qs-gray-400); background-clip: content-box; }
/* Beats the inline height restored from storage */
.qd-desc.expanded .qd-desc-scroll { height: auto !important; resize: none; }
/* Fade at the bottom edge — without it a full window reads as a complete text */
.qd-desc-wrap::after {
    content: '';
    position: absolute;
    left: 1px;
    right: 13px; /* clear of the scrollbar and the resize grip */
    bottom: 1px;
    height: 34px;
    border-radius: 0 0 10px 10px;
    background: linear-gradient(rgba(249, 250, 251, 0), var(--qs-gray-50));
    opacity: 0;
    transition: opacity 0.15s;
    pointer-events: none;
}
.qd-desc.has-more .qd-desc-wrap::after { opacity: 1; }
.qd-desc-head strong { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.qd-desc-actions { display: inline-flex; align-items: center; gap: 6px; flex-shrink: 0; }
.qd-desc-badge {
    padding: 2px 8px;
    border-radius: 999px;
    background: #ecfdf5;
    border: 1px solid #a7f3d0;
    color: #047857;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .02em;
}
.qd-desc.is-full .qd-desc-badge { display: none; }
.qd-desc-source {
    flex-shrink: 0;
    padding: 4px 11px;
    border: 1px solid var(--qs-gray-200);
    border-radius: 6px;
    background: white;
    color: var(--qs-accent);
    font-family: inherit;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
}
.qd-desc-source:hover { border-color: var(--qs-accent); background: #eff6ff; }
/* The cleaned message is usually a few lines: fit it instead of a tall empty window */
.qd-desc.is-clean .qd-desc-scroll { height: auto !important; max-height: 320px; min-height: 0; resize: none; }
/* Cooperant requirements: a short window. Drag the corner to make it taller. */
.qd-desc.is-compact .qd-desc-scroll { height: 140px; }
.qd-desc-scroll.is-empty { color: var(--qs-gray-400); font-style: italic; }
.qd-desc-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 14px;
    margin-top: 8px;
    font-size: 11px;
    color: var(--qs-gray-400);
}
.qd-desc-meta span { overflow-wrap: anywhere; }

@media (max-width: 768px) {
    .qd-desc-head { margin-bottom: 8px; }
    .qd-desc-toggle { padding: 7px 13px; font-size: 12px; }
    .qd-desc-scroll {
        /* Relative to the viewport so the window never eats a whole phone
           screen, and never shrinks to a two-line slit on a small one.
           No drag grip on touch — there is nothing comfortable to grab. */
        height: 40vh;
        min-height: 140px;
        resize: none;
        font-size: 14px;
        padding: 12px;
    }
    .qd-desc.is-compact .qd-desc-scroll { height: 140px; min-height: 0; }
}

/* ---- Print ---- */
@media print {
    .qs-topnav, .qs-btn, .qs-chat-container, .qs-chat-input-area, .iskrex-signature, .qs-back-float { display: none !important; }
    .qs-main { max-width: 100%; padding: 0; }
    .qs-card { box-shadow: none; border: 1px solid #ddd; }
    /* Paper has no scrollbar: the whole enquiry has to be on the page */
    .qd-desc-toggle, .qd-desc-source { display: none; }
    .qd-desc-scroll { height: auto !important; max-height: none !important; overflow: visible; resize: none; background: white; }
    .qd-desc-wrap::after { display: none; }
}
