/* =====================================================================
   Suplynx V1 - Core Design System & Stylesheet
   Curated palette, modern typography, grid layouts, and print overrides.
   ===================================================================== */

/* 1. CSS VARIABLES & COLOR PALETTES */
:root {
    /* Color Tokens (HSL harmonized) */
    --font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
    
    /* Light Mode Palette */
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f1f5f9;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    
    --primary: #40B9EA;
    --primary-hover: #2DAEE3;
    --primary-active: #229FD2;
    --primary-light: #EAF9FE;
    --primary-border: #BEEBFA;
    
    --accent: #40B9EA;
    --accent-hover: #2DAEE3;
    
    --success: #10b981;
    --success-light: #ecfdf5;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --danger: #ef4444;
    --danger-light: #fef2f2;
    --border-color: #e2e8f0;
    
    /* Shadows & Border Radii */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-full: 9999px;
    
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;
    
    --sidebar-width: 260px;
    --navbar-height: 70px;
}

/* System-level Dark Mode Theme (Toggled via data-theme="dark") */
[data-theme="dark"] {
    --bg-primary: #090d16;
    --bg-secondary: #111827;
    --bg-tertiary: #1f2937;
    --text-primary: #f9fafb;
    --text-secondary: #d1d5db;
    --text-muted: #6b7280;
    
    --primary: #40B9EA;
    --primary-hover: #2DAEE3;
    --primary-light: #0e3a4a;
    
    --border-color: #374151;
    
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.3), 0 2px 4px -2px rgb(0 0 0 / 0.3);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.3), 0 4px 6px -4px rgb(0 0 0 / 0.3);
}

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

body {
    font-family: var(--font-family);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
    transition: background-color var(--transition-normal), color var(--transition-normal);
}

html {
    scroll-behavior: smooth;
}

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

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

/* 3. LAYOUT STRUCTURE */
#app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.main-layout {
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr;
    min-height: 100vh;
    align-items: flex-start;
}

.content-area {
    padding: 32px 40px 40px;
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
    overflow-y: auto;
}

/* 4. COMPONENT STYLES */

/* Sidebar Navigation */
.sidebar {
    background-color: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 24px;
    height: 100vh;
    position: sticky;
    top: 0;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 40px;
    font-size: 1.5rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.brand-logo-navbar {
    height: 32px;
    width: auto;
    max-width: 160px;
    object-fit: contain;
    flex-shrink: 0;
}

.public-preview-logo {
    height: 28px;
    width: auto;
    max-width: 140px;
    object-fit: contain;
    vertical-align: middle;
}

.nav-links {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-grow: 1;
}

.nav-item a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-weight: 500;
    transition: all var(--transition-fast);
}

.nav-item.active a, .nav-item a:hover {
    background-color: var(--primary-light);
    color: var(--primary);
}

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

.user-badge {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    font-family: var(--font-family);
    font-size: 0.95rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn[aria-busy="true"] {
    opacity: 0.78;
    cursor: wait;
    pointer-events: none;
}

.page-breadcrumb {
    font-size: 0.85rem;
    color: var(--text-secondary);
    letter-spacing: 0.01em;
    margin-bottom: 8px;
    line-height: 1.3;
}

.page-breadcrumb a {
    color: var(--text-secondary);
    text-decoration: none;
}

.page-breadcrumb a:hover {
    text-decoration: underline;
}

.btn-primary,
.btn-primary:hover,
.btn-primary:focus,
.btn-primary:active,
.btn-primary:visited {
    background-color: var(--primary);
    color: #ffffff !important;
}

.btn-primary:hover,
.btn-primary:focus,
.btn-primary:active {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.btn-back-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: all var(--transition-fast);
    padding: 0;
}

.btn-back-icon:hover {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    border-color: var(--text-secondary);
}

.btn-back-icon i {
    width: 18px;
    height: 18px;
}

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

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

.btn-danger {
    background-color: var(--danger);
    color: white;
}

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

.btn-sm {
    padding: 6px 12px;
    font-size: 0.85rem;
}

.btn-icon {
    padding: 8px;
    border-radius: var(--radius-sm);
}

/* Cards & Containers */
.card {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 24px;
    box-shadow: var(--shadow-sm);
}

/* Form Styles */
.form-group {
    margin-bottom: 20px;
}

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

label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
select,
textarea {
    width: 100%;
    padding: 10px 14px;
    font-family: var(--font-family);
    font-size: 0.95rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    outline: none;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

input:focus, select:focus, textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(64, 185, 234, 0.18);
}

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

/* Status Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.badge-draft { background-color: var(--bg-tertiary); color: var(--text-secondary); }
.badge-sent { background-color: var(--primary-light); color: var(--primary); }
.badge-accepted { background-color: #fef3c7; color: #d97706; }
.badge-invoiced { background-color: #f5f3ff; color: #7c3aed; }
.badge-paid { background-color: var(--success-light); color: var(--success); }

/* Table design */
.table-container {
    width: 100%;
    overflow-x: auto;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background-color: var(--bg-secondary);
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.95rem;
}

th {
    background-color: var(--bg-tertiary);
    color: var(--text-secondary);
    font-weight: 600;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-color);
}

td {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}

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

tr:hover td {
    background-color: var(--bg-primary);
}

/* Dashboard Analytics */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

.stat-card {
    display: flex;
    align-items: center;
    gap: 20px;
}

.stat-icon {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-md);
    background-color: var(--primary-light);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
}

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

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

.stat-value {
    font-size: 1.75rem;
    font-weight: 800;
    line-height: 1.2;
}

