/* EveMan CRM - layout on top of Tabler */
:root {
  --em-top: 56px;
  --em-side: 248px;
  --em-side-mini: 68px;
}
body.em-body { font-family: var(--tblr-font-sans-serif); background: var(--tblr-bg-surface-secondary, var(--tblr-body-bg)); }

/* primary colour follows settings */
.btn-primary {
  --tblr-btn-bg: var(--tblr-primary); --tblr-btn-border-color: var(--tblr-primary);
  --tblr-btn-hover-bg: color-mix(in srgb, var(--tblr-primary) 88%, #000); --tblr-btn-hover-border-color: color-mix(in srgb, var(--tblr-primary) 88%, #000);
  --tblr-btn-active-bg: color-mix(in srgb, var(--tblr-primary) 80%, #000); --tblr-btn-color: #fff; --tblr-btn-hover-color: #fff;
}
.btn-outline-primary { --tblr-btn-color: var(--tblr-primary); --tblr-btn-border-color: var(--tblr-primary); --tblr-btn-hover-bg: var(--tblr-primary); --tblr-btn-hover-border-color: var(--tblr-primary); }
.bg-primary { background-color: var(--tblr-primary) !important; }
.text-primary { color: var(--tblr-primary) !important; }
.bg-primary-lt { background-color: rgba(var(--tblr-primary-rgb), .1) !important; color: var(--tblr-primary) !important; }
.form-check-input:checked { background-color: var(--tblr-primary); border-color: var(--tblr-primary); }
.nav-tabs .nav-link.active { border-color: var(--tblr-primary); }
.page-item.active .page-link { background-color: var(--tblr-primary); border-color: var(--tblr-primary); }

/* ---------- top bar ---------- */
.em-topbar {
  position: fixed; top: 0; left: 0; right: 0; height: var(--em-top); z-index: 1035;
  background: var(--tblr-bg-surface); border-bottom: 1px solid var(--tblr-border-color);
  padding: 0;
}
.em-brand { display: flex; align-items: center; gap: .6rem; padding: 0; font-weight: 600; font-size: 1rem; }
.em-logo { height: 30px; width: auto; max-width: 140px; object-fit: contain; }
.em-brand-name { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--tblr-body-color); }
.em-bell-count { position: absolute; top: 2px; right: 0; font-size: .65rem; padding: .2em .4em; }
.em-notif-menu { width: 380px; max-width: calc(100vw - 24px); }
.em-notif-list { max-height: 380px; overflow-y: auto; }
.em-unread { background: rgba(var(--tblr-primary-rgb), .06); }
.em-unread .fw-medium::before { content: ''; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--tblr-primary); margin-right: 6px; vertical-align: middle; }
[data-bs-theme="dark"] .em-show-light, [data-bs-theme="light"] .em-show-dark { display: none; }

