/**
 * NRW India — Business Operating System
 * Primary Design System & UI Stylesheet
 */

:root {
  --g: #1AAE4A;
  --g-dark: #148C3B;
  --g-darker: #0E6B2D;
  --g-soft: #E8F7ED;
  --g-soft2: #D3F0DF;
  --ink: #10231A;
  --ink-2: #17321F;
  --bg: #F5F7F6;
  --card: #FFFFFF;
  --border: #E6EAE7;
  --text: #1B241E;
  --muted: #697066;
  --muted-2: #98A09A;
  --blue: #2563EB;
  --blue-soft: #E9F0FE;
  --amber: #C77700;
  --amber-soft: #FDF1DF;
  --red: #DC2626;
  --red-soft: #FCEBEB;
  --pink: #DB2777;
  --pink-soft: #FCEAF3;
  --violet: #7C3AED;
  --violet-soft: #F1EBFE;
  --teal: #0D9488;
  --teal-soft: #E2F6F4;
  --shadow: 0 1px 2px rgba(16,35,26,.05);
  --shadow-lg: 0 12px 34px rgba(16,35,26,.12);
  --r: 14px;
}

*, *::before, *::after { box-sizing: border-box; }
html, body {
  height: 100%;
  max-width: 100vw;
  overflow-x: hidden;
}
body {
  margin: 0;
  font-family: 'Poppins', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  font-size: 14px;
}
button, input, select, textarea { font-family: inherit; }
a { color: inherit; text-decoration: none; }
::selection { background: var(--g-soft2); color: var(--g-darker); }
:focus-visible { outline: 2px solid var(--g); outline-offset: 2px; }

/* ================= SHELL LAYOUT ================= */
.app {
  display: grid;
  grid-template-columns: 256px 1fr;
  min-height: 100vh;
  max-width: 100vw;
  overflow-x: hidden;
}

.sidebar {
  background: var(--card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 16px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 40;
}

.sb-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 6px 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}

.sb-mark {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  background: var(--g);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(26,174,74,.25);
}

.sb-name {
  font-size: 14.5px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.15;
  letter-spacing: -.01em;
}

.sb-sub {
  font-size: 10.5px;
  color: var(--muted-2);
  margin-top: 2px;
}

.sb-close {
  margin-left: auto;
  display: none;
  color: var(--muted);
  cursor: pointer;
}

.nav-lbl {
  font-size: 9.5px;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--muted-2);
  padding: 12px 12px 6px;
  font-weight: 600;
}

.nav {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
  overflow-y: auto;
}
.nav::-webkit-scrollbar { width: 0; }

.nav-link {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 12px;
  border-radius: 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s, color .15s;
  text-decoration: none;
}
.nav-link svg {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
  color: var(--muted-2);
  transition: color .15s;
}
.nav-link:hover {
  background: var(--bg);
  color: var(--text);
}
.nav-link:hover svg {
  color: var(--text);
}
.nav-link.active {
  background: var(--g-soft);
  color: var(--g-darker);
  font-weight: 600;
}
.nav-link.active svg {
  color: var(--g);
}

.nav-count {
  margin-left: auto;
  font-size: 10.5px;
  font-weight: 600;
  background: var(--bg);
  color: var(--muted);
  padding: 2px 7px;
  border-radius: 20px;
}
.nav-link.active .nav-count {
  background: #fff;
  color: var(--g-dark);
}

.sb-card {
  margin-top: 12px;
  background: var(--g-soft);
  border: 1px solid var(--g-soft2);
  border-radius: 12px;
  padding: 12px;
}
.sb-card h5 {
  margin: 0 0 3px;
  font-size: 11.5px;
  color: var(--g-darker);
  font-weight: 600;
}
.sb-card p {
  margin: 0 0 8px;
  font-size: 10.5px;
  color: var(--g-dark);
  line-height: 1.45;
}
.sb-card .mb-bar {
  height: 5px;
  border-radius: 4px;
  background: #fff;
  overflow: hidden;
}
.sb-card .mb-bar span {
  display: block;
  height: 100%;
  background: var(--g);
}

