/* ============================================================================
   PLI CMMS - Shop-Floor UI & Micro-Interactions (Pure CSS3 + SVG)
   ============================================================================ */
:root {
  --bg: #f1f5f9;
  --bg-soft: #e2e8f0;
  --surface: #ffffff;
  --surface-alt: #f8fafc;
  --border: #cbd5e1;
  --border-soft: #e2e8f0;
  --text: #0f172a;
  --text-2: #334155;
  --muted: #64748b;

  --primary: #1d4ed8;
  --primary-dark: #1e40af;
  --primary-soft: #eff6ff;
  --primary-ring: rgba(29, 78, 216, 0.22);

  --green: #059669;
  --green-soft: #ecfdf5;
  --green-border: #6ee7b7;

  --yellow: #d97706;
  --yellow-soft: #fffbeb;
  --yellow-border: #fcd34d;

  --red: #dc2626;
  --red-soft: #fef2f2;
  --red-border: #fca5a5;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.16);

  --radius: 14px;
  --radius-sm: 10px;
  --nav-height: 66px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
  padding-bottom: calc(var(--nav-height) + env(safe-area-inset-bottom) + 24px);
}

body.modal-open {
  position: fixed;
  width: 100%;
  left: 0;
  right: 0;
  overflow: hidden;
}

.hidden {
  display: none !important;
}

/* ---------- Header ---------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border-soft);
  box-shadow: var(--shadow-sm);
}

.header-inner {
  max-width: 920px;
  margin: 0 auto;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: linear-gradient(135deg, #1d4ed8, #0f172a);
  color: #ffffff;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}

.brand-text {
  min-width: 0;
}

.brand-title {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 800;
  letter-spacing: -0.015em;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-sub {
  margin: 0;
  font-size: 0.69rem;
  color: var(--muted);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.conn-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 8px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  white-space: nowrap;
  background: var(--surface-alt);
  border: 1px solid var(--border-soft);
  color: var(--text-2);
}

.pulse-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--green);
  position: relative;
  flex-shrink: 0;
}

.pulse-dot::after {
  content: "";
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  border: 2px solid currentColor;
  opacity: 0;
  animation: pulseDot 1.9s cubic-bezier(0.24, 0, 0.38, 1) infinite;
}

.conn-pill.is-online .pulse-dot {
  background: var(--green);
  color: var(--green);
}

.conn-pill.is-syncing .pulse-dot {
  background: var(--yellow);
  color: var(--yellow);
}

.conn-pill.is-offline .pulse-dot {
  background: var(--red);
  color: var(--red);
}

@keyframes pulseDot {
  0% {
    transform: scale(0.7);
    opacity: 0.85;
  }
  70% {
    transform: scale(1.7);
    opacity: 0;
  }
  100% {
    transform: scale(1.7);
    opacity: 0;
  }
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--border-soft);
  background: var(--surface);
  color: var(--text-2);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform 0.12s ease, background-color 0.15s ease, border-color 0.15s ease;
}

@media (min-width: 480px) {
  .header-inner { padding: 10px 14px; gap: 10px; }
  .brand { gap: 10px; }
  .brand-mark { width: 38px; height: 38px; border-radius: 10px; }
  .brand-title { font-size: 1rem; }
  .brand-sub { font-size: 0.74rem; }
  .header-right { gap: 8px; }
  .conn-pill { padding: 6px 10px; font-size: 0.75rem; gap: 6px; }
  .icon-btn { width: 40px; height: 40px; }
}

.icon-btn:active {
  transform: scale(0.94);
  background: var(--primary-soft);
  border-color: var(--primary);
}

.icon-btn.is-spinning svg {
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ---------- Navigation (Bottom on Mobile, Top on Tablet/Desktop) ---------- */
.main-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 45;
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--border-soft);
  box-shadow: 0 -4px 16px rgba(15, 23, 42, 0.08);
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
}

