/* ── Reset ───────────────────────────────────────────────── */
*,*::before,*::after{box-sizing:border-box;margin:0;padding:0}

/* ══ PALETAS DE CORES ════════════════════════════════════════
   Cada paleta define accent (UI) + colorway (gráficos).
   O tema (dark/light) controla fundo e texto separadamente.
══════════════════════════════════════════════════════════ */
[data-palette="teal"]{
  --accent:#004140; --accent-l:#00605e; --accent-ll:#008f8c;
  --accent2:#ED7D31; --accent2-d:#c96520;
}
[data-palette="indigo"]{
  --accent:#312e81; --accent-l:#4338ca; --accent-ll:#818cf8;
  --accent2:#f59e0b; --accent2-d:#d97706;
}
[data-palette="emerald"]{
  --accent:#064e3b; --accent-l:#065f46; --accent-ll:#34d399;
  --accent2:#fbbf24; --accent2-d:#d97706;
}
[data-palette="violet"]{
  --accent:#4c1d95; --accent-l:#5b21b6; --accent-ll:#a78bfa;
  --accent2:#f59e0b; --accent2-d:#d97706;
}
[data-palette="ruby"]{
  --accent:#7f1d1d; --accent-l:#991b1b; --accent-ll:#f87171;
  --accent2:#fbbf24; --accent2-d:#d97706;
}
[data-palette="slate"]{
  --accent:#1e3a5f; --accent-l:#1e4976; --accent-ll:#60a5fa;
  --accent2:#38bdf8; --accent2-d:#0ea5e9;
}

/* ══ TEMAS ═══════════════════════════════════════════════════ */
[data-theme="dark"]{
  --bg:#12161f; --bg2:#1a2030; --bg3:#212840;
  --sidebar:#161b27; --sidebar-hover:#1e2538;
  --border:#2a3350; --border2:#33405a;
  --text:#d4dbe8; --muted:#6b7a98; --text-head:#e8edf6;
  --card:#1e2538; --card2:#252d40;
  --chip-bg:#232d42;
  --gridcol:#2a3350; --zerocol:#33405a;
  --font-color:#c8d0e0;
  --upload-err-bg:#2d1515; --upload-err-border:#5a2020; --upload-err-text:#f88;
}
[data-theme="light"]{
  --bg:#ffffff; --bg2:#f7f9fc; --bg3:#f0f4f8;
  --sidebar:#ffffff; --sidebar-hover:#f0f4f8;
  --border:#dde3ec; --border2:#c8d5e4;
  --text:#2a3348; --muted:#7a8fa6; --text-head:#1a2535;
  --card:#ffffff; --card2:#f7fafc;
  --chip-bg:#edf0f5;
  --gridcol:#e0e8f0; --zerocol:#ccd5e0;
  --font-color:#3a4a60;
  --upload-err-bg:#fff0f0; --upload-err-border:#f5c6c6; --upload-err-text:#c00;
}

/* ── Base ─────────────────────────────────────────────────── */
.cts-font{font-family:'cts','dispersao-legacy','Segoe UI',system-ui,Arial,sans-serif}
body{font-family:'Segoe UI',system-ui,Arial,sans-serif;background:var(--bg);color:var(--text);min-height:100vh;display:flex;flex-direction:column}
.hidden{display:none !important}

/* ── Topbar ───────────────────────────────────────────────── */
.topbar{
  height:52px;background:var(--sidebar);border-bottom:1px solid var(--border);
  display:flex;align-items:center;gap:.75rem;padding:0 1.25rem;
  position:sticky;top:0;z-index:100;flex-shrink:0;
}
.logo-mark{
  width:32px;height:32px;border-radius:8px;background:var(--accent);
  display:flex;align-items:center;justify-content:center;flex-shrink:0;
}
.logo-mark svg{width:18px;height:18px;fill:white}
.app-name{font-size:.92rem;font-weight:700;color:var(--text-head);letter-spacing:.02em}
.sprint-badge{
  margin-left:auto;background:var(--chip-bg);border:1px solid var(--border);
  border-radius:99px;padding:.25rem .75rem;font-size:.75rem;
  color:var(--muted);font-weight:600;letter-spacing:.03em;display:none;
}
.sprint-badge.visible{display:inline-block}
.topbar-actions{display:flex;align-items:center;gap:.4rem;margin-left:.5rem}
.topbar-user{
  display:flex;align-items:center;gap:.5rem;margin-left:.75rem;
  padding:.2rem .35rem .2rem .7rem;border:1px solid var(--border);
  border-radius:999px;background:var(--chip-bg);
}
.topbar-user-name{
  font-size:.75rem;color:var(--text);max-width:180px;
  white-space:nowrap;overflow:hidden;text-overflow:ellipsis;
}
.btn-topbar{
  height:28px;padding:0 .7rem;border:1px solid var(--border);border-radius:999px;
  background:var(--bg3);cursor:pointer;color:var(--muted);font-size:.72rem;
  font-weight:700;font-family:inherit;transition:all .15s;
}
.btn-topbar:hover{background:var(--sidebar-hover);color:var(--text);border-color:var(--border2)}
.btn-icon{
  width:32px;height:32px;border:1px solid var(--border);border-radius:8px;
  background:var(--chip-bg);cursor:pointer;color:var(--muted);
  display:flex;align-items:center;justify-content:center;transition:all .15s;font-size:.8rem;
}
.btn-icon:hover{background:var(--sidebar-hover);color:var(--text);border-color:var(--border2)}
.btn-upload-new{
  height:32px;padding:0 .85rem;border:1px solid var(--border);border-radius:8px;
  background:var(--chip-bg);cursor:pointer;color:var(--muted);font-size:.78rem;
  font-weight:600;font-family:inherit;display:none;align-items:center;gap:.4rem;
  transition:all .15s;white-space:nowrap;
}
.btn-upload-new:hover{background:var(--sidebar-hover);color:var(--text);border-color:var(--border2)}
.btn-upload-new.visible{display:flex}

/* ── Palette button & panel ───────────────────────────────── */
.palette-btn-wrap{position:relative}
.palette-btn{
  width:32px;height:32px;border:1px solid var(--border);border-radius:8px;
  background:var(--chip-bg);cursor:pointer;
  display:flex;align-items:center;justify-content:center;transition:all .15s;gap:3px;padding:7px;
}
.palette-btn:hover{background:var(--sidebar-hover);border-color:var(--border2)}
.palette-dot{width:8px;height:8px;border-radius:50%;background:var(--accent);flex-shrink:0}
.palette-dot2{width:6px;height:6px;border-radius:50%;background:var(--accent2);flex-shrink:0}
.palette-panel{
  display:none;position:fixed;top:auto;right:1rem;
  background:var(--sidebar);border:1px solid var(--border);border-radius:14px;
  padding:1rem;box-shadow:0 8px 32px rgba(0,0,0,.22);z-index:200;width:260px;
}
.palette-panel.open{display:block}
.palette-panel-title{font-size:.68rem;font-weight:700;color:var(--muted);letter-spacing:.07em;text-transform:uppercase;margin-bottom:.65rem}
.palette-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:.5rem}
.palette-item{
  display:flex;flex-direction:column;align-items:center;gap:.35rem;
  padding:.6rem .4rem;border-radius:10px;cursor:pointer;
  border:2px solid transparent;transition:all .15s;background:var(--bg3);
}
.palette-item:hover{background:var(--sidebar-hover);border-color:var(--border2)}
.palette-item.active{border-color:var(--accent)}
.palette-swatch{display:flex;gap:3px;align-items:center}
.p-dot1{width:18px;height:18px;border-radius:50%}
.p-dot2{width:12px;height:12px;border-radius:50%;opacity:.85}
.palette-name{font-size:.67rem;font-weight:600;color:var(--muted);text-align:center;letter-spacing:.02em}

