/* Attendance Register – one stylesheet for every page */
:root {
    --bg: #eef2f1;
    --surface: #ffffff;
    --ink: #1c2b33;
    --ink-soft: #5b6b72;
    --line: #d5dedc;
    --side: #14343b;
    --side-ink: #cfe0dd;
    --accent: #0f6e6a;
    --accent-dark: #0a524f;

    --present: #2f7d4f;
    --late: #a86b12;
    --half: #6b5ca5;
    --absent: #b83a3a;
    --leave: #2f6fa8;
    --off: #7b8a8f;

    --radius-s: 4px;
    --radius-m: 8px;
    font-size: 16px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: "Public Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
    line-height: 1.5;
}

a { color: var(--accent); }
a:hover { color: var(--accent-dark); }

:focus-visible {
    outline: 3px solid #f2b705;
    outline-offset: 2px;
}

h1, h2 { line-height: 1.2; margin: 0; }
h1 { font-size: 1.75rem; font-weight: 700; letter-spacing: -0.01em; }
h2 { font-size: 1.125rem; font-weight: 600; }

.muted { color: var(--ink-soft); }
.small { font-size: 0.875rem; }
td, .stat strong, .punch-clock time, .login-clock span { font-variant-numeric: tabular-nums; }

/* ---------- Layout ---------- */
.shell {
    display: grid;
    grid-template-columns: 240px 1fr;
    min-height: 100vh;
}

.sidebar {
    background: var(--side);
    color: var(--side-ink);
    padding: 1.5rem 1rem;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    color: #fff;
    font-weight: 700;
    text-decoration: none;
    font-size: 1.05rem;
}
.brand:hover { color: #fff; }

/* A small clock face as the logo mark */
.brand-mark {
    width: 22px; height: 22px;
    border: 2px solid #fff;
    border-radius: 50%;
    position: relative;
    flex-shrink: 0;
}
.brand-mark::before, .brand-mark::after {
    content: "";
    position: absolute;
    left: 50%; bottom: 50%;
    width: 2px;
    background: #fff;
    transform-origin: bottom center;
}
.brand-mark::before { height: 7px; transform: translateX(-50%); }
.brand-mark::after  { height: 5px; transform: translateX(-50%) rotate(90deg); }

.role-tag {
    margin: 0.35rem 0 1.5rem 2rem;
    font-size: 0.8rem;
    color: #8fb3ad;
}

.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar nav a {
    color: var(--side-ink);
    text-decoration: none;
    padding: 0.55rem 0.75rem;
    border-radius: var(--radius-s);
    border-left: 3px solid transparent;
}
.sidebar nav a:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }
.sidebar nav a.active {
    background: rgba(255, 255, 255, 0.1);
    border-left-color: #f2b705;
    color: #fff;
    font-weight: 600;
}

.sidebar-foot {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    padding: 1rem 0.75rem 0;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    font-size: 0.9rem;
}
.sidebar-foot strong { color: #fff; }
.sidebar-foot span { color: #8fb3ad; font-size: 0.8rem; }
.sidebar-foot a { color: var(--side-ink); margin-top: 0.5rem; }

.content {
    padding: 2rem clamp(1rem, 3vw, 2.5rem) 3rem;
    min-width: 0;
    max-width: 1200px;
}

.page-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}
.today { margin: 0; color: var(--ink-soft); }

.section-title { margin: 2rem 0 0.75rem; }

/* ---------- Panels ---------- */
.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-m);
    padding: 1.25rem;
    margin-top: 1rem;
}
.panel > h2 { margin-bottom: 1rem; }
.panel-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}
.form-panel { max-width: 760px; }

.grid-2 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1rem;
    align-items: start;
}
.grid-2 .panel { margin-top: 0; }

.empty {
    padding: 2rem 1rem;
    text-align: center;
    color: var(--ink-soft);
    margin: 0;
}

.details {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 0.5rem 1.5rem;
    margin: 0;
}
.details dt { color: var(--ink-soft); }
.details dd { margin: 0; }

