/**
 * TARJOUSAPURI — MiniApp Styles
 * Cyber-teema, A4-esikatselu, PDF-tulostus
 * Digitoimisto Lapio — 2026
 */

/* === APP-RUNKO === */
.ta-app {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  height: 100%;
  min-height: 0;
}

@media (max-width: 768px) {
  .ta-app {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto;
  }
}

/* === VASEN PANEELI (lomake) === */
.ta-left {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  overflow-y: auto;
  padding-right: 4px;
  min-height: 0;
}

.ta-left::-webkit-scrollbar { width: 6px; }
.ta-left::-webkit-scrollbar-track { background: transparent; }
.ta-left::-webkit-scrollbar-thumb { background: var(--glass-border); border-radius: 3px; }
.ta-left::-webkit-scrollbar-thumb:hover { background: var(--accent-primary); }

.ta-section {
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius-btn, 4px);
  padding: 1rem;
}

.ta-section h4 {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent-primary);
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.ta-section h4 i {
  font-size: 0.9rem;
  opacity: 0.8;
}

.ta-section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.ta-section-head h4 {
  margin-bottom: 0;
}

/* === INPUTIT === */
.ta-input,
.ta-cell-input {
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius-btn, 4px);
  padding: 0.5rem 0.65rem;
  color: var(--text-main);
  font-family: var(--font-body);
  font-size: 0.85rem;
  width: 100%;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.ta-input:focus,
.ta-cell-input:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 10px rgba(0,255,157,0.12);
}

.ta-cell-input.ta-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.ta-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.ta-label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent-secondary);
}

.ta-check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  cursor: pointer;
}

.ta-check input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent-primary);
  cursor: pointer;
  flex-shrink: 0;
}

/* === TAULUKOT === */
.ta-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.ta-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}

.ta-table thead th {
  text-align: left;
  font-weight: 600;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent-secondary);
  padding: 0.35rem 0.3rem;
  border-bottom: 1px solid var(--glass-border);
  white-space: nowrap;
}

.ta-table tbody td {
  padding: 0.3rem;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  vertical-align: middle;
}

.ta-table .ta-cell-input {
  padding: 0.35rem 0.45rem;
  font-size: 0.8rem;
}

/* === NAPIT === */
.ta-btn-sm {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.7rem;
  background: transparent;
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius-btn, 4px);
  color: var(--accent-primary);
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: all 0.2s ease;
}

.ta-btn-sm:hover {
  background: rgba(0,255,157,0.08);
  border-color: var(--accent-primary);
  box-shadow: 0 0 12px rgba(0,255,157,0.15);
}

.ta-del {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.75rem;
  transition: all 0.15s ease;
}

.ta-del:hover {
  background: rgba(255,100,100,0.12);
  border-color: rgba(255,100,100,0.4);
  color: #ff6464;
}

/* === OIKEA PANEELI (esikatselu) === */
.ta-right {
  display: flex;
  flex-direction: column;
  min-height: 0;
  gap: 0.75rem;
}

.ta-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.ta-btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1.2rem;
  background: var(--accent-primary);
  border: 1px solid var(--accent-primary);
  border-radius: var(--border-radius-btn, 4px);
  color: var(--bg-color);
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  cursor: pointer;
  box-shadow: 0 0 15px rgba(0,255,157,0.25);
  transition: all 0.2s ease;
}

.ta-btn-primary:hover {
  background: var(--accent-secondary);
  border-color: var(--accent-secondary);
  color: #fff;
  box-shadow: 0 0 25px rgba(14,165,233,0.35);
  transform: translateY(-1px);
}

.ta-hint {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-style: italic;
}

/* === A4-ESIKATSELU === */
.ta-a4-wrap {
  flex: 1;
  overflow: auto;
  background: rgba(0,0,0,0.25);
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius-btn, 4px);
  padding: 1rem;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  -webkit-overflow-scrolling: touch;
}