.palette-sep{height:1px;background:var(--border);margin:.8rem 0 .65rem}
.palette-panel-title2{font-size:.68rem;font-weight:700;color:var(--muted);letter-spacing:.07em;text-transform:uppercase;margin-bottom:.5rem}
.theme-row{display:flex;gap:.5rem}
.theme-btn{
  flex:1;padding:.5rem;border-radius:8px;border:2px solid var(--border);
  background:var(--bg3);cursor:pointer;font-size:.75rem;font-weight:600;
  color:var(--muted);font-family:inherit;transition:all .15s;
  display:flex;align-items:center;justify-content:center;gap:.35rem;
}
.theme-btn:hover{background:var(--sidebar-hover);border-color:var(--border2);color:var(--text)}
.theme-btn.active{border-color:var(--accent);color:var(--accent);background:var(--chip-bg)}

/* ── Layout ───────────────────────────────────────────────── */
.layout{display:flex;flex:1;overflow:hidden;height:calc(100vh - 52px)}

/* ── Sidebar ──────────────────────────────────────────────── */
.sidebar{
  width:220px;background:var(--sidebar);border-right:1px solid var(--border);
  display:flex;flex-direction:column;overflow-y:auto;flex-shrink:0;
}
.sidebar-search{
  position:sticky;top:0;z-index:3;background:var(--sidebar);
  padding:.7rem .75rem .55rem;border-bottom:1px solid var(--border);
}
.sidebar-search-input{
  width:100%;height:34px;border:1px solid var(--border);border-radius:8px;
  background:var(--bg3);color:var(--text);font:inherit;font-size:.78rem;
  padding:0 .75rem;outline:none;
}
.sidebar-search-input:focus{border-color:var(--accent);box-shadow:0 0 0 2px color-mix(in srgb, var(--accent) 18%, transparent)}
.sidebar-search-empty{padding:.85rem 1rem;color:var(--muted);font-size:.76rem}
.sidebar-group{border-bottom:1px solid var(--border)}
.sidebar-group.filtered-out{display:none}
.sidebar-group-toggle{
  width:100%;border:0;background:transparent;color:var(--muted);font:inherit;
  display:flex;align-items:center;gap:.55rem;padding:.7rem .85rem .55rem;
  cursor:pointer;text-align:left;
}
.sidebar-group-toggle:hover{background:var(--sidebar-hover);color:var(--text)}
.sidebar-group-chevron{
  width:.42rem;height:.42rem;border-right:2px solid currentColor;border-bottom:2px solid currentColor;
  transform:rotate(45deg);transition:transform .15s;flex-shrink:0;margin-top:-.12rem;
}
.sidebar-group.collapsed .sidebar-group-chevron{transform:rotate(-45deg);margin-top:0}
.sidebar-group-name{
  flex:1;font-size:.68rem;font-weight:800;letter-spacing:.08em;text-transform:uppercase;
  white-space:nowrap;overflow:hidden;text-overflow:ellipsis;
}
.sidebar-group-count{
  min-width:1.25rem;height:1.25rem;border-radius:999px;background:var(--chip-bg);
  color:var(--muted);display:flex;align-items:center;justify-content:center;
  font-size:.65rem;font-weight:800;
}
.sidebar-group-items{padding:.15rem 0 .45rem}
.sidebar-group.collapsed .sidebar-group-items{display:none}
.sidebar-section-label{
  padding:.75rem 1rem .35rem;font-size:.65rem;font-weight:700;color:var(--muted);
  letter-spacing:.08em;text-transform:uppercase;
}
.nav-item{
  width:100%;border:0;background:transparent;text-align:left;font-family:inherit;
  display:flex;align-items:center;gap:.65rem;padding:.55rem 1rem;
  cursor:pointer;transition:background .12s;border-left:3px solid transparent;
  font-size:.82rem;color:var(--text);font-weight:500;
}
.nav-item.filtered-out{display:none}
.nav-item:hover{background:var(--sidebar-hover)}
.nav-item.active{
  background:color-mix(in srgb, var(--accent) 15%, transparent);
  border-left-color:var(--accent);
  color:var(--accent-ll);font-weight:700;
}
[data-theme="light"] .nav-item.active{color:var(--accent)}
.nav-icon{
  width:26px;height:26px;border-radius:6px;
  display:flex;align-items:center;justify-content:center;flex-shrink:0;
  font-size:.85rem;background:var(--chip-bg);transition:background .12s;
}
.nav-item.active .nav-icon{background:color-mix(in srgb, var(--accent) 22%, transparent)}
.nav-label{flex:1;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.nav-divider{height:1px;background:var(--border);margin:.35rem .75rem}

/* ── Main ─────────────────────────────────────────────────── */
.main{flex:1;overflow-y:auto;display:flex;flex-direction:column}

/* ── Upload screen ────────────────────────────────────────── */
.upload-screen{
  flex:1;display:flex;align-items:center;justify-content:center;padding:2rem;
}
.upload-card{
  background:var(--card);border:1px solid var(--border);border-radius:20px;
  padding:3rem 2.5rem;max-width:480px;width:100%;text-align:center;
}
.upload-icon{
  width:72px;height:72px;border-radius:16px;
  background:color-mix(in srgb, var(--accent) 14%, transparent);
  display:flex;align-items:center;justify-content:center;margin:0 auto 1.5rem;
}
.upload-icon svg{width:36px;height:36px;color:var(--accent-ll)}
.upload-title{font-size:1.35rem;font-weight:700;color:var(--text-head);margin-bottom:.6rem}
.upload-sub{font-size:.88rem;color:var(--muted);line-height:1.6;margin-bottom:2rem}
.upload-format{
  display:grid;grid-template-columns:1fr 1fr;gap:.5rem;margin:-.8rem 0 1rem;
}
.upload-format-option{
  min-width:0;height:38px;border:1px solid var(--border2);border-radius:10px;
  background:var(--bg3);color:var(--muted);display:flex;align-items:center;justify-content:center;
  cursor:pointer;font-size:.78rem;font-weight:800;
}
.upload-format-option input{position:absolute;opacity:0;pointer-events:none}
.upload-format-option:has(input:checked){
  border-color:var(--accent);background:color-mix(in srgb, var(--accent) 12%, transparent);
  color:var(--accent-ll);
}
.drop-zone{
  border:2px dashed var(--border2);border-radius:14px;padding:2rem 1.5rem;
  cursor:pointer;transition:all .2s;position:relative;overflow:hidden;
  background:var(--bg3);
}
.drop-zone:hover,.drop-zone.drag{border-color:var(--accent);background:color-mix(in srgb, var(--accent) 6%, transparent)}
.drop-zone input{position:absolute;inset:0;opacity:0;cursor:pointer;width:100%;height:100%}
.dz-text{font-size:.88rem;color:var(--muted);margin-top:.5rem}
.dz-text strong{color:var(--text);display:block;font-size:.95rem;margin-bottom:.25rem}
.dz-ext{
  display:inline-block;margin-top:.6rem;
  background:color-mix(in srgb, var(--accent) 12%, transparent);
  color:var(--accent-ll);font-size:.7rem;font-weight:700;letter-spacing:.05em;
  padding:.15rem .5rem;border-radius:99px;
}
.upload-progress{display:none;margin-top:1.25rem}
.upload-progress.visible{display:block}
.prog-bar-wrap{height:6px;background:var(--border);border-radius:99px;overflow:hidden;margin-bottom:.5rem}
.prog-bar{height:100%;background:var(--accent);border-radius:99px;width:0;transition:width .3s}
.prog-text{font-size:.78rem;color:var(--muted)}
.upload-error{
  display:none;margin-top:1rem;padding:.75rem 1rem;border-radius:10px;
  background:var(--upload-err-bg);border:1px solid var(--upload-err-border);
  color:var(--upload-err-text);font-size:.84rem;line-height:1.5;
}
.upload-error.visible{display:block}

/* â”€â”€ Auth + Library â”€â”€ */
.auth-screen{
  min-height:calc(100vh - 52px);display:flex;align-items:center;justify-content:center;padding:2rem;
  background:
    radial-gradient(circle at top right, color-mix(in srgb, var(--accent) 18%, transparent), transparent 30%),
    radial-gradient(circle at bottom left, color-mix(in srgb, var(--accent2) 16%, transparent), transparent 28%);
}
.auth-card{
  width:100%;max-width:420px;background:var(--card);border:1px solid var(--border);
  border-radius:22px;padding:2rem 1.75rem;box-shadow:0 18px 48px rgba(0,0,0,.18);
}
.auth-title{font-size:1.4rem;font-weight:800;color:var(--text-head);margin-bottom:.45rem}
.auth-sub{font-size:.88rem;color:var(--muted);line-height:1.6;margin-bottom:1.35rem}
.auth-form{display:flex;flex-direction:column;gap:.95rem}
.auth-field{display:flex;flex-direction:column;gap:.35rem}
.auth-field label{font-size:.78rem;font-weight:700;color:var(--muted);letter-spacing:.03em}
.auth-field input{
  height:42px;border-radius:12px;border:1px solid var(--border2);background:var(--bg3);
  color:var(--text);padding:0 .85rem;font:inherit;outline:none;
}
.auth-field input:focus{border-color:var(--accent);box-shadow:0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent)}
.auth-submit{
  margin-top:.25rem;height:42px;border:none;border-radius:12px;cursor:pointer;
  background:linear-gradient(135deg, var(--accent), var(--accent-l));
  color:white;font:inherit;font-weight:800;letter-spacing:.02em;
}
.auth-submit:hover{filter:brightness(1.06)}
.auth-alt{
  margin-top:.15rem;height:40px;border-radius:12px;border:1px solid var(--border2);
  background:transparent;color:var(--text);font:inherit;font-weight:700;cursor:pointer;
}
.auth-alt:hover{background:var(--bg3);border-color:var(--accent)}
.auth-note{font-size:.78rem;color:var(--muted);line-height:1.6;margin-top:1rem}

