:root {
  --bg: #f8fafc;
  --panel: #ffffff;
  --border: #e8edf3;
  --border-strong: #dbe3ec;
  --text: #0f172a;
  --muted: #7c8899;
  --muted-2: #9aa5b4;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --onsite: #ea580c;
  --onsite-bg: #fff7ed;
  --leave: #16a34a;
  --leave-bg: #f0fdf4;
  --home: #64748b;
  --danger: #dc2626;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 1px 3px rgba(15, 23, 42, .06);
  --shadow-lg: 0 20px 50px rgba(15, 23, 42, .18);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ================= LAYOUT ================= */
.layout { display: flex; min-height: 100vh; }

/* ================= SIDEBAR ================= */
.sidebar {
  width: 260px;
  flex: 0 0 260px;
  background: #fff;
  border-right: 1px solid var(--border);
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand { display: flex; align-items: center; gap: 11px; padding: 2px 4px; }
.logo {
  width: 40px; height: 40px; border-radius: 10px;
  background: #eff4ff;
  color: var(--primary);
  border: 1px solid #dbe6ff;
  font-weight: 800; display: grid; place-items: center;
  font-size: 14px; letter-spacing: .5px;
}
.brand-title { font-size: 14.5px; font-weight: 700; line-height: 1.2; }
.brand-sub { font-size: 12px; color: var(--muted); }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 10px;
  font-size: 13.5px; font-weight: 600; color: #46536a;
  text-decoration: none; transition: .15s;
}
.nav-item:hover { background: #f4f7fb; }
.nav-item.active { background: #eef4ff; color: var(--primary); }
.nav-ico { font-size: 15px; }

.side-section { display: flex; flex-direction: column; gap: 6px; }
.side-label {
  font-size: 10.5px; font-weight: 700; letter-spacing: .8px;
  color: var(--muted-2); text-transform: uppercase; padding: 0 4px 4px;
}
.side-list { display: flex; flex-direction: column; }
.side-row {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 6px; border-radius: 8px; font-size: 13.5px;
  cursor: pointer; transition: .12s;
}
.side-row:hover { background: #f4f7fb; }
.side-row .sr-name { flex: 1; color: #2c3a52; font-weight: 500; }
.side-row .sr-count { color: var(--muted); font-size: 12.5px; }
.side-dot { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 9px; }

/* ================= MAIN ================= */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 14px 28px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
  position: sticky; top: 0; z-index: 40;
}
.crumb { font-size: 12.5px; color: var(--muted); margin-bottom: 2px; }
.crumb span { margin: 0 4px; color: var(--muted-2); }
.topbar-left h1 { margin: 0; font-size: 19px; font-weight: 700; letter-spacing: -.2px; }
.topbar-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.date-pill {
  font-size: 13px; color: #46536a;
  border: 1px solid var(--border-strong); background: #fff;
  padding: 8px 13px; border-radius: 10px;
}
.date-pill b { color: var(--text); font-weight: 600; }

/* ================= BUTTONS ================= */
.btn {
  border: 1px solid transparent; border-radius: 10px;
  padding: 9px 15px; font-size: 13.5px; font-weight: 600;
  cursor: pointer; transition: .15s; font-family: inherit;
  display: inline-flex; align-items: center; gap: 7px; white-space: nowrap;
}
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 1px 2px rgba(37,99,235,.25); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost { background: #fff; border-color: var(--border-strong); color: #2c3a52; }
.btn-ghost:hover { background: #f4f7fb; }
.btn-danger { background: #fff; border-color: #fecaca; color: var(--danger); }
.btn-danger:hover { background: #fef2f2; }
.btn-sm { padding: 6px 11px; font-size: 12.5px; border-radius: 8px; }
.icon-btn {
  background: none; border: none; font-size: 16px; cursor: pointer;
  color: var(--muted); padding: 5px 9px; border-radius: 8px; line-height: 1;
}
.icon-btn:hover { background: #f1f5f9; color: var(--text); }

/* ================= CONTENT ================= */
.content { padding: 26px 28px 40px; }
.page-title { margin: 0 0 18px; font-size: 22px; font-weight: 700; letter-spacing: -.3px; }

/* ================= STAT CARDS ================= */
.stats {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 14px;
  margin-bottom: 20px;
}
.stat {
  background: #fff; border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 16px 18px;
  cursor: pointer; transition: .15s; box-shadow: var(--shadow);
  position: relative;
}
.stat:hover { border-color: var(--border-strong); transform: translateY(-2px); box-shadow: 0 6px 16px rgba(15,23,42,.07); }
.stat.active { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.stat-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.stat-head { display: flex; align-items: center; gap: 10px; }
.stat-ico {
  width: 46px; height: 46px; border-radius: 12px;
  display: grid; place-items: center; font-size: 24px; line-height: 1;
}
.stat-label { font-size: 13.5px; font-weight: 600; color: #46536a; }
.stat-chev {
  display: inline-grid; place-items: center;
  width: 34px; height: 34px; border-radius: 9px;
  background: #f1f5f9; color: #46536a;
  font-size: 22px; line-height: 1; transition: .18s;
}
.stat:hover .stat-chev { background: #e2e8f0; }
.stat.open { border-color: var(--primary); background: #f6f9ff; box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.stat.open .stat-chev { transform: rotate(180deg); background: var(--primary); color: #fff; }
.stat-value { font-size: 34px; font-weight: 800; line-height: 1; letter-spacing: -1px; }
.stat-value.tint-onsite { color: var(--onsite); }
.stat-value.tint-leave { color: var(--leave); }

/* ================= STAT DETAIL PANEL ================= */
.stat-panel {
  position: absolute; top: calc(100% + 8px); left: 0;
  min-width: 460px; max-width: 620px;
  background: #fff; border: 1px solid var(--border-strong);
  border-radius: 14px; box-shadow: var(--shadow-lg);
  padding: 14px 16px 10px; z-index: 60; display: none;
  text-align: left; cursor: default;
}
.stat.open .stat-panel { display: block; }
.stat-panel.panel-right { left: auto; right: 0; }
.stat-panel-head {
  font-size: 11px; font-weight: 700; letter-spacing: .7px;
  text-transform: uppercase; color: var(--muted-2);
  padding-bottom: 10px; margin-bottom: 4px; border-bottom: 1px solid var(--border);
}
.panel-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 8px; border-radius: 9px; transition: .12s;
}
.panel-row + .panel-row { border-top: 1px solid var(--border); }
.panel-row:hover { background: #f4f7fb; }
.panel-row[data-row-team] { cursor: pointer; }
.pr-name { font-size: 14px; font-weight: 700; color: var(--text); min-width: 86px; }
.pr-mid { flex: 1; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.pr-val { font-size: 13px; font-weight: 600; color: #46536a; white-space: nowrap; }
.pr-val.muted { color: var(--muted); font-weight: 500; }
.pr-val.onsite { color: var(--onsite); }
.pr-val.leave { color: var(--leave); }
.pr-dest { font-size: 11px; color: var(--muted); font-weight: 500; }
.panel-empty { padding: 16px 8px; font-size: 13px; color: var(--muted); }

.geo-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px 3px 3px; border-radius: 999px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
}
.geo-code {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 22px; height: 18px; padding: 0 5px; border-radius: 5px;
  font-size: 10px; font-weight: 800; letter-spacing: .3px; color: #fff;
}

/* ================= CARD ================= */
.card {
  background: #fff; border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
}
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.card-head h3 { margin: 0; font-size: 15px; font-weight: 700; }
.pill {
  background: #f1f5f9; color: #46536a; font-size: 12px; font-weight: 600;
  padding: 5px 11px; border-radius: 999px;
}

/* ================= TEAM TABLE ================= */
.team-table-wrap { overflow-x: auto; }
.team-table { width: 100%; border-collapse: collapse; min-width: 820px; }
.team-table thead th {
  text-align: left; font-size: 11px; font-weight: 700; letter-spacing: .6px;
  text-transform: uppercase; color: var(--muted-2);
  padding: 13px 20px; border-bottom: 1px solid var(--border);
  background: #fff; white-space: nowrap;
}
.team-table th.col-num, .team-table td.col-num { text-align: center; }
.team-table th.col-caret, .team-table td.col-caret { width: 44px; text-align: center; }
.team-table tbody td { padding: 16px 20px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.team-table tbody tr:last-child td { border-bottom: none; }
.team-table tbody tr.team-row:hover { background: #fafcff; }

.t-team { font-size: 15px; font-weight: 700; color: var(--text); }

.t-country { display: flex; align-items: center; gap: 9px; }
.chip {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 26px; height: 18px; padding: 0 5px;
  border-radius: 5px; font-size: 10px; font-weight: 800; letter-spacing: .3px;
  color: #fff;
}
.t-prov { font-size: 13px; color: #46536a; }
.t-prov-empty { font-size: 13px; color: var(--muted); }

.t-num { font-size: 21px; font-weight: 800; line-height: 1; color: var(--text); }
.t-num.onsite { color: var(--onsite); }
.t-num.leave { color: var(--leave); }
.t-unit { display: block; font-size: 11px; color: var(--muted); font-weight: 500; margin-top: 4px; }
.t-note { display: block; font-size: 11px; color: var(--muted); font-weight: 500; margin-top: 4px; }
.t-dest { display: block; font-size: 11px; color: var(--onsite); font-weight: 600; margin-top: 2px; }
.t-dest-leave { display: block; font-size: 11px; color: var(--leave); font-weight: 600; margin-top: 2px; }

.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.dot-onsite { background: #f59e0b; }
.dot-leave { background: #22c55e; }

.caret {
  color: var(--muted-2); font-size: 12px; cursor: pointer;
  transition: transform .2s; display: inline-block;
}
.team-row.open .caret { transform: rotate(180deg); }

/* ================= FILTERS ================= */
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin: 0 0 14px; }
.filters input, .filters select {
  padding: 8px 11px; border: 1px solid var(--border-strong); border-radius: 9px;
  font-size: 13px; font-family: inherit; background: #fff; color: var(--text);
}
.filters input[type="search"] { flex: 1; min-width: 160px; }
.filters input:focus, .filters select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }

/* ================= EMPLOYEE TABLE ================= */
.emp-wrap { overflow-x: auto; }
table.emp-table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 720px; }
.emp-table th, .emp-table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
.emp-table th { font-size: 11px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted-2); background: #fafbfd; font-weight: 700; }
.emp-table tbody tr:hover td { background: #fafcff; }
.emp-name { font-weight: 600; }
.emp-id { font-size: 11px; color: var(--muted); }

.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.badge.onsite { background: var(--onsite-bg); color: var(--onsite); }
.badge.leave { background: var(--leave-bg); color: var(--leave); }
.badge.home { background: #f1f5f9; color: var(--home); }

.pos-tag { display: inline-block; padding: 3px 9px; border-radius: 7px; font-size: 11px; background: #eef2ff; color: #4338ca; font-weight: 600; }
.pos-tag.lead { background: #fef3c7; color: #b45309; }

.row-actions { display: flex; gap: 6px; }
.empty { text-align: center; color: var(--muted); padding: 28px; font-size: 13px; }

/* ================= MODAL ================= */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .45);
  display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 100;
  backdrop-filter: blur(2px);
}
.modal-overlay[hidden] { display: none; }
.modal {
  background: #fff; border-radius: 16px; width: 100%; max-width: 470px;
  max-height: 92vh; overflow-y: auto; padding: 22px; box-shadow: var(--shadow-lg);
}
.modal-lg { max-width: 680px; }
.modal-xl { max-width: 980px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.modal-head h3 { margin: 0; font-size: 17px; font-weight: 700; }
.form { display: flex; flex-direction: column; gap: 13px; }
.form label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; font-weight: 600; color: #46536a; }
.form label small { font-weight: 500; color: var(--muted); }
.form input, .form select, .form textarea {
  padding: 10px 12px; border: 1px solid var(--border-strong); border-radius: 9px;
  font-size: 14px; font-family: inherit; color: var(--text); background: #fff;
}
.form textarea { resize: vertical; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; }
.form input:focus, .form select:focus, .form textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }
.req { color: var(--danger); }
.form-note { font-size: 12px; color: var(--muted); margin: 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.bulk-result { margin-top: 12px; font-size: 13px; }
.bulk-result .ok { color: var(--leave); font-weight: 600; }
.bulk-result .err { color: var(--danger); }
.bulk-result ul { margin: 6px 0; padding-left: 18px; }

/* ================= TOAST ================= */
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: #0f172a; color: #fff; padding: 12px 20px; border-radius: 11px;
  font-size: 13.5px; z-index: 200; box-shadow: 0 10px 25px rgba(0,0,0,.3);
  max-width: 90vw;
}
.toast.err { background: var(--danger); }
.toast.ok { background: var(--leave); }

/* ================= RESPONSIVE ================= */
@media (max-width: 1100px) {
  .stats { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 820px) {
  .sidebar { display: none; }
  .content { padding: 18px 16px 32px; }
  .topbar { padding: 12px 16px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
  .page-title { font-size: 19px; }
}
@media (max-width: 520px) {
  .stats { grid-template-columns: 1fr; }
  .topbar-right { width: 100%; }
}