.ta-a4-wrap::-webkit-scrollbar { width: 6px; }
.ta-a4-wrap::-webkit-scrollbar-track { background: transparent; }
.ta-a4-wrap::-webkit-scrollbar-thumb { background: var(--glass-border); border-radius: 3px; }

.ta-a4 {
  width: 210mm;
  min-height: 297mm;
  background: #fff;
  color: #1a1a1a;
  box-shadow: 0 4px 24px rgba(0,0,0,0.35);
  transform-origin: top center;
  transform: scale(0.65);
  margin-bottom: -105mm; /* kompensoi skaalausta */
}

@media (max-width: 768px) {
  .ta-a4 {
    transform: scale(0.5);
    margin-bottom: -150mm;
  }
}

@media (max-width: 480px) {
  .ta-a4 {
    transform: scale(0.42);
    margin-bottom: -175mm;
  }
}

/* === A4-SISÄLTÖ === */
.ta-a4-inner {
  padding: 18mm 20mm;
  font-family: 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  font-size: 10pt;
  line-height: 1.45;
  color: #1a1a1a;
}

.ta-a4-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  border-bottom: 2px solid #00c06e;
  padding-bottom: 12px;
  margin-bottom: 18px;
}

.ta-a4-brand {
  display: flex;
  gap: 12px;
  align-items: center;
}

.ta-a4-logo svg {
  display: block;
}

.ta-a4-company {
  font-size: 14pt;
  font-weight: 700;
  color: #0f172a;
  display: block;
}

.ta-a4-meta {
  font-size: 8pt;
  color: #555;
  margin-top: 2px;
}

.ta-a4-docinfo {
  text-align: right;
}

.ta-a4-label {
  font-size: 16pt;
  font-weight: 800;
  color: #00c06e;
  letter-spacing: 1px;
  line-height: 1;
  margin-bottom: 4px;
}

.ta-a4-customer {
  margin-bottom: 14px;
}

.ta-a4-to {
  font-size: 8pt;
  text-transform: uppercase;
  color: #666;
  letter-spacing: 0.5px;
  margin-bottom: 2px;
}

.ta-a4-cname {
  font-size: 12pt;
  font-weight: 700;
  color: #0f172a;
}

.ta-a4-project {
  background: #f6f6f6;
  padding: 8px 10px;
  border-radius: 4px;
  margin-bottom: 14px;
  font-size: 9.5pt;
}

.ta-a4-section {
  margin-bottom: 14px;
}

.ta-a4-h5 {
  font-size: 10pt;
  font-weight: 700;
  text-transform: uppercase;
  color: #00c06e;
  letter-spacing: 0.5px;
  border-bottom: 1px solid #e5e5e5;
  padding-bottom: 3px;
  margin-bottom: 6px;
}

.ta-a4-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 9.5pt;
  margin-bottom: 4px;
}

.ta-a4-table th {
  text-align: left;
  font-weight: 600;
  color: #444;
  padding: 4px 6px;
  border-bottom: 1px solid #ccc;
}

.ta-a4-table td {
  padding: 4px 6px;
  border-bottom: 1px solid #eee;
}

.ta-a4-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.ta-a4-subtotal {
  text-align: right;
  font-size: 9.5pt;
  color: #444;
  padding: 4px 6px;
}

.ta-a4-subtotal strong {
  color: #0f172a;
  font-weight: 700;
}

.ta-a4-totals {
  border-top: 2px solid #00c06e;
  padding-top: 10px;
  margin-top: 6px;
}

.ta-a4-total-row {
  display: flex;
  justify-content: space-between;
  padding: 3px 0;
  font-size: 9.5pt;
  color: #333;
}

.ta-a4-total-row.ta-total {
  font-size: 12pt;
  font-weight: 800;
  color: #0f172a;
  border-top: 1px solid #ddd;
  margin-top: 6px;
  padding-top: 6px;
}

.ta-a4-total-row.ta-hh {
  color: #008844;
}