/* ---------- sidebar ---------- */
.em-sidebar {
  position: fixed; top: var(--em-top); bottom: 0; left: 0; width: var(--em-side); z-index: 1030;
  background: var(--tblr-bg-surface); border-right: 1px solid var(--tblr-border-color);
  display: flex; flex-direction: column; overflow-x: hidden; overflow-y: auto;
  transition: width .18s ease, transform .2s ease;
}
.em-sidebar[data-bs-theme="dark"] { background: #1b2434; border-right-color: #1b2434; }
.em-nav { padding: .75rem .6rem; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.em-link, .em-sublink {
  display: flex; align-items: center; gap: .75rem; padding: .55rem .75rem; border-radius: var(--tblr-border-radius);
  color: var(--tblr-secondary-color, var(--tblr-body-color)); text-decoration: none; white-space: nowrap; font-weight: 500;
}
.em-sidebar[data-bs-theme="dark"] .em-link, .em-sidebar[data-bs-theme="dark"] .em-sublink { color: rgba(255,255,255,.72); }
.em-link:hover, .em-sublink:hover { background: rgba(var(--tblr-primary-rgb), .08); color: var(--tblr-body-color); text-decoration: none; }
.em-sidebar[data-bs-theme="dark"] .em-link:hover, .em-sidebar[data-bs-theme="dark"] .em-sublink:hover { background: rgba(255,255,255,.06); color: #fff; }
.em-link.active, .em-sublink.active { background: rgba(var(--tblr-primary-rgb), .14); color: var(--tblr-primary); }
.em-sidebar[data-bs-theme="dark"] .em-link.active, .em-sidebar[data-bs-theme="dark"] .em-sublink.active { background: var(--tblr-primary); color: #fff; }
.em-link.active-parent { color: var(--tblr-body-color); }
.em-sidebar[data-bs-theme="dark"] .em-link.active-parent { color: #fff; }
.em-ico { font-size: 1.3rem; width: 1.5rem; text-align: center; flex-shrink: 0; }
.em-caret { margin-left: auto; transition: transform .2s; font-size: .95rem; }
.em-group.collapsed .em-caret { transform: rotate(-90deg); }
.em-sub { padding-left: 2.25rem; }
.em-sublink { padding: .4rem .75rem; font-weight: 400; font-size: .92em; }
.em-count { margin-left: auto; font-size: .65rem; }
.em-side-foot { padding: .75rem 1.2rem; font-size: .75rem; color: var(--tblr-secondary-color); }
.em-sidebar[data-bs-theme="dark"] .em-side-foot { color: rgba(255,255,255,.4); }

/* main */
.em-main { margin-left: var(--em-side); padding-top: var(--em-top); min-height: 100vh; display: flex; flex-direction: column; transition: margin-left .18s ease; }
.em-main .page-body { flex: 1; }
.em-inset { flex: 1; display: flex; flex-direction: column; }
.em-container { max-width: 1600px; }

/* mini sidebar (desktop) */
@media (min-width: 992px) {
  html.em-mini .em-sidebar { width: var(--em-side-mini); }
  html.em-mini .em-main { margin-left: var(--em-side-mini); }
  html.em-mini .em-sidebar:not(:hover) .em-label,
  html.em-mini .em-sidebar:not(:hover) .em-caret,
  html.em-mini .em-sidebar:not(:hover) .em-count,
  html.em-mini .em-sidebar:not(:hover) .em-sub { display: none !important; }
  html.em-mini .em-sidebar:not(:hover) .em-link { justify-content: center; padding-left: 0; padding-right: 0; }
  html.em-mini .em-sidebar:hover { width: var(--em-side); box-shadow: 0 0 30px rgba(0,0,0,.18); }
}
/* drawer (mobile) */
@media (max-width: 991.98px) {
  .em-sidebar { transform: translateX(-100%); width: 270px; }
  .em-main { margin-left: 0; }
  html.em-open .em-sidebar { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.3); }
  html.em-open .em-backdrop { display: block; }
  .em-notif-menu { position: fixed !important; left: 12px !important; right: 12px !important; top: var(--em-top) !important; transform: none !important; width: auto; }
}
.em-backdrop { display: none; position: fixed; inset: var(--em-top) 0 0 0; background: rgba(0,0,0,.35); z-index: 1029; }

/* ---------- components ---------- */
.card { border-radius: var(--tblr-border-radius-lg); }
.table-actions { white-space: nowrap; text-align: right; }
.table-actions .btn { padding: .25rem .45rem; }
.table td { vertical-align: middle; }
.stat-card .subheader { text-transform: uppercase; letter-spacing: .04em; font-size: .72rem; }
.stat-card .h1 { font-size: 1.6rem; }
.em-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; vertical-align: middle; }
.em-swatch { width: 34px; height: 34px; border-radius: 50%; border: 3px solid transparent; cursor: pointer; display: inline-block; }
.em-swatch-input:checked + .em-swatch { border-color: var(--tblr-body-color); box-shadow: 0 0 0 2px var(--tblr-bg-surface) inset; }
.em-swatch-input { position: absolute; opacity: 0; pointer-events: none; }
.em-user-picker { max-height: 190px; overflow-y: auto; border: 1px solid var(--tblr-border-color); border-radius: var(--tblr-border-radius); padding: .4rem .6rem; }
.em-filelist .list-group-item { padding: .5rem .75rem; }
.em-items td { padding: .35rem; }
.em-items .form-control, .em-items .form-select { padding: .3rem .5rem; }
.em-items .col-qty { width: 90px; }
.em-items .col-unit { width: 110px; }
.em-items .col-price { width: 130px; }
.em-items .col-pct { width: 90px; }
.em-items .col-total { width: 130px; text-align: right; white-space: nowrap; }
.em-code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; line-height: 1.5; tab-size: 2; white-space: pre; }
.em-preview-frame { width: 100%; height: 78vh; border: 1px solid var(--tblr-border-color); border-radius: var(--tblr-border-radius); background: #fff; }
.em-var { cursor: pointer; font-family: ui-monospace, monospace; font-size: 12px; }
.em-var:hover { background: rgba(var(--tblr-primary-rgb), .1); }

/* calendar - explicit palette per theme so it never depends on FullCalendar's white defaults */
.em-calendar {
  --em-cal-bg: #ffffff; --em-cal-head-bg: #f4f6fa; --em-cal-head-fg: #3a4859; --em-cal-text: #1f2937;
  --em-cal-muted: #8a94a6; --em-cal-border: #e3e7ed; --em-cal-other: #fafbfc; --em-cal-hover: #f1f5fb;
  --em-cal-today: rgba(var(--tblr-primary-rgb), .08);
  min-height: 640px; color: var(--em-cal-text);
}
[data-bs-theme="dark"] .em-calendar {
  --em-cal-bg: #182433; --em-cal-head-bg: #1f2e42; --em-cal-head-fg: #e3e8ef; --em-cal-text: #e3e8ef;
  --em-cal-muted: #8d9bb0; --em-cal-border: #2b3c53; --em-cal-other: #152030; --em-cal-hover: #22324a;
  --em-cal-today: rgba(var(--tblr-primary-rgb), .18);
}
.em-calendar .fc {
  --fc-border-color: var(--em-cal-border); --fc-page-bg-color: var(--em-cal-bg); --fc-neutral-bg-color: var(--em-cal-head-bg);
  --fc-neutral-text-color: var(--em-cal-muted); --fc-today-bg-color: var(--em-cal-today); --fc-list-event-hover-bg-color: var(--em-cal-hover);
  --fc-button-bg-color: var(--em-cal-bg); --fc-button-border-color: var(--em-cal-border); --fc-button-text-color: var(--em-cal-text);
  --fc-button-hover-bg-color: var(--em-cal-hover); --fc-button-hover-border-color: var(--em-cal-border);
  --fc-button-active-bg-color: var(--tblr-primary); --fc-button-active-border-color: var(--tblr-primary);
  --fc-now-indicator-color: #d63939;
  color: var(--em-cal-text);
}
/* toolbar */
.em-calendar .fc .fc-toolbar-title { font-size: 1.15rem; font-weight: 600; text-transform: capitalize; color: var(--em-cal-text); }
.em-calendar .fc .fc-button { font-size: .85rem; padding: .3rem .65rem; text-transform: capitalize; box-shadow: none !important; }
.em-calendar .fc .fc-button-primary { background: var(--fc-button-bg-color); color: var(--fc-button-text-color); border-color: var(--fc-button-border-color); }
.em-calendar .fc .fc-button-primary:not(:disabled):hover { background: var(--fc-button-hover-bg-color); color: var(--em-cal-text); }
.em-calendar .fc .fc-button-primary:not(:disabled).fc-button-active,
.em-calendar .fc .fc-button-primary:not(:disabled):active { background: var(--tblr-primary); border-color: var(--tblr-primary); color: #fff; }
.em-calendar .fc .fc-button-primary:disabled { opacity: .55; background: var(--fc-button-bg-color); color: var(--em-cal-muted); }
/* grid background + header row */
.em-calendar .fc .fc-scrollgrid, .em-calendar .fc .fc-daygrid-body, .em-calendar .fc table { background: var(--em-cal-bg); }
.em-calendar .fc .fc-col-header, .em-calendar .fc .fc-col-header-cell,
.em-calendar .fc .fc-scrollgrid-section-header > *, .em-calendar .fc .fc-scrollgrid-section-sticky > * { background: var(--em-cal-head-bg) !important; }
.em-calendar .fc .fc-col-header-cell-cushion { display: block; padding: 9px 4px; color: var(--em-cal-head-fg); text-decoration: none;
  font-weight: 600; font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; }
/* day cells - taller rows */
.em-calendar .fc .fc-daygrid-day-frame { min-height: 128px; }
.em-calendar .fc-daygrid-day { cursor: pointer; transition: background-color .12s; }
.em-calendar .fc-daygrid-day:hover { background: var(--em-cal-hover); }
.em-calendar .fc .fc-daygrid-day-number { color: var(--em-cal-text); text-decoration: none; font-weight: 500; padding: 6px 8px; }
.em-calendar .fc .fc-day-other { background: var(--em-cal-other); }
.em-calendar .fc .fc-day-other .fc-daygrid-day-number { color: var(--em-cal-muted); opacity: .7; }
.em-calendar .fc .fc-day-today .fc-daygrid-day-number { background: var(--tblr-primary); color: #fff; border-radius: 50%;
  min-width: 26px; height: 26px; display: inline-flex; align-items: center; justify-content: center; padding: 0 6px; margin: 4px; }
.em-calendar .fc .fc-daygrid-more-link { color: var(--tblr-primary); font-weight: 500; }
/* events */
.em-calendar .fc-event { cursor: pointer; border-radius: 4px; padding: 2px 4px; font-size: .78rem; }
.em-calendar .fc-daygrid-event-dot { border-color: currentColor; }
.em-calendar .fc-daygrid-dot-event .fc-event-title, .em-calendar .fc-daygrid-dot-event .fc-event-time { color: var(--em-cal-text); }
.em-calendar .fc-event.em-done { opacity: .55; text-decoration: line-through; }
/* week / day view */
.em-calendar .fc .fc-timegrid-slot { height: 2.6em; }
.em-calendar .fc .fc-timegrid-slot-label, .em-calendar .fc .fc-timegrid-axis { color: var(--em-cal-muted); background: var(--em-cal-bg); }
/* list view */
.em-calendar .fc .fc-list { background: var(--em-cal-bg); }
.em-calendar .fc .fc-list-day-cushion { background: var(--em-cal-head-bg) !important; color: var(--em-cal-head-fg); }
.em-calendar .fc .fc-list-day-cushion a, .em-calendar .fc .fc-list-event td { color: var(--em-cal-text); text-decoration: none; }
.em-calendar .fc .fc-list-empty { background: var(--em-cal-bg); color: var(--em-cal-muted); }
/* "+ more" popover */
.em-calendar .fc .fc-popover { background: var(--em-cal-bg); border-color: var(--em-cal-border); box-shadow: 0 8px 24px rgba(0,0,0,.25); }
.em-calendar .fc .fc-popover-header { background: var(--em-cal-head-bg); color: var(--em-cal-head-fg); }
@media (max-width: 767.98px) {
  .em-calendar .fc .fc-daygrid-day-frame { min-height: 84px; }
  .em-calendar .fc .fc-toolbar { flex-direction: column; gap: .5rem; }
}
.em-legend span { margin-right: 1rem; white-space: nowrap; }

/* print (documents) */
@media print {
  .em-main { margin: 0 !important; padding: 0 !important; }
  body.em-body { background: #fff; }
}

.em-row-done td { opacity: .6; }
.em-row-done td a.fw-medium { text-decoration: line-through; }

/* notification bell panel */
.em-bell-panel { position: absolute; top: calc(100% + 8px); right: -8px; width: 380px; max-width: calc(100vw - 24px); z-index: 1050;
  box-shadow: 0 12px 32px rgba(0,0,0,.18); border-radius: var(--tblr-border-radius-lg); overflow: hidden; }
.em-bell-panel::before { content: ''; position: absolute; top: -6px; right: 20px; width: 12px; height: 12px; transform: rotate(45deg);
  background: var(--tblr-bg-surface); border-left: 1px solid var(--tblr-border-color); border-top: 1px solid var(--tblr-border-color); }
.em-bell-panel .em-notif-list { max-height: 400px; overflow-y: auto; }
#emBell .ti-bell { transition: transform .2s; }
#emBell[aria-expanded="true"] .ti-bell { transform: rotate(-15deg); color: var(--tblr-primary); }
@media (max-width: 575.98px) {
  .em-bell-panel { position: fixed; top: calc(var(--em-top) + 6px); left: 12px; right: 12px; width: auto; }
  .em-bell-panel::before { display: none; }
}

/* ticket conversation */
.em-thread { max-height: 65vh; overflow-y: auto; }
.em-msg { max-width: 82%; background: var(--tblr-bg-surface-secondary); border: 1px solid var(--tblr-border-color); border-radius: 4px 14px 14px 14px; padding: .6rem .85rem; }
.em-msg-mine { background: rgba(var(--tblr-primary-rgb), .1); border-color: rgba(var(--tblr-primary-rgb), .25); border-radius: 14px 4px 14px 14px; }
.em-msg-body { white-space: normal; word-wrap: break-word; }
.em-attach { display: inline-flex; width: 92px; height: 72px; align-items: center; justify-content: center; text-align: center; border: 1px solid var(--tblr-border-color); border-radius: 6px; overflow: hidden; background: var(--tblr-bg-surface); color: var(--tblr-body-color); text-decoration: none; }
.em-attach img { width: 100%; height: 100%; object-fit: cover; }

/* availability ring on assignee avatars */
.em-pres { display: inline-flex; border-radius: 50%; padding: 2px; }
.em-pres .avatar { box-shadow: none; }
.em-pres-confirmed { box-shadow: 0 0 0 2px var(--tblr-green); }
.em-pres-declined { box-shadow: 0 0 0 2px var(--tblr-red); opacity: .55; }
.em-pres-pending { box-shadow: 0 0 0 2px var(--tblr-orange); }

/* ---- installed app (PWA) ---- */
html.em-standalone .em-main { padding-bottom: env(safe-area-inset-bottom); }
html.em-standalone body { -webkit-tap-highlight-color: transparent; overscroll-behavior-y: none; }
#emInstallHelp .em-platform-mine .accordion-button { font-weight: 600; }
#emInstallHelp .accordion-body .ti { font-size: 1.15em; vertical-align: -2px; }

/* ---- Fonts & text settings ---- */
html .em-sidebar.em-sidebar-sample { position: static; transform: none; width: auto; height: auto; z-index: auto; box-shadow: none; border: 1px solid var(--tblr-border-color); }
html.em-mini .em-sidebar.em-sidebar-sample .em-label { display: inline !important; }
.em-typo-ev { background: var(--em-color-job, #066fd1); color: #fff; border-radius: 4px; padding: 2px 6px; font-size: .85em; }
#emTypoAcc .accordion-body { padding-top: .5rem; }
.em-css-editor { font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; line-height: 1.5; tab-size: 2; min-height: 420px; white-space: pre; }

/* ---- technicians' own days on a job ---- */
.em-days input[type=date] { width: auto; min-width: 8.5rem; padding-top: .15rem; padding-bottom: .15rem; }
.fc .em-own-days { background-image: repeating-linear-gradient(135deg, rgba(255,255,255,.18) 0 6px, transparent 6px 12px); }
.em-days { white-space: normal; }

/* ---- contracts: document editor ---- */
.em-re-bar { display: flex; align-items: center; }
.em-re-bar .btn-group .btn { border-radius: 4px; }
.em-re-frame { width: 100%; height: 72vh; border: 0; display: block; background: #e9ecef; }
.em-re-src { height: 72vh; font-size: 12.5px; line-height: 1.45; border: 0; border-radius: 0; white-space: pre-wrap; }
.em-contract-preview { width: 100%; height: 75vh; border: 1px solid var(--tblr-border-color); border-radius: var(--tblr-border-radius); background: #e9ecef; }

/* job window: merged technicians list */
.em-min0 { min-width: 0; }
.em-hide { display: none !important; }
#emTechCard .em-tech-head { border-bottom: 1px solid var(--tblr-border-color); background: var(--tblr-bg-surface-secondary); }
#emTechCard .em-tech-row .input-group input[type=date] { min-width: 0; }
#emTechCard .em-pres-sel { max-width: 11rem; }
.em-pres-confirmed { border-color: var(--tblr-green) !important; color: var(--tblr-green); }
.em-pres-declined { border-color: var(--tblr-red) !important; color: var(--tblr-red); }
.em-pres-pending { border-color: var(--tblr-orange) !important; }
#emPickModal .em-pick-dialog { max-width: min(1140px, 96vw); }
#emPickModal #emPickList { max-height: none; }
@media (min-width: 992px) {
  #emPickModal .em-pick-dialog .modal-content { min-height: 70vh; }
  #emPickModal #emPickList { display: grid; grid-template-columns: 1fr 1fr; }
  #emPickModal #emPickList > .list-group-item { border-bottom: 1px solid var(--tblr-border-color); }
  #emPickModal #emPickList > .list-group-item:nth-child(odd) { border-right: 1px solid var(--tblr-border-color); }
}

/* ---------- wizard (estimate → invoice) ---------- */
.em-wiz-back { position: fixed; right: 1rem; bottom: calc(1rem + env(safe-area-inset-bottom, 0px)); z-index: 1040; display: flex; gap: .25rem; }
.em-wiz-back .btn { border-radius: 999px; }
.em-wiz-steps .step-item a { text-decoration: none; }
.em-wiz-card { scroll-margin-top: calc(var(--em-top) + 1rem); }
.em-wiz-card .card-header { gap: .25rem; }
.em-wiz-cur { border: 2px solid var(--tblr-primary) !important; box-shadow: 0 0 0 4px rgba(var(--tblr-primary-rgb), .12); }
.em-wiz-done:not(.em-wiz-cur) .card-body { opacity: .85; }
@media (max-width: 575.98px) {
  .em-wiz-steps { font-size: .7rem; }
  .em-wiz-back .btn:first-child { max-width: calc(100vw - 5rem); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}
