/* =====================================================
   B2B.nu — Unified Stylesheet
   Tokens → Base elements → Components → Layout
   ===================================================== */

/* =====================================================
   DESIGN TOKENS
   ===================================================== */

:root {
    /* === LAYOUT === */
    --sidebar-width: 250px;
    --sidebar-collapsed-width: 70px;
    --navbar-height: 60px;

    /* === PRIMARY BRAND === */
    --primary-color: #4f7df3;
    --primary-soft: #e6eefc;
    --primary-dark: #2e4f98;
    --primary-focus: rgba(79, 125, 243, 0.2);

    /* === SEMANTIC / STATUS === */
    --color-success: #22c55e;
    --color-danger: #ef4444;
    --color-warning: #f59e0b;
    --color-info: #3b82f6;

    /* === TEXT === */
    --text-primary: #1f2937;
    --text-secondary: #4b5f88;
    --text-muted: #6b7280;
    --text-light: #9aa8c2;

    /* === SURFACES / BACKGROUNDS === */
    --page-bg: #f3f6fb;
    --card-bg: #ffffff;
    --surface-light: #f8f9fc;
    --surface-hover: #f5f8fe;
    --surface-input: #fbfcff;
    --surface-highlight: #eef3ff;
    --surface-muted: #f0f3f9;

    /* === BORDERS === */
    --card-border: #e6e9f0;
    --border-light: #f3f4f6;
    --border-medium: #e5e7eb;

    /* === ALERTS === */
    --alert-success-bg: #effaf4;
    --alert-success-text: #1f5f3a;
    --alert-danger-bg: #fff1f2;
    --alert-danger-text: #7f1d1d;
    --alert-warning-bg: #fff7ed;
    --alert-warning-text: #7c2d12;
    --alert-info-bg: #eff6ff;
    --alert-info-text: #1e3a8a;

    /* === SIDEBAR === */
    --sidebar-bg: #1d2f4a;
    --sidebar-bg-alt: #21498b;
    --sidebar-text: #c2d3f5;
    --sidebar-active: #ffffff;
    --sidebar-hover-bg: rgba(255, 255, 255, 0.12);
    --admin-sidebar-bg: #23324f;
    --admin-sidebar-alt: #1f3a63;

    /* === SHADOWS === */
    --shadow-soft: 0 12px 24px rgba(30, 41, 59, 0.08);
    --shadow-subtle: 0 3px 10px rgba(30, 41, 59, 0.08);
    --shadow-primary: 0 6px 14px rgba(79, 125, 243, 0.25);
    --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.04);

    /* === BORDER RADIUS === */
    --radius-xs: 4px;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 22px;
    --radius-btn: 0.75rem;
    --radius-pill: 9999px;

    /* === TRANSITIONS === */
    --transition-fast: 0.1s ease;
    --transition-base: 0.2s ease;
    --transition-slow: 0.3s ease;

    /* === FONTS === */
    --font-body: 'Open Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-heading: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* =====================================================
   BASE ELEMENTS
   ===================================================== */

body {
    font-family: var(--font-body);
    background-color: var(--page-bg);
    color: var(--text-primary);
    min-height: 100vh;
}

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

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

h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: var(--font-heading);
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.3px;
}

h1,
.content h1 {
    font-size: 1.75rem;
    margin-bottom: 0.25rem;
}

h2 {
    font-size: 1.5rem;
    margin-bottom: 0.25rem;
}

h3 {
    font-size: 1.25rem;
    margin-bottom: 0.25rem;
}

h4 {
    font-size: 1.1rem;
    margin-bottom: 0.25rem;
}

h5 {
    font-size: 1rem;
    margin-bottom: 0.25rem;
}

h6 {
    font-size: 0.875rem;
    margin-bottom: 0.25rem;
}

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

/* =====================================================
   COMPONENTS & LAYOUT
   ===================================================== */

/* Admin body */
.admin-body .admin-sidebar {
    background: linear-gradient(180deg, var(--admin-sidebar-bg) 0%, var(--admin-sidebar-alt) 100%);
}

.admin-body .nav-link.active {
    background-color: var(--surface-highlight);
    color: var(--primary-dark);
}

