:root {
    --bg: #f4efe6;
    --surface: #fffaf3;
    --ink: #1f2430;
    --muted: #6b7280;
    --accent: #b45309;
    --accent-dark: #7c2d12;
    --border: #e5d5bd;
    --success: #166534;
    --danger: #b91c1c;
    --shadow: 0 18px 40px rgba(92, 55, 18, 0.12);
    --radius: 22px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    color: var(--ink);
    background:
        radial-gradient(circle at top left, rgba(180, 83, 9, 0.18), transparent 30%),
        linear-gradient(145deg, #fbf7ef 0%, #f2e7d3 100%);
    min-height: 100vh;
}

body.modal-open {
    overflow: hidden;
}

code {
    font-family: Consolas, Monaco, monospace;
}

a {
    color: inherit;
    text-decoration: none;
}

.shell {
    display: grid;
    grid-template-columns: 300px 1fr;
    min-height: 100vh;
}

.sidebar {
    background: linear-gradient(180deg, #25160d 0%, #442515 100%);
    color: #f9efe0;
    padding: 32px 24px;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: stretch;
    gap: 24px;
}

.sidebar-profile {
    display: grid;
    grid-template-columns: 64px 1fr;
    gap: 14px;
    align-items: center;
    margin-bottom: 20px;
    padding: 14px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.08);
}

.sidebar-avatar {
    width: 64px;
    height: 64px;
    border-radius: 18px;
    object-fit: cover;
    border: 2px solid rgba(255, 255, 255, 0.16);
    background: rgba(255, 255, 255, 0.12);
}

.sidebar-label {
    display: block;
    font-size: 0.72rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #f7c998;
    margin-bottom: 4px;
}

.sidebar h1,
.topbar h2,
.panel h3 {
    margin: 0;
    font-family: Georgia, "Times New Roman", serif;
    font-weight: 700;
}

.sidebar-copy,
.assumption-card p,
.helper-text,
.empty-state,
table td,
table th,
label span,
.month-picker select,
.plain-list li,
.legend,
.stat-card span {
    color: var(--muted);
}

.eyebrow {
    margin: 0 0 8px;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    font-size: 0.72rem;
    color: #f7c998;
}

.nav {
    display: grid;
    gap: 10px;
    align-content: start;
}

.nav a {
    padding: 14px 16px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.06);
    transition: 0.2s ease;
}

.nav a.active,
.nav a:hover {
    background: rgba(255, 255, 255, 0.14);
    transform: translateX(3px);
}

.assumption-card {
    background: rgba(255, 255, 255, 0.08);
    padding: 18px;
    border-radius: 18px;
    line-height: 1.55;
    margin-top: auto;
}

.assumption-card strong {
    display: block;
    margin-bottom: 8px;
    color: #fff7ee;
}

.content {
    padding: 28px;
}

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

.topbar,
.panel-header,
.inline-fields,
.camera-actions,
.filter-form,
.action-cell {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
}

.month-picker select,
input,
select,
textarea,
.button {
    border-radius: 14px;
    border: 1px solid var(--border);
    padding: 12px 14px;
    font: inherit;
}

input,
select,
textarea {
    width: 100%;
    background: #fffdf8;
    color: var(--ink);
}

textarea {
    resize: vertical;
}

.flash {
    margin: 18px 0;
    padding: 14px 18px;
    border-radius: 16px;
    font-weight: 600;
}

.flash.success {
    background: rgba(22, 101, 52, 0.12);
    color: var(--success);
}

.flash.error {
    background: rgba(185, 28, 28, 0.12);
    color: var(--danger);
}

.stats-grid,
.summary-grid,
.photo-grid,
.two-column,
.report-sections {
    display: grid;
    gap: 20px;
}

.stats-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin: 22px 0;
}

