*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f5f7fa;
  color: #1a1a2e;
  min-height: 100vh;
}

/* ── Login page ── */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 4px 24px rgba(0,0,0,.10);
  padding: 48px 40px;
  text-align: center;
  max-width: 380px;
  width: 100%;
  margin: auto;
}

.login-card h1 { font-size: 2rem; margin-bottom: 8px; }
.login-card p  { color: #666; margin-bottom: 32px; }

.btn-google {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: #fff;
  border: 2px solid #ddd;
  border-radius: 8px;
  padding: 12px 24px;
  font-size: 1rem;
  font-weight: 600;
  color: #333;
  text-decoration: none;
  transition: box-shadow .15s, border-color .15s;
  cursor: pointer;
}
.btn-google:hover { border-color: #4285F4; box-shadow: 0 2px 8px rgba(66,133,244,.2); }

.error-msg { color: #d32f2f; margin-bottom: 16px; font-size: .9rem; }

/* Local login form */
.local-login-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: left;
  margin-bottom: 12px;
}
.local-login-form label { font-size: .85rem; font-weight: 600; color: #444; }
.local-login-form input {
  padding: 10px 12px;
  border: 1.5px solid #ddd;
  border-radius: 8px;
  font-size: 1rem;
  outline: none;
  transition: border-color .15s;
}
.local-login-form input:focus { border-color: #4285F4; }
.btn-submit {
  margin-top: 4px;
  padding: 11px;
  background: #1a1a2e;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}
.btn-submit:hover { background: #2e2e50; }
.local-mode-notice { font-size: .75rem; color: #aaa; margin-top: 4px; }

/* ── App header ── */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #fff;
  border-bottom: 1px solid #e8eaf0;
  padding: 12px 24px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.app-title { font-size: 1.25rem; font-weight: 700; }

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: .9rem;
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
}

.btn-logout {
  color: #666;
  text-decoration: none;
  padding: 4px 12px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: .85rem;
  transition: background .15s;
}
.btn-logout:hover { background: #f5f5f5; }

/* ── Main ── */
.app-main {
  max-width: 1200px;
  margin: 32px auto;
  padding: 0 16px;
}

.hint {
  color: #888;
  font-size: .9rem;
  margin-bottom: 16px;
}

.app-content {
  display: flex;
  gap: 20px;
  align-items: flex-start;
}

#calendar {
  flex: 1;
  min-width: 0;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(0,0,0,.07);
  padding: 16px;
}

/* ── WFH People Panel ── */
.wfh-people-panel {
  width: 220px;
  flex-shrink: 0;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(0,0,0,.07);
  padding: 16px;
}

.wfh-people-title {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 12px;
  color: #1a1a2e;
}

.wfh-people-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 40px;
}

.wfh-person {
  display: flex;
  align-items: center;
  gap: 8px;
}

.wfh-person-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.wfh-person-initials {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #e8eaf0;
  color: #444;
  font-size: .85rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.wfh-person-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.wfh-person-name {
  font-size: .85rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wfh-person-period {
  font-size: .75rem;
  color: #888;
}

.wfh-people-empty {
  font-size: .85rem;
  color: #aaa;
  text-align: center;
  padding: 8px 0;
}

.wfh-people-loading {
  font-size: .85rem;
  color: #aaa;
  text-align: center;
  padding: 8px 0;
}

/* WFH event pills */
.wfh-event {
  color: #fff !important;
  border-radius: 4px !important;
  font-size: .8rem !important;
}
.wfh-full      { background: #2e7d32 !important; border-color: #2e7d32 !important; }
.wfh-morning   { background: #1565c0 !important; border-color: #1565c0 !important; }
.wfh-afternoon { background: #e65100 !important; border-color: #e65100 !important; }

/* ── Period selection popup ── */
.period-popup {
  position: absolute;
  z-index: 1000;
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 10px;
  box-shadow: 0 4px 16px rgba(0,0,0,.14);
  display: flex;
  gap: 6px;
  padding: 8px;
}

.period-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 7px 14px;
  border: 1.5px solid #e0e0e0;
  border-radius: 7px;
  background: #fafafa;
  font-size: .9rem;
  cursor: pointer;
  transition: background .12s, border-color .12s;
  white-space: nowrap;
}
.period-btn:hover        { background: #f0f4ff; border-color: #90a4ae; }
.period-btn-active       { background: #e8f5e9; border-color: #2e7d32; font-weight: 600; }

/* FullCalendar today highlight */
.fc-day-today { background: #e8f5e9 !important; }

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: #323232;
  color: #fff;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: .9rem;
  opacity: 0;
  transition: opacity .25s, transform .25s;
  pointer-events: none;
  z-index: 999;
  white-space: nowrap;
}
.toast.toast-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.toast.toast-error { background: #c62828; }
.toast.toast-ok    { background: #2e7d32; }

/* ── Header nav ── */
.header-nav {
  display: flex;
  gap: 4px;
}

.nav-link {
  color: #555;
  text-decoration: none;
  padding: 4px 12px;
  border-radius: 6px;
  font-size: .9rem;
  transition: background .15s, color .15s;
}
.nav-link:hover       { background: #f0f4ff; color: #1a1a2e; }
.nav-link-active      { background: #e8f5e9; color: #2e7d32; font-weight: 600; }

/* ── Stats page ── */
.stats-heading {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 20px;
  color: #1a1a2e;
}

.stats-empty {
  color: #aaa;
  font-size: .95rem;
  text-align: center;
  padding: 40px 0;
}

.stats-card {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(0,0,0,.07);
  overflow: hidden;
}

.stats-table {
  width: 100%;
  border-collapse: collapse;
}

.stats-th {
  text-align: left;
  padding: 12px 16px;
  font-size: .8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: #888;
  border-bottom: 1px solid #f0f0f0;
}
.stats-th-rank { width: 48px; text-align: center; }
.stats-th-days { width: 120px; text-align: right; }

.stats-row { transition: background .12s; }
.stats-row:hover { background: #f9fbff; }
.stats-row + .stats-row { border-top: 1px solid #f5f5f5; }

.stats-td { padding: 12px 16px; vertical-align: middle; }
.stats-td-rank { text-align: center; color: #aaa; font-size: .85rem; }
.stats-td-days { text-align: right; }

.stats-days {
  font-size: 1.05rem;
  font-weight: 700;
  color: #2e7d32;
}

@media (max-width: 768px) {
  .app-header { padding: 10px 14px; }
  .app-main   { margin: 16px auto; }
  #calendar   { padding: 8px; }
  .app-content { flex-direction: column; }
  .wfh-people-panel { width: 100%; }
}
