* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    width: 100%;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f5f5f5;
    color: #333;
    margin: 0;
    box-sizing: border-box;
}

.container {
    min-width: 1200px !important;
    width: 100%;
    margin: 0 auto;
    padding: 8px;
}

/* Loading Screen */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

/* Loading Screen Hidden State */
.loading-screen[style*="display: none"] {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}


/* Header */
.header {
    background: white;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 10px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    text-align: center;
}

.header h1 {
    font-size: 24px;
    margin-bottom: 8px;
    color: #2c3e50;
}

.subtitle {
    font-size: 14px;
    color: #666;
    margin-bottom: 20px;
}

.location-input {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
}

.location-input-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.location-input label {
    font-size: 16px;
    font-weight: 500;
    white-space: nowrap;
}

.location-input input {
    width: 400px;
}

.action-buttons {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.save-btn, .load-btn, .reset-btn, .data-viewer-btn {
    padding: 8px 16px;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: background-color 0.3s;
    white-space: nowrap;
    flex-shrink: 0;
}

.save-btn {
    background: #28a745;
}

.save-btn:hover {
    background: #218838;
}

.load-btn {
    background: #007bff;
}

.load-btn:hover {
    background: #0056b3;
}

.reset-btn {
    background: #dc3545;
}

.reset-btn:hover {
    background: #c82333;
}

.data-viewer-btn {
    background: #6f42c1;
}

.data-viewer-btn:hover {
    background: #5a32a3;
}

.save-btn i, .load-btn i, .reset-btn i, .data-viewer-btn i {
    font-size: 12px;
}

.location-input input {
    flex: 1;
    max-width: 400px;
    padding: 8px 12px;
    border: 1px solid #000;
    border-radius: 4px;
    font-size: 14px;
}

/* Table Section */
.table-section {
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin-bottom: 20px;
}

.table-container {
    display: flex;
    flex-direction: column;
}

/* Table Header */
.table-header {
    display: flex;
    background: #f8f9fa;
    border-bottom: 2px solid #333;
    height: 48px;
}

.header-cell {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    border-right: 1px solid #333;
    font-weight: bold;
    font-size: 14px;
}

.header-cell:last-child {
    border-right: none;
}

/* Table Body */
.table-body {
    min-height: 480px; /* 48px * 10 rows */
}

.group-row {
    display: flex;
    border-bottom: 1px solid #333;
}

.data-rows {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.data-row {
    display: flex;
    height: 48px;
    border-bottom: 1px solid #333;
}

.data-row:last-child {
    border-bottom: none;
}

.cell {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    border-right: 1px solid #333;
    font-size: 14px;
}

.cell:last-child {
    border-right: none;
}

.cell input, .cell select {
    width: 100%;
    border: 1px solid #000;
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 14px;
}

.cell input:focus, .cell select:focus {
    outline: none;
    border-color: #007bff;
}

/* Usage Selection Button */
.usage-btn {
    width: 100%;
    height: 100%;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s;
}

.usage-btn.empty {
    background: #ffc107;
    color: white;
}

.usage-btn.selected {
    background: #c8e6c9;
    color: black;
}

.usage-btn:hover {
    opacity: 0.8;
}

/* Input Fields */
.input-fields {
    display: flex;
    align-items: center;
    justify-content: space-evenly;
    gap: 4px;
    padding: 4px;
}

.input-field {
    display: flex;
    align-items: center;
    gap: 4px;
}

.input-field label {
    font-size: 14px;
    white-space: nowrap;
}

.input-field input {
    width: 60px;
    padding: 2px 4px;
    font-size: 14px;
    border: 1px solid #000;
    border-radius: 4px;
}

/* Action Buttons */
.action-buttons {
    display: flex;
    align-items: center;
    justify-content: space-around;
    gap: 4px;
}

.dropdown-btn {
    position: relative;
}

.dropdown-menu {
    position: fixed;
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    z-index: 1000;
    min-width: 120px;
    display: none;
}

.dropdown-menu.show {
    display: block;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 12px;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
}

.dropdown-item:hover {
    background: #f8f9fa;
}

.action-icon {
    cursor: pointer;
    padding: 4px;
    border-radius: 2px;
    color: #666;
    font-size: 14px;
}

.action-icon:hover {
    color: #333;
    background: #f0f0f0;
}

.drag-handle {
    cursor: grab;
}

.drag-handle:active {
    cursor: grabbing;
}

/* Table Footer */
.table-footer {
    display: flex;
    height: 96px; /* 48px * 2 */
}

.footer-cell {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    border-right: 1px solid #333;
    font-weight: bold;
    font-size: 14px;
}

.footer-cell:last-child {
    border-right: none;
}

.footer-content {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 0;
    border-right: 1px solid #333;
}

.footer-row {
    display: flex;
    align-items: center;
    height: 48px;
    border-bottom: 1px solid #333;
    padding: 0;
}

.footer-row:last-child {
    border-bottom: none;
}

.footer-row span {
    font-size: 14px;
    font-weight: 500;
    border-right: 1px solid #333;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    box-sizing: border-box;
    height: 100%;
}

.footer-row span:last-child {
    border-right: none;
}

.footer-row input {
    border: 1px solid #000;
    border-radius: 4px;
    font-size: 14px;
}

.print-btn {
    background: #007bff;
    color: white;
    border: none;
    border-radius: 8px;
    padding: 12px 20px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    width: 100%;
    height: 80%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: background 0.2s;
}

.print-btn:hover {
    background: #0056b3;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
}

.modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 0;
    border-radius: 8px;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow: hidden;
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid #eee;
    background: #f8f9fa;
}

.modal-header h2 {
    margin: 0;
    font-size: 20px;
    color: #333;
}

.modal-body {
    padding: 20px;
    max-height: 60vh;
    overflow-y: auto;
}

.modal-footer {
    padding: 20px;
    border-top: 1px solid #eee;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* Search Container */
.search-container {
    position: relative;
    margin-bottom: 20px;
}

.search-container input {
    width: 100%;
    padding: 12px 40px 12px 12px;
    border: 1px solid #000;
    border-radius: 4px;
    font-size: 14px;
}

.search-container i {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #666;
}

.search-results {
    border: 1px solid #ddd;
    border-radius: 4px;
    max-height: 300px;
    overflow-y: auto;
}

.search-result-item {
    padding: 12px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    font-size: 14px;
}

.search-result-item:hover {
    background: #f8f9fa;
}

.search-result-item:last-child {
    border-bottom: none;
}

.no-selection {
    padding: 40px;
    text-align: center;
    color: #666;
    font-style: italic;
}

.selected-usage {
    margin-top: 20px;
}

.selected-usage h3 {
    margin-bottom: 10px;
    color: #333;
}

.selected-usage label {
    display: block;
    margin: 15px 0 5px;
    font-weight: bold;
    color: #555;
}

.selected-usage input {
    width: 100%;
    padding: 12px;
    border: 1px solid #000;
    border-radius: 4px;
    font-size: 14px;
}

/* Buttons */
.btn-cancel, .btn-confirm, .btn-danger {
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
}

.btn-cancel {
    background: #6c757d;
    color: white;
}

.btn-confirm {
    background: #007bff;
    color: white;
}

.btn-danger {
    background: #dc3545;
    color: white;
}

.btn-cancel:hover {
    background: #5a6268;
}

.btn-confirm:hover {
    background: #0056b3;
}

.btn-danger:hover {
    background: #c82333;
}

.btn-confirm:disabled {
    background: #ccc;
    cursor: not-allowed;
}


/* Notification */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 12px 20px;
    background: #28a745;
    color: white;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    opacity: 0;
    transform: translateX(100%);
    transition: all 0.3s;
    z-index: 1001;
}

.notification.show {
    opacity: 1;
    transform: translateX(0);
}

.notification.error {
    background: #dc3545;
}

/* Custom Tooltip */
.custom-tooltip {
    position: fixed;
    background: #333;
    color: white;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    z-index: 1000;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
    max-width: 300px;
    word-wrap: break-word;
}

.custom-tooltip.show {
    opacity: 1;
}

.custom-tooltip::before {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: #333;
}

/* Print Layout Styles */
.print-layout {
    background: white;
    padding: 40px;
    font-family: 'Malgun Gothic', sans-serif;
    color: black;
    line-height: 1.4;
}

.print-header {
    text-align: center;
    margin-bottom: 30px;
    border-bottom: 2px solid #333;
    padding-bottom: 20px;
}

.print-header h1 {
    font-size: 24px;
    font-weight: bold;
    margin: 0 0 10px 0;
    color: #333;
}

.print-subtitle {
    font-size: 14px;
    color: #666;
    margin: 0 0 15px 0;
}

.print-location {
    text-align: left;
    font-size: 16px;
    margin-top: 15px;
}

.print-table {
    margin: 20px 0;
}

.print-data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.print-data-table th,
.print-data-table td {
    border: 1px solid #333;
    padding: 8px;
    text-align: center;
    vertical-align: middle;
}

.print-data-table th {
    background-color: #f8f9fa;
    font-weight: bold;
}

.print-data-table .print-total-row {
    background-color: #e9ecef;
    font-weight: bold;
}

.print-summary {
    margin: 20px 0;
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
}

.print-summary-item {
    font-size: 14px;
    margin: 5px 0;
    flex: 1;
    min-width: 200px;
}

.print-footer {
    margin-top: 30px;
    text-align: right;
    font-size: 12px;
    color: #666;
}

/* Print Media Queries */
@media print {
    .print-layout {
        padding: 20px;
    }
    
    .print-data-table {
        font-size: 10px;
    }
    
    .print-data-table th,
    .print-data-table td {
        padding: 4px;
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .table-container {
        font-size: 12px;
    }
    
    .header-cell, .cell {
        padding: 2px;
        font-size: 11px;
    }
    
    .modal-content {
        width: 95%;
        margin: 2% auto;
        max-height: 95vh;
    }
    
    .input-field input {
        width: 50px;
        font-size: 10px;
    }
}

/* Sortable styles */
.sortable-ghost {
    opacity: 0.4;
    background: #f0f8ff;
}

.sortable-chosen {
    transform: scale(1.02);
    background-color: #f0f8ff;
}

.sortable-drag {
    transform: scale(1.02);
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

/* Option dropdown styles */
.option-dropdown {
    position: relative;
    min-width: 80px;
}

.option-dropdown select {
    width: 100%;
    padding: 2px 4px;
    font-size: 11px;
    border: 1px solid #ddd;
    border-radius: 2px;
    background: white;
}

.option-text {
    font-size: 12px;
    color: #333;
}

/* Empty state */
.empty-state {
    text-align: center;
    color: #666;
    font-style: italic;
    padding: 20px;
}