/* /home/segundo/api_infra/painel.css
   Painel Infra • Aiyra Cloud
   Baseado no design system do tenant (plataforma.css) — tokens neutros + KISS
*/

:root{
  --bg:#ffffff;
  --surface:#ffffff;
  --ink:#111111;
  --muted:#6b6b6b;
  --line:#e5e5e5;

  --hover:#f3f3f3;
  --active:#eeeeee;
  --focus-ring:rgba(17,17,17,.25);

  --radius:12px;
  --radius-sm:10px;
  --shadow:0 6px 14px rgba(0,0,0,.12);

  --ok:#065f46;
  --ok-bg:#ecfdf5;
  --ok-br:#a7f3d0;

  --warn:#92400e;
  --warn-bg:#fffbeb;
  --warn-br:#fcd34d;

  --err:#7f1d1d;
  --err-bg:#fef2f2;
  --err-br:#fecaca;
}

*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  font:14px/1.45 ui-sans-serif,system-ui,-apple-system,Segoe UI,Roboto,Inter,Arial,sans-serif;
  color:var(--ink);
  background:var(--bg);
  -webkit-font-smoothing:antialiased;
  -moz-osx-font-smoothing:grayscale;
}

a{color:inherit;text-decoration:none}
a:hover{text-decoration:underline}
a.btn, a.btn-outline, a.btn-ghost, a.btn-danger, a.chip{ text-decoration:none }
a.btn:hover, a.btn-outline:hover, a.btn-ghost:hover, a.btn-danger:hover, a.chip:hover{ text-decoration:none }

.muted{color:var(--muted)}
.small{font-size:12px;color:var(--muted)}
.mono{font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace}

.topbar{
  position:sticky;
  top:0;
  z-index:40;
  min-height:56px;
  height:auto;
  display:grid;
  grid-template-columns:auto 1fr;
  align-items:center;
  gap:12px;
  padding:10px 16px;
  background:var(--surface);
  border-bottom:1px solid var(--line);
}

.title{
  font-size:16px;
  font-weight:800;
  letter-spacing:.2px;
}

.container{
  padding:16px;
}

.panel{
  background:var(--surface);
  border:1px solid var(--line);
  border-radius:var(--radius);
  box-shadow:var(--shadow);
  padding:12px;
}

.row{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  flex-wrap:wrap;
}

.tools{
  display:flex;
  align-items:center;
  justify-content:flex-end;
  gap:10px;
  flex-wrap:wrap;
  min-width:0;
}

.input{
  flex:1 1 320px;
  width:auto;
  max-width:none;
  min-width:240px;
  padding:10px 12px;
  border:1px solid var(--line);
  border-radius:var(--radius-sm);
  background:var(--surface);
  color:var(--ink);
}

.input:focus{
  outline:none;
  border-color:#cfcfcf;
  box-shadow:0 0 0 3px var(--focus-ring);
}

.chips{
  display:flex;
  gap:6px;
  flex-wrap:wrap;
}

.chip{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  padding:8px 10px;
  border:1px solid var(--line);
  border-radius:999px;
  background:var(--surface);
  color:var(--ink);
  cursor:pointer;
  user-select:none;
}

.chip:hover{ background:var(--hover) }
.chip.active{
  border-color:#cfcfcf;
  box-shadow:0 0 0 3px var(--focus-ring);
}

.badges{ display:flex; gap:8px; flex-wrap:wrap }
.badge{
  display:inline-block;
  padding:4px 10px;
  border-radius:999px;
  border:1px solid var(--line);
  background:var(--surface);
  font-weight:700;
  font-size:12px;
  color:var(--ink);
}
.badge.ok{ background:var(--ok-bg); border-color:var(--ok-br); color:var(--ok) }
.badge.warn{ background:var(--warn-bg); border-color:var(--warn-br); color:var(--warn) }
.badge.err{ background:var(--err-bg); border-color:var(--err-br); color:var(--err) }

.btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:8px;
  padding:10px 14px;
  border-radius:var(--radius-sm);
  background:#111;
  color:#fff;
  font-weight:700;
  cursor:pointer;
  border:1px solid #111;
  box-shadow:0 2px 0 rgba(0,0,0,.08);
}
.btn:hover{ filter:brightness(.96) }
.btn:active{ transform:translateY(1px) scale(.99) }
.btn:focus-visible{ outline:none; box-shadow:0 0 0 3px var(--focus-ring) }

