:root{
      --bg:#0b1220; --bg1:rgba(94,234,212,.18); --bg2:rgba(59,130,246,.16);
      --card:#101a33; --card2:#0f1830;
      --text:#e9eefc; --muted:#aab6d3;
      --accent:#5eead4; --accent2:#34d399;
      --line:rgba(255,255,255,.08);
      --shadow:0 12px 30px rgba(0,0,0,.35);
      --radius:18px;
    }
    html[data-theme="light"]{
      --bg:#f3f6ff; --bg1:rgba(99,102,241,.12); --bg2:rgba(16,185,129,.10);
      --card:#ffffff; --card2:#ffffff;
      --text:#0f172a; --muted:#5b6478;
      --accent:#6366f1; --accent2:#10b981;
      --line:rgba(15,23,42,.10);
      --shadow:0 14px 34px rgba(15,23,42,.12);
    }
    *{box-sizing:border-box}
    body{
      margin:0;
      font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial;
      color:var(--text);
      background:
        radial-gradient(900px 600px at -10% -10%, var(--bg1), transparent 60%),
        radial-gradient(900px 600px at 110% 0%, var(--bg2), transparent 55%),
        var(--bg);
      min-height:100vh;
      padding:26px;
    }
    .wrap{max-width:1200px;margin:0 auto}
    .top{
      display:flex;align-items:flex-start;justify-content:space-between;gap:14px;margin-bottom:16px;
    }
    h1{margin:0;font-size:22px;letter-spacing:.4px}
    .sub{color:var(--muted);font-size:13px;margin-top:6px}
    .topRight{display:flex;gap:10px;align-items:center}
    

    .themeToggle{
      display:inline-flex;align-items:center;gap:10px;
      padding:8px 10px;border-radius:999px;
      background:rgba(255,255,255,.06);
      border:1px solid var(--line);
      box-shadow:var(--shadow);
      user-select:none;
      cursor:pointer;
      color:var(--muted);
      font-size:12px;
    }
    html[data-theme="light"] .themeToggle{background:rgba(15,23,42,.03);box-shadow:none}
    .themeToggle input{display:none}
    .switch{
      width:44px;height:24px;border-radius:999px;
      background:rgba(255,255,255,.10);
      border:1px solid var(--line);
      position:relative;
    }
    html[data-theme="light"] .switch{background:rgba(15,23,42,.05)}
    .switch::after{
      content:"";
      width:18px;height:18px;border-radius:50%;
      position:absolute;top:2px;left:2px;
      background:var(--accent);
      transition:.2s;
      box-shadow:0 4px 12px rgba(0,0,0,.25);
    }
    html[data-theme="light"] .switch::after{box-shadow:0 6px 16px rgba(255,138,0,.30)}
    input:checked + .switch::after{left:22px}