.ta-a4-total-row.ta-final {
  font-size: 11pt;
  font-weight: 800;
  color: #0f172a;
  border-top: 2px solid #00c06e;
  margin-top: 4px;
  padding-top: 4px;
}

.ta-a4-note {
  font-size: 8pt;
  color: #555;
  margin-top: 14px;
  border-top: 1px solid #eee;
  padding-top: 8px;
}

.ta-a4-note p + p {
  margin-top: 4px;
}

.ta-a4-footer {
  display: flex;
  gap: 40px;
  margin-top: 30px;
  page-break-inside: avoid;
}

.ta-a4-signature {
  flex: 1;
  font-size: 8pt;
  color: #444;
}

.ta-a4-signline {
  border-bottom: 1px solid #333;
  height: 36px;
  margin-bottom: 4px;
}

.ta-placeholder {
  color: #bbb;
  font-style: italic;
}

/* === MOBIILI === */
@media (max-width: 768px) {
  .ta-right {
    order: -1;
  }

  .ta-a4-wrap {
    min-height: 420px;
  }

  .ta-toolbar {
    justify-content: center;
  }

  .ta-hint {
    display: none;
  }
}

@media (max-width: 480px) {
  .ta-grid-2 {
    grid-template-columns: 1fr;
  }

  .ta-table thead th {
    font-size: 0.65rem;
    padding: 0.25rem 0.2rem;
  }

  .ta-table tbody td {
    padding: 0.2rem;
  }

  .ta-table .ta-cell-input {
    padding: 0.25rem 0.3rem;
    font-size: 0.75rem;
  }

  .ta-del {
    width: 24px;
    height: 24px;
  }

  .ta-section {
    padding: 0.75rem;
  }

  .ta-a4-wrap {
    padding: 0.5rem;
    min-height: 340px;
  }
}

/* ============================================================
   TARJOUSAPURI v2 — Moderni hinnoittelu- ja katelaskentasovellus
   Mobile-first. Käyttää ta2- etuliitettä (ei törmää vanhaan ta-).
   ============================================================ */

.ta2-app {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* === TYÖKALUPALKKI: pohja + tulostus === */
.ta2-toolbar {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.ta2-template {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  flex: 1;
}

.ta2-ctrl-label {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent-secondary);
  font-family: var(--font-display, 'Space Grotesk', monospace);
}

.ta2-select {
  appearance: none;
  -webkit-appearance: none;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius-btn, 4px);
  color: var(--text-main);
  font-family: var(--font-body, 'Space Grotesk', monospace);
  font-size: 0.85rem;
  padding: 0.6rem 2rem 0.6rem 0.75rem;
  width: 100%;
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'%3E%3Cpath d='M1 1L6 6L11 1' stroke='%2300ff9d' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.7rem center;
}

.ta2-select:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 10px rgba(0,255,157,0.12);
}

.ta2-select option {
  background: #0f172a;
  color: var(--text-main);
}

.ta2-btn-print {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.7rem 1.2rem;
  background: var(--accent-primary);
  border: 1px solid var(--accent-primary);
  border-radius: var(--border-radius-btn, 4px);
  color: var(--bg-color);
  font-family: var(--font-display, 'Space Grotesk', monospace);
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  cursor: pointer;
  box-shadow: 0 0 15px rgba(0,255,157,0.25);
  transition: background 0.2s, box-shadow 0.2s, transform 0.2s;
  min-height: 44px;
}

.ta2-btn-print:hover {
  background: var(--accent-secondary);
  border-color: var(--accent-secondary);
  color: #fff;
  box-shadow: 0 0 25px rgba(14,165,233,0.35);
  transform: translateY(-1px);
}

.ta2-btn-print:active {
  transform: translateY(0);
}

/* === KPI-YHTEENVETO === */
.ta2-kpis {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.6rem;
}

.ta2-kpi {
  background: rgba(0,0,0,0.25);
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius-btn, 4px);
  padding: 0.85rem 0.7rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  transition: border-color 0.25s, box-shadow 0.25s, transform 0.25s;
}

