/* Hygienx CRM theme — cloned from the "TeamHub" HR Dashboard UI Figma template
   (creativemarket.com/peterdraw/291686957). Colors sampled directly from the
   template's own preview screenshots: teal #27BD9E, forest #0F4D42. Flat cards,
   soft shadows, no blur/glass — Hygienx branding (logo, name, real data) stays,
   the visual system is the template's own. */
:root {
  --teal: #27bd9e;
  --teal-dark: #1c9a81;
  --forest: #0f4d42;
  --teal-tint: rgba(39, 189, 158, 0.12);
  --teal-tint-strong: rgba(39, 189, 158, 0.22);

  --primary: #16211d;
  --charcoal: #2c3e50;
  --text-body: #4b5a55;
  --text-muted: #8a9994;

  --surface-app: #f2f7f5;
  --surface-soft: #eaf5f1;
  --surface-card: #ffffff;
  --border: #e6ece9;

  --danger: #e4574c;
  --warning: #f0b429;
  --info: var(--teal);

  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 22px;
  --radius: var(--radius-md);
  --shadow: 0 4px 18px rgba(16, 40, 34, 0.06);
  --shadow-md: 0 10px 30px rgba(16, 40, 34, 0.09);

  --font: 'Plus Jakarta Sans', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);

  /* aliases kept so every rule below (and the JS that references them) resolves
     under the new template palette without a wider find/replace */
  --ink: var(--primary);
  --accent: var(--teal);
  --green: var(--teal);
  --deep-green: var(--forest);
  --secondary: var(--teal-dark);
  --cyan: var(--teal);
  --offwhite: var(--surface-soft);
  --white: #ffffff;
  --grad-brand: linear-gradient(120deg, var(--teal) 0%, var(--teal-dark) 100%);
  --grad-soft: linear-gradient(135deg, #eafaf5 0%, #f4faf3 100%);
  --grad-text: linear-gradient(120deg, var(--teal), var(--forest));

  --sidebar-w: 244px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--surface-app);
  color: var(--text-body);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { color: var(--primary); font-weight: 700; letter-spacing: -0.01em; margin: 0 0 6px; }
a { color: var(--teal); }
button { font-family: inherit; }
::selection { background: var(--teal-tint-strong); }

/* ---------- Login ---------- */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-app);
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 40px 34px;
  text-align: center;
}
.login-card .brand-mark {
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 18px;
}
.login-card .brand-mark img { height: 42px; width: auto; }
.login-card h1 { font-size: 21px; margin-bottom: 4px; }
.login-card p.sub { color: var(--text-muted); font-size: 13px; margin-bottom: 26px; }
.login-card .field { text-align: left; margin-bottom: 14px; }
.login-card label { display: block; font-size: 12.5px; font-weight: 600; color: var(--primary); margin-bottom: 6px; }
.login-error { color: var(--danger); font-size: 13px; margin: 10px 0 0; min-height: 18px; }
.login-hint { margin-top: 18px; font-size: 12px; color: var(--text-muted); background: var(--teal-tint); border-radius: var(--radius-sm); padding: 10px 14px; }

