:root {
  --brand: #6B21A8;
  --brand-dark: #4C1D95;
  --brand-light: #9333EA;
  --brand-bg: #F3E8FF;
  --bg: #F4F5F7;
  --surface: #FFFFFF;
  --text-main: #1F2937;
  --text-muted: #6B7280;
  --border: #E5E7EB;
  --danger: #DC2626;
  --success: #16A34A;
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.04);
  --shadow-md: 0 8px 24px rgba(107,33,168,0.08);
  --radius: 16px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans TC", Arial, sans-serif; background: var(--bg); color: var(--text-main); line-height: 1.5; }

/* Header */
.site-header { height: 60px; display: none; align-items: center; justify-content: space-between; padding: 0 16px; background: linear-gradient(135deg, var(--brand), var(--brand-dark)); color: #fff; position: sticky; top: 0; z-index: 50; box-shadow: 0 4px 12px rgba(0,0,0,0.1); }
.site-header.show { display: flex; }
.brand { font-weight: 700; font-size: 18px; letter-spacing: 1px; }
.icon-btn { background: transparent; border: none; color: inherit; padding: 8px; border-radius: 50%; display: flex; align-items: center; justify-content: center; cursor: pointer; }

/* Drawer (Side Menu) */
.drawer { position: fixed; left: 0; top: 0; height: 100%; width: 280px; background: var(--surface); z-index: 100; transform: translateX(-100%); transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1); box-shadow: 2px 0 12px rgba(0,0,0,0.1); display: flex; flex-direction: column; }
.drawer.show { transform: translateX(0); }
.drawer-mask { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 90; backdrop-filter: blur(2px); opacity: 0; transition: opacity 0.3s; pointer-events: none; }
.drawer-mask.show { opacity: 1; pointer-events: auto; }
.drawer-header { padding: 24px 20px; background: var(--brand-bg); display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border); }
.drawer-user { font-weight: 700; color: var(--brand-dark); font-size: 18px; }
.drawer-header .icon-btn { color: var(--brand-dark); background: rgba(0,0,0,0.05); }
.drawer-nav { padding: 16px 0; display: flex; flex-direction: column; }
.drawer-link { padding: 16px 24px; color: var(--text-main); text-decoration: none; font-weight: 500; font-size: 16px; display: flex; align-items: center; transition: background 0.2s; }
.drawer-link:active { background: var(--bg); }
.drawer-link.active { background: var(--brand-bg); color: var(--brand-dark); border-right: 4px solid var(--brand); font-weight: 700; }
.divider { height: 1px; background: var(--border); margin: 12px 20px; }
.text-danger { color: var(--danger) !important; }

/* Views & Animation */
.view { display: none; padding: 20px 16px 80px; animation: fadeIn 0.4s ease-out; }
.view.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.page-header { margin-bottom: 24px; }
.page-header h2 { margin: 0 0 4px; font-size: 24px; color: var(--text-main); }
.muted { color: var(--text-muted); font-size: 14px; margin: 0; }
.section-title { font-size: 16px; font-weight: 700; margin: 24px 0 12px; color: var(--text-main); }

/* Login */
.login-wrapper { display: flex; align-items: center; justify-content: center; min-height: 80vh; }
.login-card { background: var(--surface); padding: 32px 24px; border-radius: var(--radius); box-shadow: var(--shadow-md); width: 100%; max-width: 400px; text-align: center; }
.login-logo { width: 64px; height: 64px; background: linear-gradient(135deg, var(--brand), var(--brand-dark)); color: white; border-radius: 16px; display: flex; align-items: center; justify-content: center; font-size: 24px; font-weight: bold; margin: 0 auto 16px; }
.login-card .brand-title { font-size: 22px; margin: 0 0 8px; }
.form-group { text-align: left; margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; }
.form-group input { width: 100%; padding: 14px; border: 1.5px solid var(--border); border-radius: 12px; font-size: 16px; transition: border-color 0.2s; outline: none; }
.form-group input:focus { border-color: var(--brand); }
.login-footer { margin-top: 24px; font-size: 13px; color: var(--text-muted); }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; padding: 14px 20px; border-radius: 12px; font-size: 16px; font-weight: 600; cursor: pointer; border: none; transition: transform 0.1s, opacity 0.2s; }
.btn:active { transform: scale(0.96); }
.btn-block { width: 100%; margin-top: 8px; }
.btn-primary { background: var(--brand); color: #fff; box-shadow: 0 4px 12px rgba(107,33,168,0.3); }
.btn-ghost { background: var(--surface); color: var(--text-main); border: 1px solid var(--border); box-shadow: var(--shadow-sm); }

/* Top Stats */
.top-stats { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 8px; margin: 0 -16px 16px; padding-left: 16px; padding-right: 16px; }
.top-stats::-webkit-scrollbar { display: none; }
.stat { min-width: 140px; background: var(--surface); padding: 16px; border-radius: var(--radius); box-shadow: var(--shadow-sm); border: 1px solid rgba(0,0,0,0.02); }
.stat .num { font-size: 28px; font-weight: 800; color: var(--brand); line-height: 1; margin-bottom: 4px; }

/* Clocking Panel */
.clocking-panel-wrapper { background: var(--surface); padding: 24px; border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.clocking-panel { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.clocking-panel .btn { padding: 20px 10px; font-size: 16px; flex-direction: column; gap: 8px; border-radius: 14px; }
.btn-work { background: var(--brand); color: white; }
.btn-off { background: var(--text-main); color: white; }
.btn-trip { background: #3B82F6; color: white; }
.btn-leave-personal { background: #F59E0B; color: white; }
.btn-leave-sick { background: #EF4444; color: white; }
.btn-leave-special { background: #10B981; color: white; }
.btn-custom { background: var(--bg); color: var(--text-main); border: 1px dashed var(--border); }

/* Cards (Attendance & Announcements) */
.att-card, .ann-card { background: var(--surface); padding: 16px; border-radius: var(--radius); margin-bottom: 12px; box-shadow: var(--shadow-sm); border: 1px solid rgba(0,0,0,0.03); }
.att-top { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 8px; }
.att-type { font-weight: 700; font-size: 16px; color: var(--brand); background: var(--brand-bg); padding: 4px 10px; border-radius: 6px; }
.att-time { font-size: 13px; color: var(--text-muted); }
.att-body { font-size: 15px; font-weight: 500; margin-bottom: 4px; }
.att-meta { font-size: 13px; display: inline-block; padding: 2px 8px; border-radius: 4px; background: var(--bg); color: var(--text-muted); }

.ann-card { border-left: 4px solid var(--brand); }
.ann-title { font-weight: 700; font-size: 16px; margin-bottom: 6px; }
.ann-body { font-size: 14px; color: var(--text-muted); line-height: 1.5; }

/* Reports */
.report-card { background: var(--surface); padding: 24px; border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.report-card h3 { margin: 0 0 12px; }
.actions-grid { display: flex; flex-direction: column; gap: 12px; }

/* Toast */
#toastContainer { position: fixed; bottom: 24px; left: 16px; right: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 999; pointer-events: none; }
.toast { background: #374151; color: #fff; padding: 14px 20px; border-radius: 12px; font-size: 14px; font-weight: 500; box-shadow: 0 10px 25px rgba(0,0,0,0.2); opacity: 0; transform: translateY(20px); transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); }
.toast.show { opacity: 1; transform: translateY(0); }
