:root {
    --primary: #10b981;
    --primary-dark: #059669;
    --secondary: #3b82f6;
    --bg-color: #f3f4f6;
    --card-bg: rgba(255, 255, 255, 0.9);
    --text-main: #1f2937;
    --text-muted: #6b7280;
    --border-color: #e5e7eb;
    --error: #ef4444;
    --success: #10b981;
}

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

body {
    font-family: 'Outfit', sans-serif;
    background: linear-gradient(135deg, #e0f2fe 0%, #d1fae5 100%);
    color: var(--text-main);
    min-height: 100vh;
}

.app-container {
    max-width: 600px;
    margin: 0 auto;
    background-color: white;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 0 20px rgba(0,0,0,0.05);
    position: relative;
    padding-bottom: env(safe-area-inset-bottom);
}

header {
    background: var(--primary);
    color: white;
    padding: calc(15px + env(safe-area-inset-top)) 20px 15px;
    text-align: center;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.logo h1 {
    font-size: 1.5rem;
    margin: 0;
    font-weight: 600;
    letter-spacing: 1px;
}

.sum-table .bg-25 th, .sum-table .bg-25 td {
    border: 1px solid #000;
}
.sum-table .bg-15 th, .sum-table .bg-15 td {
    border: 1px solid #000;
}

/* Trailer Diagram */
.trailer-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    border: 2px solid #000;
    margin-top: 10px;
}
.trailer-box {
    position: relative;
    border: 1px solid #000;
    height: 60px;
    background-color: #eaf4f4; /* light greenish tint like the paper */
}
.trailer-box .t-pos {
    position: absolute;
    top: 2px;
    left: 4px;
    font-size: 10px;
    font-weight: bold;
}
.trailer-box .t-cuadro {
    position: absolute;
    top: 4px;
    right: 8px;
    font-size: 14px;
    font-weight: bold;
    color: #1e3a8a; /* Dark blue for pen */
}
.trailer-box .t-tamano {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}
.tamano-circle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background-color: #f472b6; /* pink highlighter color */
    color: #fff;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    font-size: 14px;
    font-weight: bold;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
}
.trailer-box .t-total {
    position: absolute;
    bottom: 2px;
    left: 4px;
    font-size: 14px;
    font-weight: bold;
    color: #1e3a8a;
}

.bottom-action-bar .btn {
    flex: 1;
}
    position: absolute;
    top: 2px;
    left: 4px;
    font-size: 10px;
    font-weight: bold;
}
.trailer-box .t-cuadro {
    position: absolute;
    top: 4px;
    right: 8px;
    font-size: 14px;
    font-weight: bold;
    color: #1e3a8a; /* Dark blue for pen */
}
.trailer-box .t-tamano {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}
.tamano-circle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background-color: #f472b6; /* pink highlighter color */
    color: #fff;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    font-size: 14px;
    font-weight: bold;
}
.trailer-box .t-total {
    position: absolute;
    bottom: 2px;
    left: 4px;
    font-size: 14px;
    font-weight: bold;
    color: #1e3a8a;
}

.subtitle {
    font-size: 0.85rem;
    opacity: 0.9;
}

main {
    padding: 15px;
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.grid-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
}

@media (max-width: 900px) {
    .grid-container {
        grid-template-columns: 1fr;
    }
}

/* Cards (Glassmorphism) */
.card {
    background: var(--card-bg);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    padding: 25px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.4);
}

.card h2 {
    margin-bottom: 20px;
    font-size: 1.5rem;
    color: var(--primary-dark);
    border-bottom: 2px solid var(--primary);
    padding-bottom: 10px;
    display: inline-block;
}

/* Form Styles */
.form-group {
    margin-bottom: 20px;
}
.color-tooltip-container:hover .tooltip-img {
    display: block !important;
}
.tooltip-img {
    cursor: zoom-in;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.tooltip-img:hover {
    transform: scale(1.02);
    box-shadow: 0 6px 20px rgba(0,0,0,0.15);
}

.form-row {
    display: flex;
    gap: 15px;
}

.form-row .form-group {
    flex: 1;
}

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

input[type="text"],
input[type="date"],
input[type="number"],
input[type="time"],
select {
    width: 100%;
    padding: 12px 15px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: #f9fafb;
    font-family: inherit;
    font-size: 1rem;
    transition: all 0.3s ease;
}

input[type="text"]:focus,
input[type="date"]:focus,
input[type="number"]:focus,
input[type="time"]:focus,
select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
    background: #fff;
}

/* Checkbox */
.checkbox-group {
    margin-top: 10px;
}

