/* Gesner Wind Farm Ops — mobile-first, app-like (not spreadsheet) */
:root {
  --bg: #0b1220;
  --bg-elev: #121a2b;
  --card: #162033;
  --card-hover: #1c2940;
  --border: rgba(148, 163, 184, 0.18);
  --text: #e8eef9;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --accent-2: #818cf8;
  --online: #22c55e;
  --offline: #ef4444;
  --danger: #f87171;
  --ok: #4ade80;
  --radius: 16px;
  --tap: 48px;
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
  --font: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}

body {
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(56, 189, 248, 0.12), transparent 55%),
    radial-gradient(900px 500px at 90% 0%, rgba(129, 140, 248, 0.1), transparent 50%),
    var(--bg);
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

a {
  color: var(--accent);
}

.app-shell {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  padding: 12px 14px 32px;
  padding-bottom: calc(32px + env(safe-area-inset-bottom, 0px));
}

/* Header */
.app-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 4px 16px;
}

.app-header .brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: #000;
  display: grid;
  place-items: center;
  box-shadow: var(--shadow);
  flex-shrink: 0;
  overflow: hidden;
  padding: 0;
}

.app-header .brand-mark svg {
  width: 26px;
  height: 26px;
  fill: #0b1220;
}

.app-header h1 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.app-header .subtitle {
  margin: 2px 0 0;
  font-size: 0.78rem;
  color: var(--muted);
}

.back-btn {
  min-width: var(--tap);
  min-height: var(--tap);
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: 14px;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0 14px;
  gap: 6px;
}

.back-btn:active {
  transform: scale(0.97);
}

/* Panels / routing */
.panel {
  display: none;
  animation: fadeIn 0.22s ease;
}

.panel.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

/* Date chip — HOME ONLY */
.date-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 14px;
}

.date-chip .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(56, 189, 248, 0.15);
}

/* Weather card */
.weather-card {
  background: linear-gradient(145deg, #1a2740, #132036);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}

.weather-card .wx-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.weather-card .wx-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 4px;
}

.weather-card .wx-temp {
  font-size: 2.4rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1;
}

.weather-card .wx-desc {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.95rem;
}

.weather-card .wx-metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}

.metric {
  background: rgba(255, 255, 255, 0.04);
  border-radius: 12px;
  padding: 10px 12px;
}

.metric .k {
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.metric .v {
  font-size: 1.05rem;
  font-weight: 650;
  margin-top: 2px;
}

.wx-fallback {
  color: var(--muted);
  font-size: 0.9rem;
}

/* Status grid */
.section-title {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  margin: 8px 4px 10px;
  font-weight: 600;
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 18px;
}

.status-tile {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: var(--radius);
  min-height: 108px;
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  color: var(--text);
  box-shadow: var(--shadow);
  transition: background 0.15s, transform 0.1s;
}

.status-tile:active {
  transform: scale(0.97);
  background: var(--card-hover);
}

.status-tile .icon-wrap {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  position: relative;
}

.status-tile.online .icon-wrap {
  background: rgba(34, 197, 94, 0.15);
  color: var(--online);
}

.status-tile.offline .icon-wrap {
  background: rgba(239, 68, 68, 0.18);
  color: var(--offline);
}

.status-tile .icon-wrap svg {
  width: 30px;
  height: 30px;
  fill: currentColor;
}

.status-tile .name {
  font-size: 0.82rem;
  font-weight: 650;
  text-align: center;
}

.status-tile .badge {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 3px 8px;
  border-radius: 999px;
}

.status-tile.online .badge {
  background: rgba(34, 197, 94, 0.2);
  color: var(--online);
}

.status-tile.offline .badge {
  background: rgba(239, 68, 68, 0.22);
  color: var(--offline);
}

/* Action buttons */
.action-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.action-btn {
  min-height: var(--tap);
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  text-align: left;
  color: var(--text);
  box-shadow: var(--shadow);
}

.action-btn:active {
  background: var(--card-hover);
  transform: scale(0.99);
}

.action-btn .ab-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: rgba(56, 189, 248, 0.12);
  color: var(--accent);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.action-btn .ab-icon svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

.action-btn .ab-text {
  flex: 1;
}

.action-btn .ab-title {
  font-weight: 650;
  font-size: 0.98rem;
}

.action-btn .ab-sub {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 2px;
}

.action-btn .chev {
  color: var(--muted);
  font-size: 1.2rem;
}

.action-btn.primary {
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.22), rgba(129, 140, 248, 0.18));
  border-color: rgba(56, 189, 248, 0.35);
}

