/* PFERD TOOLS Efficiency & Cost Saving – Mobile-first Styles */
:root {
  --pf-dark: #001A70; --pf-blue: #004ED7; --pf-light-blue: #00C3FF; --pf-mint: #19FF7D; --pf-green: #00BE41;
  --pf-orange: #FF9100; --pf-grey: #AFAFAF; --pf-light-grey: #F3F3F3;
  --text: #1A1A1A; --muted: #5F6368; --line: #DADCE0; --card: #FFFFFF; --danger: #C62828;
  --radius: 14px; --header-h: 56px; --nav-h: 76px; --max-w: 760px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "Noto Sans Thai", "Noto Sans KR", "Noto Sans SC", sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: 16px; line-height: 1.4; color: var(--text); background: var(--pf-light-grey); -webkit-tap-highlight-color: transparent; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--pf-blue); }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* Header */
.app-header { position: fixed; top: 0; left: 0; right: 0; height: calc(var(--header-h) + env(safe-area-inset-top)); padding-top: env(safe-area-inset-top); background: var(--pf-dark); color: #fff; z-index: 50; box-shadow: 0 2px 8px rgba(0,0,0,.25); }
.app-header .inner { max-width: var(--max-w); margin: 0 auto; height: var(--header-h); display: flex; align-items: center; gap: 12px; padding: 0 12px; }
.app-header .logo { height: 30px; width: auto; display: block; }
.app-header .logo-btn { background: none; border: 0; padding: 4px; margin: 0; display: flex; align-items: center; }
.app-header .title { flex: 1; font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; opacity: .95; }
.icon-btn { background: rgba(255,255,255,.12); border: 0; color: #fff; min-width: 44px; height: 44px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 0 10px; font-weight: 600; font-size: 14px; }
.icon-btn svg { width: 22px; height: 22px; fill: currentColor; }
.icon-btn:active { background: rgba(255,255,255,.25); }

/* Layout */
main { max-width: var(--max-w); margin: 0 auto; padding: calc(var(--header-h) + env(safe-area-inset-top) + 16px) 16px calc(var(--nav-h) + env(safe-area-inset-bottom) + 24px); }
main.no-nav { padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
h1 { font-size: 22px; line-height: 1.25; margin: 4px 0 12px; color: var(--pf-dark); }
h2 { font-size: 17px; margin: 0 0 10px; color: var(--pf-dark); }
h3 { font-size: 15px; margin: 0 0 8px; color: var(--pf-dark); }
p { margin: 0 0 10px; }
.muted { color: var(--muted); font-size: 14px; }
.card { background: var(--card); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; box-shadow: 0 1px 2px rgba(0,0,0,.06); }
.card.flat { box-shadow: none; border: 1px solid var(--line); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1 1 auto; }
.stack > * + * { margin-top: 10px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.actions .btn { flex: 1 1 140px; }
.actions .btn.danger { flex: 0 1 220px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 52px; padding: 10px 18px; border-radius: 12px; border: 2px solid var(--pf-blue); background: var(--pf-blue); color: #fff; font-weight: 700; font-size: 16px; text-decoration: none; }
.btn:active { filter: brightness(.92); }
.btn.secondary { background: #fff; color: var(--pf-blue); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--pf-blue); min-height: 44px; }
.btn.danger { background: #fff; color: var(--danger); border-color: var(--danger); }
.btn.small { min-height: 42px; font-size: 14px; padding: 6px 12px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .45; }
.btn svg { width: 20px; height: 20px; fill: currentColor; }

/* Home */
.home-hero { background: var(--pf-dark); color: #fff; border-radius: var(--radius); padding: 20px 18px; margin-bottom: 14px; }
.home-hero h1 { color: #fff; margin: 0 0 4px; font-size: 22px; }
.home-hero p { margin: 0; opacity: .85; font-size: 14px; }
.home-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 18px; }
.home-actions .btn { min-height: 60px; flex-direction: column; gap: 2px; font-size: 15px; }
.home-actions .btn small { font-weight: 500; font-size: 12px; opacity: .85; }
.type-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 560px) { .type-grid { grid-template-columns: 1fr 1fr; } }
.type-card { display: flex; align-items: center; gap: 14px; text-align: left; width: 100%; min-height: 92px; background: #fff; border: 2px solid transparent; border-radius: var(--radius); padding: 14px; box-shadow: 0 1px 2px rgba(0,0,0,.06); }
.type-card:active, .type-card:focus-visible { border-color: var(--pf-blue); outline: none; }
.type-card .ico { flex: 0 0 56px; width: 56px; height: 56px; border-radius: 14px; background: var(--pf-light-grey); display: flex; align-items: center; justify-content: center; color: var(--pf-dark); }
.type-card .ico svg { width: 34px; height: 34px; }
.type-card .txt { flex: 1; min-width: 0; }
.type-card .txt b { display: block; font-size: 16px; color: var(--pf-dark); margin-bottom: 2px; }
.type-card .txt span { display: block; font-size: 13px; color: var(--muted); line-height: 1.3; }
.type-card .chev { color: var(--pf-grey); }
.lang-select { width: 100%; min-height: 48px; border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; background: #fff; }

/* Stepper */
.stepper { display: flex; justify-content: space-between; align-items: flex-start; margin: 0 0 14px; padding: 0; list-style: none; counter-reset: s; }
.stepper li { flex: 1; text-align: center; position: relative; font-size: 11px; color: var(--muted); line-height: 1.2; }
.stepper li::before { content: counter(s); counter-increment: s; display: block; width: 28px; height: 28px; margin: 0 auto 4px; border-radius: 50%; background: #fff; border: 2px solid var(--pf-grey); color: var(--muted); font-weight: 700; font-size: 13px; line-height: 24px; }
.stepper li.done::before { background: var(--pf-blue); border-color: var(--pf-blue); color: #fff; content: "✓"; }
.stepper li.active { color: var(--pf-dark); font-weight: 700; }
.stepper li.active::before { border-color: var(--pf-blue); color: var(--pf-blue); }
.stepper li:not(:last-child)::after { content: ""; position: absolute; top: 13px; left: calc(50% + 16px); right: calc(-50% + 16px); height: 2px; background: var(--line); }
.stepper li.done::after { background: var(--pf-blue); }

/* Fields */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 700; color: var(--pf-dark); margin-bottom: 5px; }
.field label .req { color: var(--pf-orange); margin-left: 2px; }
.field .hint { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.field .ctl { display: flex; align-items: stretch; }
.field input[type=text], .field input[type=date], .field select, .field textarea { width: 100%; min-height: 48px; border: 1.5px solid var(--line); border-radius: 12px; padding: 10px 12px; background: #fff; font-size: 16px; }
.field textarea { min-height: 80px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--pf-blue); box-shadow: 0 0 0 3px rgba(0,78,215,.15); }
.field .ctl input { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.field .unit { display: flex; align-items: center; padding: 0 12px; background: var(--pf-light-grey); border: 1.5px solid var(--line); border-left: 0; border-radius: 0 12px 12px 0; font-size: 14px; color: var(--muted); white-space: nowrap; }
.field .unit select { border: 0; background: transparent; min-height: 0; padding: 0; width: auto; }
.field.invalid input, .field.invalid select { border-color: var(--pf-orange); background: #FFF8EE; }
.field.invalid .err { color: #B35F00; font-size: 12.5px; margin-top: 4px; font-weight: 600; }
.field.required-missing label { color: #B35F00; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
@media (max-width: 400px) { .grid2 { grid-template-columns: 1fr; } }
.segment { display: flex; gap: 6px; background: var(--pf-light-grey); padding: 4px; border-radius: 12px; }
.segment button { flex: 1; min-height: 44px; border: 0; border-radius: 9px; background: transparent; font-weight: 600; font-size: 14px; color: var(--muted); padding: 4px 6px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; }
.segment button.on { background: #fff; color: var(--pf-dark); box-shadow: 0 1px 3px rgba(0,0,0,.15); }
.segment button img { width: 100%; max-width: 120px; height: auto; border-radius: 6px; }
.segment.wrap { flex-wrap: wrap; }
.segment.wrap button { flex: 1 1 40%; }
.alert { background: #FFF4E5; border: 1px solid #FFD199; color: #7A4100; border-radius: 12px; padding: 10px 12px; font-size: 14px; margin-bottom: 12px; }
.info { background: #EEF3FF; border: 1px solid #C9D8F7; color: var(--pf-dark); border-radius: 12px; padding: 10px 12px; font-size: 13.5px; margin-bottom: 12px; }
.computed { display: flex; justify-content: space-between; gap: 8px; padding: 8px 12px; background: var(--pf-light-grey); border-radius: 10px; font-size: 14px; margin-bottom: 8px; }
.computed b { color: var(--pf-dark); }
.product-card { border-left: 5px solid var(--pf-grey); }
.product-card.baseline { border-left-color: var(--pf-dark); }
.product-card h3 { display: flex; align-items: center; gap: 8px; }
.badge { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--pf-dark); color: #fff; letter-spacing: .02em; }
.badge.light { background: var(--pf-light-grey); color: var(--pf-dark); }
.count-ctl { display: flex; align-items: center; gap: 10px; }
.count-ctl button { width: 44px; height: 44px; border-radius: 10px; border: 1.5px solid var(--line); background: #fff; font-size: 20px; font-weight: 700; color: var(--pf-blue); }
.count-ctl b { min-width: 24px; text-align: center; font-size: 18px; }

/* Wizard nav */
.wizard-nav { position: fixed; left: 0; right: 0; bottom: 0; background: #fff; border-top: 1px solid var(--line); padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); z-index: 40; }
.wizard-nav .inner { max-width: var(--max-w); margin: 0 auto; display: flex; gap: 10px; }
.wizard-nav .btn { flex: 1; }

/* Result */
.kpi-grid { display: grid; grid-template-columns: 1fr; gap: 10px; margin-bottom: 12px; }
@media (min-width: 480px) { .kpi-grid { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); } }
.kpi { background: #fff; border-radius: var(--radius); padding: 14px 14px 14px 18px; position: relative; overflow: hidden; box-shadow: 0 1px 2px rgba(0,0,0,.06); }
.kpi::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 6px; background: var(--kpi, var(--pf-grey)); }
.kpi .name { font-size: 14px; font-weight: 600; color: var(--muted); margin-bottom: 2px; }
.kpi .big { font-size: 32px; font-weight: 800; color: var(--pf-dark); line-height: 1.1; }
.kpi.worse .big { color: #C65A00; }
.kpi .sub { font-size: 13.5px; color: var(--text); margin-top: 4px; }
.chart { margin-bottom: 8px; }
.chart-title { font-weight: 700; color: var(--pf-dark); margin-bottom: 8px; font-size: 15px; }
.bar-row { margin-bottom: 10px; }
.bar-label { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; margin-bottom: 4px; }
.bar-name { font-weight: 600; }
.bar-sub { color: var(--muted); font-size: 13px; }
.bar-track { display: flex; align-items: center; gap: 10px; }
.bar-fill { position: relative; height: 34px; border-radius: 8px; min-width: 6px; display: flex; align-items: center; justify-content: flex-end; overflow: hidden; transition: width .4s ease; }
.bar-part { height: 100%; display: block; }
.bar-part + .bar-part { border-left: 2px solid rgba(255,255,255,.7); }
.bar-badge { position: absolute; right: 10px; top: 0; bottom: 0; display: flex; align-items: center; font-weight: 800; font-size: 14px; white-space: nowrap; letter-spacing: .01em; }
.bar-value { font-size: 14px; font-weight: 600; white-space: nowrap; min-width: 64px; }
.bar-legend { display: flex; gap: 14px; font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.bar-legend i { display: inline-block; width: 12px; height: 12px; background: var(--pf-blue); border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.chart-compact .bar-fill { height: 26px; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th, .tbl td { padding: 7px 6px; border-bottom: 1px solid var(--line); text-align: right; vertical-align: top; }
.tbl th:first-child, .tbl td:first-child { text-align: left; }
.tbl th { color: var(--pf-dark); font-size: 12.5px; }
.tbl tr.strong td { font-weight: 700; }
.tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.meta-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; font-size: 14px; }
.meta-grid div span { display: block; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.meta-grid div b { font-weight: 600; word-break: break-word; }
.notes { font-size: 13px; color: var(--muted); }
.claim { text-align: right; font-weight: 700; color: var(--pf-dark); font-size: 14px; margin-top: 8px; }
details summary { cursor: pointer; font-weight: 700; color: var(--pf-blue); padding: 6px 0; list-style: none; }
details summary::-webkit-details-marker { display: none; }

/* List */
.search { display: flex; gap: 8px; margin-bottom: 10px; }
.search input, .search select { flex: 1; min-height: 46px; border: 1.5px solid var(--line); border-radius: 12px; padding: 8px 12px; background: #fff; min-width: 0; }
.list-item { display: flex; align-items: center; gap: 12px; background: #fff; border-radius: var(--radius); padding: 12px 14px; margin-bottom: 8px; box-shadow: 0 1px 2px rgba(0,0,0,.06); }
.list-item .ico { flex: 0 0 40px; width: 40px; height: 40px; border-radius: 10px; background: var(--pf-light-grey); display: flex; align-items: center; justify-content: center; color: var(--pf-dark); }
.list-item .ico svg { width: 24px; height: 24px; }
.list-item .main { flex: 1; min-width: 0; text-align: left; background: none; border: 0; padding: 0; }
.list-item .main b { display: block; font-size: 15px; color: var(--pf-dark); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-item .main span { display: block; font-size: 12.5px; color: var(--muted); }
.list-item .more { width: 44px; height: 44px; border-radius: 10px; border: 0; background: var(--pf-light-grey); color: var(--pf-dark); font-size: 22px; font-weight: 700; }
.sheet-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 60; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: #fff; width: 100%; max-width: var(--max-w); border-radius: 18px 18px 0 0; padding: 14px 16px calc(16px + env(safe-area-inset-bottom)); max-height: 88vh; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.sheet .btn.small { min-height: 46px; margin-bottom: 6px; }
.sheet h3 { margin-bottom: 10px; }
.sheet .btn { width: 100%; margin-bottom: 8px; justify-content: flex-start; }
.toast { position: fixed; left: 50%; bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--pf-dark); color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px; z-index: 70; box-shadow: 0 4px 14px rgba(0,0,0,.3); max-width: calc(100% - 32px); }
.offline-pill { display: inline-block; margin-top: 6px; font-size: 11px; background: rgba(255,255,255,.15); padding: 2px 8px; border-radius: 999px; white-space: nowrap; }

/* Print */
@media print {
  @page { margin: 12mm; }
  body { background: #fff; }
  .app-header, .wizard-nav, .no-print, .toast { display: none !important; }
  main { padding: 0; max-width: none; }
  .card { box-shadow: none; border: 1px solid #ccc; break-inside: avoid; }
  .print-header { display: flex !important; align-items: center; justify-content: space-between; background: var(--pf-dark); color: #fff; padding: 10px 14px; border-radius: 8px; margin-bottom: 10px; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .print-header img { height: 26px; }
  .bar-fill, .kpi::before, .bar-part, .bar-legend i { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  details { display: block; } details summary { display: none; } details > * { display: block; }
  .tbl { font-size: 11px; }
}
.print-header { display: none; }

/* Produktfoto (optional) */
.photo-block { margin-top: 4px; }
.photo-block > label { display: block; font-size: 13px; font-weight: 700; color: var(--pf-dark); margin-bottom: 6px; }
.photo-row { display: flex; gap: 12px; align-items: center; }
.photo-thumb { flex: 0 0 96px; width: 96px; height: 72px; object-fit: contain; border-radius: 10px; background: var(--pf-light-grey); display: flex; align-items: center; justify-content: center; color: var(--pf-grey); }
.photo-thumb.empty svg { width: 32px; height: 32px; fill: currentColor; }
.photo-btns { display: flex; flex-wrap: wrap; gap: 6px; flex: 1; }
.photo-btns .btn { flex: 1 1 120px; }
.photo-strip { display: flex; gap: 12px; overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 4px; }
.photo-item { flex: 0 0 140px; text-align: center; }
.photo-item img, .photo-item .photo-thumb { width: 140px; height: 105px; object-fit: contain; border-radius: 10px; display: block; background: var(--pf-light-grey); }
.photo-item b { display: block; font-size: 13px; margin-top: 6px; color: var(--pf-dark); word-break: break-word; }
.photo-item .badge { margin-top: 4px; }
@media print { .photo-strip { overflow: visible; flex-wrap: wrap; } }
