/* MMS Field Mobile — paleta LIGHT jak desktop MTapp (theme.py) */
:root {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --surface-alt: #f8fafc;
  --border: #e2e8f0;
  --text: #0f172a;
  --text-muted: #64748b;
  --text-hint: #94a3b8;
  --indigo: #6366f1;
  --cyan: #06b6d4;
  --amber: #f59e0b;
  --green: #22c55e;
  --orange: #f97316;
  --red: #ef4444;
  --blue: #3b82f6;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 4px 14px rgba(15, 23, 42, 0.04);
  --radius: 14px;
  --radius-sm: 8px;
  --input-bg: #f8fafc;
  --cart-accent: #f59e0b;
  --cart-accent-pressed: #d97706;
  --keyboard-inset: 0px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
  min-height: 100dvh;
}

.app {
  max-width: 520px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ── Nagłówek (parytet tytułu okna desktop) ─────────────────────────────── */
.app-header {
  background: linear-gradient(135deg, #eef2ff 0%, #f8fafc 55%, var(--bg) 100%);
  border-bottom: 1px solid var(--border);
  padding: 14px 16px 12px;
  position: sticky;
  top: 0;
  z-index: 20;
}

.app-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.app-logo {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--indigo), #818cf8);
  color: #fff;
  font-weight: 800;
  font-size: 0.72rem;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.35);
  flex-shrink: 0;
}

.app-brand h1 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.app-sub {
  margin: 2px 0 0;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.app-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  padding: 6px 0 4px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--indigo);
  border-bottom: 2px solid var(--indigo);
}

.app-tab-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--red);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2);
}

.app-main {
  flex: 1;
  padding: 12px 14px 28px;
}

/* ── Karty / formularze ─────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.card h2 {
  margin: 0 0 12px;
  font-size: 0.95rem;
  font-weight: 700;
}

.card-login {
  margin-top: 8px;
  padding: 22px 18px 20px;
}

/* Ekran logowania — duże cele dotykowe (rękawice / grube palce) */
.card-login h2 {
  font-size: 1.2rem;
  margin-bottom: 20px;
}

.card-login label {
  font-size: 0.82rem;
  margin-bottom: 8px;
}

.card-login input {
  min-height: 56px;
  padding: 16px 16px;
  font-size: 1.125rem;
  margin-bottom: 20px;
  border-radius: 12px;
  border-width: 2px;
  -webkit-tap-highlight-color: transparent;
}

.card-login input[type="password"] {
  font-size: 1.25rem;
  letter-spacing: 0.06em;
}

.card-login .btn.primary {
  min-height: 58px;
  padding: 18px 20px;
  font-size: 1.125rem;
  font-weight: 700;
  border-radius: 12px;
  margin-top: 4px;
  margin-bottom: 4px;
}

.card-login .hint {
  font-size: 0.88rem;
  margin-top: 18px;
  line-height: 1.45;
}

label {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-hint);
  margin-bottom: 6px;
}

input, textarea {
  width: 100%;
  padding: 11px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  margin-bottom: 12px;
  font-size: 1rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus, textarea:focus {
  outline: none;
  border-color: var(--indigo);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

/* ── Przyciski ──────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  border: none;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: transform 0.1s, opacity 0.15s;
}

.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

/* ── Async action buttons (spinner + label) ─────────────────────────────── */
.btn-action-spinner {
  display: none;
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: btn-action-spin 0.65s linear infinite;
}

.btn-action-label {
  line-height: 1.2;
}

.btn.is-loading {
  pointer-events: none;
  cursor: wait;
}

.btn.is-loading .btn-action-spinner {
  display: block;
}

.btn.is-loading .btn-join-icon {
  display: none;
}

@keyframes btn-action-spin {
  to { transform: rotate(360deg); }
}

.btn.primary {
  background: var(--indigo);
  color: #fff;
  width: 100%;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.28);
}

.btn.secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn.danger {
  background: var(--red);
  color: #fff;
  flex: 1;
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.22);
}

.btn.link {
  background: transparent;
  color: var(--indigo);
  padding: 8px 4px;
  font-weight: 600;
}

.btn.icon-btn {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--indigo);
  font-size: 1.1rem;
}

.row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.actions {
  margin-bottom: 12px;
  gap: 10px;
}

.actions .btn.primary,
.actions .btn.danger {
  flex: 1;
  width: auto;
}

.hidden { display: none !important; }

.muted {
  color: var(--text-muted);
  font-size: 0.82rem;
}

.hint {
  margin: 8px 0 0;
  font-size: 0.78rem;
  color: var(--text-hint);
  line-height: 1.4;
}

/* ── KPI (pasek statystyk jak desktop) ──────────────────────────────────── */
.kpi-strip {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
}

.kpi-card {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.kpi-card--danger {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.12), rgba(239, 68, 68, 0.04));
  border-color: rgba(239, 68, 68, 0.28);
}

.kpi-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  background: rgba(239, 68, 68, 0.14);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.kpi-card--danger .kpi-icon { color: var(--red); }

.kpi-label {
  display: block;
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: var(--text-muted);
}

.kpi-value {
  display: block;
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--red);
  line-height: 1.1;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

#list-status {
  font-size: 0.78rem;
  color: var(--text-hint);
}

/* ── Lista WO — karty jak card_builder.py ─────────────────────────────────── */
#wo-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

#wo-list > li {
  margin-bottom: 10px;
}

.wo-card {
  background: var(--surface);
  border-radius: 14px;
  border: 1px solid rgba(99, 102, 241, 0.12);
  border-left: 5px solid var(--status-color, var(--indigo));
  box-shadow: var(--shadow);
  padding: 10px 12px 9px;
  cursor: pointer;
  transition: box-shadow 0.15s, transform 0.1s;
}

.wo-card:active {
  transform: scale(0.995);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}

.wo-card-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}

.wo-number {
  font-size: 1.05rem;
  font-weight: 900;
  letter-spacing: 0.02em;
  color: var(--text);
  line-height: 1.2;
}

.badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 6px;
  font-size: 0.58rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  border: 1px solid transparent;
  line-height: 1.3;
}

.badge-type {
  color: var(--type-color, var(--red));
  background: color-mix(in srgb, var(--type-color, var(--red)) 14%, transparent);
  border-color: color-mix(in srgb, var(--type-color, var(--red)) 38%, transparent);
}

.badge-status {
  margin-left: auto;
  color: var(--status-color, var(--indigo));
  background: color-mix(in srgb, var(--status-color, var(--indigo)) 14%, transparent);
  border-color: color-mix(in srgb, var(--status-color, var(--indigo)) 40%, transparent);
  border-radius: 20px;
  padding: 3px 9px;
  font-size: 0.58rem;
}

/* Wiersze szeregowe: etykieta | wartość w jednej linii */
.wo-card-body {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.wo-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-height: 0;
}

.wo-row--meta {
  margin-top: 2px;
  padding-top: 4px;
  border-top: 1px solid var(--border);
}

.field-label-inline {
  flex: 0 0 52px;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-hint);
  line-height: 1.2;
}

.wo-row-grow {
  flex: 1;
  min-width: 0;
}

.field-value {
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--text-muted);
  line-height: 1.25;
}

.field-value--machine {
  color: var(--blue);
  font-weight: 700;
}

.wo-desc {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}

/* Stare klasy — szczegóły / fallback */
.field-label {
  display: block;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--text-hint);
  margin-bottom: 3px;
}

.wo-card-foot {
  display: none;
}

.detail-meta-grid {
  margin-top: 8px;
}

.wo-empty {
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 20px 16px;
  color: var(--text-muted);
  font-size: 0.88rem;
  line-height: 1.5;
}

.app-tab.hidden {
  display: none;
}

/* ── Nawigacja szczegółów (powrót — styl mobile app) ─────────────────────── */
.detail-nav {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: -12px -14px 14px;
  padding: 10px 14px 12px;
  position: sticky;
  top: 0;
  z-index: 15;
  background: rgba(241, 245, 249, 0.88);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.detail-back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0 16px 0 10px;
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.06);
  color: var(--indigo);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.12s, box-shadow 0.12s, background 0.12s;
  -webkit-tap-highlight-color: transparent;
}

.detail-back:active {
  transform: scale(0.97);
  background: #eef2ff;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.05);
}

.detail-back-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  margin-left: -2px;
}

.detail-back-label {
  line-height: 1;
  padding-bottom: 1px;
}

.detail-nav-title {
  flex: 1;
  min-width: 0;
  text-align: center;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding-right: 8px;
}

#detail-panel {
  padding-top: 0;
}

/* ── Szczegóły WO ─────────────────────────────────────────────────────────── */
.detail-card {
  border-left: 5px solid var(--status-color, var(--indigo));
}

.detail-ur-report-wrap {
  margin-top: 12px;
}

.detail-ur-report-btn {
  width: 100%;
  min-height: 44px;
  border-radius: 12px;
  font-weight: 800;
  color: #0369a1;
  background: rgba(14, 165, 233, 0.12);
  border: 1px solid rgba(14, 165, 233, 0.35);
}