.home-panel{
  width:100%;max-width:1200px;display:grid;
  grid-template-columns:minmax(320px,460px) minmax(320px,1fr);
  gap:1.25rem;align-items:start;
}
.library-card{
  background:var(--card);border:1px solid var(--border);border-radius:20px;
  padding:1.4rem;min-height:280px;display:flex;flex-direction:column;
}
.library-head{display:flex;align-items:flex-start;justify-content:space-between;gap:1rem;margin-bottom:1rem}
.library-actions{display:flex;align-items:center;justify-content:flex-end;gap:.5rem;flex-wrap:wrap}
.library-title{font-size:1.08rem;font-weight:800;color:var(--text-head)}
.library-sub{font-size:.8rem;color:var(--muted);margin-top:.25rem}
.btn-small{
  height:32px;padding:0 .8rem;border-radius:10px;border:1px solid var(--border);
  background:var(--chip-bg);cursor:pointer;color:var(--muted);font:inherit;
  font-size:.76rem;font-weight:700;
}
.btn-small:hover{background:var(--sidebar-hover);color:var(--text);border-color:var(--border2)}
.btn-small:disabled{opacity:.45;cursor:default;background:var(--chip-bg);color:var(--muted);border-color:var(--border)}
.reports-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(240px,1fr));gap:.9rem}
.report-card{
  background:var(--bg3);border:1px solid var(--border);border-radius:16px;
  padding:1rem;display:flex;flex-direction:column;gap:.75rem;min-height:168px;
}
.report-title{font-size:.95rem;font-weight:800;color:var(--text-head);line-height:1.35}
.report-meta{font-size:.78rem;color:var(--muted);line-height:1.55}
.report-actions{margin-top:auto;display:flex;gap:.5rem}
.report-actions button{flex:1}
.reports-empty{
  margin:auto 0;padding:1rem 0;text-align:center;font-size:.88rem;
  color:var(--muted);line-height:1.6;
}
.upload-check{
  margin-top:.8rem;display:flex;align-items:flex-start;gap:.55rem;
  font-size:.8rem;color:var(--text);line-height:1.4;cursor:pointer;
}
.upload-check input{
  margin-top:.12rem;accent-color:var(--accent);flex:0 0 auto;
}
.upload-check code{
  font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;
  background:color-mix(in srgb, var(--bg3) 75%, transparent);
  border:1px solid var(--border);border-radius:8px;padding:.08rem .35rem;font-size:.74rem;
}
.upload-check-note{
  margin-top:.35rem;font-size:.74rem;color:var(--muted);line-height:1.45;
}