.summary-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.report-grid {
    margin-top: 18px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.photo-grid {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.photo-grid.single-column {
    grid-template-columns: 1fr;
}

.two-column {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
}

.panel {
    background: rgba(255, 250, 243, 0.85);
    border: 1px solid rgba(229, 213, 189, 0.9);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
    margin-bottom: 22px;
    backdrop-filter: blur(10px);
}

.panel.inner {
    margin-bottom: 0;
    box-shadow: none;
    background: #fffdf8;
}

.stat-card,
.summary-grid > div,
.photo-card,
.calendar-cell {
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid rgba(229, 213, 189, 0.75);
    border-radius: 18px;
    padding: 18px;
}

.stat-card strong,
.summary-grid strong {
    display: block;
    margin-top: 10px;
    font-size: 1.85rem;
    color: var(--accent-dark);
}

.stack-form,
.month-picker,
label {
    display: grid;
    gap: 8px;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: auto;
    cursor: pointer;
    background: var(--accent);
    border-color: transparent;
    color: white;
    font-weight: 700;
}

.button.secondary {
    background: #fff6ea;
    color: var(--accent-dark);
    border-color: var(--border);
}

.button.danger {
    background: var(--danger);
}

.button.small {
    padding: 8px 12px;
    font-size: 0.88rem;
}

.table-wrap {
    overflow-x: auto;
    margin-top: 18px;
}

.table-avatar {
    width: 54px;
    height: 54px;
    border-radius: 14px;
    object-fit: cover;
    display: grid;
    place-items: center;
    background: #efe4d6;
    color: var(--accent-dark);
    font-size: 0.72rem;
    text-align: center;
}

.table-avatar.placeholder {
    padding: 6px;
}

.employee-photo-preview {
    display: grid;
    grid-template-columns: 92px 1fr;
    gap: 14px;
    align-items: center;
    padding: 14px;
    border-radius: 18px;
    background: #fff8ef;
    border: 1px solid rgba(229, 213, 189, 0.85);
}

.employee-photo-preview img {
    width: 92px;
    height: 92px;
    border-radius: 18px;
    object-fit: cover;
}

.employee-photo-preview strong,
.employee-photo-preview span {
    display: block;
}

.worklog-filter {
    margin-bottom: 18px;
}

.worklog-list {
    display: grid;
    gap: 18px;
}

.worklog-card {
    background: #fff8ef;
    border: 1px solid rgba(229, 213, 189, 0.85);
    border-radius: 18px;
    padding: 18px;
    display: grid;
    gap: 14px;
}

.worklog-card-head {
    display: flex;
    align-items: center;
    gap: 14px;
}

.worklog-card-head strong,
.worklog-card-head span {
    display: block;
}

.worklog-card-head span {
    color: var(--muted);
}

.work-block {
    background: rgba(255, 255, 255, 0.74);
    border: 1px solid rgba(229, 213, 189, 0.75);
    border-radius: 16px;
    padding: 14px 16px;
}

.work-block h4 {
    margin: 0 0 8px;
    color: var(--accent-dark);
    font-size: 1rem;
}

.work-block p {
    margin: 0;
    line-height: 1.6;
    color: var(--ink);
    white-space: normal;
    word-break: break-word;
}

.reopen-note {
    background: rgba(180, 83, 9, 0.08);
}

.reopen-note .task-meta {
    margin-bottom: 8px;
}

.task-card {
    background: #fff8ef;
    border: 1px solid rgba(229, 213, 189, 0.85);
    border-radius: 18px;
    padding: 12px;
    display: grid;
    gap: 10px;
}

.task-card.completed {
    background: rgba(22, 101, 52, 0.08);
}

.task-accordion {
    padding: 0;
    overflow: hidden;
}

.task-accordion-toggle {
    list-style: none;
    cursor: pointer;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
}

.task-accordion-toggle::-webkit-details-marker {
    display: none;
}

.task-accordion-body {
    padding: 0 14px 14px;
    border-top: 1px solid rgba(229, 213, 189, 0.75);
}

.task-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.task-heading {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.task-heading > div {
    display: grid;
    gap: 4px;
}

.task-header strong {
    font-size: 1.05rem;
    line-height: 1.45;
}

.task-staff-name {
    color: var(--muted);
}

.task-accordion-meta {
    display: flex;
    align-items: center;
    gap: 10px;
}

.task-meta {
    margin: 0;
    color: var(--muted);
}

.priority-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 78px;
    padding: 7px 10px;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 700;
    border: 1px solid rgba(229, 213, 189, 0.85);
}

.priority-badge.low {
    background: rgba(14, 116, 144, 0.12);
    color: #0f5f78;
}

.priority-badge.medium {
    background: rgba(245, 158, 11, 0.14);
    color: #9a5a00;
}

.priority-badge.high {
    background: rgba(185, 28, 28, 0.12);
    color: #9b1c1c;
}

.sortable-task-list {
    gap: 16px;
}

.draggable-task {
    cursor: grab;
}

.draggable-task.dragging {
    opacity: 0.55;
    border-style: dashed;
}

.drag-handle {
    border: 0;
    background: transparent;
    color: var(--muted);
    cursor: grab;
    font-size: 1.2rem;
    line-height: 1;
    padding: 2px 2px;
}

.task-edit-form {
    margin-top: 10px;
}

.task-actions {
    justify-content: flex-start;
}

.task-delete-form {
    margin-top: -2px;
}

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

th,
td {
    text-align: left;
    padding: 14px 10px;
    border-bottom: 1px solid rgba(229, 213, 189, 0.85);
}

.camera-box {
    display: grid;
    gap: 12px;
}

.dashboard-checkin-row {
    align-items: start;
}

.dashboard-checkin-panel .camera-stage {
    max-height: 360px;
}

.dashboard-checkin-panel #camera-feed,
.dashboard-checkin-panel #camera-preview {
    min-height: 0;
    height: 360px;
}

.dashboard-checkin-panel .camera-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
}

