/*
 * FIMS app-style UI layer — fitness-kit inspired refresh.
 * Loaded after portal.css. Keeps CDC blue / orange brand; soft cards + mobile bottom nav.
 */

:root {
  --app-paper: #E8EDF3;
  --app-radius-sm: 10px;
  --app-radius-md: 16px;
  --app-radius-lg: 20px;
  --app-shadow-card: 0 4px 18px rgba(0, 40, 80, 0.08);
  --app-shadow-soft: 0 2px 10px rgba(0, 40, 80, 0.06);
}

body {
  background: var(--app-paper);
}

/* ── Top bar ── */
.topbar {
  border-bottom: none;
  box-shadow: var(--app-shadow-soft);
}

.topbar-nav-row {
  border-top-color: rgba(213, 221, 232, 0.7);
}

.role-pill {
  border-radius: 999px;
  padding: 5px 12px;
  font-family: 'Inter', sans-serif;
}

.navlink,
.btn,
.icon-btn,
.sched-input {
  border-radius: var(--app-radius-sm);
}

.btn {
  border-radius: 12px;
}

/* ── Login ── */
.page-login .breadcrumb {
  display: none;
}

.page-login .topbar {
  box-shadow: none;
  border-bottom: 1px solid rgba(213, 221, 232, 0.8);
}

.page-login .system-title {
  display: none;
}

.login-wrap {
  align-items: center;
  min-height: calc(100vh - 72px);
  padding: 32px 20px 48px;
}

.login-card {
  border: none;
  border-radius: var(--app-radius-lg);
  box-shadow: var(--app-shadow-card);
  padding: 40px 32px 36px;
}

.login-card-title {
  text-align: center;
  font-size: 20px;
  font-weight: 800;
  margin-bottom: 4px;
}

.login-card-subtitle {
  text-align: center;
  margin-bottom: 20px;
  font-size: 13px;
}

.login-card .field {
  margin-bottom: 10px;
}

.login-card .sched-input {
  width: 100%;
  min-width: 0;
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 14px;
}

.login-submit {
  width: 100%;
  justify-content: center;
  margin-top: 14px;
  min-height: 46px;
  border-radius: 999px;
  font-size: 14px;
}

.login-error {
  border-radius: 10px;
}

/* ── Home section cards ── */
.home-section-card,
.home-section-card--supervisory,
.home-section-card--pending,
.home-section-card--ld,
.home-section-card--monthly,
.home-section-card--workshop,
.home-section-card--facility,
.home-section-card--ops {
  background: #fff;
  border: none;
  border-radius: var(--app-radius-md);
  box-shadow: var(--app-shadow-card);
  padding: 18px 16px 16px;
  max-width: 720px;
}

.home-section-card-title {
  text-transform: none;
  letter-spacing: 0;
  font-size: 14px;
  font-weight: 800;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--line);
}

.home-section-card--supervisory .home-section-card-title {
  color: #005a9e;
  border-bottom-color: #93bce0;
}

.home-section-card--pending .home-section-card-title {
  color: #c45a10;
  border-bottom-color: #f0c9a8;
}

.home-section-card--ld .home-section-card-title {
  color: #5b3fa0;
  border-bottom-color: #c4b5e0;
}

.home-section-card--monthly .home-section-card-title {
  color: #9e3a3a;
  border-bottom-color: #d4a5a5;
}

.home-section-card--workshop .home-section-card-title {
  color: #3d6b2e;
  border-bottom-color: #a8c99e;
}

.home-section-card--facility .home-section-card-title {
  color: #5b3fa0;
  border-bottom-color: #c4b5e0;
}

.home-section-card--ops .home-section-card-title {
  color: #3d5a4a;
  border-bottom-color: #b5c5b8;
}

.home-section-card .si-preset-row {
  gap: 10px;
}

.si-preset-btn {
  border-radius: 14px;
  background: #fff;
  box-shadow: var(--app-shadow-soft);
}

.si-preset-btn--rich {
  padding: 14px 12px;
  min-height: 72px;
}

.si-preset-btn:hover {
  box-shadow: 0 4px 14px rgba(0, 114, 206, 0.12);
  transform: translateY(-1px);
}