.detail-ur-report-btn.is-open-report {
  color: #15803d;
  background: rgba(34, 197, 94, 0.14);
  border-color: rgba(34, 197, 94, 0.35);
}

.detail-ur-report-btn.is-loading {
  opacity: 0.75;
}

.detail-event-desc-block {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 4px;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--surface-alt);
  border: 1px solid #e2e8f0;
  border-left: 3px solid var(--amber);
}

.detail-event-desc-block .field-label-inline {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.detail-event-desc-text {
  font-size: 0.88rem;
  line-height: 1.45;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}

.detail-actions-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin: 0 0 8px;
}

/* Sticky pasek START — duży przycisk pod kciuk */
body.detail-open .app-main {
  padding-bottom: 88px;
}

body.module-nav-open .app-main {
  padding-bottom: calc(96px + env(safe-area-inset-bottom, 0px));
}

body.detail-open.module-nav-open .app-main {
  padding-bottom: 88px;
}

body.detail-open.detail-joined .app-main {
  padding-bottom: calc(300px + env(safe-area-inset-bottom, 0px));
}

body.detail-open.detail-joined.module-nav-open .app-main {
  padding-bottom: calc(300px + env(safe-area-inset-bottom, 0px));
}

/* ── Pasek akcji detail (join / stop / complete) ─────────────────────────── */
.detail-action-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: var(--keyboard-inset, 0px);
  z-index: 30;
  max-width: 520px;
  margin: 0 auto;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.72) 0%, rgba(255, 255, 255, 0.96) 28%, #fff 100%);
  backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  border-top: 1px solid rgba(226, 232, 240, 0.9);
  box-shadow: 0 -8px 32px rgba(15, 23, 42, 0.1);
}

body.keyboard-open .detail-action-bar {
  padding-bottom: 12px;
}

.detail-action-join,
.detail-action-close {
  width: 100%;
}

.detail-action-close {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.detail-action-close .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex: 1;
  min-height: 54px;
  padding: 0 14px;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  border-radius: 14px;
  border: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
}

.btn-close-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  opacity: 0.9;
}

.btn-stop {
  color: #fff;
  background: linear-gradient(135deg, #fdba74, #f97316);
  box-shadow: 0 6px 18px rgba(249, 115, 22, 0.28);
}

.btn-stop:active:not(:disabled) {
  transform: scale(0.98);
  filter: brightness(0.97);
}

.btn-stop.is-loading:disabled {
  background: linear-gradient(135deg, #fdba74, #f97316);
  color: #fff;
  opacity: 1;
  cursor: wait;
}

.btn-stop:disabled:not(.is-loading) {
  background: #e2e8f0;
  color: #94a3b8;
  box-shadow: none;
  cursor: not-allowed;
  opacity: 1;
}

.btn-complete {
  color: #fff;
  background: linear-gradient(135deg, #f87171, #dc2626);
  box-shadow: 0 6px 18px rgba(239, 68, 68, 0.28);
}

.btn-complete:active:not(:disabled) {
  transform: scale(0.98);
  filter: brightness(0.97);
}

.btn-stop.is-loading:disabled,
.btn-complete.is-loading:disabled {
  opacity: 1;
  cursor: wait;
}

.btn-complete.is-loading:disabled {
  background: linear-gradient(135deg, #f87171, #dc2626);
  color: #fff;
  box-shadow: 0 6px 18px rgba(239, 68, 68, 0.28);
}

.btn-complete:disabled:not(.is-loading) {
  background: #e2e8f0;
  color: #64748b;
  box-shadow: none;
  cursor: not-allowed;
  filter: none;
  opacity: 1;
}

.btn-complete:disabled:not(.is-loading) .btn-close-icon {
  opacity: 0.5;
}

.detail-action-close .btn.is-loading .btn-close-icon {
  opacity: 0;
}

/* ── Karta zamknięcia ───────────────────────────────────────────────────── */
.close-form {
  margin: 0 0 12px;
  padding: 0;
  border: none;
  border-radius: 20px;
  background: var(--surface);
  box-shadow:
    0 1px 2px rgba(15, 23, 42, 0.04),
    0 8px 28px rgba(15, 23, 42, 0.07);
  overflow: hidden;
}

.close-form-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 16px 14px;
  background: linear-gradient(135deg, #fff7ed 0%, #ffffff 55%, #fef2f2 100%);
  border-bottom: 1px solid rgba(226, 232, 240, 0.8);
}

.close-form-header-icon {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #ea580c;
  background: linear-gradient(145deg, #ffedd5, #fed7aa);
  box-shadow: 0 4px 12px rgba(249, 115, 22, 0.18);
}

.close-form-header-text {
  min-width: 0;
}

.close-form-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
}

.close-form-subtitle {
  margin: 2px 0 0;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.close-form-block {
  padding: 14px 16px;
}

.close-form-block + .close-form-block {
  border-top: 1px solid var(--border);
}

.close-form-block--comment {
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
}

.close-form-block-head {
  margin-bottom: 10px;
}

.close-form-block-label {
  display: block;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.close-form-toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.close-form-toggle-input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

.close-form-toggle-track {
  position: relative;
  width: 48px;
  height: 28px;
  flex-shrink: 0;
  border-radius: 999px;
  background: #cbd5e1;
  transition: background 0.22s ease, box-shadow 0.22s ease;
  box-shadow: inset 0 1px 3px rgba(15, 23, 42, 0.12);
}

.close-form-toggle-track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.18);
  transition: transform 0.22s cubic-bezier(0.34, 1.2, 0.64, 1);
}

.close-form-toggle-input:checked + .close-form-toggle-track {
  background: linear-gradient(145deg, #fb923c, #ea580c);
  box-shadow: 0 2px 10px rgba(249, 115, 22, 0.35);
}

.close-form-toggle-input:checked + .close-form-toggle-track::after {
  transform: translateX(20px);
}

.close-form-toggle-input:focus-visible + .close-form-toggle-track {
  outline: 2px solid rgba(249, 115, 22, 0.45);
  outline-offset: 2px;
}

.close-form-toggle-text {
  font-size: 0.94rem;
  font-weight: 600;
  color: var(--text);
}

.close-duration-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 16px;
  background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
  border: 1px solid rgba(226, 232, 240, 0.95);
}

.close-duration-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.close-duration-label {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text);
}

.close-duration-unit {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: lowercase;
}

.close-duration-input {
  width: 76px;
  min-width: 76px;
  padding: 10px 8px;
  border: 2px solid transparent;
  border-radius: 14px;
  font-size: 1.5rem;
  font-weight: 800;
  line-height: 1;
  text-align: center;
  color: var(--indigo);
  background: #fff;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.1);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.close-duration-input:focus {
  outline: none;
  border-color: rgba(99, 102, 241, 0.45);
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.12);
}

.close-duration-input:read-only {
  color: #475569;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: none;
}

.close-duration-input:not(:read-only) {
  color: #4f46e5;
  border-color: rgba(99, 102, 241, 0.25);
}

.close-time-fields {
  margin-top: 12px;
}

.close-time-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.close-time-cell {
  min-width: 0;
}

.close-time-label {
  display: block;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.close-time-grid input {
  width: 100%;
  padding: 10px 11px;
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 0.82rem;
  font-weight: 500;
  background: #fff;
  color: var(--text-muted);
}

.close-time-summary {
  margin: 10px 0 0;
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 0.82rem;
  font-weight: 600;
  color: #64748b;
  background: rgba(99, 102, 241, 0.06);
}

.close-time-summary:empty {
  display: none;
}

.close-comment-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.close-comment-head-left {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.close-comment-required {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #b91c1c;
  background: #fef2f2;
  border: 1px solid #fecaca;
}

.close-comment-counter {
  font-size: 0.78rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text-hint);
  padding-top: 2px;
  transition: color 0.15s ease;
}

.close-comment-counter--warn {
  color: #ea580c;
}

.close-comment-counter--danger {
  color: #dc2626;
}

#close-sap-comment {
  width: 100%;
  min-height: 96px;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: 14px;
  font: inherit;
  font-size: 0.95rem;
  line-height: 1.45;
  resize: vertical;
  background: #fff;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

#close-sap-comment::placeholder {
  color: #94a3b8;
}

#close-sap-comment:focus {
  outline: none;
  border-color: rgba(239, 68, 68, 0.45);
  box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.1);
}

.close-availability-hint {
  margin: 0;
  padding: 12px 16px;
  font-size: 0.86rem;
  line-height: 1.4;
  color: #92400e;
  background: linear-gradient(90deg, #fffbeb, #fff7ed);
  border-bottom: 1px solid #fde68a;
}

.close-availability-hint.hidden {
  display: none;
}

.close-confirm-modal {
  max-width: 360px;
}

.close-confirm-message {
  margin: 0 0 16px;
  font-size: 0.92rem;
  line-height: 1.45;
  white-space: pre-wrap;
}

.close-confirm-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.close-confirm-actions .btn-complete {
  min-height: 48px;
  border-radius: 14px;
  font-weight: 700;
}

.btn-join {
  width: 100%;
  min-height: 56px;
  padding: 14px 20px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--indigo), #818cf8);
  color: #fff;
  font-size: 1.05rem;
  font-weight: 700;
  box-shadow: 0 6px 18px rgba(99, 102, 241, 0.35);
  gap: 10px;
}

