:root {
  --bg: #f3f6f4;
  --surface: #ffffff;
  --surface-alt: #f8faf9;
  --border: #dce3de;
  --text: #142019;
  --text-muted: #5a6b61;
  --primary: #14532d;
  --primary-hover: #166534;
  --primary-soft: #e8f3ec;
  --accent: #0f766e;
  --danger: #b91c1c;
  --danger-soft: #fef2f2;
  --warning: #b45309;
  --warning-soft: #fffbeb;
  --success: #15803d;
  --success-soft: #f0fdf4;
  --radius: 16px;
  --shadow: 0 1px 3px rgba(15, 35, 22, 0.04), 0 6px 20px rgba(15, 35, 22, 0.035);
  --shadow-hover: 0 10px 26px rgba(20, 83, 45, 0.09);
  --font: system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; font-family: var(--font); background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.5; overflow-x: clip; }
a { color: var(--primary); text-decoration: none; }
button, input, select, textarea { font-family: inherit; font-size: 14px; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* Layout Shell */
.app-shell { display: flex; min-height: 100vh; min-height: 100dvh; }
.sidebar-backdrop { display: none; position: fixed; inset: 0; background: rgba(10, 20, 14, 0.5); z-index: 55; }
.sidebar-backdrop.open { display: block; }
.sidebar {
  width: 256px; background: linear-gradient(180deg, #0f291a 0%, #091b11 100%); color: #e2ede6; display: flex; flex-direction: column;
  padding: 20px 14px; position: sticky; top: 0; height: 100vh; height: 100dvh; flex-shrink: 0;
  border-right: 1px solid rgba(255,255,255,0.06);
}
.brand {
  display: flex; align-items: center; justify-content: center;
  padding: 10px 12px; margin-bottom: 16px;
  background: #ffffff; border-radius: 12px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
}
.brand-logo { display: block; width: 100%; max-width: 204px; height: auto; object-fit: contain; }
.brand-badge {
  width: 36px; height: 36px; border-radius: 10px; background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%); color: #052e16;
  font-weight: 800; display: grid; place-items: center; font-size: 14px; flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(34, 197, 94, 0.25);
}
.brand-title { font-weight: 700; font-size: 15px; line-height: 1.2; color: #fff; letter-spacing: -0.2px; }
.brand-sub { font-size: 11px; color: #9ec0aa; }

.nav-list { display: flex; flex-direction: column; gap: 4px; flex: 1; overflow-y: auto; }
.sidebar-secondary { padding: 10px 0; border-top: 1px solid rgba(255,255,255,0.08); display: flex; flex-direction: column; gap: 4px; }
.nav-icon { width: 17px; height: 17px; flex-shrink: 0; opacity: 0.88; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px;
  color: #cde0d4; font-weight: 500; cursor: pointer; border: none; background: transparent;
  text-align: left; width: 100%; transition: background 0.16s ease, color 0.16s ease, transform 0.12s ease;
}
.nav-item:hover { background: rgba(255,255,255,0.08); color: #fff; }
.nav-item.active {
  background: rgba(34, 197, 94, 0.16); color: #fff; font-weight: 600;
  box-shadow: inset 3px 0 0 #4ade80;
}
.nav-item.active .nav-icon { opacity: 1; color: #4ade80; }

.sidebar-footer { padding-top: 12px; border-top: 1px solid rgba(255,255,255,0.12); font-size: 12px; color: #b9d4c2; }
.sidebar-version { margin-top: 6px; font-size: 11px; color: #9ec0aa; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

/* Full-screen focused login layout */
.app-shell.is-login {
  background:
    radial-gradient(circle at 18% 20%, rgba(34, 197, 94, 0.10), transparent 42%),
    radial-gradient(circle at 82% 80%, rgba(15, 118, 110, 0.10), transparent 42%),
    var(--bg);
}
.app-shell.is-login .sidebar,
.app-shell.is-login .sidebar-backdrop,
.app-shell.is-login .topbar { display: none !important; }
.app-shell.is-login .main-area { justify-content: center; align-items: center; min-height: 100vh; min-height: 100dvh; padding: 20px 12px; }
.app-shell.is-login .content { max-width: 440px; padding: 0; }
.app-shell.is-login .card { box-shadow: 0 16px 40px rgba(15, 35, 22, 0.08); }
.login-brand-header { display: flex; align-items: center; justify-content: center; margin-bottom: 16px; padding-bottom: 14px; border-bottom: 1px solid var(--border); }
.login-brand-logo { display: block; width: 100%; max-width: 260px; height: auto; object-fit: contain; }
.login-brand-header .brand-badge { width: 42px; height: 42px; font-size: 16px; }
.main-area { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  background: rgba(255, 255, 255, 0.86); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border); padding: 12px 24px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; position: sticky; top: 0; z-index: 20;
}
.topbar-left { display: flex; align-items: center; gap: 12px; }
.menu-toggle { display: none; align-items: center; gap: 6px; background: var(--surface-alt); border: 1px solid var(--border); border-radius: 10px; padding: 7px 12px; cursor: pointer; font-weight: 600; }
.page-title { font-size: 18px; font-weight: 700; margin: 0; }
.content { padding: 20px 24px; max-width: 1400px; width: 100%; margin: 0 auto; }

/* Cards & Grids */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); margin-bottom: 16px; }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card-title { font-size: 16px; font-weight: 700; margin: 0; }

.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-bottom: 16px; }
.kpi-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease; }
.kpi-card.clickable { cursor: pointer; }
.kpi-card.clickable:hover { transform: translateY(-2px); border-color: #86efac; box-shadow: var(--shadow-hover); }
.kpi-label { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); font-weight: 700; }
.kpi-value { font-size: 28px; font-weight: 800; margin: 6px 0 4px; color: var(--text); font-variant-numeric: tabular-nums; letter-spacing: -0.5px; }
.kpi-sub { font-size: 12px; color: var(--text-muted); }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }

/* Controls & Forms */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.input, .select, .textarea {
  padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; background: #fff; color: var(--text);
  outline: none; transition: border-color 0.15s; min-height: 40px; width: 100%;
}
.toolbar .input, .toolbar .select { width: auto; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(20, 83, 45, 0.12); }
.textarea { width: 100%; min-height: 80px; resize: vertical; }
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.field label { font-size: 13px; font-weight: 600; color: var(--text); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 15px;
  border-radius: 10px; border: 1px solid transparent; font-weight: 600; cursor: pointer; min-height: 40px;
  transition: all 0.16s cubic-bezier(0.2, 0.8, 0.2, 1); white-space: nowrap;
}
.btn:active:not(:disabled) { transform: scale(0.985); }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 1px 2px rgba(20, 83, 45, 0.18); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--surface-alt); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: #e8eeea; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 5px 10px; font-size: 12px; min-height: 32px; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