.stat-value-skeleton {
    width: 150px;
    height: 1.55rem;
    border-radius: 8px;
    background: linear-gradient(90deg, #eef3fb 0%, #f7faff 50%, #eef3fb 100%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.2s linear infinite;
}

.dashboard-skeleton-row td {
    padding-top: 16px;
    padding-bottom: 16px;
}

.dashboard-skeleton-line {
    display: inline-block;
    height: 12px;
    border-radius: 999px;
    background: linear-gradient(90deg, #eef3fb 0%, #f7faff 50%, #eef3fb 100%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.2s linear infinite;
}

.dashboard-skeleton-line.w-40 { width: 40%; }
.dashboard-skeleton-line.w-42 { width: 42%; }
.dashboard-skeleton-line.w-44 { width: 44%; }
.dashboard-skeleton-line.w-45 { width: 45%; }
.dashboard-skeleton-line.w-50 { width: 50%; }
.dashboard-skeleton-line.w-52 { width: 52%; }
.dashboard-skeleton-line.w-53 { width: 53%; }
.dashboard-skeleton-line.w-55 { width: 55%; }
.dashboard-skeleton-line.w-58 { width: 58%; }
.dashboard-skeleton-line.w-60 { width: 60%; }
.dashboard-skeleton-line.w-65 { width: 65%; }
.dashboard-skeleton-line.w-68 { width: 68%; }
.dashboard-skeleton-line.w-70 { width: 70%; }
.dashboard-skeleton-line.w-75 { width: 75%; }
.dashboard-skeleton-line.w-78 { width: 78%; }
.dashboard-skeleton-line.w-80 { width: 80%; }

@keyframes skeleton-shimmer {
    from {
        background-position: 200% 0;
    }
    to {
        background-position: -200% 0;
    }
}

.workspace-loading-indicator {
    position: fixed;
    top: 16px;
    left: 50%;
    transform: translateX(-50%) translateY(-6px);
    opacity: 0;
    pointer-events: none;
    z-index: 1200;
    padding: 8px 14px;
    border-radius: 999px;
    border: 1px solid rgba(186, 202, 230, 0.65);
    background: rgba(255, 255, 255, 0.78);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    box-shadow: 0 8px 18px rgba(24, 50, 83, 0.08);
    transition: opacity 160ms ease, transform 160ms ease;
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.workspace-loading-indicator.is-visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.workspace-loading-text {
    display: inline-block;
    font-size: 0.86rem;
    font-weight: 600;
    color: #355273;
    letter-spacing: 0.01em;
    animation: workspace-text-fade 1.8s ease-in-out infinite;
}

.workspace-loading-logo {
    height: 48px;
    width: auto;
    max-width: 160px;
    object-fit: contain;
}

@keyframes workspace-text-fade {
    0%,
    100% {
        opacity: 0.65;
    }
    50% {
        opacity: 1;
    }
}

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

.dashboard-quick-actions .quick-action-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

.dashboard-quick-actions .quick-action-card:hover {
    background: var(--bg-secondary);
    border-color: var(--border-color);
    box-shadow: var(--shadow-md);
}

#setup-assistant-root {
    position: fixed;
    right: 24px;
    bottom: 24px;
    width: min(360px, calc(100vw - 32px));
    z-index: 1600;
    pointer-events: none;
}

#setup-assistant-root[data-visible="0"] {
    display: none;
}

.setup-assistant-card {
    pointer-events: auto;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: 18px;
}

.setup-assistant-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.setup-assistant-title {
    font-size: 1rem;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.setup-assistant-description {
    font-size: 0.92rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.setup-assistant-close {
    appearance: none;
    border: 1px solid var(--border-color);
    background: var(--bg-primary);
    color: var(--text-secondary);
    width: 30px;
    height: 30px;
    border-radius: 9999px;
    cursor: pointer;
    line-height: 1;
    font-size: 1rem;
    flex: 0 0 auto;
}

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

.setup-assistant-steps {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
}

.setup-assistant-step {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.88rem;
    color: var(--text-secondary);
}

.setup-assistant-step-box {
    width: 24px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: 1px solid var(--border-color);
    font-size: 0.8rem;
    font-weight: 600;
    flex: 0 0 auto;
    background: transparent;
    color: var(--text-secondary);
}

.setup-assistant-step.is-complete .setup-assistant-step-box {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
}

.setup-assistant-step.is-next .setup-assistant-step-box {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
}

.setup-assistant-footer {
    display: flex;
    justify-content: flex-end;
}

.onboarding-steps {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 10px;
}

.onboarding-steps > div {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-primary);
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.onboarding-steps > div span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 9999px;
    background: var(--primary-light);
    color: var(--primary);
    font-size: 0.75rem;
    font-weight: 700;
    flex: 0 0 auto;
}

.onboarding-steps > div strong {
    color: var(--text-primary);
    font-weight: 600;
}

/* Toast Notification styling */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 1000;
}

.toast {
    display: flex;
    align-items: center;
    gap: 12px;
    background-color: var(--bg-secondary);
    border-left: 4px solid var(--primary);
    color: var(--text-primary);
    padding: 16px 20px;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    font-weight: 600;
    font-size: 0.9rem;
    animation: slideIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    min-width: 280px;
}

.toast.success { border-left-color: var(--success); }
.toast.danger { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }

/* Suplynx Modal Dialogs */
.suplynx-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(2px);
}

.suplynx-modal-card {
    width: 100%;
    max-width: 460px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: 24px;
}

.suplynx-modal-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 10px;
}

.suplynx-modal-message {
    font-size: 0.95rem;
    color: var(--text-secondary);
    line-height: 1.55;
    margin-bottom: 18px;
    white-space: pre-wrap;
}