.sb-foot {
  border-top: 1px solid var(--border);
  padding-top: 12px;
  margin-top: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.sb-fname {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sb-frole {
  font-size: 10px;
  color: var(--muted-2);
}
.sb-out {
  margin-left: auto;
  color: var(--muted-2);
  cursor: pointer;
  padding: 5px;
  border-radius: 7px;
  display: inline-flex;
}
.sb-out:hover {
  background: var(--bg);
  color: var(--red);
}

.scrim {
  position: fixed;
  inset: 0;
  background: rgba(16,35,26,.55);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  z-index: 998;
  display: none;
}
.scrim.on { display: block; }

.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* ================= TOPBAR ================= */
.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 28px;
  border-bottom: 1px solid var(--border);
  background: var(--card);
  position: sticky;
  top: 0;
  z-index: 30;
}

.burger {
  display: none;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
  align-items: center;
  justify-content: center;
  color: var(--text);
  cursor: pointer;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.burger svg { pointer-events: none; }

.crumb {
  font-size: 12px;
  color: var(--muted-2);
  white-space: nowrap;
}
.crumb b {
  color: var(--text);
  font-weight: 600;
}

.tsearch {
  flex: 1;
  position: relative;
  max-width: 380px;
}
.tsearch svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 15px;
  height: 15px;
  color: var(--muted-2);
}
.tsearch input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 12px 8px 36px;
  font-size: 12.5px;
  color: var(--text);
  outline: none;
}
.tsearch input:focus {
  border-color: var(--g);
  background: #fff;
  box-shadow: 0 0 0 3px var(--g-soft);
}

.tb-right {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

/* Company Switcher Dropdown */
.company-selector {
  position: relative;
}
.comp-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  transition: all .15s;
}
.comp-btn:hover { background: var(--bg); }
.comp-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--g);
}
.comp-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 290px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 12px 36px rgba(0,0,0,0.12);
  padding: 8px;
  display: none;
  z-index: 10050;
}
.comp-menu.show { display: block; }
.comp-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 9px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  transition: all .14s;
  border: 1px solid transparent;
  margin-bottom: 2px;
}
.comp-item:hover { background: var(--bg); border-color: var(--border); }
.comp-item.active { background: var(--g-soft); color: var(--g-darker); border-color: #86EFAC; font-weight: 600; }
.comp-badge {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 11px;
  flex-shrink: 0;
  letter-spacing: -0.02em;
}

.role-chip {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 20px;
  background: var(--g-soft);
  color: var(--g-darker);
  white-space: nowrap;
}

.icon-btn {
  width: 35px;
  height: 35px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
}
.icon-btn:hover { background: var(--bg); color: var(--text); }
.icon-btn .dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--red);
  border: 1.5px solid #fff;
}

/* User Menu Dropdown */
.user-dropdown { position: relative; }
.user-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  width: 200px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  padding: 6px;
  display: none;
  z-index: 50;
}
.user-menu.show { display: block; }
.user-menu-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 12.5px;
  color: var(--text);
  text-decoration: none;
}
.user-menu-item:hover { background: var(--bg); }
.user-menu-item.danger { color: var(--red); }
.user-menu-item.danger:hover { background: var(--red-soft); }

/* ================= PAGE HEAD & CONTENT ================= */
.phead {
  padding: 22px 28px 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}
.phead h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -.025em;
  color: var(--ink);
}
.phead p {
  margin: 4px 0 0;
  font-size: 12.5px;
  color: var(--muted);
}
.hactions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

