/* Design tokens: hr-tokens.css */

* { box-sizing: border-box; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--hr-canvas, var(--hr-bg));
  color: var(--hr-text);
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
}

.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ---------------------------------------------------------------- Sidebar */

.side-nav {
  width: var(--hr-sidebar-width);
  flex-shrink: 0;
  background: var(--hr-sidebar-bg);
  border-right: 1px solid var(--hr-sidebar-border);
  box-shadow: var(--hr-shadow-sm);
  color: var(--hr-sidebar-text);
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.side-nav .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--hr-text);
  font-weight: 800;
  font-size: 1rem;
  text-decoration: none;
  padding: 6px 10px 16px;
}

.side-nav .brand span {
  width: 32px;
  height: 32px;
  border-radius: var(--hr-radius-sm, 8px);
  background: var(--hr-primary);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
}

.nav-caption {
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  color: var(--hr-sidebar-caption);
  margin: 12px 10px 6px;
  font-weight: 700;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--hr-radius-sm, 8px);
  color: var(--hr-sidebar-text);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 2px;
  transition: background 0.18s ease, color 0.18s ease;
}

.nav-link i { width: 18px; text-align: center; opacity: 0.85; font-size: 0.95rem; }

.nav-link:hover {
  background: var(--hr-sidebar-hover-bg);
  color: var(--hr-sidebar-text-hover);
}

.nav-link:hover i { color: var(--hr-primary); }

.nav-link.active {
  background: var(--hr-sidebar-active-bg);
  color: var(--hr-sidebar-active-text);
}

.nav-link.active i { color: #fff; opacity: 1; }

.nav-link.muted { opacity: 0.55; pointer-events: none; }

.nav-bottom {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--hr-sidebar-border);
}

/* ------------------------------------------------------------------ Topbar */

.content {
  flex: 1;
  margin-left: 0;
  min-width: 0;
  /* Page shells (.hrd-shell / .obu-shell / .hrp-shell / .prt-shell) own spacing —
     avoid a second padded wrapper (“box in a box”). */
  padding: 0;
}

/* Edge-to-edge chrome pages: light inset owned by the page, not .content */
.hr-chrome-shell {
  width: 100%;
  max-width: none;
  box-sizing: border-box;
  padding: 8px 4px 32px;
}
.hrd-shell,
.obu-shell,
.hrp-shell,
.prt-shell {
  width: 100%;
  max-width: none;
  box-sizing: border-box;
}

/* Classic pages without a chrome shell still need a light edge inset. */
.content:not(:has(.hrd, .obu, .hrp, .prt, .hr-chrome-shell)) {
  padding: 8px 16px 28px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 0;
  color: var(--hr-text-muted);
  font-size: 0.85rem;
}

.breadcrumbs i { margin: 0 6px; font-size: 0.7rem; }

.top-profile { display: flex; align-items: center; gap: 8px; }

.profile-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--hr-success);
  display: inline-block;
}

/* -------------------------------------------------------------- Page header */

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}

.page-header-identity {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.page-header h1 {
  margin: 0 0 4px;
  font-size: 1.5rem;
  font-weight: 800;
}

.page-subtitle {
  margin: 0;
  color: var(--hr-text-muted);
  font-size: 0.92rem;
}

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

/* -------------------------------------------------------------------- Grid */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 16px;
  margin-bottom: 22px;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  margin-bottom: 22px;
}

