/* ===== Base ===== */
:root{
  --primary:#2554e6;
  --primary-dark:#1a3fb8;
  --primary-light:#eef2ff;
  --teal:#0891b2;
  --danger:#dc2626;
  --danger-light:#fef2f2;
  --warning:#d97706;
  --warning-light:#fffbeb;
  --success:#16a34a;
  --success-light:#f0fdf4;
  --ink:#0f172a;
  --muted:#64748b;
  --line:#e2e8f0;
  --bg:#f6f8fb;
  --card:#ffffff;
}

*{box-sizing:border-box}
html,body{height:100%}
body{
  font-family:'Inter', system-ui, sans-serif;
  background:var(--bg);
  color:var(--ink);
  -webkit-font-smoothing:antialiased;
}

/* ===== Layout ===== */
.app-shell{display:flex; min-height:100vh}
.sidebar{
  width:264px; flex-shrink:0; background:#0b1330; color:#cbd5e1;
  display:flex; flex-direction:column; position:sticky; top:0; height:100vh;
}
.sidebar-logo{
  display:flex; align-items:center; gap:.6rem; padding:1.25rem 1.25rem;
  border-bottom:1px solid rgba(255,255,255,.08);
}
.sidebar-logo .mark{
  width:34px;height:34px;border-radius:9px;
  background:linear-gradient(135deg,#3b6bf6,#7c3aed);
  display:flex;align-items:center;justify-content:center;font-weight:800;color:#fff;font-size:.95rem;
}
.sidebar nav{padding:.9rem .7rem; flex:1; overflow-y:auto}
.side-section-title{
  font-size:.7rem; text-transform:uppercase; letter-spacing:.06em; color:#64748b;
  padding:.9rem .8rem .35rem;
}
.side-link{
  display:flex; align-items:center; gap:.7rem; padding:.6rem .8rem; border-radius:10px;
  color:#c7d2fe; text-decoration:none; font-size:.9rem; font-weight:600; margin-bottom:2px;
  transition:background .15s;
}
.side-link:hover{background:rgba(255,255,255,.06); color:#fff}
.side-link.active{background:linear-gradient(135deg,#2554e6,#4338ca); color:#fff}
.side-link .ic{width:18px;text-align:center;flex-shrink:0;opacity:.9}
.sidebar-foot{padding:1rem 1.1rem; border-top:1px solid rgba(255,255,255,.08); font-size:.78rem; color:#64748b}

.main{flex:1; min-width:0; display:flex; flex-direction:column}
.topbar{
  position:sticky; top:0; z-index:30; background:rgba(246,248,251,.85); backdrop-filter:blur(6px);
  border-bottom:1px solid var(--line);
  display:flex; align-items:center; justify-content:space-between;
  padding:.85rem 1.5rem; gap:1rem;
}
.content{padding:1.5rem; flex:1}

/* ===== Cards ===== */
.card{background:var(--card); border:1px solid var(--line); border-radius:16px}
.card-pad{padding:1.25rem 1.4rem}
.stat-card{
  background:var(--card); border:1px solid var(--line); border-radius:16px; padding:1.1rem 1.3rem;
  display:flex; flex-direction:column; gap:.4rem;
}
.stat-icon{
  width:38px;height:38px;border-radius:10px;display:flex;align-items:center;justify-content:center;
  font-size:1rem; margin-bottom:.3rem;
}

/* ===== Buttons ===== */
.btn{
  display:inline-flex; align-items:center; gap:.45rem; font-weight:700; font-size:.85rem;
  padding:.55rem 1.05rem; border-radius:10px; border:1px solid transparent; cursor:pointer;
  transition:all .15s; white-space:nowrap; text-decoration:none;
}
.btn-primary{background:var(--primary); color:#fff}
.btn-primary:hover{background:var(--primary-dark)}
.btn-outline{background:#fff; border-color:var(--line); color:var(--ink)}
.btn-outline:hover{border-color:var(--primary); color:var(--primary)}
.btn-ghost{background:transparent; color:var(--muted)}
.btn-ghost:hover{background:#eef1f6; color:var(--ink)}
.btn-danger-soft{background:var(--danger-light); color:var(--danger)}
.btn-sm{padding:.4rem .75rem; font-size:.78rem; border-radius:8px}
.btn:disabled{opacity:.5; cursor:not-allowed}
.icon-btn{
  width:36px;height:36px;border-radius:10px;border:1px solid var(--line); background:#fff;
  display:flex;align-items:center;justify-content:center; cursor:pointer; color:var(--muted);
}
.icon-btn:hover{color:var(--primary); border-color:var(--primary)}

/* ===== Badges ===== */
.badge{
  display:inline-flex; align-items:center; gap:.35rem; font-size:.72rem; font-weight:700;
  padding:.28rem .6rem; border-radius:999px; white-space:nowrap;
}
.badge-dot{width:6px;height:6px;border-radius:50%}
.badge-green{background:var(--success-light); color:var(--success)}
.badge-green .badge-dot{background:var(--success)}
.badge-amber{background:var(--warning-light); color:var(--warning)}
.badge-amber .badge-dot{background:var(--warning)}
.badge-red{background:var(--danger-light); color:var(--danger)}
.badge-red .badge-dot{background:var(--danger)}
.badge-blue{background:var(--primary-light); color:var(--primary)}
.badge-blue .badge-dot{background:var(--primary)}
.badge-gray{background:#f1f5f9; color:#475569}
.badge-gray .badge-dot{background:#94a3b8}

/* ===== Table ===== */
table.tbl{width:100%; border-collapse:collapse; font-size:.86rem}
table.tbl thead th{
  text-align:start; font-size:.72rem; text-transform:uppercase; letter-spacing:.04em; color:var(--muted);
  padding:.7rem .9rem; border-bottom:1px solid var(--line); background:#fafbfd; white-space:nowrap;
}
table.tbl tbody td{padding:.75rem .9rem; border-bottom:1px solid #f0f2f6; vertical-align:middle}
table.tbl tbody tr:hover{background:#fafbff}
table.tbl tbody tr:last-child td{border-bottom:none}

/* ===== Forms ===== */
.field{margin-bottom:1rem}
.field label{display:block; font-size:.8rem; font-weight:700; color:var(--ink); margin-bottom:.4rem}
.field .hint{font-size:.74rem; color:var(--muted); margin-top:.3rem}
.input, select.input, textarea.input{
  width:100%; padding:.6rem .8rem; border:1px solid var(--line); border-radius:10px; font-size:.86rem;
  font-family:inherit; background:#fff; color:var(--ink);
}
.input:focus, select.input:focus, textarea.input:focus{outline:2px solid var(--primary); outline-offset:0; border-color:var(--primary)}
.form-grid{display:grid; grid-template-columns:1fr 1fr; gap:1rem}
.checkbox-row{display:flex; align-items:center; gap:.5rem; font-size:.85rem}

/* ===== Avatar ===== */
.avatar{
  width:38px;height:38px;border-radius:50%; display:flex; align-items:center; justify-content:center;
  font-weight:800; font-size:.8rem; color:#fff; flex-shrink:0;
}

/* ===== Misc ===== */
.section-title{font-size:1.05rem; font-weight:800}
.muted{color:var(--muted)}
.kpi-value{font-size:1.7rem; font-weight:800}
.divider{height:1px; background:var(--line); margin:1.2rem 0}
.scrollx{overflow-x:auto}
.mono{font-family:ui-monospace,Consolas,monospace}

.mobile-toggle{display:none}
.sidebar-scrim{display:none; position:fixed; inset:0; background:rgba(15,23,42,.4); z-index:199}

@media (max-width: 980px){
  .sidebar{position:fixed; inset-inline-start:0; top:0; height:100vh; transform:translateX(-100%); z-index:200; transition:transform .2s}
  .sidebar.open{transform:translateX(0)}
  .sidebar.open ~ .sidebar-scrim, .sidebar-scrim.open{display:block}
  .mobile-toggle{display:flex}
  .form-grid{grid-template-columns:1fr}
}

/* ===== Tag picker (multi-select autocomplete) ===== */
.tagpicker-chips{display:flex; flex-wrap:wrap; gap:.35rem; margin-bottom:.35rem}
.tagpicker-chips:empty{margin-bottom:0}
.tagpicker-chip{
  display:inline-flex; align-items:center; gap:.35rem; background:var(--primary-light); color:var(--primary);
  font-size:.78rem; font-weight:600; padding:.25rem .3rem .25rem .6rem; border-radius:999px;
}
.tagpicker-remove{
  background:none; border:none; color:inherit; cursor:pointer; font-size:1rem; line-height:1; padding:0 .25rem;
  opacity:.7;
}
.tagpicker-remove:hover{opacity:1}

/* ===== Combo (searchable single-select) ===== */
.combo{min-width:160px}
.combo-input{width:100%}

/* ===== Dashboard drill-down tree (country -> job -> specialty) ===== */
#dash-country-tree{border:1px solid var(--line); border-radius:12px; overflow:hidden}
.dash-row{border-bottom:1px solid var(--line)}
.dash-row:last-child{border-bottom:none}
.dash-row-head{
  display:flex; align-items:center; gap:.7rem; padding:.7rem .8rem; min-height:1.6rem;
  cursor:pointer; transition:background .15s; background:#fff;
}
.dash-row-head:hover{background:var(--primary-light)}
.dash-chevron{
  display:inline-flex; align-items:center; justify-content:center; flex-shrink:0;
  width:1.1rem; color:var(--muted); font-size:.7rem; transition:transform .15s, color .15s;
}
.dash-row.open > .dash-row-head .dash-chevron{color:var(--primary); transform:rotate(90deg)}
.dash-label{font-weight:600; font-size:.88rem; flex:1; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap}
.dash-counts{flex-shrink:0; display:flex; align-items:center; gap:.9rem; font-size:.8rem; white-space:nowrap}
.dash-total{font-weight:800; min-width:3.2rem; text-align:end; color:var(--ink)}
.dash-sub{color:var(--muted); display:inline-flex; align-items:center; gap:.25rem}
.dash-children{
  max-height:0; overflow:hidden; border-inline-start:2px solid var(--line); margin-inline-start:1.4rem;
  transition:max-height .3s ease;
}
.dash-row.open > .dash-children{max-height:6000px}
/* Each nesting level (job under country, specialty under job) gets a
   progressively softer tint so the tree reads at a glance without having
   to trace the indentation guide line. */
.dash-children .dash-row-head{background:#f8fafc}
.dash-children .dash-children .dash-row-head{background:#f2f4f8}
.dash-children .dash-label{font-weight:500; font-size:.85rem}
.dash-children .dash-total{font-weight:700}
.dash-loading, .dash-empty{color:var(--muted); font-size:.8rem; padding:.7rem .8rem .7rem 1.4rem}

/* ===== Accordion (collapsed-by-default dashboard sections) ===== */
.accordion{overflow:hidden}
.accordion-head{
  display:flex; align-items:center; gap:.7rem; padding:1.05rem 1.3rem; cursor:pointer;
  font-weight:800; font-size:1rem; transition:background .15s; border-radius:16px;
}
.accordion-head:hover{background:#f8fafc}
.accordion.open .accordion-head{border-radius:16px 16px 0 0}
.accordion-chevron{
  display:inline-flex; align-items:center; justify-content:center; flex-shrink:0;
  width:1rem; color:var(--muted); font-size:.8rem; transition:transform .2s, color .2s;
}
.accordion.open .accordion-chevron{color:var(--primary); transform:rotate(90deg)}
.accordion-body{max-height:0; overflow:hidden; transition:max-height .35s ease}
.accordion.open .accordion-body{max-height:8000px}
.accordion-content{margin:0 1.3rem 1.3rem; padding-top:1rem; border-top:1px solid var(--line)}

/* ===== Share results dropdown (contacts.php) ===== */
.share-wrap{position:relative; display:inline-block}
.share-menu{
  display:none; position:absolute; top:calc(100% + .4rem); inset-inline-start:0; z-index:20;
  background:#fff; border:1px solid var(--line); border-radius:12px; box-shadow:0 12px 30px -10px rgba(15,23,42,.25);
  padding:.4rem; min-width:170px; flex-direction:column; gap:.15rem;
}
.share-menu.open{display:flex}
.share-menu a, .share-menu button{
  display:flex; align-items:center; gap:.6rem; padding:.55rem .7rem; border-radius:8px; border:none; background:none;
  font-family:inherit; font-size:.85rem; font-weight:600; color:var(--ink); text-decoration:none; cursor:pointer; text-align:start; width:100%;
}
.share-menu a:hover, .share-menu button:hover{background:#f1f5fb}
.share-menu .ic{width:1.2rem; text-align:center}

/* ===== Generic modal (export column picker, etc.) ===== */
.modal-overlay{
  position:fixed; inset:0; background:rgba(15,23,42,.5); display:none; align-items:center; justify-content:center;
  z-index:200; padding:1.2rem;
}
.modal-overlay.show{display:flex}
.modal{
  background:#fff; border-radius:16px; padding:1.5rem 1.6rem; max-width:560px; width:100%;
  max-height:85vh; overflow-y:auto; position:relative; box-shadow:0 30px 70px -20px rgba(0,0,0,.35);
}
.modal-close{
  position:absolute; top:.9rem; inset-inline-end:.9rem; width:32px; height:32px; border-radius:50%;
  border:none; background:#f1f5fb; color:var(--muted); font-size:1.2rem; line-height:1; cursor:pointer;
  display:flex; align-items:center; justify-content:center; transition:background .15s;
}
.modal-close:hover{background:#e2e8f0}