/* Wrapper */
.wrapper {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    height: 100dvh;
    background: linear-gradient(180deg, var(--sidebar-bg) 0%, var(--sidebar-bg-alt) 100%);
    position: fixed;
    left: 0;
    top: 0;
    z-index: 1000;
    transition: all var(--transition-slow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-header {
    padding: 1.5rem 1.25rem 1.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.16);
    flex: 0 0 auto;
}

.sidebar .logo {
    text-decoration: none;
    display: flex;
    align-items: center;
}

.sidebar .sidebar-logo {
    max-width: 100%;
    max-height: 40px;
    width: auto;
    height: auto;
    object-fit: contain;
}

.sidebar .nav {
    padding: 0.75rem 0 1rem;
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    flex-direction: column;
    flex-wrap: nowrap;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.sidebar .nav::-webkit-scrollbar {
    display: none;
}

.sidebar .nav-item {
    margin: 0.2rem 0.9rem;
    flex: 0 0 auto;
}

.sidebar .nav-link {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    color: var(--sidebar-text);
    border-radius: var(--radius-pill);
    text-decoration: none;
    transition: all var(--transition-base);
}

.sidebar .nav-link:hover {
    background-color: var(--sidebar-hover-bg);
    color: var(--sidebar-active);
}

.sidebar .nav-link.active {
    background-color: var(--surface-light);
    color: var(--primary-dark);
    font-weight: 600;
}

.sidebar .nav-link i {
    font-size: 1.2rem;
    width: 1.5rem;
    margin-right: 0.75rem;
    text-align: center;
}

.sidebar .nav-divider {
    height: 1px;
    background-color: rgba(255, 255, 255, 0.16);
    margin: 1rem 0.9rem;
    flex: 0 0 auto;
}

/* Collapsed sidebar */
.sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
}

.sidebar.collapsed .nav-link span,
.sidebar.collapsed .sidebar-footer .company-name {
    display: none;
}

.sidebar.collapsed .sidebar-logo {
    max-height: 30px;
}

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

.sidebar.collapsed .nav-link i {
    margin-right: 0;
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    transition: margin-left var(--transition-slow);
    max-width: calc(100vw - var(--sidebar-width));
    padding-bottom: 120px;
}

.sidebar.collapsed + .main-content {
    margin-left: var(--sidebar-collapsed-width);
    max-width: calc(100vw - var(--sidebar-collapsed-width));
}

.container-fluid {
    padding-left: 1.75rem;
    padding-right: 1.75rem;
}

.content .card {
    margin-bottom: 1.5rem;
}

.content .row.g-4 {
    --bs-gutter-x: 1.5rem;
    --bs-gutter-y: 1.5rem;
}

/* Navbar */
.navbar {
    height: var(--navbar-height);
    background-color: var(--surface-light);
    position: relative;
    z-index: 1030;
    overflow: visible;
}

.sidebar-toggle {
    font-size: 1.5rem;
    color: var(--text-secondary);
    padding: 0.25rem 0.5rem;
}

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

.navbar .btn-link {
    color: var(--text-muted);
    text-decoration: none;
    padding: 0.5rem;
}

.navbar .btn-link:hover {
    color: var(--text-primary);
}

.navbar .dropdown-toggle::after {
    display: none;
}

.navbar .avatar {
    font-size: 1.6rem;
    color: var(--text-secondary);
}

.fiscal-year-select {
    width: auto;
    min-width: 5.5rem;
}

.navbar .dropdown-menu {
    border-radius: var(--radius-lg);
    border-color: var(--card-border);
    box-shadow: var(--shadow-soft);
}

.navbar .dropdown-item {
    font-weight: 500;
}

/* Content */
.content {
    min-height: calc(100vh - var(--navbar-height));
    overflow-x: hidden;
}

.auth-page {
    background: linear-gradient(180deg, #f4f7fe 0%, #eef3fb 100%);
}

.auth-page .card {
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-soft);
}

.auth-page .card-body {
    padding: 2rem;
}

.auth-page .form-check-label {
    color: var(--text-secondary);
}

.auth-logo {
    max-width: 180px;
    height: auto;
}

.followup-inline-wrapper {
    align-items: center;
    gap: 0.35rem;
    margin-left: 0.5rem;
    vertical-align: middle;
    white-space: nowrap;
}

.followup-inline-wrapper.d-none {
    display: none !important;
}

.followup-inline-wrapper .input-group {
    width: 150px;
    flex-shrink: 0;
}

.followup-inline-wrapper .input-group .form-control,
.followup-inline-wrapper .input-group .btn {
    padding: 0.1rem 0.4rem;
    font-size: 0.8rem;
}

.followup-inline-wrapper input[type="time"] {
    width: 90px;
    padding: 0.1rem 0.4rem;
    font-size: 0.8rem;
    flex-shrink: 0;
}

/* Cards */
.card {
    border: 1px solid var(--card-border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-subtle);
    background-color: var(--card-bg);
}

.card .rounded-circle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 1 / 1;
    line-height: 1;
}

.card-header {
    background-color: transparent;
    border-bottom: 1px solid var(--card-border);
    font-weight: 600;
}

.card-header h5,
.card-header h6 {
    font-weight: 600;
}

/* Tables */
.table {
    margin-bottom: 0;
    border-color: var(--card-border);
}

.table-responsive {
    overflow-x: auto;
    overflow-y: visible;
}

@media (min-width: 992px) {
    .table-responsive {
        overflow: visible;
    }
}

.table th {
    font-weight: 600;
    color: var(--text-muted);
    background-color: var(--surface-light);
    border-bottom-width: 1px;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding-left: 1.25rem;
}

.table td {
    vertical-align: middle;
    padding-left: 1.25rem;
}

.table th:first-child,
.table td:first-child {
    padding-left: 1.5rem;
}

.todo-th-title {
    white-space: nowrap;
    width: 40%;
}

.todo-cell-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: nowrap;
}

.todo-actions-inline {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    flex-shrink: 0;
}

.todo-title-content {
    min-width: 0;
    flex: 1;
}

.todo-title-content .todo-title {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.bug-reports-table th,
.bug-reports-table td {
    vertical-align: top;
}

.bug-reports-table > :not(caption) > * > * {
    vertical-align: top;
}

.table-hover tbody tr:hover {
    background-color: var(--surface-hover);
}

/* Status Badges */
.badge {
    font-weight: 500;
    padding: 0.35em 0.65em;
    border-radius: var(--radius-pill);
    font-size: 0.75rem;
}

.badge-status-paid { background-color: var(--color-success); }
.badge-status-cancelled { background-color: var(--text-muted); }
.badge-status-pending { background-color: var(--color-warning); }

.badge-priority-a { background-color: var(--color-danger); }
.badge-priority-b { background-color: var(--color-warning); }
.badge-priority-c { background-color: var(--color-info); }

select.priority-select-a {
    background-color: #fee2e2 !important;
    border-color: var(--color-danger) !important;
}

select.priority-select-b {
    background-color: #fef3c7 !important;
    border-color: var(--color-warning) !important;
}

select.priority-select-c {
    background-color: #dbeafe !important;
    border-color: var(--color-info) !important;
}

.category-tag {
    color: #ffffff;
    font-weight: 600;
}

.category-tag.light-text {
    color: var(--text-primary);
}

/* Forms */
.form-label {
    font-weight: 600;
    font-size: 0.8rem;
    margin-bottom: 0.375rem;
    color: var(--text-muted);
}

.form-control,
.form-select {
    border-radius: var(--radius-sm);
    border-color: var(--card-border);
    background-color: var(--surface-input);
}

.form-control-sm {
    font-size: 1rem;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-focus);
}

