:root {
    --primary-blue: #2563EB;
    --border-color: #000000;
}

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

body {
    font-family: 'Sarabun', sans-serif;
    background-color: #f0f2f5;
    color: #000;
    line-height: 1.5;
    padding: 2rem 2rem 5rem 2rem;
}

/* Tab Navigation */
.main-tabs {
    max-width: 900px;
    margin: 0 auto 0 auto;
    display: flex;
    gap: 5px;
}
.main-tabs .tab-link {
    padding: 12px 24px;
    background: #e2e8f0;
    color: #475569;
    text-decoration: none;
    font-weight: 600;
    font-size: 1.1rem;
    border-radius: 8px 8px 0 0;
    transition: all 0.2s;
    border: 1px solid #cbd5e1;
    border-bottom: none;
}
.main-tabs .tab-link:hover {
    background: #cbd5e1;
}
.main-tabs .tab-link.active {
    background: #FFF;
    color: #2563eb;
    border-top: 3px solid #2563eb;
    margin-bottom: -1px;
    z-index: 2;
    position: relative;
    box-shadow: 0 -4px 6px -1px rgba(0,0,0,0.05);
}

.page-container {
    max-width: 900px;
    margin: 0 auto;
    background: #FFF;
    padding: 40px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

/* Header Grid */
.header-grid {
    display: flex;
    border: 1px solid var(--border-color);
    margin-bottom: 20px;
}

.h-logo-left, .h-logo-right {
    width: 25%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
}

.h-logo-left { border-right: 1px solid var(--border-color); }
.h-logo-right { border-left: 1px solid var(--border-color); }

.h-logo-left img, .h-logo-right img {
    max-width: 100%;
    max-height: 80px;
    object-fit: contain;
}

.h-center {
    width: 50%;
    display: flex;
    flex-direction: column;
}

.h-row {
    border-bottom: 1px solid var(--border-color);
    padding: 8px 10px;
    flex: 1;
    display: flex;
    align-items: center;
}

.h-row.border-none { border-bottom: none; }

.title-row {
    font-weight: 600;
    font-size: 1.1rem;
}

.split-row {
    padding: 0;
}

.h-col {
    flex: 1;
    padding: 8px 10px;
}
.h-col:first-child {
    border-right: 1px solid var(--border-color);
}

/* Title */
.form-title {
    text-align: center;
    font-size: 1.25rem;
    font-weight: 700;
    margin: 20px 0;
}

/* Date */
.date-row {
    display: flex;
    justify-content: flex-end;
    align-items: flex-end;
    margin-bottom: 20px;
    gap: 8px;
}

/* Inputs */
.dotted-input {
    border: none;
    border-bottom: 1px dotted #000;
    background: transparent;
    font-family: inherit;
    font-size: 1rem;
    padding: 6px 5px 2px 5px;
    outline: none;
    transition: all 0.2s;
    line-height: 1.5;
}

.dotted-input:focus {
    border-bottom: 2px solid var(--primary-blue);
    background-color: #f8fafc;
}

.date-picker-wrapper {
    position: relative;
    display: inline-flex;
}
.date-picker-wrapper .date-display {
    width: 100%;
    cursor: pointer;
}
.date-picker-wrapper .hidden-date {
    position: absolute;
    left: 0;
    top: 0;
    width: 1px;
    height: 1px;
    opacity: 0;
    z-index: -1;
    border: none;
    padding: 0;
    margin: 0;
}

.flex-grow { flex-grow: 1; }
.ml-4 { margin-left: 1.5rem; }

/* Info Row */
.info-row {
    display: flex;
    align-items: flex-end;
    margin-bottom: 20px;
}

/* Category */
.category-row {
    display: flex;
    margin-bottom: 20px;
}
.cat-label {
    width: 90px;
    flex-shrink: 0;
}
.checkbox-grid {
    flex-grow: 1;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    row-gap: 12px;
    column-gap: 5px;
}

.c-box {
    display: flex;
    align-items: center;
    cursor: pointer;
    user-select: none;
}
.c-box input[type="checkbox"] {
    display: none;
}
.box {
    width: 18px;
    height: 18px;
    border: 1px solid #000;
    margin-right: 8px;
    display: inline-block;
    position: relative;
    background-color: transparent;
}

.c-box:hover .box { border-color: var(--primary-blue); }
.c-box input:checked + .box {
    border-color: var(--primary-blue);
}
.c-box input:checked + .box::after {
    content: '';
    position: absolute;
    left: 5px;
    top: 2px;
    width: 5px;
    height: 10px;
    border: solid var(--primary-blue);
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.with-input {
    grid-column: span 2;
    align-items: flex-end;
}

/* Delivery & Rental */
.delivery-row, .rental-row {
    display: flex;
    align-items: flex-end;
    margin-bottom: 20px;
}

/* Table */
.data-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 40px;
    border: 1px solid #000;
}

.data-table th, .data-table td {
    border: 1px solid #000;
    padding: 0;
    text-align: center;
}

.data-table th {
    padding: 10px;
    font-weight: 600;
}

.data-table td input {
    width: 100%;
    min-height: 35px;
    padding: 6px 5px 2px 5px;
    border: none;
    background: transparent;
    text-align: center;
    font-family: inherit;
    outline: none;
    line-height: 1.5;
}

.data-table td:nth-child(2) input {
    text-align: left;
    padding-left: 10px;
}

.data-table td input:focus {
    background-color: #EFF6FF;
}

/* Select inside table */
.unit-select {
    width: 100%;
    height: 100%;
    min-height: 35px;
    border: none;
    background: transparent;
    text-align: center;
    font-family: inherit;
    outline: none;
    cursor: pointer;
    text-align-last: center;
}

.unit-select:focus {
    background-color: #EFF6FF;
}

.delete-row-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
    color: #fca5a5;
    font-weight: bold;
    opacity: 0.7;
}
.delete-row-btn:hover {
    opacity: 1;
    color: #f87171;
}