.btn-join:active:not(:disabled) {
  transform: scale(0.98);
}

.btn-join.joined,
.btn-join:disabled:not(.is-loading) {
  background: #e2e8f0;
  color: #64748b;
  box-shadow: none;
  opacity: 1;
  cursor: not-allowed;
}

.btn-join.is-loading:disabled {
  background: linear-gradient(135deg, var(--indigo), #818cf8);
  color: #fff;
  box-shadow: 0 6px 18px rgba(99, 102, 241, 0.35);
  opacity: 1;
  cursor: wait;
}

.btn-join-icon {
  display: inline-flex;
  width: 22px;
  height: 22px;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
}

/* ── Uczestnicy ─────────────────────────────────────────────────────────── */
#participants-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.participant {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.participant:last-child { border-bottom: none; }

.participant .name {
  font-weight: 600;
  font-size: 0.9rem;
}

.participant.active .name { color: var(--green); }

.participant.active .name::before {
  content: "● ";
  font-size: 0.7rem;
}

.p-time {
  font-size: 0.78rem;
  color: var(--text-hint);
  margin-top: 2px;
}

/* ── Toast ──────────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 16px;
  left: 14px;
  right: 14px;
  max-width: 492px;
  margin: auto;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--text);
  color: #fff;
  font-size: 0.88rem;
  z-index: 100;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.2);
}

.toast.error { background: #991b1b; }
.toast.ok { background: #166534; }

/* ── Nawigacja modułów — pływająca wyspa na dole ─────────────────────────── */
.module-nav {
  position: fixed;
  left: 8px;
  right: 8px;
  bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  z-index: 25;
  width: min(calc(100% - 16px), 560px);
  max-width: calc(100vw - 16px);
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  padding: 8px 6px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(226, 232, 240, 0.95);
  box-shadow:
    0 4px 6px rgba(15, 23, 42, 0.04),
    0 12px 28px rgba(15, 23, 42, 0.12);
  box-sizing: border-box;
}

body.keyboard-open .module-nav,
body.keyboard-open .cart-fab {
  display: none !important;
}

body.keyboard-open.module-nav-open .app-main {
  padding-bottom: 24px;
}

.module-nav-btn {
  min-width: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 50px;
  padding: 6px 2px;
  border: 1px solid transparent;
  border-radius: 16px;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.6rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.module-nav-btn.active {
  color: var(--indigo);
  background: rgba(99, 102, 241, 0.1);
  border-color: rgba(99, 102, 241, 0.22);
}

.module-nav-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  line-height: 1;
}

.module-nav-label {
  line-height: 1.1;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Wyszukiwarka części ─────────────────────────────────────────────────── */
.parts-search-card {
  margin-bottom: 10px;
}

.parts-search-card label {
  margin-bottom: 8px;
}

.parts-search-row {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.parts-search-row--inline {
  flex-direction: row;
  align-items: center;
  gap: 10px;
}

.parts-query-input {
  flex: 1;
  min-width: 0;
  width: 100%;
  margin-bottom: 0;
  min-height: 56px;
  padding: 14px 16px;
  font-size: 1.05rem;
  font-weight: 500;
  border-radius: 12px;
  border: 1.5px solid var(--border);
  background: var(--input-bg);
}

.parts-query-input:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.14);
}

.parts-search-row:not(.parts-search-row--inline) input {
  width: 100%;
  margin-bottom: 0;
  min-height: 52px;
  font-size: 1.05rem;
}

.parts-search-btn {
  width: 100%;
  min-height: 52px;
  padding: 14px 20px;
  font-size: 1.05rem;
  font-weight: 700;
  border-radius: 12px;
  gap: 8px;
}

.parts-search-btn-icon {
  font-size: 1.15rem;
  line-height: 1;
}

#parts-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

#parts-list > li {
  margin-bottom: 7px;
}

/* ── Karta części ────────────────────────────────────────────────────────── */
.part-card {
  background: var(--surface);
  border-radius: 16px;
  border: 1px solid var(--border);
  box-shadow:
    0 1px 2px rgba(15, 23, 42, 0.04),
    0 4px 16px rgba(15, 23, 42, 0.06);
  overflow: hidden;
  transition: box-shadow 0.15s ease;
}

/* Kolorowy pasek boczny zależny od stanu */
.part-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  border-radius: 16px 0 0 16px;
}

.part-card {
  position: relative;
}

.part-card[data-tone="ok"]::before    { background: var(--green); }
.part-card[data-tone="low"]::before   { background: var(--amber); }
.part-card[data-tone="empty"]::before { background: var(--red); }
.part-card[data-tone="unknown"]::before { background: var(--border); }

.part-card-main {
  padding: 10px 12px 0 15px;
}

.part-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 3px;
}

.part-id {
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: 0.01em;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.part-stock-badge {
  flex-shrink: 0;
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 3px 8px;
  border-radius: 999px;
}

.part-stock-badge--ok {
  color: #166534;
  background: #dcfce7;
}

.part-stock-badge--low {
  color: #92400e;
  background: #fef3c7;
}

.part-stock-badge--empty {
  color: #991b1b;
  background: #fee2e2;
}

.part-stock-badge--unknown {
  color: var(--text-muted);
  background: #f1f5f9;
}

.part-card-desc {
  margin: 0 0 5px;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}

.part-card-loc {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--blue);
  margin-bottom: 10px;
}

/* ── Sekcja pobrania ─────────────────────────────────────────────────────── */
.part-cart {
  padding: 8px 12px 8px 15px;
  background: #f8fafc;
  border-top: 1px solid var(--border);
}

.part-cart--blocked {
  opacity: 0.85;
}

.part-cart-row {
  display: flex;
  align-items: center;
  gap: 7px;
}

.part-cart-qty-wrap {
  flex: 0 0 auto;
  width: 76px;
  display: flex;
  align-items: center;
  height: 36px;
  padding: 0 6px 0 8px;
  gap: 3px;
  border-radius: 9px;
  background: var(--surface);
  border: 1px solid var(--border);
  cursor: text;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.part-cart-qty-wrap:focus-within {
  border-color: var(--indigo);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}

.part-cart-qty {
  width: 28px;
  flex: 0 0 auto;
  height: 36px;
  border: none;
  background: transparent;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text);
  text-align: center;
  padding: 0;
  margin: 0;
  line-height: 36px;
  box-sizing: border-box;
  -moz-appearance: textfield;
  appearance: none;
  outline: none;
}

.part-cart-qty::-webkit-outer-spin-button,
.part-cart-qty::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.part-cart-qty:disabled {
  opacity: 0.4;
}

.part-cart-qty-sfx {
  flex-shrink: 0;
  align-self: center;
  font-size: 0.62rem;
  font-weight: 600;
  line-height: 1;
  color: var(--text-hint);
  pointer-events: none;
}

.part-cart-btn {
  flex: 0 0 auto;
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 36px;
  padding: 0 12px;
  border: none;
  border-radius: 9px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.01em;
  color: #fff;
  background: var(--cart-accent);
  position: relative;
  white-space: nowrap;
  transition: background 0.15s ease, transform 0.1s ease;
}

.part-cart-btn:active:not(:disabled):not(.is-loading) {
  transform: scale(0.98);
  background: var(--cart-accent-pressed);
}

.part-cart-btn-icon {
  flex-shrink: 0;
  opacity: 0.9;
}

.part-cart-btn.is-disabled,
.part-cart-btn:disabled {
  cursor: not-allowed;
  background: #cbd5e1;
  box-shadow: none;
  filter: none;
}

.part-cart-btn.is-loading {
  pointer-events: none;
  color: transparent;
}

.part-cart-btn.is-loading .part-cart-btn-icon {
  opacity: 0;
}

.part-cart-btn.is-loading::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 14px;
  height: 14px;
  margin: -7px 0 0 -7px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: part-cart-spin 0.6s linear infinite;
}

@keyframes part-cart-spin {
  to { transform: rotate(360deg); }
}

.part-cart-foot {
  margin-top: 4px;
  display: flex;
  align-items: center;
}

.part-cart-operator {
  font-size: 0.62rem;
  font-weight: 600;
  color: var(--text-hint);
  letter-spacing: 0.01em;
}

.part-cart-feedback {
  margin: 5px 0 0;
  font-size: 0.63rem;
  font-weight: 600;
  line-height: 1.3;
  color: var(--text-hint);
}

.part-cart-feedback[hidden] {
  display: none !important;
}

.part-cart-feedback--warn {
  color: #b45309;
}

.part-cart-feedback--error {
  color: var(--red);
}

#parts-status {
  font-size: 0.78rem;
  color: var(--text-hint);
}

