:root {
    --primary-color: #4f46e5;
    --border-color: #e5e7eb;
    --bg-light: #f9fafb;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --price-update-color: #22c55e;
}

body {
    background-color: var(--bg-light);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.container {
    max-width: 95%;
    margin: 2rem auto;
}

.upload-card {
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
    padding: 2rem;
    margin-bottom: 2rem;
    border: 1px solid var(--border-color);
}

.date-info {
    background: #f0f9ff;
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
    text-align: center;
}

.existing-data-notice {
    background: #fef3c7;
    border: 1px solid #fcd34d;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
    color: #92400e;
}

.websocket-status {
    padding: 0.5rem 1rem;
    border-radius: 6px;
    margin-bottom: 1rem;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.ws-connected {
    background: #f0fdf4;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.ws-disconnected {
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #fecaca;
}

.ws-connecting {
    background: #fff7ed;
    color: #ea580c;
    border: 1px solid #fed7aa;
}

.pulse {
    animation: pulse 2s infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

.file-input {
    width: 100%;
    padding: 0.75rem;
    border: 2px dashed var(--border-color);
    border-radius: 8px;
    background: #fafafa;
    transition: all 0.3s ease;
}

.file-input:hover {
    border-color: var(--primary-color);
    background: #f0f9ff;
}

.btn-upload {
    background-color: var(--primary-color);
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    color: white;
    font-weight: 500;
    transition: all 0.2s ease;
}

.btn-upload:hover {
    background-color: #3730a3;
    color: white;
}

.btn-clear-today {
    background-color: var(--danger-color);
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    color: white;
    font-size: 0.9rem;
    margin-left: 0.5rem;
}

.btn-clear-today:hover {
    background-color: #dc2626;
    color: white;
}

.table-viewer {
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
    border: 1px solid var(--border-color);
    display: none;
}

.table-viewer.show {
    display: block;
}

.table-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    background: #f8fafc;
    border-radius: 12px 12px 0 0;
}

.table-content {
    height: 70vh;
    overflow: auto;
    border-radius: 0 0 12px 12px;
}

.data-table {
    width: 100%;
    margin: 0;
    border-collapse: separate;
    border-spacing: 0;
}

.data-table thead th {
    background: #f1f5f9;
    color: #374151;
    font-weight: 600;
    padding: 1rem;
    text-align: left;
    border-bottom: 2px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 10;
    white-space: nowrap;
}

.data-table tbody td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #f3f4f6;
    white-space: nowrap;
    color: #374151;
    vertical-align: middle;
    transition: all 0.3s ease;
}

.data-table tbody tr:hover {
    background-color: #f9fafb;
}

.data-table tbody td:first-child {
    border-left: 3px solid transparent;
}

.data-table tbody tr:hover td:first-child {
    border-left-color: var(--primary-color);
}

/* Sum row styling */
.sum-row {
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
    border-top: 3px solid var(--primary-color);
    font-weight: 600;
    color: #1e40af;
    position: sticky;
    bottom: 0;
    z-index: 5;
}

.sum-row td {
    border-bottom: none !important;
    padding: 1rem !important;
    background: inherit;
}

.sum-row td:first-child {
    border-left: 3px solid var(--primary-color) !important;
}

.sum-label {
    font-weight: 700;
    color: #1e40af;
    font-size: 1.05em;
}

.sum-value {
    font-family: 'Courier New', monospace;
    color: #059669;
    font-weight: 700;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* Price update animation */
.price-updated {
    background-color: #22c55e !important;
    color: white !important;
    font-weight: bold !important;
    animation: priceFlash 2s ease-out forwards;
}

@keyframes priceFlash {
    0% {
        background-color: #22c55e;
        transform: scale(1.05);
        box-shadow: 0 0 20px rgba(34, 197, 94, 0.5);
    }

    50% {
        background-color: #16a34a;
        transform: scale(1.02);
    }

    100% {
        background-color: #dcfce7;
        color: #374151;
        font-weight: normal;
        transform: scale(1);
        box-shadow: none;
    }
}

.actions-column {
    width: 120px;
    text-align: center;
}

.action-btn {
    padding: 0.25rem 0.5rem;
    margin: 0 0.125rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.2s ease;
}

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

.btn-edit:hover {
    background-color: #d97706;
}

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

.btn-delete:hover {
    background-color: #dc2626;
}

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

.btn-save:hover {
    background-color: #059669;
}

.btn-cancel {
    background-color: #6b7280;
    color: white;
}

.btn-cancel:hover {
    background-color: #4b5563;
}

.edit-form {
    background: #fff7ed;
    border: 2px solid var(--warning-color);
    border-radius: 8px;
    margin: 1rem;
    padding: 1rem;
    display: none;
}

.edit-form.show {
    display: block;
}

.edit-form-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.edit-form-body {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group label {
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: #374151;
}

.form-group input {
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 0.9rem;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.edit-form-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.row-editing {
    background-color: #fff7ed !important;
    border-left: 4px solid var(--warning-color) !important;
}

.loading {
    text-align: center;
    padding: 2rem;
    color: #6b7280;
}

.spinner {
    width: 24px;
    height: 24px;
    border: 2px solid var(--border-color);
    border-top: 2px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    display: inline-block;
    margin-right: 0.5rem;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.error-message {
    color: #dc2626;
    background: #fef2f2;
    padding: 1rem;
    border-radius: 6px;
    border-left: 4px solid #dc2626;
    margin-top: 1rem;
}

.success-message {
    color: var(--success-color);
    background: #f0fdf4;
    padding: 1rem;
    border-radius: 6px;
    border-left: 4px solid var(--success-color);
    margin-top: 1rem;
}

.backend-status {
    padding: 0.5rem 1rem;
    border-radius: 6px;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.backend-connected {
    background: #f0fdf4;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.backend-disconnected {
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #fecaca;
}

/* Log Viewer Styling */
.log-viewer {
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
    border: 1px solid var(--border-color);
    margin-top: 2rem;
    padding: 1.5rem;
}

.log-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    height: 70vh;
}

.log-box {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    background: #fafafa;
}

.log-header {
    background: #f8fafc;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
    font-weight: 600;
}

.btn-clear-log {
    background: #ef4444;
    color: white;
    border: none;
    padding: 0.25rem 0.75rem;
    border-radius: 4px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
}


.btn-squareoff {
    /* Base styles */
    background: linear-gradient(135deg, #8BE9FD 0%, #6DD5E9 100%);
    color: #1a1a1a;
    font-weight: bold;
    font-size: 14px;
    
    /* Shape & spacing - normal button size */
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    
    /* Visual polish */
    box-shadow: 0 2px 8px rgba(139, 233, 253, 0.25);
    cursor: pointer;
    
    /* Smooth transitions */
    transition: all 0.2s ease;
    
    /* Text rendering */
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* Hover effect */
.btn-squareoff:hover {
    background: linear-gradient(135deg, #6DD5E9 0%, #5BC4D8 100%);
    box-shadow: 0 4px 12px rgba(139, 233, 253, 0.35);
    transform: translateY(-1px);
}

/* Active/Click effect */
.btn-squareoff:active {
    transform: translateY(0px);
    box-shadow: 0 1px 4px rgba(139, 233, 253, 0.3);
}

/* Focus effect (for accessibility) */
.btn-squareoff:focus {
    outline: none;
    box-shadow: 0 2px 8px rgba(139, 233, 253, 0.25), 
                0 0 0 3px rgba(139, 233, 253, 0.3);
}

/* Disabled state */
.btn-squareoff:disabled {
    background: linear-gradient(135deg, #cccccc 0%, #999999 100%);
    cursor: not-allowed;
    box-shadow: none;
    opacity: 0.6;
}

.btn-squareoff:disabled:hover {
    transform: none;
}

/* Optional: Add icon support */
.btn-squareoff i,
.btn-squareoff svg {
    margin-right: 6px;
    vertical-align: middle;
}

/* Optional: Loading state */
.btn-squareoff.loading {
    position: relative;
    color: transparent;
    pointer-events: none;
}

.btn-squareoff.loading::after {
    content: "";
    position: absolute;
    width: 14px;
    height: 14px;
    top: 50%;
    left: 50%;
    margin-left: -7px;
    margin-top: -7px;
    border: 2px solid #1a1a1a;
    border-radius: 50%;
    border-top-color: transparent;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}
.btn-clear-log:hover {
    background: #dc2626;
}

.log-textarea {
    flex: 1;
    width: 100%;
    padding: 1rem;
    border: none;
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
    resize: none;
    background: #fafafa;
    color: #374151;
    line-height: 1.5;
}

.log-textarea:focus {
    outline: none;
}

.log-textarea::-webkit-scrollbar {
    width: 6px;
}

.log-textarea::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.log-textarea::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.log-textarea::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Custom scrollbars */
.table-content::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.table-content::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.table-content::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

.table-content::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

@media (max-width: 768px) {
    .container {
        margin: 1rem auto;
    }

    .upload-card {
        padding: 1rem;
    }

    .edit-form-body {
        grid-template-columns: 1fr;
    }

    .actions-column {
        width: 100px;
    }

    .action-btn {
        padding: 0.2rem 0.4rem;
        font-size: 0.7rem;
    }
    
    .log-container {
        grid-template-columns: 1fr;
        height: auto;
    }
    
    .log-box {
        height: 250px;
    }
}