/* =====================================================================
   Ishikawa + FMEA + Gantt page (ishikawa-fmea.html)
   Everything is inside the box with id="ifm", so these styles never
   change other Picrezo pages. The tool area keeps light colors even in
   dark mode, so the diagrams and tables always stay readable.
   ===================================================================== */
.wrap.wide { max-width: 1200px; }               /* wider page for diagrams and tables */
#ifm { color: var(--text); }

  /* ===== Colors of the tool area (same blue as the Picrezo top bar) ===== */
  #ifm { --blue:#2563eb; --bg:#f4f6f9; --card:#fff; --line:#d6dbe3; --text:#1d2430; --muted:#5f6b7a;
          --H:#d32f2f; --M:#f9a825; --L:#2e7d32; }
  #ifm * { box-sizing:border-box; }
  #ifm .card { background:var(--card); border:1px solid var(--line); border-radius:10px; padding:14px; margin-bottom:14px; }
  #ifm label { font-size:13px; color:var(--muted); display:block; margin-bottom:4px; }
  #ifm input, #ifm select, #ifm textarea { font:inherit; font-size:14px; padding:7px 8px; border:1px solid var(--line); border-radius:6px; width:100%; background:#fff; }
  #ifm button { font:inherit; font-size:14px; padding:8px 12px; border:1px solid var(--blue); background:var(--blue); color:#fff; border-radius:6px; cursor:pointer; }
  #ifm button.ghost { background:#fff; color:var(--blue); }
  #ifm button.small { padding:3px 8px; font-size:13px; }
  #ifm button.danger { border-color:#c62828; background:#fff; color:#c62828; }
  #ifm .row { display:flex; gap:10px; flex-wrap:wrap; }
  #ifm .row > * { flex:1 1 200px; }

  /* ===== Tabs (Ishikawa / FMEA / File) ===== */
  #ifm .tabs { display:flex; gap:6px; margin-bottom:12px; flex-wrap:wrap; }
  #ifm .tabs button { background:#fff; color:var(--blue); }
  #ifm .tabs button.on { background:var(--blue); color:#fff; }
  #ifm .view { display:none; }
  #ifm .view.on { display:block; }

  /* ===== Fishbone drawing area (scrolls sideways on phones) ===== */
  #ifm .svgwrap { overflow-x:auto; border:1px solid var(--line); border-radius:8px; background:#fff; }
  #ifm .svgwrap svg { display:block; min-width:640px; width:100%; height:auto; }

  /* ===== Cause lists per category ===== */
  #ifm .cats { display:grid; grid-template-columns:repeat(auto-fill,minmax(300px,1fr)); gap:12px; }
  #ifm .cat h3 { margin:0 0 8px; font-size:15px; }
  #ifm .cause { display:flex; gap:6px; align-items:center; margin-bottom:6px; }
  #ifm .cause input[type=text] { flex:1; }
  #ifm .cause .fm { display:flex; align-items:center; gap:3px; font-size:12px; color:var(--muted); white-space:nowrap; }
  #ifm .cause .fm input { width:auto; }
  #ifm .addline { display:flex; gap:6px; }

  /* ===== FMEA table (scrolls sideways on phones) ===== */
  #ifm .tablewrap { overflow-x:auto; }
  #ifm table { border-collapse:collapse; width:100%; min-width:1100px; font-size:13px; }
  #ifm th, #ifm td { border:1px solid var(--line); padding:4px; vertical-align:top; }
  #ifm th { background:#eef2f7; text-align:left; font-weight:600; }
  #ifm td input, #ifm td select { font-size:13px; padding:5px; }
  #ifm td.num select { width:58px; }
  #ifm .ap { font-weight:700; text-align:center; color:#fff; border-radius:4px; padding:5px 0; }
  #ifm .ap.H { background:var(--H); } #ifm .ap.M { background:var(--M); color:#222; } #ifm .ap.L { background:var(--L); } #ifm .ap.x { background:#aaa; }
  #ifm .badge { font-size:11px; background:#e3f2fd; color:var(--blue); border-radius:4px; padding:1px 5px; }
  #ifm .note { font-size:12px; color:var(--muted); }
  /* ===== Saving methods (Save / Open tab) ===== */
  #ifm .h2 { font-size:17px; margin:0 0 6px; }
  #ifm .btns { display:flex; gap:8px; flex-wrap:wrap; align-items:center; }
  #ifm .filebtn { display:inline-block; margin:0; padding:8px 12px; border:1px solid var(--blue); border-radius:6px; color:var(--blue); background:#fff; cursor:pointer; font-size:14px; }
  #ifm .reco { background:#e8f5e9; border:1px solid #a5d6a7; border-radius:8px; padding:8px 10px; font-size:14px; margin:8px 0 12px; }
  #ifm .method { border:1px solid var(--line); border-radius:10px; padding:12px; margin-bottom:10px; cursor:pointer; }
  #ifm .method.on { border:2px solid var(--blue); background:#f5f9ff; }
  #ifm .method.off { opacity:.55; cursor:not-allowed; }
  #ifm .method .title { display:flex; gap:8px; align-items:center; font-weight:700; font-size:15px; flex-wrap:wrap; }
  #ifm .method .title input { width:auto; }
  #ifm .tag { font-size:11px; font-weight:600; border-radius:4px; padding:2px 6px; }
  #ifm .tag.def { background:#eceff1; color:#37474f; } #ifm .tag.rec { background:#c8e6c9; color:#1b5e20; } #ifm .tag.na { background:#ffcdd2; color:#b71c1c; }
  #ifm .method ul { margin:6px 0 0; padding-left:4px; list-style:none; font-size:13px; line-height:1.5; }
  #ifm .method .ctl { margin-top:10px; }
  #ifm .status { font-size:13px; margin-top:8px; }
  #ifm .status.ok { color:var(--L); } #ifm .status.warn { color:#e65100; } #ifm .status.err { color:var(--H); }
  #ifm .banner { background:#fff8e1; border:1px solid #ffcc80; border-radius:10px; padding:10px 12px; margin-bottom:14px; font-size:14px; }
  #ifm .banner .btns { margin-top:8px; }
  /* ===== Gantt ===== */
  #ifm table.gtable { min-width:760px; }
  #ifm .gtable td.prog select { width:76px; }
  #ifm .warnTxt { color:var(--H); font-size:12px; }
  #ifm #msg { position:fixed; bottom:16px; left:50%; transform:translateX(-50%); background:#222; color:#fff; padding:8px 14px; border-radius:6px; font-size:14px; display:none; }