/* ── Pływający koszyk (FAB) ─────────────────────────────────────────────── */
.cart-fab {
  position: fixed;
  right: 16px;
  bottom: calc(78px + env(safe-area-inset-bottom, 0px));
  z-index: 35;
  width: 52px;
  height: 52px;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(145deg, #818cf8 0%, var(--indigo) 100%);
  color: #fff;
  box-shadow:
    0 4px 14px rgba(99, 102, 241, 0.45),
    0 2px 6px rgba(15, 23, 42, 0.12);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.cart-fab:active {
  transform: scale(0.94);
}

.cart-fab.hidden {
  display: none;
}

.cart-fab-icon {
  font-size: 1.35rem;
  line-height: 1;
}

.cart-fab-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--red);
  color: #fff;
  font-size: 0.62rem;
  font-weight: 800;
  line-height: 18px;
  text-align: center;
  border: 2px solid var(--surface);
  box-sizing: content-box;
}

.cart-fab-badge.hidden {
  display: none;
}

/* ── Widok koszyka ───────────────────────────────────────────────────────── */
.cart-toolbar {
  margin-bottom: 8px;
}

#cart-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

#cart-list > li {
  margin-bottom: 8px;
}

.cart-item-card {
  background: var(--surface);
  border-radius: 14px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 10px 12px;
}

.cart-item-card--mine {
  border-left: 3px solid var(--indigo);
}

.cart-item-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}

.cart-item-id {
  font-size: 0.9rem;
  font-weight: 800;
  color: var(--text);
}

.cart-item-qty {
  flex-shrink: 0;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  background: #eef2ff;
  color: var(--indigo);
}

.cart-item-desc {
  margin: 0 0 6px;
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.cart-item-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.cart-item-author {
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--text-hint);
}

.cart-item-remove {
  flex-shrink: 0;
  height: 28px;
  padding: 0 10px;
  border: 1px solid rgba(239, 68, 68, 0.35);
  border-radius: 8px;
  background: #fff;
  color: var(--red);
  font-family: inherit;
  font-size: 0.68rem;
  font-weight: 700;
  cursor: pointer;
}

.cart-item-remove:active {
  background: #fef2f2;
}

.cart-item-remove:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

body.cart-open .cart-fab {
  display: none;
}

body.cart-open .app-main {
  padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
}

/* ── Wystaw WO ───────────────────────────────────────────────────────────── */
.create-wo-shell {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.create-wo-badge {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 0;
  padding: 14px 16px;
  background: linear-gradient(135deg, rgba(34, 197, 94, 0.12) 0%, rgba(99, 102, 241, 0.06) 100%);
  border-color: rgba(34, 197, 94, 0.28);
  box-shadow: 0 4px 18px rgba(34, 197, 94, 0.08);
}

.create-wo-badge-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.06);
}

.create-wo-badge-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.create-wo-badge-title {
  font-size: 0.92rem;
  font-weight: 800;
  color: #14532d;
  letter-spacing: -0.02em;
}

.create-wo-card {
  margin-bottom: 0;
  border-radius: 16px;
  box-shadow:
    0 1px 2px rgba(15, 23, 42, 0.04),
    0 6px 20px rgba(15, 23, 42, 0.06);
  overflow: hidden;
}

.create-wo-card--machine {
  border-left: 4px solid var(--indigo);
}

.create-wo-card--confirmed {
  border-left: 4px solid var(--green);
  background: linear-gradient(180deg, rgba(34, 197, 94, 0.06) 0%, var(--surface) 40%);
}

.create-wo-card--confirmed.is-pending {
  border-left-color: #cbd5e1;
  background: var(--surface);
}

.create-wo-card--confirmed.is-pending .create-wo-section-icon {
  background: var(--surface-alt);
  color: var(--text-muted);
  font-weight: 400;
}

.create-wo-card--confirmed.is-pending .create-wo-context-row {
  background: var(--surface-alt);
}

.create-wo-card--confirmed.is-pending .create-wo-ctx-value {
  color: var(--text-muted);
}

.create-wo-card--confirmed.is-pending.is-loading .create-wo-ctx-value {
  color: var(--text-muted);
  font-style: italic;
}

.create-wo-card--wc {
  border-left: 4px solid var(--cyan);
}

.create-wo-card--wc.is-pending {
  border-left-color: #cbd5e1;
}

.create-wo-card--wc.is-pending .wc-select:disabled {
  opacity: 1;
  background: var(--surface-alt);
  color: var(--text-muted);
  border-color: #e2e8f0;
  cursor: not-allowed;
}

.create-wo-card--desc {
  border-left: 4px solid var(--amber);
}

.create-wo-card h2 {
  margin: 0 0 12px;
  font-size: 0.95rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 8px;
  letter-spacing: -0.02em;
}

.create-wo-section-icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--surface-alt);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  flex-shrink: 0;
}

.create-wo-card--confirmed .create-wo-section-icon {
  background: rgba(34, 197, 94, 0.15);
  color: #166534;
  font-weight: 800;
}

.create-wo-search-row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.create-wo-machine-input {
  flex: 1;
  min-width: 0;
  min-height: 56px;
  margin-bottom: 0;
  padding: 14px 16px;
  font-size: 1.08rem;
  font-weight: 500;
  border-radius: 12px;
  border: 1.5px solid var(--border);
  background: var(--input-bg);
}

.create-wo-machine-input:focus {
  border-color: var(--indigo);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.14);
}

.create-wo-search-btn {
  flex-shrink: 0;
  width: 46px;
  height: 46px;
  min-width: 46px;
  min-height: 46px;
  padding: 0;
  border-radius: 12px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  color: var(--indigo);
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.05);
}

.create-wo-scan-btn {
  flex-shrink: 0;
  width: 46px;
  height: 46px;
  min-width: 46px;
  min-height: 46px;
  padding: 0;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(6, 182, 212, 0.12) 0%, rgba(99, 102, 241, 0.1) 100%);
  border: 1.5px solid rgba(6, 182, 212, 0.35);
  color: #0891b2;
  box-shadow: 0 2px 8px rgba(6, 182, 212, 0.15);
}

.create-wo-scan-btn:active {
  background: rgba(6, 182, 212, 0.18);
  border-color: rgba(6, 182, 212, 0.5);
}

.create-wo-scan-btn svg,
.create-wo-search-btn svg {
  display: block;
}

.create-wo-field-hint {
  margin-top: 8px;
  margin-bottom: 0;
}

.create-wo-title-input {
  min-height: 50px;
  font-size: 1rem;
  font-weight: 500;
  margin-bottom: 0;
}

.create-wo-detail-input {
  width: 100%;
  min-height: 130px;
  margin-bottom: 0;
  padding: 14px 16px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  background: var(--input-bg);
  font-family: inherit;
  font-size: 0.95rem;
  line-height: 1.5;
  resize: vertical;
}

.field-footer {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-top: 6px;
  margin-bottom: 14px;
}

.field-footer .hint {
  margin: 0;
  flex: 1;
  font-size: 0.74rem;
}

.field-footer--end {
  justify-content: flex-end;
}

.char-counter {
  flex-shrink: 0;
  font-size: 0.74rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-alt);
}

.char-counter--ok {
  color: #166534;
  background: rgba(34, 197, 94, 0.12);
}

.char-counter--warn {
  color: #b45309;
  background: rgba(245, 158, 11, 0.15);
}

.char-counter--limit {
  color: #b91c1c;
  background: rgba(239, 68, 68, 0.12);
}

.create-wo-suggestions {
  list-style: none;
  padding: 0;
  margin: 12px 0 0;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: var(--surface);
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.06);
  max-height: 240px;
  overflow-y: auto;
}

.create-wo-suggestions.hidden {
  display: none;
}

.create-wo-suggestions > li + li {
  border-top: 1px solid var(--border);
}

.machine-suggestion {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  padding: 14px 16px;
  border: none;
  background: transparent;
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.12s ease;
}

.machine-suggestion:active {
  background: rgba(99, 102, 241, 0.06);
}

.machine-suggestion-name {
  font-size: 0.94rem;
  font-weight: 700;
  color: var(--text);
}

.machine-suggestion-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.35;
}

.create-wo-context-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.create-wo-context-row {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.7);
}

.wc-select {
  width: 100%;
  min-height: 50px;
  margin-bottom: 8px;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  background: var(--input-bg);
  font-size: 0.95rem;
  color: var(--text);
}

.create-wo-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 0;
  padding: 16px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  border-radius: 16px;
  background: var(--surface);
  box-shadow:
    0 1px 2px rgba(15, 23, 42, 0.04),
    0 8px 24px rgba(15, 23, 42, 0.08);
}

.create-wo-status-line {
  min-height: 1.2em;
  font-size: 0.82rem;
  text-align: center;
}

.create-wo-submit {
  width: 100%;
  min-height: 54px;
  font-size: 1.02rem;
  font-weight: 800;
  border: none;
  border-radius: 14px;
  color: #fff;
  background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
  box-shadow: 0 6px 18px rgba(34, 197, 94, 0.35);
}

.create-wo-submit:disabled {
  opacity: 0.5;
  box-shadow: none;
}