/* ── Entry cards (activity-style) ── */
.entry-card-list {
  gap: 12px;
}

.si-entry {
  border: none;
  border-radius: var(--app-radius-md);
  box-shadow: var(--app-shadow-soft);
  padding: calc(16px * var(--entry-font-scale, 1)) calc(18px * var(--entry-font-scale, 1));
  gap: calc(10px * var(--entry-font-scale, 1));
  background: #fff;
  font-size: calc(15px * var(--entry-font-scale, 1));
  line-height: 1.5;
}

.si-entry--sev-low {
  background: #f8fcf9;
  box-shadow: var(--app-shadow-soft), inset 0 0 0 1px #b8dcc8;
}

.si-entry--sev-medium {
  background: #fffcf6;
  box-shadow: var(--app-shadow-soft), inset 0 0 0 1px #e8d4a8;
}

.si-entry--sev-high {
  background: #fff9f7;
  box-shadow: var(--app-shadow-soft), inset 0 0 0 1px #e8c4bc;
}

.si-entry--sev-critical {
  background: #fff5f3;
  box-shadow: var(--app-shadow-soft), inset 0 0 0 1px #dfa8a0;
}

.si-entry.pending-highlight,
.si-entry--pending {
  border-left: 4px solid var(--cdc-orange);
}

.si-entry-id {
  font-family: 'IBM Plex Mono', monospace;
  font-size: calc(13px * var(--entry-font-scale, 1));
  letter-spacing: 0.02em;
  color: var(--ink-soft);
}

a.si-entry-id-link {
  color: var(--cdc-blue);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

a.si-entry-id-link:hover {
  color: var(--cdc-orange);
}

.si-entry-sub {
  font-size: calc(13px * var(--entry-font-scale, 1));
}

.si-entry-loc {
  flex: 1 1 100%;
  font-size: calc(17px * var(--entry-font-scale, 1));
  font-weight: 700;
  color: var(--ink);
  line-height: 1.35;
}

.si-entry-inspector {
  font-size: calc(13px * var(--entry-font-scale, 1));
  color: var(--ink-soft);
}

.si-entry-desc {
  font-size: calc(15px * var(--entry-font-scale, 1));
  color: var(--ink);
  line-height: 1.55;
}

.si-entry-head {
  gap: calc(8px * var(--entry-font-scale, 1)) calc(12px * var(--entry-font-scale, 1));
}

.si-entry .icon-btn,
.si-entry .icon-btn-compact,
.si-entry .si-log-toggle {
  font-size: calc(13px * var(--entry-font-scale, 1)) !important;
  padding: calc(6px * var(--entry-font-scale, 1)) calc(10px * var(--entry-font-scale, 1)) !important;
  min-height: calc(34px * var(--entry-font-scale, 1));
  border-radius: 10px;
}

.si-entry-type {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: calc(13px * var(--entry-font-scale, 1));
  color: var(--ink);
}

.si-entry-type::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--cdc-blue);
  flex: none;
}

.tag,
.si-tag-select {
  border-radius: 999px;
  padding: calc(5px * var(--entry-font-scale, 1)) calc(12px * var(--entry-font-scale, 1));
  font-size: calc(12px * var(--entry-font-scale, 1));
  font-weight: 700;
}

.page-head h1 {
  font-size: 22px;
  letter-spacing: -0.01em;
}

/* ── Bottom nav (mobile) ── */
.bottom-nav {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 55;
  background: #fff;
  border-top: 1px solid var(--line);
  box-shadow: 0 -4px 16px rgba(0, 40, 80, 0.08);
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom, 0px));
  justify-content: space-around;
  align-items: stretch;
  gap: 2px;
}

.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-width: 0;
  padding: 6px 4px;
  border-radius: 12px;
  color: var(--ink-soft);
  font-size: 10px;
  font-weight: 700;
  text-decoration: none;
  border: none;
  background: transparent;
  font-family: inherit;
  cursor: pointer;
}

.bottom-nav-item:hover {
  background: #f4f7fb;
  color: var(--cdc-blue);
}

.bottom-nav-item.active {
  color: var(--cdc-blue);
  background: #eef5fc;
}

.bottom-nav-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
}