/* ---------- Inputs / Buttons ---------- */
input, select, textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: var(--font);
  background: #fff;
  color: var(--primary);
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 3px var(--teal-tint);
}
textarea { resize: vertical; min-height: 70px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 10px 18px;
  font-family: var(--font);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease), background 0.2s var(--ease), color 0.2s var(--ease), border-color 0.2s var(--ease);
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--teal); color: #fff; box-shadow: 0 6px 16px rgba(39, 189, 158, 0.32); }
.btn-primary:hover { background: var(--teal-dark); box-shadow: 0 8px 20px rgba(39, 189, 158, 0.4); }
.btn-outline { color: var(--primary); background: #fff; border-color: var(--border); }
.btn-outline:hover { border-color: var(--teal); color: var(--teal); }
.btn-danger { background: #fff; color: var(--danger); border-color: rgba(228, 87, 76, 0.35); }
.btn-danger:hover { background: rgba(228, 87, 76, 0.08); }
.btn-sm { padding: 7px 14px; font-size: 12.5px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

/* ---------- App shell ---------- */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w);
  background: #fff;
  border-right: 1px solid var(--border);
  color: var(--primary);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  z-index: 10;
}
.sidebar .brand {
  display: flex; align-items: center;
  padding: 26px 20px 20px;
}
.sidebar .brand .brand-logo { width: 100%; height: auto; object-fit: contain; }

.nav-group { padding: 10px 14px; flex: 1; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-body);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  margin-bottom: 2px;
  text-decoration: none;
  transition: background 0.2s var(--ease), color 0.2s var(--ease);
}
.nav-item .ico { width: 20px; height: 20px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.nav-item .ico svg { width: 19px; height: 19px; }
.nav-item:hover { background: var(--teal-tint); color: var(--teal-dark); }
.nav-item.active { background: var(--teal); color: #fff; font-weight: 700; }

.sidebar .user-box {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  font-size: 12.5px;
}
.sidebar .user-box .u-name { color: var(--primary); font-weight: 700; }
.sidebar .user-box .u-role { color: var(--text-muted); margin-bottom: 10px; }

.main-area { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 68px; flex-shrink: 0;
  display: flex; align-items: center;
  padding: 0 26px;
  background: #fff;
  border-bottom: 1px solid var(--border);
  gap: 20px;
}
.topbar h2 { font-size: 18px; white-space: nowrap; }
.topbar .crumbs { font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.topbar-search {
  flex: 1 1 auto; max-width: 420px; margin-left: 12px; display: flex; align-items: center; gap: 8px;
  background: var(--surface-soft); border-radius: 999px; padding: 9px 16px;
  color: var(--text-muted); font-size: 13px;
}
.topbar-search svg { width: 16px; height: 16px; flex-shrink: 0; }
.topbar-icons { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.topbar-icon-btn {
  width: 38px; height: 38px; border-radius: 50%; background: var(--surface-soft);
  border: none; display: flex; align-items: center; justify-content: center; cursor: pointer;
  color: var(--text-body); flex-shrink: 0;
}
.topbar-icon-btn svg { width: 18px; height: 18px; }
.topbar-user { display: flex; align-items: center; gap: 10px; flex-shrink: 0; position: relative; cursor: pointer; }
.topbar-user .tu-name { font-size: 13px; font-weight: 700; color: var(--primary); line-height: 1.2; }
.topbar-user .tu-role { font-size: 11px; color: var(--text-muted); }
.user-dropdown {
  display: none; position: absolute; top: calc(100% + 12px); right: 0; z-index: 60;
  width: 210px; background: #fff; border: 1px solid var(--border); border-radius: var(--radius-md);
  box-shadow: var(--shadow-md); padding: 8px; cursor: default;
}
.user-dropdown.open { display: block; }
.user-dropdown-head { padding: 8px 10px 10px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.user-dropdown-head .tu-name { font-size: 13.5px; }
.user-dropdown-item {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left;
  padding: 9px 10px; border-radius: var(--radius-sm); border: none; background: none;
  font-size: 13px; color: var(--text-body); text-decoration: none; cursor: pointer;
}
.user-dropdown-item:hover { background: var(--teal-tint); color: var(--teal-dark); }
.user-dropdown-item svg { width: 16px; height: 16px; flex-shrink: 0; }

.content { padding: 26px; flex: 1; overflow-y: auto; }

.avatar-circle {
  width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--teal); color: #fff; font-weight: 700; font-size: 13px;
  text-transform: uppercase;
}
.avatar-circle.sm { width: 26px; height: 26px; font-size: 10.5px; }
.avatar-stack { display: flex; }
.avatar-stack .avatar-circle { margin-left: -8px; border: 2px solid #fff; }
.avatar-stack .avatar-circle:first-child { margin-left: 0; }
.cell-with-avatar { display: flex; align-items: center; gap: 10px; }
.cell-with-avatar .cell-sub { font-size: 11.5px; color: var(--text-muted); }

/* ---------- Cards / KPIs ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; margin-bottom: 22px; }
.kpi-card {
  background: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  box-shadow: var(--shadow);
}
.kpi-card .kpi-label { font-size: 12px; color: var(--text-muted); font-weight: 600; }
.kpi-card .kpi-value { font-size: 26px; font-weight: 800; color: var(--primary); margin-top: 8px; }
.kpi-card .kpi-sub { font-size: 11.5px; color: var(--text-muted); margin-top: 4px; }
.kpi-card.kpi-dark { background: var(--forest); border-color: var(--forest); }
.kpi-card.kpi-dark .kpi-label, .kpi-card.kpi-dark .kpi-sub { color: rgba(255,255,255,.7); }
.kpi-card.kpi-dark .kpi-value { color: #fff; }
.kpi-card.kpi-teal { background: var(--teal); border-color: var(--teal); }
.kpi-card.kpi-teal .kpi-label, .kpi-card.kpi-teal .kpi-sub { color: rgba(255,255,255,.85); }
.kpi-card.kpi-teal .kpi-value { color: #fff; }

.panel {
  background: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow);
  padding: 22px;
  margin-bottom: 20px;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; flex-wrap: wrap; gap: 10px; }
.panel-head h3 { font-size: 15px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data-table th {
  text-align: left; padding: 10px 12px;
  color: var(--text-muted); font-size: 11px; text-transform: uppercase; letter-spacing: .03em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.data-table td { padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data-table tr:hover td { background: var(--teal-tint); }
table.data-table .row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.empty-row td { text-align: center; color: var(--text-muted); padding: 34px 12px; }

/* ---------- Badges / status pills ---------- */
.badge {
  display: inline-block; padding: 3px 11px; border-radius: 999px;
  font-size: 11px; font-weight: 700; letter-spacing: .02em;
  background: var(--surface-soft); color: var(--charcoal);
}
.badge-green { background: var(--teal-tint); color: var(--teal-dark); }
.badge-blue { background: var(--teal-tint); color: var(--teal-dark); }
.badge-amber { background: rgba(240, 180, 41, .16); color: #9a6f0a; }
.badge-red { background: rgba(228, 87, 76, .13); color: var(--danger); }
.badge-grey { background: #eef1ef; color: var(--text-muted); }

/* ---------- Toolbar / search / filters ---------- */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.toolbar .search-box { position: relative; min-width: 220px; }
.toolbar select, .toolbar input { width: auto; }

.view-toggle { display: inline-flex; background: var(--surface-soft); border-radius: var(--radius-sm); padding: 3px; gap: 2px; }
.view-toggle button {
  border: none; background: none; padding: 6px 12px; border-radius: 7px; cursor: pointer;
  font-size: 12.5px; font-weight: 600; color: var(--text-muted);
}
.view-toggle button.active { background: #fff; color: var(--primary); box-shadow: var(--shadow); }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(16, 40, 34, .4);
  display: flex; align-items: center; justify-content: center;
  padding: 20px; z-index: 100;
}
.modal-box {
  background: #fff;
  border-radius: var(--radius-md); width: 100%; max-width: 560px;
  max-height: 88vh; overflow-y: auto; overflow-x: hidden;
  box-shadow: 0 24px 60px rgba(0,0,0,.22);
}
.modal-box.modal-wide { max-width: 760px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.modal-head h3 { font-size: 16px; }
.modal-close { background: none; border: none; font-size: 18px; cursor: pointer; color: var(--text-muted); }
.modal-body { padding: 20px 22px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 22px; border-top: 1px solid var(--border); }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.field label { display: block; font-size: 12.5px; font-weight: 600; color: var(--primary); margin-bottom: 6px; }

/* ---------- Line items (orders/invoices) ---------- */
.line-items-table { width: 100%; min-width: 480px; border-collapse: collapse; margin-bottom: 10px; }
.line-items-table th { text-align: left; font-size: 11px; color: var(--text-muted); padding: 6px 8px; }
.line-items-table td { padding: 6px 8px; }
.line-items-table input, .line-items-table select { padding: 7px 8px; font-size: 13px; }
.totals-box { margin-left: auto; width: 240px; font-size: 13.5px; }
.totals-box .row { display: flex; justify-content: space-between; padding: 5px 0; }
.totals-box .row.grand { font-weight: 800; font-size: 15px; border-top: 1px solid var(--border); margin-top: 4px; padding-top: 8px; color: var(--primary); }

/* ---------- Kanban (Leads) ---------- */
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: 250px; gap: 14px; overflow-x: auto; padding-bottom: 8px; }
.kanban-col { background: var(--surface-soft); border-radius: var(--radius-sm); padding: 10px; min-height: 200px; }
.kanban-col h4 { font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--text-muted); margin-bottom: 10px; display: flex; justify-content: space-between; }
.kanban-card {
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; margin-bottom: 8px;
  cursor: pointer; font-size: 13px;
  transition: box-shadow 0.2s var(--ease), transform 0.2s var(--ease);
}
.kanban-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.kanban-card .kc-name { font-weight: 700; color: var(--primary); margin-bottom: 3px; }
.kanban-card .kc-meta { font-size: 11px; color: var(--text-muted); }

/* ---------- Dashboard: charts, rings, calendar, heatmap ---------- */
.kpi-card.clickable { cursor: pointer; transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease); }
.kpi-card.clickable:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }

.charts-grid { display: grid; grid-template-columns: 1.3fr 1fr; gap: 16px; margin-bottom: 20px; }
.charts-grid .panel { margin-bottom: 0; }
@media (max-width: 1000px) { .charts-grid { grid-template-columns: 1fr; } }

.chart-legend { display: flex; gap: 16px; margin-bottom: 10px; font-size: 12px; color: var(--text-body); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend-dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.chart-summary { margin-top: 8px; font-size: 12px; color: var(--text-muted); text-align: right; }

.hbar-row { display: flex; align-items: center; gap: 10px; padding: 6px 0; }
.hbar-label { width: 40%; min-width: 110px; font-size: 12px; color: var(--text-body); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar-track { flex: 1; height: 14px; background: var(--surface-soft); border-radius: 999px; overflow: hidden; }
.hbar-fill { height: 100%; border-radius: 999px; transition: width .3s var(--ease); }
.hbar-value { width: 48px; text-align: right; font-size: 12px; font-weight: 700; color: var(--primary); font-variant-numeric: tabular-nums; }

/* Ring (donut) charts — leave-balance style KPI */
.ring-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 14px; margin-bottom: 20px; }
.ring-card { background: var(--surface-card); border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: var(--shadow); padding: 16px; text-align: center; }
.ring-card svg { display: block; margin: 0 auto 8px; }
.ring-card .ring-value { font-size: 18px; font-weight: 800; fill: var(--primary); }
.ring-card .ring-label { font-size: 12px; font-weight: 700; color: var(--primary); }
.ring-card .ring-sub { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* Calendar widget */
.mini-cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.mini-cal-head .mc-nav { display: flex; gap: 4px; }
.mini-cal-head button { width: 28px; height: 28px; border-radius: 8px; border: 1px solid var(--border); background: #fff; cursor: pointer; color: var(--text-body); }
.mini-cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; text-align: center; }
.mini-cal-grid .mc-dow { font-size: 10.5px; color: var(--text-muted); font-weight: 700; padding-bottom: 6px; }
.mini-cal-grid .mc-day {
  font-size: 12.5px; padding: 7px 0; border-radius: 8px; color: var(--text-body); position: relative; cursor: default;
}
.mini-cal-grid .mc-day.muted { color: var(--border); }
.mini-cal-grid .mc-day.today { background: var(--teal); color: #fff; font-weight: 700; }
.mini-cal-grid .mc-day.has-event::after {
  content: ''; position: absolute; bottom: 2px; left: 50%; transform: translateX(-50%);
  width: 4px; height: 4px; border-radius: 50%; background: var(--teal);
}
.mini-cal-grid .mc-day.today.has-event::after { background: #fff; }

/* Heatmap grid (activity intensity) */
.heatmap-grid { display: grid; gap: 4px; }
.heatmap-cell { aspect-ratio: 1; border-radius: 4px; background: var(--surface-soft); }
.heatmap-legend { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--text-muted); margin-top: 10px; justify-content: flex-end; }
.heatmap-legend .hl-box { width: 11px; height: 11px; border-radius: 3px; }

.dash-tabrow { display: flex; gap: 8px; margin-bottom: 16px; }
.dash-tab {
  padding: 7px 16px; border-radius: 999px; font-size: 12.5px; font-weight: 600;
  background: var(--surface-soft); color: var(--text-muted); cursor: pointer; border: 1px solid transparent;
  transition: all 0.2s var(--ease);
}
.dash-tab.active { background: var(--teal); color: #fff; }

.activity-feed { display: flex; flex-direction: column; }
.activity-row { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--border); cursor: pointer; }
.activity-row:last-child { border-bottom: none; }
.activity-row:hover { background: var(--teal-tint); margin: 0 -8px; padding: 10px 8px; border-radius: var(--radius-sm); }
.activity-icon { width: 30px; height: 30px; border-radius: 10px; background: var(--surface-soft); display: flex; align-items: center; justify-content: center; font-size: 14px; flex-shrink: 0; }
.activity-text { font-size: 13px; color: var(--text-body); }
.activity-text b { color: var(--primary); }
.activity-time { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* ---------- Toasts ---------- */
.toast-stack { position: fixed; top: 18px; right: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast {
  background: #fff; border: 1px solid var(--border);
  border-left: 4px solid var(--teal); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md); padding: 12px 16px; font-size: 13.5px; min-width: 220px;
}
.toast.error { border-left-color: var(--danger); color: var(--danger); }

/* ---------- Misc ---------- */
.text-muted { color: var(--text-muted); }
.stock-low { color: var(--danger); font-weight: 700; }
.empty-state { text-align: center; padding: 50px 20px; color: var(--text-muted); }
.empty-state .es-icon { font-size: 34px; margin-bottom: 10px; }

.menu-toggle {
  display: none; width: 38px; height: 38px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--surface-soft);
  align-items: center; justify-content: center;
  cursor: pointer; margin-right: 12px; flex-shrink: 0; color: var(--text-body);
}
.menu-toggle svg { width: 18px; height: 18px; }
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(16, 40, 34, .4); z-index: 49; }
.sidebar-overlay.show { display: block; }

@media (max-width: 860px) {
  .sidebar { position: fixed; z-index: 50; height: 100%; transform: translateX(-100%); transition: transform .3s var(--ease); }
  .sidebar.open { transform: translateX(0); }
  .menu-toggle { display: inline-flex; align-items: center; justify-content: center; }
  .topbar { padding: 0 14px; }
  .topbar-search { display: none; }
  .content { padding: 14px; }
  .form-grid { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .modal-backdrop { padding: 0; align-items: flex-end; }
  .modal-box { max-width: 100%; max-height: 92vh; border-radius: var(--radius-md) var(--radius-md) 0 0; }
}

@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .toolbar { width: 100%; }
  .toolbar .search-box { min-width: 0; flex: 1; }
  .panel-head { flex-direction: column; align-items: stretch; }
}
