/* Ready 2 Clock — design tokens, light and dark */
:root {
    --bg: #f6f7f9;
    --surface: #ffffff;
    --surface-2: #f1f3f6;
    --border: #e4e7ec;
    --text: #0f1729;
    --text-2: #5b6576;
    --text-3: #8a93a3;

    --brand: #5b5bf0;
    --brand-hover: #4a4ae0;
    --brand-solid: #5b5bf0;        /* button fill: keeps white text readable in both themes */
    --brand-solid-hover: #4a4ae0;
    --brand-soft: #ededfd;
    --success: #12b76a;
    --success-hover: #0ea35d;
    --success-soft: #e7f8ef;
    --warning: #f59e0b;
    --warning-hover: #e08e06;
    --warning-soft: #fef4e2;
    --danger: #ef4444;
    --danger-hover: #dc3535;
    --danger-soft: #fdecec;

    --radius: 16px;
    --radius-sm: 10px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 4px 16px rgba(16, 24, 40, .06);
    --shadow-lg: 0 24px 64px rgba(16, 24, 40, .18);
    --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;

    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0c0d10;
        --surface: #15171c;
        --surface-2: #1d2027;
        --border: #262a33;
        --text: #eef0f4;
        --text-2: #a3abb9;
        --text-3: #6d7584;

        --brand: #7c7cf5;
        --brand-hover: #8f8ff7;
        --brand-solid: #5b5bf0;
        --brand-solid-hover: #6b6bf3;
        --brand-soft: #23234a;
        --success-soft: #0f2a1e;
        --warning-soft: #2e2410;
        --danger-soft: #331718;

        --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
        --shadow-lg: 0 24px 64px rgba(0, 0, 0, .6);

        color-scheme: dark;
    }
}

/* Base */
*, *::before, *::after { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 15px/1.5 var(--font);
    -webkit-font-smoothing: antialiased;
    font-feature-settings: 'cv11', 'ss01';
}

h1, h2, p { margin: 0; }
h1 { font-size: 28px; font-weight: 700; letter-spacing: -.02em; }
h2 { font-size: 17px; font-weight: 600; letter-spacing: -.01em; }
a { color: var(--brand); text-decoration: none; }
[hidden] { display: none !important; }

.icon { width: 18px; height: 18px; flex: none; }
.muted { color: var(--text-2); font-size: 14px; }
.eyebrow { color: var(--text-2); font-size: 13px; font-weight: 500; text-transform: uppercase; letter-spacing: .06em; margin-bottom: 4px; }
.stack { display: grid; gap: 16px; }
.container { max-width: 1120px; margin: 0 auto; padding: 32px 20px 64px; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 40px;
    padding: 0 16px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    color: var(--text);
    font: 600 14px/1 var(--font);
    cursor: pointer;
    white-space: nowrap;
    transition: background .15s, transform .1s, box-shadow .15s, opacity .15s;
    position: relative;
}
.btn:active:not(:disabled) { transform: scale(.98); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--brand-soft), 0 0 0 1px var(--brand); }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.btn-primary { background: var(--brand-solid); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--brand-solid-hover); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover:not(:disabled) { background: var(--success-hover); }
.btn-warning { background: var(--warning); color: #fff; }
.btn-warning:hover:not(:disabled) { background: var(--warning-hover); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: var(--danger-hover); }
.btn-soft { background: var(--surface-2); border-color: var(--border); }
.btn-soft:hover:not(:disabled) { background: var(--border); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }

.btn-sm { height: 34px; padding: 0 12px; font-size: 13px; }
.btn-lg { height: 46px; font-size: 15px; }
.btn-xl { height: 54px; font-size: 16px; border-radius: 14px; }
.btn-xl .icon { width: 20px; height: 20px; }
.btn-icon { width: 38px; height: 38px; padding: 0; }
.btn-block { width: 100%; }

.btn.is-loading { color: transparent !important; }
.btn.is-loading::after {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, .5);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin .7s linear infinite;
}
.btn-soft.is-loading::after, .btn-ghost.is-loading::after { border-color: var(--border); border-top-color: var(--text); }

@keyframes spin { to { transform: rotate(360deg); } }
.spinner {
    width: 22px;
    height: 22px;
    border: 2px solid rgba(255, 255, 255, .25);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin .7s linear infinite;
}

