* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Arial, sans-serif;
    background: #f3f4f6;
    color: #1f2937;
    overflow-x: hidden;
}

a {
    color: #0f766e;
    text-decoration: none;
}

button,
input,
select {
    font: inherit;
}

button {
    border: 0;
    background: #0f766e;
    color: #fff;
    padding: 12px 16px;
    border-radius: 6px;
    cursor: pointer;
}

button.secondary {
    background: #475569;
}

button.danger {
    background: #b91c1c;
}

button:disabled {
    background: #94a3b8;
    cursor: not-allowed;
}

input,
select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    margin-top: 6px;
}

label {
    display: block;
    font-weight: 600;
}

.container {
    width: 100%;
    max-width: 1100px;
    margin: 24px auto;
    padding: 0 16px;
}

.container.wide {
    max-width: 1900px;
}

.container.narrow {
    max-width: 460px;
}

.card {
    background: #fff;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.08);
}

.grid {
    display: grid;
    gap: 20px;
}

.two-col {
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    margin-bottom: 20px;
}

.admin-page {
    max-width: 1500px;
}

.admin-forms-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.admin-lists-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 20px;
}

.admin-forms-grid > *,
.admin-lists-grid > *,
.admin-list-card,
.admin-form-card {
    min-width: 0;
}

.admin-form-card h1,
.admin-list-card h2 {
    margin-top: 0;
}

.admin-list-card {
    margin-bottom: 20px;
}

.section-heading {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 12px;
}

.section-heading h2 {
    margin: 0;
}

.section-heading span {
    color: #64748b;
    font-size: 13px;
}

.stack > * + * {
    margin-top: 14px;
}

.topbar {
    background: #111827;
    color: #fff;
    padding: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.topbar-actions {
    display: flex;
    gap: 16px;
    align-items: center;
}

.clock {
    font-size: 56px;
    font-weight: 700;
    letter-spacing: 2px;
    margin: 16px 0 24px;
}

.muted {
    color: #64748b;
}

.small {
    font-size: 14px;
}

.button-row {
    display: flex;
    gap: 12px;
}

.status-badge {
    padding: 10px 12px;
    border-radius: 6px;
    font-weight: 600;
}

.status-badge.pending {
    background: #e2e8f0;
    color: #334155;
}

.status-badge.ok {
    background: #dcfce7;
    color: #166534;
}

.status-badge.error {
    background: #fee2e2;
    color: #991b1b;
}

.status-badge.warning {
    background: #fef3c7;
    color: #92400e;
}

.status-badge.compact {
    display: inline-block;
    padding: 5px 8px;
    font-size: 12px;
    white-space: nowrap;
}

.alert {
    padding: 12px 14px;
    border-radius: 6px;
    margin-bottom: 18px;
}

.alert.success {
    background: #dcfce7;
    color: #166534;
}

.alert.error {
    background: #fee2e2;
    color: #991b1b;
}

.table-wrap {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
}

.table-wrap table {
    min-width: 1650px;
}

.admin-table-wrap table {
    min-width: 720px;
}

.admin-table th,
.admin-table td {
    vertical-align: middle;
}

.admin-actions {
    min-width: 145px;
    white-space: nowrap;
}

.secondary-link {
    display: inline-block;
    padding: 10px 12px;
    border-radius: 6px;
    background: #e2e8f0;
    color: #334155;
    font-weight: 700;
    text-align: center;
}

.qr-tools {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.qr-preview-box {
    display: grid;
    place-items: center;
    min-height: 120px;
    border: 1px dashed #cbd5e1;
    border-radius: 8px;
    background: #f8fafc;
}

.qr-preview-box img {
    width: 120px;
    height: 120px;
    object-fit: contain;
}

.report-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
    margin: 16px 0;
}

.report-toolbar,
.pagination {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin: 14px 0;
}

.date-nav {
    display: flex;
    align-items: center;
    gap: 10px;
}

.date-nav span,
.pagination span {
    color: #475569;
    font-weight: 700;
}

.toolbar-button {
    display: inline-block;
    padding: 9px 12px;
    border-radius: 6px;
    background: #e0f2fe;
    color: #075985;
    font-weight: 700;
}

.toolbar-button.export {
    background: #dcfce7;
    color: #166534;
}

.report-summary > div {
    padding: 14px;
    border-radius: 8px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
}

.report-summary strong {
    display: block;
    font-size: 24px;
}

.report-summary span {
    color: #64748b;
    font-size: 13px;
}

.report-summary .summary-ok {
    background: #f0fdf4;
    border-color: #bbf7d0;
}

.report-summary .summary-warn {
    background: #fffbeb;
    border-color: #fde68a;
}

.report-summary .summary-error {
    background: #fef2f2;
    border-color: #fecaca;
}

.actions-cell {
    min-width: 190px;
}

.inline-form {
    display: inline;
}

.compact-button {
    padding: 5px 7px;
    margin: 0;
    font-size: 12px;
}

.action-group {
    display: grid;
    grid-template-columns: 58px auto auto;
    align-items: center;
    gap: 6px;
    margin: 3px 0;
}

.action-label {
    color: #64748b;
    font-size: 12px;
    font-weight: 700;
}

.action-link {
    display: inline-block;
    padding: 5px 7px;
    border-radius: 5px;
    background: #e0f2fe;
    color: #075985;
    font-size: 12px;
    font-weight: 700;
}

.report-edit-card {
    margin-bottom: 20px;
}

.qr-code {
    display: inline-block;
    max-width: 170px;
    padding: 4px 6px;
    border-radius: 5px;
    background: #f1f5f9;
    color: #0f172a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

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

th,
td {
    text-align: left;
    padding: 10px 8px;
    border-bottom: 1px solid #e5e7eb;
    font-size: 14px;
}

.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: end;
    margin-bottom: 16px;
}

.info-list > div + div {
    margin-top: 8px;
}

.help-box {
    margin-top: 18px;
    padding: 12px;
    background: #f8fafc;
    border-radius: 6px;
    font-size: 14px;
}

.employee-clock-page {
    background: #eef3f7;
}

.employee-container {
    max-width: 760px;
}

.employee-profile-card,
.employee-clock-card {
    border: 1px solid #cfd8e3;
    border-radius: 10px;
    box-shadow: 0 1px 4px rgba(15, 23, 42, 0.08);
}

.employee-profile-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 28px;
    background: #fff;
    margin-bottom: 16px;
}