.admin-screen{
  flex:1;padding:2rem;display:flex;flex-direction:column;justify-content:flex-start;align-items:center;gap:1.25rem;
}
.admin-layout{
  width:100%;max-width:1480px;display:grid;
  grid-template-columns:minmax(280px,340px) minmax(0,1fr);
  gap:1.25rem;align-items:start;
}
.admin-card{
  min-width:0;background:var(--card);border:1px solid var(--border);border-radius:20px;padding:1.35rem;
}
.admin-card-title{font-size:1.02rem;font-weight:800;color:var(--text-head)}
.admin-card-sub{font-size:.82rem;color:var(--muted);line-height:1.55;margin-top:.3rem}
.admin-form{display:flex;flex-direction:column;gap:.9rem;margin-top:1.15rem}
.admin-form .auth-field{gap:.35rem}
.admin-form select,
.admin-form input{
  height:42px;border-radius:12px;border:1px solid var(--border2);background:var(--bg3);
  color:var(--text);padding:0 .85rem;font:inherit;outline:none;
}
.admin-form select:focus,
.admin-form input:focus{border-color:var(--accent);box-shadow:0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent)}
.admin-form-actions{display:flex;gap:.6rem}
.admin-form-actions button{flex:1}
.admin-form-note{font-size:.76rem;color:var(--muted);line-height:1.5}
.admin-check-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(120px,1fr));gap:.55rem}
.admin-check-option{
  display:flex;align-items:center;gap:.55rem;min-height:42px;padding:.65rem .8rem;
  border:1px solid var(--border2);border-radius:12px;background:var(--bg3);cursor:pointer;
}
.admin-check-option:hover{border-color:var(--accent)}
.admin-check-option input{margin:0;accent-color:var(--accent);flex:0 0 auto}
.admin-check-option span{font-size:.82rem;color:var(--text);font-weight:600}
.admin-users-table-wrap{
  margin-top:1rem;border:1px solid var(--border);border-radius:16px;overflow:auto;background:var(--bg3);
}
.admin-users-table{
  width:100%;min-width:1080px;border-collapse:separate;border-spacing:0;font-size:.82rem;
}
.admin-users-table--users{
  min-width:0;table-layout:fixed;
}
.admin-users-table--users th:nth-child(1){width:16%}
.admin-users-table--users th:nth-child(2){width:13%}
.admin-users-table--users th:nth-child(3){width:11%}
.admin-users-table--users th:nth-child(4){width:9%}
.admin-users-table--users th:nth-child(5){width:13%}
.admin-users-table--users th:nth-child(6){width:13%}
.admin-users-table--users th:nth-child(7){width:25%}
.admin-users-table thead th{
  position:sticky;top:0;z-index:1;background:var(--card2);color:var(--muted);
  font-size:.69rem;letter-spacing:.05em;text-transform:uppercase;font-weight:800;
  padding:.85rem .9rem;text-align:left;border-bottom:1px solid var(--border);white-space:nowrap;
}
.admin-users-table tbody td{
  padding:.9rem;border-bottom:1px solid var(--border);vertical-align:top;color:var(--text);
}
.admin-users-table tbody tr:last-child td{border-bottom:none}
.admin-users-table tbody tr:hover td{background:var(--sidebar-hover)}
.admin-user-name{font-size:.9rem;font-weight:800;color:var(--text-head);line-height:1.35}
.admin-user-email{font-size:.78rem;color:var(--muted);overflow-wrap:anywhere;margin-top:.18rem}
.admin-user-badges{display:flex;gap:.35rem;flex-wrap:wrap}
.admin-badge{
  display:inline-flex;align-items:center;height:24px;padding:0 .6rem;border-radius:999px;
  border:1px solid var(--border);background:var(--chip-bg);font-size:.68rem;font-weight:700;
  letter-spacing:.03em;color:var(--muted);
}
.admin-badge.admin{color:var(--accent-ll);border-color:color-mix(in srgb, var(--accent) 32%, var(--border))}
.admin-badge.disabled{color:var(--accent2);border-color:color-mix(in srgb, var(--accent2) 42%, var(--border))}
.admin-user-meta-cell{font-size:.78rem;color:var(--muted);line-height:1.55}
.admin-user-actions{display:flex;flex-wrap:nowrap;gap:.35rem;min-width:0}
.admin-user-actions button{flex:1 1 0;min-width:58px;padding:0 .45rem;font-size:.72rem}
.profile-rules-wrap{
  width:100%;max-width:1480px;display:grid;
  grid-template-columns:minmax(280px,340px) minmax(0,1fr);
  gap:1.25rem;
}