/* ---------- Stats row ---------- */
.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.75rem;
}
.stat {
    background: var(--surface);
    border: 1px solid var(--line);
    border-top: 4px solid var(--present);
    border-radius: var(--radius-s);
    padding: 0.9rem 1rem;
}
.stat strong { display: block; font-size: 1.75rem; font-weight: 700; line-height: 1.1; }
.stat strong small { font-size: 0.95rem; color: var(--ink-soft); font-weight: 500; }
.stat span { color: var(--ink-soft); font-size: 0.875rem; }
.stat-late    { border-top-color: var(--late); }
.stat-half    { border-top-color: var(--half); }
.stat-leave   { border-top-color: var(--leave); }
.stat-absent  { border-top-color: var(--absent); }
.stat-pending { border-top-color: var(--off); }

/* ---------- Punch clock (employee home) ---------- */
.punch {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-m);
    overflow: hidden;
}
.punch-clock {
    background: var(--side);
    color: #fff;
    padding: 2.5rem 2rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    border-right: 8px solid var(--off);
}
.punch-in   .punch-clock { border-right-color: var(--present); }
.punch-done .punch-clock { border-right-color: var(--accent); }
.punch-leave .punch-clock { border-right-color: var(--leave); }

.punch-clock time {
    font-size: clamp(2.5rem, 5.5vw, 4.25rem);
    font-weight: 700;
    white-space: nowrap;
    letter-spacing: -0.03em;
    line-height: 1;
}
.punch-clock p { margin: 0.75rem 0 0; color: #8fb3ad; }

.punch-card { padding: 1.75rem; display: flex; flex-direction: column; justify-content: center; gap: 1.25rem; }
.punch-times { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.75rem; }
.punch-times span { display: block; font-size: 0.8rem; color: var(--ink-soft); }
.punch-times strong { font-size: 1.1rem; }
.punch-running { margin: 0 0 0.75rem; }

.btn.btn-punch {
    width: 100%;
    padding: 1rem;
    font-size: 1.2rem;
    font-weight: 700;
    background: var(--present);
    border-color: var(--present);
    color: #fff;
}
.btn.btn-punch:hover { background: #266843; border-color: #266843; color: #fff; }
.btn.btn-punch-out { background: var(--ink); border-color: var(--ink); }
.btn.btn-punch-out:hover { background: #0d1a20; border-color: #0d1a20; }
.btn-punch:active { transform: translateY(1px); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.925rem; }
th {
    text-align: left;
    font-weight: 600;
    color: var(--ink-soft);
    font-size: 0.825rem;
    padding: 0.6rem 0.75rem;
    border-bottom: 2px solid var(--line);
    white-space: nowrap;
}
td {
    padding: 0.65rem 0.75rem;
    border-bottom: 1px solid var(--line);
    vertical-align: top;
}
tbody tr:hover { background: #f6f9f8; }
.row-muted td { color: var(--ink-soft); background: #f8faf9; }
.num { text-align: right; }
.text-absent { color: var(--absent); font-weight: 600; }

.actions { white-space: nowrap; text-align: right; }
.actions form { display: inline; }
.actions > * + * { margin-left: 0.75rem; }
.actions form button + button { margin-left: 0.75rem; }

/* ---------- Status badges ---------- */
.badge {
    display: inline-block;
    padding: 0.1rem 0.55rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
    border: 1px solid currentColor;
    white-space: nowrap;
}
.badge-present  { color: var(--present); background: #e8f3ec; }
.badge-late     { color: var(--late);    background: #fbf1e1; }
.badge-half_day { color: var(--half);    background: #efedf7; }
.badge-absent   { color: var(--absent);  background: #f9e9e9; }
.badge-leave    { color: var(--leave);   background: #e7f0f8; }
.badge-off, .badge-pending { color: var(--off); background: #f1f3f3; }

.meter {
    display: inline-block;
    width: 90px;
    height: 8px;
    background: #e3e9e8;
    border-radius: 4px;
    overflow: hidden;
    vertical-align: middle;
    margin-right: 0.4rem;
}
.meter span { display: block; height: 100%; background: var(--accent); }

/* ---------- Forms ---------- */
label { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.875rem; font-weight: 500; }
input, select {
    font: inherit;
    font-size: 0.95rem;
    padding: 0.55rem 0.7rem;
    border: 1px solid #b9c6c3;
    border-radius: var(--radius-s);
    background: #fff;
    color: var(--ink);
    min-width: 0;
}
input:focus, select:focus { border-color: var(--accent); }

.stack { display: flex; flex-direction: column; gap: 1rem; }

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem 1.25rem;
}
.span-2, .form-actions { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 0.75rem; margin-top: 0.5rem; }

.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.75rem;
    margin-bottom: 1rem;
}
.toolbar .grow { flex: 1 1 260px; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font: inherit;
    font-weight: 600;
    font-size: 0.925rem;
    padding: 0.55rem 1rem;
    border: 1px solid #b9c6c3;
    border-radius: var(--radius-s);
    background: #fff;
    color: var(--ink);
    text-decoration: none;
    cursor: pointer;
}
.btn:hover { background: #f1f5f4; color: var(--ink); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); color: #fff; }
.btn-small { padding: 0.35rem 0.75rem; font-size: 0.85rem; }
.btn-block { width: 100%; }

button.link {
    background: none;
    border: 0;
    padding: 0;
    font: inherit;
    color: var(--accent);
    text-decoration: underline;
    cursor: pointer;
}
button.link.danger { color: var(--absent); }

.pager { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 1rem; }
.pager a {
    padding: 0.3rem 0.65rem;
    border: 1px solid var(--line);
    border-radius: var(--radius-s);
    text-decoration: none;
}
.pager a.current { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ---------- Alerts ---------- */
.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-s);
    border-left: 4px solid;
    margin-bottom: 1rem;
    background: var(--surface);
}
.alert-success { border-color: var(--present); background: #e8f3ec; }
.alert-error   { border-color: var(--absent);  background: #f9e9e9; }
.alert-info    { border-color: var(--leave);   background: #e7f0f8; }

/* ---------- Login ---------- */
.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 1rem;
    background: var(--side);
}
.login-card {
    width: 100%;
    max-width: 400px;
    background: var(--surface);
    border-radius: var(--radius-m);
    padding: 2rem;
}
.login-card h1 { font-size: 1.4rem; }
.login-card > p { margin: 0.35rem 0 1.5rem; }
.login-clock {
    display: flex;
    align-items: baseline;
    gap: 0.75rem;
    padding-bottom: 1.25rem;
    margin-bottom: 1.25rem;
    border-bottom: 1px solid var(--line);
}
.login-clock span { font-size: 2.75rem; font-weight: 700; letter-spacing: -0.03em; line-height: 1; }
.login-clock small { color: var(--ink-soft); }

/* ---------- Small screens ---------- */
@media (max-width: 860px) {
    .shell { grid-template-columns: 1fr; }
    .sidebar {
        position: static;
        height: auto;
        padding: 1rem;
    }
    .role-tag { margin: 0.25rem 0 0.75rem 2rem; }
    .sidebar nav { flex-direction: row; flex-wrap: wrap; }
    .sidebar nav a { border-left: 0; border-bottom: 3px solid transparent; }
    .sidebar nav a.active { border-bottom-color: #f2b705; }
    .sidebar-foot { flex-direction: row; align-items: baseline; gap: 0.75rem; margin-top: 0.75rem; }
    .sidebar-foot a { margin: 0 0 0 auto; }

    .punch { grid-template-columns: 1fr; }
    .punch-clock { border-right: 0; border-bottom: 8px solid var(--off); padding: 1.75rem 1.25rem; }
    .punch-in .punch-clock { border-bottom-color: var(--present); }
    .punch-done .punch-clock { border-bottom-color: var(--accent); }
    .punch-leave .punch-clock { border-bottom-color: var(--leave); }

    .form-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; }
}