/* Sheet / menu overlay */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 40;
  display: none;
  align-items: flex-end;
  justify-content: center;
  padding: 16px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
}

.sheet-backdrop.open {
  display: flex;
}

.sheet {
  width: 100%;
  max-width: 480px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 20px 20px 16px 16px;
  padding: 10px 12px 16px;
  box-shadow: var(--shadow);
  animation: sheetUp 0.22s ease;
}

@keyframes sheetUp {
  from { transform: translateY(24px); opacity: 0; }
  to { transform: none; opacity: 1; }
}

.sheet .handle {
  width: 40px;
  height: 4px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.35);
  margin: 4px auto 12px;
}

.sheet h3 {
  margin: 0 8px 12px;
  font-size: 1rem;
}

.sheet-item {
  width: 100%;
  min-height: var(--tap);
  border: none;
  background: transparent;
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  color: var(--text);
  text-align: left;
}

.sheet-item:active {
  background: var(--card);
}

.sheet-item .si-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: rgba(56, 189, 248, 0.12);
  color: var(--accent);
  display: grid;
  place-items: center;
  font-weight: 700;
}

.sheet-cancel {
  margin-top: 6px;
  width: 100%;
  min-height: var(--tap);
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--muted);
  font-weight: 600;
  cursor: pointer;
}

/* Forms */
.page-title {
  margin: 4px 0 14px;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.form-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}

.field {
  margin-bottom: 14px;
}

.field:last-child {
  margin-bottom: 0;
}

.field label {
  display: block;
  font-size: 0.78rem;
  font-weight: 650;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}

.field .hint {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 4px;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: var(--tap);
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg);
  padding: 10px 12px;
  outline: none;
}

.field textarea {
  min-height: 96px;
  resize: vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: rgba(56, 189, 248, 0.55);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.15);
}

.field input[readonly] {
  opacity: 0.85;
}

.field.hidden,
.om-hide.hidden {
  display: none !important;
}

.type-meanings {
  display: grid;
  gap: 6px;
  margin-top: 8px;
}

.type-meanings span {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
}

.guide-box {
  background: rgba(56, 189, 248, 0.08);
  border: 1px solid rgba(56, 189, 248, 0.2);
  border-radius: 12px;
  padding: 12px;
  font-size: 0.9rem;
  line-height: 1.45;
  color: var(--text);
  white-space: pre-wrap;
}

.guide-box.empty {
  color: var(--muted);
}

.guide-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  min-height: 40px;
  padding: 8px 12px;
  border-radius: 10px;
  background: rgba(56, 189, 248, 0.15);
  color: var(--accent);
  text-decoration: none;
  font-weight: 650;
  font-size: 0.9rem;
}

.guide-link.hidden {
  display: none;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.segmented label {
  text-transform: none;
  letter-spacing: 0;
  font-size: 0.85rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  min-height: var(--tap);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  cursor: pointer;
  font-weight: 600;
}

.segmented input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented label:has(input:checked) {
  border-color: rgba(56, 189, 248, 0.55);
  background: rgba(56, 189, 248, 0.15);
  color: var(--accent);
}

.btn-row {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}

.btn {
  flex: 1;
  min-height: var(--tap);
  border-radius: 14px;
  border: 1px solid var(--border);
  font-weight: 700;
  cursor: pointer;
  padding: 12px;
}

.btn-primary {
  background: linear-gradient(135deg, #38bdf8, #6366f1);
  border: none;
  color: #0b1220;
}

.btn-secondary {
  background: var(--card);
  color: var(--text);
}

.btn:active {
  transform: scale(0.98);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%) translateY(20px);
  background: #0f172a;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 18px;
  border-radius: 999px;
  font-weight: 650;
  font-size: 0.9rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 60;
  box-shadow: var(--shadow);
  max-width: calc(100% - 32px);
  text-align: center;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast.ok {
  border-color: rgba(34, 197, 94, 0.4);
}

.toast.err {
  border-color: rgba(239, 68, 68, 0.45);
}

/* Lists / stubs */
.log-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.log-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  text-align: left;
  color: var(--text);
  cursor: pointer;
  box-shadow: var(--shadow);
}

.log-card:active {
  background: var(--card-hover);
}

.log-card .lc-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.log-card .lc-entry {
  font-weight: 700;
  color: var(--accent);
}

.log-card .lc-meta {
  font-size: 0.85rem;
  color: var(--muted);
}

.log-card .lc-title {
  font-weight: 650;
  margin: 4px 0;
}

.stub-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.stub-list li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 4px;
  border-bottom: 1px solid var(--border);
  font-size: 0.95rem;
}