.ta2-kpi:hover {
  border-color: rgba(0,255,157,0.3);
  box-shadow: 0 0 12px rgba(0,255,157,0.06);
}

.ta2-kpi-label {
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  font-family: var(--font-display, 'Space Grotesk', monospace);
}

.ta2-kpi-val {
  font-family: var(--font-display, 'Space Grotesk', monospace);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

.ta2-kpi-sub {
  font-size: 0.65rem;
  color: var(--text-muted);
  font-family: var(--font-display, 'Space Grotesk', monospace);
}

.ta2-kpi-gauge {
  grid-column: 1 / -1;
}

.ta2-kpi.ta2-flash {
  animation: ta2-flash 0.45s ease-out;
}

@keyframes ta2-flash {
  0% { box-shadow: 0 0 0 rgba(0,255,157,0); border-color: var(--glass-border); }
  40% { box-shadow: 0 0 14px rgba(0,255,157,0.25); border-color: var(--accent-primary); }
  100% { box-shadow: 0 0 0 rgba(0,255,157,0); }
}

/* Kataprosentin mittari */
.ta2-gauge {
  width: 100%;
  height: 7px;
  background: rgba(255,255,255,0.06);
  border-radius: 4px;
  overflow: hidden;
  margin-top: 0.25rem;
}

.ta2-gauge-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.5s cubic-bezier(0.22,1,0.36,1), background-color 0.3s, box-shadow 0.3s;
  min-width: 2px;
}

.ta2-gauge-fill[data-level="good"] {
  background: var(--accent-primary);
  box-shadow: 0 0 8px rgba(0,255,157,0.35);
}
.ta2-gauge-fill[data-level="ok"] {
  background: #facc15;
  box-shadow: 0 0 8px rgba(250,204,21,0.3);
}
.ta2-gauge-fill[data-level="low"] {
  background: #ff6464;
  box-shadow: 0 0 8px rgba(255,100,100,0.35);
}

/* === PÄÄASETTELU === */
.ta2-main {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.ta2-left {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.ta2-right {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* === KORTIT / OSIOT === */
.ta2-card {
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius-btn, 4px);
  overflow: hidden;
}

.ta2-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 0.85rem;
  border-bottom: 1px solid var(--glass-border);
}

.ta2-card-title {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent-primary);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-display, 'Space Grotesk', monospace);
}

.ta2-card-title i {
  font-size: 0.85rem;
  opacity: 0.85;
}

/* === ACCORDION (osion otsikko) === */
.ta2-acc-head {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  padding: 0.8rem 0.85rem;
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--text-main);
  font-family: var(--font-display, 'Space Grotesk', monospace);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  text-align: left;
  transition: background 0.2s;
  min-height: 44px;
}

.ta2-acc-head:hover {
  background: rgba(0,255,157,0.04);
}

.ta2-acc-head .ta2-chev {
  font-size: 0.7rem;
  color: var(--accent-primary);
  transition: transform 0.3s cubic-bezier(0.22,1,0.36,1);
  width: 10px;
}

.ta2-acc-head[aria-expanded="true"] .ta2-chev {
  transform: rotate(90deg);
}

.ta2-acc-icon {
  color: var(--accent-primary);
  font-size: 0.85rem;
}

.ta2-acc-title {
  flex: 1;
}

.ta2-acc-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s cubic-bezier(0.22,1,0.36,1);
}

.ta2-acc-body.open {
  max-height: 900px;
}

.ta2-acc-body > * {
  padding: 0 0.85rem;
}

.ta2-acc-body > *:first-child {
  padding-top: 0.85rem;
}

.ta2-acc-body > *:last-child {
  padding-bottom: 0.85rem;
}

/* === KENTÄT === */
.ta2-field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin-bottom: 0.6rem;
}

.ta2-field:last-child {
  margin-bottom: 0;
}