.form-control.is-invalid:focus {
    border-color: var(--color-danger);
    box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.15);
}

.form-control::placeholder {
    color: var(--text-light);
}

/* Buttons */
.btn {
    font-weight: 600;
    border-radius: var(--radius-btn);
    padding: 0.5rem 1.1rem;
}

.btn-primary {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    box-shadow: var(--shadow-primary);
}

.btn-outline-primary {
    border-color: #9fb7f6;
    color: var(--primary-dark);
}

.btn-outline-primary:hover {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.btn-outline-primary:focus {
    box-shadow: 0 0 0 3px var(--primary-focus);
}

/* Pipeline / Kanban */
.pipeline {
    display: flex;
    gap: 1rem;
    overflow-x: auto;
    padding-bottom: 1rem;
}

.pipeline-stage {
    min-width: 280px;
    max-width: 280px;
    background-color: var(--surface-hover);
    border-radius: var(--radius-xl);
    padding: 1rem;
    border: 1px solid var(--card-border);
}

.breadcrumb-item + .breadcrumb-item::before {
    color: var(--text-light);
}

/* Modal */
.modal-header {
    border-bottom: 1px solid var(--border-medium);
}

.modal-footer {
    border-top: 1px solid var(--border-medium);
}

.alert {
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-medium);
    box-shadow: var(--shadow-subtle);
}

.alert-success {
    background-color: var(--alert-success-bg);
    color: var(--alert-success-text);
}

.alert-danger {
    background-color: var(--alert-danger-bg);
    color: var(--alert-danger-text);
}

.alert-warning {
    background-color: var(--alert-warning-bg);
    color: var(--alert-warning-text);
}

.alert-info {
    background-color: var(--alert-info-bg);
    color: var(--alert-info-text);
}

/* Responsive Utilities */
.mobile-card-view {
    display: none;
}

@media (max-width: 767.98px) {
    .desktop-table-view {
        display: none;
    }

    .mobile-card-view {
        display: block;
    }

    /* Mobile Card Style */
    .mobile-card {
        background: #fff;
        border: 1px solid var(--card-border);
        border-radius: var(--radius-sm);
        padding: 1rem;
        margin-bottom: 1rem;
        box-shadow: var(--shadow-subtle);
    }

    .mobile-card-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 0.5rem;
        padding-bottom: 0.5rem;
        border-bottom: 1px solid var(--card-border);
    }

    .mobile-card-title {
        font-weight: 600;
        font-size: 1rem;
        margin: 0;
    }

    .mobile-card-body {
        font-size: 0.875rem;
    }

    .mobile-card-row {
        display: flex;
        justify-content: space-between;
        margin-bottom: 0.25rem;
    }

    .mobile-card-label {
        color: var(--text-muted);
        font-weight: 500;
    }

    .mobile-card-value {
        font-weight: 500;
        text-align: right;
    }

    .mobile-card-actions {
        margin-top: 0.75rem;
        padding-top: 0.75rem;
        border-top: 1px dashed var(--card-border);
        display: flex;
        justify-content: flex-end;
        gap: 0.5rem;
    }

    /* Filter Forms */
    .filter-form .row > div {
        margin-bottom: 0.5rem;
    }

    /* Mobile Invoice Form Lines */
    .invoice-line-table thead {
        display: none;
    }

    .invoice-line-table tbody tr {
        display: block;
        background: #fff;
        border: 1px solid var(--card-border);
        border-radius: var(--radius-sm);
        padding: 1rem;
        margin-bottom: 1rem;
        position: relative;
    }

    .invoice-line-table td {
        display: block;
        border: none;
        padding: 0.25rem 0;
        width: 100% !important;
        text-align: left !important;
    }

    .invoice-line-table td::before {
        content: attr(data-label);
        font-weight: 600;
        font-size: 0.75rem;
        color: var(--text-muted);
        display: block;
        margin-bottom: 0.25rem;
    }

    /* Hide label for description as it's obvious */
    .invoice-line-table td:first-child::before {
        display: none;
    }

    /* Remove button positioning */
    .invoice-line-table td:last-child {
        position: absolute;
        top: 0.5rem;
        right: 0.5rem;
        width: auto !important;
        padding: 0;
    }
}