/* ── Dashboard ────────────────────────────────────────────── */
.consolidated-screen{
  flex:1;padding:2rem;display:flex;flex-direction:column;justify-content:flex-start;align-items:center;
}
.report-builder-layout{
  width:100%;max-width:1780px;display:grid;
  grid-template-columns:minmax(310px,380px) minmax(0,1fr);
  gap:1.25rem;align-items:start;
}
.report-builder-panel,.report-builder-workspace{min-width:0}
.report-builder-panel{display:flex;flex-direction:column;gap:1rem;max-height:calc(100vh - 112px);overflow:auto}
.report-builder-panel-section{
  display:flex;flex-direction:column;gap:.8rem;padding-top:.95rem;border-top:1px solid var(--border);
}
.report-builder-panel-section:first-of-type{border-top:0;padding-top:.2rem}
.report-builder-section-head{display:flex;align-items:flex-start;justify-content:space-between;gap:.8rem}
.report-builder-section-title{font-size:.82rem;font-weight:800;color:var(--text-head)}
.report-builder-section-sub{font-size:.74rem;color:var(--muted);line-height:1.45;margin-top:.2rem}
.report-builder-control-grid{display:grid;grid-template-columns:1fr;gap:.65rem}
.report-builder-field{display:flex;flex-direction:column;gap:.35rem}
.report-builder-field span{
  font-size:.68rem;font-weight:800;color:var(--muted);text-transform:uppercase;letter-spacing:.04em;
}
.report-builder-field select,
.report-builder-chart-config select,
.report-builder-card-actions select{
  height:34px;border-radius:10px;border:1px solid var(--border2);background:var(--bg3);
  color:var(--text);padding:0 .65rem;font:inherit;font-size:.76rem;outline:none;
}
.report-builder-field select:focus,
.report-builder-chart-config select:focus,
.report-builder-card-actions select:focus{
  border-color:var(--accent);box-shadow:0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
.report-builder-chart-list{display:flex;flex-direction:column;gap:.9rem}
.report-builder-chart-group{display:flex;flex-direction:column;gap:.55rem}
.report-builder-chart-group-title{
  font-size:.68rem;font-weight:800;color:var(--muted);text-transform:uppercase;letter-spacing:.05em;
}
.report-builder-chart-option{
  display:grid;grid-template-columns:auto minmax(0,1fr);gap:.65rem;align-items:start;
  padding:.75rem;border:1px solid var(--border);border-radius:12px;background:var(--bg3);cursor:pointer;
}
.report-builder-chart-option:hover{border-color:var(--accent)}
.report-builder-chart-option input{margin-top:.15rem;accent-color:var(--accent)}
.report-builder-chart-main{min-width:0;display:flex;flex-direction:column;gap:.22rem}
.report-builder-chart-main strong{font-size:.82rem;color:var(--text-head);line-height:1.25}
.report-builder-chart-main small{font-size:.7rem;color:var(--muted);line-height:1.35}
.report-builder-chart-config{
  grid-column:2;display:grid;grid-template-columns:1fr 1fr;gap:.45rem;
}
.report-builder-workspace{display:flex;flex-direction:column;gap:1rem}
.report-builder-toolbar{align-items:flex-start}
.report-builder-title-edit{display:flex;flex-direction:column;gap:.35rem;min-width:260px;max-width:520px;flex:1}
.report-builder-title-edit label{
  font-size:.68rem;font-weight:800;color:var(--muted);text-transform:uppercase;letter-spacing:.04em;
}
.report-builder-title-edit input{
  width:100%;height:38px;border:1px solid var(--border2);border-radius:10px;background:var(--bg3);
  color:var(--text-head);padding:0 .75rem;font:inherit;font-size:1rem;font-weight:800;outline:none;
}
.report-builder-title-edit input:focus{
  border-color:var(--accent);box-shadow:0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
.report-builder-save-status{font-size:.72rem;color:var(--muted);min-height:1rem}
.report-builder-save-status[data-mode="saved"]{color:var(--accent)}
.report-builder-save-status[data-mode="dirty"]{color:var(--accent2)}
.report-builder-save-status[data-mode="error"]{color:var(--danger)}
.report-builder-save-status[data-mode="saving"]{color:var(--muted)}
.report-builder-actions{display:flex;align-items:center;gap:.55rem;flex-wrap:wrap;justify-content:flex-end}
.report-builder-print-btn{height:34px;margin-top:0;padding:0 .95rem;white-space:nowrap}
.report-builder-tabs{display:flex;gap:.45rem;flex-wrap:wrap}
.report-builder-tabs .btn-small.active{
  background:var(--accent);border-color:var(--accent);color:#fff;
}
.report-builder-pages{display:flex;flex-direction:column;gap:1.25rem}
.report-builder-page{
  min-height:760px;border:1px solid var(--border);border-radius:16px;background:var(--bg3);
  padding:1rem;box-shadow:0 12px 30px rgba(15,23,42,.05);
}
.report-builder-page.active{border-color:color-mix(in srgb, var(--accent) 42%, var(--border))}
.report-builder-page-head{
  display:flex;align-items:center;justify-content:space-between;gap:1rem;padding:.1rem .25rem .85rem;
}
.report-builder-page-title{font-size:.98rem;font-weight:800;color:var(--text-head)}
.report-builder-page-sub{font-size:.74rem;color:var(--muted);margin-top:.15rem}
.report-builder-grid{display:grid;grid-template-columns:repeat(12,minmax(0,1fr));gap:.85rem;align-items:start}
.report-builder-card{
  min-width:0;border:1px solid var(--border);border-radius:14px;background:var(--card);
  padding:.9rem;display:flex;flex-direction:column;gap:.75rem;
}
.report-builder-card[draggable="true"]{cursor:grab}
.report-builder-card[draggable="true"]:active{cursor:grabbing}
.report-builder-card-medium{grid-column:span 6}
.report-builder-card-large{grid-column:span 8}
.report-builder-card-full{grid-column:1 / -1}
.report-builder-card-head{display:flex;align-items:flex-start;justify-content:space-between;gap:.8rem}
.report-builder-card-title{font-size:.86rem;font-weight:800;color:var(--text-head);line-height:1.25}
.report-builder-card-sub{font-size:.7rem;color:var(--muted);line-height:1.35;margin-top:.12rem}
.report-builder-card-actions{display:flex;align-items:center;gap:.45rem;flex-wrap:wrap;justify-content:flex-end}
.report-builder-card-body{display:grid;grid-template-columns:1fr;gap:.7rem;min-height:310px}
.report-builder-card-body.multi{grid-template-columns:repeat(auto-fit,minmax(260px,1fr))}
.report-builder-plot-panel{min-width:0;display:flex;flex-direction:column;gap:.35rem}
.report-builder-plot-title{
  font-size:.72rem;font-weight:800;color:var(--muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;
}
.report-builder-plot{width:100%;min-height:285px}
.report-builder-card-full .report-builder-plot{min-height:360px}
.report-builder-kpi-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:.6rem}
.report-builder-kpi{
  min-width:0;border:1px solid var(--border);border-radius:10px;background:var(--bg3);padding:.65rem;
}
.report-builder-kpi span{display:block;font-size:.66rem;font-weight:800;color:var(--muted);text-transform:uppercase}
.report-builder-kpi strong{display:block;font-size:1.25rem;color:var(--text-head);line-height:1.2;margin-top:.25rem}
.report-builder-kpi small{display:block;font-size:.68rem;color:var(--muted);margin-top:.15rem}
.report-builder-modal{
  position:fixed;inset:0;z-index:220;display:flex;align-items:center;justify-content:center;
  padding:1.5rem;background:rgba(15,23,42,.46);backdrop-filter:blur(3px);
}
.report-builder-modal.hidden{display:none}
.report-builder-modal-card{
  width:min(820px,100%);max-height:min(760px,calc(100vh - 3rem));display:flex;flex-direction:column;
  border:1px solid var(--border);border-radius:16px;background:var(--card);box-shadow:0 24px 80px rgba(15,23,42,.24);
}
.report-builder-modal-head{
  display:flex;align-items:flex-start;justify-content:space-between;gap:1rem;
  padding:1rem 1.1rem;border-bottom:1px solid var(--border);
}
.report-builder-modal-title{font-size:1rem;font-weight:900;color:var(--text-head)}
.report-builder-modal-sub{font-size:.76rem;color:var(--muted);margin-top:.18rem}
.report-builder-modal-body{padding:1rem;overflow:auto;display:flex;flex-direction:column;gap:.75rem}
.report-builder-empty{
  border:1px dashed var(--border2);border-radius:12px;background:var(--bg3);
  color:var(--muted);font-size:.82rem;padding:1rem;text-align:center;
}
.report-builder-empty.error{color:var(--danger);border-color:color-mix(in srgb, var(--danger) 38%, var(--border))}
.report-builder-saved-item{
  display:flex;align-items:center;justify-content:space-between;gap:1rem;
  border:1px solid var(--border);border-radius:12px;background:var(--bg3);padding:.85rem;
}
.report-builder-saved-item.active{border-color:var(--accent);box-shadow:0 0 0 3px color-mix(in srgb, var(--accent) 14%, transparent)}
.report-builder-saved-title{font-size:.9rem;font-weight:850;color:var(--text-head);line-height:1.3}
.report-builder-saved-meta{font-size:.72rem;color:var(--muted);line-height:1.45;margin-top:.2rem}
.report-builder-saved-actions{display:flex;gap:.45rem;flex-wrap:wrap;justify-content:flex-end;flex:0 0 auto}
.consolidated-layout{
  width:100%;max-width:1680px;display:grid;
  grid-template-columns:minmax(280px,340px) minmax(0,1fr);
  gap:1.25rem;align-items:start;
}
.consolidated-actions{display:flex;gap:.6rem;margin-top:1rem}
.consolidated-actions .auth-submit{margin-top:0;flex:1}
.consolidated-report-list{display:flex;flex-direction:column;gap:.65rem;margin-top:1rem}
.consolidated-report-option{
  display:flex;align-items:flex-start;gap:.7rem;padding:.8rem;border:1px solid var(--border);
  border-radius:12px;background:var(--bg3);cursor:pointer;
}
.consolidated-report-option:hover{border-color:var(--accent)}
.consolidated-report-option input{margin-top:.2rem;accent-color:var(--accent);flex:0 0 auto}
.consolidated-report-option span{display:flex;flex-direction:column;gap:.25rem;min-width:0}
.consolidated-report-option strong{font-size:.86rem;color:var(--text-head);line-height:1.35}
.consolidated-report-option small{font-size:.74rem;color:var(--muted);line-height:1.4}
.consolidated-result{display:flex;flex-direction:column;gap:1rem}
.consolidated-kpis{display:grid;grid-template-columns:repeat(auto-fit,minmax(220px,1fr));gap:.85rem}
.consolidated-kpis .kpi-card{padding:.95rem 1rem;border-radius:12px}
.consolidated-kpis .kpi-value{font-size:1.45rem}
.comparative-sprint-card{gap:.55rem}
.comparative-card-grid{
  display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:.35rem .6rem;margin-top:.2rem;
}
.comparative-card-grid span{
  display:flex;justify-content:space-between;gap:.5rem;font-size:.74rem;color:var(--muted);
}
.comparative-card-grid strong{color:var(--text-head);font-weight:800}
.consolidated-section-title{font-size:.82rem;font-weight:800;color:var(--text-head);margin-bottom:.65rem}
.consolidated-charts{display:grid;grid-template-columns:1fr;gap:1rem}
.consolidated-chart-card{
  min-width:0;border:1px solid var(--border);border-radius:14px;background:var(--bg3);
  padding:1rem;display:flex;flex-direction:column;
}
.consolidated-chart-card-wide{grid-column:1 / -1}
.consolidated-plot{width:100%;height:380px;min-height:320px}
.consolidated-cfd-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:.8rem;height:auto}
.consolidated-cfd-panel{min-width:0}
.consolidated-cfd-title{
  font-size:.76rem;font-weight:800;color:var(--muted);margin-bottom:.35rem;
  white-space:nowrap;overflow:hidden;text-overflow:ellipsis;
}
.consolidated-cfd-panel .consolidated-plot{height:280px;min-height:240px}
.dashboard{display:none;flex:1;flex-direction:column}
.dashboard.visible{display:flex}
.chart-header{
  padding:1.25rem 1.5rem .75rem;border-bottom:1px solid var(--border);flex-shrink:0;
}
.chart-title-row{display:flex;align-items:center;gap:.75rem;margin-bottom:.75rem}
.chart-title{font-size:1.1rem;font-weight:700;color:var(--text-head)}
.chart-subtitle{font-size:.78rem;color:var(--muted);margin-top:.15rem}
.chart-toolbar{display:flex;align-items:center;justify-content:space-between;gap:.8rem;flex-wrap:wrap}
.chart-actions{display:flex;align-items:center;gap:.6rem;flex-wrap:wrap}
.chart-filters{display:flex;gap:.55rem;flex-wrap:wrap}
.chart-filter{
  display:flex;align-items:center;gap:.45rem;padding:.35rem .5rem .35rem .7rem;
  border:1px solid var(--border);border-radius:12px;background:var(--bg3);
}
.chart-filter--stacked{align-items:flex-start}
.chart-filter-body{display:flex;flex-direction:column;gap:.4rem}
.chart-filter label{font-size:.72rem;font-weight:700;color:var(--muted);letter-spacing:.04em}
.chart-filter select{
  height:34px;border-radius:10px;border:1px solid var(--border2);background:var(--card);
  color:var(--text);padding:0 .7rem;font:inherit;min-width:150px;outline:none;
}
.chart-filter select[multiple]{
  height:auto;min-height:112px;padding:.45rem .5rem;min-width:230px;
}
.chart-filter select:focus{border-color:var(--accent);box-shadow:0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent)}
.chart-filter-actions{display:flex;gap:.45rem;align-items:center;flex-wrap:wrap}
.chart-filter-hint{font-size:.68rem;color:var(--muted);max-width:280px;line-height:1.35}
.type-selector{display:flex;gap:.4rem;flex-wrap:wrap}
.type-chip{
  padding:.32rem .8rem;border-radius:99px;border:1px solid var(--border2);
  background:var(--chip-bg);color:var(--muted);font-size:.75rem;font-weight:600;
  cursor:pointer;transition:all .15s;font-family:inherit;letter-spacing:.02em;
  display:flex;align-items:center;gap:.35rem;
}
.type-chip:hover{border-color:var(--accent);color:var(--accent-ll)}
.type-chip.active{background:var(--accent);border-color:var(--accent);color:#fff}

/* ── Chart area ───────────────────────────────────────────── */
.chart-body{flex:1;padding:1.25rem 1.5rem;overflow-y:auto}
.chart-workspace{
  display:flex;
  gap:1rem;
  align-items:stretch;
}
.chart-workspace--with-sidebar{
  display:grid;
  grid-template-columns:minmax(260px,320px) minmax(0,1fr);
}
.chart-side-panel{
  min-width:0;
}
.chart-side-filter{
  width:100%;
  height:100%;
  padding:.9rem 1rem;
}
.chart-side-filter .chart-filter-body{
  width:100%;
}
.chart-side-filter .chart-filter-actions{
  justify-content:flex-start;
}
.chart-side-filter .chart-filter-hint{
  max-width:none;
}
.chart-side-filter select[multiple]{
  width:100%;
  min-width:0;
  max-width:100%;
}
.chart-plot-shell{display:flex;flex-direction:column;gap:.8rem;min-height:420px}
.chart-plot-wrap{width:100%;min-height:420px;flex:1}
.chart-footer{
  display:none;align-items:center;justify-content:space-between;gap:.8rem;flex-wrap:wrap;
  padding:.7rem .85rem;border:1px solid var(--border);border-radius:12px;background:var(--bg3);
}
.chart-footer.visible{display:flex}
.chart-footer-meta{display:flex;flex-direction:column;gap:.55rem;min-width:0}
.chart-footer-info{font-size:.78rem;color:var(--muted);font-weight:600}
.chart-footer-actions{display:flex;align-items:center;gap:.45rem;flex-wrap:wrap}
.chart-footer-legend{display:flex;align-items:center;gap:.45rem .65rem;flex-wrap:wrap}
.chart-legend-chip{
  display:inline-flex;align-items:center;gap:.42rem;
  padding:.28rem .55rem;border:1px solid var(--border);border-radius:999px;
  background:var(--card);font-size:.74rem;font-weight:700;color:var(--text);
}
.chart-legend-swatch{
  width:10px;height:10px;border-radius:50%;display:inline-block;flex:0 0 auto;
  box-shadow:0 0 0 1px color-mix(in srgb, var(--border2) 72%, transparent);
}
.chart-plot-shell:fullscreen{
  background:var(--card);padding:1rem;box-sizing:border-box;
}
.chart-plot-shell:fullscreen .chart-plot-wrap{min-height:0;height:calc(100vh - 130px)}
.chart-plot-shell:fullscreen .chart-footer{
  background:var(--card2);
}
#mainPlot{width:100%;height:100%;min-height:420px}

/* ── KPI Cards ────────────────────────────────────────────── */
.kpi-groups{display:flex;flex-direction:column;gap:.9rem;margin-bottom:1.35rem}
.kpi-section{
  display:grid;grid-template-columns:minmax(110px,140px) minmax(0,1fr);
  gap:1rem;align-items:start;padding:.9rem 0;border-top:1px solid var(--border);
}
.kpi-section:first-child{padding-top:0;border-top:0}
.kpi-section .kpi-grid{margin-bottom:0}
.kpi-section-head{
  color:var(--text-head);font-size:.76rem;font-weight:800;text-transform:uppercase;
  padding-top:.62rem;line-height:1.2;
}
.kpi-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(170px,1fr));gap:1rem;margin-bottom:1.5rem}
.kpi-card{
  background:var(--card);border:1px solid var(--border);border-radius:14px;
  padding:1.1rem 1.2rem;display:flex;flex-direction:column;gap:.3rem;position:relative;
}
.kpi-card-head{display:flex;align-items:flex-start;justify-content:space-between;gap:.65rem}
.kpi-label{font-size:.7rem;font-weight:700;color:var(--muted);letter-spacing:.05em;text-transform:uppercase}
.kpi-value{font-size:1.8rem;font-weight:800;color:var(--text-head);line-height:1.1}
.kpi-unit{font-size:.75rem;color:var(--muted)}
.kpi-sub{font-size:.72rem;color:var(--accent-ll);margin-top:.2rem}
.kpi-info{position:relative;display:inline-flex;flex:0 0 auto}
.kpi-info-trigger{
  width:18px;height:18px;border-radius:50%;border:1px solid var(--border);background:var(--bg3);
  color:var(--muted);font-size:.68rem;font-weight:800;line-height:1;cursor:help;
  display:inline-flex;align-items:center;justify-content:center;padding:0;
}
.kpi-info-trigger:hover,
.kpi-info-trigger:focus-visible{color:var(--text-head);border-color:var(--accent);outline:0}
.kpi-tooltip{
  position:absolute;z-index:30;left:calc(100% + 12px);top:0;width:330px;max-width:calc(100vw - 3rem);
  background:#006b66;color:#fff;border:1px solid rgba(255,255,255,.16);border-radius:6px;
  box-shadow:0 12px 30px rgba(0,0,0,.32);padding:.75rem .85rem;font-size:.76rem;line-height:1.35;
  opacity:0;visibility:hidden;transform:translateX(-4px);transition:opacity .14s ease,transform .14s ease,visibility .14s;
  pointer-events:none;text-transform:none;letter-spacing:0;font-weight:500;
}
.kpi-tooltip::before{
  content:"";position:absolute;left:-6px;top:16px;width:10px;height:10px;background:#006b66;
  transform:rotate(45deg);border-left:1px solid rgba(255,255,255,.16);border-bottom:1px solid rgba(255,255,255,.16);
}
.kpi-tooltip span{display:block}
.kpi-tooltip span + span{margin-top:.35rem}
.kpi-info:hover .kpi-tooltip,
.kpi-info:focus-within .kpi-tooltip{opacity:1;visibility:visible;transform:translateX(0)}
.metric-table-wrap{
  margin-top:.25rem;border:1px solid var(--border);border-radius:12px;overflow:hidden;background:var(--card);
}
.metric-table{width:100%;border-collapse:collapse;font-size:.82rem}
.metric-table th{
  background:var(--bg3);color:var(--muted);font-size:.68rem;letter-spacing:.06em;
  text-transform:uppercase;font-weight:800;text-align:left;padding:.65rem .85rem;
  border-bottom:1px solid var(--border);
}
.metric-table td{padding:.7rem .85rem;border-bottom:1px solid var(--border);color:var(--text)}
.metric-table tr:last-child td{border-bottom:0}
.metric-health{
  margin-top:.25rem;border:1px solid var(--border);border-radius:12px;background:var(--card);
  padding:1rem;display:flex;flex-direction:column;gap:.75rem;
}
.metric-health-title{font-size:.76rem;font-weight:800;color:var(--text-head);text-transform:uppercase}
.metric-health-row{
  display:grid;grid-template-columns:90px minmax(0,1fr) 58px;align-items:center;gap:.75rem;
  color:var(--muted);font-size:.78rem;
}
.metric-health-row strong{color:var(--text-head);text-align:right}
.metric-health-track{height:10px;border-radius:999px;background:var(--bg3);overflow:hidden}
.metric-health-track b{display:block;height:100%;border-radius:999px;background:var(--accent)}
.metric-health-track.work b{background:var(--accent2)}

