/* Safety Forms theme, matching the PowerVac iOS app (Theme.swift):
   blue #0583E1 on #F2F8FC, white cards with a hairline border and 14px
   corners, light-blue icon tiles, iOS-style navigation bar and grouped lists. */
:root {
  --primary: #0583E1;
  --primary-dark: #075691;
  --icon-bg: #E2EFF9;
  --bg: #F2F8FC;
  --card: #FFFFFF;
  --border: #C9D3DC;
  --text: #111C26;
  --text-2: #3D4D5C;
  --danger: #D92D20;
  --radius: 14px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  /* Bootstrap + Form.io pick these up */
  --bs-primary: var(--primary);
  --bs-primary-rgb: 5, 131, 225;
  --bs-body-font-family: var(--font);
  --bs-body-color: var(--text);
  --bs-border-color: var(--border);
  --bs-link-color: var(--primary);
  --bs-link-color-rgb: 5, 131, 225;
}

html { -webkit-text-size-adjust: 100%; }
body { background: var(--bg); color: var(--text); font-family: var(--font); min-height: 100vh; }
a { color: var(--primary); }

/* ---------- App frame: sidebar on wide screens (like the iPad split view) ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar { display: none; }
.content { flex: 1; min-width: 0; display: flex; flex-direction: column; }

@media (min-width: 900px) {
  .sidebar {
    display: block; width: 280px; flex-shrink: 0; background: var(--bg);
    border-right: 1px solid var(--border); padding: 16px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto;
  }
  .sidebar .app-name { font-size: 1.6rem; font-weight: 700; padding: 8px 10px 14px; }
  .sidebar .group-label { font-size: .75rem; font-weight: 600; color: var(--text-2); text-transform: uppercase; letter-spacing: .03em; padding: 14px 10px 6px; }
  .sidebar a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; color: var(--text); text-decoration: none; font-weight: 500; }
  .sidebar a i { color: var(--primary); font-size: 1.1rem; width: 22px; text-align: center; }
  .sidebar a:hover { background: var(--icon-bg); }
  .sidebar a.active { background: var(--primary); color: #fff; }
  .sidebar a.active i { color: #fff; }
  .navbar-app .back { visibility: hidden; }
}

/* ---------- Navigation bar ---------- */
.navbar-app {
  position: sticky; top: 0; z-index: 1030;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px;
  padding: 10px 16px; padding-top: calc(10px + env(safe-area-inset-top));
  background: rgba(242, 248, 252, .85); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid rgba(201, 211, 220, .7);
  min-height: 52px;
}
.navbar-app .back { justify-self: start; display: inline-flex; align-items: center; gap: 2px; color: var(--primary); text-decoration: none; font-size: 1.05rem; max-width: 100%; }
.navbar-app .back i { font-size: 1.25rem; }
.navbar-app .back span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.navbar-app .title { font-weight: 600; font-size: 1.05rem; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 55vw; }
.navbar-app .trailing { justify-self: end; position: relative; }

/* Access badge + menu (like AccessMenu in the app) */
.access-badge { display: inline-flex; align-items: center; gap: 6px; background: none; border: 0; color: var(--primary); font-weight: 600; font-size: .95rem; padding: 4px 2px; }
.access-menu {
  position: absolute; right: 0; top: calc(100% + 8px); min-width: 250px; z-index: 1040;
  background: rgba(255, 255, 255, .97); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-radius: 14px; box-shadow: 0 12px 40px rgba(17, 28, 38, .18), 0 0 0 1px rgba(201, 211, 220, .6);
  overflow: hidden; display: none;
}
.access-menu.open { display: block; }
.access-menu .head { padding: 12px 16px; border-bottom: 1px solid var(--border); }
.access-menu .head .role { font-weight: 600; display: flex; align-items: center; gap: 8px; }
.access-menu .head .who { color: var(--text-2); font-size: .85rem; margin-top: 2px; }
.access-menu button { display: flex; width: 100%; align-items: center; justify-content: space-between; gap: 10px; background: none; border: 0; padding: 12px 16px; font-size: 1rem; color: var(--text); text-align: left; }
.access-menu button + button { border-top: 1px solid rgba(201, 211, 220, .6); }
.access-menu button:hover { background: var(--bg); }
.access-menu button.destructive { color: var(--danger); }