/* Sidebar Overlay Mobile + Responsive */
@media (max-width: 991.98px) {
    .container-fluid {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .sidebar {
        margin-left: calc(-1 * var(--sidebar-width));
        box-shadow: 0 0 15px rgba(0,0,0,0.2);
        position: fixed;
        top: var(--navbar-height);
        left: 0;
        bottom: 0;
        height: calc(100vh - var(--navbar-height)) !important;
        height: calc(100dvh - var(--navbar-height)) !important;
        min-height: 0 !important;
        max-height: calc(100vh - var(--navbar-height)) !important;
        max-height: calc(100dvh - var(--navbar-height)) !important;
        overflow: hidden !important;
        display: flex !important;
        flex-direction: column !important;
    }

    .sidebar .sidebar-header {
        flex: 0 0 auto;
        display: none;
    }

    .sidebar .nav {
        flex: 1 1 0 !important;
        min-height: 0 !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 2rem;
        display: flex !important;
        flex-direction: column !important;
        flex-wrap: nowrap !important;
    }

    .sidebar .nav-item {
        flex: 0 0 auto !important;
        width: 100% !important;
        display: block !important;
    }

    .sidebar .nav-divider {
        flex: 0 0 auto !important;
        width: 100% !important;
    }

    .sidebar .sidebar-footer {
        position: static !important;
        flex: 0 0 auto;
        width: 100%;
        padding-bottom: 2rem;
    }

    .sidebar.show {
        margin-left: 0;
    }

    .sidebar-overlay {
        position: fixed;
        top: var(--navbar-height);
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0,0,0,0.5);
        z-index: 999;
        display: none;
        opacity: 0;
        transition: opacity var(--transition-slow);
    }

    body.sidebar-open .sidebar-overlay {
        display: block;
        opacity: 1;
    }

    .main-content {
        margin-left: 0 !important;
        max-width: 100vw !important;
    }

    /* Prevent body scroll when sidebar is open */
    body.sidebar-open {
        overflow: hidden;
        position: fixed;
        width: 100%;
    }

    /* Mobile navbar styled as menu bar */
    .navbar {
        background: linear-gradient(180deg, var(--sidebar-bg) 0%, var(--sidebar-bg-alt) 100%) !important;
        border-bottom: none !important;
    }

    .sidebar-toggle {
        color: #ffffff !important;
    }

    .sidebar-toggle:hover {
        color: rgba(255, 255, 255, 0.8) !important;
    }

    .navbar .btn-link {
        color: rgba(255, 255, 255, 0.85) !important;
    }

    .navbar .btn-link:hover {
        color: #ffffff !important;
    }

    .navbar .avatar {
        color: rgba(255, 255, 255, 0.85) !important;
    }

    .navbar .text-muted {
        color: rgba(255, 255, 255, 0.7) !important;
    }

    .navbar .form-select {
        background-color: rgba(255, 255, 255, 0.15) !important;
        color: #ffffff !important;
        border-color: rgba(255, 255, 255, 0.25) !important;
    }
}

/* Print */
@media print {
    .sidebar,
    .navbar,
    .btn {
        display: none !important;
    }

    .main-content {
        margin-left: 0 !important;
    }

    .card {
        box-shadow: none !important;
        border: 1px solid #000 !important;
    }
}

/* =====================================================
   Global Search (Command Palette)
   ===================================================== */

.global-search {
    position: relative;
    flex: 0 1 380px;
    margin: 0 1.5rem 0 0;
    z-index: 9999;
}

.global-search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.global-search-input {
    width: 100%;
    height: 36px;
    padding: 0 0.75rem;
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-btn);
    background-color: var(--surface-muted);
    font-size: 0.8rem;
    color: var(--text-primary);
    outline: none;
    transition: all var(--transition-base);
}

.global-search-input::placeholder {
    color: var(--text-light);
    font-size: 0.8rem;
}

.global-search-input:hover {
    background-color: var(--surface-muted);
    border-color: #c8cfe0;
}

.global-search-input:focus {
    background-color: #fff;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 125, 243, 0.12);
}

.global-search.active .global-search-input {
    background-color: #fff;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 125, 243, 0.12);
    border-radius: var(--radius-md) var(--radius-md) 0 0;
}

/* Results dropdown — rendered at body level, positioned by JS */
.global-search-results {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    left: auto;
    width: max(100%, 480px);
    background: #ffffff;
    border: 1px solid var(--primary-color);
    border-top: 1px solid var(--border-light);
    border-radius: 0 0 12px 12px;
    box-shadow: 0 12px 36px rgba(30, 41, 59, 0.22), 0 0 0 1px rgba(0,0,0,0.05);
    max-height: min(400px, calc(100vh - var(--navbar-height) - 20px));
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 9999;
    scrollbar-width: thin;
}

.global-search-results.active {
    display: block;
}

/* Category headers */
.global-search-category {
    padding: 0.45rem 0.85rem 0.2rem;
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-light);
    background: var(--surface-light);
    border-bottom: 1px solid var(--border-light);
    position: sticky;
    top: 0;
    z-index: 1;
}

/* Result items */
.global-search-item {
    display: flex;
    align-items: center;
    padding: 0.5rem 0.85rem;
    text-decoration: none;
    color: var(--text-primary);
    background-color: #ffffff;
    cursor: pointer;
    transition: background-color var(--transition-fast);
    border-bottom: 1px solid var(--border-light);
}

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

.global-search-item:hover {
    background-color: var(--surface-highlight);
    color: var(--text-primary);
    text-decoration: none;
}

.global-search-item.active {
    background-color: var(--surface-highlight);
    color: var(--text-primary);
    text-decoration: none;
}

.global-search-item-icon {
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    background: var(--surface-muted);
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-right: 0.65rem;
    flex-shrink: 0;
    transition: all var(--transition-fast);
}

.global-search-item.active .global-search-item-icon,
.global-search-item:hover .global-search-item-icon {
    background: var(--primary-color);
    color: #fff;
}

.global-search-item-text {
    flex: 1;
    min-width: 0;
}

.global-search-item-name {
    font-weight: 600;
    font-size: 0.8rem;
    line-height: 1.3;
}

.global-search-item-desc {
    font-size: 0.7rem;
    color: var(--text-light);
    line-height: 1.3;
}

/* Empty / no results */
.global-search-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
    padding: 1.5rem 1rem;
    color: var(--text-light);
    font-size: 0.8rem;
}

.global-search-empty i {
    font-size: 1.25rem;
    opacity: 0.4;
}

.global-search-no-results {
    padding: 1.25rem 1rem;
    text-align: center;
    color: var(--text-light);
    font-size: 0.8rem;
}

/* Overlay */
.global-search-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: transparent;
    z-index: 9990;
}

.global-search-overlay.active {
    display: block;
}