.stat-card {
  background: var(--hr-surface);
  border: 1px solid var(--hr-border);
  border-radius: var(--hr-radius);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.stat-label {
  font-size: 0.78rem;
  color: var(--hr-text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.stat-value {
  font-size: 1.6rem;
  font-weight: 800;
}

.stat-hint {
  font-size: 0.75rem;
  color: var(--hr-text-muted);
}

/* --------------------------------------------------------------------- Card */

.hr-card {
  background: var(--hr-surface);
  border: 1px solid var(--hr-border);
  border-radius: var(--hr-radius);
  margin-bottom: 20px;
  overflow: hidden;
}

.hr-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--hr-border);
}

.hr-card-header h2 { margin: 0; font-size: 1.02rem; font-weight: 700; }

.hr-card-body { padding: 20px; }

.hr-card-body.no-pad { padding: 0; }

.form-card { max-width: 640px; }

/* -------------------------------------------------------------------- Table */

.hr-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.hr-table thead th {
  text-align: left;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--hr-text-muted);
  font-weight: 700;
  padding: 12px 20px;
  background: var(--hr-surface-muted);
  border-bottom: 1px solid var(--hr-border);
}

.hr-table tbody td {
  padding: 13px 20px;
  border-bottom: 1px solid var(--hr-border);
  vertical-align: middle;
}

.hr-table tbody tr:last-child td { border-bottom: none; }

.hr-table tbody tr:hover { background: var(--hr-row-hover); }

.hr-table tbody td.hr-num,
.hr-table tbody td[data-align="right"],
.hr-table .num { text-align: right; font-variant-numeric: tabular-nums; }

.person-cell { display: flex; flex-direction: column; }
.person-name { font-weight: 600; }
.person-meta { font-size: 0.76rem; color: var(--hr-text-muted); }

.empty-state {
  padding: 34px 20px;
  text-align: center;
  color: var(--hr-text-muted);
  margin: 0;
}

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

.strike { text-decoration: line-through; color: var(--hr-text-muted); }

/* --------------------------------------------------------------------- Pill */

.pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 700;
  background: var(--hr-muted-bg);
  color: var(--hr-text-muted);
}

.pill-success { background: var(--hr-success-bg); color: var(--hr-success); }
.pill-warning { background: var(--hr-warning-bg); color: var(--hr-warning); }
.pill-error { background: var(--hr-error-bg); color: var(--hr-error); }
.pill-muted { background: var(--hr-muted-bg); color: var(--hr-text-muted); }

/* ------------------------------------------------------------------ Buttons */

.primary-button, .ghost-button, .danger-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.88rem;
  text-decoration: none;
  border: 1px solid transparent;
  cursor: pointer;
}

