:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #fafbfc;
  --border: #e3e6ea;
  --text: #1c2024;
  --muted: #6b7280;
  --accent: #e8821e;      /* строительный янтарь */
  --accent-dark: #c96a0c;
  --green: #1f9d55;
  --green-bg: #e7f6ee;
  --red: #d64545;
  --red-bg: #fbeaea;
  --amber-bg: #fdf1e1;
  --blue: #2b6cb0;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(20,30,40,.07), 0 1px 2px rgba(20,30,40,.04);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* ─── topbar ─────────────────────────────────────────────── */
.topbar {
  display: flex; align-items: center; gap: 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px; height: 84px;
  position: sticky; top: 0; z-index: 50;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand:hover { text-decoration: none; }
.brand-logo { height: 62px; width: auto; display: block; }
.brand-sub { color: var(--muted); font-weight: 400; font-size: 13px; border-left: 1px solid var(--border); padding-left: 10px; }
@media (max-width: 760px) { .brand-logo { height: 48px; } .topbar { height: 68px; } }
@media (max-width: 620px) { .brand-sub { display: none; } }
.topbar nav { display: flex; gap: 4px; flex: 1; }
.topbar nav a {
  color: var(--text); padding: 8px 14px; border-radius: 8px; font-weight: 500;
}
.topbar nav a:hover { background: var(--surface-2); text-decoration: none; }
.topbar nav a.active { background: var(--amber-bg); color: var(--accent-dark); }
.logout button {
  background: none; border: 1px solid var(--border); border-radius: 8px;
  padding: 7px 14px; cursor: pointer; color: var(--muted);
}
.logout button:hover { border-color: var(--red); color: var(--red); }

/* ─── layout ─────────────────────────────────────────────── */
.container { max-width: 1180px; margin: 0 auto; padding: 28px 24px 60px; }
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; gap: 16px; flex-wrap: wrap; }
h1 { font-size: 24px; margin: 0 0 2px; }
h2 { font-size: 18px; margin: 0 0 14px; }
h3 { font-size: 15px; margin: 0 0 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 20px; margin-bottom: 20px;
}
.grid { display: grid; gap: 20px; }
.grid.cols-2 { grid-template-columns: 1fr 1fr; }
.grid.side { grid-template-columns: 1.6fr 1fr; }
@media (max-width: 860px) { .grid.cols-2, .grid.side { grid-template-columns: 1fr; } }