/* Small spacing helpers (used instead of style="..." in the HTML,
   because the site's security rules block inline styles) */
#ifm .mt8 { margin-top: 8px; }
#ifm .mt10 { margin-top: 10px; }
#ifm .sev { flex: 0 1 160px; }
#ifm .card, #ifm .banner { color: #1d2430; }   /* dark text on the light boxes, also in dark mode */

/* ===== 8D report form ===== */
#ifm input[type=checkbox] { width:auto; }
#ifm textarea { resize:vertical; }
#ifm .dcode { display:inline-block; background:var(--blue); color:#fff; border-radius:5px; padding:1px 7px; margin-right:8px; font-size:13px; vertical-align:2px; }
#ifm .d8table { min-width:640px; }
#ifm .d8info { margin-bottom:10px; }
#ifm .d8info p { margin:2px 0; font-size:14px; }
#ifm .rc { border-top:1px solid var(--line); padding:8px 0; }
#ifm label.rcl { display:flex; gap:8px; align-items:center; color:var(--text); font-size:14px; margin:0; cursor:pointer; }
#ifm .rccat { font-size:11px; background:#eef2f7; border-radius:4px; padding:1px 6px; color:var(--muted); }
#ifm .whys { margin:6px 0 0 26px; }
#ifm .why { display:flex; gap:8px; align-items:center; margin-bottom:4px; }
#ifm .whyn { font-size:12px; color:var(--muted); white-space:nowrap; width:44px; flex:none; }
#ifm .d7chk { display:flex; gap:16px; flex-wrap:wrap; margin-bottom:10px; }
#ifm label.inl { display:flex; align-items:center; gap:4px; color:var(--text); font-size:14px; margin:0; cursor:pointer; }
#ifm .print8d { margin-right:10px; }