.primary-button { background: var(--hr-primary); color: #fff; border-radius: var(--hr-radius-sm, 8px); font-weight: 700; }
.primary-button:hover { background: var(--hr-primary-hover); color: #fff; }

.ghost-button { background: var(--hr-surface); color: var(--hr-text); border-color: var(--hr-border); }
.ghost-button:hover { background: var(--hr-surface-muted); color: var(--hr-text); }

.danger-button { background: var(--hr-error-bg); color: var(--hr-error); }
.danger-button:hover { background: #fecaca; color: var(--hr-error); }

.ghost-button-sm {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 8px;
  background: var(--hr-surface-muted);
  color: var(--hr-text);
  font-size: 0.8rem;
  font-weight: 600;
  text-decoration: none;
  border: 1px solid var(--hr-border);
  cursor: pointer;
}

.ghost-button-sm:hover { background: var(--hr-muted-bg); color: var(--hr-text); }

.inline-form { display: inline-block; }

.check-toggle {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  border: 1px solid var(--hr-border);
  background: var(--hr-surface);
  color: transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.check-toggle.checked { background: var(--hr-success); border-color: var(--hr-success); color: #fff; }

/* ------------------------------------------------------------------- Forms */

.filter-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.filter-input, .filter-select, .form-control {
  padding: 8px 12px;
  border-radius: var(--hr-radius-sm, 8px);
  border: 1px solid var(--hr-border);
  font-size: 0.875rem;
  background: var(--hr-input, var(--hr-surface));
  color: var(--hr-text);
  min-height: 36px;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.filter-input:focus, .filter-select:focus, .form-control:focus {
  outline: none;
  border-color: var(--hr-primary);
  box-shadow: 0 0 0 3px var(--hr-primary-soft);
}

.filter-input { min-width: 220px; }

.form-row { margin-bottom: 16px; display: flex; flex-direction: column; gap: 6px; }

.form-row label { font-size: 0.82rem; font-weight: 600; color: var(--hr-text-muted); }

.form-row.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.form-row.two-col > div { display: flex; flex-direction: column; gap: 6px; }

.form-row.checkbox-row label { display: flex; align-items: center; gap: 8px; font-weight: 500; color: var(--hr-text); }

.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

/* ------------------------------------------------------------------- Misc */

.muted { color: var(--hr-text-muted); }
.muted.small, .small { font-size: 0.78rem; }

.progress-bar {
  width: 100%;
  max-width: 140px;
  height: 7px;
  border-radius: 999px;
  background: var(--hr-muted-bg);
  overflow: hidden;
  margin-bottom: 4px;
}

.progress-fill { height: 100%; background: var(--hr-primary); border-radius: 999px; }

.rating i { color: var(--hr-warning); font-size: 0.85rem; }
.rating i.dim { color: var(--hr-border); }

.kv-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--hr-border);
  font-size: 0.9rem;
}

.kv-row:last-child { border-bottom: none; }

.kv-row.total { font-weight: 700; }

.kv-row.large { font-size: 1.2rem; }

/* -------------------------------------------------------------------- Alerts */

.hr-alert {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: 10px;
  margin-bottom: 18px;
  font-size: 0.88rem;
  font-weight: 600;
}

.hr-alert-success { background: var(--hr-success-bg); color: var(--hr-success); }
.hr-alert-error { background: var(--hr-error-bg); color: var(--hr-error); }

/* ------------------------------------------------------------- Access page */

.access-required {
  max-width: 460px;
  margin: 90px auto;
  text-align: center;
  padding: 40px 32px;
  background: var(--hr-surface);
  border-radius: var(--hr-radius);
  border: 1px solid var(--hr-border);
}

.access-icon {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: var(--hr-muted-bg);
  color: var(--hr-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  margin: 0 auto 18px;
}

.access-required .eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--hr-text-muted);
  margin-bottom: 6px;
}

.access-required h1 { margin: 0 0 10px; font-size: 1.3rem; }
.access-required p { color: var(--hr-text-muted); margin-bottom: 22px; }

/* ------------------------------------------------------------------ Embed / single-page scroll */

html.crm-embedded,
html.crm-embedded body {
  height: auto !important;
  min-height: 0 !important;
  overflow: visible !important;
  margin-bottom: 0 !important;
}
html.crm-embedded .app-shell {
  min-height: 0 !important;
  height: auto !important;
  display: block;
}
html.crm-embedded .content,
html.crm-embedded .hr-main-wrap,
html.crm-embedded .hr-main {
  overflow: visible !important;
  height: auto !important;
  max-height: none !important;
  min-height: 0 !important;
}
html.crm-embedded body { background: var(--hr-surface); }

/* Chrome tabs: not sticky inside CRM iframe (outer CRM scroll owns vertical movement) */
html.crm-embedded:has(.hrp) .hr-chrome-tabs,
html.crm-embedded:has(.hrd) .hr-chrome-tabs,
html.crm-embedded:has(.prt) .hr-chrome-tabs {
  position: static;
}

/* Onboarding standalone: page scroll. Embed: expand — CRM iframe height follows hr-resize. */
html.crm-embedded:has(.obu),
html.crm-embedded:has(.obu) body {
  overflow: visible !important;
  height: auto !important;
  min-height: 0 !important;
  margin-bottom: 0 !important;
}
html:has(.obu):not(.crm-embedded),
html:has(.obu):not(.crm-embedded) body {
  overflow-x: hidden;
  overflow-y: auto;
  margin-bottom: 0 !important;
  height: auto;
  min-height: 0;
}
html:has(.obu) .app-shell {
  min-height: 0 !important;
  height: auto !important;
  display: block;
}
html:has(.obu) .content,
html:has(.obu) .obu,
html:has(.obu) .obu-shell {
  overflow: visible !important;
  height: auto !important;
  max-height: none !important;
}

/* Shared section tabs — clean segmented control */
.hr-tabs {
  margin: 0 0 18px;
  width: 100%;
}
.hr-tabs-track {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  padding: 6px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  border-radius: var(--hr-radius-compact, 12px);
  background: var(--hr-surface-muted, #f4f4f5);
  border: 1px solid var(--hr-border);
  box-shadow: none;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  isolation: isolate;
}
.hr-tabs-track::-webkit-scrollbar { display: none; }

.hr-tab,
.hrd-tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  flex: 0 0 auto;
  padding: 9px 14px;
  border-radius: 10px;
  background: transparent;
  color: var(--hr-text-muted, #64748b);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.82rem;
  border: 0;
  font-family: Inter, system-ui, sans-serif;
  white-space: nowrap;
  transition: background .15s ease, color .15s ease, box-shadow .15s ease, transform .12s ease;
}
.hr-tab i {
  font-size: 0.78rem;
  opacity: .85;
}
.hr-tab:hover,
.hrd-tab:hover {
  color: var(--hr-text, #09090b);
  background: var(--hr-row-hover, #f4f4f5);
}
.hr-tab.is-active,
.hrd-tab.is-active {
  background: var(--hr-surface);
  color: var(--hr-primary);
  box-shadow: var(--hr-shadow-sm), 0 0 0 1px var(--hr-primary-soft);
}
.hr-tab.is-active i { opacity: 1; color: var(--hr-primary); }

[data-theme="dark"] .hr-tabs-track, [data-theme-mode="dark"] .hr-tabs-track {
  background: var(--hr-surface);
  border-color: var(--hr-border);
  box-shadow: var(--hr-shadow-sm);
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}
[data-theme="dark"] .hr-tab:hover, [data-theme-mode="dark"] .hr-tab:hover,
[data-theme="dark"] .hr-tab.is-active, [data-theme-mode="dark"] .hr-tab.is-active,
[data-theme="dark"] .hrd-tab.is-active, [data-theme-mode="dark"] .hrd-tab.is-active {
  background: var(--hr-primary);
  color: #fff;
  box-shadow: 0 4px 14px var(--hr-primary-soft);
}
[data-theme="dark"] .hr-tab.is-active i, [data-theme-mode="dark"] .hr-tab.is-active i { color: #fff; }

/* Module chrome: page title → section tabs → content */
.hr-chrome {
  padding: 18px 30px 0;
  background: transparent;
}

.hr-page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.hr-page-title {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--hr-text);
  line-height: 1.2;
}

.hr-page-sub {
  margin: 6px 0 0;
  font-size: 0.8125rem;
  color: var(--hr-text-muted);
  font-weight: 500;
  max-width: 42rem;
  line-height: 1.45;
}

.hr-page-eyebrow {
  margin-bottom: 6px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--hr-text-muted);
}

.hr-page-eyebrow a {
  color: var(--hr-text-muted);
  text-decoration: none;
}
.hr-page-eyebrow a:hover { color: var(--hr-primary); }

.hr-page-head-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* Sticky section tabs below page title */
.hr-chrome-tabs {
  padding: 0;
  position: sticky;
  top: 0;
  z-index: 40;
  background: transparent;
  margin-bottom: 4px;
}
.hr-chrome-tabs .hr-tabs { margin-bottom: 12px; }

.content:has(.hr-chrome) .hrp-shell,
.content:has(.hr-chrome) .hrd-shell,
.content:has(.hr-chrome) .obu-shell,
.content:has(.hr-chrome) .prt-shell,
.content:has(.hr-chrome) .sth-shell,
.content:has(.hr-chrome) .pcf-shell,
.content:has(.hr-chrome) .ms-root {
  padding-top: 12px;
}
.hr-main-wrap {
  position: relative;
  min-height: 56vh;
}
.hr-main {
  min-height: 50vh;
}
.hr-main.hr-main-swap {
  animation: hrFadeIn .08s ease;
}
@keyframes hrFadeIn {
  from { opacity: .92; }
  to { opacity: 1; }
}
@media (max-width: 720px) {
  .hr-chrome { padding: 14px 16px 0; }
  .hr-page-title { font-size: 1.2rem; }
  .hr-chrome-tabs { padding: 0; }
}

/* YouTube-style top progress */
.hr-top-progress {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  z-index: 99999;
  pointer-events: none;
  opacity: 0;
}
.hr-top-progress.is-active { opacity: 1; }
.hr-top-progress-bar {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--hr-primary-light), var(--hr-primary) 50%, var(--hr-primary-hover));
  box-shadow: 0 0 8px var(--hr-primary-soft);
}
.hr-top-progress.is-active .hr-top-progress-bar {
  animation: hrTopLoad 1.1s cubic-bezier(.4, 0, .2, 1) forwards;
}
.hr-top-progress.is-done .hr-top-progress-bar {
  animation: none;
  width: 100%;
  opacity: 0;
  transition: opacity .28s ease;
}
@keyframes hrTopLoad {
  0% { width: 0; }
  20% { width: 28%; }
  50% { width: 55%; }
  80% { width: 78%; }
  100% { width: 92%; }
}

/* Legacy alias used by older markup */
.hrd-tabs { display: contents; }

@media (max-width: 640px) {
  .hr-tab span { display: none; }
  .hr-tab { padding: 10px 12px; }
  .hr-tab i { font-size: 0.9rem; opacity: 1; }
}

/* ─── HR Timezone / Location bar ──────────────────────────────────────────
   Slim info strip below section tabs: city, country, UTC offset, live clock.
   Uses existing --hr-* vars so it respects light / dark theme automatically.
   ────────────────────────────────────────────────────────────────────────── */
.hr-tz-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0 12px;
  padding: 5px 6px 10px;
  font-size: 0.76rem;
  font-weight: 500;
  color: var(--hr-text-muted);
  letter-spacing: 0.01em;
  line-height: 1.4;
  /* No background / border — floats cleanly under tabs */
}

.hr-tz-loc,
.hr-tz-time,
.hr-tz-date {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

.hr-tz-loc i,
.hr-tz-time i {
  font-size: 0.7rem;
  opacity: 0.65;
}

.hr-tz-city {
  font-weight: 650;
  color: var(--hr-text);
}

.hr-tz-country {
  color: var(--hr-text-muted);
}

.hr-tz-sep {
  color: var(--hr-text-muted);
  margin: 0 -2px;
}

.hr-tz-offset {
  font-size: 0.72rem;
  color: var(--hr-text-muted);
  opacity: 0.75;
}

/* Live clock — slightly bolder so it reads as primary info */
#hrTzClock {
  font-weight: 650;
  color: var(--hr-text);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

#hrTzDate {
  color: var(--hr-text-muted);
}

/* Thin vertical separator dot between groups */
.hr-tz-divider {
  display: inline-block;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--hr-border);
  flex-shrink: 0;
  margin: 0 -4px;
}

/* Dark mode: city stays readable */
[data-theme="dark"] .hr-tz-city, [data-theme-mode="dark"] .hr-tz-city,

/* On very small screens, hide date to save space */
@media (max-width: 480px) {
  .hr-tz-date,
  .hr-tz-bar .hr-tz-divider:last-of-type { display: none; }
}
/* Advances page: align search + table with HR section tabs */
.adv-page {
  padding: 8px 30px 28px;
  margin: 0 -16px; /* cancel .content horizontal padding (16px) */
  box-sizing: border-box;
}

.adv-fund-kpis {
  margin-bottom: 16px;
}

.adv-fund-edit summary::-webkit-details-marker { display: none; }

@media (max-width: 720px) {
  .adv-page {
    padding: 8px 16px 24px;
    margin: 0;
  }
}