/* Responsive */
@media (max-width: 767.98px) {
    .global-search {
        flex: 1 1 auto;
        margin: 0 0.5rem;
    }

    .global-search-input {
        padding-right: 0.75rem;
    }

    .global-search-results {
        left: 0 !important;
        right: 0 !important;
        border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    }
}

@media print {
    .global-search,
    .global-search-overlay {
        display: none !important;
    }
}

/* Utilities */
.cursor-pointer {
    cursor: pointer;
}

.min-h-400 {
    min-height: 400px;
}

/* Bug Report Floating Button */
.bug-report-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    text-align: center;
}

.bug-report-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 700;
    margin-bottom: 6px;
    text-shadow: 0 1px 2px rgba(255,255,255,0.9);
}

.bug-report-btn {
    width: 64px;
    height: 64px;
    background: transparent;
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    animation: pulse-bug 2s infinite;
}

@keyframes pulse-bug {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.bug-report-btn:hover {
    transform: scale(1.15) !important;
}

@media (max-width: 767.98px) {
    .bug-report-container { transform: scale(0.5); transform-origin: bottom right; }
}

@media print {
    .bug-report-container {
        display: none !important;
    }
}

/* =====================================================
   Dashboard Cards & New Design
   ===================================================== */

/* Base dashboard card with soft styling */
.dashboard-card {
    border: none;
    border-radius: var(--radius-lg);
    background: #fff;
    box-shadow: var(--shadow-card), 0 1px 2px rgba(0, 0, 0, 0.02);
    transition: box-shadow var(--transition-base);
}

.dashboard-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06), 0 1px 3px rgba(0, 0, 0, 0.04);
}

/* KPI Row - Verksamheten just nu */
.kpi-col {
    padding: 0 1.25rem;
    border-right: 1px solid var(--border-medium);
}

.kpi-col-last,
.kpi-col:last-child {
    border-right: none;
}

.kpi-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    font-weight: 500;
    white-space: nowrap;
}

.kpi-value {
    font-size: 1.6rem;
    font-weight: 700;
    line-height: 1.2;
    white-space: nowrap;
}

.kpi-badge {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.2rem 0.5rem;
    border-radius: var(--radius-sm);
    white-space: nowrap;
}

.kpi-badge-up {
    background: #dcfce7;
    color: #16a34a;
}

.kpi-badge-down {
    background: #fee2e2;
    color: #dc2626;
}

.kpi-badge-neutral {
    background: var(--border-light);
    color: var(--text-muted);
}

@media (max-width: 767.98px) {
    .kpi-col {
        border-right: none;
        border-bottom: 1px solid var(--border-medium);
        padding: 0.75rem 0;
    }
    .kpi-col:last-child,
    .kpi-col-last {
        border-bottom: none;
    }
    .kpi-value {
        font-size: 1.3rem;
    }
}

/* ToDo Widget */
.todo-list {
    padding: 0 1.25rem 1.25rem 1.25rem;
}

.todo-item {
    padding: 1rem 1.25rem;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    margin-bottom: 0.75rem;
    background: #fff;
    transition: all var(--transition-base);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.01);
}

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

.todo-item:hover {
    border-color: var(--border-medium);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04);
}

.todo-checkbox-form {
    margin: 0;
    line-height: 1;
    display: flex;
    align-items: center;
}

.todo-checkbox {
    width: 26px;
    height: 26px;
    min-width: 26px;
    min-height: 26px;
    border-radius: 50%;
    border: 1.5px solid #a5b4fc;
    background: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: all var(--transition-base);
    flex-shrink: 0;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    outline: none;
    box-sizing: border-box;
}

.todo-checkbox:hover {
    border-color: #60a5fa;
    background: var(--surface-highlight);
}

.todo-checkbox-inner {
    display: block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: transparent;
    transition: background var(--transition-base);
}

.todo-checkbox:hover .todo-checkbox-inner {
    background: var(--color-info);
}

.todo-title {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-primary);
    text-decoration: none;
    display: block;
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.todo-title:hover {
    color: var(--color-info);
    text-decoration: none;
}

.todo-subtitle {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.2rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.todo-badge-important {
    background: #ffedd5;
    color: #c2410c;
    font-weight: 600;
    font-size: 0.75rem;
    padding: 0.35em 0.75em;
    border-radius: var(--radius-pill);
    white-space: nowrap;
}

.todo-badge-overdue {
    background: #fee2e2;
    color: #dc2626;
    font-weight: 600;
    font-size: 0.75rem;
    padding: 0.35em 0.75em;
    border-radius: var(--radius-pill);
    white-space: nowrap;
}

.todo-badge-due-soon {
    background: #fef9c3;
    color: #b45309;
    font-weight: 600;
    font-size: 0.75rem;
    padding: 0.35em 0.75em;
    border-radius: var(--radius-pill);
    white-space: nowrap;
}

.todo-badge-ready {
    background: var(--surface-highlight);
    color: #2563eb;
    font-weight: 600;
    font-size: 0.75rem;
    padding: 0.35em 0.75em;
    border-radius: var(--radius-pill);
    white-space: nowrap;
}

/* Activity Widget */
.activity-list {
    padding: 0;
}

.activity-item {
    padding: 0.875rem 1.5rem;
    border-bottom: 1px solid var(--border-light);
    transition: background var(--transition-base);
}

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

.activity-item:hover {
    background: var(--surface-light);
}

.activity-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 0.9rem;
}