.btn-outline{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:8px;
  padding:10px 14px;
  border-radius:var(--radius-sm);
  background:transparent;
  color:#111;
  font-weight:700;
  cursor:pointer;
  border:1px solid var(--line);
}
.btn-outline:hover{ background:var(--hover) }
.btn-outline:active{ transform:translateY(1px) scale(.99) }
.btn-outline:focus-visible{ outline:none; box-shadow:0 0 0 3px var(--focus-ring) }

.btn-ghost{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:8px;
  padding:8px 10px;
  border-radius:var(--radius-sm);
  border:1px solid var(--line);
  background:transparent;
  color:var(--ink);
  cursor:pointer;
}
.btn-ghost:hover{ background:var(--hover) }
.btn-ghost:focus-visible{ outline:none; box-shadow:0 0 0 3px var(--focus-ring) }

.btn-danger{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:8px;
  padding:10px 14px;
  border-radius:var(--radius-sm);
  background:#222;
  color:#fff;
  font-weight:800;
  cursor:pointer;
  border:1px solid #222;
}
.btn-danger:hover{ filter:brightness(.95) }
.btn-danger:active{ transform:translateY(1px) scale(.99) }
.btn-danger:focus-visible{ outline:none; box-shadow:0 0 0 3px var(--focus-ring) }

.table-wrap{
  margin-top:12px;
  overflow:auto;
  border-radius:var(--radius);
  border:1px solid var(--line);
  box-shadow:var(--shadow);
}

table{
  width:100%;
  border-collapse:separate;
  border-spacing:0;
  background:var(--surface);
}

thead th{
  position:sticky;
  top:0;
  z-index:2;
  background:var(--surface);
  border-bottom:1px solid var(--line);
  padding:12px 10px;
  text-align:left;
  font-weight:800;
  white-space:nowrap;
}

tbody td{
  padding:10px;
  border-top:1px solid var(--line);
  vertical-align:middle;
}