.suplynx-modal-input {
    width: 100%;
    margin-bottom: 18px;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-primary);
    color: var(--text-primary);
    font: inherit;
}

.suplynx-modal-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(64, 185, 234, 0.18);
}

.suplynx-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

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

.suplynx-modal-actions .btn-secondary:hover {
    background: var(--bg-tertiary);
}

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}


/* 5. SPECIFIC VIEWS STYLES */

/* Landing Page */
.landing-page {
    --landing-section-space: 120px;
    --landing-section-space-tablet: 92px;
    --landing-section-space-mobile: 64px;
    min-height: 100vh;
    background:
        radial-gradient(1000px 450px at 15% 0%, rgba(64, 185, 234, 0.14), transparent 70%),
        radial-gradient(900px 420px at 88% 6%, rgba(64, 185, 234, 0.10), transparent 72%),
        linear-gradient(180deg, #f8fbff 0%, #f2f6fd 52%, #f8fafc 100%);
}

.landing-header {
    width: 100%;
    position: sticky;
    top: 0;
    z-index: 500;
    background-color: transparent;
    border-bottom: 1px solid transparent;
    transition: background-color 300ms ease, border-color 300ms ease, backdrop-filter 300ms ease;
}

.landing-header-inner {
    width: min(1140px, calc(100% - 40px));
    margin: 0 auto;
    padding: 26px 0 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 18px;
    transition: padding 300ms ease;
}

.landing-header.scrolled {
    background: rgba(255, 255, 255, 0.72);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid rgba(148, 163, 184, 0.18);
}

.landing-header.scrolled .landing-header-inner {
    padding: 14px 0 10px;
}

.landing-logo-wrap {
    display: inline-flex;
    align-items: center;
    gap: 12px;
}

.landing-logo-mark {
    height: 32px;
    width: auto;
    border-radius: 0;
    background: transparent;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: none;
}

.landing-logo-mark img {
    height: 32px;
    width: auto;
    object-fit: contain;
}

.brand-beta-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 8px;
    height: 18px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.96);
    background: rgba(64, 185, 234, 0.16);
    border-radius: 9999px;
    letter-spacing: 0.04em;
    margin-left: 8px;
    white-space: nowrap;
}

.landing-logo-text {
    display: none;
}

.landing-header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.landing-shell {
    width: min(1140px, calc(100% - 40px));
    margin: 0 auto;
    padding: 0 0 96px;
    position: relative;
}

.landing-shell::before,
.landing-shell::after {
    content: '';
    position: absolute;
    border-radius: 999px;
    pointer-events: none;
    z-index: 0;
}

.landing-shell::before {
    width: clamp(300px, 38vw, 520px);
    height: clamp(300px, 38vw, 520px);
    right: -120px;
    top: 32%;
    background: radial-gradient(circle, rgba(64, 185, 234, 0.12) 0%, rgba(64, 185, 234, 0) 72%);
}

.landing-shell::after {
    width: clamp(260px, 34vw, 460px);
    height: clamp(260px, 34vw, 460px);
    left: -140px;
    top: 63%;
    background: radial-gradient(circle, rgba(64, 185, 234, 0.11) 0%, rgba(64, 185, 234, 0) 72%);
}

.landing-hero {
    display: grid;
    grid-template-columns: 1.05fr 0.95fr;
    gap: 44px;
    align-items: center;
    min-height: calc(100vh - 112px);
    padding: var(--landing-section-space) 0;
    position: relative;
    z-index: 1;
}

.landing-kicker {
    display: inline-flex;
    margin-bottom: 22px;
    font-size: 0.66rem;
    text-transform: uppercase;
    letter-spacing: 0.16em;
    font-weight: 700;
    color: #229FD2;
    background: rgba(64, 185, 234, 0.1);
    border: 1px solid rgba(64, 185, 234, 0.25);
    border-radius: var(--radius-full);
    padding: 5px 10px;
}

.landing-hero-title {
    font-size: clamp(2.2rem, 5vw, 3.55rem);
    line-height: 1.08;
    letter-spacing: -0.03em;
    font-weight: 800;
    margin-bottom: 26px;
    max-width: 640px;
}

.landing-subtitle {
    font-size: clamp(1.06rem, 2vw, 1.24rem);
    line-height: 1.65;
    color: var(--text-secondary);
    margin-bottom: 14px;
    max-width: 620px;
}

.landing-subtitle-secondary {
    font-size: 1rem;
    line-height: 1.7;
    color: #5b6b82;
    margin-bottom: 18px;
    max-width: 640px;
}

.landing-cta-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    margin: 8px 0 28px;
}

.landing-primary-cta,
.landing-secondary-cta {
    min-height: 44px;
    min-width: 126px;
    border-radius: 11px;
    font-weight: 700;
    padding: 10px 20px;
}

.landing-secondary-cta {
    background: #ffffff;
    border-color: #d9e3f4;
}

.landing-trust-list {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 10px 16px;
    color: #51627a;
    font-size: 0.9rem;
}

.landing-trust-list li {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-weight: 500;
}

.landing-trust-list i {
    width: 15px;
    height: 15px;
    color: #22c55e;
}

.landing-hero-preview {
    position: relative;
}

.preview-window {
    background: #ffffff;
    border: 1px solid rgba(15,23,42,0.06);
    border-radius: 20px;
    box-shadow: 0 6px 18px rgba(15,23,42,0.04);
    overflow: hidden;
}

.preview-window {
    display: flex;
    flex-direction: column;
    border-radius: 20px;
    background: #ffffff;
    border: 1px solid rgba(15,23,42,0.06);
    box-shadow: 0 6px 18px rgba(15,23,42,0.04);
    overflow: hidden;
    transition: all 300ms ease;
}