.create-wo-submit.is-loading:disabled {
  opacity: 1;
  background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
  box-shadow: 0 6px 18px rgba(34, 197, 94, 0.35);
  cursor: wait;
}

.module-nav-btn[data-module="zdarzenia"].active {
  color: var(--indigo);
  background: rgba(99, 102, 241, 0.1);
  border-color: rgba(99, 102, 241, 0.22);
}

/* ── Zdarzenia — hub typów + filtry ─────────────────────────────────────── */
#events-hub-panel {
  padding-top: 4px;
}

.events-hub-hero {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
  padding: 18px 16px;
  border-radius: calc(var(--radius) + 2px);
  background:
    linear-gradient(135deg, rgba(99, 102, 241, 0.12) 0%, rgba(129, 140, 248, 0.06) 50%, rgba(255, 255, 255, 0.9) 100%);
  border: 1px solid rgba(99, 102, 241, 0.14);
  box-shadow:
    0 1px 2px rgba(15, 23, 42, 0.04),
    0 8px 24px rgba(99, 102, 241, 0.08);
}

.events-hub-hero-icon {
  flex-shrink: 0;
  width: 52px;
  height: 52px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.65rem;
  line-height: 1;
  color: #fff;
  background: linear-gradient(145deg, #818cf8 0%, var(--indigo) 100%);
  box-shadow: 0 6px 16px rgba(99, 102, 241, 0.35);
}

.events-hub-title {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
}

.events-hub-subtitle {
  margin: 4px 0 0;
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.35;
}

.events-hub-tiles {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}

.events-type-tile {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 76px;
  padding: 14px 14px 14px 16px;
  border-radius: calc(var(--radius) + 2px);
  border: 1px solid transparent;
  background: var(--surface);
  box-shadow:
    0 1px 2px rgba(15, 23, 42, 0.04),
    0 4px 16px rgba(15, 23, 42, 0.05);
  cursor: pointer;
  text-align: left;
  overflow: hidden;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.events-type-tile::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  border-radius: 4px 0 0 4px;
  background: var(--tile-accent, var(--indigo));
}

.events-type-tile:active {
  transform: scale(0.985);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.06);
}

.events-type-tile-icon {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--tile-accent, var(--indigo));
  background: color-mix(in srgb, var(--tile-accent, var(--indigo)) 12%, white);
  border: 1px solid color-mix(in srgb, var(--tile-accent, var(--indigo)) 22%, transparent);
}

.events-type-tile-body {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.events-type-tile-label {
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--text);
}

.events-type-tile-desc {
  font-size: 0.74rem;
  font-weight: 500;
  color: var(--text-muted);
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.events-type-tile-badge {
  flex-shrink: 0;
  padding: 5px 9px;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: var(--tile-accent, var(--indigo));
  background: color-mix(in srgb, var(--tile-accent, var(--indigo)) 10%, white);
  border: 1px solid color-mix(in srgb, var(--tile-accent, var(--indigo)) 24%, transparent);
}

.events-type-tile-chevron {
  flex-shrink: 0;
  display: flex;
  color: var(--text-hint);
  opacity: 0.7;
}

.events-type-tile--pm55 {
  --tile-accent: #ef4444;
}

.events-type-tile--wystaw {
  --tile-accent: #22c55e;
}

.events-type-tile--pm50 {
  --tile-accent: #f59e0b;
}

.events-type-tile--pm60 {
  --tile-accent: #06b6d4;
}

.events-type-tile--am {
  --tile-accent: #8b5cf6;
}

.events-type-tile--ur {
  --tile-accent: #0ea5e9;
}

.events-type-tile--mii {
  --tile-accent: #6366f1;
}

.events-mii-hub-shell .events-hub-tiles {
  margin-top: 8px;
}

.events-hub-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 4px 4px;
}

.events-hub-footer-hint {
  font-size: 0.75rem;
  color: var(--text-hint);
  font-weight: 500;
}

.events-hub-logout {
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

/* ── Filtry listy zdarzeń ─────────────────────────────────────────────────── */
.events-filters-card {
  margin-bottom: 10px;
  padding: 0;
  overflow: hidden;
  border-radius: calc(var(--radius) + 2px);
  background: linear-gradient(180deg, #ffffff 0%, #fafbfc 100%);
  border: 1px solid rgba(226, 232, 240, 0.95);
  box-shadow:
    0 1px 2px rgba(15, 23, 42, 0.04),
    0 6px 20px rgba(15, 23, 42, 0.04);
}

.events-filters-card.is-collapsed {
  padding-bottom: 0;
}

.events-filters-header {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  margin: 0;
  padding: 14px 16px;
  border: none;
  background: transparent;
  cursor: pointer;
  text-align: left;
  -webkit-tap-highlight-color: transparent;
}

.events-filters-header:active {
  background: rgba(99, 102, 241, 0.04);
}

.events-filters-header-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  color: var(--indigo);
  background: rgba(99, 102, 241, 0.1);
}

.events-filters-header-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

.events-filters-header-title {
  font-size: 0.9rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.01em;
}

.events-filters-summary {
  font-size: 0.74rem;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.events-filters-toggle-chevron {
  flex-shrink: 0;
  display: flex;
  color: var(--text-muted);
  transition: transform 0.22s ease;
}

.events-filters-card.is-expanded .events-filters-toggle-chevron {
  transform: rotate(180deg);
}

.events-filters-body {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.26s ease;
}

.events-filters-card.is-expanded .events-filters-body {
  grid-template-rows: 1fr;
}

.events-filters-body-inner {
  min-height: 0;
  overflow: hidden;
}

.events-filters-card.is-expanded .events-filters-body-inner {
  overflow: visible;
}

.events-filters-card.is-collapsed .events-filters-body {
  pointer-events: none;
}

.events-filters-card.is-expanded .events-filters-header {
  border-bottom: 1px solid var(--border);
}

.events-filter-field {
  margin-bottom: 10px;
  padding: 0 16px;
}

.events-filter-field:first-child {
  padding-top: 14px;
}

.events-filters-actions {
  display: flex;
  gap: 10px;
  margin-top: 14px;
  padding: 14px 16px 16px;
  border-top: 1px solid var(--border);
}

.events-filter-field label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.events-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.events-input-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  color: var(--text-hint);
  pointer-events: none;
  z-index: 1;
}

.events-input-wrap--select .events-input-icon {
  color: var(--indigo);
}

.events-period-select,
.events-filter-input {
  width: 100%;
  min-height: 46px;
  padding: 11px 14px 11px 42px;
  border-radius: 12px;
  border: 1.5px solid var(--border);
  background: var(--input-bg);
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
  -webkit-appearance: none;
  appearance: none;
}

.events-period-select {
  padding-right: 40px;
  cursor: pointer;
}

.events-filter-input::placeholder {
  color: var(--text-hint);
  font-weight: 400;
}

.events-period-select:focus,
.events-filter-input:focus {
  outline: none;
  border-color: rgba(99, 102, 241, 0.55);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.12);
}

.events-select-chevron {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  color: var(--text-muted);
  pointer-events: none;
}

.events-search-btn {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 18px;
  border: none;
  border-radius: 14px;
  font-size: 0.92rem;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(135deg, #818cf8 0%, var(--indigo) 100%);
  box-shadow: 0 6px 18px rgba(99, 102, 241, 0.32);
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  -webkit-tap-highlight-color: transparent;
}

.events-search-btn:active {
  transform: scale(0.985);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.28);
}

.events-filter-multiselect-btn {
  width: 100%;
  min-height: 46px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 40px 11px 42px;
  border-radius: 12px;
  border: 1.5px solid var(--border);
  background: var(--input-bg);
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  position: relative;
  text-align: left;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.events-filter-multiselect-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.events-filter-multiselect-btn:active:not(:disabled) {
  border-color: rgba(99, 102, 241, 0.45);
}

.events-filter-multiselect-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  color: var(--text-hint);
  pointer-events: none;
}

.events-filter-multiselect-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.events-filter-multiselect-badge {
  flex-shrink: 0;
  font-size: 0.72rem;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(99, 102, 241, 0.14);
  color: var(--indigo);
}

.events-filter-multiselect-btn .events-select-chevron {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  color: var(--text-muted);
  pointer-events: none;
}

.events-filter-sheet-overlay {
  position: fixed;
  inset: 0;
  z-index: 1200;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(2px);
}

.events-filter-sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1210;
  max-height: min(72vh, 520px);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -8px 32px rgba(15, 23, 42, 0.18);
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.events-filter-sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 8px;
  border-bottom: 1px solid var(--border);
}

.events-filter-sheet-header h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 800;
}

.events-filter-sheet-close {
  min-width: 40px;
  min-height: 40px;
  padding: 0;
  border: none;
  background: transparent;
  font-size: 1.1rem;
  color: var(--text-muted);
}

.events-filter-sheet-actions {
  display: flex;
  gap: 12px;
  padding: 8px 16px;
}

.events-filter-sheet-link {
  padding: 4px 0;
  border: none;
  background: transparent;
  color: var(--indigo);
  font-size: 0.82rem;
  font-weight: 700;
}

