/* ── Auth Overlay ── */
.auth-overlay {
    position: fixed; inset: 0; z-index: 9999;
    background: linear-gradient(135deg, #0f2d5c, #1d4ed8);
    display: flex; align-items: center; justify-content: center;
}
.auth-overlay.hidden { display: none; }

.auth-card {
    background: white; border-radius: 16px; padding: 40px 32px;
    max-width: 420px; width: 90%; text-align: center;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.auth-card .logo { font-size: 40px; margin-bottom: 8px; }
.auth-card h2 { font-size: 20px; color: #1e3a8a; margin-bottom: 8px; }
.auth-card p  { font-size: 14px; color: #64748b; margin-bottom: 24px; line-height: 1.5; }

.google-btn {
    display: flex; align-items: center; justify-content: center; gap: 10px;
    width: 100%; padding: 14px 20px;
    background: white; border: 1.5px solid #e2e8f0; border-radius: 10px;
    font-size: 15px; font-weight: 700; color: #1e3a8a; cursor: pointer;
    transition: background 0.15s, box-shadow 0.15s;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.google-btn:hover { background: #f8fafc; box-shadow: 0 2px 8px rgba(0,0,0,0.1); }
.google-btn:active { transform: scale(0.98); }
.google-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.google-icon { width: 20px; height: 20px; }

.auth-error {
    display: none; background: #fef2f2; border: 1.5px solid #fca5a5;
    border-radius: 8px; padding: 10px 12px; color: #dc2626;
    font-size: 13px; font-weight: 600; margin-top: 16px; text-align: center;
}
.auth-error.visible { display: block; }

/* ── Logout row ── */
.logout-row {
    display: flex; justify-content: flex-end; padding: 0 0 4px;
}
.logout-btn {
    background: none; border: 1px solid rgba(255,255,255,0.25);
    border-radius: 6px; color: rgba(255,255,255,0.75); font-size: 11px;
    font-weight: 600; padding: 4px 12px; cursor: pointer;
}
.logout-btn:hover { background: rgba(255,255,255,0.1); color: white; }

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #eef2f7; color: #1a202c; min-height: 100vh;
}

/* ── Header ── */
.header {
    background: linear-gradient(135deg, #0f2d5c, #1d4ed8);
    color: white; padding: 22px 16px 18px; text-align: center;
}
.header-logo { font-size: 26px; margin-bottom: 4px; }
.header h1  { font-size: 20px; font-weight: 800; }
.header p   { font-size: 13px; opacity: 0.8; margin-top: 3px; }

.container { max-width: 680px; margin: 0 auto; padding: 14px 12px 30px; }

/* ── Cards ── */
.card {
    background: white; border-radius: 14px;
    padding: 16px; margin-bottom: 14px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.07);
}
.card-title {
    font-size: 11px; font-weight: 800; text-transform: uppercase;
    letter-spacing: 1px; color: #1d4ed8;
    margin-bottom: 14px; padding-bottom: 8px; border-bottom: 2px solid #eff6ff;
}

/* ── Forms ── */
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 10px; }
.form-group label {
    display: block; font-size: 11px; font-weight: 700; color: #64748b;
    text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 5px;
}
.form-group input, .form-group select, .form-group textarea {
    width: 100%; padding: 11px 12px; border: 1.5px solid #e2e8f0;
    border-radius: 9px; font-size: 16px; color: #1a202c;
    background: #f8fafc; -webkit-appearance: none; appearance: none;
}
.form-group select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.5'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 10px center; padding-right: 34px;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    outline: none; border-color: #1d4ed8;
    background: white; box-shadow: 0 0 0 3px rgba(29,78,216,0.1);
}
.week-badge {
    background: #eff6ff; border: 1.5px solid #bfdbfe;
    border-radius: 9px; padding: 11px 12px;
    text-align: center; font-size: 14px; font-weight: 700; color: #1d4ed8;
}

/* ══════════════════════════════════════════
   PER-ENTRY WORKER MANAGEMENT
   ══════════════════════════════════════════ */

/* "Add Worker" button in action bar */
.add-worker-btn {
    background: #eef2ff; border: 1.5px solid #c7d2fe;
    border-radius: 9px; color: #4338ca;
    font-size: 13px; font-weight: 700;
    padding: 8px 13px; cursor: pointer;
    display: flex; align-items: center; gap: 5px;
    white-space: nowrap; flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
}
.add-worker-btn.open { background: #c7d2fe; border-color: #818cf8; color: #312e81; }

/* Worker chips row (below action bar) */
.entry-worker-list {
    display: flex; flex-wrap: wrap; gap: 5px;
    margin-bottom: 8px; min-height: 0;
}
.entry-worker-chip {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 5px 6px 5px 10px; border-radius: 16px;
    font-size: 12px; font-weight: 700;
    color: white; white-space: nowrap;
}
.chip-role-tag {
    font-size: 9px; font-weight: 800; opacity: 0.85;
    text-transform: uppercase; letter-spacing: 0.3px;
}
.ew-chip-remove {
    background: rgba(255,255,255,0.28); border: none;
    border-radius: 50%; width: 17px; height: 17px;
    display: flex; align-items: center; justify-content: center;
    font-size: 10px; font-weight: 900; cursor: pointer;
    color: white; padding: 0; line-height: 1; flex-shrink: 0;
}
.ew-chip-remove:hover { background: rgba(255,255,255,0.5); }

/* Inline worker add form (inside entry row) */
.entry-worker-form {
    display: none; background: #eef2ff;
    border: 1.5px solid #c7d2fe; border-radius: 10px;
    padding: 10px; margin-bottom: 8px;
}
.entry-worker-form.open { display: block; }
.ew-form-row {
    display: flex; gap: 6px; align-items: center; flex-wrap: wrap;
}
.ew-name-input {
    flex: 1; min-width: 120px; padding: 9px 10px;
    border: 1.5px solid #c7d2fe; border-radius: 8px;
    font-size: 14px; color: #1a202c; background: white;
    -webkit-appearance: none;
}
.ew-name-input:focus { outline: none; border-color: #6366f1; box-shadow: 0 0 0 3px rgba(99,102,241,0.15); }
.ew-role-select {
    padding: 9px 28px 9px 10px; border: 1.5px solid #c7d2fe;
    border-radius: 8px; font-size: 13px; font-weight: 600;
    color: #312e81; background: white;
    -webkit-appearance: none; appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%234f46e5' stroke-width='2.5'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 8px center;
}
.ew-role-select:focus { outline: none; border-color: #6366f1; }
.ew-save-btn {
    padding: 9px 14px; background: #4338ca;
    border: none; border-radius: 8px; color: white;
    font-size: 13px; font-weight: 700; cursor: pointer; white-space: nowrap;
}
.ew-cancel-btn {
    padding: 9px 10px; background: none;
    border: 1.5px solid #c7d2fe; border-radius: 8px;
    font-size: 13px; color: #6366f1; cursor: pointer;
}

/* ── Day cards ── */
.day-card {
    border: 1.5px solid #e2e8f0; border-radius: 12px;
    margin-bottom: 12px; overflow: hidden;
}
.day-header {
    background: #1e3a8a; color: white; padding: 10px 14px;
    display: flex; justify-content: space-between; align-items: center;
}
.day-header.weekend { background: #5b21b6; }
.day-name  { font-weight: 800; font-size: 15px; }
.day-date  { font-size: 12px; opacity: 0.8; margin-top: 1px; }
.day-total-badge {
    background: rgba(255,255,255,0.18); border-radius: 20px;
    padding: 4px 12px; font-size: 13px; font-weight: 700;
}
.day-body { padding: 12px; background: #f8fafc; }

/* ── DAY TIMELINE ── */
.day-timeline-wrap { padding: 10px 12px 0; background: white; }
.day-ruler {
    position: relative; height: 46px;
    background: #f1f5f9; border-radius: 10px;
    border: 1.5px solid #e2e8f0; overflow: hidden;
}
.tl-tick {
    position: absolute; top: 0; width: 1px; height: 100%;
    background: rgba(0,0,0,0.09); pointer-events: none;
}
.tl-seg {
    position: absolute; top: 0; height: 100%;
    border-radius: 5px; z-index: 1;
    display: flex; align-items: center; overflow: hidden;
    transition: left 0.12s, width 0.12s; min-width: 2px;
}
.tl-seg-label {
    color: white; font-size: 10px; font-weight: 800;
    white-space: nowrap; padding: 0 6px;
    text-shadow: 0 1px 2px rgba(0,0,0,0.4);
    overflow: hidden; text-overflow: ellipsis;
}
.tl-lunch-seg {
    position: absolute; top: 0; height: 100%;
    background: #fef3c7;
    border-left: 2.5px solid #f59e0b;
    border-right: 2.5px solid #f59e0b;
    display: flex; align-items: center; justify-content: center;
    font-size: 18px; z-index: 3;
    transition: left 0.12s, width 0.12s;
}
.tl-legend {
    display: flex; flex-wrap: wrap; gap: 5px; padding: 6px 2px 8px;
}
.tl-legend-item {
    font-size: 10px; font-weight: 700; border-radius: 4px;
    padding: 3px 8px; color: white; white-space: nowrap;
    max-width: 130px; overflow: hidden; text-overflow: ellipsis;
}
.tl-legend-lunch { background: #f59e0b !important; color: #78350f !important; }
.day-hlabels {
    display: flex; justify-content: space-between; padding: 2px 2px 10px;
}
.day-hlabels span { font-size: 9px; color: #94a3b8; font-weight: 600; }
@media (max-width: 420px) { .day-hlabels span:nth-child(even) { display: none; } }

/* ── Entry rows ── */
.entry-row {
    background: white; border: 1.5px solid #e2e8f0;
    border-radius: 10px; padding: 12px; margin-bottom: 8px;
}
.entry-row-header {
    display: flex; justify-content: space-between;
    align-items: center; margin-bottom: 10px;
}
.entry-row-num {
    font-size: 11px; font-weight: 700; color: #94a3b8;
    text-transform: uppercase; letter-spacing: 0.5px;
}
.entry-color-dot {
    width: 9px; height: 9px; border-radius: 50%;
    display: inline-block; margin-right: 5px; vertical-align: middle;
}
.remove-btn {
    background: #fee2e2; border: none; border-radius: 6px;
    color: #ef4444; font-size: 13px; font-weight: 700;
    padding: 4px 10px; cursor: pointer;
}
.entry-dropdowns {
    display: grid; grid-template-columns: 1fr 1fr;
    gap: 8px; margin-bottom: 10px;
}
.entry-label {
    font-size: 11px; font-weight: 700; color: #64748b;
    text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 4px;
}
.entry-select {
    width: 100%; padding: 10px;
    border: 1.5px solid #e2e8f0; border-radius: 8px;
    font-size: 14px; background: #f8fafc; color: #1a202c;
    -webkit-appearance: none; appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.5'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 8px center; padding-right: 28px;
}
.entry-select:focus { outline: none; border-color: #1d4ed8; background: white; }

.time-pickers {
    display: grid; grid-template-columns: 1fr 1fr 80px;
    gap: 8px; margin-bottom: 10px; align-items: end;
}
.time-input-big {
    width: 100%; padding: 12px 8px;
    border: 1.5px solid #e2e8f0; border-radius: 9px;
    font-size: 18px; font-weight: 700; color: #1e3a8a;
    background: #eff6ff; text-align: center;
    -webkit-appearance: none; appearance: none;
}
.time-input-big:focus {
    outline: none; border-color: #1d4ed8;
    background: white; box-shadow: 0 0 0 3px rgba(29,78,216,0.1);
}
.hours-pill {
    background: #1e3a8a; color: white; border-radius: 9px;
    display: flex; align-items: center; justify-content: center;
    flex-direction: column; font-size: 17px; font-weight: 800; min-height: 50px;
}
.hours-pill-sub {
    font-size: 9px; font-weight: 600; opacity: 0.7; text-transform: uppercase;
}

/* ── Entry action bar: Lunch + Add Worker ── */
.entry-actions {
    display: flex; gap: 8px; align-items: center;
    margin-bottom: 8px; flex-wrap: wrap;
}
.lunch-btn {
    background: #fef3c7; border: 1.5px solid #f59e0b;
    border-radius: 9px; color: #92400e;
    font-size: 13px; font-weight: 700;
    padding: 8px 13px; cursor: pointer;
    display: flex; align-items: center; gap: 5px;
    white-space: nowrap; flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
}
.lunch-btn.active { background: #f59e0b; border-color: #d97706; color: white; }

/* Lunch panel */
.lunch-panel {
    display: none; background: #fffbeb;
    border: 1.5px solid #fde68a; border-radius: 10px;
    padding: 10px 12px; margin-bottom: 10px;
}
.lunch-panel.visible { display: block; }
.lunch-panel-row {
    display: grid; grid-template-columns: 1fr 1fr auto;
    gap: 8px; align-items: end;
}
.entry-label-sm {
    font-size: 10px; font-weight: 700; color: #92400e;
    text-transform: uppercase; letter-spacing: 0.4px; margin-bottom: 4px;
}
.lunch-time-input {
    width: 100%; padding: 9px 8px; border: 1.5px solid #fde68a;
    border-radius: 8px; font-size: 15px; font-weight: 700;
    color: #92400e; background: white; text-align: center; -webkit-appearance: none;
}
.lunch-time-input:focus { outline: none; border-color: #f59e0b; }
.lunch-dur-select {
    width: 100%; padding: 9px 8px; border: 1.5px solid #fde68a;
    border-radius: 8px; font-size: 14px; font-weight: 700;
    color: #92400e; background: white;
    -webkit-appearance: none; appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23f59e0b' stroke-width='3'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 8px center; padding-right: 26px;
}
.remove-lunch-btn {
    background: #fecaca; border: none; border-radius: 8px;
    color: #ef4444; font-size: 13px; font-weight: 700;
    padding: 9px 12px; cursor: pointer; white-space: nowrap;
}

.entry-desc-input {
    width: 100%; padding: 9px 10px; border: 1.5px solid #e2e8f0;
    border-radius: 8px; font-size: 14px; background: #f8fafc; color: #1a202c;
}
.entry-desc-input:focus { outline: none; border-color: #1d4ed8; background: white; }

.add-entry-btn {
    display: block; width: 100%; padding: 11px;
    background: #eff6ff; border: 2px dashed #93c5fd; border-radius: 9px;
    color: #1d4ed8; font-size: 14px; font-weight: 700;
    text-align: center; cursor: pointer; margin-top: 2px;
}

/* ── Summary ── */
.totals-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.total-box {
    background: #eff6ff; border: 1.5px solid #bfdbfe;
    border-radius: 10px; padding: 12px 8px; text-align: center;
}
.total-box.accent { background: #1e3a8a; border-color: #1e3a8a; }
.total-lbl {
    font-size: 10px; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.6px; color: #64748b; margin-bottom: 4px;
}
.total-box.accent .total-lbl { color: rgba(255,255,255,0.7); }
.total-val { font-size: 24px; font-weight: 800; color: #1e3a8a; }
.total-box.accent .total-val { color: white; }

/* Worker hours breakdown in summary */
.worker-summary {
    display: none; margin-top: 14px;
    border-top: 2px solid #eff6ff; padding-top: 12px;
}
.worker-summary-title {
    font-size: 11px; font-weight: 800; text-transform: uppercase;
    letter-spacing: 0.8px; color: #1d4ed8; margin-bottom: 10px;
}
.worker-summary-row {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 0; border-bottom: 1px solid #f1f5f9;
}
.worker-summary-row:last-child { border-bottom: none; }
.ws-dot { width: 11px; height: 11px; border-radius: 50%; flex-shrink: 0; }
.ws-name { font-weight: 700; font-size: 14px; flex: 1; }
.ws-role {
    font-size: 11px; font-weight: 700; padding: 2px 8px;
    border-radius: 10px; color: white; white-space: nowrap;
}
.ws-hours { font-size: 16px; font-weight: 800; color: #1e3a8a; min-width: 60px; text-align: right; }

/* ── Signature ── */
.sig-wrap {
    border: 2px solid #e2e8f0; border-radius: 10px;
    background: #fafafa; overflow: hidden; position: relative;
}
.sig-wrap.signed { border-color: #22c55e; }
#signatureCanvas { display: block; width: 100%; height: 160px; cursor: crosshair; touch-action: none; }
.sig-placeholder {
    position: absolute; inset: 0; display: flex;
    align-items: center; justify-content: center;
    color: #cbd5e1; font-size: 14px; pointer-events: none;
}
.sig-placeholder.hidden { opacity: 0; }
.sig-row { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; }
.sig-hint { font-size: 12px; color: #94a3b8; }
.clear-sig-btn {
    background: none; border: 1.5px solid #e2e8f0; border-radius: 7px;
    padding: 6px 14px; font-size: 13px; font-weight: 600; color: #64748b; cursor: pointer;
}
.declaration {
    background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 9px;
    padding: 12px 14px; font-size: 13px; color: #475569;
    line-height: 1.6; margin-bottom: 14px;
}

/* ── Submit ── */
.submit-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 30px; }
.btn {
    padding: 15px 12px; border-radius: 12px; font-size: 15px;
    font-weight: 800; border: none; cursor: pointer;
    display: flex; align-items: center; justify-content: center; gap: 8px;
    transition: transform 0.1s, opacity 0.1s;
}
.btn:active { transform: scale(0.97); opacity: 0.85; }
.btn-pdf   { background: #1e3a8a; color: white; }
.btn-email { background: #059669; color: white; }

.error-banner {
    display: none; background: #fef2f2; border: 1.5px solid #fca5a5;
    border-radius: 9px; padding: 12px 14px; color: #dc2626;
    font-size: 14px; font-weight: 600; margin-bottom: 12px; text-align: center;
}

/* ── Print ── */
@media print {
    body { background: white; }
    .header, .day-header, .tl-seg, .total-box.accent, .hours-pill
    { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .worker-chip.on { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .submit-grid, .add-entry-btn, .remove-btn, .lunch-btn, .remove-lunch-btn,
    .clear-sig-btn, .sig-hint, .error-banner, .add-worker-trigger,
    .add-worker-form, .tm-remove, .cancel-worker-btn { display: none !important; }
    .card { box-shadow: none; break-inside: avoid; margin-bottom: 10px; }
    .day-card { break-inside: avoid; }
    .container { padding: 0; }
}

/* ── Responsive ── */
@media (max-width: 400px) {
    .entry-dropdowns, .form-row { grid-template-columns: 1fr; }
    .time-pickers { grid-template-columns: 1fr 1fr; }
    .hours-pill-col { display: none; }
    .totals-grid { grid-template-columns: 1fr; }
    .submit-grid { grid-template-columns: 1fr; }
    .lunch-panel-row { grid-template-columns: 1fr 1fr; }
    .remove-lunch-btn { grid-column: 1 / -1; }
}

/* ── Print: hide auth + logout ── */
@media print {
    .auth-overlay, .logout-row { display: none !important; }
}
