/* ── Client role ─────────────────────────────────────────────
   One rung below supervisor: read-only. The client inherits every
   viewer-role restriction above, and additionally loses the
   dashboard's buttons (only switch-user survives, for handing the
   phone back). Until 2.4.79 a client was routed into Field
   Overview instead; that screen is gone, so the dashboard itself
   is the landing now and these rules are what shapes it. */
body.client-role #dashboardView .btn,
body.client-role #dashboardView button {
  display: none !important;
}
body.client-role #dashboardView [data-onclick='switchUser()'] {
  display: flex !important;
}
/* Admin tools (Add technician, Set service hours, Bulk import / Set up
   lists). Hidden for every other role even if a script sets them visible.
   applyRoleRestriction sets data-role="admin" on <html> for an admin. */
html:not([data-role='admin'])
  :is(
    #addTechnicianBtn,
    #adminServiceHoursBtn,
    #bulkImportFolderBtn,
    #setupListsBtn,
    #setupImportBtn,
    [data-admin-only]
  ) {
  display: none !important;
}

/* ── Landing overlay ─────────────────────────────────────────
   First screen an unauthenticated device sees, and the screen a
   prospective client is walked past in a demo. Kept in CSS rather
   than a wall of inline styles so the feature cards actually pick
   up --bg-card / --card-dark (the previous inline block referenced
   --bg-card before that token existed). Field UI is deliberately
   untouched: glove-size buttons stay where they are. */
.landing-overlay {
  display: flex;
  position: fixed;
  inset: 0;
  background: var(--bg-dark);
  z-index: 9600;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: calc(20px + var(--safe-top)) 20px calc(20px + var(--safe-bottom));
  overflow-y: auto;
}
.landing-inner {
  max-width: 500px;
  width: 100%;
  text-align: center;
}
.landing-logo {
  width: 80px;
  height: auto;
  margin-bottom: 20px;
}
.landing-title {
  color: var(--primary);
  font-size: clamp(1.5rem, 4vw, 1.85rem);
  margin: 0 0 12px;
  letter-spacing: 0.02em;
  text-wrap: balance;
  line-height: 1.15;
}
.landing-lede {
  color: var(--text-muted);
  font-size: var(--fs-sm);
  line-height: 1.6;
  margin: 0 auto 24px;
  max-width: 42em;
  text-wrap: pretty;
}
.landing-features {
  display: grid;
  gap: 10px;
  margin-bottom: 20px;
  text-align: left;
}
.landing-feature {
  background: var(--card-dark);
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  min-height: 100%;
}
.landing-feature-label {
  color: var(--primary);
  font-size: var(--fs-sm);
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin: 0 0 4px;
}
.landing-feature p {
  color: var(--text-main);
  font-size: var(--fs-sm);
  line-height: 1.55;
  margin: 0;
}
.landing-overlay .btn-primary {
  width: 100%;
  margin-bottom: 10px;
}
.landing-footer {
  font-size: var(--fs-2xs);
  color: var(--text-muted);
  margin-top: 12px;
}
.landing-footer a {
  color: var(--text-muted);
  text-decoration: underline;
}
@media (prefers-reduced-motion: no-preference) {
  .landing-inner {
    animation: landing-in 280ms ease-out;
  }
}
@keyframes landing-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Tablet / desktop: the field app stays a phone-width column (glove
   buttons), but the landing is a product page and should use the screen. */
@media (min-width: 700px) {
  .landing-inner {
    max-width: 760px;
  }
  .landing-features {
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }
  .landing-overlay .btn-primary {
    max-width: 320px;
    margin-left: auto;
    margin-right: auto;
  }
  .landing-logo {
    width: 96px;
  }
  body {
    max-width: 680px;
    padding: 24px;
    padding-top: calc(24px + var(--safe-top));
    padding-bottom: calc(24px + var(--safe-bottom));
    padding-left: calc(24px + var(--safe-left));
    padding-right: calc(24px + var(--safe-right));
  }
}
@media (min-width: 1024px) {
  .landing-inner {
    max-width: 860px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .btn,
  .btn-secondary,
  .btn-action,
  .landing-inner {
    transition: none;
    animation: none;
  }
}

/* Equal-width TODAY / HISTORY (and the same pair on every report).
   auto-fit so a hidden second tab (Review, when you're not admin)
   doesn't leave a blank hole. */
.tab-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
  gap: 8px;
  margin: 10px 0 14px;
  align-items: stretch;
}
.tab-row .btn-action {
  width: 100%;
  margin-bottom: 0;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 12px 8px;
  box-sizing: border-box;
  white-space: normal;
  line-height: 1.25;
}

