:root {
    --green-dark: #0c3d2e;
    --green: #0f6b4c;
    --green-mid: #145c45;
    --orange: #c45c26;
    --bg: #eef2f0;
    --panel: #ffffff;
    --ink: #14201a;
    --muted: #5c6b63;
    --line: #d5ddd8;
    --danger: #b91c1c;
    --ok: #047857;
    --warn: #b45309;
    --info: #0369a1;
    --radius: 14px;
    --font: "Segoe UI", "Trebuchet MS", sans-serif;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: var(--font);
    color: var(--ink);
    background: var(--bg);
    min-height: 100vh;
}

body.login-page {
    background:
        linear-gradient(160deg, var(--green-dark) 0%, var(--green-mid) 42%, var(--bg) 42%);
    min-height: 100vh;
}

.app-shell {
    min-height: 100vh;
    background:
        linear-gradient(160deg, var(--green-dark) 0%, var(--green-mid) 38%, var(--bg) 38%);
}

.app-header {
    padding: max(1rem, env(safe-area-inset-top)) 1.1rem .5rem;
    color: #fff;
}

.app-header-main {
    display: flex;
    gap: .75rem;
    align-items: center;
}

.app-logo {
    width: 42px;
    height: 42px;
    object-fit: contain;
    border-radius: 10px;
    background: #fff;
}

.app-title {
    font-size: 1rem;
    font-weight: 900;
    line-height: 1.25;
}

.app-subtitle {
    margin-top: .2rem;
    font-size: .78rem;
    color: rgba(255,255,255,.82);
    font-weight: 600;
}

.app-nav {
    display: flex;
    gap: .35rem;
    margin-top: .85rem;
    flex-wrap: wrap;
}

.app-nav a {
    color: rgba(255,255,255,.88);
    text-decoration: none;
    padding: .45rem .75rem;
    border-radius: 999px;
    font-size: .82rem;
    font-weight: 700;
    background: rgba(255,255,255,.1);
}

.app-nav a.active,
.app-nav a:hover {
    background: rgba(255,255,255,.22);
    color: #fff;
}

.app-main {
    padding: .5rem 1rem max(2rem, env(safe-area-inset-bottom));
    max-width: 560px;
    margin: 0 auto;
}

.login-wrap {
    max-width: 420px;
    margin: 0 auto;
    padding: 1.25rem 1rem 2rem;
}

.login-brand {
    text-align: center;
    color: #fff;
    margin-bottom: 1.25rem;
}

.login-brand img {
    width: 64px;
    height: 64px;
    object-fit: contain;
    border-radius: 14px;
    background: #fff;
    margin-bottom: .75rem;
}

.login-brand h1 {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 900;
}

.login-brand p {
    margin: .35rem 0 0;
    color: rgba(255,255,255,.85);
    font-size: .9rem;
}

.ios-tip {
    margin-top: .65rem !important;
    font-size: .78rem !important;
    line-height: 1.45;
    color: rgba(255,255,255,.75) !important;
}

.card {
    background: var(--panel);
    border-radius: var(--radius);
    box-shadow: 0 10px 30px rgba(20,32,26,.08);
    padding: 1rem 1.1rem;
    margin-bottom: .85rem;
}

.card-title {
    margin: 0 0 .75rem;
    font-size: 1rem;
    font-weight: 800;
}

.date-line {
    color: rgba(255,255,255,.88);
    font-size: .92rem;
    margin: .25rem 0 1rem;
    text-align: center;
}

.status-grid {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: .5rem;
}

.status-grid .divider {
    width: 1px;
    height: 54px;
    background: var(--line);
}

.status-label {
    color: var(--muted);
    font-size: .85rem;
    text-align: center;
}

.status-time {
    font-size: 1.75rem;
    font-weight: 800;
    text-align: center;
    margin-top: .25rem;
}

.status-time.in { color: var(--green); }
.status-time.out { color: var(--orange); }

.hint-row {
    display: flex;
    gap: .65rem;
    align-items: flex-start;
    font-size: .9rem;
}

.hint-row svg { flex-shrink: 0; margin-top: .1rem; }