.stub-list li:last-child {
  border-bottom: none;
}

.stub-list input[type="checkbox"] {
  width: 22px;
  height: 22px;
  margin-top: 1px;
  accent-color: var(--accent);
}

.empty-state {
  text-align: center;
  color: var(--muted);
  padding: 28px 12px;
  background: var(--card);
  border-radius: var(--radius);
  border: 1px dashed var(--border);
}

.detail-grid {
  display: grid;
  gap: 10px;
}

.detail-row {
  background: var(--bg);
  border-radius: 12px;
  padding: 10px 12px;
}

.detail-row .dk {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.detail-row .dv {
  margin-top: 2px;
  font-weight: 600;
  white-space: pre-wrap;
}

@media (min-width: 520px) {
  .app-shell {
    padding-top: 20px;
  }
}

/* --- Phase 2: inventory, bell, checklists, downtime --- */
.header-grow {
  flex: 1;
  min-width: 0;
}

.bell-btn {
  position: relative;
  width: var(--tap);
  height: var(--tap);
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--muted);
  display: grid;
  place-items: center;
  cursor: pointer;
  flex-shrink: 0;
  padding: 0;
}

.bell-btn svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

.bell-btn.has-alert {
  color: #fbbf24;
  border-color: rgba(251, 191, 36, 0.45);
  background: rgba(251, 191, 36, 0.12);
}

.bell-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--offline);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 800;
  display: grid;
  place-items: center;
  line-height: 1;
}

.bell-badge.hidden {
  display: none;
}

.rule-note,
.sync-note {
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.4;
  margin: 0 4px 14px;
  padding: 10px 12px;
  background: rgba(56, 189, 248, 0.06);
  border: 1px solid rgba(56, 189, 248, 0.15);
  border-radius: 12px;
}

.check-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.check-list li {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 4px;
  border-bottom: 1px solid var(--border);
  font-size: 0.95rem;
}

.check-list li:last-child {
  border-bottom: none;
}

.check-list input[type="checkbox"] {
  width: 24px;
  height: 24px;
  margin-top: 1px;
  flex-shrink: 0;
  accent-color: var(--accent);
}

.check-list label {
  flex: 1;
  line-height: 1.35;
  cursor: pointer;
}

.check-list input:checked + label {
  color: var(--muted);
  text-decoration: line-through;
}

.sheet-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
}

.sheet-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  min-width: 360px;
}

.sheet-table th,
.sheet-table td {
  padding: 10px 8px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.sheet-table th {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  background: rgba(0, 0, 0, 0.25);
  position: sticky;
  top: 0;
  white-space: nowrap;
}

.sheet-table td.num,
.sheet-table th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.sheet-table tr.row-zero td {
  color: #fca5a5;
}

.sheet-table tr.row-zero td:nth-child(3) {
  font-weight: 800;
  color: var(--offline);
}

.empty-cell {
  text-align: center;
  color: var(--muted);
  padding: 20px !important;
}

.tracker-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.tracker-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
}

.tracker-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}

.tracker-grid .k {
  display: block;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.tracker-grid .v {
  font-weight: 600;
  font-size: 0.88rem;
  word-break: break-word;
}

.pill {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.2);
  color: var(--muted);
}

.pill.ok {
  background: rgba(34, 197, 94, 0.2);
  color: var(--online);
}

.pill.warn {
  background: rgba(251, 191, 36, 0.2);
  color: #fbbf24;
}

.row-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.btn-sm {
  flex: 1;
  min-height: 40px;
  font-size: 0.85rem;
  padding: 8px;
}

.btn-danger {
  background: rgba(239, 68, 68, 0.18);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #fca5a5;
  font-weight: 700;
  border-radius: 14px;
  cursor: pointer;
}

.btn-danger:active {
  transform: scale(0.98);
}

.confirm-msg {
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.4;
  margin: 0 8px 16px;
}

.quote-total {
  margin: 12px 4px;
  font-size: 1rem;
}

.history-group {
  margin-bottom: 8px;
}

.history-group .log-card {
  margin-bottom: 8px;
}

#inv-view-search {
  width: 100%;
  min-height: var(--tap);
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--card);
  padding: 10px 12px;
  outline: none;
}

#inv-view-search:focus {
  border-color: rgba(56, 189, 248, 0.55);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.15);
}

.hidden {
  display: none !important;
}