.preview-window.floating-animation {
    animation: float-subtle 6s ease-in-out infinite;
}

@keyframes float-subtle {
    0%, 100% {
        transform: translateY(0px);
    }
    50% {
        transform: translateY(-12px);
    }
}

.preview-window:hover {
    box-shadow: 0 24px 48px rgba(33, 76, 150, 0.16);
    transform: translateY(-2px);
}

.badge-pulse {
    animation: badge-pulse-animation 2s ease-in-out infinite;
}

@keyframes badge-pulse-animation {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.85;
    }
}

.preview-topbar {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f6f8fb;
    padding: 10px 14px;
    border-bottom: 1px solid rgba(15,23,42,0.04);
}

.preview-topbar span {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #bfd4f6;
}

.preview-topbar span:nth-child(1) { background: #FF5F57; }
.preview-topbar span:nth-child(2) { background: #FEBC2E; }
.preview-topbar span:nth-child(3) { background: #28C840; }

.preview-content {
    padding: 18px;
}

.preview-kpi-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 14px;
}

.preview-kpi-card {
    border-radius: 14px;
    padding: 14px;
    border: 1px solid #dae6f8;
    background: linear-gradient(165deg, #f8fbff 0%, #eff5ff 100%);
}

.preview-kpi-card p {
    font-size: 0.78rem;
    color: #5f7392;
    margin-bottom: 4px;
}

.preview-kpi-card h3 {
    font-size: 1.16rem;
    letter-spacing: -0.01em;
    margin-bottom: 2px;
}

.preview-kpi-card small {
    color: #6f86a7;
    font-size: 0.75rem;
}

.preview-document-card {
    border: 1px solid #d5e2f6;
    border-radius: 14px;
    background: #ffffff;
    padding: 15px;
}

.preview-document-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 5px;
}

.preview-document-head strong {
    font-size: 0.9rem;
    color: #1f3555;
}

.preview-status {
    font-size: 0.72rem;
    font-weight: 700;
    background: #eafbf3;
    color: #0f8a53;
    border-radius: var(--radius-full);
    padding: 4px 9px;
}

.preview-document-client {
    font-size: 0.78rem;
    color: #6a7f9f;
    margin-bottom: 10px;
}

.preview-line {
    height: 1px;
    background: #d9e5f7;
    margin-bottom: 11px;
}

.preview-document-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.82rem;
    color: #425a7d;
    margin-bottom: 5px;
}

.preview-total {
    margin-top: 8px;
    padding-top: 9px;
    border-top: 1px dashed #c7d9f4;
    font-size: 0.88rem;
}

.preview-total strong {
    color: #0f2e57;
}

.landing-section {
    margin-top: 0;
    border-top: 1px solid #e1e9f5;
    padding: var(--landing-section-space) 0;
    position: relative;
    z-index: 1;
}

.landing-section-header {
    margin-bottom: 40px;
}

.landing-section-kicker {
    text-transform: uppercase;
    letter-spacing: 0.13em;
    font-size: 0.72rem;
    color: #5f7392;
    font-weight: 700;
    margin-bottom: 18px;
}

.landing-section-heading {
    font-size: clamp(1.55rem, 3.1vw, 2.25rem);
    letter-spacing: -0.02em;
    line-height: 1.2;
    max-width: 740px;
}

.landing-info-grid {
    display: grid;
    gap: 16px;
}

.landing-feature-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.landing-info-card {
    background: #ffffff;
    border: 1px solid #dde8f8;
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 10px 28px rgba(22, 40, 72, 0.05);
}

.landing-info-card i {
    width: 20px;
    height: 20px;
    color: #40B9EA;
    margin-bottom: 12px;
}

.landing-feature-logo-icon {
    height: 20px;
    width: auto;
    max-width: 100px;
    object-fit: contain;
    margin-bottom: 12px;
}

.landing-info-card h3 {
    font-size: 1.06rem;
    letter-spacing: -0.01em;
    margin-bottom: 7px;
}

.landing-info-card p {
    font-size: 0.94rem;
    color: #5f6f86;
    line-height: 1.62;
}

.landing-faq {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
}

.landing-faq-item {
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    background: #ffffff;
    overflow: hidden;
    transition: all 200ms ease;
}

.landing-faq-item:hover {
    border-color: #cbd5e1;
    box-shadow: 0 4px 12px rgba(33, 76, 150, 0.06);
}

.landing-faq-item.is-open {
    border-color: #40B9EA;
    box-shadow: 0 8px 20px rgba(64, 185, 234, 0.1);
}

.landing-faq-trigger {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 24px;
    background: transparent;
    border: none;
    cursor: pointer;
    font-family: var(--font-family);
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    text-align: left;
    transition: color 200ms ease;
}

.landing-faq-trigger:hover {
    color: var(--primary);
}

.landing-faq-question {
    flex: 1;
}

.landing-faq-icon {
    display: inline-block;
    width: 20px;
    height: 20px;
    margin-left: 16px;
    flex-shrink: 0;
    transition: transform 300ms cubic-bezier(0.16, 1, 0.3, 1);
    color: var(--text-secondary);
}

.landing-faq-trigger[aria-expanded="true"] .landing-faq-icon {
    transform: rotate(180deg);
    color: var(--primary);
}

.landing-faq-content {
    overflow: hidden;
    max-height: 0px;
    transition: max-height 300ms cubic-bezier(0.16, 1, 0.3, 1);
}

.landing-faq-content p {
    padding: 0 24px 24px 24px;
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.6;
    margin: 0;
}

.landing-footer {
    padding: 20px 24px;
    border-top: 1px solid rgba(226, 232, 240, 0.8);
    background: transparent;
}

.landing-footer-content {
    max-width: 1140px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.landing-footer-note {
    font-size: 0.95rem;
    color: var(--text-secondary);
    margin: 0;
    line-height: 1.6;
}

.landing-footer-feedback {
    background-color: #191919;
    border-color: #191919;
    color: #ffffff;
    padding: 8px 16px;
    font-size: 0.92rem;
    min-height: 38px;
}

.landing-footer-feedback:hover,
.landing-footer-feedback:focus {
    background-color: #232323;
    border-color: #191919;
    box-shadow: none;
}

@media (max-width: 680px) {
    .landing-footer-content {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .landing-footer-feedback {
        margin-top: 10px;
    }
}

/* Feedback Modal */
.feedback-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.feedback-modal-card {
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(22, 40, 72, 0.15);
    max-width: 500px;
    width: calc(100% - 32px);
    max-height: 80vh;
    overflow-y: auto;
    animation: slideUp 300ms ease;
}

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

.feedback-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 24px;
    border-bottom: 1px solid #e2e8f0;
}

.feedback-modal-title {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
}

.feedback-modal-close {
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: #94a3b8;
    transition: color 200ms ease;
    padding: 0;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.feedback-form {
    padding: 24px;
}

.feedback-form-group {
    margin-bottom: 20px;
}

.feedback-form-group:last-of-type {
    margin-bottom: 24px;
}

.feedback-form-label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
}

.feedback-form-input,
.feedback-form-textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-family: var(--font-family);
    font-size: 0.95rem;
    color: var(--text-primary);
    background: #ffffff;
    transition: border-color 200ms ease, box-shadow 200ms ease;
    box-sizing: border-box;
}

.feedback-form-input:focus,
.feedback-form-textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(64, 185, 234, 0.1);
}