.bottom-nav-icon svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.bottom-nav-label {
  line-height: 1.1;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

@media (max-width: 640px) {
  .has-bottom-nav .topbar-nav-row {
    display: none;
  }

  .has-bottom-nav .page {
    padding-left: 0;
    padding-right: 0;
    padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px));
  }

  .has-bottom-nav .system-title {
    display: none;
  }

  .bottom-nav {
    display: flex;
  }

  .bottom-nav-item {
    padding: 5px 2px;
  }

  .bottom-nav-label {
    font-size: 9px;
  }

  .fire-section-card .field textarea.sched-input {
    width: 100%;
    box-sizing: border-box;
  }

  .login-wrap {
    min-height: calc(100vh - 56px);
    padding: 24px 16px calc(24px + env(safe-area-inset-bottom, 0px));
  }

  .home-section-card {
    max-width: none;
  }

  .si-form-card--create,
  .toilet-inspection-card,
  .defect-form-card,
  .petrol-form-card,
  .cleaning-report-card {
    max-width: none;
    width: 100%;
  }

  .page-head h1 {
    font-size: 20px;
  }
}

@media (min-width: 641px) {
  .bottom-nav {
    display: none !important;
  }
}

/* ── Readable entries & create forms (poor vision) ── */
.si-form-card {
  border: none;
  border-radius: var(--app-radius-md);
  box-shadow: var(--app-shadow-soft);
  padding: calc(20px * var(--entry-font-scale, 1)) calc(18px * var(--entry-font-scale, 1));
}

.si-form-card--create {
  max-width: 640px;
}

.si-form-card .si-form-grid .field label,
.si-form-card .field label {
  font-size: calc(14px * var(--entry-font-scale, 1));
  font-weight: 700;
  color: var(--ink);
  margin-bottom: calc(4px * var(--entry-font-scale, 1));
}

.si-form-card .si-form-grid .field input,
.si-form-card .si-form-grid .field select,
.si-form-card .si-form-grid .field textarea,
.si-form-card .field input,
.si-form-card .field select,
.si-form-card .field textarea {
  font-size: calc(15px * var(--entry-font-scale, 1));
  padding: calc(10px * var(--entry-font-scale, 1)) calc(12px * var(--entry-font-scale, 1));
  line-height: 1.45;
  border-radius: 12px;
}

.si-form-card .si-form-grid .field textarea,
.si-form-card .field textarea {
  min-height: calc(88px * var(--entry-font-scale, 1));
}

.si-form-card .si-form-stacked .field {
  margin-bottom: calc(10px * var(--entry-font-scale, 1));
}

.si-form-card .si-preset-badge {
  font-size: calc(14px * var(--entry-font-scale, 1));
  padding: calc(6px * var(--entry-font-scale, 1)) calc(12px * var(--entry-font-scale, 1));
  margin-bottom: calc(12px * var(--entry-font-scale, 1));
  border-radius: 10px;
}

.si-form-card .help,
.si-form-card .si-form-meta {
  font-size: calc(13px * var(--entry-font-scale, 1));
  line-height: 1.45;
}

.si-form-card .si-form-actions .btn {
  min-height: calc(42px * var(--entry-font-scale, 1));
  padding: calc(10px * var(--entry-font-scale, 1)) calc(16px * var(--entry-font-scale, 1));
  font-size: calc(14px * var(--entry-font-scale, 1));
}

.si-form-card .si-photo-actions .btn {
  min-height: calc(40px * var(--entry-font-scale, 1));
  font-size: calc(13px * var(--entry-font-scale, 1));
}

.list-toolbar-title {
  font-size: calc(15px * var(--entry-font-scale, 1));
  font-weight: 700;
  text-transform: none;
  letter-spacing: 0;
}

.si-control-label {
  font-size: calc(13px * var(--entry-font-scale, 1));
  font-weight: 700;
  color: var(--ink);
  gap: calc(5px * var(--entry-font-scale, 1));
}

.si-control-label .sched-input,
.si-control-label select {
  font-size: calc(14px * var(--entry-font-scale, 1));
  padding: calc(8px * var(--entry-font-scale, 1)) calc(10px * var(--entry-font-scale, 1));
  min-height: calc(38px * var(--entry-font-scale, 1));
}