/* Forms */
.field { display: grid; gap: 6px; }
.field-label { font-size: 13px; font-weight: 500; color: var(--text-2); }
.input-wrap { position: relative; display: block; }
.input-wrap .icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); z-index: 1; width: 17px; height: 17px; color: var(--text-3); pointer-events: none; transition: color .15s; }
.input-wrap:focus-within .icon { color: var(--brand); }
input[type=email], input[type=password], input[type=date], select {
    width: 100%;
    height: 44px;
    padding: 0 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font: 15px var(--font);
    transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
input::placeholder { color: var(--text-3); }
.input-wrap input { padding-left: 42px; }
input[type=password]:not(:placeholder-shown) { letter-spacing: .12em; }
/* Keep browser autofill from painting a bright background over the themed input */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
    -webkit-text-fill-color: var(--text);
    -webkit-box-shadow: 0 0 0 1000px var(--surface) inset;
    caret-color: var(--text);
    transition: background-color 9999s;
}

/* Alerts */
.alert {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    font-size: 14px;
}
.alert .icon { margin-top: 1px; }
.alert-error { background: var(--danger-soft); color: var(--danger); }

/* Top bar */
.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    background: color-mix(in srgb, var(--bg) 80%, transparent);
    backdrop-filter: saturate(180%) blur(12px);
    -webkit-backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid var(--border);
}
.topbar-inner {
    max-width: 1120px;
    margin: 0 auto;
    padding: 0 20px;
    height: 60px;
    display: flex;
    align-items: center;
    gap: 28px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--text); letter-spacing: -.01em; }
.brand-mark {
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    border-radius: 9px;
    background: linear-gradient(135deg, var(--brand), #8b5cf6);
    color: #fff;
    box-shadow: 0 4px 12px rgba(91, 91, 240, .35);
}
.brand-mark .icon { width: 17px; height: 17px; stroke-width: 2.5; }
.brand-mark-lg { width: 52px; height: 52px; border-radius: 15px; }
.brand-mark-lg .icon { width: 28px; height: 28px; }
.nav { display: flex; gap: 4px; }
.nav a { padding: 7px 12px; border-radius: 8px; color: var(--text-2); font-weight: 500; font-size: 14px; }
.nav a:hover { color: var(--text); background: var(--surface-2); }
.nav a.is-active { color: var(--text); background: var(--surface-2); }
.account { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.avatar {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--brand-soft);
    color: var(--brand);
    font-size: 13px;
    font-weight: 700;
}

/* Login */
.auth {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
    background:
        radial-gradient(60% 50% at 20% 0%, color-mix(in srgb, var(--brand) 14%, transparent), transparent),
        radial-gradient(50% 40% at 100% 100%, color-mix(in srgb, #8b5cf6 12%, transparent), transparent);
}
.auth-card {
    width: 100%;
    max-width: 400px;
    padding: 36px 32px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 22px;
    box-shadow: var(--shadow);
    display: grid;
    gap: 24px;
}
.auth-brand { text-align: center; display: grid; justify-items: center; gap: 8px; }
.auth-brand h1 { font-size: 24px; margin-top: 8px; }
.auth-brand p { color: var(--text-2); }
.auth-foot { margin-top: 20px; color: var(--text-3); font-size: 13px; }

/* Page */
.page-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
}
.clocks { display: flex; gap: 10px; }
.clock {
    display: grid;
    padding: 8px 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    min-width: 116px;
}
.clock-label { font-size: 12px; color: var(--text-3); font-weight: 500; }
.clock-time { font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; }

.dashboard {
    display: grid;
    grid-template-columns: minmax(300px, 380px) 1fr;
    gap: 20px;
    align-items: start;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
    min-width: 0;
}
.card-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 20px;
}

/* Status hero */
.hero { --accent: var(--text-3); --accent-soft: var(--surface-2); position: sticky; top: 84px; }
.hero.state-in { --accent: var(--success); --accent-soft: var(--success-soft); }
.hero.state-break { --accent: var(--warning); --accent-soft: var(--warning-soft); }
.hero-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 13px;
    font-weight: 600;
}
.status-pill .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.state-in .status-pill .dot, .state-break .status-pill .dot { animation: pulse 1.8s ease-out infinite; }
@keyframes pulse {
    0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 55%, transparent); }
    100% { box-shadow: 0 0 0 8px transparent; }
}

.ring {
    --progress: 0;
    position: relative;
    width: min(240px, 100%);
    aspect-ratio: 1;
    margin: 28px auto;
    border-radius: 50%;
    background: conic-gradient(var(--accent) calc(var(--progress) * 360deg), var(--surface-2) 0);
    display: grid;
    place-items: center;
    transition: background .4s;
}
.ring-inner {
    width: calc(100% - 24px);
    aspect-ratio: 1;
    border-radius: 50%;
    background: var(--surface);
    display: grid;
    place-content: center;
    text-align: center;
    gap: 4px;
}
.ring-value { font-size: 46px; font-weight: 700; letter-spacing: -.03em; font-variant-numeric: tabular-nums; line-height: 1; }
.ring-value small { font-size: 22px; color: var(--text-3); font-weight: 600; }
.ring-label { color: var(--text-2); font-size: 13px; font-weight: 500; }
.ring-label span { font-variant-numeric: tabular-nums; color: var(--warning); font-weight: 600; }
.ring-label small { font-size: inherit; }