/* Signatures */
.sig-grid {
    display: flex;
    justify-content: space-between;
    gap: 30px;
    margin-top: 50px;
}

.sig-box {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.sig-pad {
    width: 100%;
    border: 1px solid #000;
    height: 100px;
    position: relative;
    margin-bottom: 15px;
}

.sig-canvas {
    width: 100%;
    height: 100%;
    cursor: crosshair;
    touch-action: none;
}

.sig-tools {
    position: absolute;
    bottom: 5px;
    right: 5px;
    display: flex;
    gap: 5px;
}
.clear-sig-btn, .eraser-sig-btn {
    font-size: 0.8rem;
    padding: 4px 10px;
    background: white;
    border: 1px solid #cbd5e1;
    cursor: pointer;
    border-radius: 12px;
    color: #334155;
    display: flex;
    align-items: center;
    gap: 5px;
    font-family: inherit;
    font-weight: 500;
    transition: background-color 0.2s;
}
.clear-sig-btn:hover, .eraser-sig-btn:hover { background: #f8fafc; }
.eraser-sig-btn.active {
    background: #e2e8f0;
    border-color: #94a3b8;
    color: #0f172a;
    font-weight: bold;
}

.sig-title {
    font-weight: 600;
}

/* Print Styles */
@media print {
    body { background: white; padding: 0; }
    .page-container { box-shadow: none; padding: 0; max-width: 100%; }
    
    .dotted-input {
        border-bottom: 1px dotted #000 !important;
        background: transparent !important;
    }
    
    .c-box input[type="checkbox"] { display: block; appearance: auto; margin-right: 5px; width:14px; height:14px; }
    .box { display: none; }
    
    .data-table td input { background: transparent !important; }
    .clear-sig-btn, .no-print { display: none !important; }
    
    .unit-select {
        appearance: none;
        -webkit-appearance: none;
        -moz-appearance: none;
        text-align-last: center;
    }
}

/* Custom Button Styles */
.add-row-btn {
    background-color: #64748b;
    color: white;
    border: none;
    border-radius: 8px;
    padding: 8px 16px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    transition: background-color 0.2s;
}
.add-row-btn:hover { background-color: #475569; }

/* Floating Actions */
.floating-actions {
    position: fixed;
    bottom: 30px;
    right: 30px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 1000;
}
.action-btn {
    padding: 12px 20px;
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 1rem;
    font-family: inherit;
    cursor: pointer;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    transition: transform 0.2s, box-shadow 0.2s;
    font-weight: 600;
}
.action-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0,0,0,0.15);
}
.btn-primary { background-color: #2563EB; }
.btn-success { background-color: #16A34A; }
.btn-danger { background-color: #DC2626; }
