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

:root {
    --primary: #1a73e8;
    --primary-dark: #1557b0;
    --success: #34a853;
    --warning: #fbbc04;
    --danger: #ea4335;
    --gray-50: #f8f9fa;
    --gray-100: #f1f3f4;
    --gray-200: #e8eaed;
    --gray-300: #dadce0;
    --gray-500: #9aa0a6;
    --gray-700: #5f6368;
    --gray-900: #202124;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 2px 8px rgba(0,0,0,0.1);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.15);
    --radius: 12px;
    --radius-sm: 8px;
}

body {
    font-family: 'Noto Sans CJK KR', 'Noto Sans KR', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(-45deg, #1e40af, #3b82f6);
    min-height: 100vh;
    padding: 0;
    color: #333;
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: rgba(26, 115, 232, 0.2);
}

/* Header */
/* Header - Compact for fixed layout */
.header {
    background: linear-gradient(-45deg, #1e40af, #3b82f6);
    backdrop-filter: blur(10px);
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    position: relative;
    height: 60px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-img {
    width: 38px;
    height: 38px;
    border-radius: 6px;
    object-fit: contain;
}

.logo-icon {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 20px;
}

.logo-text {
    font-weight: 700;
    font-size: 20px;
    color: white;
}

.logo-subtitle {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.7);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.header-center {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
}

.header-title {
    font-weight: 600;
    font-size: 26px;
    color: white;
}

.connection-status {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 16px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.1);
}

.datetime-display {
    text-align: right;
}

.time-display {
    font-size: 18px;
    font-weight: 700;
    color: white;
    line-height: 1.2;
    font-family: 'Inter', monospace;
}

.date-display {
    font-size: 14px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.9);
    line-height: 1.2;
}

.status-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #4ade80;
    box-shadow: 0 0 8px #4ade80;
    animation: pulse 2s infinite;
    flex-shrink: 0;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Main Content */
main {
    padding: 30px;
    max-width: 1400px;
    margin: 0 auto;
}

/* Footer */
.footer {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    text-align: center;
    padding: 20px;
    color: #fff;
    font-size: 0.9rem;
}

/* No Work View */
#no-work-view {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 400px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 16px;
    padding: 60px 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
}

/* Hidden class */
.hidden {
    display: none !important;
}

/* Buttons */
.btn {
    padding: 12px 24px;
    font-size: 15px;
    border: none;
    border-radius: 10px;
    cursor: none;
    font-weight: 600;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    min-height: 44px;
    -webkit-tap-highlight-color: rgba(26, 115, 232, 0.3);
}

.btn:active {
    transform: scale(0.95);
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.btn-large {
    padding: 35px 70px;
    font-size: 32px;
    min-width: 320px;
    min-height: 140px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    border-radius: 24px;
    transition: all 0.3s ease;
}

.btn-large:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(26, 115, 232, 0.5);
}

.btn-large .icon {
    font-size: 36px;
}

.btn-primary {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 15px rgba(26, 115, 232, 0.4);
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 15px rgba(26, 115, 232, 0.4);
}

.btn-success {
    background: var(--success);
    color: white;
    min-width: 120px;
}

.btn-danger {
    background: var(--danger);
    color: white;
    box-shadow: 0 4px 15px rgba(234, 67, 53, 0.4);
}

.icon {
    font-size: 32px;
}

/* Ongoing Work View - Compact */
#ongoing-work-view {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
}

.work-header {
    margin-bottom: 20px;
}

.work-header h2 {
    font-size: 26px;
    color: var(--primary);
    margin-bottom: 15px;
}