.hero-note {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin: -12px 0 20px;
    color: var(--text-2);
    font-size: 13px;
}
.hero-note .icon { width: 15px; height: 15px; }
.hero-actions { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 10px; }

/* Toolbar */
.toolbar { display: flex; align-items: center; gap: 6px; }
.segmented {
    display: inline-flex;
    padding: 3px;
    border-radius: 11px;
    background: var(--surface-2);
}
.segmented a {
    display: inline-flex;
    align-items: center;
    height: 32px;
    padding: 0 12px;
    border-radius: 8px;
    color: var(--text-2);
    font-size: 13px;
    font-weight: 600;
}
.segmented a:hover { color: var(--text); }
.segmented a.is-active { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .1); }
.segmented .icon { width: 16px; height: 16px; }

.popover { position: relative; }
.popover summary { list-style: none; }
.popover summary::-webkit-details-marker { display: none; }
.popover[open] summary { background: var(--surface-2); color: var(--text); }
.popover-body {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    z-index: 5;
    width: 240px;
    padding: 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: var(--shadow-lg);
}

/* Stats */
.stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1px;
    background: var(--border);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 20px;
}
.stat { background: var(--surface); padding: 14px 16px; display: grid; gap: 2px; }
.stat-label { font-size: 12px; color: var(--text-3); font-weight: 500; text-transform: uppercase; letter-spacing: .05em; }
.stat-value { font-size: 22px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }

/* Chart */
.chart {
    display: grid;
    grid-template-columns: repeat(var(--cols), 1fr);
    gap: clamp(3px, 1.2vw, 10px);
    height: 140px;
    padding: 4px 0 0;
    margin-bottom: 20px;
}
.bar { display: grid; grid-template-rows: 1fr auto; gap: 6px; min-width: 0; }
.bar-fill {
    align-self: end;
    min-height: 3px;
    border-radius: 6px 6px 3px 3px;
    background: color-mix(in srgb, var(--brand) 30%, var(--surface-2));
    transition: background .15s;
}
.bar:hover .bar-fill { background: color-mix(in srgb, var(--brand) 55%, var(--surface-2)); }
.bar.is-today .bar-fill { background: var(--brand); }
.bar-label { text-align: center; font-size: 11px; color: var(--text-3); font-weight: 500; }
.bar.is-today .bar-label { color: var(--brand); font-weight: 700; }

/* Day list */
.days { display: grid; }
.day {
    display: grid;
    grid-template-columns: 48px 1fr auto;
    gap: 16px;
    align-items: center;
    padding: 14px 8px;
    border-top: 1px solid var(--border);
}
.day.is-today .day-num { background: var(--brand); color: #fff; }
.day-date { display: grid; justify-items: center; }
.day-num {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--surface-2);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}
.day-name { font-size: 11px; color: var(--text-3); font-weight: 600; text-transform: uppercase; margin-top: 3px; }
.shifts { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.shifts li { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.shift-times { font-variant-numeric: tabular-nums; font-weight: 500; }
.shift-times .arrow { color: var(--text-3); margin: 0 4px; }
.live { color: var(--success); font-weight: 600; }
.chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--warning-soft);
    color: var(--warning);
    font-size: 12px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}
.chip .icon { width: 13px; height: 13px; }
.day-total { font-weight: 700; font-size: 16px; font-variant-numeric: tabular-nums; }

.empty { display: grid; justify-items: center; gap: 10px; padding: 40px 0; color: var(--text-3); border-top: 1px solid var(--border); }
.empty .icon { width: 32px; height: 32px; }
.footnote { margin-top: 16px; font-size: 12px; color: var(--text-3); }