.activity-title {
    font-weight: 600;
    font-size: 0.9rem;
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.activity-time {
    font-size: 0.8rem;
    color: var(--text-light);
}

.activity-badge-booked {
    background: var(--surface-highlight);
    color: #2563eb;
    font-weight: 600;
    border: 1px solid #bfdbfe;
    font-size: 0.75rem;
    padding: 0.25em 0.625em;
    border-radius: var(--radius-pill);
    white-space: nowrap;
}

.activity-badge-internal {
    background: #faf5ff;
    color: #7c3aed;
    font-weight: 600;
    border: 1px solid #ddd6fe;
    font-size: 0.75rem;
    padding: 0.25em 0.625em;
    border-radius: var(--radius-pill);
    white-space: nowrap;
}

.activity-badge-deadline {
    background: #fef2f2;
    color: #dc2626;
    font-weight: 600;
    border: 1px solid #fecaca;
    font-size: 0.75rem;
    padding: 0.25em 0.625em;
    border-radius: var(--radius-pill);
    white-space: nowrap;
}

/* Cashflow Widget */
.cashflow-chart-container {
    position: relative;
    max-width: 200px;
    margin: 0 auto;
}

.cashflow-center-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    pointer-events: none;
}

.cashflow-balance {
    display: block;
    font-size: 1.1rem;
    font-weight: 700;
    color: #06b6d4;
    line-height: 1.2;
}

.cashflow-label {
    display: block;
    font-size: 0.7rem;
    color: var(--text-light);
    margin-top: 0.125rem;
}

.cashflow-legend {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.cashflow-legend-item {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    font-size: 0.85rem;
}

.cashflow-legend-dot {
    width: 12px;
    height: 12px;
    border-radius: var(--radius-xs);
    flex-shrink: 0;
}

.cashflow-legend-label {
    flex-grow: 1;
}

.cashflow-legend-value {
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

/* Health Gauge Widget */
.health-gauge-container {
    position: relative;
    max-width: 280px;
    margin: 1rem auto 0;
}

.health-gauge-center {
    position: absolute;
    bottom: 10%;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
    pointer-events: none;
}

.health-gauge-value {
    display: block;
    font-size: 2.5rem;
    font-weight: 700;
    line-height: 1;
}

.health-gauge-label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* =====================================================
   Dashboard Customization / Drag and Drop
   ===================================================== */

/* Dashboard zones */
.dashboard-zone {
    min-height: 50px;
    transition: all var(--transition-base);
}

.dashboard-zone-full {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.dashboard-zone-top,
.dashboard-zone-bottom {
    min-height: 100px;
    display: flex;
    flex-direction: column;
}

.dashboard-zone-top > .dashboard-widget,
.dashboard-zone-bottom > .dashboard-widget {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.dashboard-zone-top > .dashboard-widget > .dashboard-card,
.dashboard-zone-bottom > .dashboard-widget > .dashboard-card {
    flex: 1;
}

/* Edit mode */
body.dashboard-edit-mode .dashboard-zone {
    background: rgba(79, 125, 243, 0.05);
    border: 2px dashed rgba(79, 125, 243, 0.2);
    border-radius: var(--radius-sm);
    padding: 0.75rem;
}

body.dashboard-edit-mode .dashboard-zone-full {
    padding: 0.75rem;
}

body.dashboard-edit-mode .dashboard-zone-hidden:empty::after {
    content: 'Dra widgets hit för att dölja dem';
    display: block;
    padding: 1rem;
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* Widget container */
.dashboard-widget {
    position: relative;
    transition: all var(--transition-base);
}

body.dashboard-edit-mode .dashboard-widget {
    border: 2px dashed transparent;
    border-radius: var(--radius-sm);
    padding: 0.25rem;
}

body.dashboard-edit-mode .dashboard-widget:hover {
    border-color: var(--primary-color);
    background: rgba(79, 125, 243, 0.02);
}

/* Widget controls */
.widget-controls {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    z-index: 10;
    display: flex;
    gap: 0.25rem;
    opacity: 0;
    transition: opacity var(--transition-base);
}

body.dashboard-edit-mode .widget-controls {
    opacity: 1;
}

body.dashboard-edit-mode .dashboard-widget:hover .widget-controls {
    opacity: 1;
}

.widget-drag-handle {
    cursor: grab;
    padding: 0.35rem 0.5rem;
    background: #fff;
    border-radius: var(--radius-sm);
    border: 1px solid var(--card-border);
    color: var(--text-muted);
    font-size: 1rem;
    display: flex;
    align-items: center;
    box-shadow: var(--shadow-subtle);
}

.widget-drag-handle:active {
    cursor: grabbing;
    background: var(--primary-soft);
    color: var(--primary-color);
}

.widget-hide-btn {
    padding: 0.35rem 0.5rem;
    background: #fff;
    border: 1px solid var(--card-border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--text-muted);
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    box-shadow: var(--shadow-subtle);
    transition: all var(--transition-base);
}

.widget-hide-btn:hover {
    background: var(--color-danger);
    color: white;
    border-color: var(--color-danger);
}

/* Sortable ghost and chosen states */
.dashboard-widget.sortable-ghost {
    opacity: 0.4;
    background: rgba(79, 125, 243, 0.1);
    border-radius: var(--radius-sm);
}

.dashboard-widget.sortable-chosen {
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    transform: rotate(1deg);
}

.dashboard-widget.sortable-drag {
    opacity: 1 !important;
}

/* Hidden widgets panel */
#hidden-widgets-panel {
    border-color: var(--card-border);
}

#hidden-widgets-panel .card-header {
    background: #f8f9fa;
    font-weight: 500;
}

.dashboard-zone-hidden {
    min-height: 60px;
}

/* Hidden widget chip */
.dashboard-widget-hidden {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: #fff;
    border: 1px solid var(--card-border);
    border-radius: var(--radius-sm);
    cursor: grab;
    box-shadow: var(--shadow-subtle);
    transition: all var(--transition-base);
}

.dashboard-widget-hidden:hover {
    border-color: var(--primary-color);
    background: var(--primary-soft);
}

.dashboard-widget-hidden:active {
    cursor: grabbing;
}

.dashboard-widget-hidden .widget-controls {
    position: static;
    opacity: 1;
}

.dashboard-widget-hidden .widget-drag-handle {
    padding: 0.25rem;
    background: transparent;
    border: none;
    box-shadow: none;
}

.widget-hidden-label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
}

/* Hide original widget content when in hidden zone */
.dashboard-widget-hidden > .card,
.dashboard-widget-hidden > .alert,
.dashboard-widget-hidden > .row {
    display: none !important;
}

/* Edit mode buttons */
#dashboard-customize-btn {
    border-color: var(--card-border);
}

#dashboard-customize-btn:hover {
    background: var(--primary-soft);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

/* Responsive: Disable drag-drop on mobile */
@media (max-width: 991.98px) {
    #dashboard-customize-btn,
    #dashboard-save-btn,
    #dashboard-cancel-btn,
    #dashboard-reset-btn,
    #hidden-widgets-panel {
        display: none !important;
    }

    .widget-controls {
        display: none !important;
    }
}