/* iOS date/time controls have an intrinsic min-width that overflows a
   two-column grid and paints over the field next to them (Date over
   Project on the DAR). Force them to the cell. */
.grid-2 > *,
.grid-3 > * {
  min-width: 0;
  overflow: visible;
}
input[type='date'],
input[type='time'],
input[type='datetime-local'] {
  display: block;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  -webkit-appearance: none;
  appearance: none;
}
input[type='date']::-webkit-date-and-time-value,
input[type='time']::-webkit-date-and-time-value {
  text-align: left;
  min-width: 0;
}

/* Every paired/tripled field row: labels can wrap, but the boxes sit
   on one baseline. Applies to Date/Project, Time On/Off, commissioning,
   fault, service, IR, GI, PDI, load test, work orders, PPE. */
.grid-2,
.grid-3 {
  align-items: stretch;
}
.grid-2:not([style*='margin-bottom']),
.grid-3:not([style*='margin-bottom']) {
  margin-bottom: 12px;
}
.grid-2 > .form-group,
.grid-3 > .form-group {
  display: flex;
  flex-direction: column;
  margin-bottom: 0;
  min-width: 0;
}
.grid-2 > .form-group > input,
.grid-2 > .form-group > select,
.grid-2 > .form-group > textarea,
.grid-3 > .form-group > input,
.grid-3 > .form-group > select,
.grid-3 > .form-group > textarea {
  margin-top: auto;
  width: 100%;
  max-width: 100%;
}

/* Standard form controls — beat inline padding="9px" so a date next to
   a select is the same height on every screen. Direct children only, so
   compact widgets (oil-pressure unit, PPE serial) stay compact. */
.form-group > input:not([type='checkbox']):not([type='radio']):not([type='file']),
.form-group > select,
.app-modal-box .form-group > input:not([type='checkbox']):not([type='radio']):not([type='file']),
.app-modal-box .form-group > select {
  min-height: 48px !important;
  font-size: 16px !important;
  padding: 12px 14px !important;
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
}
.form-group > select,
.app-modal-box .form-group > select {
  padding-right: 36px !important;
  background-position: right 12px center;
}
.form-group > input[type='file'] {
  min-height: 48px;
  padding: 10px 12px;
  font-size: 16px;
}
/* Photo pickers: the native "Choose File" control is hidden. The label
   is the button. multiple is set so a laptop can add several at once;
   the phone still offers the camera, then the same compress-and-keep flow. */
.photo-add {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  margin-top: 8px;
  padding: 0 14px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  background: var(--input-bg);
  color: var(--text-main);
  font-weight: 700;
  cursor: pointer;
}
.photo-file {
  position: absolute !important;
  width: 0 !important;
  height: 0 !important;
  min-height: 0 !important;
  padding: 0 !important;
  margin: 0 !important;
  overflow: hidden !important;
  opacity: 0 !important;
  border: 0 !important;
  pointer-events: none !important;
}

.grid-2 > .btn-action,
.grid-3 > .btn-action {
  min-height: 48px;
  margin-bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

/* Day Type and similar radio groups: one option per row on a phone so
   "Waiting On Weather" doesn't wrap under the other two. */
.choice-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 4px 0 8px;
}
.choice-row label {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  min-height: 44px;
  font-weight: 400;
  text-transform: none;
  font-size: var(--fs-sm);
  color: var(--text-main);
}
.choice-row input[type='radio'] {
  width: 20px;
  height: 20px;
  min-height: 0;
  flex-shrink: 0;
  accent-color: var(--primary);
}
@media (min-width: 560px) {
  .choice-row {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 10px 22px;
  }
}

/* Dashboard buttons were a mix of one-line folders and two-line labelled
   tiles, so the row heights jumped. Same min-height, and room at the
   bottom so the last tile isn't hidden under Safari's toolbar. */
#dashboardView .btn {
  min-height: 76px;
}
#dashboardView .btn:has([id$='FolderArrow']),
#dashboardView .btn:has(#folderArrow) {
  padding-right: 44px;
}
/* Bottom padding is scroll room, not visible spacing: it sits below the
   version stamp, at the very end of the page. Home shell slice 1 moved
   the tap-to-scroll targets from the tiles (near the top) to the folder
   panels themselves, below the rows stack and the fleet strip. A short
   panel - Team, when only the timeline button shows - plus everything
   under it can total less than one viewport, so without enough room
   below it the page runs out of scroll before the panel can reach the
   top (measured 33px short on a Pixel 7 with an empty recent-work list,
   and further still when the status line grows mid-scroll as the first
   sync lands). 190px leaves that room with margin to spare. */
#dashboardView {
  padding-bottom: 190px;
}