.work-item-display {
    background: linear-gradient(-45deg, #1e40af, #3b82f6);
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 20px;
    color: white;
}

.work-item-label {
    font-size: 12px;
    opacity: 0.8;
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.work-item-name {
    font-size: 24px;
    font-weight: bold;
    margin-bottom: 5px;
}

.work-item-id {
    font-size: 14px;
    opacity: 0.9;
}

.work-info {
    display: flex;
    gap: 30px;
    flex-wrap: wrap;
    margin-bottom: 15px;
}

.info-item {
    font-size: 16px;
    color: #666;
    display: flex;
    align-items: center;
    gap: 10px;
}

.btn-inline {
    padding: 6px 12px;
    font-size: 14px;
    margin-left: 8px;
}

/* Production Metrics - Horizontal Compact Layout */
.production-metrics {
    display: flex;
    gap: 20px;
    margin: 20px 0;
}

.metric-card {
    background: linear-gradient(-45deg, #1e40af, #3b82f6);
    padding: 25px 30px;
    border-radius: 16px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    flex: 1;
}

.metric-card:active {
    transform: scale(0.95);
}

.metric-card.defect {
    background: linear-gradient(-45deg, var(--danger), #dc2626);
}

.metric-label {
    color: rgba(255, 255, 255, 0.9);
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.metric-value {
    color: white;
    font-size: 48px;
    font-weight: bold;
    margin-bottom: 8px;
}

.metric-hint {
    color: rgba(255, 255, 255, 0.7);
    font-size: 12px;
    font-style: italic;
}

/* Work Actions */
.work-actions {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 30px;
}

/* Today's Work History - Compact */
.work-history {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    max-height: 420px;
}

.work-history h3 {
    font-size: 20px;
    color: var(--primary);
    margin-bottom: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.btn-view-history {
    background: var(--primary);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-view-history:hover {
    background: var(--primary-dark);
}

.history-list {
    display: grid;
    gap: 12px;
    max-height: 320px;
    overflow-y: auto;
}

.history-item {
    background: white;
    padding: 0;
    border-radius: 12px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    border-left: 4px solid var(--primary);
    overflow: hidden;
}

.history-item:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    transform: translateY(-2px);
}

.history-row {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 18px 8px 18px;
    font-size: 14px;
}

.history-datetime {
    color: var(--primary);
    font-weight: 600;
    white-space: nowrap;
    font-size: 13px;
    background: rgba(26, 115, 232, 0.08);
    padding: 6px 12px;
    border-radius: 8px;
}

.history-item-id {
    color: #333;
    font-weight: 700;
    font-size: 15px;
    white-space: nowrap;
    background: var(--gray-100);
    padding: 6px 12px;
    border-radius: 8px;
}

.history-item-name {
    color: #555;
    flex: 1;
    font-weight: 500;
    font-size: 14px;
}

.history-workers {
    font-size: 11px;
    color: #999;
    padding: 0 18px 12px 18px;
    background: var(--gray-50);
    border-top: 1px solid var(--gray-200);
    padding-top: 8px;
    padding-bottom: 10px;
}

.history-stats {
    display: flex;
    gap: 10px;
    font-size: 15px;
    font-weight: 700;
    white-space: nowrap;
}

.stat-good {
    color: white;
    background: var(--success);
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 13px;
}

.stat-defect {
    color: white;
    background: var(--danger);
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 13px;
}

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

.modal-content {
    background: white;
    border-radius: 16px;
    padding: 20px;
    max-width: 600px;
    width: 100%;
    max-height: 85vh;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
}

.modal-content.modal-large {
    max-width: 850px;
    max-height: 85vh;
}

.modal-content h2 {
    font-size: 20px;
    color: var(--primary);
    margin-bottom: 15px;
    text-align: center;
}

.modal-content h3 {
    font-size: 16px;
    color: #333;
    margin-bottom: 12px;
    font-weight: 600;
}

/* Step Indicator */
.step-indicator {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 15px;
    gap: 15px;
}

.step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.step.active .step-number {
    background: var(--primary);
    color: white;
    transform: scale(1.05);
}

.step.completed .step-number {
    background: var(--success);
    color: white;
}

.step-number {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #e0e0e0;
    color: #999;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: bold;
    transition: all 0.3s ease;
}

.step-label {
    font-size: 12px;
    font-weight: 600;
    color: #666;
}

.step-arrow {
    font-size: 24px;
    color: #ccc;
    margin: 0 8px;
}

/* Item List */
.item-list {
    display: grid;
    gap: 10px;
    max-height: none;
    overflow: visible;
}

.item-card {
    padding: 15px;
    background: #f5f5f5;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

.item-card:hover {
    background: #e8e8e8;
}

.item-card:active {
    transform: scale(0.98);
}

.item-card.selected {
    background: var(--primary);
    color: white;
    border-color: var(--primary-dark);
}

.item-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.item-id {
    font-size: 13px;
    font-weight: 600;
    opacity: 0.8;
}

.item-model {
    font-size: 11px;
    background: rgba(0, 0, 0, 0.1);
    padding: 3px 10px;
    border-radius: 16px;
}

.item-name {
    font-size: 16px;
    font-weight: 600;
}

.item-card.selected .item-id,
.item-card.selected .item-name {
    color: white;
}

/* Selected Item Info */
.selected-item-info {
    background: linear-gradient(-45deg, #1e40af, #3b82f6);
    color: white;
    padding: 12px 15px;
    border-radius: 10px;
    margin-bottom: 12px;
}

.selected-item-info .info-label {
    font-size: 11px;
    opacity: 0.8;
    margin-bottom: 4px;
}

.selected-item-info .info-value {
    font-size: 15px;
    font-weight: 600;
}

/* Step Content */
.step-content {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

/* Worker Checklist */
.worker-checklist {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-bottom: 15px;
    max-height: none;
    overflow: visible;
}

.worker-item {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    background: #f5f5f5;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.worker-item:active {
    transform: scale(0.98);
}

.worker-item.selected {
    background: var(--primary);
    color: white;
}

.worker-item input[type="checkbox"] {
    width: 20px;
    height: 20px;
    margin-right: 10px;
    cursor: pointer;
    flex-shrink: 0;
}

.worker-item label {
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    flex: 1;
}

/* Keypad */
.input-display {
    margin-bottom: 20px;
}

.input-large {
    width: 100%;
    padding: 25px;
    font-size: 42px;
    text-align: center;
    border: 3px solid var(--primary);
    border-radius: 12px;
    background: #f5f5f5;
    font-weight: bold;
    color: #333;
}

.keypad {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    margin-bottom: 20px;
}

.keypad-btn {
    padding: 25px;
    font-size: 28px;
    font-weight: 600;
    border: none;
    border-radius: 12px;
    background: var(--primary);
    color: white;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 10px rgba(26, 115, 232, 0.3);
}

.keypad-btn:active {
    transform: scale(0.95);
    box-shadow: 0 2px 5px rgba(26, 115, 232, 0.3);
}

.keypad-zero {
    grid-column: span 2;
}

.keypad-enter {
    grid-row: span 2;
    background: var(--success);
    box-shadow: 0 4px 10px rgba(52, 168, 83, 0.3);
}

.keypad-clear {
    background: var(--danger);
    box-shadow: 0 4px 10px rgba(234, 67, 53, 0.3);
}

.keypad-backspace {
    background: var(--warning);
    box-shadow: 0 4px 10px rgba(251, 188, 4, 0.3);
}

.keypad-add {
    background: var(--primary);
    box-shadow: 0 4px 10px rgba(26, 115, 232, 0.3);
}

/* Modal Actions */
.modal-actions {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #e0e0e0;
    flex-shrink: 0;
}

/* Reminder Modal */
.reminder-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    animation: reminder-flash 0.6s infinite;
}

.reminder-overlay.hidden {
    display: none;
}

@keyframes reminder-flash {
    0%, 100% { background-color: rgba(234, 67, 53, 0.88); }
    50% { background-color: rgba(26, 87, 232, 0.88); }
}

.reminder-content {
    text-align: center;
    color: #fff;
}

.reminder-icon {
    font-size: clamp(60px, 12vw, 120px);
    line-height: 1;
    margin-bottom: 20px;
    animation: reminder-bounce 0.6s infinite alternate;
}

@keyframes reminder-bounce {
    from { transform: scale(1) rotate(-4deg); }
    to { transform: scale(1.15) rotate(4deg); }
}

.reminder-icon.hidden {
    display: none;
}

.reminder-message {
    font-size: clamp(40px, 9vw, 84px);
    font-weight: 800;
    margin-bottom: 50px;
    text-shadow: 0 4px 16px rgba(0, 0, 0, 0.6);
    line-height: 1.3;
    max-width: 1100px;
}

.btn-reminder-close {
    font-size: clamp(26px, 4.5vw, 44px);
    font-weight: 700;
    padding: 24px 72px;
    border-radius: 60px;
    border: none;
    background: #fff;
    color: #202124;
    cursor: pointer;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
    animation: reminder-pulse-btn 1s infinite;
}

@keyframes reminder-pulse-btn {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.06); }
}

/* Responsive */
@media (max-width: 768px) {
    .production-metrics {
        grid-template-columns: 1fr;
    }
    
    .history-item {
        grid-template-columns: 1fr;
    }
    
    .modal-content {
        padding: 30px 20px;
    }
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 10px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-dark);
}

/* ===================================
   WORK HISTORY PAGE STYLES
   =================================== */

.history-page {
    padding: 20px;
    max-width: 1240px;
    margin: 0 auto;
}

.page-header {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 20px;
}

.page-header h1 {
    font-size: 28px;
    color: white;
    margin: 0;
}

.btn-back {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 10px;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-back:hover {
    background: rgba(255, 255, 255, 0.3);
}

.filter-bar {
    background: rgba(255, 255, 255, 0.95);
    padding: 15px;
    border-radius: 12px;
    margin-bottom: 20px;
    display: flex;
    gap: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.filter-btn {
    background: var(--gray-200);
    color: var(--gray-700);
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.filter-btn:hover {
    background: var(--gray-300);
}

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

.history-table-container {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    max-height: 800px;
    overflow-y: auto;
}

.history-table {
    width: 100%;
    border-collapse: collapse;
}

.history-table thead {
    background: var(--primary);
    color: white;
    position: sticky;
    top: 0;
    z-index: 10;
}

.history-table th {
    padding: 12px 15px;
    text-align: left;
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.history-table tbody tr {
    border-bottom: 1px solid var(--gray-200);
    transition: all 0.2s ease;
}

.history-table tbody tr:hover {
    background: var(--gray-100);
}

.history-table td {
    padding: 12px 15px;
    font-size: 14px;
}

.history-table .qty-cell {
    color: var(--success);
    font-weight: 600;
}

.history-table .defect-cell {
    color: var(--danger);
    font-weight: 600;
}

.history-table .duration-cell {
    color: var(--gray-700);
    font-style: italic;
}

/* Part Mode floating button */
.btn-part-mode {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 500;
    background: var(--primary);
    color: white;
    border: none;
    padding: 14px 22px;
    border-radius: 30px;
    font-size: 15px;
    font-weight: 600;
    box-shadow: var(--shadow-lg);
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-part-mode:active {
    transform: scale(0.95);
}

/* Part Mode split card (process.html) */
.metric-card.part1,
.metric-card.part2 {
    background: linear-gradient(-45deg, var(--success), #16a34a);
}

#process-view,
#item-picker-view {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
}

.picker-title {
    text-align: center;
    color: var(--gray-700);
    margin-bottom: 16px;
}

.metric-sub {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.25);
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-size: 14px;
}

.metric-sub-label {
    color: rgba(255, 255, 255, 0.75);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: 12px;
}

.metric-sub-value {
    color: white;
    font-weight: 700;
    font-size: 20px;
    cursor: default;
}

.metric-sub-value.negative {
    color: #ffb3b3;
}

.part-metrics.readonly-mode .metric-card {
    cursor: default;
}

.part-metrics.readonly-mode .metric-value {
    opacity: 0.5;
}

.part-metrics.readonly-mode .metric-hint {
    display: none;
}

.process-warning {
    background: var(--warning);
    color: #664d03;
    padding: 10px 16px;
    border-radius: 10px;
    margin-bottom: 16px;
    font-size: 14px;
    text-align: center;
}