.employee-avatar {
    width: 58px;
    height: 58px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: #e0f2fe;
    border: 1px solid #bae6fd;
    color: #0369a1;
    font-weight: 800;
}

.employee-profile-main {
    display: grid;
    gap: 3px;
    flex: 1;
}

.employee-profile-main strong {
    font-size: 18px;
}

.employee-profile-main span,
.employee-profile-main small {
    color: #475569;
}

.logout-pill {
    padding: 8px 12px;
    border-radius: 999px;
    background: #f1f5f9;
    color: #334155;
    font-weight: 700;
}

.employee-company-card,
.employee-step-card,
.recent-records-card {
    margin-bottom: 16px;
}

.employee-company-card h2,
.employee-step-card h2,
.recent-records-card h2 {
    margin-top: 0;
    font-size: 16px;
}

.company-choice-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 10px;
    margin-top: 12px;
}

.company-choice {
    display: grid;
    gap: 4px;
    text-align: left;
    background: #f8fafc;
    color: #0f172a;
    border: 1px solid #cbd5e1;
}

.company-choice small {
    color: #64748b;
}

.company-choice.active {
    background: #0f766e;
    border-color: #0f766e;
    color: #fff;
}

.company-choice.active small {
    color: #ccfbf1;
}

.employee-clock-card {
    background: #0872d8;
    color: #fff;
    padding: 34px 20px;
    text-align: center;
    margin-bottom: 16px;
}

.employee-date {
    font-size: 14px;
    margin-bottom: 8px;
}

.employee-time {
    font-size: 44px;
    line-height: 1;
    font-weight: 800;
    letter-spacing: 1px;
}

.record-type-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.record-type-btn {
    min-height: 58px;
    background: #f8fafc;
    color: #0f172a;
    border: 1px solid #cbd5e1;
}

.record-type-btn.entrada.active {
    background: #16a34a;
    border-color: #16a34a;
    color: #fff;
}