/* ── Table ────────────────────────────────────────────────── */
.data-table-wrap{overflow-x:auto;border-radius:12px;border:1px solid var(--border)}
.data-table{width:100%;border-collapse:collapse;font-size:.84rem}
.data-table th{
  background:var(--bg3);color:var(--muted);font-size:.7rem;letter-spacing:.05em;
  text-transform:uppercase;font-weight:700;padding:.6rem 1rem;text-align:left;
  border-bottom:1px solid var(--border);white-space:nowrap;
}
.data-table td{padding:.55rem 1rem;border-bottom:1px solid var(--border);color:var(--text)}
.data-table tr:last-child td{border-bottom:none}
.data-table tr:hover td{background:var(--sidebar-hover)}
.td-num{text-align:right;font-variant-numeric:tabular-nums;font-weight:600}
.td-bar{min-width:100px}
.mini-bar-bg{height:8px;border-radius:99px;background:var(--border);overflow:hidden;margin-top:3px}
.mini-bar-fill{height:100%;border-radius:99px;background:var(--accent)}

/* ── Warn banner ──────────────────────────────────────────── */
.warn-banner{
  display:none;margin:0 1.5rem .75rem;padding:.65rem 1rem;border-radius:10px;
  background:color-mix(in srgb,var(--accent2) 12%,transparent);
  border:1px solid color-mix(in srgb,var(--accent2) 35%,transparent);
  font-size:.8rem;color:var(--accent2);
}
.warn-banner.visible{display:flex;align-items:flex-start;gap:.5rem}
.summary-card{
  display:none;margin:.85rem 1.5rem 0;padding:1rem 1.1rem;border-radius:14px;
  border:1px solid var(--border);background:var(--card);box-shadow:var(--shadow);
}
.summary-card.visible{display:block}
.summary-head{display:flex;align-items:flex-start;justify-content:space-between;gap:1rem}
.summary-title{font-size:.96rem;font-weight:800;color:var(--text-head)}
.summary-meta{font-size:.76rem;color:var(--muted);margin-top:.2rem}
.summary-body{margin-top:.85rem}
.summary-content{
  white-space:pre-wrap;font-size:.88rem;line-height:1.65;color:var(--text);
}
.summary-status{font-size:.82rem;color:var(--muted)}
.summary-actions{display:flex;gap:.5rem;flex-wrap:wrap}
.summary-error{margin-top:.8rem}

