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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: #f5f5f5;
    line-height: 1.6;
}

.app {
    max-width: 100%;
    min-height: 100vh;
    background: white;
    margin: 0 auto;
}

.header {
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    color: white;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.header-content {
    max-width: 1600px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
}

.header-logo {
    height: 60px;
    width: auto;
    object-fit: contain;
    background: white;
    padding: 8px;
    border-radius: 8px;
}

.header-text {
    display: flex;
    flex-direction: column;
    text-align: center;
}

.header h1 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 5px;
}

.header h2 {
    font-size: 18px;
    font-weight: 400;
    opacity: 0.9;
}

/* Breadcrumb Container */
.breadcrumb-container {
    background: linear-gradient(135deg, #3d5a96 0%, #4a6bb3 100%);
    padding: 12px 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    display: none; /* Hidden by default, shown when system is selected */
}

.breadcrumb {
    max-width: 1600px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    flex-wrap: wrap;
}

.breadcrumb-item {
    color: rgba(255, 255, 255, 0.85);
    cursor: pointer;
    transition: all 0.3s ease;
    padding: 6px 12px;
    border-radius: 6px;
}

.breadcrumb-item:hover:not(.active) {
    color: white;
    background: rgba(255, 255, 255, 0.15);
}

.breadcrumb-item.active {
    color: white;
    font-weight: 600;
    cursor: default;
    background: rgba(255, 255, 255, 0.1);
}

.breadcrumb-separator {
    color: rgba(255, 255, 255, 0.6);
    user-select: none;
    font-size: 16px;
}

/* Landing Page */
.landing-page {
    min-height: calc(100vh - 120px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px 15px;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
}

.landing-container {
    max-width: 900px;
    width: 100%;
}

.landing-title {
    text-align: center;
    font-size: 24px;
    font-weight: 700;
    color: #1e3c72;
    margin-bottom: 24px;
}

.selection-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
}

.selection-card {
    background: white;
    border-radius: 12px;
    padding: 24px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    border: 2px solid transparent;
    position: relative;
}

.selection-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.12);
    border-color: #1e3c72;
}

.selection-card:active {
    transform: translateY(-2px);
}

.card-icon {
    font-size: 48px;
    margin-bottom: 12px;
    transition: transform 0.3s ease;
    line-height: 1;
}

.selection-card:hover .card-icon {
    transform: scale(1.1);
}

.card-title {
    font-size: 18px;
    font-weight: 700;
    color: #1e3c72;
    margin-bottom: 8px;
    line-height: 1.3;
}

.card-description {
    font-size: 13px;
    color: #6c757d;
    margin-bottom: 16px;
    line-height: 1.4;
}

.card-button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #1e3c72;
    color: white;
    padding: 10px 18px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 13px;
    transition: all 0.3s ease;
}

.selection-card:hover .card-button {
    background: #2a5298;
    gap: 8px;
}

.arrow {
    transition: transform 0.3s ease;
    font-size: 14px;
}

.selection-card:hover .arrow {
    transform: translateX(3px);
}

/* Mobile optimizations */
@media (max-width: 768px) {
    .header {
        padding: 15px 10px;
    }
    
    .header-content {
        gap: 15px;
    }
    
    .header-logo {
        height: 45px;
    }
    
    .header h1 {
        font-size: 18px;
        margin-bottom: 3px;
    }
    
    .header h2 {
        font-size: 14px;
    }
    
    .header h2 {
        font-size: 16px;
    }
    
    .breadcrumb-container {
        padding: 10px 15px;
    }
    
    .breadcrumb {
        font-size: 13px;
    }
    
    .breadcrumb-item {
        padding: 5px 10px;
    }
    
    .landing-page {
        padding: 15px 10px;
        min-height: calc(100vh - 100px);
    }
    
    .landing-title {
        font-size: 20px;
        margin-bottom: 20px;
    }
    
    .selection-cards {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .selection-card {
        padding: 20px 16px;
        border-radius: 10px;
    }
    
    .card-icon {
        font-size: 40px;
        margin-bottom: 10px;
    }
    
    .card-title {
        font-size: 16px;
        margin-bottom: 6px;
    }
    
    .card-description {
        font-size: 12px;
        margin-bottom: 14px;
    }
    
    .card-button {
        padding: 9px 16px;
        font-size: 13px;
    }
}

/* Very small screens */
@media (max-width: 380px) {
    .landing-title {
        font-size: 18px;
    }
    
    .selection-card {
        padding: 18px 14px;
    }
    
    .card-icon {
        font-size: 36px;
    }
    
    .card-title {
        font-size: 15px;
    }
    
    .card-description {
        font-size: 11px;
    }
}

.container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 20px;
}

