@font-face {
  font-family: 'BZar';
  src: url('../fonts/BZar.ttf') format('truetype');
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: 'BZar';
  src: url('../fonts/BZarBd.ttf') format('truetype');
  font-weight: 600 700;
  font-display: swap;
}

:root {
  --bg: #f4f5f2;
  --surface: #ffffff;
  --border: #e2e4de;
  --text: #1f2421;
  --text-secondary: #5f6661;
  --text-muted: #9aa09b;
  --primary: #2f8f4e;
  --primary-hover: #267a41;
  --primary-soft: #e6f3ea;
  --accent: #1f6fb5;
  --danger: #b3261e;
  --danger-soft: #fcebea;

  /* Type scale: the only font sizes allowed across the automation */
  --font: 'BZar', Tahoma, sans-serif;
  --fs-page-title: 18px;
  --fs-section: 16px;
  --fs-card: 15px;
  --fs-body: 14px;
  --fs-small: 12px;
  --lh-body: 1.8;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  background: var(--bg);
  color: var(--text);
}

h1, h2, h3, h4 { font-weight: 600; line-height: 1.5; margin: 0; }
h1, .page-title { font-size: var(--fs-page-title); }
h2, .section-title { font-size: var(--fs-section); }
h3, h4, .card-title { font-size: var(--fs-card); }
.text-small { font-size: var(--fs-small); }
.text-secondary { color: var(--text-secondary); }
.text-muted { color: var(--text-muted); }

input, select, textarea, button { font-family: var(--font); font-size: var(--fs-body); }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Login */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 2rem 1.75rem;
}

.login-head { text-align: center; margin-bottom: 1.5rem; }

