/* ─── Reset & Base ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-tap-highlight-color: transparent; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans JP", sans-serif;
    background: #f0f2f5;
    color: #1a1a2e;
    min-height: 100vh;
}

/* ─── Navbar ─── */
.navbar {
    background: #2c3e50;
    color: white;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
}
.nav-brand {
    font-size: 1.1rem;
    font-weight: 700;
    color: white;
    text-decoration: none;
}
.nav-links { display: flex; gap: 4px; }
.nav-link {
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    transition: all 0.2s;
}
.nav-link:hover, .nav-link.active {
    color: white;
    background: rgba(255,255,255,0.15);
}
.nav-logout { color: rgba(255,255,255,0.5); }

/* ─── Container ─── */
.container {
    max-width: 960px;
    margin: 0 auto;
    padding: 20px 16px;
}

/* ─── Page Header ─── */
.page-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 8px;
}
.page-header h1 { font-size: 1.5rem; }
.current-time {
    font-size: 1.2rem;
    font-weight: 600;
    color: #2c3e50;
    font-variant-numeric: tabular-nums;
}
.header-stats { display: flex; gap: 16px; }
.stat { font-size: 0.9rem; color: #555; }
.stat strong { color: #2c3e50; }

/* ─── Worker Grid (打刻画面) ─── */
.worker-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}
.worker-card {
    background: white;
    border-radius: 12px;
    padding: 24px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    border: 2px solid transparent;
    transition: all 0.3s;
}
.worker-card.checked-in {
    border-color: #27ae60;
    background: #f0fff4;
}
.worker-name {
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 8px;
}
.worker-status {
    font-size: 0.85rem;
    margin-bottom: 16px;
}
.status-active { color: #27ae60; font-weight: 600; }
.status-idle { color: #95a5a6; }

/* ─── Buttons ─── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 16px;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}
.btn-large {
    width: 100%;
    padding: 16px;
    font-size: 1.2rem;
    border-radius: 12px;
}
.btn-full { width: 100%; }
.btn-sm { padding: 4px 10px; font-size: 0.8rem; }

.btn-primary { background: #3498db; color: white; }
.btn-primary:hover { background: #2980b9; }

.btn-checkin { background: #27ae60; color: white; }
.btn-checkin:hover { background: #219a52; }

.btn-checkout { background: #e74c3c; color: white; }
.btn-checkout:hover { background: #c0392b; }

.btn-secondary { background: #ecf0f1; color: #2c3e50; }
.btn-secondary:hover { background: #dfe6e9; }

.btn-ghost { background: transparent; color: #7f8c8d; }
.btn-ghost:hover { background: #f5f5f5; }

.btn-danger { background: #e74c3c; color: white; }
.btn-danger:hover { background: #c0392b; }

/* ─── Forms ─── */
.input-full, .input-field, .input-filter {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 0.95rem;
    margin-bottom: 10px;
    transition: border-color 0.2s;
}
.input-field, .input-filter { width: auto; min-width: 140px; }
.input-full:focus, .input-field:focus, .input-filter:focus {
    outline: none;
    border-color: #3498db;
}

.filter-bar { margin-bottom: 20px; }
.filter-form {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

.add-form {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: flex-end;
}

/* ─── Card ─── */
.card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

/* ─── Invoice Panel ─── */
.invoice-panel {
    background: white;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    border-left: 4px solid #3498db;
}
.invoice-panel h3 { margin-bottom: 12px; font-size: 1rem; }
.invoice-form {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

/* ─── Table ─── */
.table-wrapper { overflow-x: auto; }
.data-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.data-table th {
    background: #2c3e50;
    color: white;
    padding: 10px 12px;
    font-size: 0.8rem;
    font-weight: 600;
    text-align: left;
    white-space: nowrap;
}
.data-table td {
    padding: 10px 12px;
    border-bottom: 1px solid #f0f0f0;
    font-size: 0.85rem;
}
.data-table tr:hover { background: #fafbfc; }
.empty-row { text-align: center; color: #95a5a6; padding: 32px !important; }

/* ─── Badge ─── */
.badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
}
.badge-active { background: #d4edda; color: #155724; }
.badge-inactive { background: #f8d7da; color: #721c24; }

/* ─── Modal ─── */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
}
.modal-content {
    background: white;
    border-radius: 16px;
    padding: 28px;
    width: 90%;
    max-width: 400px;
}
.modal-content h3 { margin-bottom: 16px; }
.modal-content label {
    display: block;
    font-size: 0.85rem;
    color: #555;
    margin-bottom: 4px;
}
.modal-actions {
    display: flex;
    gap: 8px;
    margin-top: 16px;
    justify-content: flex-end;
}

/* ─── Toast ─── */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    padding: 12px 24px;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 600;
    z-index: 300;
    transition: opacity 0.3s;
}
.toast.success { background: #27ae60; color: white; }
.toast.error { background: #e74c3c; color: white; }
.toast.hidden { opacity: 0; pointer-events: none; }

/* ─── Annual Income Alert ─── */
.annual-bar {
    font-size: 0.8rem;
    padding: 6px 12px;
    border-radius: 6px;
    margin-bottom: 8px;
}
.annual-ok { background: #e8f5e9; color: #2e7d32; }
.annual-warn { background: #fff3e0; color: #e65100; font-weight: 600; }
.annual-danger { background: #fce4ec; color: #c62828; font-weight: 700; }

/* ─── GPS Status ─── */
.gps-status {
    text-align: center;
    padding: 6px;
    font-size: 0.85rem;
    border-radius: 8px;
    margin-bottom: 12px;
    transition: all 0.3s;
}
.gps-status:empty { display: none; }
.gps-status.loading { background: #fff3cd; color: #856404; }
.gps-status.ok { background: #d4edda; color: #155724; }
.gps-status.error { background: #f8d7da; color: #721c24; }

/* ─── Utility ─── */
.hidden { display: none !important; }

/* ─── Login ─── */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #2c3e50 0%, #3498db 100%);
}
.login-card {
    background: white;
    border-radius: 16px;
    padding: 40px;
    width: 90%;
    max-width: 380px;
    text-align: center;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}
.login-card h1 { font-size: 1.5rem; margin-bottom: 4px; }
.login-subtitle { color: #95a5a6; margin-bottom: 24px; font-size: 0.9rem; }

/* ─── Alert ─── */
.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; font-size: 0.85rem; }
.alert-error { background: #fde8e8; color: #c0392b; }

/* ─── Empty State ─── */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #95a5a6;
}
.empty-state p { margin-bottom: 16px; font-size: 1.1rem; }

/* ─── Responsive ─── */
@media (max-width: 640px) {
    .navbar { flex-direction: column; gap: 8px; }
    .nav-links { flex-wrap: wrap; justify-content: center; }
    .page-header { flex-direction: column; }
    .header-stats { flex-direction: column; gap: 4px; }
    .filter-form { flex-direction: column; }
    .input-filter { width: 100%; }
    .invoice-form { flex-direction: column; }
    .invoice-form .input-filter { width: 100%; }
    .worker-grid { grid-template-columns: 1fr; }
    .add-form { flex-direction: column; }
    .add-form .input-field { width: 100%; }
}