#content {
  padding: 18px 28px 60px;
  animation: fade .16s ease;
}
@keyframes fade {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

/* ================= PRIMITIVES & BUTTONS ================= */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid transparent;
  border-radius: 10px;
  font-size: 12.5px;
  font-weight: 600;
  padding: 9px 15px;
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
  font-family: inherit;
  text-decoration: none;
}
.btn svg { width: 15px; height: 15px; }
.btn-primary { background: var(--g); color: #fff; }
.btn-primary:hover { background: var(--g-dark); }
.btn-dark { background: var(--ink); color: #fff; }
.btn-dark:hover { background: var(--ink-2); }
.btn-outline { background: #fff; border-color: var(--border); color: var(--text); }
.btn-outline:hover { background: var(--bg); }
.btn-ghost { background: transparent; color: var(--text); padding: 6px 10px; font-weight: 500; }
.btn-ghost:hover { background: var(--bg); }
.btn-dang { background: transparent; color: var(--red); padding: 6px 10px; font-weight: 500; }
.btn-dang:hover { background: var(--red-soft); }
.btn-sm { padding: 6px 11px; font-size: 11.5px; border-radius: 8px; }
.btn-lg { padding: 12px 20px; font-size: 13.5px; width: 100%; justify-content: center; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  padding: 18px;
}
.phd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}
.phd h3 {
  margin: 0;
  font-size: 14.5px;
  font-weight: 600;
  color: var(--ink);
}
.link {
  font-size: 12px;
  color: var(--g-dark);
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}
.link:hover { text-decoration: underline; }
.stitle {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--ink);
  margin: 0 0 12px;
}

/* Grids */
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: 1fr 1fr; }
.g3 { grid-template-columns: repeat(3, 1fr); }
.g4 { grid-template-columns: repeat(4, 1fr); }
.g32 { grid-template-columns: 1.6fr 1fr; }
.g23 { grid-template-columns: 1fr 1.6fr; }
@media(max-width: 1150px) {
  .g3, .g4 { grid-template-columns: 1fr 1fr; }
  .g32, .g23 { grid-template-columns: 1fr; }
}
@media(max-width: 700px) {
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
}