.ta2-field label {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent-secondary);
  font-family: var(--font-display, 'Space Grotesk', monospace);
}

.ta2-input {
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius-btn, 4px);
  padding: 0.6rem 0.7rem;
  color: var(--text-main);
  font-family: var(--font-body, 'Space Grotesk', monospace);
  font-size: 0.85rem;
  width: 100%;
  transition: border-color 0.2s, box-shadow 0.2s;
  -webkit-appearance: none;
  appearance: none;
}

.ta2-input:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 10px rgba(0,255,157,0.12);
}

.ta2-input.ta2-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.ta2-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}

/* === LIUKUSÄÄTIMET === */
.ta2-slider-field {
  margin-bottom: 0.6rem;
}

.ta2-slider-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.4rem;
}

.ta2-slider-top label {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent-secondary);
  font-family: var(--font-display, 'Space Grotesk', monospace);
}

.ta2-slider-readout {
  font-family: var(--font-display, 'Space Grotesk', monospace);
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--accent-primary);
  font-variant-numeric: tabular-nums;
}

.ta2-range {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: rgba(255,255,255,0.1);
  outline: none;
  cursor: pointer;
}

.ta2-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent-primary);
  border: 2px solid #0f172a;
  box-shadow: 0 0 10px var(--accent-primary);
  cursor: pointer;
  transition: transform 0.12s ease;
}

.ta2-range::-webkit-slider-thumb:hover,
.ta2-range::-webkit-slider-thumb:active {
  transform: scale(1.2);
}

.ta2-range::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent-primary);
  border: 2px solid #0f172a;
  box-shadow: 0 0 10px var(--accent-primary);
  cursor: pointer;
}

.ta2-range:focus-visible {
  box-shadow: 0 0 0 3px rgba(0,255,157,0.25);
}

.ta2-range:focus-visible::-webkit-slider-thumb {
  box-shadow: 0 0 0 4px rgba(0,255,157,0.3), 0 0 10px var(--accent-primary);
}

/* === TOGGLE-KYTKIN === */
.ta2-toggle-row {
  margin-bottom: 0.6rem;
}

.ta2-switch {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  cursor: pointer;
  user-select: none;
}

.ta2-switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.ta2-switch-track {
  position: relative;
  width: 42px;
  height: 24px;
  background: rgba(255,255,255,0.1);
  border: 1px solid var(--glass-border);
  border-radius: 9999px;
  flex-shrink: 0;
  transition: background 0.25s, border-color 0.25s;
}

.ta2-switch-track::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  background: var(--text-muted);
  border-radius: 50%;
  transition: transform 0.25s cubic-bezier(0.22,1,0.36,1), background 0.25s;
}

.ta2-switch input:checked + .ta2-switch-track {
  background: rgba(0,255,157,0.2);
  border-color: var(--accent-primary);
}

.ta2-switch input:checked + .ta2-switch-track::after {
  transform: translateX(18px);
  background: var(--accent-primary);
  box-shadow: 0 0 8px var(--accent-primary);
}

.ta2-switch input:focus-visible + .ta2-switch-track {
  box-shadow: 0 0 0 3px rgba(0,255,157,0.25);
}

.ta2-switch-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.3;
}

.ta2-maxd-field {
  transition: opacity 0.25s;
}

.ta2-apply-btn {
  margin-top: 0.5rem;
  padding: 0.45rem 0.8rem;
  background: rgba(14,165,233,0.1);
  border: 1px solid rgba(14,165,233,0.4);
  border-radius: var(--border-radius-btn, 4px);
  color: var(--accent-secondary);
  font-family: var(--font-display, 'Space Grotesk', monospace);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: background 0.2s, box-shadow 0.2s;
  width: 100%;
  min-height: 40px;
}

.ta2-apply-btn:hover {
  background: rgba(14,165,233,0.2);
  box-shadow: 0 0 12px rgba(14,165,233,0.2);
}