.feedback-form-textarea {
    resize: vertical;
    min-height: 120px;
}

.feedback-form-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    justify-content: flex-end;
}

.feedback-form-actions button {
    flex: 0 1 auto;
}

.feedback-success-message {
    padding: 24px;
    text-align: center;
    color: var(--text-primary);
    font-size: 1.06rem;
}

.reveal-up {
    opacity: 0;
    transform: translateY(14px);
    transition:
        opacity 900ms cubic-bezier(0.16, 1, 0.3, 1),
        transform 900ms cubic-bezier(0.16, 1, 0.3, 1);
    transition-delay: var(--reveal-delay, 0ms);
    will-change: opacity, transform;
}

.reveal-up.is-visible {
    opacity: 1;
    transform: translateY(0);
}

@media (prefers-reduced-motion: reduce) {
    .reveal-up {
        opacity: 1;
        transform: none;
        transition: none;
    }
}

@media (max-width: 1024px) {
    .landing-page {
        --landing-section-space: var(--landing-section-space-tablet);
    }

    .landing-hero {
        gap: 32px;
        min-height: calc(100vh - 108px);
    }

    .landing-feature-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 900px) {
    .landing-page {
        --landing-section-space: var(--landing-section-space-mobile);
    }

    .landing-header-inner,
    .landing-shell {
        width: calc(100% - 32px);
    }

    .landing-shell {
        padding: 0 0 56px;
    }

    .landing-hero {
        grid-template-columns: 1fr;
        min-height: calc(100svh - 98px);
        padding: var(--landing-section-space) 0;
    }

    .landing-hero-title {
        max-width: none;
    }

    .landing-subtitle,
    .landing-subtitle-secondary {
        max-width: none;
    }

    .landing-trust-list {
        flex-direction: column;
        gap: 8px;
    }

    .preview-content {
        padding: 14px;
    }

    .landing-shell::before,
    .landing-shell::after {
        opacity: 0.6;
    }

    /* Decorative blobs can extend past the viewport and cause horizontal scrolling on small screens.
       Hide them to avoid overflow while keeping visual parity on larger viewports. */
    .landing-shell::before,
    .landing-shell::after {
        display: none;
    }

    .landing-faq {
        gap: 10px;
    }

    .landing-faq-trigger {
        padding: 16px 20px;
        font-size: 0.95rem;
    }

    .landing-faq-content p {
        padding: 0 20px 20px 20px;
        font-size: 0.9rem;
    }

    .landing-faq-icon {
        width: 18px;
        height: 18px;
        margin-left: 12px;
    }

    .landing-footer-links {
        flex-wrap: wrap;
        gap: 16px;
    }
}

/* Document Creation Page Specifics */
.doc-builder-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 32px;
    align-items: start;
}

.line-item-row {
    display: grid;
    grid-template-columns: 2.5fr 1fr 1.25fr 1fr auto;
    gap: 12px;
    align-items: center;
    margin-bottom: 12px;
}

