:root{
    --ink:#14243a;
    --navy:#1a4070;
    --navy-dark:#0f2a47;
    --cyan:#0a9bdb;
    --cyan-dark:#0673a3;
    --cyan-soft:#eef8fd;
    --cyan-head:#d9eefa;
    --surface:#f1f4f8;
    --paper:#ffffff;
    --line:#d3dce8;
    --muted:#5a6b80;
    --danger:#b3261e;
    --radius:6px;
  }
  *{box-sizing:border-box}
  html{-webkit-text-size-adjust:100%}
  body{
    margin:0; background:var(--surface); color:var(--ink);
    font-family:'Barlow',system-ui,'Segoe UI',Roboto,Arial,sans-serif; font-size:15px; line-height:1.4;
  }
  button,input,textarea,select{font:inherit;color:inherit}
  h1,h2,h3{margin:0}

  /* ---------- Barra superior ---------- */
  .topbar{
    background:var(--navy); color:#fff;
    border-bottom:4px solid var(--cyan);
    display:flex; align-items:center; gap:18px; padding:10px 24px;
  }
  .brand-logo{background:#fff; padding:4px 10px; border-radius:3px; display:flex; align-items:center; box-shadow:0 2px 6px rgba(0,0,0,.25)}
  .brand-logo img{height:34px; width:auto; display:block}
  .topbar h1{font-family:'Barlow Condensed',sans-serif; font-weight:600; font-size:26px; letter-spacing:.01em}
  .topbar .spacer{flex:1}
  .save-state{font-size:13px; color:#c9dcf0}
  .save-state.error{color:#ffb4ab; font-weight:600}

  /* ---------- Botões ---------- */
  .btn{
    display:inline-flex; align-items:center; gap:8px; cursor:pointer;
    border:1px solid var(--line); background:var(--paper); color:var(--ink);
    padding:8px 14px; border-radius:var(--radius); font-weight:500; white-space:nowrap;
  }
  .btn:hover{border-color:#9db0c6; background:#f7f9fc}
  .btn.primary{background:var(--navy); border-color:var(--navy); color:#fff; font-weight:600}
  .btn.primary:hover{background:var(--navy-dark); border-color:var(--navy-dark)}
  .btn.on-dark{background:transparent; border-color:rgba(255,255,255,.4); color:#fff}
  .btn.on-dark:hover{background:rgba(255,255,255,.12); border-color:#fff}
  .btn.danger{color:var(--danger)}
  .btn.link{border-color:transparent; background:transparent; padding:4px 8px; color:var(--cyan-dark); font-weight:500}
  .btn.link:hover{background:var(--cyan-soft); border-color:transparent}
  .btn.link.danger{color:var(--danger)}
  .btn.link.danger:hover{background:#fdecea}
  .btn svg{width:16px;height:16px;flex:none}
  :focus-visible{outline:3px solid var(--cyan); outline-offset:2px}

  /* ---------- Abas de clientes ---------- */
  .tabs{display:flex; align-items:flex-end; gap:4px; padding:18px 24px 0; overflow-x:auto}
  .tab{
    border:0; background:transparent; cursor:pointer; padding:10px 16px 9px;
    color:var(--muted); font-weight:500; border-bottom:3px solid transparent; white-space:nowrap;
    display:flex; align-items:center; gap:8px;
  }
  .tab:hover{color:var(--ink)}
  .tab[aria-selected="true"]{color:var(--navy); font-weight:700; border-bottom-color:var(--cyan)}
  .tab .count{font-size:12px; background:#e2e9f1; color:var(--muted); border-radius:10px; padding:1px 8px; font-weight:600}
  .tab[aria-selected="true"] .count{background:var(--cyan-head); color:var(--cyan-dark)}
  .tab-add{margin-left:8px; margin-bottom:4px}
  .tabs-line{border-bottom:1px solid var(--line); margin:0 24px}

  /* ---------- Painel principal ---------- */
  main{padding:20px 24px 40px}
  .panel{background:var(--paper); border:1px solid var(--line); border-radius:8px}
  .panel-head{display:flex; flex-wrap:wrap; align-items:flex-end; gap:16px 24px; padding:20px 24px 16px; border-bottom:1px solid var(--line)}
  .panel-head .title{flex:1; min-width:260px}
  .panel-head h2{font-family:'Barlow Condensed',sans-serif; font-size:34px; font-weight:600; line-height:1.05; color:var(--navy-dark)}
  .panel-head .sub{display:flex; align-items:center; gap:4px; margin-top:6px; color:var(--muted); font-size:14px; flex-wrap:wrap}
  .panel-head .sub .dot{margin:0 4px}
  .report-controls{display:flex; align-items:flex-end; gap:10px; flex-wrap:wrap}
  .field{display:flex; flex-direction:column; gap:4px}
  .field > span{font-size:13px; color:var(--muted); font-weight:500}
  .input{
    border:1px solid var(--line); background:#fff; border-radius:var(--radius);
    padding:7px 10px; width:100%; min-height:38px;
  }
  .input:hover{border-color:#9db0c6}
  .input:focus{outline:2px solid var(--cyan); outline-offset:0; border-color:var(--cyan)}

  /* ---------- Tabela de processos ---------- */
  .table-wrap{overflow-x:auto}
  table{border-collapse:separate; border-spacing:0; width:100%; min-width:1400px; table-layout:fixed}
  th,td{padding:10px 12px; text-align:left; vertical-align:top; border-bottom:1px solid var(--line)}
  thead .group th{
    font-family:'Barlow Condensed',sans-serif; font-size:16px; font-weight:600; letter-spacing:.02em;
    padding:10px 12px; border-bottom:1px solid var(--line);
  }
  thead .group .fixed{color:var(--navy); background:#f7f9fc}
  thead .group .weekly{color:var(--cyan-dark); background:var(--cyan-head); border-left:1px solid #bfdff1}
  thead .group .weekly small{font-family:'Barlow',sans-serif; font-weight:500; font-size:13px; color:var(--cyan-dark); opacity:.85; margin-left:8px; letter-spacing:0}
  thead .cols th{font-size:13px; font-weight:600; color:var(--muted); padding:8px 12px; background:#fff}
  thead .cols .weekly{background:var(--cyan-soft); color:var(--cyan-dark)}
  tbody td.weekly{background:var(--cyan-soft)}
  tbody td.weekly:first-of-type, thead .weekly.first{border-left:1px solid #bfdff1}
  tbody tr:last-child td{border-bottom:0}
  .c-act{text-align:right; padding-left:6px; padding-right:8px}
  .cell-main{font-weight:600; color:var(--ink); overflow-wrap:anywhere}
  .cell-sub{display:block; color:var(--muted); font-size:13.5px; margin-top:2px; overflow-wrap:anywhere}
  .empty-dash{color:#9aa8ba}
  td.weekly .input{padding:6px 9px; min-height:36px; font-size:14.5px}
  td.weekly textarea.input{resize:none; overflow:hidden; display:block; min-height:62px; line-height:1.35}
  .date-line{display:flex; align-items:center; gap:8px}
  .date-line + .date-line{margin-top:6px}
  .date-line > span{width:28px; flex:none; font-size:13px; font-weight:600; color:var(--cyan-dark)}
  .date-line .input{flex:1; min-width:0; width:auto; min-height:36px; padding:5px 6px; font-size:14px}
  .row-actions{display:flex; justify-content:flex-end; gap:0; flex-wrap:nowrap}
  .icon-btn{
    width:28px; height:28px; display:grid; place-items:center; cursor:pointer;
    background:transparent; border:1px solid transparent; border-radius:var(--radius); color:var(--muted);
  }
  .icon-btn:hover{background:#e9eff6; color:var(--ink)}
  .icon-btn.danger:hover{background:#fdecea; color:var(--danger)}
  .icon-btn:disabled{opacity:.3; cursor:default; background:transparent}
  .icon-btn svg{width:17px; height:17px}
  .table-foot{padding:14px 24px; border-top:1px solid var(--line); display:flex; align-items:center; gap:12px; flex-wrap:wrap}
  .table-foot .hint{color:var(--muted); font-size:13.5px}

  .empty{padding:56px 24px; text-align:center}
  .empty h3{font-family:'Barlow Condensed',sans-serif; font-size:26px; font-weight:600; color:var(--navy-dark)}
  .empty p{margin:8px auto 18px; max-width:46ch; color:var(--muted)}

  .footnote{margin-top:16px; color:var(--muted); font-size:13.5px}

  /* ---------- Diálogos ---------- */
  dialog{border:0; padding:0; border-radius:10px; box-shadow:0 20px 60px rgba(15,42,71,.35); color:var(--ink); max-width:calc(100vw - 32px)}
  dialog::backdrop{background:rgba(15,42,71,.5)}
  .dlg{width:560px; max-width:100%}
  .dlg-head{padding:20px 24px 4px}
  .dlg-head h3{font-family:'Barlow Condensed',sans-serif; font-size:26px; font-weight:600; color:var(--navy-dark)}
  .dlg-head p{margin:4px 0 0; color:var(--muted); font-size:14px}
  .dlg-body{padding:14px 24px 6px; display:grid; gap:14px}
  .dlg-body.two{grid-template-columns:1fr 1fr}
  .dlg-body .full{grid-column:1/-1}
  .dlg-foot{padding:16px 24px 20px; display:flex; justify-content:flex-end; gap:10px}
  .dlg-msg{padding:6px 24px 0; color:var(--ink)}
  .preview{width:min(1100px, calc(100vw - 32px)); height:min(760px, calc(100vh - 32px)); display:flex; flex-direction:column}
  .preview .dlg-foot{border-top:1px solid var(--line); padding:12px 20px; align-items:center}
  .preview .dlg-foot .grow{flex:1; font-weight:600; color:var(--navy-dark)}
  .preview iframe{flex:1; width:100%; border:0; background:#e4e9ef}

  .toast{
    position:fixed; left:50%; bottom:24px; transform:translateX(-50%); background:var(--navy-dark); color:#fff;
    padding:10px 18px; border-radius:8px; font-weight:500; box-shadow:0 8px 24px rgba(0,0,0,.3);
    opacity:0; pointer-events:none; transition:opacity .2s;
  }
  .toast.show{opacity:1}
  @media (prefers-reduced-motion:reduce){ .toast{transition:none} }
  .sr-only{position:absolute; width:1px; height:1px; overflow:hidden; clip:rect(0 0 0 0); white-space:nowrap}

  /* ================= acréscimos da versão com servidor ================= */
  [hidden]{display:none !important}
  .topbar .who-am-i{font-size:14px; color:#dbe8f6}
  .sync{font-size:13px; color:#c9dcf0; display:flex; align-items:center; gap:7px}
  .sync::before{content:""; width:8px; height:8px; border-radius:50%; background:#5fd38d; flex:none}
  .sync.saving::before{background:#ffd166}
  .sync.offline{color:#ffb4ab; font-weight:600}
  .sync.offline::before{background:#ff6b5e}

  .menu{position:relative}
  .menu-list{
    position:absolute; right:0; top:calc(100% + 6px); min-width:210px; z-index:20;
    background:#fff; color:var(--ink); border:1px solid var(--line); border-radius:8px;
    box-shadow:0 12px 32px rgba(15,42,71,.25); padding:6px; display:grid; gap:2px;
  }
  .menu-list button{border:0; background:transparent; text-align:left; padding:9px 12px; border-radius:6px; cursor:pointer; display:flex; gap:10px; align-items:center}
  .menu-list button:hover{background:var(--cyan-soft)}
  .menu-list .sep{height:1px; background:var(--line); margin:4px 0}
  .menu-list .me{padding:8px 12px 6px; color:var(--muted); font-size:13px}
  .menu-list .me strong{display:block; color:var(--ink); font-size:15px}

  /* tela de login */
  .login-screen{
    position:fixed; inset:0; z-index:50; background:var(--surface);
    display:grid; place-items:center; padding:24px; overflow:auto;
  }
  .login-card{width:min(400px,100%); background:#fff; border:1px solid var(--line); border-radius:10px; overflow:hidden; box-shadow:0 10px 40px rgba(15,42,71,.12)}
  .login-top{background:var(--navy); border-bottom:4px solid var(--cyan); padding:22px 24px; display:flex; justify-content:center}
  .login-top .brand-logo img{height:48px}
  .login-body{padding:24px; display:grid; gap:16px}
  .login-body h2{font-family:'Barlow Condensed',sans-serif; font-size:30px; font-weight:600; color:var(--navy-dark)}
  .login-body p{margin:0; color:var(--muted)}
  .form-error{color:var(--danger); font-weight:500; min-height:1.4em; margin:0}
  .btn.block{width:100%; justify-content:center; padding:11px 14px}

  /* atualizado por */
  .who{
    display:block; margin-top:6px; padding:2px 0; border:0; background:transparent; cursor:pointer;
    color:var(--muted); font-size:12.5px; text-align:left;
  }
  .who:hover{color:var(--cyan-dark); text-decoration:underline}

  /* usuários */
  .dlg.wide{width:760px}
  .users-table{width:100%; min-width:0; table-layout:auto; font-size:14.5px}
  .users-table th{font-size:13px; color:var(--muted); font-weight:600; background:#fff; padding:8px 10px}
  .users-table td{padding:8px 10px; vertical-align:middle}
  .users-table select{min-height:34px; padding:4px 8px}
  .users-table .off td{color:#8896a8}
  .users-table .row-actions{justify-content:flex-start; gap:6px}
  .badge{font-size:12px; font-weight:600; padding:2px 8px; border-radius:10px; background:#e2e9f1; color:var(--muted)}
  .badge.on{background:#dff3e6; color:#1d6b3a}
  .users-scroll{max-height:52vh; overflow:auto; border-top:1px solid var(--line); border-bottom:1px solid var(--line); margin:14px 0 0}

  /* histórico */
  .hist-list{list-style:none; margin:0; padding:0; max-height:52vh; overflow:auto; display:grid}
  .hist-list li{padding:10px 24px; border-top:1px solid var(--line); display:grid; gap:2px}
  .hist-list li:first-child{border-top:0}
  .hist-meta{font-size:13px; color:var(--muted)}
  .hist-change b{color:var(--navy-dark)}
  .hist-from{color:#8896a8; text-decoration:line-through; margin-right:6px}
  .hist-empty{padding:18px 24px; color:var(--muted)}