/* ---------- Page body ---------- */
.page { width: 100%; max-width: 900px; margin: 0 auto; padding: 16px 16px 48px; }
.page.narrow { max-width: 760px; }
.page.wide { max-width: 1400px; }

/* Home header banner (photo + logo card, or a blue gradient) */
.banner {
  height: 170px; position: relative; display: flex; align-items: center; justify-content: center; overflow: hidden;
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
}
.banner.has-image { background-size: cover; background-position: center; }
.banner.has-image::after { content: ""; position: absolute; inset: 0; background: linear-gradient(rgba(0,0,0,.05), rgba(0,0,0,.35)); }
.banner .logo-card { position: relative; z-index: 1; background: rgba(255,255,255,.92); border-radius: 12px; padding: 10px 16px; max-width: 260px; }
.banner .logo-card img { display: block; max-width: 228px; max-height: 60px; }
.banner .logo-card .wordmark { font-size: 1.75rem; font-weight: 800; color: var(--primary-dark); letter-spacing: -.01em; }

.home-head { text-align: center; padding-top: 20px; margin-bottom: 18px; }
.capsule { display: inline-block; font-size: .7rem; font-weight: 700; letter-spacing: .09em; color: var(--primary); background: var(--icon-bg); border-radius: 999px; padding: 4px 10px; }
.home-head h1 { font-size: 1.75rem; font-weight: 700; margin: 8px 0 4px; }
.home-head p { color: var(--text-2); margin: 0; font-size: .95rem; }

/* Tiles */
.tile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.tile {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; text-align: center;
  min-height: 130px; padding: 16px 10px; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); text-decoration: none; transition: transform .08s ease, box-shadow .15s ease;
}
.tile:hover { box-shadow: 0 4px 14px rgba(5, 131, 225, .12); color: var(--text); }
.tile:active { transform: scale(.98); }
.tile .name { font-weight: 600; font-size: 1.05rem; line-height: 1.2; }
.tile .count { color: var(--text-2); font-size: .8rem; margin-top: -8px; }

.icon-tile { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; width: 44px; height: 44px; border-radius: 11px; background: var(--icon-bg); color: var(--primary); font-size: 20px; }
.icon-tile.lg { width: 52px; height: 52px; border-radius: 13px; font-size: 24px; }
.icon-tile.sm { width: 40px; height: 40px; border-radius: 10px; font-size: 18px; }

/* Rows (LinkRow in the app) */
.rows { display: flex; flex-direction: column; gap: 12px; }
.row-link {
  display: flex; align-items: center; gap: 14px; padding: 12px; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); text-decoration: none; width: 100%; text-align: left;
}
.row-link:hover { color: var(--text); box-shadow: 0 4px 14px rgba(5, 131, 225, .10); }
.row-link .text { flex: 1; min-width: 0; }
.row-link .t { font-weight: 600; display: block; }
.row-link .s { color: var(--text-2); font-size: .82rem; display: block; margin-top: 1px; }
.row-link .chev { color: var(--text-2); font-size: .85rem; }

.pill-link { display: inline-flex; align-items: center; gap: 8px; padding: 12px 18px; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); font-weight: 600; text-decoration: none; }