.layout {
    display: grid;
    grid-template-columns: 1fr 450px;
    gap: 20px;
}

@media (max-width: 1200px) {
    .layout { 
        grid-template-columns: 1fr;
    }
    
    #rightPanel {
        display: none !important;
    }
}

@media (min-width: 1201px) {
    #leftPanel .tabs .tab:first-child {
        display: none;
    }
}

@media (max-width: 768px) {
    body {
        font-size: 14px;
    }
    
    .header {
        padding: 15px 10px;
    }
    
    .header h1 {
        font-size: 20px;
    }
    
    .header h2 {
        font-size: 16px;
    }
    
    .container {
        padding: 0;
    }
    
    .layout {
        gap: 0;
    }
    
    .panel {
        border-radius: 0;
        box-shadow: none;
        border-bottom: 1px solid #e9ecef;
    }
    
    .panel-body {
        padding: 15px 10px;
    }
    
    .panel-header {
        padding: 12px 10px;
    }
    
    .form-row {
        margin-bottom: 14px;
    }
    
    .items-section {
        padding: 10px;
        margin-bottom: 14px;
        border-radius: 6px;
    }
    
    .item-row {
        grid-template-columns: 1fr 55px 44px;
        gap: 4px;
    }
    
    .item-row input {
        font-size: 13px;
        padding: 10px 6px;
    }
    
    .item-row input.item-qty {
        padding: 10px 2px;
    }
    
    .btn-icon {
        width: 44px;
        height: 48px;
    }
    
    .action-buttons {
        flex-direction: column;
    }
    
    .stat-grid {
        gap: 8px;
    }
    
    .order-head {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .order-date {
        font-size: 11px;
    }
    
    .tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .tab {
        white-space: nowrap;
        padding: 12px 16px;
        font-size: 13px;
    }
    
    .modal {
        padding: 0;
    }
    
    .modal-dialog {
        max-width: 100%;
        border-radius: 0;
    }
    
    .modal-header {
        padding: 12px 10px;
    }
    
    .modal-header h3 {
        font-size: 16px;
    }
    
    .modal-body {
        padding: 15px 10px;
    }
    
    .modal-footer {
        padding: 12px 10px;
        flex-wrap: wrap;
    }
    
    .email-preview {
        font-size: 11px;
        padding: 12px;
    }
    
    .order-items table {
        font-size: 12px;
    }
    
    .order {
        padding: 15px 10px;
    }
    
    #pendingOrdersTab > div:first-child,
    #pendingOrdersTab .stat-grid {
        padding-left: 10px;
        padding-right: 10px;
    }
    
    .auto-order-info {
        margin-left: 0;
        margin-right: 0;
    }
}

@media (max-width: 480px) {
    .header {
        padding: 12px 10px;
    }
    
    .header-content {
        gap: 12px;
    }
    
    .header-logo {
        height: 40px;
    }
    
    .header h1 {
        font-size: 16px;
    }
    
    .header h2 {
        font-size: 13px;
    }
    
    .container {
        padding: 0;
    }
    
    .panel {
        border-radius: 0;
    }
    
    .panel-header {
        padding: 15px 10px;
        font-size: 14px;
    }
    
    .panel-body {
        padding: 15px 10px;
    }
    
    .items-section {
        padding: 10px;
    }
    
    .item-row {
        grid-template-columns: 1fr 48px 44px;
        gap: 4px;
    }
    
    .item-row input {
        font-size: 13px;
        padding: 10px 4px;
    }
    
    .item-row input.item-qty {
        padding: 10px 2px;
        font-size: 12px;
    }
    
    .btn-icon {
        width: 44px;
        height: 48px;
    }
    
    .form-row input,
    .form-row select,
    .form-row textarea {
        font-size: 13px;
    }
    
    .btn {
        font-size: 13px;
        padding: 12px;
    }
    
    .stat-value {
        font-size: 20px;
    }
    
    .stat-label {
        font-size: 10px;
    }
    
    .order {
        padding: 12px 10px;
    }
    
    .order-crew {
        font-size: 14px;
    }
    
    .order-type {
        font-size: 10px;
        padding: 2px 6px;
    }
    
    .order-items {
        padding: 10px;
    }
    
    .order-items table {
        font-size: 11px;
    }
    
    .order-items td {
        padding: 3px 6px;
    }
    
    .order-notes {
        font-size: 12px;
        padding: 8px 10px;
    }
    
    .modal-footer .btn {
        flex: 1;
        min-width: 0;
    }
    
    .modal-dialog {
        border-radius: 0;
    }
    
    .modal-header {
        padding: 12px 10px;
    }
    
    .modal-body {
        padding: 15px 10px;
    }
    
    .modal-footer {
        padding: 12px 10px;
    }
}

