:root{
  /* Integr8 palette (Brand Guidelines - Distributor) */
  --i8-navy:#001529;
  --i8-blue:#349CC8;
  --i8-green:#9ac023;
  --i8-charcoal:#474545;

  --bg:#ffffff;
  --canvas:#ffffff;
  --surface:#ffffff;
  --border:#d9e2ee; /* thin grey borders like QuickBooks */
  --text:#0f172a;
  --muted:#64748b;
  --shadow:0 2px 10px rgba(2, 10, 26, 0.04);

  --radius:14px;
  --sidebar-w:150px;
  --sidebar-w-collapsed:56px;
  --topbar-h:46px;
}

*{box-sizing:border-box;}

html,body{height:100%;}

body{
  margin:0;
  font-family:'Arimo', Arial, sans-serif;
  background:var(--bg);
  color:var(--text);
}

/* Typography: clean + corporate (avoid heavy bold headings) */
h1,h2,h3,h4{
  margin:0 0 10px 0;
  font-weight:600;
  color:var(--i8-navy);
  letter-spacing:-0.01em;
}
h1{font-size:17px;}
h2{font-size:15px;}
h3{font-size:14px;}
h4{font-size:13px;}
p{margin:0 0 10px 0; color:var(--muted);}

/* Layout */
.layout{display:flex; min-height:100vh;}

.sidebar{
  width:var(--sidebar-w);
  background:var(--i8-navy);
  color:#fff;
  display:flex;
  flex-direction:column;
  padding:10px;
}

.sidebar-top{display:flex; align-items:center; gap:8px; margin-bottom:10px;}