.nav-inner {
  max-width: 920px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.nav-inner.nav-inner-2 {
  grid-template-columns: repeat(2, 1fr);
}

.nav-btn {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  border-radius: 11px;
  padding: 7px 4px;
  min-height: 50px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.12s ease, background-color 0.16s ease, color 0.16s ease, border-color 0.16s ease;
}

.nav-btn svg {
  width: 20px;
  height: 20px;
}

.nav-btn:active {
  transform: scale(0.95);
}

.nav-btn.is-active {
  background: var(--primary-soft);
  color: var(--primary);
  border-color: rgba(29, 78, 216, 0.22);
}

@media (min-width: 768px) {
  body {
    padding-bottom: 36px;
  }

  .main-nav {
    position: sticky;
    top: 59px;
    bottom: auto;
    border-top: none;
    border-bottom: 1px solid var(--border-soft);
    box-shadow: none;
    padding: 8px 14px;
  }

  .nav-btn {
    flex-direction: row;
    gap: 8px;
    font-size: 0.88rem;
    min-height: 44px;
  }
}

/* ---------- Main Container & Views ---------- */
.container {
  max-width: 920px;
  margin: 0 auto;
  padding: 14px 12px 24px;
}

.tab-panel {
  display: none;
  animation: fadePanel 0.2s ease;
}

.tab-panel.is-active {
  display: block;
}

@keyframes fadePanel {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ---------- Cards & Banners ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 12px;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}

.card-head--wrap {
  flex-wrap: wrap;
  row-gap: 8px;
}

.card-title-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
}

.card-title {
  margin: 0;
  font-size: 0.96rem;
  font-weight: 800;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.step-badge {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 7px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 0.78rem;
  font-weight: 800;
  flex-shrink: 0;
}

.form-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.progress-wrap {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  padding: 8px 12px;
  box-shadow: var(--shadow-sm);
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-2);
  margin-bottom: 5px;
}

.progress-track {
  height: 7px;
  border-radius: 999px;
  background: var(--bg-soft);
  overflow: hidden;
}

.step-progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, #2563eb, #059669);
  transition: width 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

.edit-banner {
  background: #eff6ff;
  border: 1.5px solid #93c5fd;
  color: #1e3a8a;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.84rem;
  font-weight: 700;
}

.warn-banner {
  background: var(--yellow-soft);
  border: 1.5px solid var(--yellow-border);
  color: #92400e;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-top: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.82rem;
  font-weight: 600;
}

.suggest-box {
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-top: 10px;
  font-size: 0.82rem;
  color: #0c4a6e;
}

.suggest-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

/* ---------- Form Grids & Fields ---------- */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.grid-3 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

@media (min-width: 600px) {
  .grid-2 {
    grid-template-columns: repeat(2, 1fr);
  }
  .grid-3 {
    grid-template-columns: repeat(3, 1fr);
  }
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.field label,
.field-label {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-2);
  display: flex;
  align-items: center;
  justify-content: flex-start;
  flex-wrap: wrap;
  gap: 3px;
}

.req-star {
  color: var(--red);
  margin-left: 2px;
}

.input,
.select,
.textarea {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 0.96rem;
  font-weight: 600;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background-color 0.16s ease;
}

.textarea {
  min-height: 78px;
  resize: vertical;
  font-weight: 500;
}

.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-ring);
}

.input[readonly] {
  background: var(--surface-alt);
  color: var(--text-2);
  border-style: dashed;
}

.input-row {
  display: flex;
  align-items: stretch;
  gap: 6px;
}

.input-row .input {
  flex: 1;
  min-width: 0;
}

.hint-text {
  font-size: 0.74rem;
  color: var(--muted);
}

.error-msg {
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--red);
  min-height: 0;
}

.field.has-error .input,
.field.has-error .select,
.field.has-error .textarea,
.field.has-error .chip-row {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.14);
}

.field.is-shaking {
  animation: fieldShake 0.36s ease;
}

@keyframes fieldShake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  45% { transform: translateX(6px); }
  70% { transform: translateX(-4px); }
  85% { transform: translateX(4px); }
}

/* ---------- Tactile Chips & Cards ---------- */
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  border-radius: var(--radius-sm);
}

.chip-row.cols-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
}

.chip-row.cols-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
}

.chip-row.cols-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
}

.chip-btn {
  appearance: none;
  min-height: 46px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  transition: transform 0.1s ease, background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

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

.chip-btn.is-selected {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary-dark);
  box-shadow: 0 0 0 2px var(--primary-ring);
}