.panel {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    overflow: hidden;
}

.panel-header {
    background: #f8f9fa;
    padding: 15px 20px;
    border-bottom: 2px solid #e9ecef;
    font-weight: 700;
    font-size: 16px;
    color: #495057;
}

.panel-body {
    padding: 20px;
}

.form-row {
    margin-bottom: 16px;
}

.form-row label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 600;
    color: #333;
}

.form-row input,
.form-row select,
.form-row textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid #e9ecef;
    border-radius: 6px;
    font-size: 16px;
    font-family: inherit;
    height: 48px;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    transition: border-color 0.3s ease;
}

.form-row input:focus,
.form-row select:focus,
.form-row textarea:focus {
    outline: none;
    border-color: #1e3c72;
    box-shadow: 0 0 0 3px rgba(30, 60, 114, 0.1);
}

.form-row select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

.form-row textarea {
    resize: vertical;
    min-height: 80px;
    height: auto;
}

.items-section {
    border: 2px solid #e9ecef;
    border-radius: 6px;
    padding: 12px;
    background: #fafafa;
    margin-bottom: 16px;
    overflow: hidden;
}

.items-header {
    font-size: 14px;
    font-weight: 600;
    color: #333;
    margin-bottom: 12px;
}

.item-row {
    display: grid;
    grid-template-columns: 1fr 70px 48px;
    gap: 8px;
    margin-bottom: 8px;
    align-items: start;
}

.item-row input {
    padding: 12px;
    border: 2px solid #e9ecef;
    border-radius: 6px;
    font-size: 14px;
    height: 48px;
    min-width: 0;
    transition: border-color 0.3s ease;
}

.item-row input.item-qty {
    text-align: center;
    padding: 12px 4px;
}

.item-row input:focus {
    outline: none;
    border-color: #1e3c72;
    box-shadow: 0 0 0 3px rgba(30, 60, 114, 0.1);
}

.pipe-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1.5fr 48px;
    gap: 8px;
    margin-bottom: 8px;
    align-items: start;
}

.pipe-row input {
    padding: 12px;
    border: 2px solid #e9ecef;
    border-radius: 6px;
    font-size: 14px;
    height: 48px;
    min-width: 0;
    transition: border-color 0.3s ease;
}

.pipe-row input:focus {
    outline: none;
    border-color: #1e3c72;
    box-shadow: 0 0 0 3px rgba(30, 60, 114, 0.1);
}

@media (max-width: 768px) {
    .pipe-row {
        grid-template-columns: 1fr;
        gap: 8px;
    }
    
    .pipe-row .btn-icon {
        grid-column: 1;
        width: 100%;
    }
}

.btn {
    padding: 12px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    height: 48px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    min-height: 44px;
}

.btn-primary {
    background: #1e3c72;
    color: white;
}

.btn-primary:hover {
    background: #2a5298;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(30, 60, 114, 0.3);
}

.btn-success {
    background: #28a745;
    color: white;
}

.btn-success:hover {
    background: #218838;
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
}

.btn-outline {
    background: transparent;
    color: #1e3c72;
    border: 2px solid #1e3c72;
}

.btn-outline:hover {
    background: #1e3c72;
    color: white;
}

