:root {
    --bg: #f4f6f9;
    --card: #ffffff;
    --text: #1f2937;
    --muted: #6b7280;
    --line: #e5e7eb;
    --primary: #1f6feb;
    --primary-dark: #0f4ca5;
    --danger: #dc2626;
    --success: #16a34a;
    --warning: #d97706;
    --sidebar: #111827;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: Arial, Helvetica, sans-serif; color: var(--text); background: var(--bg); }
a { color: inherit; text-decoration: none; }
.app-shell { display: flex; min-height: 100vh; }
.sidebar { width: 260px; background: var(--sidebar); color: #fff; padding: 18px; display: flex; flex-direction: column; gap: 18px; position: fixed; inset: 0 auto 0 0; }
.brand { display: flex; align-items: center; gap: 12px; padding-bottom: 14px; border-bottom: 1px solid rgba(255,255,255,.12); }
.brand-mark { width: 42px; height: 42px; border-radius: 12px; background: var(--primary); display: grid; place-items: center; font-weight: 800; font-size: 22px; }
.brand strong { display: block; font-size: 18px; }
.brand small { color: #9ca3af; }
.sidebar nav { display: flex; flex-direction: column; gap: 6px; }
.sidebar nav a, .logout { padding: 11px 12px; border-radius: 10px; color: #d1d5db; }
.sidebar nav a.active, .sidebar nav a:hover, .logout:hover { background: rgba(255,255,255,.1); color: #fff; }
.logout { margin-top: auto; color: #fecaca; }
.main-content { margin-left: 260px; width: calc(100% - 260px); padding: 24px; }
.topbar { background: var(--card); padding: 18px 22px; border-radius: 18px; box-shadow: 0 8px 24px rgba(17,24,39,.06); display: flex; justify-content: space-between; gap: 16px; align-items: center; margin-bottom: 18px; }
.topbar h1 { margin: 0 0 4px; font-size: 26px; }
.topbar p { margin: 0; color: var(--muted); }
.user-chip { background: #eff6ff; color: var(--primary-dark); padding: 10px 12px; border-radius: 999px; font-weight: 700; }
.user-chip span { color: var(--muted); font-weight: 400; margin-left: 8px; }
.card { background: var(--card); border-radius: 18px; padding: 18px; box-shadow: 0 8px 24px rgba(17,24,39,.06); margin-bottom: 18px; }
.card h2 { margin-top: 0; font-size: 20px; }
.grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.stat { background: var(--card); border-radius: 18px; padding: 18px; box-shadow: 0 8px 24px rgba(17,24,39,.06); }
.stat span { color: var(--muted); font-size: 14px; }
.stat strong { display: block; font-size: 30px; margin-top: 8px; }
.form-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; align-items: end; }
.form-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
label { display: block; font-weight: 700; font-size: 13px; margin-bottom: 6px; }
input, select, textarea { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font-size: 14px; background: #fff; }
textarea { min-height: 80px; }
button, .btn { border: 0; border-radius: 10px; padding: 11px 14px; background: var(--primary); color: #fff; cursor: pointer; font-weight: 700; display: inline-block; }
button:hover, .btn:hover { background: var(--primary-dark); }
.btn-secondary { background: #374151; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 12px; overflow: hidden; }
th, td { padding: 12px; border-bottom: 1px solid var(--line); text-align: left; font-size: 14px; vertical-align: top; }
th { background: #f9fafb; color: #374151; font-weight: 800; }
.badge { display: inline-block; border-radius: 999px; padding: 5px 9px; font-size: 12px; font-weight: 800; background: #e5e7eb; }
.badge.ok { background: #dcfce7; color: #166534; }
.badge.warn { background: #fef3c7; color: #92400e; }
.badge.danger { background: #fee2e2; color: #991b1b; }
.alert { padding: 12px 14px; border-radius: 12px; margin-bottom: 14px; font-weight: 700; }
.alert-success { background: #dcfce7; color: #166534; }
.alert-error { background: #fee2e2; color: #991b1b; }
.login-page { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(135deg, #111827, #1f6feb); padding: 20px; }
.login-card { width: min(430px, 100%); background: #fff; border-radius: 24px; padding: 28px; box-shadow: 0 30px 80px rgba(0,0,0,.28); }
.login-card h1 { margin: 0 0 8px; }
.login-card p { color: var(--muted); margin-bottom: 22px; }
.login-card .field { margin-bottom: 14px; }
.note { color: var(--muted); font-size: 13px; margin-top: 10px; }
@media (max-width: 980px) {
    .sidebar { position: static; width: 100%; }
    .app-shell { display: block; }
    .main-content { margin-left: 0; width: 100%; }
    .grid, .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
    .grid, .form-grid, .form-grid.two { grid-template-columns: 1fr; }
    .topbar { flex-direction: column; align-items: flex-start; }
}

/* Employee Clock PWA */
.clock-app-page {
    min-height: 100vh;
    background: radial-gradient(circle at top left, #1f6feb 0, #111827 45%, #030712 100%);
    color: #111827;
}
.clock-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 18px;
}
.clock-card {
    width: min(560px, 100%);
    background: rgba(255,255,255,.96);
    border-radius: 28px;
    padding: 22px;
    box-shadow: 0 28px 80px rgba(0,0,0,.32);
}
.clock-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 18px;
}
.clock-brand .brand-mark {
    flex: 0 0 auto;
}
.clock-brand strong {
    display: block;
    font-size: 23px;
}
.clock-brand small {
    color: var(--muted);
}
.pin-panel label {
    font-size: 15px;
}
.pin-input {
    font-size: 28px;
    text-align: center;
    letter-spacing: 8px;
    font-weight: 800;
    border-radius: 18px;
    padding: 18px 14px;
}
.clock-main-btn,
.clock-submit {
    width: 100%;
    border-radius: 18px;
    font-size: 20px;
    padding: 18px 14px;
    margin-top: 12px;
}
.clock-submit {
    background: var(--success);
}
.clock-submit:hover {
    background: #15803d;
}
.clock-submit:disabled,
.clock-main-btn:disabled,
.camera-actions button:disabled {
    opacity: .55;
    cursor: not-allowed;
}
.clock-help {
    color: var(--muted);
    text-align: center;
    line-height: 1.5;
}
.employee-panel {
    margin-top: 16px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 20px;
    background: #f9fafb;
}
.employee-panel h1 {
    margin: 10px 0 6px;
    font-size: 28px;
}
.employee-panel p {
    margin: 0;
    color: var(--muted);
}
.mode-badge {
    display: inline-flex;
    border-radius: 999px;
    padding: 7px 11px;
    font-size: 13px;
    font-weight: 900;
    background: #dbeafe;
    color: #1e40af;
}
.mode-badge.out {
    background: #fee2e2;
    color: #991b1b;
}
.camera-panel {
    margin-top: 16px;
}
.camera-panel video,
.photo-preview {
    width: 100%;
    max-height: 420px;
    object-fit: cover;
    background: #111827;
    border-radius: 22px;
    border: 1px solid var(--line);
}
.camera-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 10px;
}
.camera-actions button {
    border-radius: 16px;
    padding: 15px 12px;
    font-size: 16px;
}
.hidden {
    display: none !important;
}
.clock-footer {
    text-align: center;
    margin-top: 14px;
    color: rgba(255,255,255,.82);
    font-size: 13px;
}
.clock-footer a {
    color: #fff;
    text-decoration: underline;
}
.clock-photo-thumb {
    width: 66px;
    height: 66px;
    object-fit: cover;
    border-radius: 12px;
    border: 1px solid var(--line);
    display: block;
}
@media (max-width: 640px) {
    .clock-shell { padding: 10px; align-items: stretch; }
    .clock-card { border-radius: 22px; padding: 16px; min-height: calc(100vh - 45px); }
    .pin-input { font-size: 24px; }
    .clock-main-btn, .clock-submit { font-size: 18px; }
    .camera-actions { grid-template-columns: 1fr; }
}


/* Mobile-only employee clock v2 */
.mobile-clock-only .clock-shell {
    place-items: stretch;
    padding: max(10px, env(safe-area-inset-top)) 10px max(10px, env(safe-area-inset-bottom));
}
.mobile-clock-card {
    width: min(520px, 100%);
    min-height: calc(100vh - 20px);
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
}
.compact-brand { margin-bottom: 12px; }
.compact-brand strong { font-size: 21px; }
.auto-camera-panel {
    position: relative;
    width: 100%;
    aspect-ratio: 3 / 4;
    max-height: 56vh;
    min-height: 280px;
    overflow: hidden;
    border-radius: 24px;
    background: #030712;
    border: 1px solid rgba(255,255,255,.14);
    box-shadow: inset 0 0 0 1px rgba(0,0,0,.15);
}
.auto-camera-panel video,
.auto-camera-panel .photo-preview {
    width: 100%;
    height: 100%;
    max-height: none;
    object-fit: cover;
    border: 0;
    border-radius: 24px;
    display: block;
}
.camera-live-badge {
    position: absolute;
    left: 12px;
    top: 12px;
    border-radius: 999px;
    background: rgba(17,24,39,.84);
    color: #fff;
    padding: 7px 10px;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: .2px;
}
.camera-live-badge.ready { background: rgba(22,163,74,.9); }
.camera-live-badge.error { background: rgba(220,38,38,.92); }
.open-camera-btn {
    width: 100%;
    border-radius: 18px;
    padding: 15px 14px;
    margin-top: 12px;
    font-size: 17px;
}
.mobile-pin-panel { margin-top: 14px; }
.mobile-pin-panel label { text-align: center; font-size: 14px; color: #374151; }
.mobile-pin-panel .pin-input {
    font-size: 30px;
    padding: 16px 14px;
    letter-spacing: 10px;
    border: 2px solid #d1d5db;
}
.mobile-pin-panel .clock-main-btn {
    background: linear-gradient(135deg, #16a34a, #1f6feb);
    box-shadow: 0 16px 30px rgba(31,111,235,.23);
    min-height: 68px;
}
.mobile-pin-panel .clock-main-btn:disabled { opacity: .75; }
.photo-report-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
}
.clock-photo-card {
    border: 1px solid var(--line);
    border-radius: 18px;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 8px 20px rgba(17,24,39,.05);
}
.clock-photo-card img,
.missing-photo {
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    display: block;
    background: #111827;
    color: #fff;
}
.missing-photo { display: grid; place-items: center; font-weight: 800; }
.clock-photo-info {
    padding: 13px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}
.clock-photo-info strong { font-size: 16px; }
.clock-photo-info span { color: var(--muted); font-size: 13px; line-height: 1.35; }
@media (max-width: 640px) {
    .mobile-clock-only .clock-card { border-radius: 20px; padding: 14px; }
    .auto-camera-panel { min-height: 300px; max-height: 54vh; }
    .mobile-pin-panel .pin-input { font-size: 28px; }
    .clock-help { font-size: 13px; margin: 10px 0 0; }
}

/* HR v3 refinements */
.form-grid .full { grid-column: 1 / -1; }
.checkline { display: flex; align-items: center; gap: 8px; margin: 0; font-weight: 700; }
.checkline input { width: auto; }
.row-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inline-form { display: inline; margin: 0; }
.btn-small { padding: 7px 10px; border-radius: 9px; font-size: 12px; }
button.danger, .btn.danger { background: var(--danger); }
button.danger:hover, .btn.danger:hover { background: #991b1b; }
.finish-panel {
    border-radius: 20px;
    background: #dcfce7;
    color: #166534;
    padding: 16px;
    margin-bottom: 14px;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 5px;
}
.finish-panel strong { font-size: 22px; }
.countdown-overlay {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    background: rgba(0,0,0,.42);
    color: #fff;
    font-size: clamp(56px, 16vw, 116px);
    font-weight: 1000;
    letter-spacing: 2px;
    text-shadow: 0 10px 30px rgba(0,0,0,.55);
    z-index: 5;
}
@media (max-width: 640px) {
    .row-actions { min-width: 160px; }
}

/* HR v4 - TIVA / WordPress-like admin look */
:root {
    --wp-sidebar: #1d2327;
    --wp-sidebar-hover: #2c3338;
    --wp-blue: #2271b1;
    --wp-blue-dark: #135e96;
    --wp-border: #c3c4c7;
    --wp-bg: #f0f0f1;
}
body.wp-admin-look { background: var(--wp-bg); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif; }
.admin-top-strip {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 32px;
    background: #1d2327;
    color: #f0f0f1;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 14px;
    font-size: 13px;
    box-shadow: 0 1px 0 rgba(0,0,0,.2);
}
.admin-top-brand { font-weight: 700; display: flex; align-items: center; gap: 7px; }
.mini-logo { width: 20px; height: 20px; display: inline-grid; place-items: center; border-radius: 4px; background: var(--wp-blue); color: #fff; font-weight: 900; }
.admin-top-user span { color: #a7aaad; margin-left: 8px; text-transform: capitalize; }
.wp-admin-look .app-shell { padding-top: 32px; }
.wp-admin-look .sidebar {
    top: 32px;
    width: 235px;
    background: var(--wp-sidebar);
    padding: 0;
    gap: 0;
    border-right: 1px solid #000;
}
.wp-admin-look .brand {
    padding: 14px 14px 12px;
    border-bottom: 1px solid rgba(255,255,255,.08);
    background: #111517;
}
.wp-admin-look .brand-mark { width: 36px; height: 36px; border-radius: 7px; background: var(--wp-blue); font-size: 20px; }
.wp-admin-look .brand strong { font-size: 16px; }
.wp-admin-look .brand small { color: #a7aaad; }
.wp-admin-look .sidebar nav { gap: 0; padding: 8px 0; }
.wp-admin-look .sidebar nav a,
.wp-admin-look .logout,
.wp-admin-look .employee-clock-link {
    border-radius: 0;
    padding: 10px 14px;
    color: #c3c4c7;
    border-left: 4px solid transparent;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
}
.wp-admin-look .sidebar nav a em {
    font-style: normal;
    font-size: 10px;
    color: #8c8f94;
    text-transform: uppercase;
}
.wp-admin-look .sidebar nav a.active {
    background: var(--wp-blue);
    color: #fff;
    border-left-color: #72aee6;
}
.wp-admin-look .sidebar nav a:hover,
.wp-admin-look .logout:hover,
.wp-admin-look .employee-clock-link:hover { background: var(--wp-sidebar-hover); color: #fff; }
.wp-admin-look .employee-clock-link { margin-top: auto; color: #72aee6; border-top: 1px solid rgba(255,255,255,.07); }
.wp-admin-look .logout { color: #ffb3b3; }
.wp-admin-look .main-content {
    margin-left: 235px;
    width: calc(100% - 235px);
    padding: 22px 24px 34px;
}
.wp-admin-look .topbar {
    background: transparent;
    box-shadow: none;
    border-radius: 0;
    border-bottom: 1px solid var(--wp-border);
    padding: 0 0 14px;
    margin-bottom: 18px;
}
.wp-admin-look .topbar h1 { font-size: 24px; font-weight: 500; color: #1d2327; }
.wp-admin-look .topbar p { color: #646970; }
.wp-admin-look .user-chip { border: 1px solid var(--wp-border); background: #fff; color: #1d2327; border-radius: 3px; padding: 7px 10px; }
.wp-admin-look .card,
.wp-admin-look .stat {
    border-radius: 4px;
    border: 1px solid var(--wp-border);
    box-shadow: none;
    background: #fff;
}
.wp-admin-look .card h2 { font-size: 18px; font-weight: 600; color: #1d2327; }
.wp-admin-look input,
.wp-admin-look select,
.wp-admin-look textarea {
    border-color: #8c8f94;
    border-radius: 4px;
    min-height: 34px;
}
.wp-admin-look input:focus,
.wp-admin-look select:focus,
.wp-admin-look textarea:focus {
    outline: 2px solid rgba(34,113,177,.22);
    border-color: var(--wp-blue);
}
.wp-admin-look button,
.wp-admin-look .btn {
    border-radius: 3px;
    background: var(--wp-blue);
    border: 1px solid var(--wp-blue-dark);
    padding: 8px 12px;
    min-height: 34px;
    box-shadow: 0 1px 0 rgba(0,0,0,.08);
}
.wp-admin-look button:hover,
.wp-admin-look .btn:hover { background: var(--wp-blue-dark); }
.wp-admin-look .btn-secondary { background: #f6f7f7; color: #2271b1; border-color: #2271b1; }
.wp-admin-look .btn-secondary:hover { background: #f0f6fc; color: #0a4b78; }
.wp-admin-look table { border-radius: 0; border: 1px solid var(--wp-border); }
.wp-admin-look th { background: #f6f7f7; color: #1d2327; border-bottom: 1px solid var(--wp-border); }
.wp-admin-look td { border-bottom: 1px solid #dcdcde; }
.wp-admin-look tr:hover td { background: #f6f7f7; }
.settings-section-title { border-top: 1px solid var(--line); padding-top: 8px; }
.setting-toggle { align-self: center; background: #f6f7f7; border: 1px solid #dcdcde; border-radius: 4px; padding: 12px; }
.permissions-box { border-top: 1px solid var(--line); padding-top: 10px; }
.permission-table-wrap { overflow-x: auto; }
.permission-table th:nth-child(2), .permission-table th:nth-child(3), .permission-table td:nth-child(2), .permission-table td:nth-child(3) { width: 160px; text-align: center; }
.permission-table .checkline { justify-content: center; }
.payroll-period-header { display: flex; justify-content: space-between; gap: 14px; align-items: center; }
.done-close-btn { width: 100%; margin-top: 10px; background: #16a34a !important; border-color: #15803d !important; font-size: 18px; padding: 15px !important; border-radius: 16px !important; }
.final-done { min-height: 45vh; justify-content: center; }
.camera-disabled { display: grid; place-items: center; min-height: 160px; aspect-ratio: auto; background: #111827; }
.camera-disabled video { display: none; }
@media (max-width: 980px) {
    .admin-top-strip { position: sticky; }
    .wp-admin-look .app-shell { padding-top: 0; }
    .wp-admin-look .sidebar { position: static; width: 100%; }
    .wp-admin-look .main-content { margin-left: 0; width: 100%; padding: 18px; }
    .payroll-period-header { display: block; }
}
.dual-photo-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: #dcdcde; }
.dual-photo-grid > div { position: relative; background: #111827; }
.dual-photo-grid img, .dual-photo-grid .missing-photo { width: 100%; aspect-ratio: 1 / 1; object-fit: cover; }
.photo-label { position: absolute; left: 8px; top: 8px; z-index: 2; background: rgba(0,0,0,.72); color: #fff; padding: 4px 7px; border-radius: 999px; font-size: 11px; font-weight: 800; }
