* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  font: 14px/1.45 system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  color: #1a1a1a; background: #f4f5f7;
}
.muted { color: #6b7280; }
.error { color: #b3261e; }
button {
  font: inherit; padding: 8px 14px; border: 0; border-radius: 8px;
  background: #0b5fff; color: #fff; cursor: pointer;
}
button.ghost { background: #e5e7eb; color: #1a1a1a; }
button:disabled { opacity: .5; cursor: default; }
a.ghost {
  font: inherit; padding: 8px 14px; border-radius: 8px; background: #e5e7eb;
  color: #1a1a1a; text-decoration: none; display: inline-block;
}
input, select {
  font: inherit; padding: 8px 10px; border: 1px solid #cbd5e1; border-radius: 8px;
  background: #fff;
}

/* login */
.login-wrap { height: 100%; display: grid; place-items: center; }
.login-card {
  background: #fff; padding: 32px; border-radius: 14px; width: 300px;
  display: flex; flex-direction: column; gap: 12px; box-shadow: 0 8px 30px rgba(0,0,0,.08);
}
.login-card h1 { margin: 0; font-size: 22px; }
.login-card p { margin: 0; }

/* app shell */
#app { height: 100%; display: flex; flex-direction: column; }
header {
  display: flex; align-items: center; gap: 12px; padding: 10px 16px;
  background: #fff; border-bottom: 1px solid #e5e7eb;
}
header .spacer { flex: 1; }
nav { display: flex; gap: 4px; }
.tab { background: transparent; color: #374151; padding: 6px 12px; }
.tab.active { background: #eef2ff; color: #0b5fff; }
main { flex: 1; position: relative; overflow: hidden; }
.tab-panel { position: absolute; inset: 0; display: none; }
.tab-panel.active { display: flex; }

/* map tab */
#tab-map { flex-direction: row; }
#staff-panel {
  width: 320px; background: #fff; border-right: 1px solid #e5e7eb;
  display: flex; flex-direction: column; flex-shrink: 0;
}
.panel-head, .panel-foot {
  padding: 10px 14px; border-bottom: 1px solid #e5e7eb;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.panel-foot { border-bottom: 0; border-top: 1px solid #e5e7eb; font-size: 12px; }
.trail-toggle { display: flex; align-items: center; gap: 4px; }
#staff-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
#staff-list li {
  padding: 10px 14px; border-bottom: 1px solid #f0f0f0; cursor: pointer;
  display: flex; flex-direction: column; gap: 3px;
}
#staff-list li:hover { background: #f8fafc; }
#staff-list li.active { background: #eef2ff; }
.staff-name { font-weight: 600; display: flex; align-items: center; gap: 6px; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.s-CLOCKED_IN { background: #16a34a; }
.s-ON_BREAK { background: #d97706; }
.s-CLOCKED_OUT { background: #9ca3af; }
.s-NEVER { background: #d1d5db; }
.badge-late { color: #b3261e; font-size: 12px; }
#map { flex: 1; }

/* places panel (per-user "everywhere they went" list) */
.places-panel {
  position: absolute; right: 0; top: 0; bottom: 0; width: 340px;
  background: #fff; border-left: 1px solid #e5e7eb; z-index: 600;
  display: flex; flex-direction: column;
}
#places-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
#places-list li { padding: 10px 14px; border-bottom: 1px solid #f0f0f0; }
.place-time { font-weight: 600; }
.place-label { margin-top: 2px; }
.place-edit { display: flex; gap: 6px; margin-top: 6px; }
.place-edit input { flex: 1; padding: 4px 8px; font-size: 12px; width: 0; }
.place-edit button { padding: 4px 8px; font-size: 12px; }
.place-details { margin-top: 6px; font-size: 12px; }
.place-details a { color: #0b5fff; cursor: pointer; }
.badge-auto, .badge-task, .badge-unknown, .badge-manual {
  font-size: 11px; border-radius: 4px; padding: 1px 6px; margin-left: 4px;
}
.badge-auto { color: #92400e; background: #fef3c7; }
.badge-task { color: #1e3a8a; background: #dbeafe; }
.badge-manual { color: #14532d; background: #dcfce7; }
.badge-unknown { color: #7f1d1d; background: #fee2e2; }

/* stop pin popup (map) */
.stop-popup .place-time { font-size: 12px; }

/* "open in Odoo" deep links */
.odoo-link { color: #0b5fff; text-decoration: none; font-size: 12px; white-space: nowrap; }
.odoo-link:hover { text-decoration: underline; }

/* attendance tab */
#tab-attendance { flex-direction: column; padding: 16px; gap: 12px; overflow: auto; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.table-wrap { overflow: auto; background: #fff; border-radius: 10px; border: 1px solid #e5e7eb; }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 8px 12px; border-bottom: 1px solid #f0f0f0; white-space: nowrap; }
th { background: #f9fafb; position: sticky; top: 0; }
tr.late td { background: #fef2f2; }
#field-table td:nth-child(5), #field-table td:nth-child(7) { white-space: normal; max-width: 280px; }

/* odoo tab */
#tab-odoo { flex-direction: column; padding: 16px; gap: 16px; overflow: auto; }
.card { background: #fff; border: 1px solid #e5e7eb; border-radius: 10px; padding: 16px; max-width: 720px; }
.card h2 { margin: 0 0 8px; font-size: 16px; }
.card label { display: block; margin: 6px 0; }
pre { background: #0f172a; color: #e2e8f0; padding: 12px; border-radius: 8px; overflow: auto; font-size: 12px; }

@media (max-width: 640px) {
  #staff-panel { width: 100%; position: absolute; z-index: 500; max-height: 45%; bottom: 0; border-right: 0; border-top: 1px solid #e5e7eb; }
  #tab-map { flex-direction: column; }
  .places-panel { width: 100%; }
}
