/* ============================================
   CRM Panel Styles - RusCargo
   ============================================ */

:root {
    --crm-sidebar: #0f172a;
    --crm-sidebar-hover: #1e293b;
    --crm-sidebar-active: #2563eb;
    --crm-bg: #f1f5f9;
    --crm-card: #ffffff;
    --crm-border: #e2e8f0;
    --crm-text: #334155;
    --crm-text-light: #64748b;
    --crm-primary: #2563eb;
    --crm-primary-hover: #1d4ed8;
    --crm-success: #10b981;
    --crm-warning: #f59e0b;
    --crm-danger: #ef4444;
    --crm-info: #06b6d4;
    --crm-radius: 10px;
    --crm-shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
    --crm-shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.1);
}

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

body {
    font-family: 'Inter', sans-serif;
    color: var(--crm-text);
    line-height: 1.6;
    background: var(--crm-bg);
}

/* Layout */
.crm-layout {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.crm-sidebar {
    width: 260px;
    background: var(--crm-sidebar);
    color: #fff;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    overflow-y: auto;
}

.crm-sidebar-logo {
    padding: 1.5rem 1.25rem;
    font-size: 1.35rem;
    font-weight: 700;
    color: #fff;
    text-decoration: none;
    display: block;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    letter-spacing: -0.02em;
}

.crm-sidebar-section {
    padding: 1rem 0 0.25rem;
}

.crm-sidebar-section-title {
    padding: 0 1.25rem;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(255,255,255,0.35);
    margin-bottom: 0.4rem;
    font-weight: 600;
}

.crm-sidebar-nav {
    list-style: none;
    padding: 0;
    margin: 0;
}

.crm-sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 1.25rem;
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    font-size: 0.9rem;
    transition: all 0.15s;
    border-left: 3px solid transparent;
}

.crm-sidebar-nav a:hover {
    background: var(--crm-sidebar-hover);
    color: #fff;
}

.crm-sidebar-nav a.active {
    background: rgba(37,99,235,0.15);
    color: #fff;
    border-left-color: var(--crm-sidebar-active);
    font-weight: 600;
}

.crm-sidebar-nav .nav-icon {
    font-size: 1.15rem;
    width: 1.5rem;
    text-align: center;
    flex-shrink: 0;
}

.crm-sidebar-footer {
    margin-top: auto;
    padding: 1rem 1.25rem;
    border-top: 1px solid rgba(255,255,255,0.08);
}

.crm-sidebar-footer a {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: rgba(255,255,255,0.5);
    text-decoration: none;
    font-size: 0.85rem;
    transition: color 0.15s;
}

.crm-sidebar-footer a:hover {
    color: #fff;
}

/* Main Content */
.crm-main {
    flex: 1;
    margin-left: 260px;
    background: var(--crm-bg);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    min-width: 0;
    width: calc(100% - 260px);
}

/* Top Bar */
.crm-topbar {
    background: var(--crm-card);
    border-bottom: 1px solid var(--crm-border);
    padding: 0 2rem;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 50;
}

.crm-topbar-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.crm-topbar-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--crm-text);
}

.crm-topbar-breadcrumb {
    font-size: 0.8rem;
    color: var(--crm-text-light);
}

.crm-topbar-breadcrumb a {
    color: var(--crm-primary);
    text-decoration: none;
}

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

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

.crm-topbar-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--crm-primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    flex-shrink: 0;
}

.crm-topbar-user {
    font-size: 0.88rem;
    color: var(--crm-text);
    font-weight: 500;
}

/* Content Area */
.crm-content {
    padding: 1.75rem 2rem;
}

/* Cards */
.crm-card {
    background: var(--crm-card);
    border-radius: var(--crm-radius);
    box-shadow: var(--crm-shadow);
    border: 1px solid var(--crm-border);
    padding: 1.5rem;
    margin-bottom: 1.25rem;
}

.crm-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.crm-card-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.5rem;
    flex-wrap: wrap;
    white-space: normal;
    min-width: 0;
}

.crm-card-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--crm-text);
}

/* Stat Cards */
.crm-stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
    width: 100%;
}