.dashboard-summary-panel .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.camera-stage {
    position: relative;
    border-radius: 22px;
    overflow: hidden;
    background: #d9d4c9;
}

#camera-feed,
#camera-preview,
.photo-card img {
    width: 100%;
    border-radius: 18px;
    min-height: 220px;
    object-fit: cover;
    background: #d9d4c9;
}

#camera-preview {
    display: none;
}

.camera-guide {
    position: absolute;
    inset: 0;
    display: grid;
    align-content: end;
    justify-items: center;
    padding: 20px;
    pointer-events: none;
    background: linear-gradient(180deg, rgba(22, 15, 10, 0.08), rgba(22, 15, 10, 0.28));
}

.camera-guide-frame {
    position: absolute;
    top: 10%;
    left: 50%;
    width: min(56%, 320px);
    aspect-ratio: 3 / 4;
    transform: translateX(-50%);
    border: 3px solid rgba(255, 255, 255, 0.92);
    border-radius: 160px;
    box-shadow: 0 0 0 999px rgba(20, 14, 10, 0.24);
}

.camera-guide span {
    position: relative;
    z-index: 1;
    background: rgba(20, 14, 10, 0.68);
    color: #fff7ee;
    padding: 10px 14px;
    border-radius: 999px;
    font-size: 0.92rem;
    letter-spacing: 0.01em;
}

.photo-card {
    display: grid;
    gap: 12px;
}

.photo-card strong,
.photo-card span {
    display: block;
}

.live-register-card {
    gap: 16px;
}

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

.live-register-thumb {
    display: grid;
    gap: 8px;
}

.live-register-thumb img {
    min-height: 150px;
    max-height: 210px;
}

.live-register-details {
    display: grid;
    gap: 6px;
}

.legend {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.dot {
    width: 12px;
    height: 12px;
    display: inline-block;
    border-radius: 999px;
    margin-right: 6px;
}

.calendar {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 10px;
}

.calendar-head {
    font-weight: 700;
    text-align: center;
    color: var(--accent-dark);
}

.calendar-cell {
    min-height: 110px;
    display: grid;
    gap: 6px;
    align-content: start;
}

.calendar-cell-button {
    width: 100%;
    text-align: left;
    font: inherit;
    cursor: pointer;
    background-size: cover;
    background-position: center;
    color: var(--ink);
}

.calendar-cell-button.has-photo {
    color: #fff7ee;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
}

.calendar-cell-button.has-photo span,
.calendar-cell-button.has-photo small,
.calendar-cell-button.has-photo strong {
    color: inherit;
}

.calendar-cell.empty {
    background: transparent;
    border-style: dashed;
}

.calendar-cell.today {
    outline: 2px solid var(--accent);
}

.calendar-cell.present,
.dot.present {
    background: rgba(22, 101, 52, 0.12);
}

.calendar-cell.leave-paid,
.dot.leave-paid {
    background: rgba(14, 116, 144, 0.12);
}

.calendar-cell.leave-unpaid,
.dot.leave-unpaid {
    background: rgba(185, 28, 28, 0.12);
}

.calendar-cell.absent,
.dot.absent {
    background: rgba(245, 158, 11, 0.14);
}

.calendar-cell.off,
.dot.off {
    background: rgba(107, 114, 128, 0.14);
}

.attendance-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: grid;
    place-items: center;
    padding: 16px;
}

.attendance-modal[hidden] {
    display: none !important;
}

.attendance-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(20, 14, 10, 0.48);
}

.attendance-modal-dialog {
    position: relative;
    z-index: 1;
    width: min(84vw, 1080px);
    max-height: 84vh;
    background: #fffaf3;
    border: 1px solid rgba(229, 213, 189, 0.9);
    border-radius: 24px;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.attendance-modal-content {
    padding: 20px;
    overflow: auto;
}

.attendance-modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 44px;
    height: 44px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: #fff6ea;
    color: var(--accent-dark);
    font: inherit;
    cursor: pointer;
    font-weight: 700;
    z-index: 2;
}