.action-btn.sync .ab-icon {
  background: rgba(56, 189, 248, 0.14);
  color: #7dd3fc;
}
.action-btn.sync:disabled {
  opacity: 0.55;
  pointer-events: none;
}


/* Inventory 100% confirmation card */
.inv-confirm-card {
  margin: 0 0 14px;
}
.inv-confirm-title {
  margin: 0 0 8px;
  font-weight: 650;
  font-size: 0.95rem;
}
.inv-confirm-card .rule-note {
  margin: 0 0 12px;
}

/* Anchor styled as button (e.g. Open PDF on Drive) */
a.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  text-align: center;
  box-sizing: border-box;
}


/* --- Attach / photo previews (work-log form) --- */
.form-card-title {
  font-size: 1rem;
  font-weight: 700;
  margin: 0 0 12px;
  letter-spacing: -0.01em;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.photo-preview-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 10px;
}

.photo-thumb {
  position: relative;
  width: 96px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg);
}

.photo-thumb img {
  display: block;
  width: 96px;
  height: 96px;
  object-fit: cover;
}

.photo-thumb .photo-remove {
  display: block;
  width: 100%;
  border: 0;
  border-top: 1px solid var(--border);
  background: var(--card);
  color: var(--danger, #b42318);
  font-size: 0.72rem;
  font-weight: 650;
  padding: 6px 4px;
  cursor: pointer;
}

.photo-detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}

.photo-detail-item {
  display: block;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg);
}

.photo-detail-item img {
  display: block;
  width: 100%;
  height: 160px;
  object-fit: cover;
}


/* --- Work log list: keep Date / headers inside viewport on phone --- */
.app-shell {
  overflow-x: hidden;
  width: 100%;
}

.log-list,
#log-list,
#edit-pick-list,
#history-list {
  max-width: 100%;
  overflow-x: hidden;
  box-sizing: border-box;
}