.record-type-btn.salida.active {
    background: #dc2626;
    border-color: #dc2626;
    color: #fff;
}

.verification-list {
    display: grid;
    gap: 12px;
}

.verification-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
    padding: 13px 14px;
    border-radius: 8px;
    background: #f1f5f9;
}

.verification-row > div:first-child {
    display: grid;
    gap: 4px;
}

.verification-row small {
    color: #64748b;
}

.verification-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.gps-countdown {
    min-width: 38px;
    padding: 5px 8px;
    border-radius: 999px;
    background: #ecfdf5;
    color: #047857;
    font-size: 12px;
    font-weight: 800;
    text-align: center;
    border: 1px solid #bbf7d0;
}

.mini-action-btn {
    padding: 7px 10px;
    border-radius: 6px;
    background: #fff;
    color: #0f172a;
    border: 1px solid #cbd5e1;
    font-size: 13px;
}

.mini-action-btn:disabled {
    cursor: not-allowed;
    opacity: 0.65;
}

.hidden-input {
    display: none;
}

.confirm-record-btn {
    width: 100%;
    margin-top: 16px;
    font-weight: 800;
}

.verification-help {
    text-align: center;
    color: #64748b;
    margin: 10px 0 0;
}

.ok-text {
    color: #166534;
}

.error-text {
    color: #991b1b;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.employee-table-wrap table {
    min-width: 620px;
}

.camera-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: grid;
    place-items: center;
    padding: 16px;
    background: rgba(15, 23, 42, 0.78);
}

.camera-modal[hidden] {
    display: none;
}

.camera-panel {
    width: min(520px, 100%);
    background: #fff;
    border-radius: 14px;
    padding: 16px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.28);
}

.camera-header,
.camera-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.camera-close-btn {
    padding: 7px 10px;
    background: #e2e8f0;
    color: #334155;
    font-size: 13px;
}

.camera-view {
    position: relative;
    overflow: hidden;
    margin: 14px 0 10px;
    border-radius: 12px;
    background: #020617;
    aspect-ratio: 3 / 4;
}

.camera-view video,
.camera-view img,
.camera-view canvas {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.camera-view video[hidden],
.camera-view img[hidden],
.camera-view canvas[hidden] {
    display: none !important;
}

.selfie-view video,
.selfie-view img {
    transform: scaleX(-1);
}

.qr-focus-frame {
    position: absolute;
    inset: 50%;
    width: min(72%, 290px);
    aspect-ratio: 1;
    transform: translate(-50%, -50%);
    border: 3px solid #38bdf8;
    border-radius: 18px;
    box-shadow: 0 0 0 999px rgba(2, 6, 23, 0.42);
}

.camera-message {
    min-height: 20px;
    color: #475569;
    font-size: 14px;
    text-align: center;
}

.mini-action-btn.primary,
.mini-action-btn.active {
    background: #0f766e;
    color: #fff;
    border-color: #0f766e;
}

@media (max-width: 640px) {
    .container {
        margin: 16px auto;
        padding: 0 12px;
    }

    .card {
        padding: 16px;
    }

    .admin-page {
        margin-top: 16px;
    }

    .admin-forms-grid,
    .admin-lists-grid {
        gap: 14px;
    }

    .admin-list-card {
        margin-bottom: 14px;
    }

    .admin-table-wrap {
        border: 1px solid #e2e8f0;
        border-radius: 8px;
    }

    .admin-table-wrap table {
        min-width: 680px;
    }

    .topbar {
        align-items: flex-start;
    }

    .topbar-actions {
        width: 100%;
        justify-content: flex-start;
        flex-wrap: wrap;
    }

    .clock {
        font-size: 42px;
    }

    .button-row,
    .filters {
        flex-direction: column;
        align-items: stretch;
    }

    .employee-profile-card,
    .verification-row {
        align-items: flex-start;
        flex-direction: column;
    }

    .logout-pill {
        align-self: flex-start;
    }

    .record-type-grid {
        grid-template-columns: 1fr;
    }

    .employee-time {
        font-size: 36px;
    }
}

@media (max-width: 1100px) {
    .admin-forms-grid,
    .admin-lists-grid {
        grid-template-columns: 1fr;
    }
}