/* Dialog */
.modal {
    width: min(720px, calc(100vw - 32px));
    max-height: calc(100vh - 32px);
    padding: 24px;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow-lg);
}
.modal[open] { animation: pop .2s ease-out; }
.modal::backdrop { background: rgba(10, 12, 20, .55); backdrop-filter: blur(4px); }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.modal-head h2 { font-size: 20px; }
.modal .alert { margin-top: 16px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

.capture-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.capture {
    position: relative;
    aspect-ratio: 4 / 3;
    border-radius: 14px;
    overflow: hidden;
    background: #111318;
}
.capture video, .capture iframe { display: block; width: 100%; height: 100%; border: 0; object-fit: cover; }
.capture video { transform: scaleX(-1); /* mirrored preview; the saved photo is not mirrored */ }
.capture-status {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 16px;
    text-align: center;
    color: #d4d8e0;
    font-size: 13px;
    background: #111318;
}
.capture-status .icon { width: 26px; height: 26px; color: var(--warning); flex: none; }
.capture-status .status-text { max-width: 300px; line-height: 1.45; font-size: 12.5px; }
.capture-status:has(.status-text) { justify-content: safe center; overflow-y: auto; gap: 8px; }
.capture-status .status-text strong { display: block; color: #fff; font-size: 14px; margin-bottom: 2px; }
.capture-status .status-text b { color: #fff; font-weight: 600; }
.btn-on-dark { background: rgba(255, 255, 255, .14); color: #fff; }
.btn-on-dark:hover { background: rgba(255, 255, 255, .24); }
.capture-tag {
    position: absolute;
    left: 10px;
    bottom: 10px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    border-radius: 999px;
    background: rgba(0, 0, 0, .55);
    backdrop-filter: blur(6px);
    color: #fff;
    font-size: 12px;
    font-weight: 600;
}
.capture-tag .icon { width: 14px; height: 14px; }
.capture-tag.is-ok { background: rgba(18, 183, 106, .9); }

/* Toasts */
.toasts {
    position: fixed;
    left: 50%;
    bottom: 24px;
    transform: translateX(-50%);
    display: grid;
    gap: 8px;
    z-index: 100;
    width: max-content;
    max-width: calc(100vw - 32px);
}
.toast {
    padding: 12px 18px;
    border-radius: 12px;
    background: var(--text);
    color: var(--bg);
    font-weight: 500;
    font-size: 14px;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    transform: translateY(10px);
    transition: opacity .25s, transform .25s;
}
.toast.is-visible { opacity: 1; transform: none; }
.toast-error { background: var(--danger); color: #fff; }

/* Admin table */
.filters { display: grid; grid-template-columns: 2fr 1fr 1fr auto; gap: 12px; align-items: end; margin-bottom: 20px; }
.filters .actions { display: flex; gap: 8px; }
.filters .btn { height: 44px; }
.people { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 20px; }
.person {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px 8px 8px;
    border: 1px solid var(--border);
    border-radius: 12px;
    font-size: 13px;
}
.person strong { display: block; font-size: 14px; }
.person span.muted { font-size: 12px; }
.table-wrap { overflow-x: auto; margin: 0 -24px; padding: 0 24px; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.table th {
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: .05em;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.table td { padding: 12px; border-bottom: 1px solid var(--border); vertical-align: middle; white-space: nowrap; }
.table tr:hover td { background: var(--surface-2); }
.table .num { text-align: right; }
.table .who { display: flex; align-items: center; gap: 10px; font-weight: 500; }
.table .avatar { width: 28px; height: 28px; font-size: 11px; }
.punch { display: inline-flex; align-items: center; gap: 8px; }
.punch a { color: var(--text-3); display: inline-flex; }
.punch a:hover { color: var(--brand); }
.photo-thumb { width: 32px; height: 32px; object-fit: cover; border-radius: 8px; display: block; }
.badge-live { display: inline-flex; padding: 2px 8px; border-radius: 999px; background: var(--success-soft); color: var(--success); font-size: 12px; font-weight: 600; }

/* Responsive */
@media (max-width: 900px) {
    .dashboard { grid-template-columns: 1fr; }
    .hero { position: static; }
    .filters { grid-template-columns: 1fr 1fr; }
    .filters .field:first-child, .filters .actions { grid-column: 1 / -1; }
}
@media (max-width: 600px) {
    .container { padding: 20px 16px 48px; }
    .topbar-inner { gap: 16px; padding: 0 16px; }
    .hide-sm { display: none; }
    h1 { font-size: 24px; }
    .card { padding: 18px; border-radius: 14px; }
    .table-wrap { margin: 0 -18px; padding: 0 18px; }
    .stats { grid-template-columns: repeat(2, 1fr); }
    .clock { min-width: 0; }
    .capture-grid { grid-template-columns: 1fr; }
    .capture { aspect-ratio: 16 / 10; }
    .capture:has(.status-text) { aspect-ratio: auto; min-height: 220px; }
    .modal { padding: 18px; }
    .day { grid-template-columns: 40px 1fr auto; gap: 12px; padding: 12px 4px; }
    .auth-card { padding: 28px 22px; }
}