/* === RIVIKORTIT (työerä / materiaali) === */
.ta2-items {
  padding: 0.6rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.ta2-empty {
  color: var(--text-muted);
  font-size: 0.8rem;
  text-align: center;
  padding: 0.75rem;
  font-style: italic;
  margin: 0;
}

.ta2-item {
  background: rgba(0,0,0,0.2);
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius-btn, 4px);
  overflow: hidden;
  transition: border-color 0.2s;
}

.ta2-item:hover {
  border-color: rgba(0,255,157,0.25);
}

.ta2-item.open {
  border-color: var(--accent-primary);
  box-shadow: 0 0 12px rgba(0,255,157,0.08);
}

.ta2-item-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.7rem 0.75rem;
  background: transparent;
  border: none;
  cursor: pointer;
  text-align: left;
  transition: background 0.2s;
  min-height: 44px;
}

.ta2-item-head:hover {
  background: rgba(0,255,157,0.04);
}

.ta2-item-head .ta2-chev {
  font-size: 0.65rem;
  color: var(--accent-primary);
  transition: transform 0.3s cubic-bezier(0.22,1,0.36,1);
  flex-shrink: 0;
}

.ta2-item.open .ta2-item-head .ta2-chev {
  transform: rotate(90deg);
}

.ta2-item-title {
  flex: 1;
  font-size: 0.82rem;
  color: var(--text-main);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ta2-item-total {
  font-family: var(--font-display, 'Space Grotesk', monospace);
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-main);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.ta2-item-margin {
  font-size: 0.62rem;
  font-weight: 700;
  padding: 0.18rem 0.4rem;
  border-radius: 3px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
  font-family: var(--font-display, 'Space Grotesk', monospace);
  border: 1px solid transparent;
}

.ta2-item-margin[data-level="good"] {
  background: rgba(0,255,157,0.12);
  color: #00ff9d;
  border-color: rgba(0,255,157,0.25);
}
.ta2-item-margin[data-level="ok"] {
  background: rgba(250,204,21,0.12);
  color: #facc15;
  border-color: rgba(250,204,21,0.25);
}
.ta2-item-margin[data-level="low"] {
  background: rgba(255,100,100,0.12);
  color: #ff6464;
  border-color: rgba(255,100,100,0.25);
}

.ta2-item-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s cubic-bezier(0.22,1,0.36,1);
}

.ta2-item.open .ta2-item-body {
  max-height: 700px;
}

.ta2-item-body > * {
  padding: 0 0.75rem;
}

.ta2-item-body > *:first-child {
  padding-top: 0.6rem;
}

.ta2-item-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.6rem 0.75rem !important;
  border-top: 1px solid rgba(255,255,255,0.04);
  margin-top: 0.4rem;
}

.ta2-line-info {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.ta2-line-info strong {
  color: var(--accent-primary);
  font-family: var(--font-display, 'Space Grotesk', monospace);
}

.ta2-del {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.8rem;
  transition: all 0.15s ease;
}

.ta2-del:hover {
  background: rgba(255,100,100,0.12);
  border-color: rgba(255,100,100,0.4);
  color: #ff6464;
}

.ta2-add-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.7rem;
  background: transparent;
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius-btn, 4px);
  color: var(--accent-primary);
  font-family: var(--font-display, 'Space Grotesk', monospace);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: all 0.2s ease;
  min-height: 40px;
}

.ta2-add-btn:hover {
  background: rgba(0,255,157,0.08);
  border-color: var(--accent-primary);
  box-shadow: 0 0 12px rgba(0,255,157,0.15);
}

.ta2-vat-custom {
  margin-top: 0.4rem;
}

.ta2-margin-target {
  border-top: 1px dashed rgba(255,255,255,0.08);
  padding-top: 0.6rem;
}

/* === KOTITALOUSVÄHENNYS-TIEDOTUS === */
.ta2-hh-info {
  background: rgba(0,255,157,0.05);
  border: 1px solid rgba(0,255,157,0.18);
  border-radius: var(--border-radius-btn, 4px);
  padding: 0.6rem 0.75rem;
  margin-bottom: 0.6rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  transition: opacity 0.25s;
}