tbody tr:nth-child(2n){ background:#fafafa }
tbody tr:hover{ background:var(--hover) }

tbody tr.late{
  background: transparent;
}
tbody tr.late:hover{
  background: var(--hover);
}

.actions{
  display:flex;
  gap:6px;
  flex-wrap:wrap;
  align-items:center;
}

.more{
  display:inline-block;
}
.more summary{
  list-style:none;
  cursor:pointer;
}
.more summary::-webkit-details-marker{ display:none }
.more .menu{
  margin-top:6px;
  display:flex;
  flex-wrap:wrap;
  gap:6px;
}

.notice{
  padding:10px 12px;
  border-radius:10px;
  border:1px solid var(--line);
  background:#f7f7f7;
  margin-top:12px;
}

@media (max-width:980px){
  .topbar{
    grid-template-columns:1fr;
    align-items:start;
  }
  .topbar .title{
    width:100%;
  }
  .hide-sm{ display:none }
  .input{ min-width:220px }
}

.chips{
  flex:0 1 auto;
  max-width:100%;
}

@media (max-width:980px){
  .tools{
    justify-content:flex-start;
  }
  .input{
    flex:1 1 100%;
    min-width:220px;
  }
}

/* ─────────────────────────────────────────────────────────────
   UX padrão de "processando" (botões / ações com DB)
   • Reutilizável no painel, parceiros e demais páginas Infra.
   • Não depende de HTMX (mas é compatível).
   ───────────────────────────────────────────────────────────── */

.btn[disabled],
.btn-outline[disabled],
.btn-ghost[disabled],
.btn-danger[disabled],
button.btn[disabled],
button.btn-outline[disabled],
button.btn-ghost[disabled],
button.btn-danger[disabled]{
  opacity:.65;
  cursor:not-allowed;
  transform:none !important;
  filter:none !important;
}

.btn-spinner{
  display:none;
  width:14px;
  height:14px;
  border-radius:50%;
  border:2px solid rgba(255,255,255,.35);
  border-top-color:#fff;
  animation: aiy-spin .8s linear infinite;
}

.btn-outline .btn-spinner,
.btn-ghost .btn-spinner{
  border:2px solid rgba(17,17,17,.25);
  border-top-color:#111;
}

.is-loading .btn-spinner{
  display:inline-block;
}

@keyframes aiy-spin{
  to { transform: rotate(360deg); }
}

/* Notices semânticos (úteis no portal parceiros) */
.notice-ok{
  background:var(--ok-bg);
  border-color:var(--ok-br);
  color:var(--ok);
}
.notice-warn{
  background:var(--warn-bg);
  border-color:var(--warn-br);
  color:var(--warn);
}
.notice-err{
  background:var(--err-bg);
  border-color:var(--err-br);
  color:var(--err);
}

/* ─────────────────────────────────────────────────────────────
   Portal Parceiros — helpers de layout (KISS)
   • Mantém unicidade visual com o /painel
   • Reduz CSS por página
   ───────────────────────────────────────────────────────────── */

.page{ max-width:1200px; margin:0 auto; }
.page-md{ max-width:980px; margin:0 auto; }
.page-sm{ max-width:720px; margin:0 auto; }
.page-xs{ max-width:520px; margin:0 auto; }

.stack{ display:flex; flex-direction:column; gap:12px; }

.card{
  border:1px solid var(--line);
  border-radius:var(--radius);
  background:var(--surface);
  padding:12px;
  box-shadow:var(--shadow);
}
.card.soft{ box-shadow:none; }

.grid-2{ display:grid; grid-template-columns:1fr 1fr; gap:12px; }
@media (max-width:980px){ .grid-2{ grid-template-columns:1fr; } }

.grid-3{ display:grid; grid-template-columns:repeat(3,1fr); gap:12px; }
@media (max-width:1100px){ .grid-3{ grid-template-columns:1fr 1fr; } }
@media (max-width:720px){ .grid-3{ grid-template-columns:1fr; } }

.grid-4{ display:grid; grid-template-columns:repeat(4,1fr); gap:12px; }
@media (max-width:1100px){ .grid-4{ grid-template-columns:1fr 1fr; } }
@media (max-width:720px){ .grid-4{ grid-template-columns:1fr; } }

.hero{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:12px;
  flex-wrap:wrap;
}
.hero h1{ margin:0; font-size:18px; font-weight:900; letter-spacing:.2px; }
.hero p{ margin:4px 0 0; color:var(--muted); max-width:62ch; }
.hero .right{ display:flex; gap:8px; flex-wrap:wrap; align-items:center; justify-content:flex-end; }

.section-title{
  display:flex;
  align-items:flex-end;
  justify-content:space-between;
  gap:10px;
  flex-wrap:wrap;
  margin-top:14px;
}
.section-title h2{ margin:0; font-size:16px; }
.section-title .muted{ font-size:12px; color:var(--muted); }

.field label{ display:block; font-weight:800; margin:10px 0 6px; }
.help{ margin-top:6px; }

.navtabs{
  display:flex;
  gap:6px;
  flex-wrap:wrap;
  align-items:center;
}
.navtabs a{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  padding:8px 10px;
  border:1px solid var(--line);
  border-radius:999px;
  background:var(--surface);
  color:var(--ink);
  font-weight:800;
}
.navtabs a:hover{ background:var(--hover) }
.navtabs a.active{
  border-color:#cfcfcf;
  box-shadow:0 0 0 3px var(--focus-ring);
}

.kpi{
  border:1px solid var(--line);
  border-radius:var(--radius);
  background:var(--surface);
  padding:12px;
  box-shadow:var(--shadow);
}
.kpi .label{ font-size:12px; color:var(--muted); font-weight:900; letter-spacing:.2px; }
.kpi .value{ font-size:22px; font-weight:950; margin-top:6px; }
.kpi .sub{ margin-top:6px; font-size:12px; color:var(--muted); }
.kpi .sub b{ color:var(--ink); }

.kv{ display:flex; justify-content:space-between; gap:10px; padding:4px 0; flex-wrap:wrap; }
.kv .k{ color:var(--muted); font-size:12px; font-weight:900; }
.kv .v{ font-weight:950; }

.center-stage{
  min-height: calc(100vh - 56px - 32px);
  display:grid;
  place-items:center;
}

/* ─────────────────────────────────────────────────────────────
   Form actions (padrão) — usado no Portal de Parceiros
   ───────────────────────────────────────────────────────────── */
.form-actions{
  display:flex;
  align-items:center;
  gap:10px;
  flex-wrap:wrap;
  margin-top:12px;
}
.form-actions .grow{
  flex:1 1 auto;
}
.form-actions .right{
  margin-left:auto;
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  align-items:center;
}

/* ─────────────────────────────────────────────────────────────
   Modal/Popup canônico (Infra) — elegante, centralizado e KISS
   • Usado no Portal de Parceiros e outras páginas Infra.
   ───────────────────────────────────────────────────────────── */
.pop-wrap{
  position:fixed;
  inset:0;
  z-index:9999;
  display:none;
  align-items:center;
  justify-content:center;
  padding:16px;
}
.pop-wrap.open{
  display:flex;
}
.pop-backdrop{
  position:absolute;
  inset:0;
  background:rgba(0,0,0,.38);
}
.pop-card{
  position:relative;
  width:100%;
  max-width:560px;
  background:var(--surface);
  border:1px solid var(--line);
  border-radius:var(--radius);
  box-shadow:var(--shadow);
  padding:14px;
}
.pop-head{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:12px;
  flex-wrap:wrap;
}
.pop-title{
  font-size:16px;
  font-weight:950;
  margin:0;
}
.pop-sub{
  margin-top:4px;
  color:var(--muted);
  font-size:12px;
}
.pop-actions{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
  align-items:center;
  margin-top:12px;
}
body.modal-open{
  overflow:hidden;
}

/* Botão “X” discreto */
.btn-x{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  padding:8px 10px;
  border-radius:10px;
  border:1px solid var(--line);
  background:transparent;
  cursor:pointer;
  font-weight:900;
}
.btn-x:hover{ background:var(--hover); }
.btn-x:focus-visible{ outline:none; box-shadow:0 0 0 3px var(--focus-ring); }

@media (max-width:520px){
  .pop-card{ padding:12px; }
}

/* ─────────────────────────────────────────────────────────────
   Toast / Banner (sucesso/erro/aviso) — padrão Infra
   • Usado para feedback de ações do painel sem querystring "ok/msg".
   • O backend seta um cookie curto (AIYRA_FLASH) e o painel.js consome.
   ───────────────────────────────────────────────────────────── */

.toast-wrap{
  position:fixed;
  top:72px;                 /* abaixo da topbar */
  left:50%;
  transform:translateX(-50%);
  z-index:9999;
  width:min(720px, calc(100vw - 24px));
  display:flex;
  flex-direction:column;
  gap:10px;
  pointer-events:none;
}

.toast{
  pointer-events:auto;
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:10px;
  padding:12px 12px;
  border-radius:12px;
  border:1px solid var(--line);
  background:var(--surface);
  box-shadow:var(--shadow);
  animation: aiy-toast-in .16s ease-out;
}

.toast .left{
  display:flex;
  gap:10px;
  align-items:flex-start;
}

.toast .icon{
  width:22px;
  height:22px;
  border-radius:999px;
  display:grid;
  place-items:center;
  border:1px solid var(--line);
  background:#fff;
  font-weight:950;
  font-size:12px;
  flex:0 0 auto;
}

.toast .msg{
  min-width:0;
}

.toast .title{
  font-weight:950;
  letter-spacing:.2px;
  margin:0;
  font-size:13px;
}

.toast .text{
  margin:4px 0 0 0;
  font-size:12px;
  color:var(--muted);
  white-space:pre-wrap;
  word-break:break-word;
}

.toast .close{
  border:1px solid var(--line);
  background:transparent;
  color:var(--ink);
  border-radius:10px;
  padding:6px 10px;
  cursor:pointer;
  font-weight:900;
}
.toast .close:hover{ background:var(--hover); }
.toast .close:focus-visible{ outline:none; box-shadow:0 0 0 3px var(--focus-ring); }

.toast.ok{
  border-color:var(--ok-br);
  background:var(--ok-bg);
  color:var(--ok);
}
.toast.ok .text{ color:color-mix(in oklab, var(--ok) 70%, var(--muted)); }
.toast.ok .icon{ border-color:var(--ok-br); background:#fff; color:var(--ok); }

.toast.err{
  border-color:var(--err-br);
  background:var(--err-bg);
  color:var(--err);
}
.toast.err .text{ color:color-mix(in oklab, var(--err) 70%, var(--muted)); }
.toast.err .icon{ border-color:var(--err-br); background:#fff; color:var(--err); }

.toast.warn{
  border-color:var(--warn-br);
  background:var(--warn-bg);
  color:var(--warn);
}
.toast.warn .text{ color:color-mix(in oklab, var(--warn) 70%, var(--muted)); }
.toast.warn .icon{ border-color:var(--warn-br); background:#fff; color:var(--warn); }

@keyframes aiy-toast-in{
  from{ transform:translateY(-6px); opacity:.2; }
  to{ transform:translateY(0); opacity:1; }
}
