* { box-sizing: border-box; }
html, body, #root { height: 100%; margin: 0; }
body { background: var(--bg-000); color: var(--ink-100); font-family: var(--font-sans); }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-300); }

/* ---------- Login ---------- */
.login-wrap { position: fixed; inset: 0; display: grid; place-items: center; background: var(--bg-000); padding: 16px; }
.login-card { width: 340px; max-width: 100%; background: var(--bg-200); border: 1px solid var(--line-100);
  border-radius: var(--radius-lg); padding: 32px; display: flex; flex-direction: column; gap: 14px; box-shadow: var(--shadow-float); }
.login-card .brand { font-family: var(--font-sans); font-size: 22px; font-weight: 600; letter-spacing: -0.01em; }
.login-card .sub { color: var(--ink-300); font-size: 13px; margin-top: -8px; }
.login-err { color: var(--status-offline); font-size: 12px; }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: var(--rail-w) 1fr; height: 100%; min-height: 0; }
.content { min-width: 0; min-height: 0; display: flex; }

/* ---------- Map screen ---------- */
.scr { display: grid; grid-template-columns: var(--panel-w) 1fr; width: 100%; height: 100%; min-height: 0; }
.lp { display: flex; flex-direction: column; background: var(--bg-200); border-right: 1px solid var(--line-100); min-height: 0; }
.lp .hd { padding: 12px; display: grid; gap: 10px; border-bottom: 1px solid var(--line-100); }
.lp .hd-row { display: flex; justify-content: space-between; align-items: center; }
.lp .ls { flex: 1; overflow: auto; }
.lp .ft { padding: 10px 12px; border-top: 1px solid var(--line-100); display: flex; justify-content: space-between;
  font: 400 11px/16px var(--font-mono); color: var(--ink-300); }
.mw { position: relative; min-width: 0; }
#map { position: absolute; inset: 0; background: var(--map-water); }
.det { position: absolute; right: 12px; top: 12px; width: 316px; max-height: calc(100% - 24px);
  display: flex; flex-direction: column; background: var(--bg-200); border: 1px solid var(--line-100);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-float); z-index: 500; overflow: hidden; }
.det .t { padding: 12px 16px; border-bottom: 1px solid var(--line-100); }
.det .t .n { font: 600 15px/22px var(--font-sans); display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.det .t .role { color: var(--ink-300); font-size: 12px; margin-top: 2px; }
.det .kv { display: grid; grid-template-columns: repeat(3,1fr); border-bottom: 1px solid var(--line-100); }
.det .kv > div { padding: 8px 12px; border-left: 1px solid var(--line-100); }
.det .kv > div:first-child { border-left: 0; }
.det .kv .label { color: var(--ink-300); }
.det .kv b { display: block; font: 500 15px/20px var(--font-mono); margin-top: 2px; }
.det .acts { padding: 10px 12px; display: flex; gap: 8px; }
.det .empty { padding: 16px; color: var(--ink-300); font-size: 13px; }
.det .lg { padding: 4px 12px 10px; overflow: auto; }
.dock { position: absolute; left: 12px; right: 340px; bottom: 24px; z-index: 500;
  background: var(--bg-200); border: 1px solid var(--line-100); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-float); padding: 10px 16px 8px; }
.dock .row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.date-nav { display: flex; align-items: center; gap: 6px; justify-content: space-between; }
.date-nav .lbl { font: 500 13px/20px var(--font-mono); }