.chip-btn.status-open.is-selected {
  background: var(--red-soft);
  border-color: var(--red);
  color: #991b1b;
  box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.2);
}

.chip-btn.status-close.is-selected {
  background: var(--green-soft);
  border-color: var(--green);
  color: #065f46;
  box-shadow: 0 0 0 2px rgba(5, 150, 105, 0.2);
}

.chip-btn.status-temp.is-selected {
  background: var(--yellow-soft);
  border-color: var(--yellow);
  color: #92400e;
  box-shadow: 0 0 0 2px rgba(217, 119, 6, 0.2);
}

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

.jenis-card {
  appearance: none;
  min-height: 54px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  transition: transform 0.1s ease, border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
}

.jenis-card:active {
  transform: scale(0.97);
}

.jenis-card strong {
  font-size: 0.84rem;
}

.jenis-card span {
  font-size: 0.72rem;
  color: var(--muted);
}

.jenis-card.is-selected {
  border-color: var(--primary);
  background: var(--primary-soft);
  box-shadow: 0 0 0 2px var(--primary-ring);
}

.jenis-card[data-value="Planned Downtime"].is-selected {
  border-color: #2563eb;
  background: #eff6ff;
}

.jenis-card[data-value="Unplanned Downtime"].is-selected {
  border-color: var(--red);
  background: var(--red-soft);
  box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.18);
}

.jenis-card[data-value="Minor Stop"].is-selected {
  border-color: var(--yellow);
  background: var(--yellow-soft);
  box-shadow: 0 0 0 2px rgba(217, 119, 6, 0.18);
}

.jenis-card[data-value="Persiapan Awal Produksi"].is-selected {
  border-color: var(--green);
  background: var(--green-soft);
  box-shadow: 0 0 0 2px rgba(5, 150, 105, 0.18);
}

/* ---------- Stepper Controls (+ / -) ---------- */
.stepper-group {
  display: flex;
  align-items: stretch;
  gap: 6px;
}

.step-btn {
  appearance: none;
  min-width: 48px;
  min-height: 46px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--surface-alt);
  color: var(--text);
  font-size: 1.25rem;
  font-weight: 800;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: transform 0.1s ease, background-color 0.14s ease, border-color 0.14s ease;
}

.step-btn:active {
  transform: scale(0.95);
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary);
}

.stepper-group .input {
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* ---------- Buttons ---------- */
.btn {
  appearance: none;
  border: 1.5px solid transparent;
  border-radius: var(--radius-sm);
  min-height: 46px;
  padding: 10px 16px;
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 800;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.1s ease, background-color 0.16s ease, box-shadow 0.16s ease, opacity 0.16s ease;
}

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

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
  box-shadow: 0 3px 10px rgba(29, 78, 216, 0.25);
  width: 100%;
  min-height: 52px;
  font-size: 0.98rem;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-dark);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text-2);
  border-color: var(--border);
}

.btn-soft {
  background: var(--primary-soft);
  color: var(--primary-dark);
  border-color: rgba(29, 78, 216, 0.22);
}

.btn-sm {
  min-height: 40px;
  padding: 7px 12px;
  font-size: 0.78rem;
  border-radius: 8px;
  white-space: nowrap;
  flex-shrink: 0;
}

.btn-spinner {
  display: none;
  width: 18px;
  height: 18px;
  border: 2.5px solid rgba(255, 255, 255, 0.35);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.btn.is-loading .btn-spinner {
  display: inline-block;
}

/* ---------- Live Telemetry & OEE Animated Gauge ---------- */
.oee-hero {
  background: linear-gradient(145deg, #ffffff 0%, #f8fafc 100%);
  border: 1.5px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-md);
}

.oee-hero-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  align-items: center;
}

@media (min-width: 600px) {
  .oee-hero-grid {
    grid-template-columns: 170px 1fr;
  }
}

.gauge-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.gauge-svg-wrap {
  position: relative;
  width: 152px;
  height: 152px;
}

.gauge-svg {
  width: 152px;
  height: 152px;
  transform: rotate(-90deg);
}