.btn-icon {
    width: 48px;
    height: 48px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-block {
    width: 100%;
}

.btn-add {
    background: #e3f2fd;
    color: #1e3c72;
    border: 2px dashed #1e3c72;
    margin-top: 4px;
}

.btn-add:hover {
    background: #bbdefb;
}

.btn-remove {
    background: #f8d7da;
    color: #dc3545;
}

.btn-remove:hover {
    background: #f5c6cb;
}

.action-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 16px;
}

.tabs {
    display: flex;
    border-bottom: 1px solid #e9ecef;
    background: #f8f9fa;
}

.tab {
    padding: 12px 20px;
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    color: #6c757d;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    height: 48px;
    display: flex;
    align-items: center;
    transition: all 0.3s ease;
}

.tab.active {
    color: #1e3c72;
    border-bottom-color: #1e3c72;
    background: white;
}

.orders-container {
    max-height: calc(100vh - 240px);
    overflow-y: auto;
}

.order {
    border-bottom: 1px solid #e9ecef;
    padding: 20px;
}

.order:last-child {
    border-bottom: none;
}

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

.order-crew {
    font-weight: 600;
    font-size: 15px;
    color: #333;
}

.order-date {
    font-size: 12px;
    color: #6c757d;
}

.order-items {
    background: #fafafa;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    padding: 12px;
    margin-bottom: 8px;
}

.order-items table {
    width: 100%;
    font-size: 13px;
}

.order-items td {
    padding: 4px 8px;
}

.order-items td:first-child {
    padding-left: 0;
}

.order-items td:last-child {
    text-align: right;
    font-weight: 600;
    color: #1e3c72;
    padding-right: 0;
}

.order-items td.checkbox-cell {
    width: 30px;
    text-align: center;
    padding: 4px;
}

.order-items input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: #dc3545;
}

.order-items tr.missing-item {
    background: #fff5f5;
}

.order-items tr.missing-item td {
    color: #dc3545;
}

.order-notes {
    background: #fff3cd;
    border-left: 3px solid #ffc107;
    padding: 8px 12px;
    margin-bottom: 8px;
    font-size: 13px;
    color: #856404;
}

.order-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.empty {
    text-align: center;
    padding: 40px;
    color: #9ca3af;
}

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 600;
}

.badge-success {
    background: #d4edda;
    color: #155724;
}

.badge-delivery {
    margin-left: 4px;
}

.badge-missing {
    background: #f8d7da;
    color: #721c24;
    margin-left: 4px;
}

.delivery-today {
    background: #fff3cd;
    color: #856404;
}

.delivery-tomorrow {
    background: #cfe2ff;
    color: #084298;
}

.delivery-past {
    background: #d1e7dd;
    color: #0f5132;
}

.delivery-future {
    background: #e2e3e5;
    color: #41464b;
}

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal.active {
    display: flex;
}

.modal-dialog {
    background: white;
    border-radius: 8px;
    max-width: 700px;
    width: 100%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

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

.modal-header h3 {
    font-size: 18px;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: #9ca3af;
    cursor: pointer;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}

.modal-close:hover {
    background: #f3f4f6;
    color: #4b5563;
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    padding: 16px 20px;
    border-top: 1px solid #e9ecef;
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    background: #f8f9fa;
}

.email-preview {
    background: #fafafa;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    padding: 16px;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    line-height: 1.6;
    white-space: pre-wrap;
    margin-top: 12px;
}

.alert {
    padding: 15px 20px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 14px;
}

.alert-success {
    background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
    color: #155724;
    border: 1px solid #c3e6cb;
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 500;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.alert-success::before {
    content: "✓";
    background: #28a745;
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 16px;
}

.stat {
    background: #fafafa;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    padding: 12px;
    text-align: center;
}

.stat-label {
    font-size: 11px;
    text-transform: uppercase;
    color: #6c757d;
    font-weight: 600;
    margin-bottom: 4px;
}

.stat-value {
    font-size: 24px;
    font-weight: 700;
    color: #1e3c72;
}

.auto-order-info {
    background: #e3f2fd;
    border: 2px solid #1e3c72;
    border-radius: 6px;
    padding: 12px;
    font-size: 13px;
    color: #1e3c72;
    margin-bottom: 16px;
}

.auto-order-message {
    font-weight: 600;
    margin-bottom: 4px;
}

.countdown-timer {
    font-size: 12px;
    color: #2a5298;
    font-weight: 500;
}

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

@keyframes slideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(400px);
        opacity: 0;
    }
}
