:root {
    --brand: #0d6efd;
    --bg: #f4f6fa;
    --card: #ffffff;
    --text: #1b2333;
    --muted: #6b7488;
    --line: #e3e7ef;
    --ok: #17994d;
    --warn: #c98a00;
    --bad: #d43c3c;
    --info: #2f6fd0;
    --radius: 14px;
    --shadow: 0 1px 3px rgba(16, 24, 40, .06), 0 8px 24px rgba(16, 24, 40, .06);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    -webkit-text-size-adjust: 100%;
}

a { color: var(--brand); text-decoration: none; }

.app-bar {
    position: sticky;
    top: 0;
    z-index: 20;
    background: var(--brand);
    color: #fff;
    padding-top: env(safe-area-inset-top);
}

.app-bar-inner {
    max-width: 720px;
    margin: 0 auto;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.app-brand { display: flex; align-items: center; gap: 10px; color: #fff; min-width: 0; }
.app-brand-mark { width: 10px; height: 10px; border-radius: 50%; background: #fff; flex: none; }
.app-brand-text {
    font-weight: 650;
    font-size: 15px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.app-user { text-align: right; line-height: 1.25; flex: none; }
.app-user-name { display: block; font-size: 13px; font-weight: 600; }
.app-user-link { display: block; font-size: 11px; color: rgba(255, 255, 255, .8); }

.app-main {
    max-width: 720px;
    margin: 0 auto;
    padding: 16px 16px 96px;
}

.flash-wrap { max-width: 720px; margin: 12px auto 0; padding: 0 16px; }
.flash {
    border-radius: 10px;
    padding: 11px 14px;
    font-size: 14px;
    margin-bottom: 8px;
    border: 1px solid transparent;
}
.flash-success { background: #e7f6ec; color: #0f6b37; border-color: #b9e3c8; }
.flash-error { background: #fdeaea; color: #9b2626; border-color: #f5c2c2; }
.flash-warning { background: #fdf3e0; color: #8a6100; border-color: #f3ddb0; }
.flash-info { background: #e9f1fd; color: #23508f; border-color: #c5daf6; }

.card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px;
    margin-bottom: 14px;
}
.card-title {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--muted);
    font-weight: 700;
    margin: 0 0 12px;
}

.state-hero { text-align: center; padding: 26px 18px; }
.state-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 8px;
    vertical-align: middle;
}
.state-in .state-dot { background: var(--ok); }
.state-out .state-dot { background: var(--muted); }
.state-break .state-dot { background: var(--warn); }
.state-leave .state-dot { background: var(--info); }

.state-label { font-size: 22px; font-weight: 700; margin: 0 0 4px; }
.state-sub { color: var(--muted); font-size: 14px; margin: 0; }
.state-clock {
    font-size: 44px;
    font-weight: 300;
    letter-spacing: -.02em;
    margin: 10px 0 2px;
    font-variant-numeric: tabular-nums;
}
.state-date { color: var(--muted); font-size: 13px; }

.geo-box {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    border-radius: 10px;
    padding: 12px 14px;
    font-size: 13px;
    margin-bottom: 14px;
    background: #eef2f8;
    color: var(--muted);
    border: 1px solid var(--line);
}
.geo-box.is-ok { background: #e7f6ec; color: #0f6b37; border-color: #b9e3c8; }
.geo-box.is-bad { background: #fdeaea; color: #9b2626; border-color: #f5c2c2; }
.geo-box.is-wait { background: #fdf3e0; color: #8a6100; border-color: #f3ddb0; }
.geo-icon { flex: none; font-size: 16px; line-height: 1.3; }
.geo-text { flex: 1; min-width: 0; }
.geo-title { font-weight: 650; display: block; }
.geo-detail { display: block; opacity: .85; font-size: 12px; margin-top: 2px; }

.action-grid { display: grid; gap: 10px; }
@media (min-width: 520px) { .action-grid { grid-template-columns: 1fr 1fr; } }

.action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    min-height: 62px;
    border: none;
    border-radius: 12px;
    background: var(--brand);
    color: #fff;
    font-size: 17px;
    font-weight: 650;
    cursor: pointer;
    padding: 14px 18px;
    transition: transform .08s ease, opacity .15s ease;
}
.action-btn:active { transform: scale(.985); }
.action-btn[disabled] { opacity: .5; cursor: not-allowed; }
.action-btn.is-out { background: #4a5468; }
.action-btn.is-break { background: #c98a00; }
.action-btn.is-leave { background: #2f6fd0; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: 1px solid var(--line);
    background: #fff;
    color: var(--text);
    border-radius: 10px;
    padding: 10px 16px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
}
.btn-primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn-danger { background: #fff; color: var(--bad); border-color: #f0c2c2; }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 13px; }

.field { margin-bottom: 14px; }
.field label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
    margin-bottom: 6px;
}
.field input, .field select, .field textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 12px 14px;
    font-size: 16px;
    font-family: inherit;
    background: #fff;
    color: var(--text);
}
.field input:focus, .field select:focus, .field textarea:focus {
    outline: 2px solid rgba(13, 110, 253, .25);
    border-color: var(--brand);
}
.field-row { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
.field-hint { font-size: 12px; color: var(--muted); margin-top: 4px; }

.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
    border: 1px solid var(--line);
    background: #fff;
    border-radius: 999px;
    padding: 9px 16px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    color: var(--text);
}
.chip.is-active { background: var(--brand); color: #fff; border-color: var(--brand); }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li {
    display: flex;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--line);
}
.timeline li:last-child { border-bottom: none; }
.timeline-time {
    font-variant-numeric: tabular-nums;
    font-weight: 700;
    font-size: 15px;
    width: 58px;
    flex: none;
}
.timeline-body { flex: 1; min-width: 0; }
.timeline-title { font-weight: 600; font-size: 15px; }
.timeline-meta { font-size: 12px; color: var(--muted); }

.badge {
    display: inline-block;
    border-radius: 999px;
    padding: 3px 10px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .02em;
}
.badge-success { background: #e7f6ec; color: #0f6b37; }
.badge-warning { background: #fdf3e0; color: #8a6100; }
.badge-danger { background: #fdeaea; color: #9b2626; }
.badge-secondary { background: #eef1f6; color: #5a6478; }
.badge-info { background: #e9f1fd; color: #23508f; }

.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 520px) { .stat-grid { grid-template-columns: repeat(4, 1fr); } }
.stat {
    background: var(--card);
    border-radius: 12px;
    padding: 14px;
    box-shadow: var(--shadow);
}
.stat-value { font-size: 21px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-label { font-size: 12px; color: var(--muted); margin-top: 2px; }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th {
    text-align: left;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--muted);
    padding: 8px 10px;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}
table.data td {
    padding: 10px;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}
table.data tr:last-child td { border-bottom: none; }

.tab-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    background: #fff;
    border-top: 1px solid var(--line);
    display: flex;
    z-index: 30;
    padding-bottom: env(safe-area-inset-bottom);
}
.tab-item {
    flex: 1;
    text-align: center;
    padding: 9px 4px 7px;
    color: var(--muted);
    font-size: 11px;
}
.tab-item.is-active { color: var(--brand); }
.tab-icon { display: block; font-size: 17px; line-height: 1.2; }
.tab-label { display: block; }

.auth-shell {
    max-width: 420px;
    margin: 0 auto;
    padding: 32px 20px 60px;
}
.auth-card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 26px 22px;
}
.auth-title { font-size: 20px; font-weight: 700; margin: 0 0 6px; }
.auth-sub { color: var(--muted); font-size: 14px; margin: 0 0 20px; }

.result-screen { text-align: center; padding: 40px 20px; }
.result-mark {
    width: 78px;
    height: 78px;
    border-radius: 50%;
    margin: 0 auto 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 38px;
    color: #fff;
    background: var(--ok);
}
.result-mark.is-bad { background: var(--bad); }
.result-title { font-size: 22px; font-weight: 700; margin: 0 0 6px; }
.result-time {
    font-size: 40px;
    font-weight: 300;
    font-variant-numeric: tabular-nums;
    margin: 12px 0 4px;
}
.result-meta { color: var(--muted); font-size: 14px; }

.empty {
    text-align: center;
    color: var(--muted);
    font-size: 14px;
    padding: 26px 12px;
}

.muted { color: var(--muted); }
.text-right { text-align: right; }
.mb-0 { margin-bottom: 0; }
.mt-2 { margin-top: 12px; }
.spin {
    display: inline-block;
    width: 15px;
    height: 15px;
    border: 2px solid rgba(255, 255, 255, .4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.is-hidden { display: none !important; }
