/* ── Variables ────────────────────────────────────────────────────────────── */
:root {
  --blue:       #1B5EA7;
  --dark-blue:  #113870;
  --gold:       #B8942A;
  --bg:         #f0f2f5;
  --sidebar-bg: #0d2444;
  --card-bg:    #ffffff;
  --text:       #1a1a1a;
  --muted:      #6b7280;
  --border:     #e5e7eb;
  --radius:     10px;
  --sidebar-w:  280px;
}

/* ── Reset ────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; color: var(--text); }
input, button { font-family: inherit; }

/* ── Login ────────────────────────────────────────────────────────────────── */
.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--dark-blue) 0%, var(--blue) 100%);
}

.login-card {
  background: var(--card-bg);
  border-radius: 16px;
  padding: 40px 36px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}

.logo-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  background: var(--blue);
  color: #fff;
  font-size: 18px;
  font-weight: 800;
  border-radius: 12px;
  margin-bottom: 12px;
  letter-spacing: 1px;
}

.logo-mark.small {
  width: 36px;
  height: 36px;
  font-size: 12px;
  border-radius: 8px;
  flex-shrink: 0;
}

.login-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--dark-blue);
}

.login-subtitle {
  font-size: 13px;
  color: var(--muted);
  margin-top: 2px;
}

.field {
  margin-bottom: 16px;
}

.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--dark-blue);
  margin-bottom: 6px;
}

.field input, input[type="number"], input[type="text"], input[type="password"] {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 15px;
  outline: none;
  transition: border-color 0.15s;
  background: #fff;
}

input:focus { border-color: var(--blue); }

.error-msg {
  background: #fef2f2;
  color: #dc2626;
  border: 1px solid #fecaca;
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 14px;
}

.hidden { display: none !important; }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn-primary {
  width: 100%;
  padding: 12px;
  background: var(--blue);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-primary:hover { background: var(--dark-blue); }

.btn-small {
  padding: 6px 12px;
  background: rgba(255,255,255,0.12);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-small:hover { background: rgba(255,255,255,0.2); }

.btn-ghost {
  padding: 6px 12px;
  background: transparent;
  color: rgba(255,255,255,0.6);
  border: none;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
}

.btn-ghost:hover { color: #fff; }

/* ── Dashboard layout ─────────────────────────────────────────────────────── */
.dashboard-body {
  display: flex;
  height: 100vh;
  overflow: hidden;
  background: var(--bg);
}

/* ── Sidebar ──────────────────────────────────────────────────────────────── */
#sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--sidebar-bg);
  color: #fff;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 16px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-title {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
}

.sidebar-subtitle {
  font-size: 11px;
  color: rgba(255,255,255,0.45);
}

.sidebar-section-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: rgba(255,255,255,0.35);
  padding: 16px 16px 8px;
}

#employee-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 10px;
}

#employee-list::-webkit-scrollbar { width: 4px; }
#employee-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 2px; }

.no-employees {
  font-size: 13px;
  color: rgba(255,255,255,0.35);
  text-align: center;
  padding: 24px 0;
}

/* ── Employee card ────────────────────────────────────────────────────────── */
.emp-card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 8px;
  border-radius: 8px;
  margin-bottom: 4px;
  transition: background 0.15s;
}

.emp-card:hover { background: rgba(255,255,255,0.06); }
.emp-card.stale { opacity: 0.5; }

.emp-dot {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
}

.emp-info { flex: 1; min-width: 0; }

.emp-name {
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.emp-number {
  font-size: 11px;
  color: rgba(255,255,255,0.45);
}

.emp-station {
  font-size: 11px;
  color: var(--gold);
  margin-top: 2px;
}

.emp-meta {
  font-size: 10px;
  color: rgba(255,255,255,0.3);
  margin-top: 3px;
}

.emp-loc-ok  { color: #4ade80; }
.emp-loc-warn { color: #fbbf24; }

.emp-event {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
  flex-shrink: 0;
  align-self: flex-start;
  margin-top: 2px;
}

.event-in      { background: rgba(74,222,128,0.15); color: #4ade80; }
.event-out     { background: rgba(248,113,113,0.15); color: #f87171; }
.event-neutral { background: rgba(255,255,255,0.08); color: rgba(255,255,255,0.5); }

/* ── Sidebar footer ───────────────────────────────────────────────────────── */
.sidebar-footer {
  padding: 12px 16px 20px;
  border-top: 1px solid rgba(255,255,255,0.08);
}

#last-update {
  font-size: 11px;
  color: rgba(255,255,255,0.3);
  margin-bottom: 10px;
}

.sidebar-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ── Map area ─────────────────────────────────────────────────────────────── */
#map-area {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 20px;
}

#map-container {
  position: relative;
  max-width: 100%;
  max-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

#floorplan-img {
  max-width: 100%;
  max-height: calc(100vh - 40px);
  object-fit: contain;
  border-radius: 12px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.15);
  display: block;
}

#dot-canvas {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: all;
  border-radius: 12px;
}

.map-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: var(--card-bg);
  border-radius: 16px;
  padding: 60px 40px;
  text-align: center;
  box-shadow: 0 4px 24px rgba(0,0,0,0.08);
  min-width: 360px;
}

.placeholder-icon { font-size: 48px; }

.placeholder-text {
  font-size: 18px;
  font-weight: 600;
  color: var(--dark-blue);
}

.placeholder-sub {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.6;
}

.placeholder-sub code {
  background: #f3f4f6;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12px;
}

/* ── Calibration modal ────────────────────────────────────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal-card {
  background: var(--card-bg);
  border-radius: 16px;
  padding: 32px;
  width: 100%;
  max-width: 560px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.25);
}

.modal-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--dark-blue);
  margin-bottom: 8px;
}

.modal-desc {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.6;
  margin-bottom: 24px;
}

.cal-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}

.cal-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--dark-blue);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 8px;
}

.field-row input {
  padding: 8px 10px;
  font-size: 13px;
}

.cal-point .btn-small {
  background: var(--blue);
  color: #fff;
  border-color: var(--blue);
  width: 100%;
  padding: 7px;
  font-size: 12px;
}

.cal-point .btn-small:hover { background: var(--dark-blue); border-color: var(--dark-blue); }

.modal-actions {
  display: flex;
  gap: 10px;
}

.modal-actions .btn-primary { flex: 1; }

.modal-actions .btn-ghost {
  color: var(--muted);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 20px;
  font-size: 15px;
  font-weight: 600;
}

.modal-actions .btn-ghost:hover { background: var(--bg); color: var(--text); }