/* List/filter toolbars: same pill height for selects, dates, and category toggles */
.si-controls .si-control-label .sched-input:not(textarea),
.si-controls .si-control-label select,
.si-controls .si-control-label .si-category-dropdown-toggle {
  padding: calc(8px * var(--entry-font-scale, 1)) calc(12px * var(--entry-font-scale, 1));
  min-height: calc(38px * var(--entry-font-scale, 1));
  border-radius: 999px;
  box-sizing: border-box;
}

.si-controls .si-control-label .si-category-dropdown {
  display: block;
  width: 100%;
}

.si-controls .si-control-label .si-category-dropdown-toggle {
  width: 100%;
  min-width: 11rem;
  font-size: calc(14px * var(--entry-font-scale, 1));
}

.si-controls > .btn,
.si-controls .petrol-filter-btn,
.si-controls .petrol-export-links .btn {
  border-radius: 999px;
  min-height: calc(38px * var(--entry-font-scale, 1));
  box-sizing: border-box;
}

.si-controls .view-toggle {
  border-radius: 999px;
  align-self: flex-end;
}

.si-controls .view-toggle-btn {
  border-radius: 999px;
}

.si-entry .si-log {
  margin-top: 0;
  padding: calc(8px * var(--entry-font-scale, 1)) calc(12px * var(--entry-font-scale, 1)) calc(10px * var(--entry-font-scale, 1));
  border-radius: 0;
  border-top: none;
  background: var(--expand-band);
}

.si-entry .toilet-check-summary,
.si-entry .fire-check-summary {
  background: var(--expand-band);
}

.si-entry .si-log-title {
  font-size: calc(12px * var(--entry-font-scale, 1));
}

.si-entry .si-log-entry {
  font-size: calc(14px * var(--entry-font-scale, 1));
  line-height: 1.5;
}

.si-entry .si-log-ts {
  font-size: calc(12px * var(--entry-font-scale, 1));
}

.si-entry .si-log-note {
  color: var(--ink);
}

.empty-state {
  font-size: calc(15px * var(--entry-font-scale, 1));
  line-height: 1.5;
  padding: calc(40px * var(--entry-font-scale, 1)) calc(24px * var(--entry-font-scale, 1));
}

/* Parking sweep: photo + extracted plates as one row */
.parking-photo-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.parking-photo-row {
  display: grid;
  grid-template-columns: 2.6rem 120px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  padding: 12px;
  background: #fff;
  border: 2px solid #93BCE0;
  border-radius: 12px;
}

.parking-photo-row:nth-child(even) {
  background: #F4F9FF;
  border-color: #6FA3D4;
}

.parking-photo-sn {
  font-size: 13px;
  font-weight: 800;
  color: #005A9E;
  line-height: 1.2;
  padding-top: 2px;
  white-space: nowrap;
}

.parking-photo-thumb img {
  width: 108px;
  height: 108px;
  object-fit: cover;
  border-radius: 8px;
  display: block;
  border: 1.5px solid #B8D6F0;
}

.parking-list-wrap {
  margin-bottom: 8px;
}

.si-table.si-table-compact.parking-list-table {
  width: max-content;
  min-width: 0;
  max-width: none;
  table-layout: auto;
}

.parking-list-table .parking-col-sweep {
  width: 3.25rem;
  white-space: nowrap;
}

.parking-list-table .parking-col-when {
  width: 5.5rem;
  white-space: nowrap;
}

.parking-list-table .parking-col-loc {
  width: 8.5rem;
  max-width: 8.5rem;
}

.parking-list-table .parking-col-count,
.parking-list-table .parking-col-denied {
  width: 4.25rem;
  white-space: nowrap;
  text-align: right;
}

.parking-list-table .parking-col-status {
  width: 5rem;
  white-space: nowrap;
}

.parking-list-table th.parking-col-count,
.parking-list-table th.parking-col-denied {
  text-align: right;
}

.parking-ai-batch-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.parking-ai-batch-row label {
  font-size: 13px;
  font-weight: 700;
  color: #334155;
}

.parking-ai-batch-row select {
  width: auto;
  min-width: 4.5rem;
}

