/* Shared visual scale for the existing HOSTION dashboard and its modules.
   Important declarations bridge older dynamically injected module styles. */
:root {
  --ui-body: "Avenir Next", "Century Gothic", sans-serif;
  --ui-display: "Iowan Old Style", "Palatino Linotype", serif;
  --ui-text: #183633;
  --ui-secondary: #566762;
  --ui-border: #d6dfd8;
  --ui-focus: #226d58;
  --ui-space: 20px;
}
body { font-family: var(--ui-body); font-size: 15px; line-height: 1.5; }
body [hidden] { display: none !important; }
body :is(h1,h2,h3,h4,p,small,strong,label,button,td,th) { overflow-wrap: anywhere; }
body :is(h1,h2,h3,h4) { text-wrap: pretty; }
body :is(button,input,select,textarea,a):focus-visible {
  outline: 3px solid var(--ui-focus) !important;
  outline-offset: 3px;
}
body :is(button,a,input,select,textarea) { scroll-margin-block: 90px; }
body button { font-family: var(--ui-body); }
body :is(.button,.table-action,.filter,.service-card-actions button,.service-builder-toolbar button,
  .service-checklist-actions button,.task-custom-checklist-actions button) {
  min-height: 44px;
  padding: 10px 16px;
  font-size: 14px !important;
  line-height: 1.4 !important;
  font-weight: 600 !important;
  white-space: normal;
  text-align: center;
  max-width: 100%;
}
body button:disabled { opacity: .5; cursor: not-allowed; transform: none; box-shadow: none; }
body .button:hover { transform: none; }
body :is(.icon-button,.task-detail-close,.profile-close) {
  flex: 0 0 44px; min-width: 44px; min-height: 44px; padding: 6px;
  font-size: 26px !important; line-height: 1 !important;
  border-radius: 12px;
}
body .icon-button:hover, body .task-detail-close:hover { background: #eaf0eb; color: var(--ink); }
body :is(form,dialog,.main-content) label {
  min-width: 0; font-size: 14px !important; line-height: 1.45 !important;
  font-weight: 600 !important; letter-spacing: 0 !important; text-transform: none !important;
}
body input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
body textarea, body select {
  min-width: 0; max-width: 100%; min-height: 44px;
  padding: 10px 12px !important;
  border-radius: 10px;
  font-family: var(--ui-body) !important;
  font-size: 16px !important; line-height: 1.45 !important; font-weight: 400 !important;
  letter-spacing: normal !important; color: var(--ui-text);
  box-sizing: border-box;
}
body textarea { min-height: 96px; resize: vertical; }
body input::placeholder, body textarea::placeholder { color: #65736e; opacity: 1; font-weight: 400; }
body :is(form,dialog,.main-content) small,
body :is(.german-entry-hint,.form-message,.form-error,.empty-state,.service-title-secondary) {
  font-size: 13px !important; line-height: 1.5 !important; font-weight: 400 !important;
  letter-spacing: 0; white-space: normal; overflow-wrap: anywhere;
}
body .german-entry-hint { color: #786025; margin-top: 4px; }
body .view-toolbar .german-entry-hint,
body .german-entry-hint:has(+ small) { display: none !important; }
body :is(.view-header p,.directory-panel > p,.profile-section-head p,.service-card p,
  .task-detail-head p,.task-event p,.task-description) { font-size: 14px; line-height: 1.6; font-weight: 400; }

/* Navigation: consistent labels, stable counters, and an independently scrollable list. */
body .app-shell { grid-template-columns: 240px minmax(0,1fr); align-items: start; }
body .sidebar {
  height: 100dvh !important; min-height: 0 !important; padding: 24px 16px !important;
  position: sticky !important; top: 0; display: flex !important; flex-direction: column !important;
  overflow: hidden !important; gap: 0;
}
body .sidebar .wordmark { padding: 0 12px 24px !important; flex-shrink: 0; }
body .sidebar nav {
  display: flex !important; flex-direction: column !important; flex: 1 1 auto;
  min-height: 0; max-height: none !important; overflow-y: auto !important; overflow-x: hidden;
  gap: 5px !important; padding: 0 3px 12px 0; scrollbar-width: thin; scrollbar-color: #67867b transparent;
}
body .sidebar .nav-item {
  display: flex !important; align-items: center; justify-content: flex-start;
  flex: 0 0 auto !important; gap: 8px; width: 100%; height: auto !important; min-height: 44px !important;
  padding: 10px 12px !important; margin: 0 !important;
  color: #dbe5e0 !important; opacity: 1 !important;
  font: 600 14px/1.4 var(--ui-body) !important; white-space: normal !important;
  text-align: left; border-radius: 10px;
}
body .sidebar .nav-item > span:first-child { display: none !important; }
body .sidebar .nav-item > span:not(:first-child) {
  display: inline !important; margin: 0 !important; opacity: 1 !important;
  font: inherit !important; min-width: 0;
}
body .sidebar .nav-item.active { color: #fff !important; background: #31504b !important; }
body .sidebar .nav-item:hover { background: #28433f; color: #fff !important; }
body .sidebar .nav-item > b:not([hidden]) {
  display: inline-flex !important; flex: 0 0 auto; align-items: center; justify-content: center;
  min-width: 24px; height: 24px; margin-left: auto !important; padding: 2px 7px;
  border-radius: 20px; font: 600 12px/1 var(--ui-body) !important;
}
body .sidebar-note { flex-shrink: 0; margin-top: 12px !important; padding: 14px 12px 8px; }
body .sidebar-note strong { font-size: 13px; font-weight: 600; }
body .sidebar-note small { font-size: 12px; color: #b9cac3; }
body .logout-button { flex-shrink: 0; min-height: 44px; padding: 10px 12px; color: #dbe5e0; font-size: 14px; }

/* Language control occupies real space rather than covering scrolling content. */
body .main-content { min-width: 0; padding: 18px clamp(18px,2.3vw,36px) 32px; }
.ui-page-tools { display: flex; justify-content: flex-end; min-height: 40px; margin-bottom: 14px; }
.ui-login-tools { position: absolute; top: 18px; right: 24px; left: 24px; display: flex; justify-content: flex-end; }
body .hostion-language-switcher {
  position: static !important; inset: auto !important; transform: none !important;
  display: inline-flex; align-items: center; gap: 4px; margin: 0 !important;
  max-width: 100%; padding: 4px 6px !important; border: 1px solid var(--ui-border);
  box-shadow: none !important; border-radius: 999px; background: #fffdf8;
}
body .hostion-language-switcher span { font-size: 13px !important; font-weight: 500 !important; margin: 0 8px; }
body .hostion-language-switcher button { min-width: 40px; min-height: 36px; font: 600 13px/1.3 var(--ui-body) !important; }
body .login-shell { padding-top: 84px; }
body .login-brand h1 { font-size: clamp(42px,5.5vw,80px); line-height: 1.02; }
body .login-card { padding: clamp(24px,3vw,44px); }

/* One type hierarchy across all pages. */
body :is(.topbar,.view-header) { align-items: flex-start; gap: 20px; flex-wrap: wrap; margin-bottom: 24px; }
body :is(.topbar,.view-header) > div:first-child { flex: 1 1 360px; min-width: 0; }
body .main-content :is(.topbar h2,.view-header h1) {
  margin: 6px 0 8px; font: 600 clamp(30px,3vw,42px)/1.12 var(--ui-display) !important;
  letter-spacing: -.025em !important; overflow-wrap: anywhere;
}
body .main-content .view-header p { max-width: 70ch; margin: 8px 0 0; color: var(--ui-secondary); }
body :is(.topbar-actions,.service-builder-header-actions) { flex-wrap: wrap; gap: 10px; align-items: center; }
body .user-pill { font-size: 13px; font-weight: 500; padding: 9px 12px; }
body :is(.eyebrow,.brand-kicker) { font: 600 11px/1.5 var(--ui-body); letter-spacing: .11em; }
body :is(.panel-heading,.directory-panel) h2,
body :is(.panel-heading,.directory-panel,.task-detail-section,.task-timeline,.profile-section,.service-checklist-heading) h3 {
  font-family: var(--ui-body) !important; font-size: 20px !important; line-height: 1.3 !important;
  font-weight: 600 !important; letter-spacing: -.015em;
}
body .panel-heading { flex-wrap: wrap; align-items: center; padding: 18px 20px; gap: 12px; }
body .legend { flex-wrap: wrap; font-size: 12px; line-height: 1.4; }
body .filter-row { display: flex !important; flex-wrap: wrap; gap: 6px; }
body .filter { font-size: 13px !important; }
body .view-toolbar { gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 20px; }
body .view-toolbar > :is(input,select) { min-width: 0; flex: 1 1 220px; }
body :is(.panel,.directory-panel,.service-card) { border-radius: 18px; }
body .directory-panel { min-width: 0; }
body .analytics-wide { grid-column: 1 / -1 !important; }
body :is(.metrics,.report-metrics,.device-registry-kpis,.system-status-panel) {
  display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 14px;
}
body .metric { min-height: 132px; padding: 18px 20px; }
body :is(.metric,.report-metrics article,.device-registry-kpis article,.system-status-panel article) { min-width: 0; }
body :is(.metric,.report-metrics article,.device-registry-kpis article) strong {
  font: 600 clamp(30px,3vw,42px)/1.2 var(--ui-display) !important; margin: 12px 0 4px;
}
body :is(.metric,.report-metrics article,.device-registry-kpis article) > :is(span,div) {
  font-size: 12px; font-weight: 600; letter-spacing: .03em; line-height: 1.45;
}
body .system-status-panel strong { font-size: 18px !important; line-height: 1.4 !important; font-weight: 600 !important; }
body .system-grid { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 20px; }

/* Scroll the table, not the page. Do not hide business columns on phones. */
.ui-table-scroll { min-width: 0; width: 100%; max-width: 100%; overflow: auto; overscroll-behavior-x: contain; scrollbar-width: thin; }
body .ui-table-scroll table { min-width: 680px; width: 100%; }
body .task-table-wrap .ui-table-scroll table { min-width: 960px; }
body .ui-table-scroll :is(th,td) { display: table-cell !important; padding: 14px 16px; vertical-align: top; white-space: normal; }
body .ui-table-scroll th { font-size: 12px !important; line-height: 1.45; font-weight: 600; color: var(--ui-secondary); letter-spacing: .03em; }
body .ui-table-scroll td { font-size: 14px !important; line-height: 1.5; font-weight: 400; }
body .ui-table-scroll td:first-child, body .ui-table-scroll td strong { font-weight: 600; }
body :is(.status,.specialist-request,.service-card-role,.service-card-state,.role-tag,.schedule-badge) {
  max-width: 100%; font-size: 12px !important; line-height: 1.4 !important;
  font-weight: 600 !important; white-space: normal; padding: 6px 10px;
}

/* Employee and team cards retain hierarchy without extra-heavy type. */
body .employee-layout { grid-template-columns: minmax(280px,.8fr) minmax(0,1.2fr); gap: 20px; }
body .employee-card { min-width: 0; gap: 12px; padding: 16px; text-align: left; }
body .employee-card strong, body .team-person strong { font-size: 16px !important; line-height: 1.4; font-weight: 600 !important; }
body .employee-card p { font-size: 13px; line-height: 1.5; font-weight: 400; }
body .team-person { min-width: 0; padding: 16px; border-radius: 14px; }
body .team-person p { font-size: 13px; font-weight: 400; }
body .team-person .team-connection { font-size: 13px !important; line-height: 1.4; font-weight: 700 !important; padding: 9px 12px; }
body .team-role-group h4 { font-size: 16px; font-weight: 600; }
body .worker-list { max-height: 680px; overscroll-behavior-y: contain; }

/* Dialogs: one scroll boundary, readable content, usable close targets. */
body:has(dialog[open]) { overflow: hidden !important; }
body dialog {
  max-width: calc(100vw - 32px) !important; max-height: calc(100dvh - 32px) !important;
  border-radius: 20px !important; overscroll-behavior: contain;
}
body :is(.modal,.task-detail-dialog,.employee-profile-dialog) { overflow-y: auto !important; }
body :is(.modal-heading,.task-detail-head,.profile-dialog-head,.service-editor-shell > header,.hostion-specialist-dialog-shell > header) {
  gap: 16px; align-items: flex-start;
}
body :is(.modal-heading h3,.task-detail-head h2,.profile-dialog-head h2,.service-editor-shell > header h2,.hostion-specialist-dialog-shell > header h2) {
  font: 600 clamp(24px,2.5vw,32px)/1.2 var(--ui-display) !important; margin: 4px 0 8px;
}
body :is(.task-detail-head,.profile-dialog-head) { position: sticky; top: 0; z-index: 4; padding: 20px 24px; }
body .task-detail-head { background: #fff; }
body .profile-dialog-head { background: var(--ink); }
body .profile-dialog-head p { font-size: 14px; line-height: 1.5; }
body .profile-stats strong { font-size: 26px; font-weight: 600; }
body .profile-form { padding: 16px; }
body .profile-section { padding: 20px; }
body .profile-section-head { flex-wrap: wrap; gap: 12px; }
body .profile-section-head p { max-width: 42ch; }
body .schedule-day { grid-template-columns: minmax(140px,1fr) auto; gap: 14px; }
body .time-range { grid-template-columns: minmax(110px,1fr) auto minmax(110px,1fr); }
body .time-range input { width: 100%; font-variant-numeric: tabular-nums; }
body .schedule-day:has(.schedule-enabled:not(:checked)) { opacity: 1; background: #f1f3f0; color: var(--ui-secondary); }
body :is(.schedule-actions,.profile-actions,.modal-actions,.task-detail-actions,.hostion-specialist-request-actions) { flex-wrap: wrap; gap: 10px; }
body .modal form { padding: 24px; }
body .task-create-grid { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 20px; }
body .task-create-grid > * { min-width: 0; }
body .task-create-grid .full { grid-column: 1 / -1; }
body .task-detail-grid { grid-template-columns: minmax(0,1.7fr) minmax(250px,.8fr); }
body .task-detail-grid main { min-width: 0; }
body .task-management-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
body .task-check p { font-size: 14px; line-height: 1.5; }
body .task-timeline { max-height: none; position: static; }
body .task-event strong { font-size: 14px; font-weight: 600; }
body :is(.task-detail-footer,.service-editor-footer,.hostion-specialist-dialog-shell > footer) { flex-wrap: wrap; gap: 10px; }
body .service-editor-shell { max-height: calc(100dvh - 32px); }
body .service-editor-shell > header { padding: 20px 24px; }
body .service-editor-body { padding: 20px 24px; min-height: 0; }
body .service-editor-footer { padding: 16px 24px; }
body .service-editor-fields { align-items: start; gap: 18px; }
body .service-editor-fields label { align-content: start; }
body .service-card h3 { font: 600 22px/1.3 var(--ui-display); }
body .service-card-head, body .service-card-meta { flex-wrap: wrap; }
body .service-card-meta { font-size: 13px; font-weight: 400; }
body .service-builder-count { min-width: 44px; height: 44px; border-radius: 14px; font-size: 22px; font-weight: 600; }
body .checklist-item-editor { grid-template-columns: 48px repeat(2,minmax(0,1fr)); align-items: start; gap: 16px; }
body .checklist-item-editor > label { grid-column: auto !important; }
body .checklist-item-order { grid-column: 1; grid-row: 1 / span 5; }
body .checklist-item-order button { width: 36px; height: 44px; }
body .checklist-item-remove { grid-column: 3 !important; min-height: 44px; }
/* Keep the search input inside its two existing 22px horizontal margins. */
body .checklist-library-search { width: calc(100% - 44px) !important; min-width: 0; box-sizing: border-box; }
body .checklist-library-row { grid-template-columns: 24px minmax(0,1fr) auto; }
body .checklist-library-row input { width: 18px; height: 18px; }
body .hostion-complete-media-grid { grid-template-columns: repeat(auto-fit,minmax(min(100%,280px),1fr)); gap: 18px; }
body .hostion-media-title { font-size: 15px; line-height: 1.5; font-weight: 600; }
body .hostion-media-meta { min-height: 0; padding: 14px 16px; }
body .hostion-media-meta span { font-size: 13px; font-weight: 600; }
body .hostion-specialist-dialog-shell :is(input,select,textarea) { width: 100%; }

@media (max-width: 1180px) {
  body .app-shell { grid-template-columns: 220px minmax(0,1fr); }
  body :is(.metrics,.report-metrics,.device-registry-kpis,.system-status-panel) { grid-template-columns: repeat(2,minmax(0,1fr)); }
  body :is(.employee-layout,.system-grid,.task-detail-grid) { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  body .app-shell { display: block; }
  body .sidebar {
    position: static !important; height: auto !important; min-height: 0 !important;
    display: flex !important; flex-direction: row !important; flex-wrap: wrap !important;
    align-items: center; padding: 14px 16px !important; gap: 12px;
  }
  body .sidebar .wordmark { padding: 0 !important; order: 0; }
  body .sidebar .logout-button { order: 1; margin-left: auto; padding: 8px; }
  body .sidebar nav {
    order: 2; flex: 0 0 100%; width: 100%; display: flex !important;
    flex-direction: row !important; align-items: stretch; max-height: none !important;
    overflow-x: auto !important; overflow-y: hidden !important; padding: 0 0 6px;
    gap: 6px !important; scrollbar-width: thin;
  }
  body .sidebar .nav-item { width: auto !important; max-width: 76vw; min-height: 44px !important; white-space: nowrap !important; }
  body .sidebar .sidebar-note { display: none !important; }
  body .main-content { padding: 14px 16px 28px; }
  body :is(.topbar,.view-header) { margin-bottom: 20px; }
  body .service-builder-grid { grid-template-columns: 1fr; }
  body .view-header > :is(div,button) { max-width: 100%; }
}
@media (max-width: 680px) {
  body .main-content :is(.topbar h2,.view-header h1) { font-size: 30px !important; }
  body .panel-heading { padding: 16px; }
  body .panel-heading :is(h2,h3) { font-size: 19px !important; }
  body .topbar-actions { flex-direction: row; align-items: stretch; }
  body .topbar-actions .button { flex: 1 1 auto; }
  body .user-pill { display: none; }
  body .metric { min-height: 120px; padding: 16px; }
  body .metric strong { font-size: 34px !important; }
  body .filter-row { width: 100%; }
  body .filter-row .filter { flex: 1 1 auto; }
  body .view-toolbar > :is(input,select) { flex-basis: 100%; width: 100%; }
  body .worker-list { max-height: none; overflow: visible; }
  body .team-role-group { min-width: 0; }
  body :is(.task-create-grid,.task-management-grid,.task-people,.task-checklist,.task-access-grid,
    .profile-field-grid,.service-editor-fields,.device-registry-lower) { grid-template-columns: minmax(0,1fr) !important; }
  body :is(.task-create-grid .full,.profile-wide,.service-span-2) { grid-column: 1 !important; }
  body dialog { width: calc(100vw - 16px) !important; max-width: calc(100vw - 16px) !important; max-height: calc(100dvh - 16px) !important; margin: auto; border-radius: 14px !important; }
  body .modal form { padding: 18px; }
  body :is(.modal-actions,.profile-actions,.schedule-actions,.task-detail-footer) { display: flex; flex-wrap: wrap; }
  body :is(.modal-actions,.profile-actions,.schedule-actions,.task-detail-footer) > button { flex: 1 1 160px; }
  body :is(.task-detail-head,.profile-dialog-head) { padding: 16px 18px; }
  body :is(.task-detail-head h2,.profile-dialog-head h2,.modal-heading h3) { font-size: 26px !important; }
  body .profile-section { padding: 16px; }
  body .profile-form { padding: 10px; }
  body .profile-section-head { display: flex; }
  body .schedule-day { grid-template-columns: minmax(0,1fr); gap: 10px; }
  body .time-range { grid-template-columns: minmax(0,1fr) auto minmax(0,1fr); }
  body .service-editor-shell { max-height: calc(100dvh - 16px); }
  body :is(.service-editor-shell > header,.service-editor-body,.service-editor-footer) { padding: 16px; }
  body .service-editor-footer button { flex: 1 1 110px; }
  body .checklist-item-editor { display: flex; flex-direction: column; align-items: stretch; padding: 14px; }
  body .checklist-item-order { display: flex; justify-content: flex-start; gap: 12px; border-right: 0; padding-bottom: 10px; }
  body .checklist-library-row { grid-template-columns: 24px minmax(0,1fr); }
  body .checklist-library-row b { grid-column: 2; justify-self: start; }
  body .hostion-complete-media-grid { grid-template-columns: minmax(0,1fr); }
  body .hostion-specialist-dialog-shell :is(header,footer) { flex-wrap: wrap; gap: 10px; }
  body .hostion-specialist-dialog-shell > header > div { flex: 1; min-width: 0; }
  body .hostion-specialist-dialog-shell > footer button { flex: 1 1 160px; }
}
@media (max-width: 370px) {
  body :is(.metrics,.report-metrics,.device-registry-kpis,.system-status-panel) { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  body *, body *::before, body *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
