:root{
      --bg:#f7f8fc;
      --panel:#ffffff;
      --panel-soft:#fbfbfe;
      --text:#20263a;
      --muted:#6e7892;
      --line:#e8eaf4;
      --shadow:0 14px 42px rgba(38,55,120,0.08);
      --radius:24px;

      --lav:#f0ecff;
      --blue:#eaf4ff;
      --mint:#ebfbf3;
      --peach:#fff3e8;
      --pink:#fff0f6;
      --yellow:#fff9dc;

      --lav-deep:#8b75ff;
      --blue-deep:#5f9dff;
      --mint-deep:#2db981;
      --peach-deep:#ff9f4a;
      --pink-deep:#f06292;
      --yellow-deep:#c6a500;

      --critical-bg:#fff0f1;
      --critical-tx:#d24a5c;
      --warning-bg:#fff7e8;
      --warning-tx:#ba7a00;
      --healthy-bg:#eefbf4;
      --healthy-tx:#20945a;
      --hold-bg:#f2efff;
      --hold-tx:#6f58d8;
      --info-bg:#eef4ff;
      --info-tx:#4b73d6;
    }
    *{box-sizing:border-box}
    body{
      margin:0;
      font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
      background:
        radial-gradient(circle at 10% 20%, rgba(255,192,203,0.18), transparent 25%),
        radial-gradient(circle at 90% 5%, rgba(156,204,255,0.22), transparent 22%),
        radial-gradient(circle at 85% 85%, rgba(196,255,214,0.18), transparent 22%),
        var(--bg);
      color:var(--text);
    }
    .app{
      display:grid;
      grid-template-columns: 360px 1fr;
      min-height:100vh;
      gap:18px;
      padding:18px;
    }
    .sidebar{
      position:sticky;
      top:18px;
      align-self:start;
      max-height:calc(100vh - 36px);
      overflow:auto;
      padding-right:4px;
    }
    .main{
      min-width:0;
      display:grid;
      gap:18px;
    }
    .panel{
      background:rgba(255,255,255,0.86);
      border:1px solid rgba(232,234,244,0.95);
      box-shadow:var(--shadow);
      border-radius:var(--radius);
      backdrop-filter: blur(12px);
    }
    .brand{
      padding:22px;
      background:linear-gradient(135deg, rgba(240,236,255,0.95), rgba(234,244,255,0.95) 48%, rgba(255,243,232,0.95));
      border:1px solid rgba(255,255,255,0.75);
      margin-bottom:16px;
    }
    .brand-top{
      display:flex;
      align-items:center;
      gap:14px;
      margin-bottom:14px;
    }
    .brand-badge{
      width:54px;
      height:54px;
      border-radius:18px;
      display:grid;
      place-items:center;
      background:linear-gradient(135deg, #8b75ff, #5f9dff);
      color:#fff;
      font-weight:800;
      font-size:18px;
      box-shadow:0 12px 30px rgba(95,157,255,0.28);
    }
    .brand h1{
      margin:0;
      font-size:22px;
      line-height:1.05;
      letter-spacing:-0.03em;
    }
    .brand p{
      margin:0;
      color:var(--muted);
      font-size:13px;
      line-height:1.6;
    }
    .pill-row{
      display:flex;
      flex-wrap:wrap;
      gap:8px;
      margin-top:12px;
    }
    .mini-pill{
      padding:8px 10px;
      border-radius:999px;
      font-size:11px;
      font-weight:700;
      border:1px solid rgba(255,255,255,0.8);
      background:rgba(255,255,255,0.64);
      color:#44506e;
    }
    .side-card{
      padding:18px;
      margin-bottom:16px;
    }
    .side-card h2,
    .section-title{
      margin:0 0 6px;
      font-size:15px;
      letter-spacing:-0.01em;
    }
    .helper{
      color:var(--muted);
      font-size:12px;
      line-height:1.55;
      margin:0 0 12px;
    }
    .field{
      display:grid;
      gap:8px;
      margin-bottom:12px;
    }
    .grid-2fields{
      display:grid;
      grid-template-columns:1fr 1fr;
      gap:10px;
    }
    label{
      font-size:12px;
      font-weight:700;
      color:#55607c;
      letter-spacing:0.01em;
    }
    input, select, button, textarea{
      font:inherit;
    }
    .input, .select, .file-input{
      width:100%;
      border:1px solid var(--line);
      background:#fff;
      color:var(--text);
      padding:12px 14px;
      border-radius:16px;
      font-size:13px;
      outline:none;
      transition:.18s ease;
    }
    .input:focus, .select:focus, .file-input:focus{
      border-color:#9bbaf9;
      box-shadow:0 0 0 4px rgba(95,157,255,0.14);
    }
    .button{
      width:100%;
      border:0;
      padding:13px 16px;
      border-radius:16px;
      cursor:pointer;
      font-weight:800;
      transition:transform .12s ease, box-shadow .12s ease, opacity .12s ease;
    }
    .button:hover{ transform:translateY(-1px); }
    .button.primary{
      color:#25304f;
      background:linear-gradient(135deg, #cfe3ff, #f7def6 48%, #fff0d0);
      box-shadow:0 12px 24px rgba(133,161,255,0.16);
    }
    .button.secondary{
      background:#fff;
      color:#485570;
      border:1px solid var(--line);
    }
    .button-row{
      display:grid;
      gap:10px;
    }
    .preview{
      border:1px dashed #d8dced;
      background:var(--panel-soft);
      padding:12px;
      border-radius:18px;
      min-height:112px;
      max-height:220px;
      overflow:auto;
      font-size:11px;
      line-height:1.55;
      color:#62708e;
      white-space:pre-wrap;
    }
    .mapping-grid{
      display:grid;
      gap:10px;
    }
    .header{
      display:flex;
      justify-content:space-between;
      gap:16px;
      padding:22px;
      align-items:flex-start;
      background:linear-gradient(135deg, rgba(255,255,255,0.9), rgba(240,236,255,0.75), rgba(234,244,255,0.75));
    }
    .header h2{
      margin:0;
      font-size:28px;
      line-height:1.02;
      letter-spacing:-0.04em;
    }
    .header p{
      margin:8px 0 0;
      color:var(--muted);
      line-height:1.6;
      font-size:14px;
      max-width:760px;
    }
    .status-chip{
      padding:10px 14px;
      border-radius:999px;
      background:#fff;
      border:1px solid var(--line);
      font-size:12px;
      color:#4b5875;
      font-weight:700;
      white-space:nowrap;
    }
    .note-band{
      padding:16px 18px;
      border-radius:22px;
      background:linear-gradient(135deg, var(--yellow), var(--pink));
      border:1px solid rgba(255,255,255,0.9);
      display:flex;
      justify-content:space-between;
      gap:12px;
      flex-wrap:wrap;
      align-items:center;
    }
    .note-band strong{font-size:14px}
    .note-band span{
      color:#645b4c;
      font-size:13px;
      line-height:1.55;
    }
    .kpi-grid{
      display:grid;
      grid-template-columns:repeat(6,minmax(0,1fr));
      gap:14px;
    }
    .kpi{
      padding:18px;
      position:relative;
      overflow:hidden;
    }
    .kpi.bg-lav{background:linear-gradient(135deg, #faf8ff, #f0ecff);}
    .kpi.bg-blue{background:linear-gradient(135deg, #fbfdff, #eaf4ff);}
    .kpi.bg-mint{background:linear-gradient(135deg, #fbfffd, #ebfbf3);}
    .kpi.bg-peach{background:linear-gradient(135deg, #fffdfb, #fff3e8);}
    .kpi.bg-pink{background:linear-gradient(135deg, #fffafd, #fff0f6);}
    .kpi.bg-yellow{background:linear-gradient(135deg, #fffef8, #fff9dc);}
    .kpi-label{
      color:#66718a;
      font-size:12px;
      font-weight:700;
      margin-bottom:10px;
    }
    .kpi-value{
      font-size:34px;
      line-height:1;
      font-weight:800;
      letter-spacing:-0.04em;
      margin-bottom:10px;
    }
    .kpi-sub{
      color:#73809d;
      font-size:12px;
      line-height:1.45;
    }
    .content-grid-2{
      display:grid;
      grid-template-columns:1.08fr .92fr;
      gap:18px;
    }
    .content-grid-2.equal{
      grid-template-columns:1fr 1fr;
    }
    .content-grid-4{
      display:grid;
      grid-template-columns:repeat(2,minmax(0,1fr));
      gap:18px;
    }
    .card{
      padding:20px;
      min-width:0;
    }
    .card-header{
      display:flex;
      justify-content:space-between;
      gap:12px;
      align-items:flex-start;
      margin-bottom:12px;
    }
    .card-header p{
      margin:4px 0 0;
      color:var(--muted);
      font-size:13px;
      line-height:1.5;
    }
    .soft-badge{
      padding:7px 10px;
      border-radius:999px;
      font-size:11px;
      font-weight:800;
      white-space:nowrap;
    }
    .soft-badge.info{background:var(--info-bg); color:var(--info-tx);}
    .soft-badge.lav{background:var(--lav); color:var(--hold-tx);}
    .chart-wrap{
      position:relative;
      height:320px;
    }
    .chart-wrap.small{
      height:280px;
    }
    .cards-stack{
      display:grid;
      gap:12px;
      max-height:420px;
      overflow:auto;
      padding-right:2px;
    }
    .dispatch-card{
      padding:16px;
      border-radius:20px;
      border:1px solid var(--line);
      background:#fff;
      display:grid;
      gap:10px;
    }
    .dispatch-top{
      display:flex;
      justify-content:space-between;
      gap:12px;
      align-items:flex-start;
      flex-wrap:wrap;
    }
    .dispatch-title{
      font-size:18px;
      font-weight:800;
      line-height:1.15;
      letter-spacing:-0.02em;
      margin:0;
    }
    .dispatch-sub{
      color:var(--muted);
      font-size:12px;
      margin-top:4px;
    }
    .status-badge{
      display:inline-flex;
      align-items:center;
      padding:8px 12px;
      border-radius:999px;
      font-size:11px;
      font-weight:800;
    }
    .status-critical{background:var(--critical-bg); color:var(--critical-tx);}
    .status-warning{background:var(--warning-bg); color:var(--warning-tx);}
    .status-healthy{background:var(--healthy-bg); color:var(--healthy-tx);}
    .status-hold{background:var(--hold-bg); color:var(--hold-tx);}
    .stat-line{
      display:grid;
      grid-template-columns:repeat(4,minmax(0,1fr));
      gap:10px;
    }
    .mini-stat{
      padding:12px;
      border-radius:16px;
      background:var(--panel-soft);
      border:1px solid var(--line);
    }
    .mini-stat-label{
      font-size:11px;
      color:#7b86a0;
      margin-bottom:4px;
      font-weight:700;
    }
    .mini-stat-value{
      font-size:18px;
      font-weight:800;
      letter-spacing:-0.03em;
    }
    .drivers{
      display:flex;
      flex-wrap:wrap;
      gap:8px;
    }
    .driver{
      padding:8px 10px;
      border-radius:999px;
      background:var(--blue);
      color:#49649d;
      font-size:11px;
      font-weight:700;
    }
    .hold-card{
      background:linear-gradient(135deg,#fbfaff,#f5f2ff);
    }
    .table-shell{
      overflow:auto;
      border:1px solid var(--line);
      border-radius:22px;
      background:#fff;
    }
    table{
      width:100%;
      border-collapse:collapse;
      min-width:1080px;
    }
    th, td{
      padding:14px 14px;
      border-bottom:1px solid var(--line);
      text-align:left;
      vertical-align:top;
      font-size:13px;
    }
    th{
      position:sticky;
      top:0;
      background:#fbfcff;
      z-index:2;
      color:#57637f;
      font-size:11px;
      font-weight:800;
      text-transform:uppercase;
      letter-spacing:.08em;
    }
    tbody tr:hover{
      background:#fbfcff;
    }
    .muted{
      color:var(--muted);
    }
    .legend-note{
      color:#73809d;
      font-size:12px;
      line-height:1.6;
      margin-top:12px;
    }
    .empty{
      padding:28px;
      text-align:center;
      color:#7d8aa6;
      border:1px dashed #d9deed;
      border-radius:20px;
      background:#fbfbfe;
      line-height:1.6;
      font-size:13px;
    }
    .footer{
      padding:16px 18px;
      color:#71809d;
      font-size:12px;
      line-height:1.65;
    }
    .tiny-list{
      display:flex;
      flex-wrap:wrap;
      gap:8px;
    }
    .tiny-item{
      padding:6px 8px;
      border-radius:999px;
      font-size:11px;
      border:1px solid var(--line);
      background:#fff;
      color:#66738f;
      font-weight:700;
    }

    @media (max-width: 1500px){
      .kpi-grid{grid-template-columns:repeat(3,minmax(0,1fr));}
      .content-grid-2, .content-grid-2.equal, .content-grid-4{grid-template-columns:1fr;}
    }
    @media (max-width: 1150px){
      .app{grid-template-columns:1fr; padding:14px;}
      .sidebar{position:static; max-height:none;}
    }
    @media (max-width: 720px){
      .kpi-grid{grid-template-columns:1fr;}
      .grid-2fields, .stat-line{grid-template-columns:1fr 1fr;}
      .header{flex-direction:column;}
    }
    @media (max-width: 560px){
      .grid-2fields, .stat-line{grid-template-columns:1fr;}
    }

    .theme-switcher{display:flex;gap:8px;flex-wrap:wrap;margin-top:16px}
    .theme-btn{border:1px solid var(--line);background:rgba(255,255,255,0.7);color:var(--text);padding:8px 14px;border-radius:999px;font:inherit;font-weight:600;cursor:pointer;transition:all .2s ease;box-shadow:0 2px 8px rgba(38,55,120,.05)}
    .theme-btn:hover{transform:translateY(-1px)}
    .theme-btn.active{background:var(--text);color:#fff;border-color:var(--text)}

    :root[data-theme="dark"]{
      --bg:#0f1423;
      --panel:#171d2e;
      --panel-soft:#1d2436;
      --text:#edf2ff;
      --muted:#aeb8d7;
      --line:#2a3248;
      --shadow:0 18px 50px rgba(0,0,0,0.35);
      --lav:#2a2345;
      --blue:#1f2e49;
      --mint:#1e3a33;
      --peach:#463324;
      --pink:#412635;
      --yellow:#403819;
      --lav-deep:#b7a7ff;
      --blue-deep:#8bb7ff;
      --mint-deep:#5ce0ad;
      --peach-deep:#ffbd78;
      --pink-deep:#ff99bf;
      --yellow-deep:#ebd467;
      --critical-bg:#3c2026;
      --critical-tx:#ffb3be;
      --warning-bg:#43351d;
      --warning-tx:#ffd782;
      --healthy-bg:#193628;
      --healthy-tx:#92efba;
      --hold-bg:#2d2650;
      --hold-tx:#c5baff;
      --info-bg:#1f2f4e;
      --info-tx:#a8c6ff;
    }
    :root[data-theme="dark"] body{
      background:
        radial-gradient(circle at 10% 20%, rgba(174,120,195,0.14), transparent 25%),
        radial-gradient(circle at 90% 5%, rgba(96,133,225,0.14), transparent 22%),
        radial-gradient(circle at 85% 85%, rgba(98,190,149,0.12), transparent 22%),
        var(--bg);
    }
    :root[data-theme="dark"] .panel{
      background:rgba(23,29,46,0.88);
      border:1px solid rgba(42,50,72,0.95);
    }
    :root[data-theme="dark"] .brand{background:linear-gradient(135deg, rgba(42,35,69,0.96), rgba(31,46,73,0.96) 48%, rgba(70,51,36,0.96));border-color:rgba(255,255,255,0.06)}
    :root[data-theme="dark"] .input,
    :root[data-theme="dark"] .select,
    :root[data-theme="dark"] .file-input,
    :root[data-theme="dark"] textarea{background:#13192a;color:var(--text);border-color:var(--line)}
    :root[data-theme="dark"] table th{background:rgba(255,255,255,0.03)}
    :root[data-theme="dark"] .preview,
    :root[data-theme="dark"] .note-band{background:rgba(255,255,255,0.03);border-color:var(--line)}