.ta2-hh-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: var(--font-display, 'Space Grotesk', monospace);
}

.ta2-hh-row span {
  min-width: 0;
}

.ta2-hh-row strong {
  color: var(--accent-primary);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.ta2-hh-row.ta2-hh-remain strong {
  color: var(--accent-secondary);
}

.ta2-hh-off {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-style: italic;
  text-align: center;
}

/* === A4-ESIKATSELU (näyttö) === */
.ta2-a4bar {
  display: flex;
  align-items: center;
}

.ta2-a4tag {
  font-family: var(--font-display, 'Space Grotesk', monospace);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent-primary);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.ta2-a4-wrap {
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius-btn, 4px);
  padding: 0.85rem;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  max-height: 70vh;
}

.ta2-a4 {
  background: #fff;
  color: #1a1a1a;
  border-radius: 4px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.4);
  max-width: 100%;
  transition: box-shadow 0.3s;
}

.ta2-a4-inner {
  padding: 1.5rem 1.4rem;
  font-family: 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  font-size: 0.82rem;
  line-height: 1.5;
  color: #1a1a1a;
}

.ta2-a4-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
  border-bottom: 2px solid #00c06e;
  padding-bottom: 0.7rem;
  margin-bottom: 0.9rem;
  flex-wrap: wrap;
}

.ta2-a4-brand {
  display: flex;
  gap: 0.6rem;
  align-items: center;
}

.ta2-a4-company {
  font-size: 1rem;
  font-weight: 700;
  color: #0f172a;
  display: block;
}

.ta2-a4-meta {
  font-size: 0.6rem;
  color: #555;
  margin-top: 2px;
}

.ta2-a4-docinfo {
  text-align: right;
}

.ta2-a4-label {
  font-size: 1.2rem;
  font-weight: 800;
  color: #00c06e;
  letter-spacing: 1px;
  line-height: 1;
  margin-bottom: 3px;
}

.ta2-a4-customer {
  margin-bottom: 0.8rem;
}

.ta2-a4-to {
  font-size: 0.6rem;
  text-transform: uppercase;
  color: #666;
  letter-spacing: 0.5px;
  margin-bottom: 2px;
}

.ta2-a4-cname {
  font-size: 0.88rem;
  font-weight: 700;
  color: #0f172a;
}

.ta2-a4-project {
  background: #f6f6f6;
  padding: 0.5rem 0.6rem;
  border-radius: 4px;
  margin-bottom: 0.8rem;
  font-size: 0.75rem;
}

.ta2-a4-section {
  margin-bottom: 0.8rem;
}

.ta2-a4-h5 {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  color: #00c06e;
  letter-spacing: 0.5px;
  border-bottom: 1px solid #e5e5e5;
  padding-bottom: 2px;
  margin-bottom: 4px;
}

.ta2-a4-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.72rem;
  margin-bottom: 3px;
}

.ta2-a4-table th {
  text-align: left;
  font-weight: 600;
  color: #444;
  padding: 3px 5px;
  border-bottom: 1px solid #ccc;
}

.ta2-a4-table td {
  padding: 3px 5px;
  border-bottom: 1px solid #eee;
}

.ta2-a4-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.ta2-a4-empty {
  color: #bbb;
  font-style: italic;
}

.ta2-a4-subtotal {
  text-align: right;
  font-size: 0.72rem;
  color: #444;
  padding: 3px 5px;
}

.ta2-a4-subtotal strong {
  color: #0f172a;
  font-weight: 700;
}

.ta2-a4-totals {
  border-top: 2px solid #00c06e;
  padding-top: 0.5rem;
  margin-top: 4px;
}

.ta2-a4-total-row {
  display: flex;
  justify-content: space-between;
  padding: 2px 0;
  font-size: 0.72rem;
  color: #333;
}

