:root{
    --ink:#16213A;
    --ink-soft:#5B6478;
    --bg:#F3F5FA;
    --surface:#FFFFFF;
    --surface-alt:#EAEFF9;
    --line:#DCE2F0;
    --primary:#2363E9;
    --primary-light:#3E78F2;
    --primary-dark:#12266B;
    --primary-deep:#0A1740;
    --accent:#2363E9;
    --accent-soft:#DCE7FC;
    --brand-gray:#8C93A6;
    --ok:#2F7D5A;
    --ok-bg:#E4F1EA;
    --danger:#C24444;
    --danger-bg:#F8E7E5;
    --info:#3E7CB1;
    --info-bg:#E6EEF5;
    --neutral:#8A7B66;
    --neutral-bg:#EFE9DE;
    --radius:10px;
    --shadow: 0 1px 2px rgba(18,38,107,0.07), 0 8px 24px -12px rgba(18,38,107,0.22);
  }
  *{box-sizing:border-box;}
  html,body{margin:0;padding:0;height:100%;}
  body{
    background:var(--bg);
    color:var(--ink);
    font-family:'Inter',sans-serif;
    font-size:14px;
    -webkit-font-smoothing:antialiased;
  }
  h1,h2,h3,.display{
    font-family:'Fraunces',serif;
    font-weight:600;
    letter-spacing:-0.01em;
  }
  .mono{ font-family:'IBM Plex Mono',monospace; letter-spacing:-0.01em; }

  #app{ display:flex; min-height:100vh; }

  /* Sidebar */
  .sidebar{
    width:250px;
    flex:0 0 250px;
    background:linear-gradient(180deg, var(--primary-dark) 0%, var(--primary-deep) 100%);
    color:#EAF0FA;
    padding:28px 20px;
    display:flex;
    flex-direction:column;
    gap:28px;
    position:sticky;
    top:0;
    height:100vh;
  }
  .brand{ display:flex; flex-direction:column; gap:2px; }
  .brand .mark{
    width:38px;height:38px;border-radius:9px;
    overflow:hidden;
    margin-bottom:10px;
    box-shadow:0 2px 8px rgba(0,0,0,0.25);
  }
  .brand .mark img{ width:100%; height:100%; display:block; object-fit:cover; }
  .brand h1{ font-size:19px; color:#fff; margin:0; line-height:1.15; }
  .brand span{ font-size:12px; color:#8FA6D9; }

  .nav-stats{ display:flex; flex-direction:column; gap:6px; }
  .nav-stat{
    display:flex; justify-content:space-between; align-items:baseline;
    padding:10px 12px; border-radius:8px; cursor:pointer;
    border:1px solid transparent;
    transition:background .12s ease;
  }
  .nav-stat:hover{ background:rgba(255,255,255,0.06); }
  .nav-stat.active{ background:rgba(255,255,255,0.1); border-color:rgba(255,255,255,0.18); }
  .nav-stat .lbl{ font-size:12.5px; color:#C9DEDB; }
  .nav-stat .val{ font-family:'Fraunces',serif; font-size:17px; color:#fff; }
  .nav-stat.dot-ok .val{ color:#8FDCB4; }
  .nav-stat.dot-cancel .val{ color:#F0A6A0; }
  .nav-stat.dot-info .val{ color:#9BC8EA; }
  .nav-stat.dot-neutral .val{ color:#E6D3AE; }

  .sidebar-footer{ margin-top:auto; font-size:11.5px; color:#7FA6A1; line-height:1.5; }

  /* Main */
  .main{ flex:1; min-width:0; padding:28px 32px 60px; }
  .topbar{
    display:flex; align-items:center; justify-content:space-between; gap:16px;
    margin-bottom:22px; flex-wrap:wrap;
  }
  .topbar h2{ font-size:24px; margin:0; }
  .topbar .sub{ font-size:13px; color:var(--ink-soft); margin-top:2px; }

  .btn{
    font-family:'Inter',sans-serif; font-weight:600; font-size:13.5px;
    border:none; border-radius:8px; padding:10px 16px; cursor:pointer;
    display:inline-flex; align-items:center; gap:7px;
    transition:transform .08s ease, box-shadow .12s ease;
  }
  .btn:active{ transform:scale(0.97); }
  .btn-primary{ background:var(--accent); color:#2B1704; box-shadow:var(--shadow); }
  .btn-primary:hover{ background:#C97D28; }
  .btn-ghost{ background:var(--surface); color:var(--primary); border:1px solid var(--line); }
  .btn-ghost:hover{ background:var(--surface-alt); }
  .btn-danger{ background:var(--danger-bg); color:var(--danger); }
  .btn-danger:hover{ background:#f2d5d2; }
  .btn-sm{ padding:6px 10px; font-size:12.5px; border-radius:6px; }

  .toolbar{
    display:flex; align-items:center; gap:10px; margin-bottom:16px; flex-wrap:wrap;
  }
  .search-box{
    display:flex; align-items:center; gap:8px;
    background:var(--surface); border:1px solid var(--line); border-radius:8px;
    padding:9px 12px; flex:1; min-width:220px; max-width:380px;
  }
  .search-box input{
    border:none; outline:none; font-size:13.5px; width:100%; background:transparent; color:var(--ink);
    font-family:'Inter',sans-serif;
  }
  .chip{
    border:1px solid var(--line); background:var(--surface); color:var(--ink-soft);
    padding:7px 13px; border-radius:999px; font-size:12.5px; cursor:pointer; font-weight:600;
    white-space:nowrap;
  }
  .chip.active{ background:var(--primary); border-color:var(--primary); color:#fff; }

  select.ddd-filter{
    border:1px solid var(--line); background:var(--surface); color:var(--ink);
    padding:9px 10px; border-radius:8px; font-size:13px; font-family:'Inter',sans-serif;
  }

  table{ width:100%; border-collapse:collapse; background:var(--surface); border-radius:var(--radius); overflow:hidden; box-shadow:var(--shadow); }
  thead th{
    text-align:left; font-size:11px; text-transform:uppercase; letter-spacing:0.04em;
    color:var(--ink-soft); padding:12px 14px; background:var(--surface-alt); border-bottom:1px solid var(--line);
    font-weight:600;
  }
  tbody td{ padding:12px 14px; border-bottom:1px solid var(--line); font-size:13.5px; vertical-align:middle; }
  tbody tr:last-child td{ border-bottom:none; }
  tbody tr{ cursor:pointer; transition:background .1s ease; }
  tbody tr:hover{ background:#FAF8F2; }

  .ddd-badge{
    width:34px; height:34px; border-radius:50%; background:var(--info-bg); color:var(--info);
    display:inline-flex; align-items:center; justify-content:center; font-size:12px; font-weight:700;
    font-family:'IBM Plex Mono',monospace;
  }
  .vendor-chip{
    display:inline-flex; align-items:center; padding:4px 10px; border-radius:999px;
    background:var(--accent-soft); color:var(--primary); font-size:11.5px; font-weight:700;
  }
  .cliente-cell{ display:flex; align-items:center; gap:10px; }
  .cliente-name{ font-weight:600; }
  .cliente-sub{ font-size:11.5px; color:var(--ink-soft); }

  .status-pill{
    display:inline-flex; align-items:center; gap:6px; padding:4px 10px; border-radius:999px;
    font-size:11.5px; font-weight:700;
  }
  .status-pill .d{ width:6px;height:6px;border-radius:50%; }
  .st-ativo{ background:var(--ok-bg); color:var(--ok); }
  .st-ativo .d{ background:var(--ok); }
  .st-cancelado{ background:var(--danger-bg); color:var(--danger); }
  .st-cancelado .d{ background:var(--danger); }
  .st-analise{ background:var(--info-bg); color:var(--info); }
  .st-analise .d{ background:var(--info); }
  .st-outro{ background:var(--neutral-bg); color:var(--neutral); }
  .st-outro .d{ background:var(--neutral); }

  .row-actions{ display:flex; gap:6px; opacity:0; transition:opacity .1s ease; }
  tbody tr:hover .row-actions{ opacity:1; }
  .icon-btn{
    width:28px;height:28px;border-radius:6px;border:1px solid var(--line);background:var(--surface);
    display:flex;align-items:center;justify-content:center;cursor:pointer;color:var(--ink-soft);
  }
  .icon-btn:hover{ background:var(--surface-alt); color:var(--ink); }

  .empty-state{ padding:60px 20px; text-align:center; color:var(--ink-soft); }
  .empty-state .display{ font-size:20px; color:var(--ink); margin-bottom:6px; }

  .vendor-grid{
    display:grid; grid-template-columns:repeat(auto-fill, minmax(260px, 1fr)); gap:14px;
  }
  .vendor-card{
    background:var(--surface); border:1px solid var(--line); border-radius:var(--radius);
    padding:18px; cursor:pointer; box-shadow:var(--shadow); transition:transform .1s ease, border-color .1s ease;
  }
  .vendor-card:hover{ transform:translateY(-2px); border-color:var(--primary-light); }
  .vendor-card.muted{ opacity:0.72; }
  .vendor-card-head{ display:flex; align-items:center; gap:11px; margin-bottom:14px; }
  .vendor-name{ font-family:'Fraunces',serif; font-size:16px; font-weight:600; }
  .vendor-count{ font-size:11.5px; color:var(--ink-soft); margin-top:1px; }
  .vendor-bar{
    display:flex; height:8px; border-radius:999px; overflow:hidden; background:var(--surface-alt); margin-bottom:12px;
  }
  .vendor-bar span{ display:block; }
  .vendor-stats-row{ display:flex; flex-direction:column; gap:5px; }
  .vstat{ display:flex; align-items:center; gap:7px; font-size:12px; color:var(--ink-soft); }
  .vstat .dot{ width:7px; height:7px; border-radius:50%; flex:0 0 auto; }
  .vendor-leads{
    margin-top:12px; padding-top:10px; border-top:1px solid var(--line);
    font-size:11.5px; color:var(--primary); font-weight:700;
  }

  /* Modal */
  .overlay{
    position:fixed; inset:0; background:rgba(16,36,43,0.42); backdrop-filter:blur(1px);
    display:flex; justify-content:flex-end; z-index:50; opacity:0; pointer-events:none;
    transition:opacity .15s ease;
  }
  .overlay.show{ opacity:1; pointer-events:auto; }
  .panel{
    width:560px; max-width:94vw; height:100vh; background:var(--surface);
    box-shadow:-12px 0 36px -12px rgba(16,36,43,0.35);
    display:flex; flex-direction:column; transform:translateX(24px); transition:transform .18s ease;
  }
  .overlay.show .panel{ transform:translateX(0); }
  .panel-head{
    padding:22px 26px; border-bottom:1px solid var(--line); display:flex; justify-content:space-between; align-items:flex-start;
  }
  .panel-head h3{ margin:0 0 3px; font-size:19px; }
  .panel-head p{ margin:0; font-size:12.5px; color:var(--ink-soft); }
  .panel-body{ flex:1; overflow-y:auto; padding:20px 26px 100px; }
  .panel-foot{
    padding:16px 26px; border-top:1px solid var(--line); display:flex; justify-content:space-between; gap:10px;
    background:var(--surface);
  }

  .section-title{
    font-size:11px; text-transform:uppercase; letter-spacing:0.06em; color:var(--accent);
    font-weight:700; margin:22px 0 10px; display:flex; align-items:center; gap:8px;
  }
  .section-title:first-child{ margin-top:0; }
  .section-title::after{ content:""; flex:1; height:1px; background:var(--line); }

  .field-grid{ display:grid; grid-template-columns:1fr 1fr; gap:12px; }
  .field{ display:flex; flex-direction:column; gap:5px; margin-bottom:12px; }
  .field.full{ grid-column:1 / -1; }
  .field label{ font-size:11.5px; font-weight:600; color:var(--ink-soft); }
  .field input, .field select, .field textarea{
    border:1px solid var(--line); border-radius:7px; padding:9px 11px; font-size:13.5px;
    font-family:'Inter',sans-serif; color:var(--ink); background:var(--bg);
    outline:none;
  }
  .field input:focus, .field select:focus, .field textarea:focus{ border-color:var(--primary); background:var(--surface); }
  .field textarea{ resize:vertical; min-height:56px; }

  .close-x{ cursor:pointer; color:var(--ink-soft); background:none; border:none; font-size:20px; line-height:1; padding:4px; }
  .close-x:hover{ color:var(--ink); }

  .toast{
    position:fixed; bottom:24px; left:50%; transform:translateX(-50%) translateY(20px);
    background:var(--primary); color:#fff; padding:11px 20px; border-radius:8px; font-size:13px; font-weight:600;
    box-shadow:var(--shadow); z-index:100; opacity:0; pointer-events:none; transition:all .2s ease;
  }
  .toast.show{ opacity:1; transform:translateX(-50%) translateY(0); }

  .confirm-box{
    position:fixed; inset:0; background:rgba(16,36,43,0.42); display:flex; align-items:center; justify-content:center;
    z-index:60; opacity:0; pointer-events:none; transition:opacity .15s ease;
  }
  .confirm-box.show{ opacity:1; pointer-events:auto; }
  .confirm-card{
    background:var(--surface); border-radius:12px; padding:22px; width:340px; box-shadow:var(--shadow);
  }
  .confirm-card h4{ margin:0 0 8px; font-family:'Fraunces',serif; font-size:17px; }
  .confirm-card p{ margin:0 0 16px; font-size:13px; color:var(--ink-soft); }
  .confirm-actions{ display:flex; justify-content:flex-end; gap:8px; }

  ::-webkit-scrollbar{ width:9px; }
  ::-webkit-scrollbar-thumb{ background:var(--line); border-radius:20px; }

  /* Login gate */
  .login-wrap{
    min-height:100vh; display:flex; background:var(--surface);
  }
  .login-side{
    flex:1 1 46%;
    background:
      radial-gradient(circle at 15% 12%, rgba(62,120,242,0.35), transparent 45%),
      linear-gradient(160deg, var(--primary-dark) 0%, var(--primary-deep) 100%);
    display:flex; flex-direction:column; justify-content:space-between;
    padding:48px;
    color:#EAF0FA;
    position:relative;
    overflow:hidden;
  }
  .login-side .logo-lockup{ max-width:280px; }
  .login-side .logo-lockup img{ width:100%; display:block; }
  .login-side .pitch{ max-width:400px; }
  .login-side .pitch h2{ color:#fff; font-size:26px; margin:0 0 10px; line-height:1.25; }
  .login-side .pitch p{ color:#B9C7EA; font-size:14px; line-height:1.6; margin:0; }
  .login-side .foot-note{ font-size:11.5px; color:#7488B8; }

  .login-main{
    flex:1 1 54%; display:flex; align-items:center; justify-content:center; padding:40px;
  }
  .login-card{ width:100%; max-width:360px; }
  .login-card .icon-badge{ width:46px;height:46px;border-radius:11px; overflow:hidden; margin-bottom:22px; box-shadow:var(--shadow); }
  .login-card .icon-badge img{ width:100%; height:100%; object-fit:cover; display:block; }
  .login-card h2{ font-size:23px; margin:0 0 6px; }
  .login-card .sub{ font-size:13px; color:var(--ink-soft); margin-bottom:26px; }
  .login-card .field{ margin-bottom:14px; }
  .login-card .field input, .login-card .field select{ width:100%; padding:11px 13px; font-size:14px; }
  .login-card .btn-primary{ width:100%; justify-content:center; padding:12px; font-size:14px; margin-top:6px; }
  .login-error{
    background:var(--danger-bg); color:var(--danger); font-size:12.5px; font-weight:600;
    padding:9px 12px; border-radius:7px; margin-bottom:14px; display:none;
  }
  .login-error.show{ display:block; }
  .login-toggle{ margin-top:18px; font-size:12.5px; color:var(--ink-soft); text-align:center; }
  .login-toggle button{
    background:none; border:none; color:var(--primary); font-weight:700; cursor:pointer; font-size:12.5px;
    font-family:'Inter',sans-serif; padding:0; margin-left:4px;
  }
  .login-hint{
    font-size:11.5px; color:var(--ink-soft); background:var(--surface-alt); border-radius:7px;
    padding:9px 11px; margin-top:16px; line-height:1.5;
  }

  /* Equipe / Employees */
  .team-row{
    display:flex; align-items:center; justify-content:space-between; gap:10px;
    padding:12px 0; border-bottom:1px solid var(--line);
  }
  .team-row:last-child{ border-bottom:none; }
  .team-who{ display:flex; align-items:center; gap:10px; }
  .team-avatar{
    width:34px;height:34px;border-radius:50%; background:var(--accent-soft); color:var(--primary);
    display:flex; align-items:center; justify-content:center; font-weight:700; font-size:13px;
    font-family:'Fraunces',serif;
  }
  .team-name{ font-weight:600; font-size:13.5px; }
  .team-user{ font-size:11.5px; color:var(--ink-soft); }
  .role-badge{
    font-size:10.5px; font-weight:700; text-transform:uppercase; letter-spacing:.03em;
    padding:3px 8px; border-radius:999px; background:var(--accent-soft); color:var(--primary);
  }
  .role-badge.staff{ background:var(--neutral-bg); color:var(--neutral); }
  .user-pill{
    display:flex; align-items:center; gap:9px; padding:10px 12px; border-radius:9px;
    background:rgba(255,255,255,0.06); margin-bottom:4px;
  }
  .user-pill .team-avatar{ background:rgba(255,255,255,0.14); color:#fff; }
  .user-pill .team-name{ color:#fff; }
  .user-pill .team-user{ color:#8FA6D9; }
  .sidebar-link{
    display:flex; align-items:center; gap:8px; padding:9px 10px; border-radius:7px;
    color:#C7D3F0; font-size:12.5px; font-weight:600; cursor:pointer; background:none; border:none;
    font-family:'Inter',sans-serif; text-align:left; width:100%;
  }
  .sidebar-link.active{ background:rgba(255,255,255,0.12); color:#fff; }
  .sidebar-link:hover{ background:rgba(255,255,255,0.07); color:#fff; }

  @media (max-width:820px){
    .login-side{ display:none; }
    .sidebar{ display:none; }
    .main{ padding:18px; }
    .field-grid{ grid-template-columns:1fr; }
    table thead{ display:none; }
    table, tbody, tr, td{ display:block; width:100%; }
    tbody tr{ border-bottom:6px solid var(--bg); padding:10px 0; }
    tbody td{ border:none; padding:4px 14px; }
  }