.log-card {
  max-width: 100%;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.log-card .lc-top {
  flex-wrap: wrap;
  align-items: baseline;
  min-width: 0;
}

.log-card .lc-meta {
  min-width: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
  word-break: break-word;
  white-space: normal;
}

.log-card .lc-title {
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* Multi-part rows on work log form */
.parts-rows {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.part-row {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px;
}

.part-row-fields {
  display: grid;
  grid-template-columns: 1fr minmax(64px, 88px) auto;
  gap: 8px;
  align-items: center;
}

.part-row-fields select,
.part-row-fields input {
  width: 100%;
  min-width: 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 10px;
}

.part-row-remove {
  white-space: nowrap;
  padding: 10px 12px;
  min-height: var(--tap);
}

@media (max-width: 420px) {
  .part-row-fields {
    grid-template-columns: 1fr 1fr;
  }
  .part-row-remove {
    grid-column: 1 / -1;
  }
}


/* Weather wind/gust line */
.weather-card .wx-wind {
  margin-top: 10px;
  font-size: 1.05rem;
  font-weight: 650;
  color: var(--accent);
  line-height: 1.35;
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* Work log list: Lines vs Cards toggle */
.log-view-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
  max-width: 100%;
}

.log-view-btn {
  min-height: var(--tap);
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  padding: 10px 12px;
}

.log-view-btn.is-active {
  border-color: rgba(56, 189, 248, 0.55);
  background: rgba(56, 189, 248, 0.15);
  color: var(--accent);
}

.log-list--lines {
  gap: 8px;
}

.log-card--line {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 14px;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  overflow: hidden;
}

.log-card--line .ll-row {
  display: grid;
  grid-template-columns: 4.2rem minmax(0, 1fr);
  gap: 8px;
  align-items: start;
  min-width: 0;
}

.log-card--line .ll-k {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  padding-top: 2px;
}

.log-card--line .ll-v {
  font-size: 0.95rem;
  font-weight: 600;
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
  white-space: normal;
}

.log-list,
#log-list,
#edit-pick-list,
#history-list {
  overflow-x: hidden;
}


/* --- Form end: date / turbine status stay inside phone width --- */
#form-end-card,
#work-log-form,
.form-actions {
  max-width: 100%;
  box-sizing: border-box;
}
#field-date-wrap input[type="date"],
#field-date {
  max-width: 100%;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  -webkit-appearance: none;
  appearance: none;
}
.form-actions {
  display: flex;
  gap: 10px;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
}
.form-actions .btn {
  flex: 1 1 0;
  min-width: 0;
}

/* Sharper turbine marks on home tiles */
.status-tile .icon-wrap {
  width: 52px;
  height: 52px;
}
.status-tile .icon-wrap svg {
  width: 34px;
  height: 34px;
  overflow: visible;
}

/* Work procedure steps */
.procedure-steps {
  margin: 14px 0 0;
  padding-left: 1.25rem;
  display: grid;
  gap: 10px;
  color: var(--text);
  font-size: 0.92rem;
  line-height: 1.45;
}
.procedure-steps li::marker {
  font-weight: 700;
  color: var(--accent);
}


/* ---- Work Procedures browser ---- */
.proc-toolbar {
  padding: 0 14px 8px;
}
.proc-search {
  width: 100%;
  box-sizing: border-box;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: rgba(15, 23, 42, 0.85);
  color: #e2e8f0;
  padding: 12px 14px;
  font-size: 16px;
}
.proc-search:focus {
  outline: 2px solid #38bdf8;
  outline-offset: 1px;
}
.proc-attach-results {
  margin-top: 8px;
  max-height: 220px;
  overflow: auto;
  border-radius: 12px;
  border: 1px solid transparent;
}
.proc-attach-results:not(:empty) {
  border-color: rgba(148, 163, 184, 0.25);
  background: rgba(15, 23, 42, 0.55);
}
.proc-attach-item {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  color: #e2e8f0;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.12);
  font-size: 14px;
}
.proc-attach-item:last-child { border-bottom: 0; }
.proc-attach-item:active, .proc-attach-item:focus {
  background: rgba(56, 189, 248, 0.12);
}
.proc-attach-item .pai-mod {
  display: block;
  font-size: 11px;
  color: #94a3b8;
  margin-bottom: 2px;
}
.proc-attach-picked {
  margin-top: 8px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(34, 197, 94, 0.12);
  border: 1px solid rgba(34, 197, 94, 0.35);
  font-size: 14px;
  color: #bbf7d0;
}
.proc-attach-picked button {
  margin-top: 6px;
  font-size: 13px;
}

/* Troubleshooting guide peek panel (over work log; expand optional) */
.guide-link {
  display: inline-block;
  margin-top: 8px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent, #2f6fed);
  font: inherit;
  font-weight: 600;
  text-decoration: underline;
  cursor: pointer;
  text-align: left;
}
.guide-peek-backdrop {
  /* Keep form visible behind a light dim; panel sits at bottom */
  background: rgba(0, 0, 0, 0.35);
  align-items: flex-end;
  padding-top: 12px;
}
.guide-modal-sheet {
  max-height: min(78vh, 640px);
  display: flex;
  flex-direction: column;
}
.guide-modal-sheet.guide-peek {
  /* Compact floating peek — quick read without leaving the form */
  max-height: min(46vh, 380px);
  height: min(46vh, 380px);
}
.guide-modal-sheet.guide-peek.guide-expanded {
  max-height: min(92vh, 820px);
  height: min(92vh, 820px);
}
.guide-modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  flex: 0 0 auto;
}
.guide-modal-header h3 {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.3;
  flex: 1;
  min-width: 0;
}
.guide-modal-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}
.guide-modal-header .btn,
.guide-size-btn,
.guide-close-btn {
  flex: 0 0 auto;
  padding: 6px 10px;
  font-size: 0.8rem;
  min-height: 36px;
}
.guide-close-btn {
  font-size: 1.05rem;
  line-height: 1;
  padding: 6px 12px;
  font-weight: 700;
}
.guide-modal-body {
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  flex: 1;
  min-height: 0;
  margin-bottom: 8px;
}
.guide-modal-summary {
  margin: 0 0 10px;
  font-size: 0.92rem;
  line-height: 1.4;
  color: var(--muted, #5b6472);
}
.guide-modal-steps {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: inherit;
  font-size: 0.9rem;
  line-height: 1.45;
  background: var(--card-2, #f4f6f8);
  border-radius: 10px;
  padding: 12px;
}
.guide-iframe-wrap {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 160px;
  border-radius: 10px;
  overflow: hidden;
  background: #0b1220;
  border: 1px solid rgba(255,255,255,0.08);
}
.guide-modal-sheet.guide-peek .guide-iframe-wrap {
  height: min(28vh, 220px);
}
.guide-modal-sheet.guide-peek.guide-expanded .guide-iframe-wrap {
  height: min(68vh, 560px);
}
.guide-iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: #fff;
}
.guide-modal-more {
  flex: 0 0 auto;
  margin-top: 2px;
  font-size: 0.85rem;
  color: var(--muted, #5b6472);
}
.guide-modal-more summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--muted, #5b6472);
  list-style: none;
  padding: 4px 0;
}
.guide-modal-more summary::-webkit-details-marker { display: none; }
.guide-modal-more[open] summary { margin-bottom: 4px; }
#guide-modal-full {
  margin-top: 2px;
  font-size: 0.85rem;
  font-weight: 500;
}
@media (min-width: 640px) {
  .guide-peek-backdrop {
    align-items: flex-end;
    justify-content: flex-end;
    padding-right: 20px;
  }
  .guide-modal-sheet.guide-peek {
    max-width: 420px;
    margin-left: auto;
  }
}