.line-item-header {
    display: grid;
    grid-template-columns: 2.5fr 1fr 1.25fr 1fr auto;
    gap: 12px;
    margin-bottom: 8px;
    font-weight: 700;
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.additional-charge-row {
    display: grid;
    grid-template-columns: 2.5fr 1.25fr auto;
    gap: 12px;
    align-items: center;
    margin-bottom: 12px;
}

.additional-charge-header {
    display: grid;
    grid-template-columns: 2.5fr 1.25fr auto;
    gap: 12px;
    margin-bottom: 8px;
    font-weight: 700;
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.doc-totals {
    border-top: 1px solid var(--border-color);
    padding-top: 16px;
    margin-top: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: flex-end;
}

.total-row {
    display: flex;
    justify-content: space-between;
    width: 260px;
    font-size: 0.95rem;
}

.total-row.grand-total {
    font-size: 1.35rem;
    font-weight: 800;
    border-top: 2px double var(--border-color);
    padding-top: 8px;
    color: var(--primary);
}

/* Login Card Layout */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px 24px;
    background:
        radial-gradient(1000px 450px at 15% 0%, rgba(64, 185, 234, 0.14), transparent 70%),
        radial-gradient(900px 420px at 88% 6%, rgba(64, 185, 234, 0.10), transparent 72%),
        linear-gradient(180deg, #f8fbff 0%, #f2f6fd 52%, #f8fafc 100%);
}

.auth-stack {
    width: 100%;
    max-width: 460px;
}

.auth-back-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.auth-back-link:hover {
    color: var(--text-primary);
}

.login-card {
    max-width: 460px;
    width: 100%;
    border-radius: 16px;
    border: 1px solid #dde8f8;
    background: #ffffff;
    box-shadow: 0 10px 28px rgba(22, 40, 72, 0.05);
    padding: 28px;
}

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

.auth-brand {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.95rem;
    letter-spacing: 0.02em;
    font-weight: 700;
    color: #229FD2;
    margin-bottom: 12px;
}

.auth-brand-icon {
    height: 48px;
    width: auto;
    max-width: 200px;
    object-fit: contain;
    flex-shrink: 0;
}

.auth-title {
    font-size: clamp(1.7rem, 3vw, 2.15rem);
    font-weight: 800;
    letter-spacing: -0.02em;
    color: #0f172a;
    margin-bottom: 10px;
}

.auth-subtitle {
    font-size: 1rem;
    line-height: 1.6;
    color: #5b6b82;
    margin: 0;
}

.auth-full-btn {
    width: 100%;
    min-height: 42px;
    margin-bottom: 16px;
}

.auth-divider {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 16px;
    color: var(--text-muted);
    font-size: 0.8rem;
}

.auth-divider hr {
    flex-grow: 1;
    border: none;
    border-top: 1px solid var(--border-color);
}

.google-auth-btn {
    background-color: #ffffff;
    border: 1px solid var(--border-color);
    color: #111827;
    font-weight: 600;
    font-size: 0.95rem;
    justify-content: center;
    gap: 10px;
}

.google-auth-btn:hover {
    background-color: #f8fbff;
    border-color: #c7d7f2;
    color: #111827;
}

.google-auth-btn:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(64, 185, 234, 0.18);
}

.google-auth-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    flex: 0 0 20px;
}

.auth-switch-row {
    margin-top: 14px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.88rem;
}

.auth-switch-link {
    margin-left: 4px;
    font-weight: 600;
    color: var(--primary);
}

.auth-switch-link:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}

.auth-setup-link-wrap {
    margin-top: 20px;
    text-align: center;
}

.auth-setup-link {
    font-size: 0.82rem;
    color: var(--text-muted);
}

.auth-setup-link:hover {
    color: var(--text-secondary);
}

.login-card input[type="text"],
.login-card input[type="email"],
.login-card input[type="password"] {
    background-color: #ffffff;
    border-color: #d8e2f1;
}

.login-card input[type="text"]:focus,
.login-card input[type="email"]:focus,
.login-card input[type="password"]:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(64, 185, 234, 0.18);
}

.login-card input:-webkit-autofill,
.login-card input:-webkit-autofill:hover,
.login-card input:-webkit-autofill:focus {
    -webkit-box-shadow: 0 0 0 1000px #ffffff inset;
    box-shadow: 0 0 0 1000px #ffffff inset;
    -webkit-text-fill-color: #0f172a;
    transition: background-color 9999s ease-out 0s;
}

@media (max-width: 900px) {
    .login-container {
        padding: 20px 16px;
    }

    .login-card {
        padding: 22px;
    }

    .auth-title {
        font-size: 1.55rem;
    }
}

/* Document Paper Layout (Mimicking Standard A4 Page) */
.document-paper {
    background-color: #ffffff;
    color: #0f172a;
    width: 210mm;
    padding: 10mm 12mm;
    margin: 0 auto;
    box-shadow: none;
    box-sizing: border-box;
    font-size: 0.88rem;
    line-height: 1.45;
    /* Pin all inherited text in the paper to dark, preventing dark-mode variable bleed */
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --border-color: #e2e8f0;
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f1f5f9;
}

.paper-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    border-bottom: 1px solid #d6dbe3;
    padding-bottom: 8mm;
    margin-bottom: 7mm;
}

.company-branding {
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: flex-start;
    max-width: 90mm;
}

.paper-logo {
    max-height: 42px;
    max-width: 110px;
    object-fit: contain;
}

.paper-company-details {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.paper-company-name {
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.25;
    color: #0f172a;
    margin: 2px 0 1px;
}

.paper-title-section {
    text-align: right;
    min-width: 70mm;
}

.paper-doc-type {
    font-size: 1.85rem;
    font-weight: 800;
    text-transform: uppercase;
    color: #0f172a;
    line-height: 1;
    letter-spacing: 0.02em;
}

.paper-doc-meta {
    margin-top: 3.5mm;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 7px;
}

.paper-doc-number {
    font-size: 0.82rem;
    font-weight: 600;
    color: #475569;
    letter-spacing: 0.01em;
}

.paper-status-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 9999px;
    border: 1px solid #d6dbe3;
    padding: 3px 8px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #334155;
    background: #f8fafc;
}

.paper-status-badge.paid {
    border-color: #bbf7d0;
    color: #15803d;
    background: #f0fdf4;
}

.paper-doc-dates {
    margin-top: 5px;
    display: flex;
    flex-direction: column;
    gap: 3px;
    align-items: flex-end;
}

.paper-meta-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0;
    margin-bottom: 7mm;
}