/* Buttons */
.btn { border-radius: 12px; font-weight: 600; }
.btn-primary { --bs-btn-bg: var(--primary); --bs-btn-border-color: var(--primary); --bs-btn-hover-bg: var(--primary-dark); --bs-btn-hover-border-color: var(--primary-dark); --bs-btn-active-bg: var(--primary-dark); --bs-btn-disabled-bg: var(--primary); --bs-btn-disabled-border-color: var(--primary); }
.btn-tinted { background: var(--icon-bg); color: var(--primary); border: 0; }
.btn-tinted:hover { background: #d3e6f6; color: var(--primary-dark); }
.btn-block { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; padding: 14px; font-size: 1.05rem; border-radius: var(--radius); }

/* Cards */
.card-plain { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }

/* Empty / locked states (ContentUnavailableView) */
.unavailable { text-align: center; padding: 56px 16px; color: var(--text-2); }
.unavailable i.big { font-size: 3rem; color: #9aa7b3; display: block; margin-bottom: 10px; }
.unavailable h2 { color: var(--text); font-size: 1.3rem; font-weight: 700; margin-bottom: 6px; }

/* Done state after submitting */
.done-check { width: 72px; height: 72px; border-radius: 50%; background: #E3F4EA; color: #1B7A43; display: inline-flex; align-items: center; justify-content: center; font-size: 2.2rem; margin-bottom: 12px; }
.done-check.waiting { background: #FFF3DC; color: #9A6200; }

/* Inset grouped lists (Admin Settings, like a SwiftUI Form) */
.group { margin-bottom: 26px; }
.group-header { font-size: .78rem; font-weight: 500; color: var(--text-2); text-transform: uppercase; letter-spacing: .02em; padding: 0 16px 6px; display: flex; justify-content: space-between; align-items: end; }
.group-header .action { text-decoration: none; text-transform: none; font-size: .9rem; font-weight: 600; letter-spacing: 0; background: none; border: 0; color: var(--primary); padding: 0; }
.group-body { background: var(--card); border-radius: 12px; border: 1px solid var(--border); overflow: hidden; }
.group-footer { font-size: .8rem; color: var(--text-2); padding: 6px 16px 0; }
.g-row { display: flex; align-items: center; gap: 12px; padding: 10px 14px; min-height: 52px; }
.g-row + .g-row { border-top: 1px solid rgba(201, 211, 220, .6); }
.g-row .main { flex: 1; min-width: 0; }
.g-row .main .t { font-weight: 500; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.g-row .main .s { color: var(--text-2); font-size: .8rem; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.g-row button.main { background: none; border: 0; text-align: left; padding: 0; color: inherit; }
.g-row .ctl { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }
.g-row select.picker {
  appearance: none; -webkit-appearance: none; border: 0; background: transparent; color: var(--text-2); font-size: .95rem; text-align: right;
  padding: 4px 18px 4px 4px; max-width: 150px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='14' viewBox='0 0 10 14'%3E%3Cpath d='M1 5l4-4 4 4M1 9l4 4 4-4' stroke='%233D4D5C' stroke-width='1.6' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right center;
}
.g-row .tag { font-size: .72rem; font-weight: 600; border-radius: 6px; padding: 2px 7px; background: var(--icon-bg); color: var(--primary-dark); }
.g-row .tag.off { background: #EEF0F2; color: var(--text-2); }
.g-row .tag.warn { background: #FFF3DC; color: #9A6200; }
.g-row .icon-btn { background: none; border: 0; color: var(--primary); font-size: 1.1rem; padding: 4px 6px; }
.g-row .icon-btn.danger { color: var(--danger); }

/* Status dot */
.status-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: #9aa5b1; margin-right: 6px; }
.status-dot.ok { background: #1B7A43; }
.status-dot.bad { background: var(--danger); }

/* Sheets (dialogs): bottom sheet on phones, centered card on wide screens */
dialog.sheet {
  border: 0; padding: 0; width: min(520px, 100%); max-height: 92vh; border-radius: 16px; background: var(--bg); color: var(--text);
  box-shadow: 0 20px 60px rgba(17, 28, 38, .25);
}
dialog.sheet::backdrop { background: rgba(17, 28, 38, .35); }
dialog.sheet .sheet-bar { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--border); background: var(--card); }
dialog.sheet .sheet-bar .title { font-weight: 600; text-align: center; }
dialog.sheet .sheet-bar button { background: none; border: 0; color: var(--primary); font-size: 1rem; padding: 0; }
dialog.sheet .sheet-bar .confirm { justify-self: end; font-weight: 600; }
dialog.sheet .sheet-bar .cancel { justify-self: start; }
dialog.sheet .sheet-body { padding: 16px; overflow-y: auto; }
dialog.sheet .field { background: var(--card); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; margin-bottom: 6px; }
dialog.sheet .field > label { display: flex; align-items: center; gap: 12px; padding: 0 14px; min-height: 48px; margin: 0; }
dialog.sheet .field > label + label { border-top: 1px solid rgba(201, 211, 220, .6); }
dialog.sheet .field > label span { width: 110px; flex-shrink: 0; color: var(--text); }
dialog.sheet .field input, dialog.sheet .field select { flex: 1; border: 0; outline: 0; background: transparent; font-size: 16px; min-width: 0; padding: 12px 0; color: var(--text); }
dialog.sheet .hint { font-size: .8rem; color: var(--text-2); padding: 4px 14px 14px; }
dialog.sheet .hint.error { color: var(--danger); }
dialog.sheet .icon-choices { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 8px; padding: 12px; }
dialog.sheet .icon-choices button { border: 2px solid transparent; background: var(--icon-bg); color: var(--primary); border-radius: 11px; height: 44px; font-size: 20px; }
dialog.sheet .icon-choices button.on { border-color: var(--primary); }
dialog.sheet .sheet-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
@media (max-width: 599px) {
  dialog.sheet { margin: auto 0 0; width: 100%; max-width: 100%; border-radius: 16px 16px 0 0; padding-bottom: env(safe-area-inset-bottom); }
}

/* Offline outbox banner */
.outbox-banner { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: #FFF3DC; color: #6B4500; border: 1px solid #F2D49B; border-radius: var(--radius); padding: 12px 14px; margin-bottom: 16px; }
.outbox-banner .btn { flex-shrink: 0; }

/* Alerts */
.alert { border-radius: 12px; }

/* Form.io inside a card, with roomy tap targets on phones */
.form-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 16px; }
.formio-form .form-control, .formio-form .form-select, .formio-form .choices__inner { min-height: 44px; font-size: 16px; border-radius: 10px; border-color: var(--border); }
.formio-form .btn { min-height: 46px; padding-left: 22px; padding-right: 22px; }
.formio-form .card { border-radius: 12px; border-color: var(--border); }
.formio-form .card-header { background: var(--icon-bg); color: var(--primary-dark); font-weight: 600; border-bottom-color: var(--border); }
.formio-form .signature-pad-body { border-radius: 10px; }

/* Builder */
.builder-meta { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 10px; }
.builder-meta label { font-size: .78rem; font-weight: 600; color: var(--text-2); text-transform: uppercase; letter-spacing: .02em; margin-bottom: 4px; }
.builder-meta .form-control, .builder-meta .form-select { border-radius: 10px; border-color: var(--border); min-height: 44px; }
.builder-meta.two { grid-template-columns: 1fr 1fr; }
@media (max-width: 700px) { .builder-meta, .builder-meta.two { grid-template-columns: 1fr; } }
.formio.builder .formcomponent { border-radius: 8px; }

/* Sign-in page */
.signin { min-height: 100vh; display: flex; flex-direction: column; }
.signin .banner { height: 210px; padding-top: env(safe-area-inset-top); }
.signin-card { background: var(--card); border: 1px solid var(--border); border-radius: 18px; padding: 26px 22px; width: calc(100% - 32px); max-width: 420px; margin: -48px auto 32px; position: relative; z-index: 2; box-shadow: 0 10px 30px rgba(17, 28, 38, .08); }
.signin-card .form-control { font-size: 16px; min-height: 50px; border-radius: 12px; border-color: var(--border); }

/* Status tags (sign-off) */
.tag { display: inline-block; font-size: .72rem; font-weight: 600; border-radius: 6px; padding: 2px 7px; background: var(--icon-bg); color: var(--primary-dark); }
.tag.ok { background: #E3F4EA; color: #1B7A43; }
.tag.warn { background: #FFF3DC; color: #9A6200; }
.tag.off { background: #EEF0F2; color: var(--text-2); }