/* =====================================================
   CRM INFO PANEL — DRAG & DROP LAYOUT
   ===================================================== */

.layout-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
}

.layout-slot {
    position: relative;
    min-height: 48px;
    border: 2px solid transparent;
    border-radius: 0.375rem;
    padding: 0.35rem 0.5rem;
    transition: border-color 0.15s, background-color 0.15s;
}

/* Show dashed borders only in edit mode */
#infoPanel.editing .layout-slot {
    border: 2px dashed var(--bs-gray-300);
}

#infoPanel.editing .layout-slot.drag-over {
    border-color: var(--bs-primary);
    background-color: rgba(var(--bs-primary-rgb), 0.06);
}

.layout-slot-content {
    position: relative;
}

.layout-slot-remove {
    position: absolute;
    top: 0;
    right: 0;
    background: none;
    border: none;
    color: var(--bs-gray-500);
    font-size: 1.1rem;
    line-height: 1;
    padding: 0;
    cursor: pointer;
}

.layout-slot-remove:hover {
    color: var(--bs-danger);
}

/* Drag handle on form labels */
.drag-grip {
    color: var(--bs-gray-400);
    cursor: grab;
    margin-right: 0.1rem;
}

.drag-label {
    cursor: grab;
    user-select: none;
    border-radius: 0.25rem;
    padding: 0.1rem 0.25rem;
    transition: background-color 0.15s, opacity 0.15s;
}

.drag-label:hover {
    background-color: rgba(var(--bs-primary-rgb), 0.08);
}

.drag-label.dragging {
    opacity: 0.4;
}

.drag-label-used {
    color: var(--bs-primary);
}

.drag-label-used::after {
    content: '\f26a';
    font-family: 'bootstrap-icons';
    font-size: 0.65rem;
    margin-left: 0.3rem;
    vertical-align: middle;
}

/* Company quick links (Google, Alla Bolag, Maps, Website) */
.company-quick-links .btn {
    gap: 0;
}
@media (max-width: 767.98px) {
    .company-quick-links .btn {
        width: 32px !important;
        height: 32px !important;
        font-size: 16px !important;
    }
}

/* Account Picker */
.account-picker {
    position: relative;
}

.account-picker-dropdown {
    position: absolute;
    z-index: 1050;
    top: 100%;
    left: 0;
    right: 0;
    min-width: 350px;
    background: #fff;
    border: 1px solid var(--card-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-soft);
    margin-top: 2px;
}

.ap-header {
    padding: 0.5rem;
    border-bottom: 1px solid var(--card-border);
}

.ap-table-wrap {
    max-height: 300px;
    overflow-y: auto;
}

.ap-table thead th {
    position: sticky;
    top: 0;
    background: var(--surface-light);
    cursor: pointer;
    font-size: 0.8rem;
    white-space: nowrap;
}

.ap-account-row {
    cursor: pointer;
    font-size: 0.85rem;
}

.ap-account-row:hover {
    background-color: var(--primary-light, #e8f0fe);
}

.ap-group-row td {
    font-weight: 600;
    font-size: 0.75rem;
    color: var(--text-muted);
    background: var(--surface-light);
    padding: 0.25rem 0.5rem;
}

.ap-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.4rem 0.5rem;
    border-top: 1px solid var(--card-border);
    font-size: 0.8rem;
}

.ap-pagination {
    display: flex;
    gap: 0.25rem;
}

.mw-250 {
    max-width: 250px;
}

/* CRM Reports icon circles */
.report-icon-circle {
    width: 80px;
    height: 80px;
}

/* =====================================================
   MOBILE RESPONSIVENESS — Global Rules
   All rules below are mobile-only (max-width: 767.98px)
   and do NOT affect desktop layout.
   ===================================================== */