.custom-checkbox {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-size: 1rem;
    user-select: none;
}

.custom-checkbox input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}

.checkmark {
    height: 24px;
    width: 24px;
    background-color: #eee;
    border-radius: 6px;
    margin-right: 10px;
    position: relative;
    transition: all 0.2s ease;
}

.custom-checkbox:hover input ~ .checkmark {
    background-color: #ccc;
}

.custom-checkbox input:checked ~ .checkmark {
    background-color: var(--primary);
}

.checkmark:after {
    content: "";
    position: absolute;
    display: none;
}

.custom-checkbox input:checked ~ .checkmark:after {
    display: block;
}

.custom-checkbox .checkmark:after {
    left: 9px;
    top: 5px;
    width: 6px;
    height: 12px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

/* Scanner Section */
.scanner-section {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

#reader {
    width: 100%;
    border-radius: 12px;
    overflow: hidden;
    border: 2px dashed var(--primary);
    background: #000;
}

.scanner-controls {
    margin-top: 20px;
    display: flex;
    justify-content: center;
    gap: 10px;
}

/* Buttons */
.btn {
    padding: 12px 24px;
    border-radius: 8px;
    border: none;
    font-family: inherit;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

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

.btn-primary:hover:not(:disabled) {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

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

.btn-secondary:hover:not(:disabled) {
    background: #dc2626;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

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

.btn-success:hover:not(:disabled) {
    background: #2563eb;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

/* List */
.list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.scanned-list-container {
    max-height: 250px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: #fff;
}

.scanned-list {
    list-style: none;
}

.scanned-list li {
    padding: 12px 15px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    animation: slideIn 0.3s ease-out;
}

.scanned-list li:last-child {
    border-bottom: none;
}

.qr-text {
    font-family: monospace;
    font-size: 1.1rem;
    color: var(--text-main);
}

.remove-btn {
    background: none;
    border: none;
    color: var(--error);
    cursor: pointer;
    font-size: 1.5rem;
    line-height: 1;
    transition: transform 0.2s;
}

.remove-btn:hover {
    transform: scale(1.2);
}

/* Animations */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background: white;
    padding: 15px 25px;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    gap: 15px;
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    z-index: 1000;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

.toast.success {
    border-left: 4px solid var(--success);
}
.toast.error {
    border-left: 4px solid var(--error);
}

.toast-icon {
    font-size: 1.5rem;
}

.toast.success .toast-icon::before {
    content: '✅';
}
.toast.error .toast-icon::before {
    content: '⚠️';
}

/* Modal */
.modal {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(5px);
}
.modal.hidden {
    display: none;
}
.modal-content {
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
}

/* Bottom Action Bar (Floating above Nav) */
.bottom-action-bar {
    position: fixed;
    bottom: calc(60px + env(safe-area-inset-bottom)); /* Above nav bar */
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 600px;
    background: transparent;
    padding: 10px 15px;
    display: flex;
    gap: 10px;
    z-index: 90;
    pointer-events: none; /* Let clicks pass through empty space */
}
.bottom-action-bar button {
    pointer-events: auto; /* Re-enable clicks on buttons */
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

/* App Bottom Navigation Bar */
.bottom-nav-bar {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 600px;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-top: 1px solid rgba(226, 232, 240, 0.9);
    padding: 6px 8px;
    padding-bottom: max(6px, env(safe-area-inset-bottom));
    display: flex;
    align-items: center;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE/Edge */
    box-shadow: 0 -3px 15px rgba(0, 0, 0, 0.08);
    z-index: 100;
}

.bottom-nav-bar::-webkit-scrollbar {
    display: none; /* Chrome, Safari, Edge */
}

@media (min-width: 768px) {
    .bottom-nav-bar {
        max-width: 860px;
    }
}

.nav-item {
    flex: 1 0 auto;
    min-width: 68px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 6px 8px;
    color: #64748b;
    text-decoration: none;
    font-size: 0.70rem;
    font-weight: 600;
    white-space: nowrap;
    border-radius: 10px;
    transition: all 0.2s ease;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.nav-item:hover {
    color: var(--primary-dark);
    background: rgba(16, 185, 129, 0.06);
}

.nav-item.active {
    color: #065f46;
    background: #ecfdf5;
    font-weight: 700;
}

.nav-item .icon {
    font-size: 1.35rem;
    line-height: 1.15;
    margin-bottom: 2px;
    transition: transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.nav-item.active .icon {
    transform: scale(1.15);
}

.nav-item span:not(.icon) {
    font-size: 0.69rem;
    letter-spacing: -0.2px;
    line-height: 1.1;
}