.brand{display:flex; align-items:center; gap:8px; text-decoration:none; color:#fff; min-width:0; flex:1;}
.brand-icon{width:26px; height:26px; object-fit:contain;}
.brand-mini{font-size:12px; color:rgba(255,255,255,0.82); letter-spacing:0.02em; white-space:nowrap; overflow:hidden; text-overflow:ellipsis;}

.menu{display:flex; flex-direction:column; gap:6px; padding:6px 2px;}
.menu-sep{margin:10px 8px 6px; font-size:8px; letter-spacing:0.12em; text-transform:uppercase; color:rgba(255,255,255,0.55);}

.menu-item{
  display:flex;
  align-items:center;
  gap:8px;
  padding:6px 6px;
  border-radius:10px;
  color:rgba(255,255,255,0.88);
  text-decoration:none;
  border:1px solid transparent;
  font-size:11px; /* slightly bigger (v3 was too small) */
}
.menu-item:hover{background:rgba(255,255,255,0.06);}
.menu-item.active{
  background:rgba(52,156,200,0.18);
  border-color:rgba(52,156,200,0.22);
  color:#fff;
}
.mi-ic{
  width:22px;
  height:22px;
  display:flex;
  align-items:center;
  justify-content:center;
  background:transparent;
  border-radius:0;
  opacity:0.95;
}
.mi-ic svg{
  width:18px;
  height:18px;
  stroke:#fff;
  fill:none;
  stroke-width:2;
  stroke-linecap:round;
  stroke-linejoin:round;
  opacity:0.92;
}
.menu-item.active .mi-ic{background:transparent;}
.mi-tx{white-space:nowrap; overflow:hidden; text-overflow:ellipsis;}

.menu-group{display:flex; flex-direction:column;}
.menu-group > summary{list-style:none;}
.menu-group > summary::-webkit-details-marker{display:none;}
.mi-caret{margin-left:auto; font-size:10px; opacity:0.72; line-height:1;}
.menu-group[open] > summary .mi-caret{transform:rotate(180deg);}

.submenu{
  display:flex;
  flex-direction:column;
  gap:4px;
  margin-top:4px;
  margin-left:30px;
  padding-left:10px;
  border-left:1px solid rgba(255,255,255,0.12);
}

.menu-subitem{
  display:flex;
  align-items:center;
  padding:6px 8px;
  border-radius:10px;
  color:rgba(255,255,255,0.78);
  text-decoration:none;
  border:1px solid transparent;
  font-size:10.5px;
}
.menu-subitem:hover{background:rgba(255,255,255,0.06);}
.menu-subitem.active{
  background:rgba(52,156,200,0.18);
  border-color:rgba(52,156,200,0.22);
  color:#fff;
}



.sidebar-bottom{margin-top:auto; display:flex; flex-direction:column; gap:10px;}
.sidebar-meta{padding:10px 10px 6px; border-top:1px solid rgba(255,255,255,0.08);}
.meta-line{font-size:12px; color:rgba(255,255,255,0.88);}
.meta-sub{font-size:11px; color:rgba(255,255,255,0.6); overflow:hidden; text-overflow:ellipsis;}

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

/* QuickBooks-style top bar */
.appbar{
  position:sticky;
  top:0;
  z-index:10;
  height:52px;
  display:flex;
  align-items:center;
  gap:14px;
  padding:8px 14px;
  background:#fff;
  border-bottom:1px solid var(--border);
}
.appbar-left{display:flex; align-items:center; gap:12px; min-width:220px;}
.appbar-logo img{height:26px; width:auto; display:block;}
.appbar-tenant{font-size:13px; color:var(--i8-charcoal); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; max-width:220px;}

.appbar-search{
  flex:1;
  display:flex;
  align-items:center;
  gap:8px;
  border:1px solid var(--border);
  border-radius:999px;
  padding:8px 12px;
  background:#fff;
  min-width:240px;
}
.search-ic{color:#94a3b8; font-size:14px; line-height:1;}
.appbar-search input{
  border:0;
  outline:none;
  width:100%;
  font-size:13px;
  color:var(--text);
  background:transparent;
}

.appbar-actions{display:flex; align-items:center; gap:10px;}
.icon-pill{
  width:34px;
  height:34px;
  display:grid;
  place-items:center;
  border-radius:10px;
  border:1px solid var(--border);
  background:#fff;
  color:var(--i8-charcoal);
  text-decoration:none;
  font-size:14px;
}
.icon-pill:hover{filter:brightness(0.98);}
.user-pill{
  display:flex;
  align-items:center;
  gap:8px;
  padding:8px 10px;
  border:1px solid var(--border);
  border-radius:999px;
  background:#fff;
  max-width:300px;
}
.user-dot{width:8px; height:8px; border-radius:99px; background:var(--i8-green);}
.user-tx{font-size:12px; color:var(--i8-charcoal); white-space:nowrap; overflow:hidden; text-overflow:ellipsis;}

.content{
  background:var(--canvas);
  padding:12px;
  flex:1;
}

.container{max-width:1520px; margin:0 auto;}

/* Collapsible sidebar */
html.sidebar-collapsed .sidebar{width:var(--sidebar-w-collapsed);}
html.sidebar-collapsed .brand-text,
html.sidebar-collapsed .mi-tx,
html.sidebar-collapsed .menu-sep,
html.sidebar-collapsed .sidebar-meta{display:none;}
html.sidebar-collapsed .menu-item{justify-content:center;}
html.sidebar-collapsed .mi-ic{width:22px;}

/* Buttons */
.btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:8px;
  padding:8px 10px;
  border-radius:10px;
  border:1px solid var(--border);
  background:#fff;
  color:var(--i8-navy);
  font-weight:600;
  text-decoration:none;
  cursor:pointer;
}
.btn:hover{border-color:#d6e2f2;}
.btn-primary{background:var(--i8-navy); border-color:var(--i8-navy); color:#fff;}
.btn-primary:hover{filter:brightness(1.05);}
.btn-ghost{background:transparent; color:var(--i8-navy);}

.icon-btn{
  width:34px;
  height:34px;
  display:grid;
  place-items:center;
  border-radius:12px;
  border:1px solid rgba(255,255,255,0.12);
  background:rgba(255,255,255,0.06);
  color:#fff;
  cursor:pointer;
}
.appbar .icon-btn{border-color:var(--border); background:#fff; color:var(--i8-navy);}
.icon-btn:hover{filter:brightness(1.05);}
.icon-bars{
  display:block;
  width:16px;
  height:2px;
  border-radius:999px;
  background:currentColor;
  position:relative;
}
.icon-bars:before,.icon-bars:after{
  content:'';
  position:absolute;
  left:0;
  right:0;
  height:2px;
  border-radius:999px;
  background:currentColor;
}
.icon-bars:before{top:-5px;}
.icon-bars:after{top:5px;}

.mobile-only{display:none;}

/* Cards + alerts */
.card{
  background:var(--surface);
  border:1px solid var(--border);
  border-radius:var(--radius);
  padding:12px;
  box-shadow:var(--shadow);
}

.alert{
  background:#fff;
  border:1px solid var(--border);
  border-left:4px solid var(--i8-blue);
  border-radius:14px;
  padding:12px 14px;
  margin-bottom:10px;
  color:var(--i8-charcoal);
}

/* Forms */
label{font-size:11px; color:var(--muted);}
input,select,textarea{
  width:auto;
  padding:8px 10px;
  border:1px solid var(--border);
  border-radius:12px;
  background:#fff;
  color:var(--text);
  outline:none;
}
input:focus,select:focus,textarea:focus{border-color:rgba(52,156,200,0.6); box-shadow:0 0 0 3px rgba(52,156,200,0.12);}

/* Tables */
table{width:100%; border-collapse:collapse; background:#fff;}
th,td{padding:9px 8px; border-bottom:1px solid var(--border); text-align:left; font-size:12px; color:var(--i8-charcoal);}
th{font-weight:600; color:var(--muted); background:#fbfdff;}

/* Dashboard helpers */
.page-head{display:flex; align-items:flex-end; justify-content:space-between; gap:12px; margin-bottom:10px;}
.page-title{font-size:14px; color:var(--i8-navy); font-weight:600;}
.page-sub{font-size:11px; color:var(--muted); margin-top:3px;}
.page-actions{display:flex; align-items:end; gap:10px; flex-wrap:wrap;}
.field{display:flex; flex-direction:column; gap:6px;}

/* Report-style headers + filters (QuickBooks-like) */
.report-head{display:flex; align-items:flex-end; justify-content:space-between; gap:12px; margin-bottom:10px; flex-wrap:wrap;}
.report-title{font-size:18px; font-weight:700; color:var(--i8-navy); letter-spacing:0.2px;}
.report-subtitle{font-size:12px; color:var(--muted); margin-top:4px; line-height:1.35;}
.report-actions{display:flex; gap:8px; align-items:center;}

.icon-btn.icon-btn-light{border-color:var(--border); background:#fff; color:var(--i8-navy);}
.icon-btn.icon-btn-light svg{width:18px; height:18px; fill:none; stroke:currentColor; stroke-width:2; stroke-linecap:round; stroke-linejoin:round; opacity:0.9;}

.report-filters{
  display:flex;
  gap:12px;
  align-items:flex-end;
  flex-wrap:wrap;
  padding:12px;
  border:1px solid var(--border);
  border-radius:14px;
  background:#fbfdff;
}
.report-filters .field{gap:6px;}
.report-filters .field label{font-size:11px; color:var(--muted);}
.report-filters .inp{height:38px; border-radius:10px; padding:8px 10px;}

/* Tighter filter row for report pages when space is tight */
.report-filters.tight{gap:8px; padding:8px; flex-wrap:nowrap; align-items:flex-end; overflow-x:auto;}
.report-filters.tight .field label{font-size:10px;}
.report-filters.tight .inp{height:32px; border-radius:8px; padding:5px 8px; font-size:11.5px;}
.report-filters.tight .btn{height:32px; padding:5px 9px; font-size:11.5px; border-radius:9px;}


.report-pagination{display:flex; align-items:center; justify-content:space-between; gap:12px; padding:10px 12px; border-top:1px solid var(--border);}
.report-pagination .pager{display:flex; gap:8px; align-items:center;}

.kpi-grid{display:grid; grid-template-columns:repeat(auto-fit, minmax(170px, 1fr)); gap:10px; margin:10px 0;}
.stat{background:#fff; border:1px solid var(--border); border-radius:var(--radius); padding:10px; box-shadow:var(--shadow);}
.stat-link{cursor:pointer; text-decoration:none; display:block;}
.stat-link:hover{border-color:rgba(52,156,200,0.35); box-shadow:0 10px 24px rgba(2,10,26,0.06);}
.stat-label{font-size:11px; color:var(--muted);}
.stat-value{margin-top:6px; font-size:18px; color:var(--i8-navy); font-weight:600;}
.stat-meta{margin-top:3px; font-size:11px; color:var(--muted);}
/* Color KPI blocks (TimeM8-style) */
.stat.color-green{background:linear-gradient(90deg,#0f7a3a,#14b86a); border-color:transparent;}
.stat.color-teal{background:linear-gradient(90deg,#0f766e,#14b8a6); border-color:transparent;}
.stat.color-navy{background:linear-gradient(90deg,var(--i8-navy),#0f2d55); border-color:transparent;}
.stat.color-purple{background:linear-gradient(90deg,#312e81,#8b5cf6); border-color:transparent;}
.stat.color-orange{background:linear-gradient(90deg,#9a3412,#f59e0b); border-color:transparent;}

.stat[class*="color-"] .stat-label,
.stat[class*="color-"] .stat-meta{color:rgba(255,255,255,0.92);}
.stat[class*="color-"] .stat-value{color:#fff; font-weight:700;}

.stat.stat-link{transition:transform .08s ease, box-shadow .12s ease, border-color .12s ease; }
.stat.stat-link:hover{transform:translateY(-1px); box-shadow:0 12px 24px rgba(2,10,26,0.08);}

.badge{display:inline-flex; align-items:center; gap:6px; font-size:11px; padding:4px 8px; border-radius:999px; border:1px solid var(--border); background:#fff; color:var(--i8-charcoal);}
.badge.blue{border-color:rgba(52,156,200,0.3); background:rgba(52,156,200,0.08);}

/* Widgets grid (QuickBooks-like customizable dashboard) */
.widget-bar{display:flex; align-items:center; justify-content:space-between; gap:12px; margin:10px 0; padding:10px 12px; border:1px dashed rgba(0,21,41,0.18); border-radius:14px; background:#fbfdff;}
.widget-grid{display:grid; grid-template-columns:repeat(12, minmax(0,1fr)); gap:10px; margin-top:10px; align-items:stretch;}
:root{--dash-row1-h:260px; --dash-row2-h:220px;}
.widget-grid .span-4{height:var(--dash-row1-h);}
.widget-grid .span-3{height:var(--dash-row2-h);}

.widget{position:relative; padding:10px; display:flex; flex-direction:column; height:100%;}
.widget[data-href]{cursor:pointer;}
.widget[data-href]:hover{border-color:rgba(52,156,200,0.35);}
.span-12{grid-column:span 12;}
.span-8{grid-column:span 8;}
.span-6{grid-column:span 6;}
.span-4{grid-column:span 4;}
.span-3{grid-column:span 3;}

.widget-head{display:flex; align-items:flex-start; gap:10px;}
.widget-handle{
  width:26px;
  height:26px;
  display:none;
  place-items:center;
  border:1px solid var(--border);
  border-radius:10px;
  color:#94a3b8;
  background:#fff;
  cursor:grab;
  user-select:none;
}
.widget-x{
  display:none;
  width:30px;
  height:30px;
  border-radius:10px;
  border:1px solid var(--border);
  background:#fff;
  color:#94a3b8;
  cursor:pointer;
}
/* Make widget bodies fill remaining height and scroll when needed */
.widget .chart-box, .widget .list, .widget .attendance-row{flex:1; min-height:0;}
.widget .list{overflow:auto;}
.widget .chart-box{overflow:hidden;}

.widget-x:hover{color:var(--i8-navy);}

html.customize .widget-handle{display:grid;}
html.customize .widget-x{display:grid; place-items:center;}
html.customize .widget{outline:1px dashed rgba(52,156,200,0.35); outline-offset:2px;}

/* Attendance: donut left + labels right */
.attendance-row{display:flex; gap:12px; align-items:flex-start;}
.donut-left{flex:0 0 150px; height:150px; width:150px;}
/* Legend as a compact 2-column grid to reduce widget height */
.list.attendance-legend{display:grid; grid-template-columns:repeat(2, minmax(0, 1fr)); gap:8px; align-content:start;}
.attendance-legend.compact{gap:6px;}
.attendance-legend.compact .list-item{padding:7px 10px; border-radius:12px;}
.attendance-legend.compact .li-title{font-size:11px;}
.attendance-legend.compact .li-sub{font-size:10px;}

.card-head{display:flex; align-items:baseline; justify-content:space-between; gap:10px; margin-bottom:8px;}
.card-title{font-size:12px; font-weight:600; color:var(--i8-navy);}
.card-note{font-size:11px; color:var(--muted);}

.list{display:flex; flex-direction:column; gap:8px;}
.list-item{display:flex; align-items:center; justify-content:space-between; gap:10px; padding:7px 10px; border:1px solid var(--border); border-radius:14px; background:#fff;}
.link-item{color:inherit; text-decoration:none;}
.link-item:hover{border-color:rgba(52,156,200,0.35);}
.li-left{display:flex; flex-direction:column; gap:2px; min-width:0;}
.li-title{font-size:12px; color:var(--i8-charcoal); white-space:nowrap; overflow:hidden; text-overflow:ellipsis;}
.li-sub{font-size:11px; color:var(--muted);}
.li-right{font-size:11px; color:var(--i8-navy); font-weight:600; white-space:nowrap;}

.muted{color:var(--muted);}

/* Responsive */
@media (max-width: 1200px){
  .kpi-grid{grid-template-columns:repeat(3, minmax(0,1fr));}
}
@media (max-width: 860px){
  .kpi-grid{grid-template-columns:repeat(2, minmax(0,1fr));}
  .widget-grid{grid-template-columns:repeat(6, minmax(0,1fr));}
  .span-8{grid-column:span 6;}
  .span-4{grid-column:span 6;}
  .span-3{grid-column:span 6;}
  .attendance-row{flex-direction:column;}
  .donut-left{width:100%; max-width:260px; height:180px;}
  .mobile-only{display:inline-grid;}
  .content{padding:14px;}
}

/* FullCalendar tweaks to match cards */
#calendar{min-height:650px;}
@media (max-width: 768px){
  #calendar{min-height:560px;}
}


/* Brand images */
.brand-icon{width:22px; height:22px; object-fit:contain;}
html.sidebar-collapsed .brand-mini{display:none;}

.chart-box{position:relative; width:100%;}

/* Override chart fixed heights inside equal-height widgets */
.widget .chart-box.chart-xs, .widget .chart-box.chart-sm, .widget .chart-box.chart-md{height:100%;}
.chart-xs{height:110px;}
.chart-sm{height:130px;}
.chart-md{height:160px;}
.chart-box canvas{position:absolute; inset:0; width:100% !important; height:100% !important;}

/* Modal (Add widgets) */
.modal{position:fixed; inset:0; z-index:50;}
.modal-backdrop{position:absolute; inset:0; background:rgba(2,10,26,0.35);}
.modal-card{position:relative; width:min(720px, calc(100vw - 24px)); margin:60px auto 0; background:#fff; border:1px solid var(--border); border-radius:16px; box-shadow:0 20px 60px rgba(2,10,26,0.18); overflow:hidden;}
.modal-head{display:flex; align-items:flex-start; justify-content:space-between; gap:12px; padding:14px; border-bottom:1px solid var(--border);}
.modal-body{padding:14px; display:grid; grid-template-columns:repeat(2, minmax(0,1fr)); gap:10px;}
.widget-opt{display:flex; align-items:center; justify-content:space-between; gap:10px; padding:10px 12px; border:1px solid var(--border); border-radius:14px;}
.widget-opt .opt-title{font-size:12px; color:var(--i8-navy); font-weight:600;}
.widget-opt .opt-sub{font-size:11px; color:var(--muted);}


/* Print-friendly report pages */
@media print {
  .sidebar { display: none !important; }
  .layout { display: block !important; }
  .content { padding: 0 !important; }
  .report-filters, .report-actions { display: none !important; }
  .card { box-shadow: none !important; border: 1px solid #d6dde6 !important; }
  th, td { font-size: 10px !important; padding: 6px 6px !important; }
}


/* Calendar UX */
.cal-people{display:flex; align-items:center; gap:10px; flex-wrap:wrap; padding:10px 12px; border:1px solid var(--border); border-radius:14px; background:#fff; min-height:44px;}
.cal-chips{display:flex; align-items:center; gap:8px; flex-wrap:wrap; max-width:520px;}
.cal-chip{display:flex; align-items:center; gap:8px; padding:6px 10px; border:1px solid var(--border); border-radius:999px; background:rgba(20, 30, 55, 0.03); }
.cal-chip-label{font-size:12px; font-weight:600; color:var(--i8-navy);}
.cal-dot{width:10px; height:10px; border-radius:999px; display:inline-block;}
.cal-chip-x{border:none; background:transparent; font-size:16px; line-height:1; cursor:pointer; color:var(--muted); padding:0 2px;}
.cal-chip-x:hover{color:var(--danger);}
.cal-ev-title{font-size:12px; font-weight:600; white-space:nowrap; overflow:hidden; text-overflow:ellipsis;}

.cal-day-columns{border-bottom:1px solid var(--border); background:rgba(20, 30, 55, 0.02);}
.cal-day-col{padding:10px 12px; font-size:12px; font-weight:700; color:var(--i8-navy); border-top:3px solid #4C78A8; border-right:1px solid var(--border); text-align:left;}
.cal-day-col:last-child{border-right:none;}

.cal-tooltip{position:fixed; z-index:9999; width:320px; max-width:70vw; background:#0f172a; color:#fff; border-radius:14px; padding:12px 12px; box-shadow:0 18px 38px rgba(0,0,0,0.25); font-size:12px;}
.cal-tt-title{font-size:13px; font-weight:800; margin-bottom:8px;}
.cal-tt-row{display:flex; gap:10px; margin:4px 0;}
.cal-tt-k{width:74px; color:rgba(255,255,255,0.7);}
.cal-tt-v{flex:1; color:#fff;}
.cal-tt-desc{margin-top:8px; padding-top:8px; border-top:1px solid rgba(255,255,255,0.15); color:rgba(255,255,255,0.9); line-height:1.35;}

.badge-ok{border-color:rgba(46,204,113,0.30); background:rgba(46,204,113,0.10);}
.badge-warn{border-color:rgba(243,156,18,0.30); background:rgba(243,156,18,0.10);}

/* Calendar: multi-user day columns (visual separators) */
.cal-multi-user-day{--cal-cols:2;}
.cal-multi-user-day .fc-timegrid-body{background-image:linear-gradient(to right, rgba(0,21,41,0.10) 1px, transparent 1px); background-size:calc(100%/var(--cal-cols)) 100%; background-repeat:repeat; background-position:0 0;}
