/* ================================================================
   calcolator.css — REDESIGN v2.0
   ================================================================ */

   .th-modal-wrap .th-modal-backdrop {
    position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 9998;
    backdrop-filter: blur(4px);
  }
  .th-modal-wrap .th-modal {
    position: fixed; inset: 0; display: grid; place-items: center; z-index: 9999;
  }
  .th-modal-wrap .th-card {
    width: min(1024px, 94vw); max-height: 90vh; overflow: auto;
    background: var(--bg-card, #111722);
    color: var(--text-primary, #f0f4ff);
    border-radius: var(--r-xl, 20px);
    box-shadow: var(--shadow-modal, 0 24px 80px rgba(0,0,0,.65));
    border: 1px solid var(--border-soft, rgba(255,255,255,0.10));
    scrollbar-width: thin; scrollbar-color: var(--bg-elevated, #1a2233) transparent;
  }
  .th-modal-wrap .th-card::-webkit-scrollbar { width: 5px; }
  .th-modal-wrap .th-card::-webkit-scrollbar-thumb { background: var(--bg-elevated, #1a2233); border-radius: 4px; }
  
  .th-modal-wrap .th-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 18px; border-bottom: 1px solid var(--border-subtle, rgba(255,255,255,0.06));
    position: sticky; top: 0; background: var(--bg-card, #111722); z-index: 5;
  }
  .th-modal-wrap .th-title {
    display: flex; gap: 10px; align-items: center;
    font-weight: 800; font-size: 14px; letter-spacing: .2px;
    font-family: 'Sora', sans-serif;
  }
  .th-modal-wrap .th-close {
    background: var(--bg-elevated, #1a2233);
    border: 1px solid var(--border-soft, rgba(255,255,255,0.10));
    border-radius: var(--r-sm, 6px);
    color: var(--text-muted, #4a5578);
    font-size: 18px; cursor: pointer; line-height: 1;
    width: 30px; height: 30px;
    display: flex; align-items: center; justify-content: center;
    transition: all .2s;
  }
  .th-modal-wrap .th-close:hover { color: var(--text-primary, #f0f4ff); background: var(--bg-card-hover, #161d2a); }
  
  .th-modal-wrap .th-body { padding: 16px 18px 20px; font-size: 13px; }
  
  /* ===== FORM GRID ===== */
  .th-row { display: grid; gap: 12px; grid-template-columns: repeat(12, 1fr); align-items: end; }
  .col-2 { grid-column: span 2; } .col-4 { grid-column: span 4; } .col-6 { grid-column: span 6; }
  .mb-12 { margin-bottom: 12px; } .mb-8 { margin-bottom: 8px; } .mt-6 { margin-top: 6px; } .mt-4 { margin-top: 4px; }
  
  .th-field { display: flex; flex-direction: column; gap: 5px; }
  .th-field label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; color: var(--text-muted, #4a5578); }
  
  .th-modal-wrap input, .th-modal-wrap select {
    background: var(--bg-elevated, #1a2233);
    border: 1px solid var(--border-soft, rgba(255,255,255,0.10));
    color: var(--text-primary, #f0f4ff);
    border-radius: var(--r-md, 10px); padding: 9px 11px; font-size: 13px;
    outline: none; font-family: inherit; transition: border-color .2s, box-shadow .2s;
  }
  .th-modal-wrap input:focus, .th-modal-wrap select:focus {
    border-color: rgba(6,182,212,.5);
    box-shadow: 0 0 0 3px rgba(6,182,212,.1);
  }
  
  /* ===== BUTTONS ===== */
  .th-actions { display: flex; gap: 8px; justify-content: flex-end; }
  .th-actions.align-end { align-self: end; }
  .th-btn {
    background: var(--brand-cyan, #06b6d4); border: 0;
    color: #fff; font-weight: 700; font-size: 13px;
    border-radius: var(--r-md, 10px); padding: 9px 14px; cursor: pointer;
    transition: all .2s; font-family: inherit;
  }
  .th-btn:hover { filter: brightness(1.08); transform: translateY(-1px); }
  .th-btn.secondary {
    background: var(--bg-elevated, #1a2233); color: var(--text-primary, #f0f4ff);
    border: 1px solid var(--border-soft, rgba(255,255,255,0.10));
  }
  .th-btn.secondary:hover { background: var(--bg-card-hover, #161d2a); }
  
  /* ===== BADGES ===== */
  .badge {
    display: inline-block; font-size: 10px; padding: 2px 7px;
    border-radius: 999px; border: 1px solid var(--border-subtle, rgba(255,255,255,0.06));
    font-weight: 600;
  }
  .warn { color: #fbbf24; border-color: rgba(251,191,36,.3); background: rgba(251,191,36,.06); }
  .err  { color: #f87171; border-color: rgba(248,113,113,.3); background: rgba(248,113,113,.06); }
  .ok   { color: #4ade80; border-color: rgba(74,222,128,.3);  background: rgba(74,222,128,.06); }
  .muted { opacity: .65; }
  .badge-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
  
  /* ===== TABLE ===== */
  .th-modal-wrap table { width: 100%; border-collapse: collapse; margin-top: 12px; font-size: 13px; }
  .th-modal-wrap th, .th-modal-wrap td {
    padding: 9px 8px; border-bottom: 1px solid var(--border-subtle, rgba(255,255,255,0.06));
    text-align: right; font-variant-numeric: tabular-nums;
  }
  .th-modal-wrap th {
    font-size: 11px; color: var(--text-muted, #4a5578);
    text-transform: uppercase; letter-spacing: .04em; font-weight: 700;
    background: var(--bg-elevated, #1a2233);
  }
  .th-modal-wrap td:first-child, .th-modal-wrap th:first-child { text-align: left; }
  
  /* ===== RESPONSIVE ===== */
  @media (max-width: 820px) {
    .th-row { grid-template-columns: repeat(6, 1fr); }
    .col-6 { grid-column: span 6; } .col-4 { grid-column: span 3; } .col-2 { grid-column: span 3; }
  }
  @media (max-width: 540px) {
    .th-modal-wrap .col-esp-prima, .th-modal-wrap .col-esp-dopo,
    .th-modal-wrap .col-prob-arr, .th-modal-wrap .col-prob-whiff { display: none; }
    .th-modal-wrap .th-title { flex-direction: column; align-items: flex-start; gap: 5px; }
    .th-modal-wrap .th-card { font-size: 12px; }
    .th-modal-wrap table { font-size: 12px; }
    .th-modal-wrap th, .th-modal-wrap td { padding: 7px 5px; }
  }
  @media (min-width: 1024px) {
    .th-modal-wrap .th-card { font-size: 14px; }
    .th-modal-wrap input, .th-modal-wrap select { font-size: 14px; padding: 10px 12px; }
    .th-modal-wrap table { font-size: 14px; }
    .th-modal-wrap th, .th-modal-wrap td { padding: 10px 8px; }
  }