/* Badges */
.badge {
  display: inline-flex; align-items: center; padding: 3px 9px; border-radius: 999px;
  font-size: 11px; font-weight: 700; letter-spacing: 0.2px; white-space: nowrap;
}
.badge-normal, .badge-success { background: var(--success-soft); color: var(--success); border: 1px solid #bbf7d0; }
.badge-abnormal { background: var(--warning-soft); color: var(--warning); border: 1px solid #fde68a; }
.badge-mati { background: var(--danger-soft); color: var(--danger); border: 1px solid #fecaca; }
.badge-muted { background: #eef2ef; color: #475569; border: 1px solid #d5ddd8; }
.badge-info { background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; }

/* Tables */
.table-wrap { overflow: auto; max-height: 68vh; border: 1px solid var(--border); border-radius: 12px; background: #fff; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { padding: 11px 13px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { position: sticky; top: 0; z-index: 2; background: var(--surface-alt); font-weight: 700; color: var(--text-muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.4px; white-space: nowrap; box-shadow: inset 0 -1px 0 var(--border); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #f4f8f5; }
.pagination { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 12px; flex-wrap: wrap; }

/* Progress bars & Trend chart */
.bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; padding: 4px 6px; border-radius: 6px; }
.bar-row.clickable { cursor: pointer; }
.bar-row.clickable:hover { background: var(--surface-alt); }
.bar-label { width: 130px; font-size: 13px; font-weight: 600; flex-shrink: 0; }
.bar-track { flex: 1; height: 10px; background: #e8eeea; border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--primary); border-radius: 999px; }
.bar-val { width: 75px; text-align: right; font-size: 13px; font-weight: 600; }

.trend-chart { display: flex; align-items: flex-end; gap: 4px; height: 110px; padding: 10px 4px 4px; border-bottom: 1px solid var(--border); }
.trend-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; min-width: 6px; }
.trend-bar { width: 100%; background: var(--primary); border-radius: 3px 3px 0 0; min-height: 2px; transition: height 0.2s; }
.trend-bar:hover { background: var(--accent); }

/* Mobile Operator & Wizard */
.operator-container { max-width: 520px; margin: 0 auto; }
.scanner-box {
  position: relative; width: 100%; aspect-ratio: 1; max-height: 350px; background: #0f172a;
  border-radius: 12px; overflow: hidden; display: grid; place-items: center; color: #cbd5e1;
}
.scanner-box video { width: 100%; height: 100%; object-fit: cover; }
.scanner-frame {
  position: absolute; width: 65%; height: 65%; border: 3px solid #22c55e; border-radius: 16px;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.42); pointer-events: none;
}

.wizard-steps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 14px; }
.wizard-pill {
  text-align: center; padding: 7px 4px; border-radius: 8px; font-size: 11.5px; font-weight: 700;
  background: #e8eeea; color: var(--text-muted); cursor: pointer; border: 1px solid transparent;
}
.wizard-pill.active { background: var(--primary); color: #fff; }
.wizard-pill.done { background: var(--success-soft); color: var(--success); border-color: #bbf7d0; }
.wizard-pill.skipped { background: #fef3c7; color: #92400e; border-color: #fde68a; }

.choice-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.choice-btn {
  padding: 12px 8px; border: 2px solid var(--border); border-radius: 10px; background: #fff;
  text-align: center; font-weight: 700; cursor: pointer; font-size: 13px; min-height: 50px;
}
.choice-btn.selected[data-val="NORMAL"], .choice-btn.selected[data-val="OFFICE"] { border-color: var(--success); background: var(--success-soft); color: var(--success); }
.choice-btn.selected[data-val="RUNNING_ABNORMAL"], .choice-btn.selected[data-val="MEDIUM"] { border-color: var(--warning); background: var(--warning-soft); color: var(--warning); }
.choice-btn.selected[data-val="MATI"], .choice-btn.selected[data-val="HARSH"] { border-color: var(--danger); background: var(--danger-soft); color: var(--danger); }
.choice-btn.selected[data-val="NOT_APPLICABLE"], .choice-btn.selected[data-val="NOT_ACCESSIBLE"] { border-color: #475569; background: #f1f5f9; color: #334155; }

.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 8px; }
.photo-thumb { position: relative; aspect-ratio: 1; border-radius: 8px; overflow: hidden; border: 1px solid var(--border); background: #f1f5f9; }
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-remove {
  position: absolute; top: 4px; right: 4px; width: 24px; height: 24px; border-radius: 50%;
  background: rgba(0,0,0,0.7); color: #fff; border: none; cursor: pointer; font-weight: 700;
}

/* Genba Qualitative v2 Wizard Enhancements */
.genba-header-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.genba-section { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); }
.genba-section-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; }
.genba-section-head h4 { margin: 0; font-size: 14px; }
.condition-guide-card {
  margin-top: 10px; padding: 10px 12px; border-radius: 10px; font-size: 13px; border: 1px solid var(--border);
}
.condition-guide-card p { margin: 4px 0 0; line-height: 1.45; }
.condition-guide-normal { background: var(--success-soft); border-color: #bbf7d0; color: #14532d; }
.condition-guide-running_abnormal { background: var(--warning-soft); border-color: #fde68a; color: #78350f; }
.condition-guide-mati { background: var(--danger-soft); border-color: #fecaca; color: #7f1d1d; }
.genba-anomaly-checklist {
  margin-top: 10px; padding: 10px 12px; border: 1px solid #fde68a; border-radius: 10px; background: #fffbeb;
  display: flex; flex-direction: column; gap: 6px;
}
.genba-anomaly-checklist legend { font-size: 12.5px; font-weight: 700; color: #78350f; padding: 0 4px; }
.anomaly-checkbox-label { display: flex; align-items: flex-start; gap: 8px; font-size: 13px; cursor: pointer; }
.anomaly-checkbox-label input { margin-top: 2px; }
.exposure-options { display: flex; flex-direction: column; gap: 8px; }
.exposure-card {
  display: flex; align-items: flex-start; gap: 10px; padding: 11px 12px; border: 2px solid var(--border);
  border-radius: 10px; background: #fff; cursor: pointer;
}
.exposure-card.selected { border-color: var(--primary); background: var(--primary-soft); }
.exposure-card input { margin-top: 3px; }
.exposure-desc { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }
.photo-dropzone {
  border: 2px dashed var(--border); border-radius: 12px; padding: 14px; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 8px; background: var(--surface-alt);
}
.photo-dropzone.has-photos { align-items: stretch; text-align: left; }
.photo-gallery { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.photo-tile { position: relative; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: #fff; }
.photo-tile img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }
.photo-tile small { display: block; padding: 4px 6px; font-size: 11px; color: var(--text-muted); text-align: center; }
.photo-choices { margin-top: 8px; padding: 10px; border: 1px solid var(--border); border-radius: 10px; background: #fff; }
.genba-exceptions { margin-top: 12px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-alt); }
.genba-exceptions summary { cursor: pointer; font-size: 13px; font-weight: 600; color: var(--text-muted); }
.genba-exception-state { padding: 10px 12px; border-radius: 10px; background: #f1f5f9; border: 1px solid #cbd5e1; font-size: 13px; }
.genba-review { display: flex; flex-direction: column; gap: 10px; }
.review-category { padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-alt); font-size: 13px; display: flex; flex-direction: column; gap: 4px; }
.review-gallery { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.review-gallery img { width: 56px; height: 56px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); }

/* Modal & Tutorial Guideline */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(10, 20, 14, 0.56); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.modal-backdrop[hidden] { display: none; }
.modal-card {
  background: #fff; border-radius: 16px; max-width: 780px; width: 100%; max-height: 90vh;
  display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 24px 60px rgba(0,0,0,0.28);
  animation: modalIn 0.18s cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(8px) scale(0.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.modal-body { padding: 20px; overflow-y: auto; }

.guide-tabs { display: flex; gap: 8px; margin-bottom: 14px; }
.guide-step-box {
  background: var(--surface-alt); border: 1px solid var(--border); border-radius: 12px;
  padding: 18px; min-height: 210px;
}
.guide-step-num {
  display: inline-block; background: var(--primary); color: #fff; padding: 3px 10px;
  border-radius: 999px; font-size: 12px; font-weight: 700; margin-bottom: 8px;
}
.guide-dots { display: flex; gap: 6px; justify-content: center; margin: 14px 0; }
.guide-dot { width: 10px; height: 10px; border-radius: 50%; background: #cbd5e1; cursor: pointer; }
.guide-dot.active { background: var(--primary); width: 24px; border-radius: 999px; }

/* User Onboarding Wizard */
.onboard-stepper { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 16px; }
.onboard-step-pill {
  padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface-alt); font-size: 12px; font-weight: 600; color: var(--text-muted);
  text-align: center; transition: all .15s ease;
}
.onboard-step-pill.active { background: #eff6ff; border-color: var(--primary); color: var(--primary); }
.onboard-step-pill.done { background: var(--success-soft); border-color: #bbf7d0; color: #14532d; }
.onboard-hero {
  background: linear-gradient(135deg, #eff6ff 0%, #f8fafc 100%);
  border: 1px solid #bfdbfe; border-radius: 12px; padding: 16px; margin-bottom: 14px;
}
.onboard-role-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; margin-top: 12px; }
.onboard-role-card {
  background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 12px; font-size: 13px;
}
.onboard-role-card strong { display: block; margin-bottom: 4px; color: var(--text); }
.onboard-checklist { display: flex; flex-direction: column; gap: 8px; margin: 12px 0; }
.onboard-check-item {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; background: #fff; font-size: 13.5px;
}
@media (max-width: 640px) {
  .onboard-stepper { grid-template-columns: repeat(2, 1fr); }
}

/* Alert */
.alert { padding: 12px 14px; border-radius: 8px; font-size: 13.5px; margin-bottom: 12px; }
.alert-info { background: #eff6ff; border: 1px solid #bfdbfe; color: #1e3a8a; }
.alert-success { background: var(--success-soft); border: 1px solid #bbf7d0; color: #14532d; }
.alert-error { background: var(--danger-soft); border: 1px solid #fecaca; color: #991b1b; }

/* Cost Reduction Simulator & Maintenance Matrix */
.cost-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin-bottom: 12px; }
.cost-card { background: var(--surface-alt); border: 1px solid var(--border); border-radius: 10px; padding: 14px; display: flex; flex-direction: column; gap: 4px; }
.cost-card span { font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; }
.cost-card strong { font-size: 20px; font-weight: 800; color: var(--text); }
.cost-card small { font-size: 12px; color: var(--text-muted); }
.cost-card.positive { background: var(--success-soft); border-color: #86efac; }
.cost-card.positive strong { color: var(--success); }

.sim-step-card { border: 1px solid var(--border); border-radius: 12px; padding: 16px; margin-bottom: 14px; background: #fff; }
.sim-step-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; padding-bottom: 10px; border-bottom: 1px solid var(--border); }
.sim-step-title { display: flex; align-items: center; gap: 10px; }
.sim-step-num { width: 26px; height: 26px; border-radius: 50%; background: var(--primary); color: #fff; font-size: 13px; font-weight: 800; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.sim-step-title h4 { margin: 0; font-size: 15px; font-weight: 700; color: var(--text); }
.sim-step-sub { margin: 2px 0 0 36px; font-size: 12.5px; color: var(--text-muted); }

.info-tip-wrap { position: relative; display: inline-flex; align-items: center; vertical-align: middle; }
.info-btn { width: 17px; height: 17px; border-radius: 50%; border: 1px solid #94a3b8; background: #f8fafc; color: #475569; font-size: 11px; font-weight: 800; font-style: italic; font-family: Georgia, serif; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; padding: 0; line-height: 1; transition: all .15s; }
.info-btn:hover, .info-btn:focus { background: var(--primary); color: #fff; border-color: var(--primary); outline: none; }
.info-pop { display: none; position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%); width: 250px; max-width: 75vw; background: #0f172a; color: #f8fafc; font-size: 12px; font-weight: 400; line-height: 1.45; padding: 8px 10px; border-radius: 8px; box-shadow: 0 8px 20px rgba(15,23,42,0.22); z-index: 60; pointer-events: none; text-align: left; white-space: normal; }
.info-tip-wrap:hover .info-pop, .info-tip-wrap.open .info-pop { display: block; }

.sim-rate-table th, .sim-rate-table td { padding: 8px 10px; font-size: 12.5px; vertical-align: middle; }
.sim-rate-input { width: 105px; padding: 5px 8px; border: 1px solid var(--border); border-radius: 6px; font-size: 12.5px; text-align: right; }
.sim-rate-vendor { width: 100px; padding: 5px 8px; border: 1px solid var(--border); border-radius: 6px; font-size: 12.5px; }

.sim-cur-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 10px; }
.sim-cur-item { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; background: var(--surface-alt); display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.sim-cur-item label { display: flex; flex-direction: column; gap: 2px; font-size: 13px; }
.sim-cur-item small { font-size: 11.5px; color: var(--text-muted); }
.sim-num-box { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; font-weight: 600; }
.sim-num-box input[type="number"] { width: 76px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; text-align: center; font-weight: 700; font-size: 13px; background: #fff; }

.sim-plant-card { border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; margin-bottom: 10px; background: #fff; }
.sim-plant-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.sim-plant-info { min-width: 170px; display: flex; flex-direction: column; }
.sim-plant-info strong { font-size: 14px; }
.sim-plant-info span { font-size: 12px; color: var(--text-muted); }
.sim-plant-controls { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.sim-unit-count { font-size: 12.5px; font-weight: 700; padding: 4px 10px; border-radius: 999px; background: var(--surface-alt); border: 1px solid var(--border); }
.sim-days-wrap { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; }
.sim-days-wrap input { width: 78px; text-align: center; }
.sim-type-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 8px; margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--border); }
.sim-type-box { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 7px 10px; border: 1px solid #e2e8f0; border-radius: 8px; background: #f8fafc; font-size: 12.5px; }
.sim-type-ctrl { display: flex; align-items: center; gap: 6px; }
.sim-type-ctrl input[type="number"] { width: 72px; padding: 5px 6px; border: 1px solid var(--border); border-radius: 6px; text-align: center; font-weight: 700; background: #fff; }

.sim-generate-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 14px 16px; border: 1px solid #bbf7d0; background: #f0fdf4; border-radius: 12px; margin-bottom: 14px; }
.sim-dirty-note { font-size: 12.5px; font-weight: 600; color: #b45309; background: #fef3c7; border: 1px solid #fde68a; padding: 5px 10px; border-radius: 8px; }

.sim-chart-wrap { border: 1px solid var(--border); border-radius: 10px; padding: 14px; background: #fff; margin-top: 12px; }
.sim-chart-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.sim-chart-legend { display: flex; gap: 16px; font-size: 12.5px; font-weight: 600; }
.sim-dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; }
.sim-dot-before { background: #94a3b8; }
.sim-dot-after { background: #15803d; }
.sim-chart-svg { width: 100%; height: auto; display: block; }

.tab-bar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }

/* QR Print Sheet Exact Physical Geometry (96 x 24 mm, ratio 4:1 - Unified A4 & Brother PT-9800PCN) */
.qr-preview-scroll { max-height: 620px; overflow: auto; border: 1px solid var(--border); border-radius: 10px; background: #cbd5e1; padding: 16px; }
.qr-sheet { position: relative; box-sizing: border-box; background: #fff; color: #000; margin: 0 auto 16px; font-family: Arial, Helvetica, sans-serif; box-shadow: 0 4px 12px rgba(0,0,0,0.15); }
.qr-sheet[data-layout="24"] { width: 297mm; height: 210mm; }
.qr-sheet[data-layout="24"] .qr-grid {
  position: absolute; left: 4.5mm; top: 9mm; width: 288mm; height: 192mm;
  display: grid; grid-template-columns: repeat(3, 96mm); grid-auto-rows: 24mm;
  align-content: start;
}
.qr-sheet[data-layout="tape24"] {
  width: 96mm; height: 24mm; margin: 10px auto; border: 1px dashed #64748b;
  background: #ffffff; color: #000000; box-sizing: border-box;
}
.qr-sheet[data-layout="tape24"] .qr-grid { position: relative; width: 96mm; height: 24mm; left: 0; top: 0; display: block; }

.qr-label {
  position: relative; box-sizing: border-box; width: 96mm; height: 24mm; display: flex; flex-direction: row; align-items: center;
  padding: 0.5mm 2mm; gap: 2mm; margin: 0; border: 0; border-radius: 0;
  background: #ffffff; color: #000000; text-align: left; break-inside: avoid; box-shadow: none;
}
.qr-sheet[data-layout="24"] .qr-label { border-right: 0.35pt solid #000000; border-bottom: 0.35pt solid #000000; }
.qr-sheet[data-layout="24"] .qr-label:nth-child(3n+1) { border-left: 0.35pt solid #000000; }
.qr-sheet[data-layout="24"] .qr-label:nth-child(-n+3) { border-top: 0.35pt solid #000000; }

.qr-label .qr-code, .qr-label .qr-code svg {
  width: 23mm; height: 23mm; flex: 0 0 23mm; display: block; shape-rendering: crispEdges;
}
.qr-label .qr-label-info {
  flex: 1 1 auto; min-width: 0; height: 23mm; display: flex; flex-direction: column;
  justify-content: center; gap: 1mm; line-height: 1.1; box-sizing: border-box; padding: 0.5mm 0.5mm 0.5mm 0;
}
.qr-label strong.qr-asset-id {
  display: block; font-family: Arial, Helvetica, sans-serif; font-size: 15.5pt; font-weight: 700;
  line-height: 1.1; letter-spacing: -0.2px; color: #000000; max-height: 8mm; margin: 0;
  white-space: nowrap; overflow: visible; text-overflow: clip;
}
.qr-label .qr-label-details {
  display: flex; flex-direction: row; align-items: flex-start; justify-content: space-between; gap: 2mm; min-width: 0;
}
.qr-label .qr-label-location {
  flex: 1 1 auto; min-width: 0; max-width: 38mm; font-size: 9.5pt; font-weight: 600; color: #000000;
  line-height: 1.15; white-space: normal; overflow-wrap: break-word; word-break: break-word;
  max-height: 9mm; overflow: hidden; margin: 0;
}
.qr-label .qr-label-year {
  flex: 0 0 auto; font-size: 10.5pt; font-weight: 700; color: #000000;
  line-height: 1.15; text-align: right; white-space: nowrap; margin: 0;
}

.qr-label.is-selectable { cursor: pointer; }
.qr-label.is-selectable:hover { background: #f0fdf4; }
.qr-label.is-selected { outline: 2px solid var(--primary); outline-offset: -2px; background: #ecfdf5; }
.qr-select-badge {
  position: absolute; top: 1mm; right: 1mm; width: 18px; height: 18px; border-radius: 999px;
  background: var(--primary); color: #fff; font-size: 11px; font-weight: 700;
  display: grid; place-items: center; pointer-events: none; box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

@media print {
  html, body {
    margin: 0 !important;
    padding: 0 !important;
    background: #fff !important;
    height: auto !important;
    min-height: 0 !important;
    overflow: visible !important;
  }
  .app-shell {
    display: block !important;
    min-height: 0 !important;
    height: auto !important;
  }
  .sidebar, .sidebar-backdrop, .topbar, .modal-backdrop, .no-print {
    display: none !important;
  }
  .main-area, .content, .qr-preview-scroll {
    display: block !important;
    flex: none !important;
    width: auto !important;
    max-width: none !important;
    height: auto !important;
    min-height: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    border: none !important;
    background: #fff !important;
    max-height: none !important;
    overflow: visible !important;
    zoom: 1 !important;
  }
  .qr-sheet {
    box-shadow: none !important;
    margin: 0 !important;
    overflow: hidden;
    break-inside: avoid;
    page-break-inside: avoid;
    break-after: page;
    page-break-after: always;
  }
  .qr-sheet[data-layout="24"] { height: 209mm; }
  .qr-sheet[data-layout="tape24"] { border: 0 !important; margin: 0 !important; }
  .qr-sheet:last-child { break-after: auto; page-break-after: auto; }
  .qr-label.is-selected { outline: none !important; background: #ffffff !important; }
}

/* Bento Dashboard Components */
.bento-top { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.bento-sub { font-size: 12.5px; color: var(--text-muted); font-weight: 500; margin-bottom: 2px; }
.bento-heading { font-size: 22px; font-weight: 800; margin: 0; letter-spacing: -0.3px; }
.bento-controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pill-group { display: inline-flex; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 3px; gap: 2px; }
.pill-btn {
  border: none; background: transparent; color: var(--text-muted); font-size: 12.5px; font-weight: 600;
  padding: 6px 12px; border-radius: 999px; cursor: pointer; transition: all 0.15s; white-space: nowrap;
}
.pill-btn:hover { color: var(--text); }
.pill-btn.active { background: var(--primary); color: #fff; box-shadow: 0 2px 6px rgba(20, 83, 45, 0.22); }
.select-pill { border-radius: 999px !important; padding: 7px 14px !important; font-size: 13px !important; font-weight: 600; min-height: 36px !important; }

.bento-board { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 16px; align-items: start; }
.bento-main { grid-column: span 8; display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.bento-side { grid-column: span 4; display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.bento-main .card, .bento-side .card { margin-bottom: 0; }

.donut-wrap { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; justify-content: center; padding: 6px 0; }
.donut-svg { width: 148px; height: 148px; flex-shrink: 0; }
.donut-legend { flex: 1; min-width: 150px; display: flex; flex-direction: column; gap: 8px; }
.legend-item { display: flex; align-items: center; justify-content: space-between; font-size: 13px; gap: 8px; }
.legend-left { display: flex; align-items: center; gap: 8px; font-weight: 600; color: var(--text); }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }

.area-chart-svg { width: 100%; height: auto; aspect-ratio: 360 / 115; display: block; overflow: visible; }

.micro-list { display: flex; flex-direction: column; gap: 10px; }
.micro-card {
  background: var(--surface-alt); border: 1px solid var(--border); border-radius: 12px;
  padding: 11px 13px; transition: border-color 0.15s, transform 0.12s;
}
.micro-card:hover { border-color: #b7d4c0; transform: translateY(-1px); }
.micro-card.tint-normal { background: #f4fbf6; border-color: #d1fae5; }
.micro-card.tint-abnormal { background: #fffdf4; border-color: #fef3c7; }
.micro-card.tint-mati { background: #fef6f6; border-color: #fee2e2; }
.micro-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.micro-id { font-weight: 700; font-size: 13.5px; color: var(--text); word-break: break-word; }
.micro-meta { font-size: 12px; color: var(--text-muted); line-height: 1.4; }

.kpi-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.kpi-icon { width: 32px; height: 32px; border-radius: 10px; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; font-size: 15px; flex-shrink: 0; }

@media (max-width: 1100px) {
  .bento-main { grid-column: span 12; }
  .bento-side { grid-column: span 12; }
}

@media (max-width: 860px) {
  .sidebar { position: fixed; left: -270px; z-index: 60; transition: left 0.2s ease; box-shadow: 4px 0 20px rgba(0, 0, 0, 0.25); }
  .sidebar.open { left: 0; }
  .menu-toggle { display: inline-flex; flex-shrink: 0; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .content { padding: 12px; }
  .topbar { padding: 10px 12px; flex-wrap: wrap; gap: 8px; }
  .topbar-left { flex: 1 1 auto; min-width: 0; gap: 8px; }
  .page-title { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  #topbar-actions { flex-wrap: wrap; gap: 6px; }
  .toolbar .input, .toolbar .select { width: 100%; }
  .input, .select, .textarea { font-size: 16px; }
  .card { padding: 14px; }
  .modal-backdrop { padding: 10px; }
  .modal-card { max-height: 92dvh; }
  .modal-body { padding: 14px; }
  .guide-tabs { flex-wrap: wrap; }
  .sim-plant-info { width: 100%; }
}

@media (max-width: 480px) {
  .wizard-steps { gap: 4px; }
  .wizard-pill { font-size: 11px; padding: 6px 2px; line-height: 1.2; }
  .choice-grid { gap: 6px; }
  .choice-btn { padding: 10px 4px; font-size: 12px; min-height: 46px; }
  .photo-grid { grid-template-columns: repeat(2, 1fr); }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi-value { font-size: 22px; }
}

/* Track Record Timeline & Modal Tabs */
.modal-tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--border); margin-bottom: 14px; padding-bottom: 8px; flex-wrap: wrap; }
.modal-tab {
  border: 1px solid var(--border); background: var(--surface-alt); color: var(--text-muted);
  border-radius: 999px; padding: 6px 14px; font-size: 13px; font-weight: 600; cursor: pointer; transition: all 0.15s;
}
.modal-tab:hover { color: var(--text); border-color: #b7d4c0; }
.modal-tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }

.track-filters { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.track-timeline { position: relative; padding-left: 18px; display: flex; flex-direction: column; gap: 10px; }
.track-timeline::before {
  content: ''; position: absolute; left: 5px; top: 8px; bottom: 8px; width: 2px; background: var(--border);
}
.track-item { position: relative; }
.track-dot {
  position: absolute; left: -18px; top: 12px; width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid #fff; box-shadow: 0 0 0 1px var(--border); background: var(--text-muted);
}
.track-dot.cat-CHANGE { background: #2563eb; }
.track-dot.cat-GENBA { background: #16a34a; }
.track-dot.cat-PM { background: #0f766e; }
.track-dot.cat-OPTIMIZATION { background: #d97706; }

.track-card {
  background: var(--surface-alt); border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 12px; font-size: 13px;
}
.track-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; flex-wrap: wrap; }
.track-title { font-weight: 700; color: var(--text); }
.track-meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.track-summary { margin-top: 5px; color: var(--text); line-height: 1.45; }
.track-diff-list { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; }
.track-diff-chip {
  background: #fff; border: 1px solid var(--border); border-radius: 6px;
  padding: 4px 8px; font-size: 12px; display: flex; flex-wrap: wrap; gap: 4px; align-items: center;
}
.track-diff-from { color: var(--danger); text-decoration: line-through; }
.track-diff-to { color: var(--success); font-weight: 600; }

/* Confirm Dialog & Toast Notifications */
.confirm-backdrop { z-index: 120; }
.confirm-card { max-width: 440px; }

.toast-container {
  position: fixed; right: 16px; bottom: 16px; z-index: 140;
  display: flex; flex-direction: column; gap: 8px; max-width: 380px; width: calc(100% - 32px);
  pointer-events: none;
}
.toast {
  pointer-events: auto; display: flex; align-items: flex-start; justify-content: space-between; gap: 10px;
  padding: 12px 14px; border-radius: 12px; background: #142019; color: #fff; font-size: 13.5px; line-height: 1.45;
  box-shadow: 0 10px 28px rgba(0,0,0,0.22); border-left: 4px solid #22c55e;
  animation: toastIn 0.2s ease-out;
}
.toast.toast-success { background: #14532d; border-left-color: #4ade80; }
.toast.toast-error { background: #7f1d1d; border-left-color: #f87171; }
.toast.toast-warning { background: #78350f; border-left-color: #fbbf24; }
.toast.toast-info { background: #1e3a8a; border-left-color: #60a5fa; }
.toast-close {
  background: transparent; border: none; color: rgba(255,255,255,0.75); cursor: pointer;
  font-size: 15px; line-height: 1; padding: 2px 4px; flex-shrink: 0;
}
.toast-close:hover { color: #fff; }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Loading Spinner, Skeleton & Offline Banner */
.loading-state { display: flex; align-items: center; gap: 10px; color: var(--text-muted); font-size: 14px; padding: 6px 0; }
.spinner {
  width: 18px; height: 18px; border: 2.5px solid var(--border); border-top-color: var(--primary);
  border-radius: 50%; animation: spin 0.7s linear infinite; flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

.skeleton {
  background: linear-gradient(90deg, #e9efeb 25%, #f4f8f5 50%, #e9efeb 75%);
  background-size: 200% 100%;
  animation: shimmer 1.3s infinite linear;
  border-radius: 8px;
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

.empty-state {
  text-align: center; padding: 32px 16px; color: var(--text-muted);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.empty-state svg { width: 36px; height: 36px; opacity: 0.45; color: var(--primary); }
.empty-state strong { color: var(--text); font-size: 14.5px; }
.empty-state p { margin: 0; font-size: 13px; max-width: 360px; }

.offline-banner {
  background: #78350f; color: #fef3c7; font-size: 12.5px; font-weight: 600;
  padding: 7px 16px; text-align: center; display: flex; align-items: center; justify-content: center; gap: 8px;
}
.offline-banner[hidden] { display: none; }

@keyframes fadeInRoute {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}
.content > .card, .content > .bento-top, .content > .operator-container {
  animation: fadeInRoute 0.16s ease-out;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* Mobile Sticky Wizard Actions */
@media (max-width: 640px) {
  .wizard-actions-bar {
    position: sticky; bottom: 0; background: var(--surface); padding: 10px 0 4px;
    margin-top: 14px; border-top: 1px solid var(--border); z-index: 15;
  }
}

@media print {
  .toast-container, .tour-layer { display: none !important; }
}

/* Interactive Spotlight Product Tour */
.tour-layer {
  position: fixed;
  inset: 0;
  z-index: 200;
  pointer-events: auto;
}
.tour-click-catcher {
  position: fixed;
  inset: 0;
  background: transparent;
  z-index: 200;
}
.tour-spotlight {
  position: fixed;
  border-radius: 12px;
  box-shadow: 0 0 0 9999px rgba(9, 20, 14, 0.64), 0 0 0 3px #4ade80, 0 0 24px rgba(74, 222, 128, 0.35);
  pointer-events: none;
  z-index: 201;
  transition: top 0.28s cubic-bezier(0.22, 1, 0.36, 1),
              left 0.28s cubic-bezier(0.22, 1, 0.36, 1),
              width 0.28s cubic-bezier(0.22, 1, 0.36, 1),
              height 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}
.tour-number-badge {
  position: fixed;
  z-index: 203;
  min-width: 28px;
  height: 28px;
  padding: 0 8px;
  border-radius: 999px;
  background: #16a34a;
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #fff;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.28);
  pointer-events: none;
  transition: top 0.28s cubic-bezier(0.22, 1, 0.36, 1), left 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}
.tour-popover {
  position: fixed;
  z-index: 202;
  width: min(360px, calc(100vw - 24px));
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 20px 50px rgba(9, 20, 14, 0.3);
  padding: 16px 18px;
  transition: top 0.24s ease, left 0.24s ease;
}
.tour-pop-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.tour-step-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--primary);
  background: var(--primary-soft);
  padding: 3px 9px;
  border-radius: 999px;
}
.tour-pop-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 4px 6px;
  border-radius: 8px;
}
.tour-pop-close:hover { background: var(--surface-alt); color: var(--text); }
.tour-pop-title {
  margin: 10px 0 6px;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}
.tour-pop-desc {
  margin: 0 0 12px;
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--text-muted);
}
.tour-pop-dots {
  display: flex;
  gap: 5px;
  justify-content: center;
  margin: 0 0 12px;
}
.tour-pop-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}