/* ── Spinner / Loading ────────────────────────────────────── */
.spinner{
  width:28px;height:28px;border:3px solid var(--border);
  border-top-color:var(--accent);border-radius:50%;
  animation:spin .75s linear infinite;margin:0 auto;
}
@keyframes spin{to{transform:rotate(360deg)}}
.loading-overlay{
  display:none;position:fixed;inset:0;background:rgba(18,22,31,.75);
  z-index:200;align-items:center;justify-content:center;flex-direction:column;gap:1rem;
}
[data-theme="light"] .loading-overlay{background:rgba(255,255,255,.8)}
.loading-overlay.visible{display:flex}
.loading-text{font-size:.88rem;color:var(--muted)}

/* ── Empty state ──────────────────────────────────────────── */
.empty-state{
  flex:1;display:flex;align-items:center;justify-content:center;
  flex-direction:column;gap:.75rem;padding:3rem;text-align:center;
}
.empty-state svg{opacity:.2;color:var(--muted)}
.empty-state p{font-size:.88rem;color:var(--muted)}

/* ── Scrollbar ─────────────────────────────────────────────── */
::-webkit-scrollbar{width:6px;height:6px}
::-webkit-scrollbar-track{background:transparent}
::-webkit-scrollbar-thumb{background:var(--border2);border-radius:99px}
::-webkit-scrollbar-thumb:hover{background:var(--muted)}

/* ══ RESPONSIVIDADE ══════════════════════════════════════════ */

/* ── Botão hambúrguer (só aparece em mobile) ─────────────── */
.menu-toggle{
  display:none;width:32px;height:32px;border:1px solid var(--border);border-radius:8px;
  background:var(--chip-bg);cursor:pointer;color:var(--muted);
  align-items:center;justify-content:center;transition:all .15s;flex-shrink:0;
}
.menu-toggle:hover{background:var(--sidebar-hover);color:var(--text);border-color:var(--border2)}

/* ── Overlay que fecha sidebar em mobile ─────────────────── */
.sidebar-overlay{
  display:none;position:fixed;inset:0;background:rgba(0,0,0,.45);z-index:90;
}
.sidebar-overlay.visible{display:block}