/* ===== The clean 8D report: hidden on screen, shown only when printing ===== */
#ifm #report8d { display:none; font:10.5pt/1.4 Arial, sans-serif; color:#000; background:#fff; }
#ifm #report8d h1 { font-size:20pt; margin:0; }
#ifm #report8d .rsub { font-size:12pt; margin:2px 0 10px; }
#ifm #report8d h2 { font-size:13pt; border-bottom:1.5px solid #2563eb; padding-bottom:2px; margin:16px 0 6px; break-after:avoid; }
#ifm #report8d table { border-collapse:collapse; width:100%; min-width:0; font-size:9.5pt; margin:4px 0; }
#ifm #report8d th, #ifm #report8d td { border:1px solid #999; padding:3px 5px; text-align:left; vertical-align:top; }
#ifm #report8d th { background:#eef2f7; }
#ifm #report8d tr { break-inside:avoid; }
#ifm #report8d svg { display:block; width:100%; height:auto; min-width:0; margin:4px 0; break-inside:avoid; }
#ifm #report8d .pre { white-space:pre-wrap; margin:4px 0; }
#ifm #report8d .rcblock { break-inside:avoid; margin:6px 0; }
#ifm #report8d .rct { font-weight:bold; margin:0; }
#ifm #report8d .rroot { color:#b42318; font-weight:bold; margin:2px 0; }
#ifm #report8d ol { margin:2px 0 2px 18px; padding:0; }
#ifm #report8d .rlab { font-weight:bold; margin:8px 0 2px; break-after:avoid; }   /* keep label with its picture */
#ifm #report8d .d7list { list-style:none; padding:0; margin:4px 0; }
#ifm #report8d .rfoot { margin-top:18px; font-size:8.5pt; color:#666; }

/* When printing: hide the whole page except the 8D report */
@media print {
  @page { size:A4; margin:12mm; }
  body { background:#fff !important; }
  .site-header, .site-footer, main.wrap > h1, main.wrap > .lead { display:none !important; }
  #ifm > * { display:none !important; }
  #ifm > #report8d { display:block !important; }
  .wrap.wide { max-width:none !important; padding:0 !important; }
  * { -webkit-print-color-adjust:exact; print-color-adjust:exact; }
}

/* ===== FMEA table (AIAG-VDA style, scrolls sideways) ===== */
/* Group header row: one light color per FMEA step */
#ifm #fmeaTable tr.grp th { text-align:center; font-size:12px; letter-spacing:.3px; }
#ifm #fmeaTable tr.grp th.g0 { background:#e3f2fd; }   /* structure & function */
#ifm #fmeaTable tr.grp th.g1 { background:#fff3e0; }   /* failure analysis */
#ifm #fmeaTable tr.grp th.g2 { background:#fce4ec; }   /* risk analysis */
#ifm #fmeaTable tr.grp th.g3 { background:#e8f5e9; }   /* optimization */
#ifm #fmeaTable tr.grp th.g4 { background:#fff; border-color:transparent; }
/* Grey hint text = value taken from the top of the page */
#ifm #fmeaTable input::placeholder { color:#9aa5b4; font-style:italic; }
/* Full-screen-width page while the FMEA tab is open */
main.wrap.wide.fullw { max-width:none; }
/* Fixed layout: column widths come from the <colgroup> (script), stretched to the page.
   On small screens (laptops) the table keeps a minimum width and scrolls sideways. */
#ifm #fmeaTable { table-layout:fixed; width:100%; min-width:1500px; font-size:12px; }
#ifm #fmeaTable th { font-size:11px; padding:3px 4px; line-height:1.25; vertical-align:bottom; }
#ifm #fmeaTable td { padding:2px; }
/* Text cells: wrap onto more lines instead of hiding text */
#ifm #fmeaTable textarea { display:block; width:100%; min-height:28px; resize:none; overflow:hidden;
  font-size:12px; line-height:1.35; padding:4px 5px; }
#ifm #fmeaTable input[type=date] { font-size:11px; padding:4px 2px; width:100%; }
/* S, O, D (and revised) + status: compact, no arrow, number centered */
#ifm #fmeaTable td.num select, #ifm #fmeaTable td.prog select, #ifm #fmeaTable td:nth-child(6) select {
  appearance:none; -webkit-appearance:none; width:100%; padding:4px 2px; font-size:12px; text-align:center; text-align-last:center; }