.attendance-modal-image-wrap {
    border-radius: 18px;
    overflow: hidden;
    background: #e8dcc8;
}

.attendance-modal-image-wrap .helper-text {
    display: block;
    text-align: center;
    padding: 10px 12px 8px;
}

.attendance-modal-image-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.attendance-modal-image-wrap img {
    width: 100%;
    display: block;
    height: min(30vh, 320px);
    object-fit: cover;
    background: #f4efe6;
}

.attendance-modal-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
    align-items: start;
}

.attendance-modal-visual,
.attendance-modal-info {
    display: grid;
    gap: 14px;
}

.attendance-modal-info .work-block {
    padding: 16px 18px;
}

.attendance-modal-info .work-block p {
    line-height: 1.55;
}

.attendance-modal-info-bottom {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.plain-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    gap: 10px;
}

.plain-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 14px;
    background: #fff8ef;
}

.plain-list a {
    color: var(--accent-dark);
    font-weight: 700;
}

.attendance-log-item {
    align-items: flex-start;
    flex-direction: column;
}

.timeline-list li {
    align-items: center;
}

.timeline-note {
    margin-top: -4px;
    padding-top: 0 !important;
    color: var(--muted);
    font-size: 0.92rem;
    background: transparent !important;
}

.compact-inline-form {
    width: 100%;
    margin-top: 10px;
    grid-template-columns: minmax(180px, 220px) auto;
    align-items: end;
}

.client-picker-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
}

.icon-button {
    width: 48px;
    min-width: 48px;
    height: 48px;
    padding: 0;
    font-size: 1.6rem;
    line-height: 1;
}

.client-create-dialog {
    width: min(92vw, 760px);
}

.read-only-card {
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid rgba(229, 213, 189, 0.75);
    border-radius: 18px;
    padding: 16px 18px;
    display: grid;
    gap: 6px;
}

.read-only-card strong {
    color: var(--accent-dark);
    font-size: 1.1rem;
}

.login-page {
    background: #f5f5f5;
}

.login-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    width: 100%;
}

.login-card {
    width: min(100%, 615px);
    background: #ffffff;
    border: 1px solid #d7dce4;
    border-radius: 12px;
    padding: 38px 36px 34px;
    box-shadow: 0 16px 36px rgba(15, 23, 42, 0.12);
    display: grid;
    gap: 24px;
}

.login-header {
    text-align: center;
    display: grid;
    gap: 10px;
}

.login-card h1 {
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    font-size: 2.15rem;
    color: #2b2f36;
    margin: 0;
}

.login-copy {
    color: #526071;
    line-height: 1.6;
    margin: 0;
}

.login-form label span {
    color: #12253f;
    font-size: 1rem;
}

.login-form input {
    border-radius: 12px;
    border: 1px solid #d3dbe7;
    background: #ffffff;
    padding: 14px 16px;
}

.password-row {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: stretch;
}

.password-row input {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    margin: 0;
}

.password-toggle {
    min-width: 94px;
    border: 1px solid #8492a6;
    border-left: 0;
    background: #ffffff;
    color: #6c7b8f;
    font: inherit;
    border-top-right-radius: 12px;
    border-bottom-right-radius: 12px;
    cursor: pointer;
    padding: 0 18px;
}

.password-toggle:hover {
    background: #f8fafc;
}

.login-submit {
    width: 100%;
    border-radius: 10px;
    background: #1f6feb;
    padding: 14px 16px;
    font-size: 1.05rem;
}

.login-submit:hover {
    background: #1a61cf;
}

.login-note {
    background: #f6f9fc;
    color: #364152;
    border: 1px solid #dde5ef;
}

.login-note p {
    color: #526071;
}

.login-note code {
    color: #1f6feb;
}

@media (max-width: 1024px) {
    .shell,
    .two-column,
    .stats-grid,
    .summary-grid,
        .report-grid {
        grid-template-columns: 1fr;
    }

    .attendance-modal-dialog {
        width: min(94vw, 680px);
        max-height: 88vh;
    }

    .attendance-modal-layout {
        grid-template-columns: 1fr;
    }

    .attendance-modal-image-grid,
    .attendance-modal-info-bottom {
        grid-template-columns: 1fr;
    }

    .attendance-modal-image-wrap img {
        max-height: 38vh;
        height: auto;
    }
}

@media (max-width: 720px) {
    .content {
        padding: 18px;
    }

    .panel {
        padding: 18px;
    }

    .topbar,
    .topbar-actions,
    .panel-header,
    .inline-fields,
    .camera-actions,
    .filter-form,
    .action-cell {
        flex-direction: column;
        align-items: stretch;
    }
}