/* ─── tables ─────────────────────────────────────────────── */
table { width: 100%; border-collapse: collapse; }
thead th {
  text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .4px;
  color: var(--muted); padding: 10px 12px; border-bottom: 2px solid var(--border); white-space: nowrap;
}
tbody td { padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:hover { background: var(--surface-2); }
tr.clickable { cursor: pointer; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.row-inactive td { color: var(--muted); opacity: .7; }

/* ─── badges ─────────────────────────────────────────────── */
.badge {
  display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600;
}
.badge.green { background: var(--green-bg); color: var(--green); }
.badge.red { background: var(--red-bg); color: var(--red); }
.badge.amber { background: var(--amber-bg); color: var(--accent-dark); }
.badge.gray { background: #eceef1; color: var(--muted); }
.dot { display:inline-block; width:8px; height:8px; border-radius:50%; margin-right:6px; }
.dot.green { background: var(--green); } .dot.gray { background: #b8bec6; }

/* ─── buttons & forms ────────────────────────────────────── */
.btn {
  display: inline-block; border: 1px solid var(--border); background: var(--surface);
  border-radius: 8px; padding: 8px 14px; font-size: 14px; cursor: pointer; color: var(--text);
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.primary:hover { background: var(--accent-dark); }
.btn.danger { color: var(--red); border-color: #f0c4c4; }
.btn.danger:hover { background: var(--red-bg); }
.btn.sm { padding: 5px 10px; font-size: 13px; }

label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 12px; }
input, select, textarea {
  width: 100%; padding: 9px 11px; margin-top: 4px; font-size: 14px;
  border: 1px solid var(--border); border-radius: 8px; background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--amber-bg); border-color: var(--accent); }
.form-row { display: flex; gap: 14px; flex-wrap: wrap; align-items: flex-end; }
.form-row > * { flex: 1; min-width: 120px; }
.inline-form { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }

.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; font-size: 14px; }
.alert.error { background: var(--red-bg); color: var(--red); }
.alert.ok { background: var(--green-bg); color: var(--green); }

/* ─── stats strip ────────────────────────────────────────── */
.stats { display: flex; gap: 16px; flex-wrap: wrap; }
.stat { flex: 1; min-width: 130px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.stat .v { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat .l { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.stat.paid .v { color: var(--green); }
.stat.unpaid .v { color: var(--accent-dark); }

/* ─── login ──────────────────────────────────────────────── */
.login-wrap { min-height: 80vh; display: flex; align-items: center; justify-content: center; }
.login-card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); padding: 32px; width: 340px; }
.login-logo { height: 52px; width: auto; display: block; margin: 0 auto 16px; }
.login-card h1 { font-size: 21px; margin-bottom: 0; }
.login-card .muted { margin-top: 0; margin-bottom: 20px; text-align: center; }
.login-card .btn { width: 100%; margin-top: 6px; }

/* ─── calendar ───────────────────────────────────────────── */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-dow { font-size: 11px; text-transform: uppercase; color: var(--muted); text-align: center; padding-bottom: 4px; letter-spacing: .3px; }
.cal-cell { min-height: 64px; border: 1px solid var(--border); border-radius: 8px; padding: 6px 8px; background: var(--surface-2); position: relative; }
.cal-cell.empty { background: transparent; border: none; }
.cal-cell.worked { background: #fff; border-color: var(--accent); }
.cal-cell.paid { background: var(--green-bg); border-color: #bfe4cf; }
.cal-cell.today { box-shadow: inset 0 0 0 2px var(--blue); }
.cal-cell .d { font-size: 12px; color: var(--muted); }
.cal-cell .h { font-weight: 700; font-size: 15px; margin-top: 6px; font-variant-numeric: tabular-nums; }
.cal-cell .open-flag { position: absolute; top: 6px; right: 8px; }

/* ─── map ────────────────────────────────────────────────── */
.map-layout { display: grid; grid-template-columns: 300px 1fr; gap: 16px; align-items: start; }
@media (max-width: 860px) { .map-layout { grid-template-columns: 1fr; } }
#map { height: 72vh; min-height: 460px; border-radius: var(--radius); border: 1px solid var(--border); }
.legend { display: flex; gap: 18px; margin: 10px 2px; flex-wrap: wrap; font-size: 13px; color: var(--muted); align-items: center; }
.legend .lg-emoji { font-size: 16px; margin-right: 5px; vertical-align: middle; }
.legend .lg-dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; background: #2b6cb0; margin-right: 5px; vertical-align: middle; }
.legend .lg-img { height: 16px; width: auto; margin-right: 5px; vertical-align: middle; }

.map-sidebar {
  max-height: 72vh; overflow: auto; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 8px;
}
.sb-group-title { font-size: 11px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); margin: 12px 6px 4px; }
.sb-site { display: flex; align-items: center; gap: 8px; padding: 7px 8px; border-radius: 8px; cursor: pointer; font-weight: 600; }
.sb-site:hover { background: var(--surface-2); }
.sb-site .emj { font-size: 17px; }
.sb-site .cnt { margin-left: auto; font-size: 12px; color: var(--muted); font-weight: 400; }
.sb-worker { display: flex; align-items: center; gap: 6px; padding: 4px 8px 4px 28px; border-radius: 8px; cursor: pointer; font-size: 13px; }
.sb-worker:hover { background: var(--surface-2); }
.sb-worker .t { margin-left: auto; color: var(--muted); font-size: 12px; }
.sb-here { padding: 2px 8px 6px 28px; }
.sb-here a { font-size: 12px; color: var(--blue); }
.sb-empty { color: var(--muted); font-size: 13px; padding: 2px 8px 6px 28px; }
.sb-vehicle { display: flex; align-items: center; gap: 6px; padding: 5px 8px; border-radius: 8px; cursor: pointer; font-size: 13px; }
.sb-vehicle:hover { background: var(--surface-2); }

/* эмодзи-маркеры на карте */
.map-emoji { font-size: 24px; line-height: 1; text-align: center; cursor: pointer;
  filter: drop-shadow(0 1px 1px rgba(0,0,0,.4)); }
.map-emoji.worker { font-size: 20px; }
/* офис — логотип в белой «пилюле» для читаемости на карте */
.map-logo { background: #fff; border: 1px solid #cfd4da; border-radius: 6px;
  padding: 3px 5px; box-shadow: 0 1px 3px rgba(0,0,0,.3); cursor: pointer; }
.map-logo img { height: 18px; width: auto; display: block; }
.leaflet-popup-content { font-size: 13px; line-height: 1.45; }
.popup-list { margin: 6px 0 0; padding-left: 16px; }
.popup-list li { margin: 2px 0; }
.popup-actions { margin-top: 6px; }

.empty-state { text-align: center; color: var(--muted); padding: 40px 0; }

/* легенда-точки + календарь отпусков */
.mk { display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.vac-name { font-size: 11px; line-height: 1.3; padding: 1px 5px; border-radius: 4px; margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vac-approved { background: var(--green-bg); color: var(--green); }
.vac-pending { background: var(--amber-bg); color: var(--accent-dark); }
.vac-rejected { background: var(--red-bg); color: var(--red); }
.thumb { height: 40px; border-radius: 4px; border: 1px solid var(--border); vertical-align: middle; }