.events-filter-sheet-options {
  flex: 1;
  overflow-y: auto;
  padding: 4px 8px 8px;
}

.events-filter-sheet-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 12px;
  border-radius: 12px;
  cursor: pointer;
  font-size: 0.92rem;
  font-weight: 500;
}

.events-filter-sheet-option:active {
  background: rgba(99, 102, 241, 0.08);
}

.events-filter-sheet-checkbox {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  accent-color: var(--indigo);
}

.events-filter-sheet-empty {
  padding: 16px 12px;
  text-align: center;
}

.events-filter-sheet-footer {
  padding: 12px 16px 16px;
  border-top: 1px solid var(--border);
}

.events-filter-sheet-done {
  width: 100%;
  min-height: 48px;
  border: none;
  border-radius: 14px;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(135deg, #818cf8 0%, var(--indigo) 100%);
}

.events-filter-multiselect-btn .events-select-chevron {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  color: var(--text-muted);
  pointer-events: none;
}

.events-refresh-btn {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  padding: 0;
  border-radius: 14px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.12s ease, color 0.12s ease, border-color 0.12s ease;
  -webkit-tap-highlight-color: transparent;
}

.events-refresh-btn:active {
  transform: scale(0.94);
  color: var(--indigo);
  border-color: rgba(99, 102, 241, 0.35);
}

.events-refresh-btn.is-loading svg {
  animation: events-spin 0.8s linear infinite;
}

.events-refresh-btn--compact {
  width: 40px;
  height: 40px;
  border-radius: 12px;
}

.events-list-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 2px 8px;
}

.events-list-toolbar .muted {
  flex: 1;
  min-width: 0;
}