/* ── Tablet (≤ 900px): sidebar mais estreita ─────────────── */
@media(max-width:1280px){
  .admin-layout{grid-template-columns:minmax(260px,320px) minmax(0,1fr)}
  .profile-rules-wrap{grid-template-columns:minmax(260px,320px) minmax(0,1fr)}
  .admin-users-table{min-width:960px}
  .admin-users-table--users{min-width:0}
  .chart-workspace--with-sidebar{
    grid-template-columns:minmax(220px,280px) minmax(0,1fr);
  }
}

@media(max-width:1080px){
  .admin-screen,.consolidated-screen{padding:1.25rem}
  .admin-layout{grid-template-columns:1fr}
  .profile-rules-wrap{grid-template-columns:1fr}
  .report-builder-layout{grid-template-columns:1fr}
  .report-builder-panel{max-height:none}
  .consolidated-layout{grid-template-columns:1fr}
  .consolidated-charts{grid-template-columns:1fr}
  .consolidated-cfd-grid{grid-template-columns:1fr}
  .report-builder-card-medium,.report-builder-card-large{grid-column:1 / -1}
}

@media(max-width:900px){
  .sidebar{width:180px}
  .nav-label{font-size:.78rem}
  .app-name{font-size:.85rem}
  .chart-body{padding:.9rem 1rem}
  .chart-header{padding:1rem 1rem .65rem}
  .kpi-section{grid-template-columns:1fr;gap:.55rem;padding:.85rem 0}
  .kpi-section-head{padding-top:0}
  .kpi-grid{grid-template-columns:repeat(auto-fill,minmax(140px,1fr))}
  .kpi-tooltip{
    left:auto;right:0;top:calc(100% + 10px);transform:translateY(-4px);width:300px;
  }
  .kpi-tooltip::before{
    left:auto;right:9px;top:-6px;transform:rotate(45deg);
    border-left:1px solid rgba(255,255,255,.16);border-top:1px solid rgba(255,255,255,.16);
    border-bottom:0;
  }
  .kpi-info:hover .kpi-tooltip,
  .kpi-info:focus-within .kpi-tooltip{transform:translateY(0)}
  .home-panel{grid-template-columns:1fr}
  .chart-workspace--with-sidebar{
    grid-template-columns:1fr;
  }
}

/* ── Mobile (≤ 640px): sidebar off-canvas ───────────────── */
@media(max-width:640px){
  /* Topbar */
  .menu-toggle{display:flex}
  .app-name{font-size:.82rem}
  .sprint-badge{display:none !important}
  .btn-upload-new span{display:none}          /* esconde texto, mantém ícone */

  /* Sidebar vira drawer */
  .sidebar{
    position:fixed;top:52px;left:0;bottom:0;z-index:95;
    width:240px;transform:translateX(-100%);transition:transform .25s ease;
    box-shadow:4px 0 20px rgba(0,0,0,.25);
  }
  .sidebar.open{transform:translateX(0)}

  /* Layout: sem sidebar reservando espaço */
  .layout{height:calc(100vh - 52px)}

  /* Main ocupa tudo */
  .main{width:100%}

  .admin-screen,.consolidated-screen{padding:1rem}
  .report-builder-title-edit{min-width:0;max-width:none;width:100%}
  .report-builder-actions{justify-content:flex-start}
  .report-builder-card-head{flex-direction:column}
  .report-builder-card-actions{justify-content:flex-start}
  .report-builder-chart-config{grid-template-columns:1fr}
  .report-builder-saved-item{align-items:flex-start;flex-direction:column}
  .report-builder-saved-actions{justify-content:flex-start}

  /* Upload card menor */
  .upload-card{padding:2rem 1.25rem}
  .upload-title{font-size:1.1rem}

  /* Chart header */
  .chart-header{padding:.8rem .9rem .55rem}
  .chart-title{font-size:.95rem}
  .chart-body{padding:.75rem .9rem}
  .summary-card{margin:.75rem .9rem 0}
  .type-chip{padding:.28rem .6rem;font-size:.7rem}

  /* KPI cards: 2 colunas */
  .kpi-grid{grid-template-columns:repeat(2,1fr);gap:.65rem}
  .kpi-value{font-size:1.5rem}

  /* Palette panel: largura máxima da viewport */
  .palette-panel{width:calc(100vw - 2rem);left:1rem !important}
}

/* ── Extra-small (≤ 400px): ajustes finos ───────────────── */
@media print{
  @page{size:A4 landscape;margin:10mm}
  html,body{width:auto !important;height:auto !important;overflow:visible !important}
  body{background:#fff !important;color:#111;-webkit-print-color-adjust:exact;print-color-adjust:exact}
  .topbar,.sidebar,.report-builder-panel,.report-builder-toolbar,.report-builder-tabs,
  .report-builder-page-head,.report-builder-card-actions,.btn-upload-new,.summary-panel,
  .auth-screen,.upload-screen,.admin-screen,.dashboard,.report-builder-modal{display:none !important}
  .layout{display:block !important;height:auto !important;overflow:visible !important}
  .main{width:100% !important;height:auto !important;overflow:visible !important;background:#fff !important}
  .consolidated-screen{display:block !important;padding:0 !important;background:#fff !important;overflow:visible !important}
  .report-builder-layout{display:block !important;width:100% !important;max-width:none !important}
  .report-builder-workspace{display:block !important;border:0 !important;padding:0 !important;background:#fff !important;overflow:visible !important}
  .report-builder-pages{display:block !important}
  .report-builder-page{
    display:block !important;width:100% !important;min-height:0 !important;overflow:visible !important;
    padding:0 !important;margin:0 0 10mm !important;border:0 !important;border-radius:0 !important;
    box-shadow:none !important;background:#fff !important;page-break-after:always;break-after:page;
  }
  .report-builder-page:last-child{page-break-after:auto;break-after:auto}
  .report-builder-grid{display:block !important}
  .report-builder-card{
    display:block !important;width:100% !important;margin:0 0 7mm !important;
    page-break-inside:avoid;break-inside:avoid-page;overflow:visible !important;
    border:1px solid #d5dde8 !important;border-radius:8px !important;
    box-shadow:none !important;background:#fff !important;padding:5mm !important;
  }
  .report-builder-card-medium,.report-builder-card-large,.report-builder-card-full{grid-column:auto !important}
  .report-builder-card-head{break-after:avoid;page-break-after:avoid;margin-bottom:3mm}
  .report-builder-card-body{display:grid !important;grid-template-columns:1fr !important;gap:4mm !important;min-height:0 !important;overflow:visible !important}
  .report-builder-card-body.multi{grid-template-columns:repeat(auto-fit,minmax(78mm,1fr)) !important}
  .report-builder-plot-panel{break-inside:avoid;page-break-inside:avoid;overflow:visible !important}
  .report-builder-card-title{color:#111 !important}
  .report-builder-card-sub,.report-builder-plot-title{color:#526173 !important}
  .report-builder-plot{height:68mm !important;min-height:68mm !important;overflow:visible !important}
  .report-builder-card-full .report-builder-plot{height:78mm !important;min-height:78mm !important}
  .report-builder-card-body.multi .report-builder-plot{height:62mm !important;min-height:62mm !important}
  .report-builder-kpi-grid{grid-template-columns:repeat(3,minmax(0,1fr)) !important}
}

@media(max-width:400px){
  .topbar{padding:0 .75rem;gap:.5rem}
  .topbar-user{max-width:150px}
  .kpi-grid{grid-template-columns:1fr 1fr}
  .type-selector{gap:.25rem}
  .type-chip{padding:.25rem .5rem;font-size:.68rem}
}