.gauge-track {
  fill: none;
  stroke: var(--bg-soft);
  stroke-width: 13;
}

.gauge-arc {
  fill: none;
  stroke: var(--muted);
  stroke-width: 13;
  stroke-linecap: round;
  stroke-dasharray: 376.99;
  stroke-dashoffset: 376.99;
  transition: stroke-dashoffset 0.45s cubic-bezier(0.22, 1, 0.36, 1), stroke 0.3s ease;
}

.gauge-box.tone-red .gauge-arc { stroke: var(--red); }
.gauge-box.tone-yellow .gauge-arc { stroke: var(--yellow); }
.gauge-box.tone-green .gauge-arc { stroke: var(--green); }
.gauge-box.tone-neutral .gauge-arc { stroke: #94a3b8; }

.gauge-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.gauge-label {
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.gauge-value {
  font-size: 1.55rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
  color: var(--text);
}

.gauge-box.tone-red .gauge-value { color: var(--red); }
.gauge-box.tone-yellow .gauge-value { color: var(--yellow); }
.gauge-box.tone-green .gauge-value { color: var(--green); }

.gauge-status-pill {
  margin-top: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 800;
  background: var(--bg-soft);
  color: var(--text-2);
}

.gauge-box.tone-red .gauge-status-pill { background: var(--red-soft); color: #991b1b; }
.gauge-box.tone-yellow .gauge-status-pill { background: var(--yellow-soft); color: #92400e; }
.gauge-box.tone-green .gauge-status-pill { background: var(--green-soft); color: #065f46; }

.metric-bars {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.metric-bar-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.metric-bar-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.82rem;
  font-weight: 700;
}

.metric-bar-head small {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
}

.metric-bar-track {
  height: 9px;
  border-radius: 999px;
  background: var(--bg-soft);
  overflow: hidden;
}

.metric-bar-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: var(--primary);
  transition: width 0.4s cubic-bezier(0.22, 1, 0.36, 1), background-color 0.25s ease;
}

.metric-bar-fill.tone-green { background: var(--green); }
.metric-bar-fill.tone-yellow { background: var(--yellow); }
.metric-bar-fill.tone-red { background: var(--red); }

.tele-strip {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.tele-item {
  background: var(--surface-alt);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  padding: 7px 8px;
  text-align: center;
}

.tele-item span {
  display: block;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--muted);
}

.tele-item strong {
  display: block;
  font-size: 0.96rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.tele-item.tone-green strong { color: var(--green); }
.tele-item.tone-yellow strong { color: var(--yellow); }
.tele-item.tone-red strong { color: var(--red); }

.preview-box {
  background: var(--surface-alt);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 0.82rem;
  color: var(--text-2);
  white-space: pre-line;
  word-break: break-word;
}

.id-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-size: 0.78rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  flex-shrink: 0;
}

.duration-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--text);
  font-size: 0.76rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ---------- Rekap List & Status Badges ---------- */
.subtabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-bottom: 10px;
}

.recap-list {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.recap-card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 12px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform 0.1s ease, border-color 0.15s ease;
}

.recap-card:active {
  transform: scale(0.985);
  border-color: var(--primary);
}

.recap-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 6px;
}

.recap-title {
  font-weight: 800;
  font-size: 0.92rem;
  color: var(--text);
}

.recap-sub {
  font-size: 0.78rem;
  color: var(--muted);
}

.recap-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 6px;
  font-size: 0.76rem;
  color: var(--text-2);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 800;
  white-space: nowrap;
}