/* Stat Cards */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 13px;
  margin-bottom: 16px;
}
.stat {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 16px;
  box-shadow: var(--shadow);
}
.stat-t {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 13px;
}
.stat-ic {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.trend {
  font-size: 10.5px;
  font-weight: 600;
}
.trend.up { color: var(--g); }
.trend.down { color: var(--red); }
.stat-n {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -.02em;
  color: var(--ink);
  line-height: 1.1;
}
.stat-l {
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 6px;
  font-weight: 500;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 10.5px;
  font-weight: 600;
  white-space: nowrap;
}
.b-g { background: var(--g-soft); color: var(--g-darker); }
.b-a { background: var(--amber-soft); color: var(--amber); }
.b-r { background: var(--red-soft); color: var(--red); }
.b-b { background: var(--blue-soft); color: var(--blue); }
.b-v { background: var(--violet-soft); color: var(--violet); }
.b-p { background: var(--pink-soft); color: var(--pink); }
.b-t { background: var(--teal-soft); color: var(--teal); }
.b-m { background: #F0F2F0; color: var(--muted); }
.dt { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* Tables */
.tw, .tbl, .table-responsive {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.sx { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table {
  width: 100%;
  border-collapse: collapse;
  min-width: 600px;
}
thead th {
  text-align: left;
  font-size: 10px;
  font-weight: 600;
  color: var(--muted);
  padding: 11px 15px;
  border-bottom: 1px solid var(--border);
  background: #FAFBFA;
  letter-spacing: .04em;
  text-transform: uppercase;
  white-space: nowrap;
}
tbody td {
  padding: 12px 15px;
  font-size: 12.5px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #FAFBFA; }
.tt { font-weight: 600; color: var(--ink); font-size: 12.5px; }
.ts { font-size: 11px; color: var(--muted-2); margin-top: 2px; }
.ra { display: flex; gap: 4px; justify-content: flex-end; }
.mono { font-variant-numeric: tabular-nums; }
.av {
  width: 28px;
  height: 28px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 10.5px;
  font-weight: 600;
  flex-shrink: 0;
}
.avr { display: flex; align-items: center; gap: 9px; }
.avs { display: flex; }
.avs .av {
  width: 24px;
  height: 24px;
  border: 2px solid #fff;
  margin-left: -7px;
  border-radius: 8px;
  font-size: 9px;
}
.avs .av:first-child { margin-left: 0; }

/* Progress bars */
.bt { height: 6px; background: #EEF1EE; border-radius: 4px; overflow: hidden; }
.bf { height: 100%; border-radius: 4px; background: var(--g); }
.br {
  display: grid;
  grid-template-columns: 120px 1fr 60px;
  align-items: center;
  gap: 10px;
  margin-bottom: 11px;
  font-size: 11.5px;
}
.br:last-child { margin-bottom: 0; }
.bl { color: var(--text); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bv { text-align: right; color: var(--muted); font-weight: 600; }

/* Empty state */
.empty { padding: 40px 20px; text-align: center; color: var(--muted); }
.empty b { display: block; font-size: 13.5px; color: var(--ink); margin-bottom: 5px; }
.empty p { max-width: 340px; margin: 0 auto; font-size: 12px; line-height: 1.55; }

/* Chart Bars */
.cols {
  display: flex;
  align-items: flex-end;
  gap: 9px;
  height: 150px;
  padding-top: 6px;
}
.col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
}
.col .stk {
  width: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  height: 100%;
  gap: 2px;
}
.col .seg { width: 100%; border-radius: 4px 4px 0 0; }
.col span { font-size: 10px; color: var(--muted-2); }
.lg { display: flex; gap: 13px; flex-wrap: wrap; }
.lg i { width: 9px; height: 9px; border-radius: 3px; display: inline-block; margin-right: 6px; }
.lg span { font-size: 11px; color: var(--muted); display: inline-flex; align-items: center; }
.donut { width: 116px; height: 116px; border-radius: 50%; flex-shrink: 0; position: relative; }
.donut::after { content: ''; position: absolute; inset: 26px; border-radius: 50%; background: var(--card); }
.dc { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; z-index: 1; }
.dc b { font-size: 17px; color: var(--ink); line-height: 1; }
.dc span { font-size: 9.5px; color: var(--muted-2); }
.ring { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }

/* Kanban */
.kanban {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  align-items: start;
}
@media(max-width: 1050px) { .kanban { grid-template-columns: repeat(2, 1fr); } }
@media(max-width: 620px) { .kanban { grid-template-columns: 1fr; } }
.kcol {
  background: #EFF2F0;
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 11px;
  min-height: 160px;
  transition: all .15s;
}
.kcol.over { background: var(--g-soft); border-color: var(--g); }
.kch { display: flex; align-items: center; gap: 7px; margin-bottom: 10px; padding: 0 3px; }
.kch b { font-size: 12px; font-weight: 600; color: var(--ink); }
.kch .n {
  font-size: 10.5px;
  color: var(--muted);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 0 7px;
  margin-left: auto;
}
.kcard {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 11px;
  margin-bottom: 9px;
  cursor: grab;
  box-shadow: var(--shadow);
  transition: box-shadow .15s, transform .15s;
}
.kcard:active { cursor: grabbing; }
.kcard.dragging { opacity: .45; }
.kcard h4 {
  margin: 0 0 7px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.35;
}
.kmeta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 9px;
}
.kproj { font-size: 10.5px; color: var(--muted-2); }

/* Forms & Toolbar */
.field { margin-bottom: 13px; }
.field label { display: block; font-size: 11.5px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.input, .select, textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  padding: 9px 12px;
  font-size: 12.5px;
  color: var(--text);
  font-family: inherit;
}
.input:focus, .select:focus, textarea:focus {
  outline: none;
  border-color: var(--g);
  box-shadow: 0 0 0 3px var(--g-soft);
}
textarea { resize: vertical; min-height: 70px; }
.select { width: auto; min-width: 140px; }
.frow { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; }
@media(max-width: 520px) { .frow { grid-template-columns: 1fr; } }
.hint { font-size: 11px; color: var(--muted-2); margin-top: 5px; line-height: 1.55; }
.toolbar {
  display: flex;
  gap: 9px;
  align-items: center;
  margin-bottom: 15px;
  flex-wrap: wrap;
}
.sw { position: relative; flex: 1; min-width: 190px; }
.sw svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 15px;
  height: 15px;
  color: var(--muted-2);
}
.sw .input { padding-left: 34px; }

/* Modals */
.ov {
  position: fixed;
  inset: 0;
  background: rgba(16,35,26,.45);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 70;
  padding: 18px;
  animation: fade .14s ease;
}
.modal {
  background: #fff;
  border-radius: 16px;
  width: 100%;
  max-width: 480px;
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}
.modal.wide { max-width: 680px; }
.mh {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 17px 21px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: #fff;
  border-radius: 16px 16px 0 0;
  z-index: 10;
}
.mh h3 { margin: 0; font-size: 15.5px; font-weight: 700; color: var(--ink); }
.mx {
  cursor: pointer;
  color: var(--muted);
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
}
.mx:hover { background: var(--bg); color: var(--text); }
.mb-modal { padding: 18px 21px; }
.mf {
  padding: 14px 21px 19px;
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}
.ibox {
  background: var(--bg);
  border-radius: 11px;
  padding: 12px 14px;
  font-size: 11.5px;
  color: var(--text);
  line-height: 1.6;
  margin-bottom: 14px;
}
.kv {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px dashed var(--border);
  font-size: 12.5px;
}
.kv:last-child { border-bottom: none; }
.kv span { color: var(--muted); }
.kv b { font-weight: 600; color: var(--ink); text-align: right; }
.kv.tot {
  border-top: 1px solid var(--border);
  border-bottom: none;
  margin-top: 4px;
  padding-top: 11px;
  font-size: 14px;
}

/* Toasts */
.toasts {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 90;
}
.toast {
  background: var(--ink);
  color: #fff;
  padding: 11px 16px;
  border-radius: 11px;
  font-size: 12.5px;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 8px;
  animation: slide .18s ease;
  max-width: 320px;
}
.toast.success { background: var(--g-darker); }
.toast.error { background: var(--red); }
@keyframes slide {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

/* Tabs */
.tabs {
  display: flex;
  gap: 4px;
  background: #EEF1EF;
  border-radius: 11px;
  padding: 4px;
  margin-bottom: 16px;
  width: fit-content;
  flex-wrap: wrap;
}
.tab {
  padding: 7px 14px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  text-decoration: none;
}
.tab.active {
  background: #fff;
  color: var(--g-darker);
  box-shadow: var(--shadow);
}

/* Hero Section */
.hero {
  background: linear-gradient(135deg, var(--g-darker) 0%, var(--g-dark) 55%, var(--g) 100%);
  border-radius: var(--r);
  padding: 22px;
  color: #fff;
  position: relative;
  overflow: hidden;
}
.hero::after {
  content: '';
  position: absolute;
  right: -60px;
  top: -60px;
  width: 200px;
  height: 200px;
  border-radius: 50%;
  background: rgba(255,255,255,.1);
}
.hero .lb {
  font-size: 10.5px;
  color: rgba(255,255,255,.75);
  letter-spacing: .05em;
  text-transform: uppercase;
}
.hero .amt {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -.03em;
  margin: 7px 0 3px;
}
.hero .sb {
  font-size: 11.5px;
  color: rgba(255,255,255,.85);
}
.hero .split {
  display: flex;
  gap: 22px;
  margin-top: 18px;
  flex-wrap: wrap;
  position: relative;
  z-index: 1;
}
.hero .split div b { display: block; font-size: 15px; font-weight: 600; }
.hero .split div span { font-size: 10.5px; color: rgba(255,255,255,.7); }

/* Timeline */
.tl { position: relative; padding-left: 20px; }
.tl::before {
  content: '';
  position: absolute;
  left: 5px;
  top: 5px;
  bottom: 5px;
  width: 2px;
  background: var(--border);
}
.tli { position: relative; padding-bottom: 15px; }
.tli:last-child { padding-bottom: 0; }
.tli::before {
  content: '';
  position: absolute;
  left: -19px;
  top: 4px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--g);
}
.tli b { display: block; font-size: 12.5px; color: var(--ink); font-weight: 600; line-height: 1.4; }
.tli small { font-size: 11px; color: var(--muted-2); }

/* Timesheet Week Grid */
.week {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
}
@media(max-width: 740px) { .week { grid-template-columns: repeat(4, 1fr); } }
.day {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  text-align: center;
  box-shadow: var(--shadow);
}
.day.now {
  border-color: var(--g);
  box-shadow: 0 0 0 3px var(--g-soft);
}
.day .dn { font-size: 10px; color: var(--muted-2); text-transform: uppercase; letter-spacing: .04em; }
.day .dd { font-size: 15px; font-weight: 700; color: var(--ink); margin: 3px 0 6px; }
.day .dh { font-size: 12px; font-weight: 600; color: var(--g-dark); }
.day .db { height: 4px; border-radius: 3px; background: #EEF1EE; margin-top: 6px; overflow: hidden; }
.day .db span { display: block; height: 100%; background: var(--g); }

/* Switch Control */
.switch {
  width: 38px;
  height: 22px;
  border-radius: 20px;
  background: #DDE2DE;
  position: relative;
  cursor: pointer;
  transition: background .18s;
  flex-shrink: 0;
}
.switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  transition: transform .18s;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.switch.on { background: var(--g); }
.switch.on::after { transform: translateX(16px); }

/* Media Breakpoints */
@media(max-width: 1180px) and (min-width: 900px) {
  .app { grid-template-columns: 74px 1fr; }
  .sidebar { padding: 16px 10px; align-items: center; }
  .sb-brand { padding: 5px 0 14px; justify-content: center; }
  .sb-brand div:not(.sb-mark), .sb-name, .sb-sub, .nav-lbl, .sb-card, .sb-fname, .sb-frole, .nav-count { display: none; }
  .nav { width: 100%; }
  .nav-link { justify-content: center; padding: 11px 0; }
  .nav-link span { display: none; }
  .sb-foot { justify-content: center; }
  .sb-out { margin-left: 0; }
}

@media(max-width: 899px) {
  .app { grid-template-columns: 1fr; width: 100%; max-width: 100vw; overflow-x: hidden; }
  .sidebar {
    position: fixed !important;
    left: 0 !important;
    top: 0 !important;
    bottom: 0 !important;
    width: 280px !important;
    max-width: 85vw !important;
    height: 100vh !important;
    height: 100dvh !important;
    z-index: 10000 !important;
    background: #ffffff !important;
    transform: translateX(-105%) !important;
    transition: transform .24s cubic-bezier(0.16, 1, 0.3, 1) !important;
    box-shadow: 0 10px 40px rgba(0,0,0,.35) !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    display: flex !important;
    flex-direction: column !important;
    padding: 16px 14px !important;
    align-items: stretch !important;
  }
  .sidebar.open {
    transform: translateX(0) !important;
  }
  .sb-brand div:not(.sb-mark), .sb-name, .sb-sub, .nav-lbl, .sb-card, .sb-fname, .sb-frole, .nav-count {
    display: block !important;
  }
  .nav-link span {
    display: inline !important;
  }
  .nav-link {
    display: flex !important;
    justify-content: flex-start !important;
    padding: 9px 12px !important;
  }
  .nav {
    width: 100% !important;
  }
  .sb-brand {
    padding: 6px 6px 16px !important;
    justify-content: flex-start !important;
    display: flex !important;
  }
  .sb-foot {
    display: flex !important;
    justify-content: flex-start !important;
    align-items: center !important;
    margin-top: auto !important;
    padding-top: 14px !important;
  }
  .sb-out {
    display: inline-flex !important;
    margin-left: auto !important;
  }
  .sb-close {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 32px !important;
    height: 32px !important;
    border-radius: 8px !important;
    background: var(--bg) !important;
    color: var(--muted) !important;
    cursor: pointer !important;
    margin-left: auto !important;
  }
  .scrim {
    position: fixed !important;
    inset: 0 !important;
    background: rgba(16,35,26,.65) !important;
    backdrop-filter: blur(4px) !important;
    -webkit-backdrop-filter: blur(4px) !important;
    z-index: 9999 !important;
    display: none;
  }
  .scrim.on {
    display: block !important;
  }
  .burger { display: flex !important; cursor: pointer !important; }
  .tsearch { display: none !important; }
  .crumb { display: none !important; }
  .role-chip { display: none !important; }
  .topbar {
    display: flex !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    height: 54px !important;
    min-height: 54px !important;
    max-height: 54px !important;
    padding: 0 12px !important;
    gap: 8px !important;
    justify-content: space-between !important;
    max-width: 100vw !important;
    box-sizing: border-box !important;
    position: sticky !important;
    top: 0 !important;
    z-index: 50 !important;
  }
  .tb-right {
    display: flex !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    gap: 6px !important;
    margin-left: auto !important;
  }
  .company-selector {
    position: static !important;
  }
  .company-selector .comp-btn { padding: 5px 8px; font-size: 11.5px; max-width: 130px; }
  .company-selector .comp-btn span:nth-child(2) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .phead, #content { padding-left: 14px; padding-right: 14px; max-width: 100vw; box-sizing: border-box; }
  .phead h1 { font-size: 18px; }

  /* Guarantee Dropdowns stay strictly inside viewport on mobile */
  .comp-menu {
    display: none !important;
    position: fixed !important;
    left: 12px !important;
    right: 12px !important;
    top: 54px !important;
    width: auto !important;
    max-width: 350px !important;
    margin: 0 auto !important;
    max-height: calc(85vh - 60px) !important;
    overflow-y: auto !important;
    box-sizing: border-box !important;
    z-index: 100050 !important;
    box-shadow: 0 16px 45px rgba(0,0,0,0.25) !important;
    background: #ffffff !important;
    border: 1px solid var(--border) !important;
    border-radius: 14px !important;
    padding: 10px !important;
    -webkit-overflow-scrolling: touch !important;
  }
  .comp-menu.show {
    display: block !important;
  }
  .notif-menu, .user-menu {
    display: none !important;
    position: fixed !important;
    left: 12px !important;
    right: 12px !important;
    top: 54px !important;
    width: auto !important;
    max-width: 360px !important;
    margin: 0 auto !important;
    max-height: calc(85vh - 60px) !important;
    overflow-y: auto !important;
    box-sizing: border-box !important;
    z-index: 100050 !important;
    box-shadow: 0 16px 45px rgba(0,0,0,0.25) !important;
    background: #ffffff !important;
  }
  .notif-menu.open {
    display: flex !important;
  }
  .user-menu.show {
    display: block !important;
  }
}

@media(max-width: 768px) {
  .grid, .g2, .g3, .g4, .g32, .g23 { grid-template-columns: 1fr !important; width: 100% !important; max-width: 100% !important; }
  .frow { grid-template-columns: 1fr !important; gap: 10px !important; }
  .btn { white-space: normal !important; text-align: center; }
  .panel { max-width: 100% !important; box-sizing: border-box !important; }
  .kanban { grid-template-columns: 1fr !important; gap: 12px !important; }
  
  .ov { padding: 8px !important; }
  .modal { width: 100% !important; max-width: calc(100vw - 16px) !important; margin: 0 auto !important; max-height: 90vh !important; }
  
  #notifToastContainer, #toasts {
    left: 10px !important;
    right: 10px !important;
    bottom: 12px !important;
    max-width: calc(100vw - 20px) !important;
    width: auto !important;
  }
}

@media(max-width: 640px) {
  #pwaInstallBtn span { display: none; }
  #pwaInstallBtn { padding: 5px 8px !important; }
  .company-selector .comp-btn { max-width: 110px; }
  .hactions { width: 100%; display: flex; flex-wrap: wrap; }
  .hactions .btn { flex: 1 1 auto; justify-content: center; }
  .phead p { display: none; }
  .phead h1 { font-size: 17px !important; margin: 0; }
  .phead { padding-top: 10px !important; padding-bottom: 8px !important; }
}

@media(max-width: 480px) {
  .topbar { padding: 0 10px !important; }
  .company-selector .comp-btn { max-width: 100px; font-size: 11px; padding: 4px 6px; }
  .phead, #content { padding-left: 10px; padding-right: 10px; }
  .stat { padding: 12px; }
  .stat-v { font-size: 19px; }
}

/* ================= NOTIFICATION SYSTEM & TOASTS ================= */
.notif-dropdown {
  position: relative;
}

.notif-badge-count {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--red);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  min-width: 17px;
  height: 17px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  border: 2px solid #fff;
  line-height: 1;
  box-shadow: 0 1px 3px rgba(220,38,38,.35);
  animation: pulse-badge 2s infinite;
}

@keyframes pulse-badge {
  0% { transform: scale(1); }
  50% { transform: scale(1.1); }
  100% { transform: scale(1); }
}

.notif-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 10px);
  width: 380px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  display: none;
  flex-direction: column;
  z-index: 1000;
  overflow: hidden;
  animation: fadeInDown .15s ease;
}
.notif-menu.open { display: flex; }

@keyframes fadeInDown {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

.notif-header {
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.notif-header h4 { margin: 0; font-size: 14px; font-weight: 700; color: var(--ink); }
.notif-header button { background: none; border: none; font-size: 11.5px; font-weight: 600; color: var(--g-dark); cursor: pointer; padding: 2px 6px; border-radius: 6px; }
.notif-header button:hover { background: var(--g-soft); }

.notif-tabs {
  display: flex;
  gap: 6px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  background: #FAFCFA;
}
.notif-tab {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 9px;
  border-radius: 14px;
  color: var(--muted);
  cursor: pointer;
  background: transparent;
  border: none;
  transition: all .12s;
}
.notif-tab:hover { color: var(--ink); background: var(--border); }
.notif-tab.active { background: var(--g); color: #fff; }

.notif-list {
  max-height: 360px;
  overflow-y: auto;
}

.notif-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  color: inherit;
  transition: background .12s;
  cursor: pointer;
  position: relative;
}
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: #F8FAF9; }
.notif-item.unread { background: #F4FBF6; }
.notif-item.unread::before {
  content: '';
  position: absolute;
  left: 5px;
  top: 18px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--g);
}

.notif-icon {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 14px;
}
.notif-icon.chat { background: var(--blue-soft); color: var(--blue); }
.notif-icon.email { background: var(--amber-soft); color: var(--amber); }
.notif-icon.action { background: var(--g-soft); color: var(--g-dark); }
.notif-icon.task { background: var(--violet-soft); color: var(--violet); }
.notif-icon.leave { background: var(--pink-soft); color: var(--pink); }
.notif-icon.invoice { background: var(--teal-soft); color: var(--teal); }

.notif-content { flex: 1; min-width: 0; }
.notif-title { font-size: 12.5px; font-weight: 600; color: var(--ink); margin-bottom: 2px; }
.notif-desc { font-size: 11.5px; color: var(--muted); line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.notif-time { font-size: 10.5px; color: var(--muted-2); margin-top: 4px; display: block; }

.notif-footer {
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  text-align: center;
  background: #FAFCFA;
}
.notif-footer a { font-size: 12px; font-weight: 600; color: var(--g-dark); }
.notif-footer a:hover { text-decoration: underline; }

/* Floating Live Toast System */
#notifToastContainer {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 99999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 360px;
  pointer-events: none;
}

.notif-toast {
  background: #FFFFFF;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  box-shadow: 0 10px 30px rgba(0,0,0,.15);
  display: flex;
  align-items: flex-start;
  gap: 10px;
  pointer-events: auto;
  cursor: pointer;
  transition: all .2s ease;
  animation: slideInRight .25s ease;
  border-left: 4px solid var(--g);
}
.notif-toast.chat { border-left-color: var(--blue); }
.notif-toast.email { border-left-color: var(--amber); }

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(40px); }
  to { opacity: 1; transform: translateX(0); }
}

.notif-toast .t-icon { width: 28px; height: 28px; border-radius: 8px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.notif-toast .t-body { flex: 1; min-width: 0; }
.notif-toast .t-title { font-size: 12.5px; font-weight: 700; color: var(--ink); }
.notif-toast .t-msg { font-size: 11.5px; color: var(--muted); margin-top: 2px; line-height: 1.35; }
.notif-toast .t-close { background: none; border: none; color: var(--muted); cursor: pointer; padding: 2px; font-size: 13px; line-height: 1; }