.pill{
      padding:8px 12px;border-radius:999px;
      background:rgba(255,255,255,.06);
      border:1px solid var(--line);
      font-weight:700;font-size:12px;
    }
    .grid{
      display:grid;
      grid-template-columns: 1.1fr .9fr;
      gap:16px;
    }
    @media (max-width: 980px){
      .grid{grid-template-columns:1fr}
    }
    .card{
      background:linear-gradient(180deg, rgba(255,255,255,.06), rgba(255,255,255,.03));
      border:1px solid var(--line);
      box-shadow:var(--shadow);
      border-radius:var(--radius);
      padding:16px;
      overflow:hidden;
    }
    html[data-theme="light"] .card{
      background:linear-gradient(180deg, rgba(255,255,255,.95), rgba(255,255,255,.86));
    }
    .row{display:flex;gap:12px;flex-wrap:wrap;align-items:center}
    .field{flex:1;min-width:220px}
    .field label{
      display:block;
      color:var(--muted);
      font-size:12px;
      margin-bottom:6px;
    }
    select,input[type="number"]{
      width:100%;
      padding:12px 12px;
      border-radius:14px;
      border:1px solid var(--line);
      outline:none;
      background:rgba(255,255,255,.05);
      color:var(--text);
      font-weight:700;
      font-size:16px;
    }
    html[data-theme="light"] select, html[data-theme="light"] input[type="number"]{
      background:rgba(15,23,42,.03);
    }
    html[data-theme="dark"] select{color-scheme:dark;}
    html[data-theme="light"] select{color-scheme:light;}
    html[data-theme="dark"] select option{background: var(--card); color: var(--text);}
    html[data-theme="light"] select option{background: #ffffff; color: #0f172a;}

    .btn{
      cursor:pointer;
      border-radius:14px;
      padding:10px 14px;
      font-weight:700;
      transition:.15s transform, .15s background, .15s box-shadow;
      user-select:none;
    }
    html[data-theme="dark"] .btn{border:1px solid var(--line);background:rgba(94,234,212,.12);color:var(--text);}
    html[data-theme="dark"] .btn:hover{transform:translateY(-1px);background:rgba(94,234,212,.18)}
    html[data-theme="dark"] .btn:active{transform:translateY(0)}
    html[data-theme="light"] .btn{
      border:0;color:#fff;
      background:linear-gradient(135deg, var(--accent), var(--accent2));
      box-shadow:0 10px 24px rgba(255,138,0,.25);
    }
    html[data-theme="light"] .btn:hover{transform:translateY(-1px);box-shadow:0 14px 30px rgba(255,138,0,.32)}
    html[data-theme="light"] .btn:active{transform:translateY(0);box-shadow:0 10px 24px rgba(255,138,0,.25)}

    /* destructive action */
    html[data-theme="dark"] .btnDanger{border:1px solid rgba(248,113,113,.45);background:rgba(248,113,113,.12);}
    html[data-theme="dark"] .btnDanger:hover{background:rgba(248,113,113,.18)}
    html[data-theme="light"] .btnDanger{
      border:0;color:#fff;
      background:linear-gradient(135deg, rgba(239,68,68,.95), rgba(248,113,113,.95));
      box-shadow:0 10px 24px rgba(239,68,68,.20);
    }
    html[data-theme="light"] .btnDanger:hover{box-shadow:0 14px 30px rgba(239,68,68,.28)}

    .kpis{display:grid;grid-template-columns:repeat(3,1fr);gap:12px;margin-top:14px}
    @media (max-width: 980px){.kpis{grid-template-columns:1fr}}
    .kpi{
      border:1px solid var(--line);
      border-radius:18px;
      padding:14px;
      background:rgba(255,255,255,.04);
      min-height:88px;
    }
    html[data-theme="light"] .kpi{background:rgba(15,23,42,.02)}
    .kpi .t{color:var(--muted);font-size:12px;margin-bottom:8px}
    .kpi .v{font-size:30px;font-weight:900;letter-spacing:.4px}
    .kpi.big{background:rgba(94,234,212,.07);border-color:rgba(94,234,212,.25)}
    html[data-theme="light"] .kpi.big{background:rgba(99,102,241,.08);border-color:rgba(99,102,241,.25)}
    .kpi .h{margin-top:6px;color:var(--muted);font-size:12px;line-height:1.2}
    .details{
      margin-top:14px;
      border-top:1px dashed var(--line);
      padding-top:12px;
      display:none;
    }
    .details.show{display:block}
    table{width:100%;border-collapse:separate;border-spacing:0 10px}
    thead th{
      text-align:left;
      color:var(--muted);
      font-size:12px;
      font-weight:800;
      padding:0 10px 6px 10px;
    }
    tbody tr{
      background:rgba(255,255,255,.035);
      border:1px solid var(--line);
    }
    html[data-theme="light"] tbody tr{background:rgba(15,23,42,.02)}
    tbody td{
      padding:10px;
      border-top:1px solid var(--line);
      border-bottom:1px solid var(--line);
      font-size:14px;
    }
    tbody td:first-child{
      border-left:1px solid var(--line);
      border-top-left-radius:14px;border-bottom-left-radius:14px;
      font-weight:800;
    }
    tbody td:last-child{
      border-right:1px solid var(--line);
      border-top-right-radius:14px;border-bottom-right-radius:14px;
      font-weight:900;
    }

    /* inline edit: % авто в детализации */
    .autoCell{ display:flex; align-items:center; gap:6px; }
    .autoInput{
      width:76px;
      padding:6px 8px;
      border-radius:10px;
      border:1px solid var(--line);
      background:rgba(255,255,255,.03);
      color:var(--text);
      font-weight:900;
      outline:none;
    }
    html[data-theme="light"] .autoInput{ background:rgba(15,23,42,.03); }
    .autoSuffix{ color:var(--muted); font-weight:800; }

    .rightHead{display:flex;align-items:center;justify-content:space-between;gap:10px;margin-bottom:8px}
    .metricBar{
      display:flex;gap:6px;flex-wrap:wrap;justify-content:flex-end
    }
    .seg{
      cursor:pointer;
      padding:8px 10px;
      border-radius:999px;
      font-size:12px;
      border:1px solid var(--line);
      color:var(--muted);
      background:rgba(255,255,255,.03);
      user-select:none;
    }
    .seg.active{
      color:var(--text);
      background:rgba(94,234,212,.12);
      border-color:rgba(94,234,212,.28);
      font-weight:800;
    }
    html[data-theme="light"] .seg.active{
      background:rgba(99,102,241,.12);
      border-color:rgba(99,102,241,.28);
    }
    .note{color:var(--muted);font-size:12px;margin-top:8px}

    .yearCard{margin-top:16px}
    .yearHead{display:flex;align-items:center;justify-content:space-between;gap:10px;margin-bottom:8px}
    .yearTitle{font-weight:900}

    .yearLayout{display:flex;gap:16px;align-items:stretch}
    .yearChartWrap{flex:1;min-width:0;height:260px}
    .overloadPanel{
      width:330px;
      border:1px solid var(--line);
      border-radius:16px;
      padding:12px;
      background:rgba(255,255,255,.03);
      display:none;
    }
    html[data-theme="light"] .overloadPanel{background:rgba(15,23,42,.02)}
    .overloadPanel.show{display:block}
    .overTitle{font-weight:900;margin-bottom:6px}
    .overSub{color:var(--muted);font-size:12px;margin-bottom:10px;line-height:1.25}
    .overTable{width:100%;border-collapse:collapse}
    .overTable th{
      color:var(--muted);
      font-size:11px;
      text-align:left;
      padding:6px 0;
      border-bottom:1px solid var(--line);
      font-weight:900;
    }
    .overTable td{
      font-size:12px;
      padding:8px 0;
      border-bottom:1px solid var(--line);
      vertical-align:top;
    }
    .badgeOver{
      display:inline-block;
      padding:2px 8px;
      border-radius:999px;
      font-size:11px;
      font-weight:900;
      border:1px solid rgba(248,113,113,.45);
      background:rgba(248,113,113,.12);
      color:var(--text);
      margin-left:8px;
    }

    .overMonths{margin-top:10px;border-top:1px solid var(--line);padding-top:10px}
    .accItem{border:1px solid var(--line);border-radius:14px;overflow:hidden;margin-top:8px;background:rgba(255,255,255,.02)}
    html[data-theme="light"] .accItem{background:rgba(15,23,42,.01)}
    .accHead{
      width:100%;
      display:flex;
      align-items:center;
      justify-content:space-between;
      gap:10px;
      padding:10px;
      cursor:pointer;
      border:0;
      background:transparent;
      color:var(--text);
      font-weight:900;
      font-size:12px;
      text-align:left;
    }
    .accHead .muted{color:var(--muted);font-weight:800}
    .accBody{display:none;padding:8px 10px 10px 10px}
    .accItem.open .accBody{display:block}
    .accTable{width:100%;border-collapse:collapse}
    .accTable th{color:var(--muted);font-size:11px;font-weight:900;text-align:left;padding:0 0 6px 0}
    .accTable td{font-size:12px;padding:6px 0;border-top:1px solid var(--line)}
    @media (max-width: 980px){
      .yearLayout{flex-direction:column}
      .overloadPanel{width:100%}
      .yearChartWrap{height:280px}
    }
    .pillBtn{ cursor:pointer; user-select:none; }
    .pillBtn:hover{ filter: brightness(1.08); }
    .pillBtn:active{ transform: translateY(1px); }

    .modal{
      position:fixed;
      inset:0;
      display:none;
      z-index:9999;
    }
    .modal.show{ display:block; }

    .modal__backdrop{
      position:absolute;
      inset:0;
      background:rgba(0,0,0,.55);
      backdrop-filter: blur(6px);
    }

    .modal__card{
      position:relative;
      width:min(760px, calc(100vw - 32px));
      max-height: min(80vh, 640px);
      overflow:auto;
      margin: 70px auto 0 auto;
      background:linear-gradient(180deg, rgba(255,255,255,.06), rgba(255,255,255,.03));
      border:1px solid var(--line);
      box-shadow:var(--shadow);
      border-radius:var(--radius);
      padding:14px;
    }
    html[data-theme="light"] .modal__card{
      background:linear-gradient(180deg, rgba(255,255,255,.98), rgba(255,255,255,.90));
    }

    .modal__head{
      display:flex;
      align-items:center;
      justify-content:space-between;
      gap:10px;
      margin-bottom:10px;
    }
    .modal__title{ font-weight:900; }

    .modal__close{
      border:1px solid var(--line);
      background:rgba(255,255,255,.04);
      color:var(--text);
      border-radius:12px;
      padding:8px 10px;
      cursor:pointer;
    }
    .modal__close:hover{ filter: brightness(1.08); }

    .modal__body{
      border-top:1px dashed var(--line);
      padding-top:10px;
    }

    html[data-theme="dark"] .modal__close{
      color: var(--text);
      background: rgba(255,255,255,.08);
      border-color: rgba(255,255,255,.20);
    }
    html[data-theme="dark"] .modal__close:hover{
      background: rgba(255,255,255,.15);
    }

    html[data-theme="dark"] #wikiBtn{
      color: var(--text);
    }

    .wiki h2{margin:0 0 10px 0;font-size:18px}
    .wiki h3{margin:14px 0 8px 0;font-size:13px;color:var(--muted);letter-spacing:.2px;text-transform:uppercase}
    .wiki p{margin:0 0 10px 0;line-height:1.45}
    .wiki ul{margin:0 0 10px 18px;padding:0}
    .wiki li{margin:4px 0;line-height:1.4}
    .wiki table{width:100%;border-collapse:separate;border-spacing:0 8px;margin-top:6px}
    .wiki thead th{padding:0 10px 6px 10px}
    .wiki tbody tr{background:rgba(255,255,255,.03)}
    html[data-theme="light"] .wiki tbody tr{background:rgba(15,23,42,.02)}
    .wiki tbody td{padding:10px;border-top:1px solid var(--line);border-bottom:1px solid var(--line)}
    .wiki tbody td:first-child{border-left:1px solid var(--line);border-top-left-radius:12px;border-bottom-left-radius:12px;font-weight:800}
    .wiki tbody td:last-child{border-right:1px solid var(--line);border-top-right-radius:12px;border-bottom-right-radius:12px;font-weight:900}
    .wiki .hr{margin:12px 0;border-top:1px dashed var(--line)}