/* ---------- Leaflet dark + markers ---------- */
.leaflet-container { background: var(--map-water); font-family: var(--font-sans); }
.dark-tiles { filter: invert(1) hue-rotate(180deg) brightness(0.92) contrast(0.9) saturate(0.65); }
.leaflet-control-attribution { background: rgba(10,18,34,.7) !important; color: var(--ink-300) !important; }
.leaflet-control-attribution a { color: var(--ink-200) !important; }
.mk { width: 22px; height: 22px; border-radius: 50%; border: 2px solid #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,.5); display: grid; place-items: center; }
.mk.sel { box-shadow: 0 0 0 4px var(--accent-tint), 0 0 0 5px var(--accent-500); }
.mk-work { background: var(--status-work); }
.mk-onsite { background: var(--status-onsite); }
.mk-private { background: var(--status-private); }
.mk-idle { background: var(--status-idle); }
.mk-offline { background: var(--status-offline); }

/* ---------- Map layers panel ---------- */
.map-tools { position: absolute; left: 54px; top: 12px; z-index: 500; background: var(--bg-200);
  border: 1px solid var(--line-100); border-radius: var(--radius-lg); box-shadow: var(--shadow-float);
  padding: 8px; display: flex; flex-direction: column; gap: 4px; min-width: 150px; }
.mt-title { display: flex; align-items: center; gap: 6px; color: var(--ink-300); font: 500 11px/16px var(--font-sans);
  text-transform: uppercase; letter-spacing: .06em; padding: 2px 4px 4px; }
.mt-chip { display: flex; align-items: center; gap: 8px; background: transparent; border: none; color: var(--ink-100);
  font: 400 13px/18px var(--font-sans); padding: 6px 8px; border-radius: var(--radius-md); cursor: pointer; text-align: left; }
.mt-chip:hover { background: var(--bg-300); }
.mt-chip.off { color: var(--ink-300); opacity: .55; }
.mt-dot { width: 10px; height: 10px; border-radius: 3px; flex: none; box-shadow: 0 0 0 2px var(--bg-200); }
.mt-chip.off .mt-dot { filter: grayscale(1); }

/* ---------- Place markers + object list ---------- */
.pmk { width: 20px; height: 20px; border-radius: var(--radius-sm); border: 2px solid #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,.5); display: grid; place-items: center; color: #fff; font: 700 11px/1 var(--font-mono); }
.pmk.sel { box-shadow: 0 0 0 4px var(--accent-tint), 0 0 0 5px var(--accent-500); }
.pmk-client { background: var(--status-onsite); }
.pmk-office { background: var(--accent-500); }
.pmk-warehouse { background: var(--status-private); }
.obj-row { padding: 10px 12px; border-bottom: 1px solid var(--line-100); cursor: pointer; display: flex; gap: 10px; align-items: center; }
.obj-row:hover { background: var(--bg-300); }
.obj-row .sq { width: 12px; height: 12px; border-radius: 2px; flex: none; }
.obj-row .nm { flex: 1; min-width: 0; }
.obj-row .nm b { display: block; font: 500 13px/18px var(--font-sans); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.obj-row .nm span { font: 400 11px/16px var(--font-mono); color: var(--ink-300); }
.obj-row .del { background: transparent; border: none; color: var(--ink-300); cursor: pointer; font-size: 16px; padding: 2px 6px; }
.obj-row .del:hover { color: var(--status-offline); }
.form-note { color: var(--ink-300); font: 400 12px/16px var(--font-mono); margin-bottom: 4px; }

/* ---------- Generic screen (employees / stub) ---------- */
.page { flex: 1; min-width: 0; overflow: auto; padding: 24px; }
.page-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; gap: 12px; }
.page-head h1 { margin: 0; font: 600 22px/28px var(--font-sans); letter-spacing: -0.01em; }
.panel { background: var(--bg-200); border: 1px solid var(--line-100); border-radius: var(--radius-lg); overflow: hidden; }
.dept-chip { display: inline-flex; align-items: center; gap: 6px; background: var(--bg-300); border: 1px solid var(--line-100);
  border-radius: 999px; padding: 4px 6px 4px 12px; font-size: 13px; }
.dept-x { background: transparent; border: none; color: var(--ink-300); cursor: pointer; font-size: 15px; line-height: 1; padding: 0 2px; }
.dept-x:hover { color: var(--status-offline); }
.dept-input { background: var(--bg-200); border: 1px solid var(--line-100); color: var(--ink-100);
  border-radius: var(--radius-md); padding: 6px 10px; font-size: 13px; width: 160px; }
.dept-input:focus { outline: none; border-color: var(--accent-500); }
.stub { flex: 1; display: grid; place-items: center; text-align: center; color: var(--ink-300); padding: 24px; }
.stub .big { font: 600 18px/24px var(--font-sans); color: var(--ink-200); margin-bottom: 6px; }

/* ---------- Modal ---------- */
.modal-wrap { position: fixed; inset: 0; background: rgba(3,7,14,.6); display: grid; place-items: center; z-index: 1100; padding: 16px; }
.modal { background: var(--bg-200); border: 1px solid var(--line-100); border-radius: var(--radius-lg);
  padding: 24px; width: 440px; max-width: 100%; position: relative; box-shadow: var(--shadow-float); }
.modal h2 { margin: 0 0 4px; font: 600 17px/24px var(--font-sans); }
.modal .code-box { font: 500 34px/1 var(--font-mono); letter-spacing: .12em; text-align: center;
  background: var(--bg-300); border: 1px dashed var(--line-200); border-radius: var(--radius-md); padding: 16px; margin: 16px 0; }
.modal .link-row { display: flex; gap: 8px; margin-top: 8px; }
.modal .link-row input { flex: 1; }
.modal .steps { color: var(--ink-300); font-size: 13px; line-height: 1.6; margin: 12px 0 0; padding-left: 18px; }
.modal-x { position: absolute; top: 10px; right: 12px; background: transparent; border: none; color: var(--ink-300);
  font-size: 22px; cursor: pointer; }
.field { display: grid; gap: 6px; margin: 12px 0; }

/* ---------- Mobile ---------- */
@media (max-width: 820px) {
  .scr { grid-template-columns: 1fr; grid-template-rows: 46% 54%; }
  .lp { border-right: 0; border-bottom: 1px solid var(--line-100); }
  .det { position: static; width: auto; max-height: none; margin: 8px; }
  .dock { position: static; left: auto; right: auto; bottom: auto; margin: 8px; }
}
