@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@300;400;500;600&family=Space+Mono:wght@400;700&display=swap');

:root {
  --c-bg:        #f4f3ef;
  --c-surface:   #ffffff;
  --c-border:    #e2e1dc;
  --c-text:      #1a1a1a;
  --c-muted:     #6b6b6b;
  --c-accent:    #e8650a;
  --c-accent-h:  #c85508;
  --c-navy:      #1e2b3c;
  --c-navy-l:    #263548;
  --c-green:     #22a06b;
  --c-red:       #d93025;
  --font-main:   'DM Sans', sans-serif;
  --font-mono:   'Space Mono', monospace;
  --radius:      10px;
  --shadow-sm:   0 1px 3px rgba(0,0,0,.08);
  --shadow-md:   0 4px 16px rgba(0,0,0,.10);
  --transition:  .18s ease;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body { font-family: var(--font-main); background: var(--c-bg); color: var(--c-text); line-height: 1.5; min-height: 100vh; display: flex; flex-direction: column; }
img, svg { display: block; }
a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; }

/* NAV */
.nav { background: var(--c-navy); border-bottom: 3px solid var(--c-accent); position: sticky; top: 0; z-index: 100; }
.nav__inner { max-width: 1280px; margin: 0 auto; padding: 0 20px; display: flex; align-items: center; justify-content: space-between; height: 58px; }
.nav__brand { display: flex; align-items: center; gap: 10px; }
.nav__logo { width: 32px; height: 32px; background: var(--c-accent); border-radius: 7px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.nav__logo svg { color: #fff; }
.nav__title { font-family: var(--font-mono); font-size: 18px; font-weight: 700; color: #fff; letter-spacing: -0.5px; }
.nav__title span { color: var(--c-accent); }
.nav__links { display: flex; gap: 4px; list-style: none; align-items: center; }
.nav__links a { color: rgba(255,255,255,.75); font-size: 13px; font-weight: 500; padding: 6px 12px; border-radius: 6px; transition: var(--transition); }
.nav__links a:hover, .nav__links a.active { color: #fff; background: rgba(255,255,255,.08); }
.nav__links a.active { color: var(--c-accent); }
.nav__burger { display: none; background: none; border: none; padding: 6px; flex-direction: column; gap: 5px; }
.nav__burger span { display: block; width: 22px; height: 2px; background: rgba(255,255,255,.8); border-radius: 2px; transition: var(--transition); }
.nav__mobile { display: none; flex-direction: column; background: var(--c-navy-l); padding: 8px 16px 12px; }
.nav__mobile a { color: rgba(255,255,255,.8); font-size: 14px; font-weight: 500; padding: 10px 8px; border-bottom: 1px solid rgba(255,255,255,.06); display: block; transition: var(--transition); }
.nav__mobile a:last-child { border: none; }
.nav__mobile a:hover { color: var(--c-accent); }
.nav__mobile.open { display: flex; }

/* HERO */
.page-hero { background: linear-gradient(135deg, var(--c-navy) 0%, #2a3f58 100%); padding: 36px 20px 32px; text-align: center; }
.page-hero h1 { font-size: clamp(22px, 4vw, 32px); font-weight: 600; color: #fff; letter-spacing: -0.5px; }
.page-hero p { color: rgba(255,255,255,.6); font-size: 14px; margin-top: 6px; max-width: 560px; margin-left: auto; margin-right: auto; }

/* MAIN */
.main-content { flex: 1; }
.app-wrap { max-width: 1280px; margin: 0 auto; padding: 20px 16px 40px; display: flex; flex-direction: column; gap: 18px; }

/* PANELS */
.panel { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow-sm); }
.panel__title { font-size: 11px; font-weight: 600; color: var(--c-muted); letter-spacing: .8px; text-transform: uppercase; display: flex; align-items: center; gap: 7px; margin-bottom: 14px; padding-bottom: 10px; border-bottom: 1px solid var(--c-border); }
.panel__title svg { flex-shrink: 0; }

/* TOP SECTION: full width, kerf inside */
.top-section { width: 100%; }
.top-section-inner { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.top-section-inner.stacked-blocks { display: flex; flex-direction: column; gap: 18px; }
.top-section-inner.stacked-blocks > div { border: 1px solid var(--c-border); border-radius: 8px; padding: 16px; background: var(--c-bg); }
.kerf-row { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--c-border); display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.kerf-row label { font-size: 10px; font-weight: 600; color: var(--c-muted); letter-spacing: .6px; text-transform: uppercase; white-space: nowrap; }
.kerf-row .inp { width: 120px; }

/* FAQ full width */
.faq-section { width: 100%; }
.faq-section .faq { max-width: 1280px; margin-left: auto; margin-right: auto; }

/* FORM */
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 10px; font-weight: 600; color: var(--c-muted); letter-spacing: .6px; text-transform: uppercase; margin-bottom: 4px; }
.inp { padding: 9px 11px; border: 1.5px solid var(--c-border); border-radius: 7px; font-size: 14px; color: var(--c-text); background: var(--c-bg); transition: border-color var(--transition), box-shadow var(--transition); -webkit-appearance: none; }
.inp:focus { border-color: var(--c-accent); outline: none; box-shadow: 0 0 0 3px rgba(232,101,10,.12); background: #fff; }
.hint-icon { display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; margin-left: 4px; background: var(--c-border); color: var(--c-text); border-radius: 50%; font-size: 11px; font-weight: 600; cursor: help; }
.hint-icon:hover { background: var(--c-accent); color: #fff; }

/* TABLE */
.parts-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 14px; gap: 12px; flex-wrap: wrap; }
.parts-header h2 { font-size: 16px; font-weight: 600; }
.parts-header p  { font-size: 12px; color: var(--c-muted); margin-top: 2px; }
.parts-badge { background: var(--c-accent); color: #fff; font-size: 11px; font-weight: 700; font-family: var(--font-mono); padding: 3px 9px; border-radius: 20px; white-space: nowrap; align-self: flex-start; }
.tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; table-layout: fixed; }
.tbl th { text-align: left; font-size: 10px; font-weight: 600; color: var(--c-muted); letter-spacing: .6px; text-transform: uppercase; padding: 8px 8px; background: var(--c-bg); border-bottom: 2px solid var(--c-border); }
.tbl td { padding: 7px 8px; border-bottom: 1px solid var(--c-border); vertical-align: middle; }
.tbl tr:last-child td { border: none; }
.tbl tr:hover td { background: #fafaf8; }
.tinp { width: 100%; padding: 6px 8px; border: 1.5px solid var(--c-border); border-radius: 6px; font-size: 14px; background: var(--c-bg); color: var(--c-text); transition: border-color var(--transition); }
.tinp:focus { border-color: var(--c-accent); outline: none; }
.btn-add { background: var(--c-accent); border: none; color: #fff; width: 30px; height: 30px; border-radius: 7px; font-size: 18px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; transition: background var(--transition); }
.btn-add:hover { background: var(--c-accent-h); }
.btn-del { background: none; border: none; color: #c0392b; font-size: 15px; padding: 3px 6px; border-radius: 5px; transition: background var(--transition); }
.btn-del:hover { background: #fdf0f0; }
.col-hide-sm { }

/* PRIORITY ARROWS */

/* BOARD CARD COMPACT */
.board-card-compact .board-hdr { margin-bottom: 6px; }
.board-card-compact .board-hdr__title { font-size: 14px; }
.board-hdr__title-text { font-size: 13px; font-family: var(--font-mono); font-weight: 700; color: var(--c-text); }
.board-hdr__title-text .count-label { color: var(--c-accent); margin-right: 4px; }
.board-meta-line { font-size: 11px; color: var(--c-muted); margin-bottom: 6px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.board-meta-line .waste-inline { color: var(--c-accent); font-weight: 600; font-family: var(--font-mono); }
.board-meta-line .eff-inline { color: var(--c-green); font-weight: 600; font-family: var(--font-mono); }
.legend-inline { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 4px; align-items: center; font-size: 11px; }
.legend-inline-item { display: flex; align-items: center; gap: 4px; color: var(--c-muted); }
.legend-inline-item .legend-dot { width: 10px; height: 10px; border-radius: 2px; flex-shrink: 0; border: 1px solid rgba(0,0,0,.1); }
.calc-btn-wrap { display: flex; justify-content: left; }
.calc-btn-wrap .btn-run { width: auto !important; min-width: 280px; padding: 16px 40px; font-size: 16px; }
.btn-run { width: 100%; margin-top: 0; padding: 14px; background: var(--c-accent); color: #fff; border: none; border-radius: 8px; font-size: 15px; font-weight: 600; display: flex; align-items: center; justify-content: center; gap: 8px; transition: background var(--transition), transform var(--transition), box-shadow var(--transition); box-shadow: 0 4px 12px rgba(232,101,10,.3); }
.btn-run:hover { background: var(--c-accent-h); transform: translateY(-1px); box-shadow: 0 6px 18px rgba(232,101,10,.4); }
.btn-run:active { transform: translateY(0); }

/* RESULTS */
.results-section { display: flex; flex-direction: column; gap: 16px; }
.results-section.hidden { display: none !important; }

/* SUMMARY */
.summary { background: var(--c-navy); border-radius: var(--radius); padding: 16px; color: #fff; }
.summary h3 { font-size: 11px; font-weight: 600; color: var(--c-accent); letter-spacing: .8px; text-transform: uppercase; margin-bottom: 12px; }
.summary__row { display: flex; justify-content: space-between; align-items: center; font-size: 13px; padding: 7px 0; border-bottom: 1px solid rgba(255,255,255,.07); }
.summary__row:last-child { border: none; }
.summary__val { font-weight: 600; font-family: var(--font-mono); font-size: 13px; }
.summary__val--accent { color: var(--c-accent); }
.summary__val--green { color: #4ade80; font-size: 15px; }

/* CUT DIAGRAM CARDS */
.boards-wrap { display: flex; flex-direction: column; gap: 16px; }
.board-card { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow-sm); }
.board-hdr { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.board-hdr__title { font-size: 22px; font-weight: 700; color: var(--c-text); font-family: var(--font-mono); }
.board-hdr__title .count-label { font-size: 16px; font-weight: 600; color: var(--c-accent); margin-left: 8px; }
.board-hdr__stats { font-size: 12px; color: var(--c-muted); display: flex; gap: 14px; flex-wrap: wrap; align-items: center; }

/* SVG CUT DIAGRAM */
.cut-diagram-wrap { overflow-x: auto; margin-bottom: 10px; }
.cut-diagram-wrap svg { display: block; }

/* STAT CHIPS – pjovimo pozicijos */
.wall-stats { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.stat-chip { background: var(--c-bg); border: 1px solid var(--c-border); border-radius: 20px; padding: 4px 10px; font-size: 11px; font-weight: 500; color: var(--c-text); display: flex; align-items: center; gap: 5px; }
.stat-chip strong { font-family: var(--font-mono); color: var(--c-accent); }

/* Piece info chips */
.piece-info { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.piece-chip { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: 8px; padding: 5px 12px; font-size: 13px; font-weight: 600; color: var(--c-text); display: flex; align-items: center; gap: 8px; }
.piece-chip__color { width: 14px; height: 14px; border-radius: 3px; flex-shrink: 0; border: 1px solid rgba(0,0,0,.12); }
.piece-chip__len { font-family: var(--font-mono); font-size: 15px; font-weight: 700; color: var(--c-text); }
.piece-chip__name { font-size: 12px; color: var(--c-muted); }

/* Waste info */
.waste-info { margin-top: 8px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.waste-tag { background: #f5f5f2; border: 1px solid var(--c-border); border-radius: 8px; padding: 5px 12px; font-size: 13px; color: var(--c-muted); display: flex; gap: 8px; align-items: center; }
.waste-tag strong { font-family: var(--font-mono); color: var(--c-text); }
.eff-tag { background: #f0fdf4; border: 1px solid #bbf7d0; border-radius: 8px; padding: 5px 12px; font-size: 13px; color: var(--c-green); font-weight: 600; font-family: var(--font-mono); }
.eff-tag.eff-o { background: #fff7ed; border-color: #fed7aa; color: var(--c-accent); }
.eff-tag.eff-r { background: #fef2f2; border-color: #fecaca; color: var(--c-red); }

/* CUT LEGEND */
.cut-legend { display: flex; flex-wrap: wrap; gap: 8px 20px; margin-top: 10px; padding: 10px 14px; background: var(--c-bg); border: 1px solid var(--c-border); border-radius: 7px; align-items: center; }
.cut-legend__label { font-size: 10px; font-weight: 600; color: var(--c-muted); letter-spacing: .6px; text-transform: uppercase; flex-basis: 100%; margin-bottom: 2px; }
.cut-legend__item { display: flex; align-items: center; gap: 7px; font-size: 12px; }
.cut-legend__color { width: 24px; height: 12px; border-radius: 3px; flex-shrink: 0; border: 1px solid rgba(0,0,0,.12); }
.cut-legend__name { font-weight: 600; color: var(--c-text); }
.cut-legend__dim { font-family: var(--font-mono); font-size: 11px; color: var(--c-muted); }

/* INFO NOTE */
.info-note { display: flex; gap: 12px; background: #fff5f5; border-left: 4px solid var(--c-red); padding: 16px; border-radius: var(--radius); color: #a8201a; font-size: 14px; line-height: 1.5; border: 1px solid #fed7d7; }
.info-note__icon { flex-shrink: 0; color: var(--c-red); margin-top: 2px; }
.info-note strong { display: block; margin-bottom: 2px; color: #7d120e; }

/* INSTRUCTIONS */
.info-section { max-width: 1280px; margin: 0 auto; padding: 40px 16px 60px; }
.info-section h2 { font-size: clamp(20px, 3vw, 26px); font-weight: 600; margin-bottom: 6px; letter-spacing: -0.3px; }
.info-section .sub { color: var(--c-muted); font-size: 14px; margin-bottom: 28px; }
.steps { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; margin-bottom: 40px; }
.step-card { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow-sm); position: relative; overflow: hidden; }
.step-card::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px; background: var(--c-accent); }
.step-num { font-family: var(--font-mono); font-size: 28px; font-weight: 700; color: rgba(232,101,10,.15); line-height: 1; margin-bottom: 8px; }
.step-card h3 { font-size: 14px; font-weight: 600; margin-bottom: 6px; }
.step-card p  { font-size: 13px; color: var(--c-muted); line-height: 1.6; }

/* TIPS */
.grain-info { background: var(--c-navy); border-radius: var(--radius); padding: 24px; color: #fff; margin-bottom: 40px; }
.grain-info h3 { font-size: 16px; font-weight: 600; color: var(--c-accent); margin-bottom: 6px; }
.grain-info p  { font-size: 13px; color: rgba(255,255,255,.7); line-height: 1.7; }
.grain-visual { margin-top: 16px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.grain-box { background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.1); border-radius: 8px; padding: 14px; }
.grain-box h4 { font-size: 12px; font-weight: 600; color: rgba(255,255,255,.5); letter-spacing: .5px; margin-bottom: 8px; text-transform: uppercase; }
.grain-box p  { font-size: 13px; color: rgba(255,255,255,.8); line-height: 1.6; }
.grain-box svg { margin-bottom: 8px; color: var(--c-accent); }

/* FAQ */
.faq { display: flex; flex-direction: column; gap: 10px; margin: 0 0 40px; width: 100%; }
.faq-item { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius); overflow: hidden; width: 100%; }
.faq-q { width: 100%; text-align: left; padding: 16px 18px; background: none; border: none; font-size: 14px; font-weight: 600; color: var(--c-text); display: flex; align-items: center; justify-content: space-between; gap: 12px; cursor: pointer; }
.faq-a { display: none; padding: 16px 18px; font-size: 13px; color: var(--c-muted); line-height: 1.7; border-top: 1px solid var(--c-border); }
.faq-item.open .faq-a { display: block; }

/* FOOTER */
.footer { background: var(--c-navy); border-top: 3px solid var(--c-accent); color: rgba(255,255,255,.65); padding: 40px 20px 24px; }
.footer__inner { max-width: 1280px; margin: 0 auto; display: grid; grid-template-columns: 1.5fr 1fr 1fr; gap: 32px; }
.footer__brand .nav__logo { width: 36px; height: 36px; margin-bottom: 10px; }
.footer__brand h3 { font-family: var(--font-mono); font-size: 16px; color: #fff; font-weight: 700; }
.footer__brand p  { font-size: 13px; line-height: 1.7; margin-top: 6px; max-width: 260px; }
.footer__col h4 { font-size: 11px; font-weight: 600; color: #fff; letter-spacing: .8px; text-transform: uppercase; margin-bottom: 12px; }
.footer__col ul { list-style: none; display: flex; flex-direction: column; gap: 7px; }
.footer__col a { font-size: 13px; color: rgba(255,255,255,.55); transition: color var(--transition); }
.footer__col a:hover { color: var(--c-accent); }
.footer__bottom { max-width: 1280px; margin: 28px auto 0; padding-top: 18px; border-top: 1px solid rgba(255,255,255,.08); display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; font-size: 12px; color: rgba(255,255,255,.35); }

/* TOAST */
#toast { position: fixed; top: 24px; left: 50%; transform: translateX(-50%); min-width: 320px; max-width: 90%; background: #c0392b; color: #fff; padding: 16px 20px; border-radius: 12px; font-size: 14px; font-weight: 500; line-height: 1.5; z-index: 9999; box-shadow: 0 10px 30px rgba(192,57,43,.3); border-left: 6px solid #8e2a20; display: flex; align-items: center; gap: 12px; animation: slideIn 0.3s ease-out forwards; }
@keyframes slideIn { from { opacity: 0; transform: translate(-50%, -20px); } to { opacity: 1; transform: translate(-50%, 0); } }
@keyframes fadeIn { from { opacity:0; transform:translateX(-50%) translateY(8px); } to { opacity:1; transform:translateX(-50%) translateY(0); } }

/* UTILITY */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.hidden { display: none !important; }
.eff-g { color: var(--c-green); font-weight: 600; }
.eff-o { color: var(--c-accent); font-weight: 600; }
.eff-r { color: var(--c-red); font-weight: 600; }

/* PRINT */
@media print {
  /* Hide everything except results */
  .nav, .page-hero, .calc-btn-wrap, #instructions, .info-section, .footer, .no-print,
  .top-section-inner, .stacked-blocks { display: none !important; }

  body { background: #fff; font-family: Arial, sans-serif; color: #000; font-size: 11px; margin: 0; padding: 0; }
  .main-content { padding: 0; }
  .app-wrap { padding: 0 12px; max-width: 100%; }

  /* Results section: stack vertically */
  .results-section { display: block !important; }
  .results-section.hidden { display: block !important; }

  /* Print header visible */
  .print-header { display: block !important; padding-bottom: 8px; margin-bottom: 8px; border-bottom: 2px solid #333; }
  .print-header h2 { font-size: 16px; font-weight: 700; color: #000; }
  .print-header p { font-size: 10px; color: #555; margin-top: 2px; }

  /* Settings table */
  .print-settings { display: block !important; padding: 6px 10px; margin-bottom: 10px; background: #f5f5f0; border: 1px solid #ccc; }
  .print-settings h3 { font-size: 10px; font-weight: 700; text-transform: uppercase; margin-bottom: 4px; }
  .print-settings td { padding: 2px 6px 2px 0; font-size: 10px; }

  /* Summary box */
  .summary { background: none !important; border: 1px solid #333; color: #000 !important; padding: 8px 12px; margin-bottom: 10px; }
  .summary h3 { color: #000 !important; font-size: 10px; margin-bottom: 6px; }
  .summary__val, .summary__val--green, .summary__val--accent { color: #000 !important; font-size: 11px; }
  .summary__row { border-bottom: 1px solid #ddd; padding: 3px 0; font-size: 11px; }

  /* Board diagrams */
  .boards-wrap { display: flex; flex-direction: column; gap: 6px; }
  .board-card { border: 1px solid #999; box-shadow: none; page-break-inside: avoid; margin-bottom: 6px; padding: 8px 10px; }
  .board-hdr__title-text { font-size: 11px; }
  .cut-diagram-wrap svg { max-height: 60px !important; }
  .legend-inline { font-size: 10px; gap: 3px 8px; margin-top: 4px; }
  .legend-dot { display: inline-block !important; }

  * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }

  /* Print footer */
  .print-footer-note { display: block !important; }
}

.print-footer-note { display: none; margin-top: 20px; padding-top: 10px; border-top: 1px solid #ccc; font-size: 10px; color: #555; text-align: center; }
.print-header h2 { font-size: 20px; font-weight: 700; color: var(--c-navy); }
.print-header p { font-size: 12px; color: var(--c-muted); margin-top: 2px; }

.print-settings { display: none; background: #f5f5f0; border: 1px solid #ccc; border-radius: 6px; padding: 12px 16px; margin-bottom: 16px; font-size: 13px; }
.print-settings h3 { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; margin-bottom: 8px; color: #333; }
.print-settings table { border-collapse: collapse; width: 100%; }
.print-settings td { padding: 3px 8px 3px 0; font-size: 12px; color: #333; vertical-align: top; }
.print-settings td:first-child { font-weight: 600; white-space: nowrap; padding-right: 16px; }

/* RESPONSIVE */
@media (max-width: 960px) {
  .top-section-inner { grid-template-columns: 1fr; }
  .footer__inner { grid-template-columns: 1fr 1fr; }
  .grain-visual { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 640px) {
  .nav__links { display: none; }
  .nav__burger { display: flex; }
  .footer__inner { grid-template-columns: 1fr; gap: 24px; }
  .grain-visual { grid-template-columns: 1fr; }
  .steps { grid-template-columns: 1fr; }
  .col-hide-sm { display: none; }
  .tinp { font-size: 13px; padding: 7px 8px; }
  .calc-btn-wrap .btn-run { min-width: unset; width: 100%; }
}
@media (max-width: 480px) {
  .app-wrap { padding: 12px 10px 30px; }
  .panel { padding: 14px; }
  .board-card { padding: 12px; }
}