@keyframes events-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.events-kpi-card {
  background: linear-gradient(135deg, color-mix(in srgb, var(--kpi-accent, #6366f1) 14%, transparent), color-mix(in srgb, var(--kpi-accent, #6366f1) 4%, transparent));
  border-color: color-mix(in srgb, var(--kpi-accent, #6366f1) 28%, transparent);
  box-shadow:
    0 1px 2px rgba(15, 23, 42, 0.04),
    0 6px 18px color-mix(in srgb, var(--kpi-accent, #6366f1) 12%, transparent);
}

.events-kpi-icon {
  color: var(--kpi-accent, #6366f1);
  background: color-mix(in srgb, var(--kpi-accent, #6366f1) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--kpi-accent, #6366f1) 30%, transparent);
}

.events-kpi-card--pm55 { --kpi-accent: #ef4444; }
.events-kpi-card--pm50 { --kpi-accent: #f59e0b; }
.events-kpi-card--pm60 { --kpi-accent: #06b6d4; }

#events-list-panel .detail-nav {
  margin-bottom: 10px;
}

#events-list-panel .toolbar {
  padding: 0;
}

#events-list-panel .toolbar .muted {
  font-size: 0.78rem;
  font-weight: 600;
}

.module-nav-btn .module-nav-label {
  font-size: 0.62rem;
}

/* ── Modal sukcesu WO (parytet desktop dialogs.py) ─────────────────────────── */
body.modal-open {
  overflow: hidden;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: modal-fade-in 0.22s ease;
}

.modal-overlay.hidden {
  display: none !important;
}

@keyframes modal-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes modal-pop-in {
  from {
    opacity: 0;
    transform: scale(0.92) translateY(12px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.modal-card.wo-success-modal {
  width: min(100%, 380px);
  padding: 22px 20px 18px;
  border-radius: 20px;
  background: var(--surface);
  border: 1px solid rgba(226, 232, 240, 0.95);
  box-shadow:
    0 8px 32px rgba(15, 23, 42, 0.12),
    0 24px 48px rgba(15, 23, 42, 0.18);
  animation: modal-pop-in 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

.wo-success-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
}

.wo-success-icon {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: rgba(34, 197, 94, 0.12);
  color: var(--green);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.wo-success-header h2 {
  margin: 0;
  font-size: 1.12rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
}

.wo-success-label {
  margin: 0 0 6px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.wo-success-number {
  display: block;
  width: 100%;
  margin: 0 0 8px;
  padding: 8px 4px;
  border: none;
  background: transparent;
  font-size: 2.25rem;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.03em;
  color: var(--green);
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  font-variant-numeric: tabular-nums;
}

.wo-success-number:active {
  opacity: 0.75;
}

.wo-success-meta {
  margin: 0 0 8px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
}

.wo-success-warnings {
  list-style: none;
  margin: 0 0 10px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.25);
}

.wo-success-warnings.hidden {
  display: none;
}

.wo-success-warnings li {
  font-size: 0.78rem;
  color: #b45309;
  line-height: 1.4;
}

.wo-success-warnings li + li {
  margin-top: 4px;
}

.wo-success-hint {
  margin: 0 0 18px;
  font-size: 0.74rem;
  color: var(--text-hint);
}

.wo-success-hint--muted {
  color: var(--text-muted);
}

.wo-success-hint--error {
  color: var(--red);
}

.wo-success-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.wo-success-btn-primary {
  width: 100%;
  min-height: 50px;
  font-size: 0.95rem;
  font-weight: 700;
  color: #fff;
  background: var(--indigo);
  border: none;
  border-radius: 12px;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.32);
}

.wo-success-btn-secondary {
  width: 100%;
  min-height: 44px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
  background: transparent;
  border: none;
}

/* ── Skaner QR maszyny ───────────────────────────────────────────────────── */
.qr-scanner-overlay {
  z-index: 210;
}

.qr-scanner-card {
  width: min(100%, 400px);
  padding: 18px 16px 16px;
  border-radius: 20px;
  animation: modal-pop-in 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

.qr-scanner-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.qr-scanner-header h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.qr-scanner-close {
  width: 36px;
  height: 36px;
  min-width: 36px;
  padding: 0;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text-muted);
  font-size: 1rem;
  line-height: 1;
}

.qr-scanner-hint {
  margin: 0 0 12px;
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.qr-reader {
  width: 100%;
  min-height: 280px;
  border-radius: 16px;
  overflow: hidden;
  background: #0f172a;
  border: 2px solid rgba(6, 182, 212, 0.35);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.qr-reader video {
  border-radius: 14px;
}

.qr-scanner-status {
  margin: 12px 0 0;
  font-size: 0.8rem;
  text-align: center;
}

.create-wo-search-btn:active {
  background: rgba(99, 102, 241, 0.08);
  border-color: rgba(99, 102, 241, 0.35);
}

/* ── Polecenia mobile MVP ───────────────────────────────────────────────── */
.commands-shell {
  padding-top: 2px;
}

.commands-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-left: 4px solid var(--amber);
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.12), #fff 65%);
}

.commands-hero h2 {
  margin: 0;
  font-size: 1.12rem;
}

.commands-hero p {
  margin: 3px 0 0;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.commands-status {
  min-height: 1.25rem;
  margin: 0 2px 8px;
}

.commands-list,
.command-notes,
.command-parts {
  list-style: none;
  padding: 0;
  margin: 0;
}

.commands-list > li {
  margin-bottom: 10px;
}

.command-card {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding: 12px 13px;
  border: 1px solid var(--border);
  border-left: 5px solid var(--command-tone, var(--amber));
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.command-card:active {
  transform: scale(0.99);
}

.command-card:focus-visible,
.commands-more:focus-visible,
.command-close-submit:focus-visible {
  outline: 3px solid rgba(99, 102, 241, 0.35);
  outline-offset: 2px;
}

.command-card-head,
.command-detail-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  width: 100%;
}

.command-number {
  font-size: 1rem;
  font-weight: 850;
  font-variant-numeric: tabular-nums;
}

.command-status {
  margin-left: auto;
}

.command-card-description {
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.command-card-meta {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  padding-top: 7px;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.72rem;
}

.command-card-meta span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.commands-state-card {
  padding: 20px 16px;
  border: 1px dashed var(--border);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text-muted);
  font-size: 0.86rem;
  line-height: 1.5;
  text-align: center;
}

.commands-state-card--error {
  color: #991b1b;
  border-color: #fecaca;
  background: #fff7f7;
}

.commands-retry {
  min-height: 44px;
  margin: 14px auto 0;
  color: #fff;
  background: var(--indigo);
}

.commands-more {
  width: 100%;
  min-height: 48px;
  margin-top: 4px;
  color: var(--indigo);
  background: var(--surface);
  border: 1px solid rgba(99, 102, 241, 0.3);
}

.command-detail-card {
  border-left: 5px solid var(--command-tone, var(--amber));
}

.command-detail-grid {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin-top: 12px;
  border-top: 1px solid var(--border);
}

.command-detail-row {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
}

.command-detail-label {
  color: var(--text-hint);
  font-size: 0.68rem;
  font-weight: 750;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.command-detail-value {
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.command-machine {
  color: var(--blue);
}

.command-text-section {
  margin-top: 14px;
}

.command-text-section h3 {
  margin: 0 0 6px;
  color: var(--text-muted);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.command-text-section > p {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 0.88rem;
}

.command-notes li {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--surface-alt);
  font-size: 0.82rem;
  white-space: pre-wrap;
}

.command-notes li + li {
  margin-top: 6px;
}

.command-rejection {
  padding: 10px 12px;
  border: 1px solid #fecaca;
  border-radius: 12px;
  background: #fef2f2;
  color: #991b1b;
}

.command-parts-section h2,
.command-close-form h2 {
  margin-bottom: 6px;
}

.command-parts li {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 8px;
  align-items: baseline;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.8rem;
}

.command-parts li:last-child {
  border-bottom: none;
}

.command-part-qty {
  color: var(--indigo);
  font-weight: 750;
  white-space: nowrap;
}

.command-close-steps {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 14px;
}

.command-close-steps span {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: #eef2ff;
  color: #64748b;
  font-size: 0.72rem;
  font-weight: 750;
}

.command-close-steps span.is-active {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #fff;
}

.command-close-steps span.is-done {
  background: #dcfce7;
  color: #166534;
}

.command-checklist {
  min-width: 0;
  margin: 12px 0 16px;
  padding: 0;
  border: 0;
}

.command-checklist-legend {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  margin-bottom: 10px;
  padding: 0;
  font-size: 0.78rem;
  font-weight: 800;
}

.command-checklist-progress {
  min-width: 42px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #eef2ff;
  color: var(--indigo);
  font-size: 0.7rem;
  font-weight: 800;
  text-align: center;
}

.command-checklist-meter {
  height: 6px;
  margin: 0 0 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #e2e8f0;
}

.command-checklist-meter-fill {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #22c55e, #16a34a);
  transition: width 0.2s ease;
}

.command-checklist-items {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.command-check-item {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(248, 250, 252, 0.96));
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.03);
}

.command-check-item.is-answered {
  border-color: rgba(34, 197, 94, 0.35);
  box-shadow: 0 0 0 1px rgba(34, 197, 94, 0.08);
}

.command-check-head {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  margin-bottom: 12px;
}

.command-check-index {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 9px;
  background: #e2e8f0;
  color: #334155;
  font-size: 0.75rem;
  font-weight: 800;
}

.command-check-item.is-answered .command-check-index {
  background: #dcfce7;
  color: #166534;
}

.command-check-head > p {
  margin: 2px 0 0;
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 650;
  line-height: 1.35;
}

.command-check-result {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  width: 100%;
  justify-items: stretch;
}

.command-check-choice {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 48px;
  margin: 0;
  padding: 0 6px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-align: center;
  cursor: pointer;
}

.command-check-choice > span {
  display: block;
  width: 100%;
  text-align: center;
  line-height: 1.1;
}

.command-check-choice input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.command-check-choice.is-selected {
  transform: translateY(-1px);
}

.command-check-choice--ok.is-selected {
  border-color: #16a34a;
  background: #dcfce7;
  color: #166534;
  box-shadow: 0 4px 12px rgba(22, 163, 74, 0.18);
}

.command-check-choice--nok.is-selected {
  border-color: #dc2626;
  background: #fee2e2;
  color: #991b1b;
  box-shadow: 0 4px 12px rgba(220, 38, 38, 0.16);
}

.command-check-choice--nd.is-selected {
  border-color: #64748b;
  background: #e2e8f0;
  color: #334155;
  box-shadow: 0 4px 12px rgba(100, 116, 139, 0.16);
}

.command-nok-comment {
  margin-top: 10px;
  color: #991b1b;
  font-size: 0.78rem;
  font-weight: 700;
}

.command-nok-comment textarea {
  margin: 6px 0 0;
  background: #fff;
}

.command-close-form {
  padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
}

.command-close-form > .muted {
  margin: 0 0 12px;
}

.command-close-form label {
  display: block;
  margin: 0 0 6px;
  font-size: 0.82rem;
  font-weight: 650;
}

.command-close-form #command-close-mii {
  width: 100%;
  margin: 0 0 12px;
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  font: inherit;
}

.command-close-form textarea {
  min-height: 104px;
  margin-bottom: 12px;
}

.command-close-actions {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 8px;
  margin-top: 4px;
}

.command-close-form > .command-close-submit {
  width: 100%;
}

.command-form-error {
  margin: -4px 0 10px;
  color: #b91c1c;
  font-size: 0.8rem;
  font-weight: 650;
}

.command-close-secondary {
  width: 100%;
  min-height: 54px;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--border);
  box-shadow: none;
}

.command-close-submit {
  width: 100%;
  min-height: 54px;
  color: #fff;
  background: linear-gradient(135deg, var(--amber), #d97706);
  box-shadow: 0 6px 18px rgba(245, 158, 11, 0.3);
}

.command-close-submit:disabled {
  opacity: 0.55;
  box-shadow: none;
}

.command-close-submit.is-loading:disabled {
  opacity: 1;
}

.command-documents-section {
  overflow: hidden;
}

.command-documents-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.command-documents-head h2 {
  margin: 0 0 3px;
}

.command-documents-head .muted {
  margin: 0;
}

.command-documents-count {
  flex-shrink: 0;
  min-width: 38px;
  padding: 4px 9px;
  border-radius: 999px;
  background: #eef2ff;
  color: var(--indigo);
  font-size: 0.72rem;
  font-weight: 800;
  text-align: center;
}

.command-documents-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.command-document-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 58px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-alt);
  color: var(--text);
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.command-document-thumb {
  width: 46px;
  height: 46px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: 9px;
  background: #e2e8f0;
  color: var(--text-muted);
  font-size: 0.62rem;
  font-weight: 850;
}

.command-document-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.command-mds-row {
  border-color: color-mix(in srgb, #6366f1 35%, var(--border));
  background: color-mix(in srgb, #6366f1 8%, var(--surface-alt));
  text-decoration: none;
}

.command-mds-thumb {
  background: #e0e7ff;
  color: #4338ca;
}

.command-document-info {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.command-document-info strong {
  overflow: hidden;
  color: var(--text);
  font-size: 0.82rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.command-document-info small {
  color: var(--text-muted);
  font-size: 0.7rem;
}

.command-document-empty {
  padding: 14px 12px;
  border: 1px dashed var(--border);
  border-radius: 12px;
  color: var(--text-muted);
  font-size: 0.8rem;
  text-align: center;
}

.command-document-error {
  border-color: #fecaca;
  background: #fff7f7;
  color: #991b1b;
}

.command-document-upload {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.command-document-input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.command-document-source {
  min-height: 48px;
  padding-inline: 10px;
  border: 1px solid rgba(99, 102, 241, 0.28);
  background: #eef2ff;
  color: var(--indigo);
  font-size: 0.8rem;
}

.command-document-help {
  grid-column: 1 / -1;
  margin: 0;
  color: var(--text-hint);
  font-size: 0.7rem;
  line-height: 1.4;
}

body.document-viewer-open {
  overflow: hidden;
}

body.document-viewer-open .toast {
  z-index: 1500;
}

.document-viewer {
  position: fixed;
  inset: 0;
  z-index: 1400;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  padding: env(safe-area-inset-top, 0) 0 env(safe-area-inset-bottom, 0);
  background: rgba(2, 6, 23, 0.98);
  color: #fff;
}

.document-viewer.hidden {
  display: none !important;
}

.document-viewer-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 58px;
  padding: 8px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
}

.document-viewer-bar strong {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  font-size: 0.9rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.document-viewer-close {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font-size: 1.1rem;
  cursor: pointer;
}

.document-viewer-stage {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.document-viewer-stage img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.document-viewer-stage iframe {
  width: 100%;
  height: 100%;
  border: 0;
  background: #fff;
}

.document-viewer-file-icon {
  font-size: 4rem;
}

.document-viewer-download {
  margin-top: 18px;
  min-height: 48px;
  background: #fff;
  color: var(--indigo);
}

.document-viewer-status {
  min-height: 1.25rem;
  margin: 0;
  padding: 8px 16px;
  color: #cbd5e1;
  font-size: 0.76rem;
  text-align: center;
}

.document-viewer-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  padding: 10px 16px 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
}

.document-upload-confirm {
  min-height: 52px;
  background: linear-gradient(135deg, var(--indigo), #818cf8);
  color: #fff;
  font-weight: 800;
}

.document-upload-confirm.is-loading:disabled {
  opacity: 1;
}

.document-upload-cancel {
  min-height: 44px;
  background: transparent;
  color: #cbd5e1;
}

.module-nav-btn[data-module="polecenia"].active {
  color: #b45309;
  background: rgba(245, 158, 11, 0.12);
  border-color: rgba(245, 158, 11, 0.3);
}

body.command-detail-open .app-main,
body.am-form-open .app-main {
  padding-bottom: calc(96px + env(safe-area-inset-bottom, 0px));
}

.am-reports-shell,
.am-report-form-shell {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.am-reports-shell .detail-nav,
.am-report-form-shell .detail-nav {
  align-items: center;
}

.am-new-btn {
  flex-shrink: 0;
  min-height: 36px;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(135deg, #8b5cf6, #6366f1);
  border: 0;
}

.am-reports-status {
  margin: 0 4px;
  font-size: 0.82rem;
}

.am-reports-filters {
  margin: 4px 4px 10px;
}

.am-reports-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.am-report-card {
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 12px;
  align-items: start;
  width: 100%;
  text-align: left;
  padding: 12px;
  border-radius: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  color: inherit;
}

.am-report-cover {
  width: 56px;
  height: 56px;
  border-radius: 12px;
  object-fit: cover;
  background: rgba(139, 92, 246, 0.12);
}

.am-report-cover-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: #7c3aed;
}

.am-report-card-body {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.am-report-card-title {
  font-size: 0.95rem;
  font-weight: 800;
  line-height: 1.25;
}

.am-report-card-meta {
  font-size: 0.74rem;
  color: var(--text-muted);
  font-weight: 600;
}

.am-report-card-excerpt {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.am-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.am-chip {
  min-height: 40px;
  padding: 8px 14px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.86rem;
  color: var(--text);
  background: var(--input-bg, #f8fafc);
  border: 1px solid var(--border);
}

.am-chip.is-active {
  color: #5b21b6;
  background: rgba(139, 92, 246, 0.16);
  border-color: #8b5cf6;
}

.am-machine-selected {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(34, 197, 94, 0.1);
  border: 1px solid rgba(34, 197, 94, 0.28);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.am-duration-input,
.am-precise-fields input[type="datetime-local"],
#am-analiza-input,
#am-dzialania-input {
  width: 100%;
}

.am-precise-toggle {
  margin-top: 12px;
}

.am-precise-fields {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.am-photos-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.am-photo-thumb {
  position: relative;
  width: 84px;
  height: 84px;
  border-radius: 12px;
  overflow: hidden;
  background: #e2e8f0;
}

.am-photo-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.am-photo-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.72);
  color: #fff;
  font-size: 0.85rem;
  line-height: 1;
}

.am-photo-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

@media (max-width: 390px) {
  .module-nav {
    gap: 4px;
    padding-inline: 6px;
  }

  .module-nav-btn {
    padding-inline: 3px;
  }

  .module-nav-btn .module-nav-label {
    font-size: 0.56rem;
  }

  .command-card-meta {
    grid-template-columns: 1fr;
    gap: 3px;
  }
}

/* ── Raporty UR (lista) ───────────────────────────────────────────────────── */

.ur-new-btn {
  flex-shrink: 0;
  min-height: 36px;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(135deg, #0ea5e9, #0284c7);
  border: 0;
}

.ur-always-filters {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0 4px 4px;
}

.ur-period-field {
  margin: 0;
}

.ur-custom-dates {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.ur-report-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.ur-status-badge {
  flex-shrink: 0;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.18);
  color: var(--text-muted);
}

.ur-status-badge--draft {
  background: rgba(245, 158, 11, 0.16);
  color: #d97706;
}

.ur-status-badge--final {
  background: rgba(34, 197, 94, 0.16);
  color: #16a34a;
}

.ur-report-cover-fallback {
  background: rgba(14, 165, 233, 0.12);
  color: #0284c7;
}

body.ur-form-open .app-main {
  padding-bottom: calc(140px + env(safe-area-inset-bottom, 0px));
}

.ur-readonly-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}

.ur-readonly-grid > div {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.ur-readonly-grid strong {
  font-size: 0.92rem;
  word-break: break-word;
}

.ur-ro-opis-label {
  display: block;
  margin-bottom: 4px;
}

.ur-ro-opis {
  margin: 0;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(148, 163, 184, 0.12);
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.88rem;
}

.ur-form-select,
#ur-autor-input,
#ur-czas-awarii-input,
#ur-opis-problemu,
#ur-opis-dzialan,
#ur-przyczyna,
#ur-zapobiegawcze,
#ur-uwagi {
  width: 100%;
  margin-bottom: 10px;
}

.ur-form-action-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

@media (min-width: 420px) {
  .ur-form-action-row {
    grid-template-columns: 0.8fr 1fr 1fr;
  }

  .ur-form-action-row.ur-form-actions--final-only {
    grid-template-columns: 0.8fr 1.2fr;
  }
}

.ur-save-draft-btn {
  min-height: 44px;
  font-weight: 700;
  border: 1px solid rgba(14, 165, 233, 0.35);
  background: rgba(14, 165, 233, 0.12);
  color: #0369a1;
}

.ur-save-draft-btn.hidden {
  display: none;
}

#ur-filters-card {
  margin: 0 4px 8px;
}

/* ── Raporty PROD/UR — podgląd read-only (detail) ─────────────────────────── */

.ur-report-detail-shell,
.am-report-detail-shell {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
}

.report-detail-content {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 0 4px 8px;
}

.report-detail-hero {
  margin: 0 4px;
  padding: 14px 14px 12px;
  border-radius: 16px;
  background: linear-gradient(145deg, rgba(14, 165, 233, 0.14), rgba(99, 102, 241, 0.08));
  border: 1px solid rgba(148, 163, 184, 0.22);
}

.report-detail-hero-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.report-detail-hero-title {
  font-size: 1.05rem;
  font-weight: 800;
  line-height: 1.25;
  word-break: break-word;
}

.report-detail-hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.report-detail-chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
}

.report-status-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  background: rgba(100, 116, 139, 0.15);
  color: #475569;
}

.report-status-badge--draft {
  background: rgba(249, 115, 22, 0.15);
  color: #c2410c;
}

.report-status-badge--final {
  background: rgba(34, 197, 94, 0.15);
  color: #15803d;
}

.report-detail-grid {
  display: grid;
  gap: 10px;
  margin: 0 4px;
  padding: 12px;
  border-radius: 14px;
  background: rgba(148, 163, 184, 0.08);
}

.report-detail-row {
  display: grid;
  grid-template-columns: minmax(110px, 38%) 1fr;
  gap: 8px;
  align-items: start;
}

.report-detail-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.report-detail-value {
  font-size: 0.92rem;
  line-height: 1.35;
  word-break: break-word;
  white-space: pre-wrap;
}

.report-detail-text {
  margin: 0 4px;
  padding: 12px 14px;
}

.report-detail-text h3 {
  margin: 0 0 8px;
  font-size: 0.92rem;
}

.report-detail-text p {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.45;
}

.report-detail-gallery-host {
  margin: 0 4px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.report-detail-cover-wrap {
  position: relative;
}

.report-detail-cover-btn {
  display: block;
  width: 100%;
  padding: 0;
  border: none;
  background: transparent;
  cursor: default;
  text-align: inherit;
}

.report-detail-cover-btn:not(:disabled) {
  cursor: zoom-in;
}

.report-detail-cover-btn:not(:disabled):active {
  opacity: 0.92;
}

.report-detail-cover {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  border-radius: 14px;
  background: rgba(148, 163, 184, 0.12);
}

.report-detail-cover-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #94a3b8;
  font-size: 0.88rem;
  font-weight: 600;
}

.report-detail-gallery {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.report-detail-thumb {
  flex: 0 0 auto;
  width: 72px;
  height: 72px;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 10px;
  overflow: hidden;
  background: rgba(148, 163, 184, 0.12);
  cursor: pointer;
}

.report-detail-thumb.is-active {
  border-color: var(--indigo);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.25);
}

.report-detail-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.report-detail-footer {
  position: sticky;
  bottom: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: auto;
  margin-left: -4px;
  margin-right: -4px;
  padding: 12px 12px calc(12px + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.65) 0%,
    rgba(255, 255, 255, 0.94) 32%,
    #ffffff 100%
  );
  backdrop-filter: blur(20px) saturate(1.35);
  -webkit-backdrop-filter: blur(20px) saturate(1.35);
  border-top: 1px solid var(--border);
  box-shadow: 0 -8px 28px rgba(15, 23, 42, 0.08);
}

.report-detail-edit-btn {
  width: 100%;
  min-height: 48px;
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 0.01em;
  border: none;
  border-radius: 14px;
  color: #fff;
  background: linear-gradient(135deg, var(--indigo) 0%, #4f46e5 100%);
  box-shadow: 0 6px 18px rgba(99, 102, 241, 0.28);
}

.report-detail-edit-btn:active:not(:disabled) {
  transform: scale(0.985);
}

.report-detail-edit-btn:disabled {
  opacity: 0.45;
  box-shadow: none;
}

.report-detail-readonly-note {
  margin: 0;
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-muted);
}

body.ur-detail-open .app-main,
body.am-detail-open .app-main {
  padding-bottom: calc(96px + env(safe-area-inset-bottom, 0px));
}

body.report-photo-lightbox-open {
  overflow: hidden;
}

.report-photo-lightbox {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(12px + env(safe-area-inset-top, 0px)) 12px calc(12px + env(safe-area-inset-bottom, 0px));
  background: rgba(15, 23, 42, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.report-photo-lightbox.hidden {
  display: none;
}

.report-photo-lightbox-close {
  position: absolute;
  top: calc(10px + env(safe-area-inset-top, 0px));
  right: 12px;
  z-index: 2;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 1.25rem;
  cursor: pointer;
}

.report-photo-lightbox-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}