.paper-party-info h4 {
    font-size: 0.72rem;
    text-transform: uppercase;
    color: #64748b;
    margin-bottom: 5px;
    letter-spacing: 0.05em;
}

.paper-party-details {
    font-weight: 500;
}

.paper-date-item {
    font-size: 0.82rem;
    color: #475569;
}

.paper-date-item strong {
    color: #64748b;
    font-weight: 700;
}

.paper-table-wrap {
    border: 1px solid #d7dee7;
    border-radius: 8px;
    overflow: hidden;
    background: #ffffff;
    margin-bottom: 7mm;
}

.paper-table {
    width: 100%;
    margin-bottom: 0;
    border-collapse: collapse;
}

.paper-table th {
    background-color: #f7f9fc;
    color: #334155;
    border-bottom: 1px solid #d9e1ea;
    padding: 11px 12px;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    font-weight: 700;
}

.paper-table td {
    padding: 10px 12px;
    border-bottom: 1px solid #e7edf4;
    color: #1e293b;
    vertical-align: top;
    min-height: 28px;
}

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

.paper-table tr:hover td {
    background-color: transparent;
}

.paper-table td:last-child,
.paper-table th:last-child {
    text-align: right;
}

.paper-table .col-center {
    text-align: center;
}

.paper-table .col-right {
    text-align: right;
}

.paper-footer-grid {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 10mm;
    margin-top: 5mm;
    border-top: 1px solid #d6dbe3;
    padding-top: 6mm;
}

.paper-payment-details {
    background-color: #f7f9fc;
    border: 1px solid #d6dbe3;
    border-radius: 8px;
    padding: 13px;
    font-size: 0.8rem;
}

.paper-payment-details h5 {
    font-weight: 700;
    color: #334155;
    margin-bottom: 6px;
    letter-spacing: 0.02em;
}

.paper-payment-details p {
    color: #475569;
    line-height: 1.45;
}

.paper-notes {
    margin-top: 11px;
    border-top: 1px solid #d6dbe3;
    padding-top: 9px;
}

.paper-totals {
    display: flex;
    flex-direction: column;
    gap: 5px;
    font-size: 0.9rem;
}

.paper-header,
.paper-meta-grid,
.paper-table,
.paper-footer-grid {
    break-inside: avoid;
    page-break-inside: avoid;
}

.paper-total-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    border-bottom: none;
    padding-bottom: 3px;
}

.paper-total-row span {
    color: #64748b;
    font-weight: 600;
}

.paper-total-row strong {
    color: #334155;
    font-weight: 700;
}

.paper-total-row.grand {
    border-bottom: none;
    border-top: 1px solid #cfd6de;
    padding-top: 8px;
    padding-bottom: 0;
}

.paper-total-row.grand span,
.paper-total-row.grand strong {
    color: #0f172a;
    font-weight: 800;
    font-size: 1.1rem;
}

