:root{
    --blue:#18624e;
    --blue-deep:#114c3c;
    --red:#E31226;
    --ink:#182620;
    --text:#384b43;
    --muted:#53675e;
    --field:#eef3f0;
    --line:#dce5e0;
    --tint:#e4f0e9;
    --success-ink:#146B39;
    --success-soft:#E8F6EE;
    --warning-ink:#8F5500;
    --warning-soft:#FFF4E0;
    --danger-soft:#FDECEE;
    --danger-ink:#A01423;
    --success:#1B8A4A;
    --error:#C4293A;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --nav-h: 64px;
  }

  *{margin:0;padding:0;box-sizing:border-box;-webkit-tap-highlight-color:transparent;}

  html{
    -webkit-text-size-adjust:100%;
    background:#fff;
  }

  body{
    font-family:'Instrument Sans',system-ui,-apple-system,'Segoe UI',sans-serif;
    color:var(--ink);
    min-height:100vh;
    min-height:100dvh;
    -webkit-font-smoothing:antialiased;
    -moz-osx-font-smoothing:grayscale;
  }

  .app{
    min-height:100vh;
    min-height:100dvh;
    display:flex;
    flex-direction:column;
  }

  /* ===== TOPO ===== */
  .hero{
    position:relative;
    isolation:isolate;
    overflow:hidden;
    background:var(--blue);
    color:#fff;
    padding:calc(24px + var(--safe-top)) 20px 56px;
  }

  .topbar{
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:16px;
  }

  .greet{display:flex;flex-direction:column;gap:2px;min-width:0;}

  .greet .hello{
    font-size:0.875rem;
    font-weight:600;
    color:rgba(255,255,255,0.8);
  }
  .greet .name{
    font-weight:800;
    font-size:1.5rem;
    line-height:1.2;
    letter-spacing:-0.03em;
    white-space:nowrap;
    overflow:hidden;
    text-overflow:ellipsis;
  }

  .topbar-actions{
    display:flex;
    align-items:center;
    gap:8px;
    flex-shrink:0;
  }

  .icon-btn{
    position:relative;
    width:44px;
    height:44px;
    border-radius:50%;
    background:rgba(255,255,255,0.16);
    border:none;
    color:#fff;
    display:flex;
    align-items:center;
    justify-content:center;
    cursor:pointer;
    touch-action:manipulation;
    transition:background .12s;
  }
  .icon-btn:active{background:rgba(255,255,255,0.28);}
  .icon-btn svg{width:22px;height:22px;}
  .icon-btn .dot{
    position:absolute;
    top:9px;
    right:9px;
    width:8px;
    height:8px;
    border-radius:50%;
    background:var(--red);
    border:2px solid var(--blue);
  }

  .avatar{
    width:44px;
    height:44px;
    border-radius:50%;
    background:#fff;
    color:var(--blue);
    display:flex;
    align-items:center;
    justify-content:center;
    font-weight:800;
    font-size:1.0625rem;
    flex-shrink:0;
  }

  /* KPIs */
  .summary{
    display:grid;
    grid-template-columns:repeat(2, 1fr);
    gap:16px 20px;
    margin-top:26px;
  }

  .sum-item{
    display:flex;
    flex-direction:column;
    gap:4px;
    min-width:0;
  }

  .sum-item .lbl{
    font-size:0.75rem;
    font-weight:600;
    color:rgba(255,255,255,0.78);
    text-transform:uppercase;
    letter-spacing:0.04em;
  }

  .sum-item .num-row{
    display:flex;
    align-items:baseline;
    gap:8px;
    flex-wrap:wrap;
  }

  .sum-item .num{
    font-weight:800;
    font-size:1.75rem;
    line-height:1;
    letter-spacing:-0.03em;
    font-variant-numeric:tabular-nums;
  }

  .trend{
    display:inline-flex;
    align-items:center;
    gap:2px;
    font-size:0.6875rem;
    font-weight:800;
    padding:2px 7px;
    border-radius:999px;
    background:rgba(255,255,255,0.18);
    color:#fff;
    line-height:1;
  }
  .trend.up{color:#B8F3CE;}
  .trend.down{color:#FFC4CB;}

  /* ===== FOLHA ===== */
  .sheet{
    position:relative;
    z-index:1;
    flex:1;
    background:#fff;
    border-radius:28px 28px 0 0;
    margin-top:-28px;
    padding:24px 20px calc(var(--nav-h) + var(--safe-bottom) + 24px);
  }

  /* ===== AÇÕES RÁPIDAS ===== */
  .quick{
    display:grid;
    grid-template-columns:repeat(2, 1fr);
    gap:10px;
    margin-bottom:24px;
  }

  .quick-btn{
    display:flex;
    align-items:center;
    gap:10px;
    padding:12px 14px;
    background:var(--field);
    border:1px solid transparent;
    border-radius:14px;
    font-family:inherit;
    font-weight:700;
    font-size:0.8125rem;
    color:var(--ink);
    text-align:left;
    text-decoration:none;
    cursor:pointer;
    touch-action:manipulation;
    transition:background .12s, border-color .12s;
  }
  .quick-btn:active{background:#e4ece7;}
  .quick-btn svg{
    width:22px;
    height:22px;
    padding:5px;
    border-radius:8px;
    background:var(--tint);
    color:var(--blue);
    flex-shrink:0;
    box-sizing:content-box;
  }
  .quick-btn.primary{
    background:var(--blue);
    color:#fff;
    box-shadow:0 8px 20px rgba(24,98,78,0.22);
  }
  .quick-btn.primary svg{background:rgba(255,255,255,0.2);color:#fff;}
  .quick-btn.primary:active{background:var(--blue-deep);}

  /* ===== SEÇÕES ===== */
  .section{
    margin-bottom:24px;
  }

  .section-head{
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:12px;
    margin-bottom:14px;
  }

  .section-head h2{
    font-weight:800;
    font-size:1.0625rem;
    letter-spacing:-0.02em;
    color:var(--ink);
  }

  .section-head .see-all{
    display:inline-flex;
    align-items:center;
    min-height:36px;
    margin-right:-8px;
    padding:0 10px;
    color:var(--blue);
    font-weight:700;
    font-size:0.8125rem;
    text-decoration:none;
    border-radius:10px;
    touch-action:manipulation;
  }
  .section-head .see-all:active{background:var(--tint);}

  /* ===== CARDS DE RELATÓRIO ===== */
  .card{
    background:#fff;
    border:1px solid var(--line);
    border-radius:16px;
    padding:16px;
  }

  /* Chart area */
  .chart-wrap{
    position:relative;
    height:180px;
    margin:0 -4px;
  }

  .chart-legend{
    display:flex;
    gap:16px;
    margin-top:14px;
    flex-wrap:wrap;
  }
  .chart-legend .leg{
    display:flex;
    align-items:center;
    gap:6px;
    font-size:0.75rem;
    font-weight:600;
    color:var(--muted);
  }
  .chart-legend .leg .sw{
    width:12px;
    height:12px;
    border-radius:4px;
    flex-shrink:0;
  }
  .chart-legend .leg .sw.completed{background:var(--blue);}
  .chart-legend .leg .sw.pending{background:#a0b9ab;}

  /* Donut */
  .donut-wrap{
    display:flex;
    align-items:center;
    gap:20px;
    flex-wrap:wrap;
  }

  .donut-svg{flex-shrink:0;}

  .donut-legend{
    display:flex;
    flex-direction:column;
    gap:8px;
    flex:1;
    min-width:130px;
  }
  .donut-legend .leg{
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:8px;
    font-size:0.8125rem;
    font-weight:600;
    color:var(--text);
  }
  .donut-legend .leg .lg-l{
    display:flex;
    align-items:center;
    gap:8px;
    min-width:0;
  }
  .donut-legend .leg .sw{
    width:10px;
    height:10px;
    border-radius:3px;
    flex-shrink:0;
  }
  .donut-legend .leg .lg-v{
    font-weight:800;
    color:var(--ink);
    font-variant-numeric:tabular-nums;
  }

  /* ===== TABELAS ===== */
  .tbl{
    display:flex;
    flex-direction:column;
  }

  .tbl-row{
    display:flex;
    align-items:center;
    gap:12px;
    padding:12px 0;
    border-bottom:1px solid var(--line);
  }
  .tbl-row:last-child{border-bottom:none;}
  .tbl-row:first-child{padding-top:0;}

  .tbl-row .row-ic{
    width:40px;
    height:40px;
    border-radius:10px;
    background:var(--tint);
    color:var(--blue);
    display:flex;
    align-items:center;
    justify-content:center;
    flex-shrink:0;
  }
  .tbl-row .row-ic svg{width:20px;height:20px;}
  .tbl-row .row-ic.thumb{padding:0;overflow:hidden;background:var(--field);}
  .tbl-row .row-ic.thumb img{width:100%;height:100%;object-fit:cover;}

  .tbl-row .row-body{
    flex:1;
    min-width:0;
    display:flex;
    flex-direction:column;
    gap:2px;
  }
  .tbl-row .row-title{
    font-weight:700;
    font-size:0.875rem;
    color:var(--ink);
    line-height:1.25;
    overflow:hidden;
    text-overflow:ellipsis;
    white-space:nowrap;
  }
  .tbl-row .row-meta{
    font-size:0.75rem;
    font-weight:600;
    color:var(--muted);
    display:flex;
    gap:8px;
    align-items:center;
    flex-wrap:wrap;
  }
  .tbl-row .row-meta .sep{opacity:0.4;}

  .row-actions{
    display:flex;
    gap:6px;
    flex-shrink:0;
  }

  .mini-btn{
    width:36px;
    height:36px;
    border-radius:10px;
    border:1px solid var(--line);
    background:#fff;
    color:var(--text);
    display:flex;
    align-items:center;
    justify-content:center;
    cursor:pointer;
    touch-action:manipulation;
    transition:background .12s, border-color .12s, color .12s;
  }
  .mini-btn svg{width:16px;height:16px;}
  .mini-btn:active{background:var(--field);}
  .mini-btn.approve{color:var(--success);}
  .mini-btn.approve:active{background:var(--success-soft);border-color:#B7E3C7;}
  .mini-btn.reject{color:var(--error);}
  .mini-btn.reject:active{background:var(--danger-soft);border-color:#F3BBC3;}

  /* ===== RANKING ===== */
  .rank-item{
    display:flex;
    align-items:center;
    gap:12px;
    padding:12px 0;
    border-bottom:1px solid var(--line);
  }
  .rank-item:last-child{border-bottom:none;}

  .rank-pos{
    width:26px;
    height:26px;
    border-radius:50%;
    display:flex;
    align-items:center;
    justify-content:center;
    font-size:0.75rem;
    font-weight:800;
    color:var(--muted);
    background:var(--field);
    flex-shrink:0;
  }
  .rank-item:nth-child(1) .rank-pos{background:#FFE9B0;color:#8F5500;}
  .rank-item:nth-child(2) .rank-pos{background:#E2E6EC;color:#4B5563;}
  .rank-item:nth-child(3) .rank-pos{background:#F4D6B8;color:#7C3A0A;}

  .rank-avatar{
    width:36px;
    height:36px;
    border-radius:50%;
    background:var(--blue);
    color:#fff;
    display:flex;
    align-items:center;
    justify-content:center;
    font-weight:800;
    font-size:0.875rem;
    flex-shrink:0;
  }

  .rank-body{
    flex:1;
    min-width:0;
  }
  .rank-name{
    font-weight:700;
    font-size:0.875rem;
    color:var(--ink);
    white-space:nowrap;
    overflow:hidden;
    text-overflow:ellipsis;
  }
  .rank-sub{
    font-size:0.75rem;
    font-weight:600;
    color:var(--muted);
    margin-top:1px;
  }

  .rank-value{
    text-align:right;
    flex-shrink:0;
  }
  .rank-value .rv{
    font-weight:800;
    font-size:0.9375rem;
    color:var(--ink);
    font-variant-numeric:tabular-nums;
  }
  .rank-value .rl{
    font-size:0.6875rem;
    font-weight:700;
    color:var(--muted);
    text-transform:uppercase;
    letter-spacing:0.04em;
  }

  /* ===== FEED DE ATIVIDADES ===== */
  .feed{
    display:flex;
    flex-direction:column;
    gap:2px;
    position:relative;
    padding-left:20px;
  }
  .feed::before{
    content:"";
    position:absolute;
    left:6px;
    top:10px;
    bottom:10px;
    width:2px;
    background:var(--line);
    border-radius:2px;
  }

  .feed-item{
    position:relative;
    padding:10px 0;
  }

  .feed-item::before{
    content:"";
    position:absolute;
    left:-19px;
    top:16px;
    width:12px;
    height:12px;
    border-radius:50%;
    background:#fff;
    border:3px solid var(--blue);
  }
  .feed-item.green::before{border-color:var(--success);}
  .feed-item.warn::before{border-color:#E0A03A;}
  .feed-item.info::before{border-color:#8D9CB8;}

  .feed-body{
    font-size:0.875rem;
    font-weight:600;
    color:var(--ink);
    line-height:1.35;
  }
  .feed-meta{
    display:flex;
    align-items:center;
    gap:8px;
    margin-top:2px;
    font-size:0.75rem;
    color:var(--muted);
    font-weight:600;
  }
  .feed-meta .driver{
    display:inline-flex;
    align-items:center;
    gap:5px;
  }
  .feed-meta .driver .d-av{
    width:16px;height:16px;border-radius:50%;
    background:var(--tint);color:var(--blue);
    font-size:0.625rem;font-weight:800;
    display:flex;align-items:center;justify-content:center;
  }

  /* ===== EXPORTAÇÃO ===== */
  .export-row{
    display:grid;
    grid-template-columns:repeat(3, 1fr);
    gap:8px;
  }
  .export-btn{
    display:flex;
    flex-direction:column;
    align-items:center;
    gap:6px;
    padding:14px 8px;
    background:#fff;
    border:1px solid var(--line);
    border-radius:14px;
    font-family:inherit;
    font-weight:700;
    font-size:0.75rem;
    color:var(--ink);
    text-align:center;
    cursor:pointer;
    touch-action:manipulation;
    transition:background .12s, border-color .12s;
  }
  .export-btn:active{background:var(--field);}
  .export-btn svg{width:22px;height:22px;color:var(--blue);}
  .export-btn.csv svg{color:#1F8F51;}
  .export-btn.xls svg{color:#107C41;}

  /* ===== ESTADO VAZIO ===== */
  .empty-mini{
    text-align:center;
    padding:28px 16px;
    border:1px dashed var(--line);
    border-radius:14px;
    color:var(--muted);
    font-size:0.8125rem;
    font-weight:600;
  }

  /* ===== TOAST ===== */
  .toast{
    position:fixed;
    left:50%;
    bottom:calc(var(--nav-h) + var(--safe-bottom) + 12px);
    transform:translate(-50%, 12px);
    width:calc(100% - 32px);
    max-width:420px;
    background:var(--ink);
    color:#fff;
    padding:14px 16px;
    border-radius:12px;
    font-weight:600;
    font-size:0.875rem;
    line-height:1.35;
    display:flex;
    align-items:center;
    gap:10px;
    box-shadow:0 8px 24px rgba(24,38,32,0.22);
    opacity:0;
    pointer-events:none;
    transition:opacity .2s ease, transform .2s ease;
    z-index:60;
  }
  .toast.show{opacity:1;transform:translate(-50%,0);}
  .toast.success{background:var(--success);}
  .toast.error{background:var(--error);}
  .toast .spin{
    width:16px;height:16px;
    border-radius:50%;
    border:2px solid rgba(255,255,255,0.35);
    border-top-color:#fff;
    animation:spin .7s linear infinite;
    flex-shrink:0;
  }
  @keyframes spin{to{transform:rotate(360deg);}}

  @media (max-width:360px){
    .hero,.sheet{padding-left:16px;padding-right:16px;}
    .greet .name{font-size:1.3rem;}
    .sum-item .num{font-size:1.5rem;}
    .quick{grid-template-columns:1fr;}
  }

  /* ===== DESKTOP ===== */
  @media (min-width:900px){

    .hero,.sheet{
      width:100%;
      max-width:1280px;
    }

    .hero{
      background:transparent;
      color:var(--ink);
      padding:40px 48px 0;
      overflow:visible;
    }
    .greet .hello{color:var(--muted);}
    .greet .name{font-size:2rem;}
    .avatar{background:var(--blue);color:#fff;}
    .icon-btn{background:var(--field);color:var(--ink);}
    .icon-btn:hover{background:#e4ece7;}
    .icon-btn .dot{border-color:#fff;}

    .summary{
      display:grid;
      grid-template-columns:repeat(4, 1fr);
      gap:16px;
      margin-top:28px;
    }

    .sum-item{
      padding:20px 22px;
      background:var(--field);
      border-radius:16px;
    }
    .sum-item .lbl{color:var(--muted);}
    .sum-item .num{font-size:2rem;}
    .trend{background:rgba(24,98,78,0.10);color:var(--blue);}
    .trend.up{color:var(--success-ink);background:var(--success-soft);}
    .trend.down{color:var(--danger-ink);background:var(--danger-soft);}

    .sheet{
      background:transparent;
      border-radius:0;
      margin-top:0;
      padding:32px 48px 48px;
    }

    .quick{
      grid-template-columns:repeat(4, 1fr);
      gap:12px;
    }

    .grid-2{
      display:grid;
      grid-template-columns:1.5fr 1fr;
      gap:16px;
      margin-bottom:24px;
    }
    .grid-2b{
      display:grid;
      grid-template-columns:1fr 1fr;
      gap:16px;
      margin-bottom:24px;
    }

    .card{padding:22px;}

    .chart-wrap{height:220px;}

    .toast{
      left:calc(50% + (var(--rail-w) / 2));
      bottom:24px;
    }
  }

  @media (prefers-reduced-motion:reduce){
    *{animation-duration:0.001ms !important;transition-duration:0.001ms !important;}
  }