#ifm #fmeaTable td:nth-child(6) select { text-align:left; text-align-last:left; padding-left:4px; }
/* AP badge + RPN under it */
#ifm #fmeaTable .ap { font-size:12px; padding:3px 0; }
#ifm #fmeaTable .rpn { font-size:10px; color:var(--muted); text-align:center; margin-top:1px; }
#ifm #fmeaTable .ico { padding:2px 0; width:24px; font-size:13px; line-height:1.2; }
/* Header rows stay visible while scrolling down a long FMEA (big screens) */
@media (min-width:1500px) {
  #ifm #v-fmea .tablewrap { overflow:visible; }
  #ifm #fmeaTable tr.grp th { position:sticky; top:0; z-index:2; height:22px; }
  #ifm #fmeaTable tr.hdr th { position:sticky; top:22px; z-index:2; }
}
#ifm #fmeaTable .rowbtns { display:flex; flex-direction:column; gap:3px; align-items:center; }

/* ===== Import CSV check box ===== */
#ifm .filebtn.small { padding:3px 8px; font-size:13px; }
#ifm .importbox { margin-top:10px; border:1px solid #90caf9; background:#f3f8ff; border-radius:8px; padding:10px 12px; font-size:13px; }
#ifm .importbox p { margin:0 0 6px; }
#ifm .importbox ul { margin:0 0 8px 18px; padding:0; }
#ifm .importbox .warn { color:#e65100; }
#ifm .importbox .err { color:var(--H); font-weight:600; }

/* ===== Explanation text under the tool: comfortable reading width ===== */
.wrap.wide .info { max-width:820px; margin-top:32px; }

/* ===== Gantt: scale buttons and time fields ===== */
#ifm .gscale { display:flex; gap:6px; align-items:center; flex-wrap:wrap; margin-bottom:8px; }
#ifm .gscale .note { margin:0; }
#ifm .gscale button.on { background:var(--blue); color:#fff; }
#ifm table.gtable { min-width:980px; }
#ifm .gtable td.tm input { width:96px; }


/* ===== Gantt page: dragging bars ===== */
#ifm .gscale .snapn { width:70px; padding:4px 6px; font-size:13px; }
#ifm .gscale .snapu { width:auto; padding:4px 6px; font-size:13px; }
#ifm .gscale button:disabled { opacity:.45; cursor:default; }
#ifm #gantt .gbar { cursor:move; }
#ifm #gantt .ghandle { cursor:ew-resize; }

/* ===== Gantt page: duration and "After" columns ===== */
#ifm .gtable td input.dur { width:110px; }
#ifm .gtable td input.dur.bad { border-color:var(--H); }
#ifm .gtable td select.after { width:170px; font-size:13px; }
#ifm .gtable td input:disabled { background:#f1f3f6; color:#5f6b7a; }
body[data-mode=gantt] #ifm table.gtable { min-width:1250px; }
#ifm .tznote { margin-top:-4px; }

/* ===== Gantt page: time zones and places ===== */
#ifm input.tz { width:170px; padding:4px 6px; font-size:13px; }
#ifm input.tz.bad { border-color:var(--H); background:#fff5f5; }
#ifm .places { display:flex; flex-direction:column; gap:4px; min-width:330px; }
#ifm .places .pl { display:flex; flex-wrap:wrap; gap:4px; align-items:center; }
#ifm .places .pll { width:34px; font-size:12px; color:var(--muted); }
#ifm .places .pn { width:110px; padding:4px 6px; font-size:13px; }
#ifm .places .tz { width:150px; }
#ifm .places .plt { width:100%; padding-left:38px; font-size:12px; color:#0d47a1; font-weight:600; }
body[data-mode=gantt] #ifm table.gtable { min-width:1600px; }

/* Gantt page: use the full screen width (wide table with places and local times) */
body[data-mode=gantt] main.wrap.wide { max-width:1900px; }
body[data-mode=gantt] main.wrap.wide > .info { max-width:820px; }

#ifm .places .tzclr { padding:1px 6px; font-size:12px; }

/* ===== Columns resizable with the mouse; text cells wrap and grow ===== */
#ifm table.rcols { table-layout:fixed; }
#ifm table.rcols th { position:relative; }
#ifm #fmeaTable tr.grp th, #ifm #fmeaTable tr.hdr th { overflow:visible; }
#ifm .colgrip { position:absolute; top:0; right:0; width:7px; height:100%; cursor:col-resize; z-index:3; touch-action:none; }
#ifm .colgrip:hover, #ifm .colgrip:active { background:rgba(37,99,235,.35); }
#ifm table.rcols td input, #ifm table.rcols td select { width:100%; min-width:0; }
#ifm table.rcols td input.tz { width:150px; }
#ifm table.rcols td input.pn { width:110px; }
/* text boxes in tables: wrap long text, can be made taller by dragging the corner */
#ifm table.rcols textarea { display:block; width:100%; min-height:30px; resize:vertical; overflow:hidden;
  font:inherit; font-size:13px; line-height:1.35; padding:5px 6px; border:1px solid var(--line); border-radius:6px; }