.badge-green { background: var(--green-soft); color: #065f46; border: 1px solid var(--green-border); }
.badge-yellow { background: var(--yellow-soft); color: #92400e; border: 1px solid var(--yellow-border); }
.badge-red { background: var(--red-soft); color: #991b1b; border: 1px solid var(--red-border); }
.badge-blue { background: var(--primary-soft); color: var(--primary-dark); border: 1px solid #bfdbfe; }
.badge-gray { background: var(--bg-soft); color: var(--text-2); border: 1px solid var(--border); }

.empty-state {
  text-align: center;
  padding: 28px 14px;
  color: var(--muted);
  font-size: 0.88rem;
}

/* ---------- Bottom-Sheet Modal & Animated SVG Checkmark ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(15, 23, 42, 0.56);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
}

.modal-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}

.modal-sheet {
  width: 100%;
  max-width: 560px;
  max-height: 86vh;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  padding: 12px 16px calc(18px + env(safe-area-inset-bottom));
  box-shadow: var(--shadow-lg);
  transform: translateY(28px);
  transition: transform 0.26s cubic-bezier(0.22, 1, 0.36, 1);
}

.modal-backdrop.is-open .modal-sheet {
  transform: translateY(0);
}

@media (min-width: 600px) {
  .modal-backdrop {
    align-items: center;
    padding: 16px;
  }
  .modal-sheet {
    border-radius: 18px;
  }
}

.sheet-handle {
  width: 42px;
  height: 4px;
  border-radius: 999px;
  background: var(--border);
  margin: 0 auto 12px;
}

.success-anim {
  width: 64px;
  height: 64px;
  margin: 4px auto 10px;
  display: block;
}

.success-circle {
  fill: var(--green-soft);
  stroke: var(--green);
  stroke-width: 3;
  stroke-dasharray: 180;
  stroke-dashoffset: 180;
  animation: drawStroke 0.45s ease forwards;
}

.success-check {
  fill: none;
  stroke: var(--green);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 48;
  stroke-dashoffset: 48;
  animation: drawStroke 0.35s 0.22s ease forwards;
}

@keyframes drawStroke {
  to { stroke-dashoffset: 0; }
}

.modal-title {
  margin: 0 0 6px;
  font-size: 1.08rem;
  font-weight: 800;
  text-align: center;
}

.modal-body {
  font-size: 0.88rem;
  color: var(--text-2);
}

.detail-kv {
  display: grid;
  grid-template-columns: 128px 1fr;
  gap: 6px 10px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border-soft);
  font-size: 0.84rem;
}

.detail-kv span:first-child {
  color: var(--muted);
  font-weight: 700;
}

.detail-kv span:last-child {
  color: var(--text);
  font-weight: 600;
  word-break: break-word;
}

.modal-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-top: 14px;
}

@media (min-width: 460px) {
  .modal-actions.cols-2 {
    grid-template-columns: 1fr 1fr;
  }
}

/* ---------- Toast (Bottom positioned, never blocks sticky progress bar or Reset Draft) ---------- */
.toast-wrap {
  position: fixed;
  bottom: calc(var(--nav-height) + env(safe-area-inset-bottom) + 74px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  width: min(92vw, 440px);
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

@media (min-width: 768px) {
  .toast-wrap {
    top: auto;
    bottom: 24px;
    left: auto;
    right: 20px;
    transform: none;
    width: min(380px, 90vw);
  }
}

.toast {
  background: #0f172a;
  color: #ffffff;
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 0.84rem;
  font-weight: 700;
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
  animation: fadePanel 0.2s ease;
}

.toast.is-error { background: #991b1b; }
.toast.is-success { background: #065f46; }
.toast.is-warn { background: #92400e; }

/* ---------- Modal Scroll Lock & Close Header ---------- */
body.modal-open {
  overflow: hidden;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.modal-head .modal-title {
  margin: 0;
  text-align: left;
  flex: 1;
}

.modal-close-x {
  appearance: none;
  border: 1px solid var(--border-soft);
  background: var(--surface-alt);
  color: var(--text-2);
  width: 34px;
  height: 34px;
  border-radius: 9px;
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.modal-close-x:active {
  transform: scale(0.94);
}

/* ---------- Mode Separation (Form CMMS vs Data CMMS) ---------- */
.app-mode {
  display: none;
}

.app-mode.is-active {
  display: block;
  animation: fadePanel 0.18s ease;
}

body.mode-data .app-header {
  border-bottom: 2px solid #0d9488;
}

body.mode-data .brand-mark {
  background: linear-gradient(135deg, #0d9488, #0f766e);
}

.mode-tag {
  font-weight: 800;
  color: var(--primary);
}

body.mode-data .mode-tag {
  color: #0f766e;
}

body.mode-data .nav-btn[data-mode="data"].is-active {
  background: #f0fdfa;
  color: #0f766e;
  border-color: rgba(13, 148, 136, 0.28);
}

.mode-banner {
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  box-shadow: var(--shadow-sm);
}

.mode-banner h2 {
  margin: 0 0 2px;
  font-size: 1rem;
  font-weight: 800;
}

.mode-banner p {
  margin: 0;
  font-size: 0.78rem;
  opacity: 0.92;
}

.mode-banner--form {
  background: linear-gradient(135deg, #1d4ed8, #1e40af);
  color: #ffffff;
}

.mode-banner--data {
  background: linear-gradient(135deg, #0f766e, #0d9488);
  color: #ffffff;
}

.mode-pill-badge {
  background: rgba(255, 255, 255, 0.2);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.72rem;
  font-weight: 800;
  white-space: nowrap;
}

.btn-soft-teal {
  background: rgba(255, 255, 255, 0.96);
  color: #0f766e;
  border: 1px solid rgba(255, 255, 255, 0.6);
}

.btn-soft-teal:hover {
  background: #ffffff;
}

/* ---------- Launcher App Menu Grid (Form CMMS Home) ---------- */
.app-menu-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

@media (min-width: 768px) {
  .app-menu-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
  }
}

.menu-card {
  appearance: none;
  border: 1px solid var(--border-soft);
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px 12px;
  text-align: left;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.12s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}

.menu-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
}

.menu-card:active {
  transform: scale(0.97);
}

.menu-card-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
}

.menu-card-icon svg {
  width: 22px;
  height: 22px;
}

.menu-card-icon.tone-blue { background: #eff6ff; color: #1d4ed8; }
.menu-card-icon.tone-indigo { background: #eef2ff; color: #4338ca; }
.menu-card-icon.tone-emerald { background: #ecfdf5; color: #059669; }
.menu-card-icon.tone-amber { background: #fffbeb; color: #d97706; }
.menu-card-icon.tone-rose { background: #fff1f2; color: #e11d48; }

.menu-card-body strong {
  display: block;
  font-size: 0.94rem;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 3px;
}

.menu-card-body span {
  display: block;
  font-size: 0.74rem;
  color: var(--muted);
  line-height: 1.35;
}

/* ---------- Quick Form Switcher Strip ---------- */
.quick-form-strip {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  padding: 4px 2px 10px;
  scrollbar-width: none;
}

.quick-form-strip::-webkit-scrollbar {
  display: none;
}

.quick-pill {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  border-radius: 999px;
  padding: 7px 13px;
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
  flex-shrink: 0;
  min-height: 36px;
  transition: background-color 0.14s ease, border-color 0.14s ease, color 0.14s ease;
}

.quick-pill--home {
  background: var(--surface-alt);
  border-color: var(--border);
  color: var(--text);
}

.quick-pill.is-active {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
}

/* ---------- Quick Duration & Filter Mini Chips ---------- */
.quick-dur-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.mini-chip {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text-2);
  border-radius: 999px;
  padding: 5px 11px;
  font-size: 0.74rem;
  font-weight: 700;
  cursor: pointer;
  min-height: 30px;
  transition: background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.mini-chip:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.mini-chip.is-active {
  background: #0f766e;
  border-color: #0f766e;
  color: #ffffff;
}

/* ---------- Sticky Submit Bar Inside Forms ---------- */
.sticky-submit-bar {
  position: sticky;
  bottom: calc(var(--nav-height) + env(safe-area-inset-bottom) + 6px);
  z-index: 32;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-top: 12px;
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.12);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

@media (min-width: 768px) {
  .sticky-submit-bar {
    bottom: 12px;
  }
}

.sticky-meta {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
  flex-shrink: 0;
}

.sticky-meta span {
  font-size: 0.68rem;
  color: var(--muted);
  font-weight: 700;
  text-transform: uppercase;
}

.sticky-meta strong {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--primary);
}

.sticky-submit-bar .btn-primary {
  flex: 1;
}

/* ---------- Alerts & Card Header Extensions ---------- */
.alert-banner {
  margin-top: 10px;
  padding: 9px 12px;
  border-radius: 10px;
  background: var(--red-soft);
  border: 1px solid var(--red-border);
  color: #991b1b;
  font-size: 0.8rem;
  font-weight: 700;
}

.card-head--wrap {
  flex-wrap: wrap;
}

.card-title-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.card--data {
  border-top: 3px solid #0d9488;
}

/* ---------- Collapsible Followup Section (WO & Hold) ---------- */
.followup-details {
  width: 100%;
}

.followup-summary {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}

.followup-summary::-webkit-details-marker {
  display: none;
}

.followup-summary::after {
  content: "▾";
  font-size: 0.9rem;
  color: var(--muted);
  margin-left: 4px;
  transition: transform 0.18s ease;
}

.followup-details[open] .followup-summary::after {
  transform: rotate(180deg);
}

/* ---------- Photo Upload Preview Box ---------- */
.photo-upload-box {
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 10px;
  background: var(--surface-alt);
}

.photo-file-input {
  width: 100%;
  font-size: 0.84rem;
}

.photo-preview-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.photo-thumb {
  width: 74px;
  height: 74px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #ffffff;
}

.photo-meta {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--text-2);
}

/* ---------- Data CMMS Subtabs, Search & Compact Filter Drawer ---------- */
.subtabs-scroll {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 8px;
  margin-bottom: 10px;
  scrollbar-width: none;
}

.subtabs-scroll::-webkit-scrollbar {
  display: none;
}

.subtabs-scroll .chip-btn {
  flex: 0 0 auto;
  padding: 8px 13px;
  min-height: 38px;
}

body.mode-data .subtabs-scroll .chip-btn.is-selected {
  background: #0f766e;
  border-color: #0f766e;
  color: #ffffff;
}

.recap-search-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.recap-search-row .input {
  flex: 1;
}

.filter-count-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: #0f766e;
  color: #ffffff;
  font-size: 0.7rem;
  font-weight: 800;
  margin-left: 4px;
}

.recap-quick-chips {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.recap-status-hint {
  font-size: 0.74rem;
  color: var(--muted);
  margin-left: auto;
}

.recap-filter-drawer {
  display: none;
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px dashed var(--border-soft);
}

.recap-filter-drawer.is-open {
  display: block;
  animation: fadePanel 0.16s ease;
}

.recap-meta-item {
  display: inline-flex;
  align-items: center;
  background: var(--surface-alt);
  border: 1px solid var(--border-soft);
  border-radius: 6px;
  padding: 2px 7px;
  font-size: 0.73rem;
  font-weight: 600;
  color: var(--text-2);
}

@media (min-width: 460px) {
  .modal-actions.cols-2 > button:last-child:nth-child(odd) {
    grid-column: 1 / -1;
  }
}

/* ---------- Install App Button, Offline Outbox & Data Analytics ---------- */
.install-app-btn {
  min-height: 32px;
  padding: 4px 9px;
  font-size: 0.72rem;
  font-weight: 800;
}

.outbox-banner {
  background: var(--yellow-soft);
  border: 1px solid var(--yellow-border);
  color: #92400e;
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 0.82rem;
  font-weight: 700;
}

.card--analytics {
  border-left: 4px solid #0d9488;
  padding: 12px 14px;
}

.analytics-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.analytics-head strong {
  font-size: 0.86rem;
  color: var(--text);
}

.analytics-head span {
  font-size: 0.74rem;
  color: var(--muted);
  font-weight: 600;
}

.analytics-bars {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.analytics-row {
  display: grid;
  grid-template-columns: minmax(90px, 130px) 1fr 64px;
  align-items: center;
  gap: 8px;
  font-size: 0.75rem;
}

.analytics-label {
  color: var(--text-2);
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.analytics-bar-track {
  position: relative;
  height: 10px;
  border-radius: 999px;
  background: var(--bg-soft);
  overflow: hidden;
}

.analytics-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: #0d9488;
}

.analytics-bar-fill.is-target { background: var(--green); }
.analytics-bar-fill.is-warn { background: var(--yellow); }
.analytics-bar-fill.is-low { background: var(--red); }

.analytics-val {
  text-align: right;
  font-weight: 800;
  color: var(--text);
}

.recap-load-more {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
  margin-bottom: 6px;
}