/* 6. RESPONSIVE DESIGN */
@media (max-width: 968px) {
    /* Prevent page-level horizontal scrolling on mobile devices */
    html, body {
        overflow-x: hidden;
        max-width: 100vw;
        position: relative;
    }

    /* Ensure main wrappers don't exceed viewport width */
    #app, .main-layout, .content-area {
        max-width: 100vw;
        overflow-x: hidden;
    }
    .main-layout {
        grid-template-columns: 1fr;
    }
    
    .sidebar {
        display: none; /* In V1 we keep layout simple, but can support toggle */
    }
    
    .mobile-topbar {
        display: flex;
        align-items: center;
        gap: 12px;
        padding-bottom: 18px;
    }

    .mobile-topbar .btn {
        box-shadow: var(--shadow-sm);
    }
    
    .mobile-drawer-overlay {
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, 0.5);
        opacity: 0;
        visibility: hidden;
        display: block;
        transition: opacity 0.25s ease, visibility 0.25s ease;
        z-index: 1200;
    }

    .mobile-drawer-overlay.open {
        opacity: 1;
        visibility: visible;
    }

    .mobile-drawer {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        width: min(280px, 90vw);
        max-width: 280px;
        transform: translateX(-110%);
        transition: transform 0.25s ease;
        background-color: var(--bg-secondary);
        border-right: 1px solid var(--border-color);
        box-shadow: 12px 0 30px rgba(15, 23, 42, 0.18);
        z-index: 1250;
        display: flex;
        flex-direction: column;
        padding: 22px 18px;
    }

    .mobile-drawer.open {
        transform: translateX(0);
    }

    .mobile-drawer-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 12px;
        margin-bottom: 20px;
        color: var(--text-primary);
        font-weight: 700;
    }

    .mobile-drawer-nav {
        display: flex;
        flex-direction: column;
        gap: 10px;
    }

    .mobile-drawer-link {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 14px 16px;
        border-radius: var(--radius-sm);
        color: var(--text-secondary);
        transition: background-color var(--transition-fast), color var(--transition-fast);
    }

    .mobile-drawer-link:hover,
    .mobile-drawer-link.active {
        background-color: var(--bg-tertiary);
        color: var(--text-primary);
    }

    .mobile-drawer-footer {
        display: flex;
        flex-direction: column;
        gap: 12px;
        margin-top: auto;
    }

    .doc-builder-grid {
        grid-template-columns: 1fr;
    }
    
    .content-area {
        padding: 20px;
    }

    /* Documents Ledger action buttons (mobile-only)
       - Target action links that create new documents via the documents new route
       - Allow the action container to wrap and make each action full-width
       - Scoped narrowly to avoid affecting other pages (uses href prefix)
    */
    .content-area > div > div[style*="gap: 8px;"] {
        /* this targets the action button container in Documents Ledger */
        flex-wrap: wrap;
        gap: 8px;
        align-items: stretch;
    }

    /* Desktop actions hidden on mobile; show compact mobile control */
    .doc-actions .desktop-actions {
        display: none !important;
    }

    .doc-actions .mobile-actions {
        display: block !important;
    }

    .mobile-new-menu {
        display: none;
        position: absolute;
        right: 0;
        top: calc(100% + 8px);
        background: var(--bg-secondary);
        border: 1px solid var(--border-color);
        box-shadow: var(--shadow-lg);
        border-radius: var(--radius-sm);
        min-width: 180px;
        z-index: 1400;
        overflow: hidden;
    }

    .mobile-new-menu.open {
        display: block;
    }

    .mobile-new-menu .mobile-new-item {
        display: block;
        padding: 10px 12px;
        color: var(--text-primary);
        text-decoration: none;
        font-weight: 600;
        border-bottom: 1px solid var(--border-color);
        background: transparent;
    }

    .mobile-new-menu .mobile-new-item:last-child {
        border-bottom: none;
    }

    .mobile-new-menu .mobile-new-item:hover {
        background: var(--bg-tertiary);
    }

    /* Ensure the mobile toggle looks compact but fits inside viewport */
    #mobile-new-toggle {
        min-width: 72px;
        padding: 8px 12px;
    }

    /* Adjust Documents Ledger header ordering on mobile:
       - move the compact '+ New' control below the description and above the tabs
       - add even vertical spacing above and below the button
       - keep desktop layout unchanged (this rule lives inside mobile media query)
    */
    .documents-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .documents-header .doc-actions {
        width: 100%;
        order: 2;
    }

    .documents-header .mobile-actions {
        width: 100%;
        display: block !important;
    }

    /* Make the toggle full-width or left-aligned depending on space; prefer full-width for clean layout */
    .documents-header #mobile-new-toggle {
        width: 100%;
        justify-content: flex-start;
        padding: 10px 14px;
        margin: 8px 0;
    }

    /* Ensure the dropdown menu is constrained to the parent width and stays inside viewport */
    .documents-header .mobile-new-menu {
        left: 0;
        right: 0;
        width: 100%;
        max-width: 360px;
        box-sizing: border-box;
    }

    /* Mobile-specific overflow & layout fixes
       - Ensure content and cards never exceed viewport width
       - Tables scroll inside their container instead of pushing page width
       - Settings grid stacks vertically and inputs/buttons fit mobile width
       - Scope button width changes to the settings area to avoid altering dashboard
    */
    .content-area {
        width: 100%;
        max-width: 100%;
        overflow-x: hidden;
    }

    .card {
        box-sizing: border-box;
        width: 100%;
        max-width: 100%;
    }

    /* Table containers should scroll horizontally inside their card */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        width: 100%;
        max-width: 100%;
    }

    /* Prevent tables from forcing page width; allow them to scroll inside .table-container */
    .table-container table {
        width: 100%;
        min-width: 600px; /* allow horizontal scroll when columns need space */
        table-layout: auto;
    }

    /* Prefer wrapping long content on mobile to avoid overflow where possible */
    .table-container th,
    .table-container td,
    table th,
    table td {
        white-space: normal;
        word-break: break-word;
    }

    /* Settings area: force the two-column settings grid to stack vertically on mobile.
       Uses structural selector to limit impact to the typical settings page layout. */
    .content-area > div > [style*="grid-template-columns"] {
        grid-template-columns: 1fr !important;
        display: grid !important;
        gap: 16px !important;
    }

    /* Ensure form rows stack into a single column on mobile */
    .form-row {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }

    /* Scope buttons inside the settings area to full-width for mobile forms only */
    .content-area > div > [style*="grid-template-columns"] .card .btn,
    .content-area > div > [style*="grid-template-columns"] .card .btn-sm {
        width: 100%;
        box-sizing: border-box;
    }

    /* Images should never overflow their containers */
    .card img,
    img {
        max-width: 100%;
        height: auto;
    }

    /* Landing preview safe constraints */
    .landing-hero-preview,
    .preview-window,
    .preview-content,
    .preview-kpi-grid,
    .preview-document-card {
        max-width: 100% !important;
        box-sizing: border-box !important;
    }

    /* Hide decorative landing blobs at this breakpoint as well to be safe */
    .landing-shell::before,
    .landing-shell::after {
        display: none !important;
    }
}

@media (min-width: 969px) {
    .mobile-topbar,
    .mobile-drawer,
    .mobile-drawer-overlay {
        display: none !important;
    }
}

@media (max-width: 600px) {
    .line-item-row, .line-item-header {
        grid-template-columns: 1.5fr 0.8fr 1fr auto;
    }
    .line-item-row .qty-col, .line-item-header .qty-col {
        display: none; /* Hide Qty column header/field, manage inline on mobile */
    }

    .additional-charge-row,
    .additional-charge-header {
        grid-template-columns: 1.5fr 1fr auto;
    }
}

/* 7. PRINT OVERRIDES */
@media print {
    @page {
        size: A4 portrait;
        margin: 0;
    }

    body {
        background-color: #ffffff !important;
        color: #000000 !important;
    }
    .sidebar, .nav-links, .btn, .quick-actions, .toast-container, .no-print {
        display: none !important;
    }
    .main-layout {
        display: block !important;
    }
    .content-area {
        padding: 0 !important;
        margin: 0 !important;
        max-width: 100% !important;
    }
    .document-paper {
        border: none !important;
        box-shadow: none !important;
        width: 210mm !important;
        min-height: auto !important;
        height: auto !important;
        padding: 10mm 12mm !important;
        margin: 0 !important;
        box-sizing: border-box !important;
    }
}