.crm-stat-card {
    background: var(--crm-card);
    border-radius: var(--crm-radius);
    box-shadow: var(--crm-shadow);
    border: 1px solid var(--crm-border);
    padding: 1.25rem;
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    width: 100%;
    min-width: 0;
}

.crm-stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
}

.crm-stat-icon.blue { background: #dbeafe; }
.crm-stat-icon.green { background: #dcfce7; }
.crm-stat-icon.yellow { background: #fef3c7; }
.crm-stat-icon.purple { background: #ede9fe; }
.crm-stat-icon.red { background: #fee2e2; }
.crm-stat-icon.cyan { background: #cffafe; }

.crm-stat-info {
    flex: 1;
}

.crm-stat-label {
    font-size: 0.8rem;
    color: var(--crm-text-light);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    font-weight: 500;
}

.crm-stat-value {
    font-size: 1.65rem;
    font-weight: 800;
    color: var(--crm-text);
    line-height: 1.2;
    margin-top: 0.15rem;
}

/* Tables */
.crm-table-wrap {
    overflow-x: auto;
}

.crm-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.crm-table thead th {
    text-align: left;
    padding: 0.75rem 1rem;
    font-weight: 600;
    color: var(--crm-text-light);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 2px solid var(--crm-border);
    white-space: nowrap;
}

.crm-table tbody td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #f1f5f9;
    color: var(--crm-text);
    vertical-align: middle;
}

.crm-table tbody tr:hover {
    background: #f8fafc;
}

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

/* Badges */
.crm-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.3rem 0.75rem;
    border-radius: 50px;
    font-size: 0.78rem;
    font-weight: 600;
    white-space: nowrap;
}

.crm-badge-sent { background: #dbeafe; color: #1e40af; }
.crm-badge-in_transit { background: #fef3c7; color: #92400e; }
.crm-badge-received { background: #dcfce7; color: #166534; }
.crm-badge-issued { background: #f1f5f9; color: #475569; }

/* Buttons */
.crm-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.6rem 1.15rem;
    border-radius: 8px;
    font-size: 0.88rem;
    font-weight: 600;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: all 0.15s;
    line-height: 1.4;
    font-family: inherit;
}

.crm-btn-primary {
    background: var(--crm-primary);
    color: #fff;
}

.crm-btn-primary:hover {
    background: var(--crm-primary-hover);
}

.crm-btn-success {
    background: var(--crm-success);
    color: #fff;
}

.crm-btn-success:hover {
    background: #059669;
}

.crm-btn-warning {
    background: var(--crm-warning);
    color: #fff;
}

.crm-btn-warning:hover {
    background: #d97706;
}

.crm-btn-danger {
    background: var(--crm-danger);
    color: #fff;
}

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

.crm-btn-outline {
    background: transparent;
    color: var(--crm-text);
    border: 1px solid var(--crm-border);
}

.crm-btn-outline:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
}

.crm-btn-sm {
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
}

.crm-btn-lg {
    padding: 0.85rem 1.75rem;
    font-size: 1rem;
}

/* Forms */
.crm-form-group {
    margin-bottom: 1.25rem;
}

.crm-form-label {
    display: block;
    margin-bottom: 0.4rem;
    font-weight: 600;
    font-size: 0.88rem;
    color: var(--crm-text);
}

.crm-form-input,
.crm-form-select,
.crm-form-textarea {
    width: 100%;
    padding: 0.65rem 0.85rem;
    border: 1px solid var(--crm-border);
    border-radius: 8px;
    font-size: 0.92rem;
    font-family: inherit;
    color: var(--crm-text);
    background: #fff;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.crm-form-input:focus,
.crm-form-select:focus,
.crm-form-textarea:focus {
    outline: none;
    border-color: var(--crm-primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

.crm-form-textarea {
    min-height: 100px;
    resize: vertical;
}

.crm-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.crm-form-help {
    font-size: 0.8rem;
    color: var(--crm-text-light);
    margin-top: 0.25rem;
}

.crm-form-error {
    font-size: 0.8rem;
    color: var(--crm-danger);
    margin-top: 0.25rem;
}

/* Filter Bar */
.crm-filter-bar {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    align-items: center;
}

.crm-filter-bar .crm-form-input,
.crm-filter-bar .crm-form-select {
    width: auto;
    min-width: 180px;
}

/* Alert */
.crm-alert {
    padding: 0.85rem 1.15rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.crm-alert-success {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.crm-alert-error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.crm-alert-info {
    background: #dbeafe;
    color: #1e40af;
    border: 1px solid #bfdbfe;
}

/* Detail / Info grid */
.crm-detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.25rem;
}

.crm-detail-item {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.crm-detail-label {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--crm-text-light);
    font-weight: 500;
}

.crm-detail-value {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--crm-text);
}

/* Timeline */
.crm-timeline {
    position: relative;
    padding-left: 1.75rem;
}

.crm-timeline::before {
    content: '';
    position: absolute;
    left: 0.5rem;
    top: 0.5rem;
    bottom: 0.5rem;
    width: 2px;
    background: var(--crm-border);
}

.crm-timeline-item {
    position: relative;
    padding-bottom: 1.5rem;
}

.crm-timeline-item:last-child {
    padding-bottom: 0;
}

.crm-timeline-dot {
    position: absolute;
    left: -1.5rem;
    top: 0.35rem;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--crm-primary);
    border: 2px solid #fff;
    box-shadow: 0 0 0 2px var(--crm-primary);
}

.crm-timeline-date {
    font-size: 0.78rem;
    color: var(--crm-text-light);
}

.crm-timeline-text {
    font-size: 0.9rem;
    color: var(--crm-text);
    margin-top: 0.15rem;
}

/* Empty state */
.crm-empty {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--crm-text-light);
}

.crm-empty-icon {
    font-size: 3rem;
    margin-bottom: 0.75rem;
}

.crm-empty-text {
    font-size: 1rem;
}

/* Link styling inside tables */
.crm-link {
    color: var(--crm-primary);
    text-decoration: none;
    font-weight: 600;
}

.crm-link:hover {
    text-decoration: underline;
}

/* Shipment builder */
.crm-section-title {
    font-size: 1rem;
    font-weight: 800;
    color: var(--crm-text);
    margin-bottom: 0.85rem;
}

.crm-builder-block {
    margin-top: 1.5rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--crm-border);
}

.crm-builder-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.85rem;
    flex-wrap: wrap;
}

.crm-builder-list {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.crm-builder-row {
    border: 1px solid var(--crm-border);
    border-radius: 12px;
    padding: 0.9rem;
    background: #f8fafc;
}

.crm-builder-grid-items {
    display: grid;
    grid-template-columns: 1.4fr 1.4fr 0.8fr 0.8fr 0.9fr 1fr auto;
    gap: 0.75rem;
    align-items: end;
}

.crm-builder-grid-expenses {
    display: grid;
    grid-template-columns: 1.8fr 0.8fr 0.9fr auto;
    gap: 0.75rem;
    align-items: end;
}

.crm-builder-remove {
    height: 42px;
}

.crm-create-shell {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.crm-create-hero {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.25rem 1.35rem;
    border: 1px solid var(--crm-border);
    border-radius: 16px;
    background: linear-gradient(135deg, #ffffff 0%, #f8fbff 100%);
    box-shadow: var(--crm-shadow-sm);
}

.crm-create-hero-title {
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--crm-text);
    margin-bottom: 0.35rem;
}

.crm-create-hero-text {
    color: var(--crm-text-light);
    font-size: 0.92rem;
    max-width: 720px;
}

.crm-create-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.crm-create-section {
    border: 1px solid var(--crm-border);
    border-radius: 16px;
    background: #fff;
    overflow: hidden;
}

.crm-create-section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--crm-border);
    background: #f8fafc;
}

.crm-create-section-title {
    font-size: 1rem;
    font-weight: 800;
    color: var(--crm-text);
}

.crm-create-section-subtitle {
    font-size: 0.84rem;
    color: var(--crm-text-light);
    margin-top: 0.2rem;
}

.crm-create-section-body {
    padding: 1.25rem;
}

.crm-create-base-grid {
    display: grid;
    grid-template-columns: 1.1fr 1fr;
    gap: 1rem;
}

.crm-create-note {
    padding: 0.9rem 1rem;
    border-radius: 12px;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    color: #1e40af;
    font-size: 0.88rem;
    line-height: 1.5;
}

.crm-builder-row {
    border: 1px solid #dbe4f0;
    border-radius: 14px;
    padding: 1rem;
    background: #fbfdff;
}

.crm-builder-row:hover {
    border-color: #cbd5e1;
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.04);
}

.crm-create-actions {
    position: sticky;
    bottom: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.25rem;
    border: 1px solid var(--crm-border);
    border-radius: 16px;
    background: rgba(255,255,255,0.96);
    backdrop-filter: blur(10px);
    box-shadow: var(--crm-shadow-sm);
}

.crm-create-actions-text {
    color: var(--crm-text-light);
    font-size: 0.88rem;
}

.crm-create-actions-buttons {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

/* Login Page */
.crm-login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 100%);
    padding: 2rem;
}

.crm-login-card {
    background: #fff;
    border-radius: 16px;
    padding: 2.5rem;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.crm-login-title {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--crm-text);
    margin-bottom: 0.35rem;
    text-align: center;
}

.crm-login-subtitle {
    font-size: 0.9rem;
    color: var(--crm-text-light);
    text-align: center;
    margin-bottom: 2rem;
}

.crm-login-btn {
    width: 100%;
    padding: 0.85rem;
    background: var(--crm-primary);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s;
    font-family: inherit;
}

.crm-login-btn:hover {
    background: var(--crm-primary-hover);
}

/* ============================================
   MOBILE HEADER & NAVIGATION
   ============================================ */

/* Mobile Header (hidden on desktop) */
.crm-mobile-header {
    display: none;
}

/* Mobile Sidebar Close Button */
.crm-sidebar-close {
    display: none;
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 36px;
    height: 36px;
    background: rgba(255,255,255,0.1);
    border: none;
    border-radius: 50%;
    color: #fff;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    z-index: 10;
    transition: background 0.15s;
}

.crm-sidebar-close:hover {
    background: rgba(255,255,255,0.2);
}

/* Sidebar Overlay */
.crm-sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 99;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.crm-sidebar-overlay.is-visible {
    opacity: 1;
}

/* ============================================
   RESPONSIVE BREAKPOINTS
   ============================================ */

/* Large Tablets & Small Laptops (1024px and below) */
@media (max-width: 1024px) {
    .crm-layout {
        flex-direction: column;
    }

    .crm-sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }

    .crm-sidebar.is-open {
        transform: translateX(0);
    }

    .crm-sidebar-overlay {
        display: block;
        pointer-events: none;
    }

    .crm-sidebar-close {
        display: block;
    }

    .crm-sidebar-overlay.is-visible {
        pointer-events: auto;
    }

    .crm-main {
        margin-left: 0;
        width: 100%;
        min-width: 0;
    }

    .crm-mobile-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 0.75rem 1rem;
        background: var(--crm-card);
        border-bottom: 1px solid var(--crm-border);
        position: sticky;
        top: 0;
        z-index: 50;
        height: 56px;
        width: 100%;
    }

    .crm-mobile-menu-toggle {
        display: flex;
        flex-direction: column;
        justify-content: center;
        gap: 5px;
        width: 44px;
        height: 44px;
        padding: 10px;
        background: transparent;
        border: none;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }

    .crm-mobile-menu-toggle span {
        display: block;
        width: 24px;
        height: 2px;
        background: var(--crm-text);
        border-radius: 2px;
        transition: all 0.3s ease;
    }

    .crm-mobile-logo {
        font-weight: 700;
        font-size: 1.1rem;
        color: var(--crm-text);
    }

    .crm-mobile-avatar {
        width: 36px;
        height: 36px;
        border-radius: 50%;
        background: var(--crm-primary);
        color: #fff;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 0.9rem;
        font-weight: 700;
        text-transform: uppercase;
    }

    .crm-topbar {
        display: none;
    }

    .crm-content {
        padding: 1rem;
    }

    /* Touch-friendly buttons */
    .crm-btn {
        min-height: 44px;
        padding: 0.65rem 1rem;
    }

    .crm-btn-sm {
        min-height: 36px;
        padding: 0.4rem 0.75rem;
    }

    /* Tables horizontal scroll */
    .crm-table-wrap {
        margin: 0 -1rem;
        padding: 0 1rem;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .crm-table {
        min-width: 800px;
    }

    /* Cards */
    .crm-card {
        padding: 1rem;
    }

    .crm-card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    /* Stats grid - force full width */
    .crm-stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 0.75rem;
        width: 100%;
    }

    .crm-stat-card {
        padding: 1rem;
    }

    .crm-stat-icon {
        width: 40px;
        height: 40px;
        font-size: 1.2rem;
    }

    .crm-stat-value {
        font-size: 1.3rem;
    }

    /* Order cards */
    .crm-order-grid {
        grid-template-columns: 1fr;
    }

    .crm-order-card {
        padding: 1rem;
    }

    .crm-order-body {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
    }

    /* Forms */
    .crm-form-row {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .crm-form-group {
        margin-bottom: 1rem;
    }

    .crm-form-input,
    .crm-form-select,
    .crm-form-textarea {
        font-size: 16px; /* Prevents iOS zoom on focus */
        padding: 0.75rem;
    }

    /* Detail grid */
    .crm-detail-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }

    /* Builder */
    .crm-builder-grid-items,
    .crm-builder-grid-expenses {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .crm-builder-row {
        padding: 0.75rem;
    }

    .crm-create-hero,
    .crm-create-actions,
    .crm-create-section-head {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }

    .crm-create-base-grid {
        grid-template-columns: 1fr;
    }

    .crm-create-section-body {
        padding: 1rem;
    }

    /* Filter bar */
    .crm-filter-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .crm-filter-bar .crm-form-input,
    .crm-filter-bar .crm-form-select {
        width: 100%;
        min-width: auto;
    }

    /* Timeline */
    .crm-timeline {
        padding-left: 1.25rem;
    }

    .crm-timeline-dot {
        left: -1.25rem;
        width: 10px;
        height: 10px;
    }
}

/* Tablets (768px and below) */
@media (max-width: 768px) {
    .crm-card-actions {
        width: 100%;
        justify-content: flex-start;
    }

    .crm-card-actions .crm-btn {
        flex: 1 1 auto;
    }

    .crm-card-actions .crm-btn-sm {
        flex: 1 1 auto;
    }

    .crm-stats-grid {
        grid-template-columns: 1fr;
        width: 100%;
    }

    .crm-detail-grid {
        grid-template-columns: 1fr;
    }

    .crm-order-body {
        grid-template-columns: 1fr;
    }

    .crm-order-actions {
        flex-direction: column;
    }

    .crm-order-actions .crm-btn {
        width: 100%;
        justify-content: center;
    }

    /* Login */
    .crm-login-wrapper {
        padding: 1rem;
    }

    .crm-login-card {
        padding: 1.5rem;
    }
}

/* Small Phones (480px and below) */
@media (max-width: 480px) {
    /* Safe area support for iPhone notch */
    .crm-mobile-header {
        padding: 0.6rem 0.75rem;
        padding-top: max(0.6rem, env(safe-area-inset-top));
        padding-left: max(0.75rem, env(safe-area-inset-left));
        padding-right: max(0.75rem, env(safe-area-inset-right));
        height: calc(52px + env(safe-area-inset-top));
    }

    .crm-mobile-logo {
        font-size: 1rem;
    }

    .crm-content {
        padding: 0.75rem;
    }

    .crm-card {
        padding: 0.875rem;
        border-radius: 8px;
    }

    .crm-card-title {
        font-size: 0.95rem;
    }

    /* Even more compact stats */
    .crm-stat-card {
        padding: 0.875rem;
        gap: 0.75rem;
    }

    .crm-stat-icon {
        width: 36px;
        height: 36px;
        font-size: 1rem;
    }

    .crm-stat-value {
        font-size: 1.1rem;
    }

    .crm-stat-label {
        font-size: 0.7rem;
    }

    /* Compact buttons */
    .crm-btn {
        padding: 0.5rem 0.875rem;
        font-size: 0.85rem;
    }

    .crm-btn-lg {
        padding: 0.75rem 1.25rem;
    }

    /* Compact badges */
    .crm-badge {
        padding: 0.25rem 0.6rem;
        font-size: 0.7rem;
    }

    /* Smaller form labels */
    .crm-form-label {
        font-size: 0.8rem;
    }

    /* Tables even more compact */
    .crm-table-wrap {
        margin: 0 -0.75rem;
        padding: 0 0.75rem;
    }

    .crm-table {
        font-size: 0.8rem;
    }

    .crm-table thead th,
    .crm-table tbody td {
        padding: 0.5rem 0.6rem;
    }

    /* Order card compact */
    .crm-order-card {
        padding: 0.875rem;
    }

    .crm-order-field .o-label {
        font-size: 0.65rem;
    }

    .crm-order-field .o-value {
        font-size: 0.85rem;
    }

    /* Timeline compact */
    .crm-timeline {
        padding-left: 1rem;
    }

    .crm-timeline::before {
        left: 0.25rem;
    }

    .crm-timeline-dot {
        left: -0.875rem;
        width: 8px;
        height: 8px;
    }

    .crm-timeline-date {
        font-size: 0.7rem;
    }

    .crm-timeline-text {
        font-size: 0.85rem;
    }

    /* Create actions sticky bottom with safe area */
    .crm-create-actions {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        border-radius: 0;
        border-left: none;
        border-right: none;
        border-bottom: none;
        padding: 0.75rem;
        padding-bottom: max(0.75rem, env(safe-area-inset-bottom));
        z-index: 40;
    }

    /* Add padding to content to prevent overlap with sticky actions */
    .crm-create-form {
        padding-bottom: calc(80px + env(safe-area-inset-bottom));
    }

    /* Safe area for main content bottom */
    .crm-content {
        padding-bottom: max(0.75rem, env(safe-area-inset-bottom));
    }

    /* Safe area for sidebar overlay button on small phones */
    .crm-sidebar-close {
        top: max(1rem, env(safe-area-inset-top));
        right: max(1rem, env(safe-area-inset-right));
    }
}

/* Shipment Order Cards */
.crm-order-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 1rem;
}

.crm-order-card {
    background: var(--crm-card);
    border: 1px solid var(--crm-border);
    border-radius: var(--crm-radius);
    padding: 1.15rem 1.25rem;
    transition: box-shadow 0.15s, border-color 0.15s;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.crm-order-card:hover {
    box-shadow: var(--crm-shadow-md);
    border-color: #cbd5e1;
}

.crm-order-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.crm-order-id {
    font-weight: 800;
    font-size: 1rem;
    color: var(--crm-text);
}

.crm-order-body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem 1rem;
}

.crm-order-field {
    display: flex;
    flex-direction: column;
}

.crm-order-field .o-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--crm-text-light);
    font-weight: 600;
}

.crm-order-field .o-value {
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--crm-text);
}

.crm-order-field .o-value.primary {
    color: var(--crm-primary);
}

.crm-order-field .o-value.success {
    color: var(--crm-success);
    font-weight: 700;
}

.crm-order-actions {
    display: flex;
    gap: 0.4rem;
    border-top: 1px solid #f1f5f9;
    padding-top: 0.75rem;
    flex-wrap: wrap;
}

/* Category tag */
.crm-category-tag {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.55rem;
    border-radius: 6px;
    font-size: 0.73rem;
    font-weight: 600;
    background: #f0f4ff;
    color: #3b5998;
}

/* Print */
@media print {
    .crm-sidebar,
    .crm-topbar,
    .crm-mobile-header,
    .crm-sidebar-overlay,
    .crm-btn,
    .no-print {
        display: none !important;
    }

    .crm-main {
        margin-left: 0;
    }

    .crm-content {
        padding: 0;
    }

    .crm-card {
        box-shadow: none;
        border: none;
    }

    body {
        background: white;
    }
}