@media (max-width: 767.98px) {

    /* --- 1A. Page Headers: stack title + buttons vertically --- */
    .d-flex.justify-content-between.align-items-center.mb-4 {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 0.75rem;
    }

    .d-flex.justify-content-between.align-items-center.mb-4 > .d-flex.gap-2,
    .d-flex.justify-content-between.align-items-center.mb-4 > div:last-child {
        width: 100%;
        flex-wrap: wrap;
    }

    .d-flex.justify-content-between.align-items-center.mb-4 .btn-primary {
        flex: 1 1 auto;
    }

    .d-flex.justify-content-between.align-items-center.mb-4 .btn {
        flex: 1 1 auto;
        min-width: 0;
    }

    /* --- 1B. Touch Targets: 44px minimum --- */
    .btn {
        min-height: 44px;
        padding-top: 0.5rem;
        padding-bottom: 0.5rem;
    }

    .btn-sm {
        min-height: 38px;
    }

    .form-control,
    .form-select,
    .input-group-text {
        min-height: 44px;
        font-size: 1rem;
    }

    .form-check-input {
        width: 1.25em;
        height: 1.25em;
    }

    .page-link {
        min-width: 44px;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .dropdown-item {
        padding: 0.625rem 1rem;
        min-height: 44px;
        display: flex;
        align-items: center;
    }

    .nav-pills .nav-link,
    .nav-tabs .nav-link {
        min-height: 44px;
        display: flex;
        align-items: center;
    }

    /* --- 1C. Forms: single column, full width --- */
    .filter-form .col-md-2,
    .filter-form .col-md-3,
    .filter-form .col-md-4 {
        flex: 0 0 100%;
        max-width: 100%;
    }

    .card-body .row.g-3 > [class*="col-md-"],
    .card-body .row.g-2 > [class*="col-md-"],
    .modal-body .row.g-3 > [class*="col-md-"],
    .modal-body .row.g-2 > [class*="col-md-"] {
        flex: 0 0 100%;
        max-width: 100%;
    }

    .form-control,
    .form-select {
        width: 100%;
    }

    /* --- 1D. Stat Cards: 2 columns on mobile --- */
    .row.g-3.mb-4 > .col-md-3:not(.col-6):not(.col-12),
    .row.g-3.mb-4 > .col-md-4:not(.col-6):not(.col-12) {
        flex: 0 0 50%;
        max-width: 50%;
    }

    .row.g-3.mb-4 .card-body {
        padding: 0.75rem;
    }

    .row.g-3.mb-4 .h3 {
        font-size: 1.25rem;
    }

    .row.g-3.mb-4 .h4 {
        font-size: 1.1rem;
    }

    /* Stat card icon circles: smaller on mobile */
    .row.g-3.mb-4 .rounded-circle.p-3 {
        padding: 0.5rem !important;
    }

    .row.g-3.mb-4 .rounded-circle.p-3 .fs-4 {
        font-size: 1rem !important;
    }

    /* --- 1E. Prevent horizontal scroll + general layout --- */
    html,
    body {
        overflow-x: hidden;
    }

    body {
        font-size: 1rem;
    }

    img {
        max-width: 100%;
        height: auto;
    }

    .card-header.d-flex {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .card-header .d-flex.gap-2 {
        flex-wrap: wrap;
    }

    .breadcrumb {
        font-size: 0.8rem;
    }

    .mw-200,
    .mw-250,
    .mw-300,
    .mw-600 {
        max-width: 100% !important;
    }

    /* Page title sizing */
    .h3 {
        font-size: 1.35rem;
    }

    /* --- 1F. Nav Pills/Tabs: horizontal scroll --- */
    .nav-pills,
    .nav-tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding-bottom: 0.25rem;
    }

    .nav-pills::-webkit-scrollbar,
    .nav-tabs::-webkit-scrollbar {
        display: none;
    }

    .nav-pills .nav-item,
    .nav-tabs .nav-item {
        flex: 0 0 auto;
    }

    .nav-pills .nav-link,
    .nav-tabs .nav-link {
        white-space: nowrap;
        font-size: 0.85rem;
        padding: 0.5rem 0.75rem;
    }

    /* --- 1G. Scrollable tables: better mobile experience --- */
    .table-responsive,
    .table-responsive-lg {
        -webkit-overflow-scrolling: touch;
    }

    .table-responsive table,
    .table-responsive-lg table {
        font-size: 0.85rem;
    }

    .table-responsive th,
    .table-responsive td,
    .table-responsive-lg th,
    .table-responsive-lg td {
        white-space: nowrap;
        padding: 0.5rem 0.4rem;
    }

    /* --- 1H. Kanban: stack columns vertically --- */
    .kanban-board {
        flex-direction: column;
    }

    .kanban-column {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
    }

    /* --- 1I. Modals: full width on mobile --- */
    .modal-dialog {
        margin: 0.5rem;
    }

    .modal-lg,
    .modal-xl {
        max-width: calc(100% - 1rem);
    }

    /* --- 1J. Account picker + offcanvas --- */
    .account-picker-dropdown {
        min-width: 0;
        width: 100%;
    }

    .offcanvas-w-680 {
        width: 100% !important;
    }

    /* Document grid: 2 columns on mobile */
    #docGridInner .col-4 {
        flex: 0 0 50%;
        max-width: 50%;
    }

    /* --- 1K. Layout-grid (CRM company show) --- */
    .layout-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    /* --- 1L. Two-column layouts stack on mobile --- */
    .col-lg-8,
    .col-lg-4 {
        flex: 0 0 100%;
        max-width: 100%;
    }

    /* --- 1M. Action button groups in card headers --- */
    .card-header .btn-group {
        flex-wrap: wrap;
    }

    /* --- 1N. Report icon circles smaller on mobile --- */
    .report-icon-circle {
        width: 50px;
        height: 50px;
    }

    /* --- 1O. Step indicators wrap on mobile --- */
    .d-flex.align-items-center.gap-2.flex-wrap .badge {
        font-size: 0.75rem;
    }

    /* --- 1P. CRM Company show: header grid stacks --- */
    .d-grid[style*="grid-template-columns"] {
        display: flex !important;
        flex-direction: column;
        gap: 0.75rem;
    }

    /* --- 1Q. Iframes responsive on mobile --- */
    iframe,
    .doc-iframe {
        width: 100% !important;
        max-width: 100%;
    }

    /* --- 1R. Min-height constraints relaxed on mobile --- */
    .min-h-400 {
        min-height: 250px;
    }

    .max-h-600 {
        max-height: 400px;
    }
}
