:root {
    --bg: #e5e7eb;
    --shell: #f8fafc;
    --dark: #111827;
    --muted: #64748b;
    --line: #e2e8f0;
    --primary: #2563eb;
    --green: #16a34a;
    --red: #dc2626;
    --bubble: #ffffff;
    --own: #dbeafe;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; background: var(--bg); color: var(--dark); }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .42; cursor: not-allowed; }
.mobile-shell { width: 100%; max-width: 430px; margin: 0 auto; background: var(--shell); min-height: 100dvh; box-shadow: 0 0 38px rgba(15, 23, 42, .18); }
.login-body { display: grid; place-items: center; padding: 0; }
.login-shell { display: grid; place-items: center; padding: 24px; }
.login-card { width: 100%; background: white; border: 1px solid var(--line); border-radius: 22px; padding: 28px 22px; text-align: center; box-shadow: 0 18px 45px rgba(15,23,42,.10); }
.brand-mark { width: 68px; height: 68px; border-radius: 20px; display: grid; place-items: center; margin: 0 auto 14px; background: var(--dark); color: white; font-weight: 900; font-size: 24px; letter-spacing: 1px; }
.login-card h1 { margin: 0; font-size: 24px; }
.login-card p { margin: 5px 0 22px; color: var(--muted); }
.login-card label { display: block; text-align: left; font-size: 13px; font-weight: 700; margin: 14px 0; }
.login-card input { width: 100%; margin-top: 7px; border: 1px solid #cbd5e1; border-radius: 12px; padding: 13px 14px; outline: none; }
.login-card input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.13); }
.login-card small { display: block; margin-top: 14px; color: var(--muted); }
.primary-btn { border: 0; border-radius: 12px; padding: 13px 16px; background: var(--dark); color: white; font-weight: 800; }
.full { width: 100%; }
.alert { padding: 11px 12px; border-radius: 10px; font-size: 13px; text-align: left; }
.alert.error { background: #fee2e2; color: #991b1b; }
.app-shell { height: 100dvh; display: grid; grid-template-rows: auto auto auto minmax(0,1fr) auto; overflow: hidden; }
.topbar { background: var(--dark); color: white; padding: max(12px, env(safe-area-inset-top)) 12px 10px; display: grid; gap: 9px; }
.topbar-main { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand-block strong { display: block; font-size: 16px; letter-spacing: .3px; }
.brand-block span { display: block; color: #cbd5e1; font-size: 11px; margin-top: 2px; }
.topbar.simple { min-height: 70px; }
.attendance-actions { display: flex; gap: 7px; flex: 0 0 auto; }
.attendance-btn { width: 46px; height: 34px; border: 1px solid rgba(255,255,255,.25); color: white; border-radius: 10px; font-size: 12px; font-weight: 900; transition: opacity .15s ease, transform .15s ease; }
.attendance-btn:not(:disabled):active { transform: scale(.96); }
.attendance-btn.in { background: var(--green); }
.attendance-btn.out { background: var(--red); }
.attendance-btn:disabled { opacity: .28; cursor: not-allowed; }
.attendance-status { min-height: 44px; padding: 8px 10px; border: 1px solid rgba(255,255,255,.14); border-radius: 11px; background: rgba(255,255,255,.07); }
.attendance-status strong { display: block; font-size: 11px; line-height: 1.25; letter-spacing: .25px; }
.attendance-status span { display: block; margin-top: 3px; color: #cbd5e1; font-size: 10px; line-height: 1.25; }
.attendance-status.not-in { border-left: 4px solid #f59e0b; }
.attendance-status.timed-in { border-left: 4px solid #22c55e; }
.attendance-status.completed { border-left: 4px solid #60a5fa; }
.attendance-status.completed strong { color: #bfdbfe; }
.menu-tabs { display: grid; grid-template-columns: 1fr 1.35fr 1fr; background: white; border-bottom: 1px solid var(--line); }
.menu-tabs a { color: #475569; text-decoration: none; text-align: center; padding: 12px 5px 10px; font-size: 12px; font-weight: 800; border-bottom: 3px solid transparent; }
.menu-tabs a.active { color: var(--primary); border-bottom-color: var(--primary); }
.menu-tabs a.logout-link { color: #b91c1c; }
.online-strip { display: flex; align-items: center; gap: 9px; padding: 8px 13px; background: #f1f5f9; border-bottom: 1px solid var(--line); min-height: 50px; }
.online-dot { width: 9px; height: 9px; border-radius: 50%; background: #22c55e; box-shadow: 0 0 0 4px rgba(34,197,94,.12); flex: 0 0 auto; }
.online-strip strong { display: block; font-size: 12px; }
.online-strip small { display: block; color: var(--muted); font-size: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 340px; }
.message-list { overflow-y: auto; padding: 12px 10px 18px; scroll-behavior: smooth; background: #eef2f7; }
.message { display: flex; align-items: flex-end; gap: 7px; margin: 9px 0; }
.message.own { flex-direction: row-reverse; }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: #334155; color: white; display: grid; place-items: center; font-size: 10px; font-weight: 900; flex: 0 0 auto; }
.bubble { max-width: 78%; background: var(--bubble); border-radius: 15px 15px 15px 4px; padding: 8px 10px; box-shadow: 0 1px 2px rgba(15,23,42,.08); }
.message.own .bubble { background: var(--own); border-radius: 15px 15px 4px 15px; }
.message-meta { display: flex; align-items: center; gap: 8px; margin-bottom: 3px; }
.message-meta strong { font-size: 11px; }
.message-meta time { font-size: 9px; color: var(--muted); }
.message-body { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13px; line-height: 1.4; }
.message.system { display: block; text-align: center; margin: 10px 18px; }
.system-text { display: inline-block; max-width: 100%; background: rgba(255,255,255,.72); border: 1px solid #dbe3ed; color: #475569; padding: 6px 10px; border-radius: 999px; font-size: 10px; white-space: pre-wrap; overflow-wrap: anywhere; }
.message.daily_summary .system-text { display: block; border-radius: 12px; text-align: left; padding: 11px; color: #1e293b; background: #fff7ed; border-color: #fed7aa; line-height: 1.55; font-size: 11px; }
.message.system time { display: block; margin-top: 3px; color: #94a3b8; font-size: 9px; }
.composer { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 8px; align-items: end; padding: 9px 10px max(9px, env(safe-area-inset-bottom)); background: white; border-top: 1px solid var(--line); }
.composer textarea { width: 100%; min-height: 42px; max-height: 120px; resize: none; border: 1px solid #cbd5e1; border-radius: 15px; padding: 10px 12px; outline: none; }
.composer textarea:focus { border-color: var(--primary); }
.composer button { height: 42px; border: 0; border-radius: 12px; background: var(--primary); color: white; font-size: 12px; font-weight: 900; padding: 0 15px; }
.summary-shell { height: auto; min-height: 100dvh; display: block; overflow: visible; padding-bottom: 26px; }
.summary-section { padding: 14px 12px 0; }
.summary-section h2 { margin: 0 0 9px; font-size: 14px; }
.summary-card, .empty-card { background: white; border: 1px solid var(--line); border-radius: 14px; padding: 12px; margin-bottom: 9px; }
.empty-card { color: var(--muted); font-size: 12px; }
.summary-date { font-size: 12px; font-weight: 900; margin-bottom: 9px; }
.summary-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 7px; }
.summary-grid span { display: block; color: var(--muted); font-size: 9px; }
.summary-grid strong { display: block; color: var(--dark); font-size: 11px; margin-top: 3px; }
.event-row { display: flex; align-items: center; justify-content: space-between; border-top: 1px solid #f1f5f9; padding: 8px 0; font-size: 11px; }
.event-row:first-of-type { border-top: 0; }
.event-badge { border-radius: 999px; padding: 3px 7px; font-size: 9px; font-weight: 900; }
.event-badge.login { background: #dcfce7; color: #166534; }
.event-badge.logout { background: #fee2e2; color: #991b1b; }
@media (min-width: 431px) {
    body { padding: 0; }
}
.alert.success { background: #dcfce7; color: #166534; }
.pin-card { padding: 14px; }
.pin-card-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.pin-card-heading strong { display: block; font-size: 13px; }
.pin-card-heading span:not(.security-badge) { display: block; margin-top: 3px; color: var(--muted); font-size: 10px; line-height: 1.35; }
.security-badge { flex: 0 0 auto; padding: 4px 7px; border-radius: 999px; background: #dcfce7; color: #166534; font-size: 8px; font-weight: 900; }
.pin-form { display: grid; gap: 10px; }
.pin-form label { display: block; color: #334155; font-size: 10px; font-weight: 800; }
.pin-form input { width: 100%; margin-top: 5px; border: 1px solid #cbd5e1; border-radius: 11px; padding: 11px 12px; outline: none; letter-spacing: 5px; font-size: 16px; }
.pin-form input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.pin-help { margin: 0; color: var(--muted); font-size: 9px; line-height: 1.45; }
.form-feedback { padding: 9px 10px; border-radius: 9px; font-size: 10px; line-height: 1.4; }
.form-feedback.error { background: #fee2e2; color: #991b1b; }
.form-feedback.success { background: #dcfce7; color: #166534; }