#ifm #fmeaTable textarea { resize:vertical; }

/* ===== Gantt page: zoom and move ===== */
#ifm #gantt .gname { cursor:zoom-in; }
#ifm #gantt .gname:hover { text-decoration:underline; }
#ifm #gantt.panning { cursor:grabbing; }
body[data-mode=gantt] #ifm .svgwrap { overflow-x:hidden; }
body[data-mode=gantt] #ifm .svgwrap svg { min-width:0; }

/* No blue/grey text highlight when dragging on the Gantt chart */
#ifm #gantt, #ifm #gantt text { -webkit-user-select:none; user-select:none; }
body.gdragging, body.gdragging * { -webkit-user-select:none !important; user-select:none !important; }

/* ===== Gantt page: row order, groups, calendar ===== */
#ifm #ganttTable td.grip { text-align:center; padding:0; }
#ifm .rowgrip { display:inline-block; cursor:grab; color:#90a4ae; font-size:16px; padding:6px 4px; user-select:none; }
#ifm .rowgrip:hover { color:var(--blue); }
#ifm #ganttTable tr.dragging { opacity:.45; }
#ifm #ganttTable tr.dropbefore td { box-shadow:inset 0 3px 0 var(--blue); }
#ifm #ganttTable tr.dropafter td { box-shadow:inset 0 -3px 0 var(--blue); }
#ifm #ganttTable tr.grow td { background:#eef2f7; }
#ifm #ganttTable tr.grow textarea { font-weight:700; background:#fff; }
#ifm .gnamebox { display:flex; gap:4px; align-items:flex-start; }
#ifm .gtoggle { padding:3px 7px; }
#ifm .ginfo { font-size:13px; color:#37474f; font-weight:600; padding:4px 2px; }
#ifm #ganttTable textarea.indent { margin-left:14px; width:calc(100% - 14px); }
#ifm .rowtools { display:flex; gap:3px; }
#ifm .rowtools button { padding:2px 7px; }
#ifm #gantt .gtog { cursor:pointer; }
#ifm input.hol { width:420px; max-width:100%; padding:4px 6px; font-size:13px; }
#ifm input.hol:disabled { background:#f1f3f6; }
#ifm .gscale label.inl { display:inline-flex; align-items:center; gap:5px; margin:0; font-size:13px; color:var(--text); }

/* Moving a row: label next to the mouse, no text selection, grab cursor everywhere */
.rowdragtip { position:fixed; z-index:50; pointer-events:none; background:#2563eb; color:#fff; font:600 12px/1.3 system-ui,Arial,sans-serif; padding:4px 8px; border-radius:5px; box-shadow:0 2px 6px rgba(0,0,0,.25); }
body.rowmoving, body.rowmoving * { cursor:grabbing !important; }
#ifm .rowgrip { touch-action:none; }

/* "Lock bars": no move / resize cursors on a locked chart */
#ifm #gantt.locked .gbar, #ifm #gantt.locked .ghandle { cursor:not-allowed; }
#ifm .gscale label.lock { font-weight:600; padding:3px 8px; border:1px solid var(--line); border-radius:6px; background:#fff; }
#ifm .gscale label.lock:has(input:checked) { background:#fff3e0; border-color:#ffb74d; }

/* ===== Critical path ===== */
#ifm #ganttTable .crit { color:#ad1457; font-size:11px; font-weight:700; margin-top:2px; }
#ifm #ganttTable .slack { color:#78909c; font-size:11px; margin-top:2px; }
#ifm #ganttTable .crit.indent, #ifm #ganttTable .slack.indent { margin-left:14px; }
#ifm .critinfo { color:#ad1457; font-weight:600; }

/* Gantt page: the line between names and timeline can be dragged */
#ifm #gantt .namegrip { cursor:col-resize; }
#ifm #gantt .namegrip:hover { fill:rgba(37,99,235,.25); }
body.colresizing, body.colresizing * { cursor:col-resize !important; }