.logo {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.login-head h1 { margin: 12px 0 4px; }
.login-head p { font-size: var(--fs-small); color: var(--text-secondary); margin: 0; }

.field { margin-bottom: 14px; }
.field label { display: block; color: var(--text-secondary); margin-bottom: 4px; }

.input-wrap { position: relative; }
.input-wrap svg { position: absolute; top: 50%; transform: translateY(-50%); color: var(--text-muted); }
.input-wrap .icon-start { right: 11px; pointer-events: none; }
.input-wrap .toggle-pass {
  position: absolute; left: 6px; top: 50%; transform: translateY(-50%);
  background: none; border: none; padding: 4px; cursor: pointer; color: var(--text-muted);
  display: flex;
}
.input-wrap .toggle-pass svg { position: static; transform: none; }

.input-wrap input {
  width: 100%;
  height: 42px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 38px 0 12px;
  background: #fff;
  color: var(--text);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.input-wrap input[type="password"], .input-wrap input.has-toggle { padding-left: 38px; }
.input-wrap input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.input-wrap input[dir="ltr"] { text-align: right; }

.row-between {
  display: flex; justify-content: space-between; align-items: center;
  font-size: var(--fs-small); margin: 4px 0 1.25rem;
}
.row-between label { display: flex; align-items: center; gap: 6px; color: var(--text-secondary); cursor: pointer; }

.btn-primary {
  width: 100%; height: 42px;
  font-weight: 600;
  background: var(--primary); color: #fff;
  border: none; border-radius: 8px; cursor: pointer;
}
.btn-primary:hover { background: var(--primary-hover); }

.alert {
  padding: 10px 12px; border-radius: 8px; margin-bottom: 14px;
  background: var(--danger-soft); color: var(--danger);
}
.alert.info { background: var(--primary-soft); color: var(--primary-hover); }

/* App layout */
:root {
  --page: #f1f2f4;
  --nav-active: #6a9f2a;
  --c-purple: #9b5de5; --c-purple-soft: #efe3fb;
  --c-blue: #1e88e5;   --c-blue-soft: #dcecfb;
  --c-mint: #2ecc71;   --c-mint-soft: #dff6e5;
  --c-amber: #f5a623;  --c-amber-soft: #fdf1d8;
  --c-rose: #f28b82;   --c-rose-soft: #fde4e1;
}
body:has(.app) { background: var(--page); }
.app { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 16px; padding: 16px; min-height: 100vh; }
/* Sidebar: sticky while scrolling, collapses to icons only (html.side-mini) */
.side { width: 236px; background: var(--surface); border-radius: 16px; padding: 18px 12px; position: sticky; top: 16px; z-index: 40; height: calc(100vh - 32px); display: flex; flex-direction: column; box-shadow: 0 2px 10px rgba(30,40,60,.04); transition: width .2s; }
.brand { display: flex; align-items: center; gap: 8px; font-size: 26px; font-weight: 700; padding: 0 10px 22px; white-space: nowrap; overflow: hidden; }
.brand svg { width: 28px; height: 28px; color: var(--nav-active); flex: none; }
.nav { overflow-y: auto; overflow-x: hidden; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; color: var(--text-secondary); text-decoration: none; font-size: var(--fs-card); font-weight: 700; margin-bottom: 4px; white-space: nowrap; overflow: hidden; }
.nav a:hover { background: var(--page); text-decoration: none; }
.nav a.active { background: var(--nav-active); color: #fff; box-shadow: 0 4px 12px rgba(106,159,42,.3); }
.nav svg { width: 21px; height: 21px; flex: none; }
.nav .sep { border-top: 1px solid var(--border); margin: 10px 8px; }
.nav a .chev { margin-right: auto; opacity: .6; font-size: var(--fs-card); }
/* Side submenu: opens next to the sidebar while the mouse is on its item (positioned by app.html script) */
.flyout { position: fixed; width: 270px; background: var(--surface); border-radius: 14px; box-shadow: 0 14px 34px rgba(30,40,60,.16); padding: 12px 10px; z-index: 70; opacity: 0; visibility: hidden; transform: translateX(6px); transition: opacity .15s, transform .15s, visibility .15s; }
.flyout::before { content: ''; position: absolute; top: 18px; right: -7px; border: 7px solid transparent; border-left-color: var(--surface); border-right: none; }
/* Invisible bridge so the mouse can cross the gap from the sidebar to the submenu */
.flyout::after { content: ''; position: absolute; top: 0; bottom: 0; right: -32px; width: 32px; }
.nav-group:hover .flyout, .nav-group:focus-within .flyout { opacity: 1; visibility: visible; transform: none; }
.nav-group:hover > a { background: var(--page); }
.flyout h4 { margin: 0 0 6px; padding: 0 8px; font-size: var(--fs-card); display: flex; align-items: center; gap: 6px; }
.flyout h4 svg { width: 18px; height: 18px; color: var(--nav-active); }
.nav .flyout a { font-weight: 400; padding: 8px 10px; align-items: flex-start; white-space: normal; margin: 0; }
.nav .flyout a:hover { background: #f4f9ee; color: #3b6d11; }
.nav .flyout a svg { width: 19px; height: 19px; color: var(--nav-active); margin-top: 3px; }
.flyout small { display: block; font-size: 11px; color: var(--text-muted); }
/* Notifications bell (in the sidebar header) */
.brand .bell-group { margin-right: auto; }
.bell { position: relative; width: 36px; height: 36px; border-radius: 11px; border: 1px solid var(--border); display: flex; align-items: center; justify-content: center; color: var(--text-secondary); }
.bell svg { width: 20px; height: 20px; }
.bell:hover { color: var(--text); text-decoration: none; }
.bell .n { position: absolute; top: -6px; left: -6px; min-width: 19px; height: 19px; border-radius: 10px; background: var(--danger); color: #fff; font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center; padding: 0 5px; border: 2px solid #fff; }
html.side-mini .brand { flex-direction: column; gap: 10px; }
html.side-mini .brand .bell-group { margin: 0; }
.notes-fly { width: 380px; padding: 0; overflow: hidden; font-size: var(--fs-body); font-weight: 400; }
.notes-fly h4 { margin: 0; padding: 12px 16px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.notes-fly .lnk { background: none; border: none; color: var(--accent); cursor: pointer; font-size: var(--fs-small); }
.notes-fly .nitem { display: flex; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); color: inherit; text-decoration: none; white-space: normal; }
.notes-fly .nitem:hover { background: #f6f7f9; text-decoration: none; }
.notes-fly .nitem.unread { background: #fffaf0; }
.notes-fly .nitem b { display: block; font-size: var(--fs-body); }
.notes-fly .nitem small { display: block; font-size: var(--fs-small); color: var(--text-secondary); line-height: 1.8; }
.notes-fly .nitem time { font-size: 11px; color: var(--text-muted); }
.nico { width: 34px; height: 34px; border-radius: 10px; display: flex; align-items: center; justify-content: center; flex: none; font-weight: 700; background: var(--c-blue-soft); color: #0c447c; }
.nico.success { background: var(--c-mint-soft); color: #085041; }
.nico.warning { background: #fff7e6; color: #8a6100; }
.nico.danger { background: var(--danger-soft); color: var(--danger); }
.nempty { padding: 18px 16px; color: var(--text-muted); }
.flyout .badge-new { margin-right: auto; background: var(--danger-soft); color: var(--danger); font-size: 11px; border-radius: 8px; padding: 0 7px; font-weight: 700; }
.collapse-btn { position: absolute; left: -14px; top: 50%; transform: translateY(-50%); width: 28px; height: 28px; border-radius: 50%; background: var(--surface); border: 1px solid var(--border); box-shadow: 0 2px 8px rgba(30,40,60,.12); display: flex; align-items: center; justify-content: center; cursor: pointer; color: var(--text-secondary); padding: 0; z-index: 5; }
.collapse-btn:hover { color: var(--text); }
.collapse-btn svg { transition: transform .2s; }
html.side-mini .side { width: 72px; }
html.side-mini .side .t { display: none; }
html.side-mini .brand, html.side-mini .nav a { justify-content: center; padding-left: 0; padding-right: 0; }
html.side-mini .side-user { justify-content: center; }
html.side-mini .collapse-btn svg { transform: rotate(180deg); }
.side-user { margin-top: auto; border-top: 1px solid var(--border); padding: 12px 8px 0; display: flex; align-items: center; justify-content: space-between; }
.side-user .name { font-weight: 700; }
.icon-btn { background: none; border: none; color: var(--text-secondary); cursor: pointer; padding: 6px; border-radius: 8px; display: flex; }
.icon-btn:hover { background: var(--page); color: var(--danger); }
.main { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.topbar { background: var(--surface); border-radius: 12px; padding: 14px 20px; display: flex; align-items: center; gap: 24px; }
.topbar .date { color: var(--text-secondary); display: flex; align-items: center; gap: 6px; }
.topbar .spacer { flex: 1; }
.range-toggle { display: flex; align-items: center; gap: 8px; color: var(--text-secondary); }
.range-toggle a { color: inherit; }
.range-toggle a.on { color: var(--text); font-weight: 700; }
.switch { width: 34px; height: 18px; border-radius: 9px; background: #5f6b7a; position: relative; display: inline-block; }
.switch::after { content: ''; position: absolute; width: 14px; height: 14px; border-radius: 50%; background: #fff; top: 2px; left: 2px; transition: left .15s; }
.switch.ytd::after { left: 18px; }

/* Dashboard sections */
.section { background: var(--surface); border-radius: 12px; padding: 14px 16px 16px; border-top: 4px solid var(--c); }
.section > h2 { margin: 0 0 12px; display: flex; align-items: center; gap: 8px; }
.section > h2 .badge { width: 28px; height: 28px; border-radius: 8px; background: var(--c-soft); color: var(--c); display: inline-flex; align-items: center; justify-content: center; }
.section > h2 .badge svg { width: 18px; height: 18px; }
.cols { display: grid; gap: 12px; }
.box { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; display: flex; flex-direction: column; min-width: 0; }
.box h3 { text-align: center; margin: 0 0 8px; }
.kpis { display: grid; gap: 8px; align-content: start; }
.kpi { border-radius: 10px; padding: 10px 12px; background: var(--k-soft); display: flex; align-items: center; gap: 10px; }
.kpi .dot { width: 34px; height: 34px; border-radius: 50%; background: var(--k); flex: none; }
.kpi .v { font-size: var(--fs-section); font-weight: 700; line-height: 1.4; }
.kpi .l { font-size: var(--fs-small); color: var(--text-secondary); }
.chart { position: relative; height: 180px; }
.chart.short { height: 160px; }
.gauge-wrap { position: relative; height: 130px; }
.gauge-val { position: absolute; inset: auto 0 14px 0; text-align: center; font-size: 30px; font-weight: 700; }
.gauge-ends { display: flex; justify-content: space-between; font-size: var(--fs-small); color: var(--text-secondary); }
.act { display: flex; align-items: center; gap: 10px; padding: 7px 4px; border-bottom: 1px solid var(--border); }
.act:last-child { border: none; }
.act .dot { width: 20px; height: 20px; border-radius: 50%; flex: none; }
.act .n { font-weight: 700; font-size: var(--fs-section); min-width: 22px; }
.act .t { flex: 1; font-size: var(--fs-small); color: var(--text-secondary); }
.pair { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; }
.sample-note { font-size: var(--fs-small); color: var(--text-muted); text-align: center; }

.foot-note { font-size: var(--fs-small); color: var(--text-muted); text-align: center; margin: 1.25rem 0 0; }

/* ---------- Responsive: phone and tablet ---------- */
.mbar, .side-shade { display: none; }
@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); padding: 10px; gap: 10px; }
  /* Sidebar slides in from the right as a drawer */
  .side, html.side-mini .side { position: fixed; top: 0; right: 0; height: 100vh; width: min(290px, 86vw); border-radius: 0; z-index: 90; transform: translateX(100%); transition: transform .22s; }
  html.side-open .side { transform: none; box-shadow: -10px 0 30px rgba(0,0,0,.2); }
  html.side-mini .side .t { display: initial; }
  html.side-mini .brand { flex-direction: row; }
  html.side-mini .brand, html.side-mini .nav a { justify-content: flex-start; padding: 10px 12px; }
  .collapse-btn { display: none; }
  .side-shade { position: fixed; inset: 0; background: rgba(20,25,35,.38); z-index: 85; }
  html.side-open .side-shade { display: block; }
  .mbar { display: flex; align-items: center; gap: 10px; background: var(--surface); border-radius: 12px; padding: 6px 10px; position: sticky; top: 6px; z-index: 30; box-shadow: 0 2px 10px rgba(30,40,60,.06); }
  .mbar b { font-size: 18px; }
  .mbar-n { margin-right: auto; background: var(--danger-soft); color: var(--danger); border-radius: 8px; padding: 0 8px; font-size: var(--fs-small); font-weight: 700; }
  /* Submenus open in place under their item */
  .flyout { position: static; width: auto; box-shadow: none; padding: 4px 0 8px 0; display: none; opacity: 1; visibility: visible; transform: none; }
  .flyout::before, .flyout::after { display: none; }
  .nav-group.open .flyout { display: block; }
  .nav-group:hover .flyout { opacity: 1; }
  .notes-fly { width: auto; border: 1px solid var(--border); border-radius: 12px; }
  .brand .bell-group { position: static; }
  .brand { flex-wrap: wrap; }
  .brand .bell-group.open { flex-basis: 100%; order: 3; }
  .topbar { flex-wrap: wrap; gap: 10px; padding: 10px 14px; }
  .pair { grid-template-columns: minmax(0, 1fr); }
  .cols { grid-template-columns: minmax(0, 1fr) !important; }
}
@media (min-width: 901px) and (max-width: 1200px) {
  .cols { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
}

.side-user a.name { color: inherit; text-decoration: none; display: block; }
.side-user a.name:hover { color: var(--nav-active); }

/* Settings gear beside the bell */
.brand .gear { margin-right: 6px; }
.brand .gear.on { border-color: var(--nav-active); color: var(--nav-active); }
html.side-mini .brand .gear { margin: 0; }

/* Body colours chosen in Settings: frosted glass, clear glass, light blue */
html[data-site-theme="frosted"] body:has(.app) { background: linear-gradient(135deg, #dbeafe 0%, #ede9fe 50%, #fce7f3 100%) fixed; }
html[data-site-theme="clear"] body:has(.app) { background: linear-gradient(135deg, #a5f3fc 0%, #c4b5fd 55%, #fbcfe8 100%) fixed; }
html[data-site-theme="blue"] body:has(.app) { background: #e8f2fc; }
html[data-site-theme="frosted"] :is(.side, .topbar, .section, .panel, .sc-kpi, .jobrow, .hc, .ob-card, .wl-box, .st-card, .kc, .card, .flyout, .mbar, .wl-links a) {
  background: rgba(255, 255, 255, .62); backdrop-filter: blur(14px) saturate(140%); -webkit-backdrop-filter: blur(14px) saturate(140%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .7), 0 8px 24px rgba(60, 60, 120, .08);
}
html[data-site-theme="clear"] :is(.side, .topbar, .section, .panel, .sc-kpi, .jobrow, .hc, .ob-card, .wl-box, .st-card, .kc, .card, .flyout, .mbar, .wl-links a) {
  background: rgba(255, 255, 255, .32); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .85), 0 8px 24px rgba(60, 60, 120, .1);
}

/* Employee section menu: emoji icons sized like the svg ones */
.nav .si { width: 21px; height: 21px; flex: none; display: grid; place-items: center; font-size: 17px; line-height: 1; }
.staff-view { display: inline-flex; align-items: center; gap: 6px; background: #f1f8e9; color: #33691e; border: 1.5px solid #c5e1a5; border-radius: 12px; padding: 7px 14px; font-weight: bold; font-size: 14.5px; text-decoration: none; margin-left: 10px; }
.staff-view:hover { background: #dcedc8; }
.flyout a.soon { opacity: .55; cursor: default; }
.flyout h4 .si, .flyout a .si { width: 21px; height: 21px; display: grid; place-items: center; font-size: 17px; flex: none; }
.nav-count { margin-right: auto; background: #e53935; color: #fff; border-radius: 10px; min-width: 20px; height: 20px; padding: 0 6px; display: inline-grid; place-items: center; font-size: 12px; }

/* One font everywhere: code, numbers and form controls use B Zar too */
code, kbd, samp, pre, tt, var, input, select, textarea, button, option, optgroup, table, th, td { font-family: var(--font); }

/* Team chart: taller on phones so the legend can sit under the ring */
@media (max-width: 700px) { .dept-chart { height: 380px !important; } }