.ta2-a4-total-row.ta2-a4-total {
  font-size: 0.9rem;
  font-weight: 800;
  color: #0f172a;
  border-top: 1px solid #ddd;
  margin-top: 4px;
  padding-top: 4px;
}

.ta2-a4-total-row.ta2-a4-hh {
  color: #008844;
}

.ta2-a4-total-row.ta2-a4-final {
  font-size: 0.85rem;
  font-weight: 800;
  color: #0f172a;
  border-top: 2px solid #00c06e;
  margin-top: 3px;
  padding-top: 3px;
}

.ta2-a4-note {
  font-size: 0.6rem;
  color: #555;
  margin-top: 0.7rem;
  border-top: 1px solid #eee;
  padding-top: 0.4rem;
}

.ta2-a4-note p + p {
  margin-top: 3px;
}

.ta2-a4-footer {
  display: flex;
  gap: 1.5rem;
  margin-top: 1.5rem;
}

.ta2-a4-sig {
  flex: 1;
  font-size: 0.6rem;
  color: #444;
}

.ta2-a4-signline {
  border-bottom: 1px solid #333;
  height: 1.6rem;
  margin-bottom: 3px;
}

.ta2-a4-ph {
  color: #bbb;
  font-style: italic;
}

/* === TABLETTI === */
@media (min-width: 520px) {
  .ta2-toolbar {
    flex-direction: row;
    align-items: flex-end;
  }
  .ta2-btn-print {
    align-self: flex-end;
  }
}

/* === DESKTOP: kaksipalstainen === */
@media (min-width: 920px) {
  .ta2-kpis {
    grid-template-columns: repeat(4, 1fr);
  }
  .ta2-kpi-gauge {
    grid-column: auto;
  }
  .ta2-main {
    flex-direction: row;
    align-items: flex-start;
  }
  .ta2-left {
    flex: 1.1;
    min-width: 0;
  }
  .ta2-right {
    flex: 1;
    min-width: 0;
    position: sticky;
    top: 1rem;
  }
  .ta2-a4-wrap {
    max-height: none;
  }
}

/* === MOBIILI 768px (T4) === */
@media (max-width: 768px) {
  .ta2-input,
  .ta2-select {
    font-size: 16px;
  }

  .ta2-btn-print,
  .ta2-acc-head,
  .ta2-item-head,
  .ta2-add-btn,
  .ta2-del,
  .ta2-apply-btn {
    min-height: 44px;
  }

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

  .ta2-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .ta2-a4-wrap {
    max-height: 50vh;
  }

  .ta2-grid-2 {
    grid-template-columns: 1fr;
  }

  .ta2-a4-inner {
    padding: 1rem 0.85rem;
    font-size: 0.75rem;
  }
}

/* === PIENET MOBIILIT === */
@media (max-width: 380px) {
  .ta2-kpis {
    grid-template-columns: 1fr;
  }
  .ta2-kpi-val {
    font-size: 1rem;
  }
  .ta2-grid-2 {
    grid-template-columns: 1fr;
  }
  .ta2-item-title {
    font-size: 0.76rem;
  }
}

/* === REDUCED MOTION === */
@media (prefers-reduced-motion: reduce) {
  .ta2-kpi.ta2-flash,
  .ta2-gauge-fill,
  .ta2-range::-webkit-slider-thumb,
  .ta2-acc-head .ta2-chev,
  .ta2-item-head .ta2-chev,
  .ta2-acc-body,
  .ta2-item-body,
  .ta2-switch-track,
  .ta2-switch-track::after {
    transition: none !important;
    animation: none !important;
  }
}

/* ============================================================
   MODAALIKONTEKSTI — .ta2-in-modal (T4)
   Lisataan containerille kun modaali on auki (onOpen-callback)
   ============================================================ */
.ta2-in-modal .ta2-a4-wrap {
  max-height: 45vh;
}

.ta2-in-modal .ta2-app {
  gap: 0.75rem;
}
