/**
 * MAALARIN TARVIKELISTA — iOS-tyylinen mobiilisovellus
 * Liquid-glass + glassmorphism, cyber-teema v2026
 * Digilapio — esimerkit-osio
 *
 * Sidoskohta: #demo-inventory (cyber-windowin sisalla).
 * Mobile-first. WCAG 2. AA. Vain cyber-teeman CSS-muuttujia.
 */

/* ============================================
   APP-SHELL — "puhelin" cyber-windowin sisalla
   ============================================ */
.tl-app {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 440px;
  margin: 0 auto;
  height: clamp(480px, 74vh, 660px);
  min-height: 480px;
  overflow: hidden;
  background:
    radial-gradient(120% 80% at 50% -10%, rgba(0, 255, 157, 0.06), transparent 60%),
    radial-gradient(100% 60% at 100% 110%, rgba(14, 165, 233, 0.05), transparent 55%),
    rgba(8, 12, 24, 0.6);
  border: 1px solid var(--glass-border, rgba(0, 255, 157, 0.2));
  border-radius: var(--border-radius-lg, 2px);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.05),
    0 0 30px rgba(0, 255, 157, 0.04),
    0 12px 40px rgba(0, 0, 0, 0.45);
}

/* Nakymasailio */
.tl-view-wrap {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

.tl-view {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  outline: none;
}

.tl-app[data-dir="forward"] .tl-view { animation: tl-push-in 0.34s cubic-bezier(0.22, 1, 0.36, 1); }
.tl-app[data-dir="back"] .tl-view { animation: tl-pop-in 0.34s cubic-bezier(0.22, 1, 0.36, 1); }

@keyframes tl-push-in {
  from { opacity: 0; transform: translateX(26px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes tl-pop-in {
  from { opacity: 0; transform: translateX(-26px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* Vieritysalue nakyman sisalla */
.tl-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0 1rem 1.25rem;
}
.tl-scroll::-webkit-scrollbar { width: 6px; }
.tl-scroll::-webkit-scrollbar-track { background: transparent; }
.tl-scroll::-webkit-scrollbar-thumb { background: var(--glass-border, rgba(0, 255, 157, 0.2)); border-radius: 3px; }

/* ============================================
   LIQUID GLASS — yleinen lasipinta
   ============================================ */
.tl-glass {
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(18px) saturate(160%);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: var(--border-radius-lg, 2px);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 6px 20px rgba(0, 0, 0, 0.28);
  transition: border-color 0.25s ease, box-shadow 0.25s ease, transform 0.25s ease;
}

/* ============================================
   YLAPALKKI — iOS large title
   ============================================ */
.tl-topbar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.85rem 1rem 0.6rem;
  background: rgba(8, 12, 24, 0.4);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.tl-title {
  flex: 1;
  margin: 0;
  font-family: var(--font-display, 'Space Grotesk', monospace);
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text-main, #e2e8f0);
  text-align: center;
}

.tl-topbar-count {
  font-family: var(--font-display, 'Space Grotesk', monospace);
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--accent-primary, #00ff9d);
  background: rgba(0, 255, 157, 0.1);
  border: 1px solid var(--glass-border, rgba(0, 255, 157, 0.2));
  border-radius: 9999px;
  padding: 0.2rem 0.55rem;
  min-width: 28px;
  text-align: center;
}

.tl-icon-btn {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--border-radius-btn, 4px);
  color: var(--accent-primary, #00ff9d);
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.18s ease, box-shadow 0.18s ease;
  flex-shrink: 0;
}
.tl-icon-btn:hover { background: rgba(0, 255, 157, 0.08); box-shadow: 0 0 10px rgba(0, 255, 157, 0.12); }
.tl-icon-btn:active { transform: scale(0.92); }
.tl-icon-btn:focus-visible { outline: 2px solid var(--accent-primary, #00ff9d); outline-offset: 2px; }

/* ============================================
   HOME — hero + yhteenveto
   ============================================ */
.tl-home .tl-title { text-align: left; padding-left: 0.25rem; }

.tl-hero {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.1rem;
  margin-top: 0.75rem;
}
.tl-hero-ring { flex-shrink: 0; }
.tl-hero-meta { flex: 1; min-width: 0; }
.tl-hero-eyebrow {
  display: block;
  font-family: var(--font-display, 'Space Grotesk', monospace);
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent-primary, #00ff9d);
  margin-bottom: 0.4rem;
}
.tl-hero-text {
  margin: 0;
  font-size: 0.82rem;
  line-height: 1.55;
  color: var(--text-muted, #94a3b8);
}
.tl-hero-text strong { color: var(--text-main, #e2e8f0); font-weight: 700; }
.tl-warn { color: #ff6464; font-weight: 700; }
.tl-good { color: var(--accent-primary, #00ff9d); font-weight: 700; }

/* Tayttoringi (SVG) */
.tl-ring { display: block; }
.tl-ring-bg { fill: none; stroke: rgba(255, 255, 255, 0.06); stroke-width: 8; }
.tl-ring-fg {
  fill: none;
  stroke-width: 8;
  stroke-linecap: round;
  transform: rotate(-90deg);
  transform-box: fill-box;
  transform-origin: center;
  transition: stroke-dashoffset 0.7s cubic-bezier(0.22, 1, 0.36, 1), stroke 0.3s ease;
}
.tl-ring-ok .tl-ring-fg { stroke: var(--accent-primary, #00ff9d); filter: drop-shadow(0 0 6px rgba(0, 255, 157, 0.45)); }
.tl-ring-medium .tl-ring-fg { stroke: var(--accent-secondary, #0ea5e9); }
.tl-ring-low .tl-ring-fg { stroke: #ff6464; filter: drop-shadow(0 0 6px rgba(255, 100, 100, 0.4)); }
.tl-ring-val { fill: var(--text-main, #e2e8f0); font-family: var(--font-display, 'Space Grotesk', monospace); font-size: 24px; font-weight: 700; text-anchor: middle; }
.tl-ring-lbl { fill: var(--text-muted, #94a3b8); font-family: var(--font-display, 'Space Grotesk', monospace); font-size: 7px; text-anchor: middle; text-transform: uppercase; letter-spacing: 0.1em; }

/* Yhteenvetokortit */
.tl-summary-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.6rem;
  margin-top: 0.75rem;
}
.tl-sum-card {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0.85rem 0.9rem;
}
.tl-sum-val {
  font-family: var(--font-display, 'Space Grotesk', monospace);
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1;
  color: var(--text-main, #e2e8f0);
}
.tl-sum-val.tl-warn { color: #ff6464; }
.tl-sum-lbl {
  font-family: var(--font-display, 'Space Grotesk', monospace);
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted, #94a3b8);
}
.tl-money { color: var(--accent-primary, #00ff9d); }

/* Lohkot */
.tl-block { margin-top: 1.5rem; }
.tl-block-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.6rem;
  padding: 0 0.15rem;
}
.tl-block-head h3 {
  margin: 0;
  font-family: var(--font-display, 'Space Grotesk', monospace);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-main, #e2e8f0);
}
.tl-block-note {
  font-family: var(--font-display, 'Space Grotesk', monospace);
  font-size: 0.7rem;
  color: var(--text-muted, #94a3b8);
}
.tl-link {
  background: none;
  border: none;
  color: var(--accent-primary, #00ff9d);
  font-family: var(--font-display, 'Space Grotesk', monospace);
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
}
.tl-link:hover { text-shadow: 0 0 8px rgba(0, 255, 157, 0.4); }

/* Puutteessa -lista */
.tl-alert-list, .tl-cat-list, .tl-list, .tl-shop-list { list-style: none; margin: 0; padding: 0; }

.tl-alert {
  margin-bottom: 0.5rem;
}
.tl-alert-info {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.6rem;
  width: 100%;
  background: transparent;
  border: none;
  padding: 0.7rem 0.85rem;
  text-align: left;
  cursor: pointer;
  color: inherit;
  border-radius: var(--border-radius-lg, 2px);
}
.tl-alert-name {
  flex: 1 1 100%;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main, #e2e8f0);
}
.tl-alert-sub {
  flex: 1;
  font-family: var(--font-display, 'Space Grotesk', monospace);
  font-size: 0.72rem;
  color: var(--text-muted, #94a3b8);
}

/* Kategoriarivit */
.tl-cat-row { margin-bottom: 0.5rem; }
.tl-cat-btn {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.6rem;
  width: 100%;
  background: transparent;
  border: none;
  padding: 0.7rem 0.85rem;
  text-align: left;
  cursor: pointer;
  color: inherit;
  border-radius: var(--border-radius-lg, 2px);
}
.tl-cat-name {
  flex: 1;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main, #e2e8f0);
}
.tl-cat-meta {
  font-family: var(--font-display, 'Space Grotesk', monospace);
  font-size: 0.68rem;
  color: var(--text-muted, #94a3b8);
}

/* CTA-painike lohkossa */
.tl-cta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0.9rem 1rem;
  background: transparent;
  border: none;
  color: var(--accent-primary, #00ff9d);
  font-family: var(--font-display, 'Space Grotesk', monospace);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}
.tl-cta:hover { border-color: var(--accent-primary, #00ff9d); box-shadow: 0 0 16px rgba(0, 255, 157, 0.1); }

.tl-block-cta { width: 100%; margin-top: 1.5rem; }

/* ============================================
   NAPIT (yleiset)
   ============================================ */
.tl-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.7rem 1.1rem;
  font-family: var(--font-display, 'Space Grotesk', monospace);
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-radius: var(--border-radius-btn, 4px);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.2s ease, background 0.2s ease;
  border: 1px solid transparent;
  min-height: 44px;
}
.tl-btn:active { transform: scale(0.97); }
.tl-btn:focus-visible { outline: 2px solid var(--accent-primary, #00ff9d); outline-offset: 2px; }

.tl-btn-primary {
  background: var(--accent-primary, #00ff9d);
  color: #06140d;
  box-shadow: 0 0 15px rgba(0, 255, 157, 0.25);
}
.tl-btn-primary:hover {
  background: var(--accent-secondary, #0ea5e9);
  color: #fff;
  box-shadow: 0 0 20px rgba(14, 165, 233, 0.4);
}

.tl-btn-ghost {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--glass-border, rgba(0, 255, 157, 0.2));
  color: var(--text-main, #e2e8f0);
}
.tl-btn-ghost:hover { border-color: var(--accent-primary, #00ff9d); color: var(--accent-primary, #00ff9d); box-shadow: 0 0 10px rgba(0, 255, 157, 0.1); }

/* ============================================
   INVENTORY — haku, pillut, toolbar
   ============================================ */
.tl-search-wrap {
  position: relative;
  display: flex;
  align-items: center;
  margin-top: 0.75rem;
}
.tl-search-wrap > i {
  position: absolute;
  left: 0.7rem;
  font-size: 0.8rem;
  color: var(--text-muted, #94a3b8);
  pointer-events: none;
}
.tl-search {
  width: 100%;
  padding: 0.65rem 2rem 0.65rem 2rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--glass-border, rgba(0, 255, 157, 0.2));
  border-radius: var(--border-radius-btn, 4px);
  color: var(--text-main, #e2e8f0);
  font-family: var(--font-body, 'Space Grotesk', monospace);
  font-size: 0.85rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.tl-search:focus { outline: none; border-color: var(--accent-primary, #00ff9d); box-shadow: 0 0 12px rgba(0, 255, 157, 0.12); }
.tl-search::placeholder { color: var(--text-muted, #94a3b8); opacity: 0.7; }
.tl-search-clear {
  position: absolute;
  right: 0.5rem;
  width: 28px;
  height: 28px;
  background: transparent;
  border: none;
  color: var(--text-muted, #94a3b8);
  font-size: 1.1rem;
  cursor: pointer;
  border-radius: 50%;
}
.tl-search-clear:hover { color: #ff6464; }

.tl-pills {
  display: flex;
  gap: 0.4rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0.6rem 0 0.2rem;
  scrollbar-width: none;
}
.tl-pills::-webkit-scrollbar { display: none; }
.tl-pill {
  flex-shrink: 0;
  padding: 0.4rem 0.85rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--glass-border, rgba(0, 255, 157, 0.2));
  border-radius: 9999px;
  color: var(--text-muted, #94a3b8);
  font-family: var(--font-display, 'Space Grotesk', monospace);
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.2s ease;
}
.tl-pill:hover { color: var(--accent-primary, #00ff9d); border-color: var(--accent-primary, #00ff9d); }
.tl-pill.active {
  background: rgba(0, 255, 157, 0.12);
  border-color: var(--accent-primary, #00ff9d);
  color: var(--accent-primary, #00ff9d);
  box-shadow: 0 0 10px rgba(0, 255, 157, 0.15);
}
.tl-pill:focus-visible { outline: 2px solid var(--accent-primary, #00ff9d); outline-offset: 2px; }

.tl-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.6rem 0.15rem 0.4rem;
}

/* iOS-kytkin */
.tl-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  user-select: none;
}
.tl-toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.tl-toggle-track {
  position: relative;
  width: 44px;
  height: 26px;
  border-radius: 9999px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--glass-border, rgba(0, 255, 157, 0.2));
  transition: background 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
  flex-shrink: 0;
}
.tl-toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}
.tl-toggle input:checked + .tl-toggle-track {
  background: var(--accent-primary, #00ff9d);
  border-color: var(--accent-primary, #00ff9d);
  box-shadow: 0 0 10px rgba(0, 255, 157, 0.3);
}
.tl-toggle input:checked + .tl-toggle-track .tl-toggle-thumb { transform: translateX(18px); background: #06140d; }
.tl-toggle input:focus-visible + .tl-toggle-track { outline: 2px solid var(--accent-primary, #00ff9d); outline-offset: 2px; }
.tl-toggle-lbl {
  font-family: var(--font-display, 'Space Grotesk', monospace);
  font-size: 0.72rem;
  color: var(--text-muted, #94a3b8);
}

.tl-select-wrap { position: relative; }
.tl-select {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--glass-border, rgba(0, 255, 157, 0.2));
  border-radius: var(--border-radius-btn, 4px);
  color: var(--text-main, #e2e8f0);
  font-family: var(--font-display, 'Space Grotesk', monospace);
  font-size: 0.72rem;
  padding: 0.5rem 0.65rem;
  cursor: pointer;
  min-height: 36px;
}
.tl-select:focus { outline: none; border-color: var(--accent-primary, #00ff9d); box-shadow: 0 0 10px rgba(0, 255, 157, 0.12); }

/* ============================================
   INVENTORY — listarivit
   ============================================ */
.tl-list { padding-top: 0.4rem; }
.tl-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.7rem 0.85rem;
  margin-bottom: 0.5rem;
}
.tl-row-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  background: transparent;
  border: none;
  text-align: left;
  cursor: pointer;
  color: inherit;
  padding: 0;
  border-radius: var(--border-radius-lg, 2px);
}
.tl-row-info:focus-visible { outline: 2px solid var(--accent-primary, #00ff9d); outline-offset: 2px; }
.tl-row-top {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.tl-row-name {
  flex: 1;
  min-width: 0;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main, #e2e8f0);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tl-cat-tag {
  flex-shrink: 0;
  font-family: var(--font-display, 'Space Grotesk', monospace);
  font-size: 0.58rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent-secondary, #0ea5e9);
  background: rgba(14, 165, 233, 0.1);
  border: 1px solid rgba(14, 165, 233, 0.2);
  border-radius: 9999px;
  padding: 0.15rem 0.45rem;
}
.tl-row-mid {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.tl-row-meta {
  flex-shrink: 0;
  font-family: var(--font-display, 'Space Grotesk', monospace);
  font-size: 0.68rem;
  color: var(--text-muted, #94a3b8);
}

/* Mini-tayttopalkki */
.tl-fillmini {
  flex: 1;
  height: 5px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 3px;
  overflow: hidden;
  min-width: 40px;
}
.tl-fillmini > span {
  display: block;
  height: 100%;
  border-radius: 3px;
  transition: width 0.5s cubic-bezier(0.22, 1, 0.36, 1), background 0.3s ease;
}
.tl-fill-ok > span { background: var(--accent-primary, #00ff9d); box-shadow: 0 0 6px rgba(0, 255, 157, 0.35); }
.tl-fill-medium > span { background: var(--accent-secondary, #0ea5e9); }
.tl-fill-low > span { background: #ff6464; box-shadow: 0 0 6px rgba(255, 100, 100, 0.35); }

/* Stepper */
.tl-stepper {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
}
.tl-step {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--glass-border, rgba(0, 255, 157, 0.2));
  border-radius: var(--border-radius-btn, 4px);
  color: var(--text-main, #e2e8f0);
  font-family: var(--font-display, 'Space Grotesk', monospace);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  touch-action: manipulation;
}
.tl-step:hover { border-color: var(--accent-primary, #00ff9d); color: var(--accent-primary, #00ff9d); box-shadow: 0 0 8px rgba(0, 255, 157, 0.15); }
.tl-step:active { transform: scale(0.9); }
.tl-step:focus-visible { outline: 2px solid var(--accent-primary, #00ff9d); outline-offset: 2px; }
.tl-step-val {
  min-width: 24px;
  text-align: center;
  font-family: var(--font-display, 'Space Grotesk', monospace);
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-main, #e2e8f0);
}

/* Statusbadge */
.tl-badge {
  font-family: var(--font-display, 'Space Grotesk', monospace);
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.2rem 0.5rem;
  border-radius: 9999px;
  border: 1px solid transparent;
  white-space: nowrap;
}
.tl-badge-ok { background: rgba(0, 255, 157, 0.12); color: var(--accent-primary, #00ff9d); border-color: rgba(0, 255, 157, 0.2); }
.tl-badge-low { background: rgba(255, 100, 100, 0.12); color: #ff6464; border-color: rgba(255, 100, 100, 0.25); animation: tl-pulse 1.6s ease-in-out infinite; }
.tl-badge-medium { background: rgba(14, 165, 233, 0.12); color: var(--accent-secondary, #0ea5e9); border-color: rgba(14, 165, 233, 0.2); }
@keyframes tl-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.55; } }

/* FAB */
.tl-fab {
  position: absolute;
  right: 1rem;
  bottom: 0.85rem;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--accent-primary, #00ff9d);
  color: #06140d;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 20px rgba(0, 255, 157, 0.35), 0 6px 16px rgba(0, 0, 0, 0.4);
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s ease;
  z-index: 20;
}
.tl-fab:hover { transform: scale(1.08); box-shadow: 0 0 28px rgba(0, 255, 157, 0.5); }
.tl-fab:active { transform: scale(0.94); }
.tl-fab:focus-visible { outline: 2px solid var(--accent-primary, #00ff9d); outline-offset: 3px; }

/* Tyhja tila */
.tl-empty {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted, #94a3b8);
}
.tl-empty i { font-size: 2.2rem; color: var(--accent-primary, #00ff9d); opacity: 0.6; margin-bottom: 0.75rem; }
.tl-empty p { margin: 0.25rem 0; font-size: 0.9rem; }
.tl-empty .tl-empty-sub { font-size: 0.78rem; opacity: 0.7; }
.tl-empty .tl-btn { margin-top: 1rem; }

.tl-reset-link {
  display: block;
  margin: 1.5rem auto 0;
  padding: 0.6rem;
  background: none;
  border: none;
  color: var(--text-muted, #94a3b8);
  font-family: var(--font-display, 'Space Grotesk', monospace);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  cursor: pointer;
  min-height: 40px;
}
.tl-reset-link:hover { color: #ff6464; text-decoration: underline; }
.tl-reset-link:focus-visible { outline: 2px solid var(--accent-primary, #00ff9d); outline-offset: 2px; }

/* ============================================
   SHOPPING — ostolista
   ============================================ */
.tl-shop-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  padding: 0.9rem 1rem;
  margin-top: 0.75rem;
}
.tl-shop-summary > div { display: flex; flex-direction: column; gap: 0.15rem; }

.tl-shop-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.75rem; }
.tl-shop-actions .tl-btn { flex: 1; min-width: 140px; }

.tl-shop {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.75rem 0.85rem;
  margin-bottom: 0.5rem;
  transition: opacity 0.25s ease;
}
.tl-shop.checked { opacity: 0.45; }
.tl-shop.checked .tl-shop-name { text-decoration: line-through; }

.tl-check { position: relative; display: inline-flex; cursor: pointer; flex-shrink: 0; }
.tl-check input { position: absolute; opacity: 0; width: 0; height: 0; }
.tl-check-box {
  width: 26px;
  height: 26px;
  border-radius: var(--border-radius-btn, 4px);
  border: 1px solid var(--glass-border, rgba(0, 255, 157, 0.2));
  background: rgba(255, 255, 255, 0.05);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}
.tl-check-box i { color: #06140d; font-size: 0.75rem; opacity: 0; transform: scale(0.4); transition: all 0.2s ease; }
.tl-check input:checked + .tl-check-box { background: var(--accent-primary, #00ff9d); border-color: var(--accent-primary, #00ff9d); box-shadow: 0 0 8px rgba(0, 255, 157, 0.3); }
.tl-check input:checked + .tl-check-box i { opacity: 1; transform: scale(1); }
.tl-check input:focus-visible + .tl-check-box { outline: 2px solid var(--accent-primary, #00ff9d); outline-offset: 2px; }

.tl-shop-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 0.15rem; }
.tl-shop-name { font-size: 0.85rem; font-weight: 600; color: var(--text-main, #e2e8f0); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tl-shop-sub { font-family: var(--font-display, 'Space Grotesk', monospace); font-size: 0.65rem; color: var(--text-muted, #94a3b8); text-transform: uppercase; letter-spacing: 0.04em; }
.tl-shop-qty { font-family: var(--font-display, 'Space Grotesk', monospace); font-size: 0.78rem; font-weight: 700; color: var(--accent-primary, #00ff9d); white-space: nowrap; }
.tl-shop-price { font-family: var(--font-display, 'Space Grotesk', monospace); font-size: 0.75rem; color: var(--text-muted, #94a3b8); white-space: nowrap; }

/* ============================================
   BOTTOM TAB BAR — iOS-kelluva navigaatio
   ============================================ */
.tl-tabbar {
  flex-shrink: 0;
  display: flex;
  justify-content: space-around;
  align-items: center;
  gap: 0.3rem;
  padding: 0.45rem 0.75rem;
  padding-bottom: calc(0.45rem + env(safe-area-inset-bottom));
  background: rgba(8, 12, 24, 0.7);
  backdrop-filter: blur(18px) saturate(160%);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}
.tl-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  padding: 0.35rem 0.25rem;
  background: transparent;
  border: none;
  color: var(--text-muted, #94a3b8);
  font-family: var(--font-display, 'Space Grotesk', monospace);
  font-size: 0.6rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  cursor: pointer;
  border-radius: var(--border-radius-btn, 4px);
  transition: color 0.2s ease;
  min-height: 44px;
  justify-content: center;
}
.tl-tab i { font-size: 1.05rem; transition: transform 0.2s ease, filter 0.2s ease; }
.tl-tab:hover { color: var(--text-main, #e2e8f0); }
.tl-tab.active { color: var(--accent-primary, #00ff9d); }
.tl-tab.active i { transform: translateY(-1px); filter: drop-shadow(0 0 8px rgba(0, 255, 157, 0.5)); }
.tl-tab:focus-visible { outline: 2px solid var(--accent-primary, #00ff9d); outline-offset: 2px; }

/* ============================================
   BOTTOM SHEET — lisays / muokkaus
   ============================================ */
.tl-sheet-overlay {
  position: absolute;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: flex-end;
}
.tl-sheet-overlay[hidden] { display: none; }

.tl-sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  animation: tl-fade 0.25s ease;
}
@keyframes tl-fade { from { opacity: 0; } to { opacity: 1; } }

.tl-sheet {
  position: relative;
  width: 100%;
  max-height: 90%;
  display: flex;
  flex-direction: column;
  background: rgba(13, 19, 33, 0.92);
  backdrop-filter: blur(24px) saturate(170%);
  -webkit-backdrop-filter: blur(24px) saturate(170%);
  border: 1px solid var(--glass-border, rgba(0, 255, 157, 0.2));
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 20px 20px 0 0;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 -8px 40px rgba(0, 0, 0, 0.5);
  animation: tl-sheet-up 0.38s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes tl-sheet-up { from { transform: translateY(100%); } to { transform: translateY(0); } }

.tl-sheet-handle {
  width: 40px;
  height: 4px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 9999px;
  margin: 0.6rem auto 0.25rem;
}

.tl-sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 1rem 0.75rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.tl-sheet-head h3 {
  margin: 0;
  font-family: var(--font-display, 'Space Grotesk', monospace);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main, #e2e8f0);
}
.tl-sheet-cancel, .tl-sheet-save {
  background: none;
  border: none;
  font-family: var(--font-display, 'Space Grotesk', monospace);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0.4rem 0.2rem;
  min-height: 40px;
}
.tl-sheet-cancel { color: var(--text-muted, #94a3b8); }
.tl-sheet-cancel:hover { color: #ff6464; }
.tl-sheet-save { color: var(--accent-primary, #00ff9d); }
.tl-sheet-save:hover { text-shadow: 0 0 10px rgba(0, 255, 157, 0.4); }
.tl-sheet-save:focus-visible, .tl-sheet-cancel:focus-visible { outline: 2px solid var(--accent-primary, #00ff9d); outline-offset: 2px; border-radius: var(--border-radius-btn, 4px); }

.tl-sheet-body {
  padding: 1rem 1.25rem 1.5rem;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.tl-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.85rem;
}
.tl-field > span {
  font-family: var(--font-display, 'Space Grotesk', monospace);
  font-size: 0.66rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent-secondary, #0ea5e9);
}
.tl-field input, .tl-field select {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--glass-border, rgba(0, 255, 157, 0.2));
  border-radius: var(--border-radius-btn, 4px);
  padding: 0.65rem 0.7rem;
  color: var(--text-main, #e2e8f0);
  font-family: var(--font-body, 'Space Grotesk', monospace);
  font-size: 0.9rem;
  width: 100%;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  min-height: 44px;
  box-sizing: border-box;
}
.tl-field input:focus, .tl-field select:focus { outline: none; border-color: var(--accent-primary, #00ff9d); box-shadow: 0 0 12px rgba(0, 255, 157, 0.12); background: rgba(255, 255, 255, 0.08); }
.tl-field input::placeholder { color: var(--text-muted, #94a3b8); opacity: 0.6; }

.tl-field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; }

.tl-sheet-preview {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.6rem;
  padding: 0.75rem 0.85rem;
  margin-top: 0.5rem;
  background: rgba(0, 0, 0, 0.2);
  border: 1px dashed var(--glass-border, rgba(0, 255, 157, 0.2));
  border-radius: var(--border-radius-btn, 4px);
}
.tl-prev-row { display: flex; align-items: center; gap: 0.5rem; flex: 1 1 100%; }
.tl-prev-lbl { font-family: var(--font-display, 'Space Grotesk', monospace); font-size: 0.62rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted, #94a3b8); }
.tl-prev-meta { font-family: var(--font-display, 'Space Grotesk', monospace); font-size: 0.68rem; color: var(--text-muted, #94a3b8); }
.tl-sheet-preview .tl-fillmini { flex: 1 1 100%; }

.tl-del-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1rem;
  padding: 0.6rem 0.9rem;
  background: rgba(255, 100, 100, 0.06);
  border: 1px solid rgba(255, 100, 100, 0.25);
  border-radius: var(--border-radius-btn, 4px);
  color: #ff6464;
  font-family: var(--font-display, 'Space Grotesk', monospace);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}
.tl-del-btn:hover { background: rgba(255, 100, 100, 0.14); border-color: #ff6464; }

/* ============================================
   APU — ruudunlukijat
   ============================================ */
.tl-live { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0; }
.tl-visually-hidden { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0; }

/* ============================================
   RESPONSIVIIVUS — mobile-first, desktop-tehosteet
   ============================================ */
/* Mobiili: >=16px syotteissa estaa iOS-zoomauksen, 44px kosketusalueet */
@media (max-width: 767px) {
  .tl-field input,
  .tl-field select,
  .tl-search {
    font-size: 16px;
  }
  .tl-step {
    width: 44px;
    height: 44px;
  }
  .tl-step-val {
    min-width: 28px;
  }
}

@media (min-width: 768px) {
  .tl-app { height: clamp(540px, 76vh, 720px); }
  .tl-summary-grid { grid-template-columns: repeat(4, 1fr); }
}

/* ============================================
   SUORITUSKYKY — low-perf-mode poistaa blurin
   ============================================ */
body.low-perf-mode .tl-glass,
body.low-perf-mode .tl-sheet,
body.low-perf-mode .tl-sheet-backdrop,
body.low-perf-mode .tl-tabbar,
body.low-perf-mode .tl-topbar {
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}
body.low-perf-mode .tl-glass,
body.low-perf-mode .tl-sheet {
  background: rgba(13, 19, 33, 0.95);
}

/* ============================================
   PREFERS-REDUCED-MOTION
   ============================================ */
@media (prefers-reduced-motion: reduce) {
  .tl-view,
  .tl-sheet,
  .tl-sheet-backdrop,
  .tl-ring-fg,
  .tl-fillmini > span,
  .tl-fab,
  .tl-toggle-thumb,
  .tl-step,
  .tl-tab i {
    animation: none !important;
    transition: none !important;
  }
}

/* ============================================
   MOBIILIMODAALI - app-shell full-screen modalissa
   Kun .tl-in-modal -luokka on containerissa (mobileMiniApps
   API:n onOpen lisaa sen), app-shell skaalautuu tays kokoiseksi
   modaaliin. Mobiilissa ei pyoristettyja kulmia tai kehyksia.
   ============================================ */
.tl-in-modal {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.tl-in-modal .tl-app {
  max-width: 100%;
  width: 100%;
  flex: 1;
  height: auto;
  min-height: 0;
  border-radius: 0;
  border: none;
  box-shadow: none;
}

/* ============================================
   MOBIILIMODAALI - responsiiviset breakpointit
   768px / 480px / 380px: app-shell skaalautuu, listan rivit
   rivittyy, tayttoastepalkit skaalautuvat
   ============================================ */
@media (max-width: 768px) {
  .tl-in-modal .tl-app {
    max-width: 100%;
    height: auto;
    min-height: 0;
  }

  .tl-in-modal .tl-summary-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 480px) {
  .tl-in-modal .tl-row {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .tl-in-modal .tl-stepper {
    width: 100%;
    justify-content: flex-end;
  }

  .tl-in-modal .tl-fillmini {
    min-width: 60px;
    flex: 1;
  }

  .tl-in-modal .tl-summary-grid {
    gap: 0.5rem;
  }

  .tl-in-modal .tl-sum-val {
    font-size: 1.25rem;
  }

  .tl-in-modal .tl-topbar {
    padding: 0.7rem 0.85rem 0.5rem;
  }

  .tl-in-modal .tl-title {
    font-size: 1rem;
  }

  .tl-in-modal .tl-hero {
    padding: 0.85rem;
    gap: 0.75rem;
  }

  .tl-in-modal .tl-shop {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .tl-in-modal .tl-shop-info {
    flex: 1 1 100%;
  }
}

@media (max-width: 380px) {
  .tl-in-modal .tl-app {
    min-height: 0;
  }

  .tl-in-modal .tl-step {
    width: 36px;
    height: 36px;
    font-size: 0.9rem;
  }

  .tl-in-modal .tl-step-val {
    min-width: 20px;
    font-size: 0.8rem;
  }

  .tl-in-modal .tl-row {
    padding: 0.6rem 0.7rem;
  }

  .tl-in-modal .tl-row-name {
    font-size: 0.8rem;
  }

  .tl-in-modal .tl-sum-val {
    font-size: 1.1rem;
  }

  .tl-in-modal .tl-summary-grid {
    gap: 0.4rem;
  }

  .tl-in-modal .tl-hero {
    padding: 0.75rem;
    gap: 0.6rem;
  }

  .tl-in-modal .tl-tab {
    font-size: 0.55rem;
  }

  .tl-in-modal .tl-tab i {
    font-size: 0.95rem;
  }

  .tl-in-modal .tl-topbar {
    padding: 0.6rem 0.75rem 0.45rem;
    gap: 0.4rem;
  }

  .tl-in-modal .tl-title {
    font-size: 0.95rem;
  }

  .tl-in-modal .tl-pills {
    gap: 0.35rem;
  }

  .tl-in-modal .tl-pill {
    padding: 0.35rem 0.7rem;
    font-size: 0.68rem;
  }
}