.parking-photo-extract {
  margin-top: 6px;
}

.parking-photo-delete {
  margin-top: 6px;
}

.parking-photo-add {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 2px;
}

.parking-photo-add-label {
  font-size: 12px;
  font-weight: 700;
  color: #334155;
  white-space: nowrap;
}

.parking-photo-add .parking-plate-input {
  flex: 1 1 10rem;
  max-width: 14rem;
  margin: 0;
}

.parking-photo-plates {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  overflow-x: auto;
}

.parking-plates-table {
  width: 100%;
  min-width: 44rem;
  table-layout: auto;
}

.parking-plates-table th,
.parking-plates-table td {
  padding: 6px 8px;
  vertical-align: middle;
}

.parking-plates-table .parking-note-cell,
.si-table .parking-note-cell {
  min-width: 10rem;
  max-width: 18rem;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
  line-height: 1.35;
  vertical-align: top;
}

.parking-plate-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 10px;
  border: 1px solid #d7e3f0;
  border-radius: 8px;
  background: #f8fbff;
}

.parking-plate-input {
  width: 100%;
  max-width: 16rem;
  font-size: 16px; /* avoid iOS zoom */
  font-weight: 700;
  letter-spacing: 0.02em;
  pointer-events: auto;
}

.parking-plate-input:not([readonly]) {
  background: #fff;
  border-color: #94a3b8;
  cursor: text;
}

.parking-plate-input[readonly] {
  cursor: default;
  opacity: 0.85;
}

.parking-plate-status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.parking-plate-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.parking-pill {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
}

.parking-pill--ok {
  color: #15803d;
  background: #dcfce7;
}

.parking-pill--bad {
  color: #c2410c;
  background: #ffedd5;
}

.parking-list-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 800;
  line-height: 1;
}

.parking-list-mark--yes {
  color: #15803d;
  background: #dcfce7;
}

.parking-list-mark--no {
  color: #b91c1c;
  background: #fee2e2;
}

.parking-plate-empty {
  padding: 8px 0;
}

.parking-discard {
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.parking-manual-row {
  display: grid;
  gap: 10px;
}

/* Phone: keep photo | plates as one row (scroll plates if needed) */
@media (max-width: 640px) {
  .parking-list-table.si-table-compact th,
  .parking-list-table.si-table-compact td {
    padding: 6px 4px;
  }

  .parking-list-table .parking-col-loc {
    width: 6.5rem;
    max-width: 6.5rem;
  }

  .parking-photo-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
  }

  .parking-photo-row {
    grid-template-columns: 2.2rem 84px minmax(0, 1fr);
    gap: 8px;
    padding: 8px;
    margin: 0;
  }

  .parking-photo-thumb img {
    width: 76px;
    height: 76px;
  }

  .parking-plates-table {
    min-width: 28rem;
  }

  .parking-photo-add {
    gap: 6px;
  }

  .parking-photo-add-label {
    font-size: 11px;
  }

  .parking-plate-card {
    padding: 6px;
    gap: 4px;
  }

  .parking-plate-card .si-control-label,
  .parking-plate-card--add .si-control-label {
    font-size: 11px;
  }

  .parking-plate-input {
    max-width: none;
    font-size: 16px;
    padding: 6px 8px;
  }

  .parking-photo-add .parking-plate-input {
    max-width: none;
    flex: 1 1 auto;
  }

  .parking-pill {
    font-size: 10px;
    padding: 1px 6px;
  }

  .parking-plate-status .help {
    display: none;
  }

  .parking-plate-actions .btn.small,
  .parking-photo-plates .btn.small {
    font-size: 11px;
    padding: 4px 6px;
  }

  .parking-discard {
    font-size: 11px;
  }

  .parking-plate-empty {
    font-size: 11px;
    padding: 4px 0;
  }
}

@media (min-width: 641px) {
  .parking-photo-row {
    grid-template-columns: 2.8rem 140px minmax(0, 1fr);
  }

  .parking-photo-thumb img {
    width: 128px;
    height: 128px;
  }

  .parking-manual-row {
    grid-template-columns: minmax(10rem, 14rem) minmax(12rem, 18rem);
    align-items: end;
  }
}