/* Shared sync status banner */
.sync-banner {
  margin: 0 12px 8px;
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 0.8rem;
  font-weight: 600;
  text-align: center;
}
.sync-banner.ok {
  background: #e8f7ee;
  color: #0f6b3a;
  border: 1px solid #b7e0c5;
}
.sync-banner.warn {
  background: #fff7e6;
  color: #8a5a00;
  border: 1px solid #f0d59a;
}
.sync-banner.err {
  background: #fdecea;
  color: #8a1f11;
  border: 1px solid #f0b6ae;
}
.sync-banner.hidden { display: none; }


/* Procedure viewer iframe (in-app OEM PDF preview) */
.proc-modal-sheet {
  max-height: min(88vh, 760px);
}
.proc-iframe-wrap {
  position: relative;
  width: 100%;
  height: min(58vh, 480px);
  border-radius: 10px;
  overflow: hidden;
  background: #0b1220;
  border: 1px solid rgba(255,255,255,0.08);
}
.proc-iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: #fff;
}
#proc-modal-full {
  margin-top: 4px;
  font-size: 0.85rem;
  font-weight: 500;
}

/* ===== Site Orientation viewer (video) ===== */
.orient-viewer {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-bottom: 28px;
}
.orient-video-wrap {
  width: 100%;
  background: #0b1220;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 4px);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.orient-video {
  display: block;
  width: 100%;
  height: auto;
  max-height: min(70vh, 720px);
  background: #000;
  vertical-align: top;
}
.orient-foot {
  text-align: center;
  margin: 0 4px;
}
.visitor-card .lc-meta {
  margin-top: 4px;
}
#panel-orientation .app-header .btn {
  min-height: 40px;
  padding: 0 12px;
  font-size: 0.9rem;
}

/* ===== Site Map (compact card + zoom overlay) ===== */
.site-map-card {
  appearance: none;
  width: 100%;
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: var(--radius);
  padding: 8px 12px 8px 8px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  text-align: left;
  color: var(--text);
  box-shadow: var(--shadow);
  margin: 0 0 14px;
  min-height: 0;
}
.site-map-card:active {
  background: var(--card-hover);
  transform: scale(0.99);
}
.site-map-card-inline {
  margin: 0 0 12px;
}
.site-map-thumb {
  width: auto;
  height: 112px;
  max-width: 168px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--border);
  flex-shrink: 0;
  background: #111827;
  display: block;
}
.site-map-card-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.site-map-card-title {
  font-weight: 650;
  font-size: 0.98rem;
}
.site-map-card-sub {
  font-size: 0.76rem;
  color: var(--muted);
  line-height: 1.3;
}
.site-map-card .chev {
  color: var(--muted);
  font-size: 1.2rem;
  flex-shrink: 0;
}

.site-map-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: none;
  flex-direction: column;
  background: #050a14;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.site-map-overlay.open {
  display: flex;
}
.site-map-overlay-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  background: rgba(11, 18, 32, 0.96);
  flex: 0 0 auto;
}
.site-map-overlay-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 650;
}
.site-map-close {
  appearance: none;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
}
.site-map-close:active {
  background: var(--card-hover);
}
.site-map-viewport {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  position: relative;
  touch-action: none;
  background: #0b1220;
  cursor: grab;
}
.site-map-viewport.dragging {
  cursor: grabbing;
}
.site-map-stage {
  position: absolute;
  left: 0;
  top: 0;
  transform-origin: 0 0;
  will-change: transform;
}
.site-map-img {
  display: block;
  width: auto;
  height: auto;
  max-width: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-user-drag: none;
  pointer-events: none;
}
.site-map-hint {
  flex: 0 0 auto;
  margin: 0;
  padding: 8px 12px 10px;
  text-align: center;
  font-size: 0.75rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
  background: rgba(11, 18, 32, 0.96);
}