.btn {
    display: block;
    width: 100%;
    border: 0;
    border-radius: var(--radius);
    padding: .95rem 1rem;
    font: inherit;
    font-weight: 800;
    font-size: 1rem;
    color: #fff;
    cursor: pointer;
    text-align: center;
    text-decoration: none;
}

.btn:disabled {
    opacity: .45;
    cursor: not-allowed;
}

.btn-green { background: var(--green); }
.btn-orange { background: var(--orange); }
.btn-secondary { background: #33463d; }

.btn-sub {
    display: block;
    margin-top: .15rem;
    font-size: .72rem;
    font-weight: 600;
    opacity: .88;
}

.btn-busy .btn-label { visibility: hidden; }
.btn-busy::after {
    content: "";
    position: absolute;
    inset: 0;
    margin: auto;
    width: 22px;
    height: 22px;
    border: 2px solid rgba(255,255,255,.35);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin .8s linear infinite;
}

.btn-wrap { position: relative; margin-bottom: .65rem; }

@keyframes spin { to { transform: rotate(360deg); } }

.done-box {
    background: #d1fae5;
    color: #065f46;
    border-radius: var(--radius);
    padding: .9rem 1rem;
    text-align: center;
    font-weight: 700;
    margin-bottom: .85rem;
}

.meta-list {
    color: var(--muted);
    font-size: .88rem;
    line-height: 1.55;
}

.meta-list strong {
    color: var(--ink);
}

.form-row { margin-bottom: .9rem; }
.form-row label {
    display: block;
    font-weight: 700;
    margin-bottom: .35rem;
    font-size: .88rem;
}
.form-row input {
    width: 100%;
    padding: .75rem .85rem;
    border: 1px solid var(--line);
    border-radius: 10px;
    font: inherit;
}

.form-row select,
.form-row textarea {
    width: 100%;
    padding: .75rem .85rem;
    border: 1px solid var(--line);
    border-radius: 10px;
    font: inherit;
    background: #fff;
}

.alert {
    padding: .75rem .9rem;
    border-radius: 10px;
    margin-bottom: .85rem;
    font-weight: 600;
    font-size: .9rem;
}
.alert-success { background: #d1fae5; color: #065f46; }
.alert-error { background: #fee2e2; color: #991b1b; }
.alert-info { background: #e0f2fe; color: #075985; }

.badge {
    display: inline-block;
    padding: .18rem .5rem;
    border-radius: 999px;
    font-size: .72rem;
    font-weight: 700;
}
.badge-ok { background: #d1fae5; color: var(--ok); }
.badge-warn { background: #ffedd5; color: var(--warn); }
.badge-info { background: #e0f2fe; color: var(--info); }
.badge-danger { background: #fee2e2; color: var(--danger); }
.badge-muted { background: #e5e7eb; color: #374151; }

.summary-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: .55rem;
    margin-bottom: .85rem;
}

.summary-tile {
    background: var(--panel);
    border-radius: 12px;
    padding: .75rem;
    box-shadow: 0 4px 14px rgba(20,32,26,.06);
}

.summary-tile .label {
    color: var(--muted);
    font-size: .75rem;
    font-weight: 700;
}

.summary-tile .value {
    font-size: 1.35rem;
    font-weight: 900;
    margin-top: .15rem;
}

.month-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: .85rem;
}

.month-nav a {
    color: var(--green-dark);
    text-decoration: none;
    font-weight: 800;
    padding: .35rem .55rem;
}

.month-nav h2 {
    margin: 0;
    font-size: 1rem;
}

.history-item {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: .35rem .75rem;
    padding: .75rem 0;
    border-bottom: 1px solid var(--line);
}

.history-item:last-child { border-bottom: 0; }

.history-date { font-weight: 800; }
.history-times { color: var(--muted); font-size: .85rem; }
.history-meta { color: var(--muted); font-size: .78rem; grid-column: 1 / -1; }

.history-photo {
    width: 44px;
    height: 44px;
    object-fit: cover;
    border-radius: 8px;
}

.empty-state {
    text-align: center;
    color: var(--muted);
    padding: 1.5rem .5rem;
}

.hidden { display: none !important; }

@media (min-width: 640px) {
    .app-main, .login-wrap { padding-left: 1.25rem; padding-right: 1.25rem; }
    .summary-grid { grid-template-columns: repeat(4, 1fr); }
}
