/* =============================================================================
   Tema visual estilo JIRA / Atlassian Design System (light)
   Apenas a casca visual — todos os IDs/classes consumidos pelo app.js
   foram preservados (.tab, .tab-panel, .badge.*, .card*, .grid, .input, .btn*,
   .seg*, .run-indicator, .modal, .toast, .kv, .timeline, etc.).
   ========================================================================== */
:root {
  /* Superfícies */
  --nav: #0747A6;          /* top bar (azul-marinho Atlassian) */
  --nav-2: #0052CC;
  --page: #F4F5F7;         /* fundo da página */
  --surface: #FFFFFF;      /* cartões, tabelas, painéis */
  --surface-2: #FAFBFC;    /* sidebar, cabeçalho de tabela */
  --surface-hover: #F4F5F7;

  /* Linhas / texto */
  --border: #DFE1E6;
  --border-2: #EBECF0;
  --text: #172B4D;         /* N800 — texto principal (navy) */
  --muted: #5E6C84;        /* N200 */
  --subtle: #6B778C;       /* N100 */

  /* Marca / interação */
  --primary: #0052CC;
  --primary-h: #0065FF;
  --primary-a: #0747A6;
  --link: #0052CC;

  /* Estados (lozenges Atlassian) */
  --ok-bg: #E3FCEF;   --ok-fg: #006644;
  --info-bg: #DEEBFF; --info-fg: #0747A6;
  --warn-bg: #FFF0B3; --warn-fg: #974F0C;
  --danger-bg: #FFEBE6; --danger-fg: #BF2600;
  --gray-bg: #DFE1E6; --gray-fg: #42526E;

  --ok: #00875A;
  --warn: #FF8B00;
  --danger: #DE350B;

  --radius: 3px;
  --radius-lg: 6px;
  --shadow: 0 4px 8px -2px rgba(9,30,66,.25), 0 0 1px rgba(9,30,66,.31);
  --shadow-card: 0 1px 1px rgba(9,30,66,.20), 0 0 1px rgba(9,30,66,.13);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--page);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.4;
}

/* ===================== App shell ===================== */
.app-shell { display: flex; flex-direction: column; min-height: 100vh; }
.app-body { display: flex; flex: 1; min-height: 0; }

/* ===================== Top bar ===================== */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  min-height: 56px; padding: 8px 16px;
  flex-wrap: wrap; row-gap: 8px; column-gap: 12px;
  background: var(--nav);
  color: #fff;
  position: sticky; top: 0; z-index: 30;
  box-shadow: 0 1px 0 rgba(9,30,66,.25);
}
.brand { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.logo {
  font-size: 18px; color: #fff; background: rgba(255,255,255,.18);
  width: 32px; height: 32px; border-radius: var(--radius);
  display: grid; place-items: center;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.topbar h1 { font-size: 16px; margin: 0; font-weight: 600; color: #fff; }
.brand-sub { font-size: 11px; color: rgba(255,255,255,.72); margin-top: 2px; }
.actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.actions .btn { white-space: nowrap; }

/* Indicador de execução (lozenge na top bar) */
.run-indicator {
  font-size: 12px; padding: 4px 10px; border-radius: 999px;
  background: rgba(255,255,255,.16); color: #fff; font-weight: 500;
}
.run-indicator.idle { color: rgba(255,255,255,.8); }
.run-indicator.running { background: var(--warn-bg); color: var(--warn-fg); animation: pulse 1.2s infinite; }
.run-indicator.ok { background: var(--ok-bg); color: var(--ok-fg); }
.run-indicator.err { background: var(--danger-bg); color: var(--danger-fg); }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .5; } }

/* ===================== Sidebar ===================== */
.sidebar {
  width: 240px; flex-shrink: 0;
  background: var(--surface-2);
  border-right: 1px solid var(--border);
  padding: 16px 12px;
  position: sticky; top: 56px; align-self: flex-start;
  height: calc(100vh - 56px); overflow-y: auto;
}
.project-head { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; }
.project-avatar {
  width: 36px; height: 36px; border-radius: var(--radius);
  background: linear-gradient(135deg, #0052CC, #2684FF);
  color: #fff; font-weight: 700; font-size: 13px;
  display: grid; place-items: center; flex-shrink: 0;
}
.project-meta { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.project-meta strong { font-size: 14px; color: var(--text); }
.project-meta span { font-size: 12px; color: var(--subtle); }

/* Nav (tabs verticais) */
.tabs { display: flex; flex-direction: column; gap: 2px; }
.tab {
  display: flex; align-items: center; gap: 10px;
  background: none; border: none; color: var(--muted);
  padding: 8px 10px; cursor: pointer; font-size: 14px;
  border-radius: var(--radius); text-align: left; width: 100%;
  border-left: 3px solid transparent;
}
.tab:hover { background: var(--border-2); color: var(--text); }
.tab.active {
  background: var(--info-bg); color: var(--primary-a);
  font-weight: 600; border-left-color: var(--primary);
}
.nav-ico { font-size: 14px; width: 18px; text-align: center; opacity: .9; }

/* ===================== Main ===================== */
main { flex: 1; min-width: 0; padding: 20px 24px 60px; }

/* Cartões de estatística (faixa superior tipo "version header") */
.cards { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 20px; }
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 14px 16px; box-shadow: var(--shadow-card);
}
.card-label { color: var(--subtle); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.card-value { font-size: 26px; font-weight: 600; margin-top: 6px; color: var(--text); }
.card-value.sm { font-size: 14px; font-weight: 500; color: var(--muted); }
.card-value.ok { color: var(--ok); }
.card-value.warn { color: var(--warn); }

/* Painel de conteúdo */
.tab-panel { display: none; }
.tab-panel.active { display: block; }
.panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-card);
  overflow: hidden;
}
.panel-head { padding: 16px 20px 0; }
.panel-head h2 { margin: 0; font-size: 20px; font-weight: 600; color: var(--text); letter-spacing: -.01em; }

/* ===================== Botões ===================== */
.btn {
  background: rgba(255,255,255,.18); color: #fff;
  border: none; padding: 7px 12px; border-radius: var(--radius);
  cursor: pointer; font-size: 13px; font-weight: 500; transition: background .12s;
}
.btn:hover { background: rgba(255,255,255,.30); }
.btn-primary { background: #fff; color: var(--primary-a); font-weight: 600; }
.btn-primary:hover { background: #F4F5F7; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-icon-only { padding: 7px 10px; }
.btn-danger { background: rgba(255,255,255,.10); color: #FFBDAD; }
.btn-danger:hover { background: var(--danger); color: #fff; }

/* Botões dentro do conteúdo claro (toolbar, ações da linha) */
.toolbar .btn, .grid .btn {
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border);
}
.toolbar .btn:hover, .grid .btn:hover { background: var(--border-2); }
.toolbar .btn-primary, .grid .btn-primary {
  background: var(--primary); color: #fff; border-color: var(--primary);
}
.toolbar .btn-primary:hover, .grid .btn-primary:hover { background: var(--primary-h); border-color: var(--primary-h); }
.toolbar .btn-danger, .grid .btn-danger {
  background: var(--surface-2); color: var(--danger); border-color: var(--border);
}
.toolbar .btn-danger:hover, .grid .btn-danger:hover { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-sm { padding: 4px 10px; font-size: 12px; }

.btn-icon { background: none; border: none; color: var(--subtle); font-size: 18px; cursor: pointer; line-height: 1; }
.btn-icon:hover { color: var(--text); }

/* ===================== Toolbar / inputs ===================== */
.toolbar { display: flex; align-items: center; gap: 10px; padding: 16px 20px; flex-wrap: wrap; }
.input {
  background: var(--surface-2); border: 2px solid var(--border); color: var(--text);
  padding: 6px 10px; border-radius: var(--radius); font-size: 13px; min-width: 260px;
  transition: border-color .12s, background .12s;
}
.input:focus { outline: none; border-color: var(--primary); background: #fff; }
.input.sm { min-width: 160px; }
.check { color: var(--muted); font-size: 13px; display: flex; align-items: center; gap: 6px; cursor: pointer; }

.seg { display: flex; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.seg-btn { background: var(--surface); border: none; color: var(--muted); padding: 7px 14px; cursor: pointer; font-size: 13px; font-weight: 500; }
.seg-btn:hover { background: var(--surface-2); }
.seg-btn.active { background: var(--primary); color: #fff; }

/* ===================== Tabela (issue grid) ===================== */
.grid-wrap { overflow-x: auto; }
/* min-width força rolagem horizontal em vez de espremer/cortar a coluna Ações */
.grid { width: 100%; min-width: 1180px; border-collapse: collapse; background: var(--surface); }
.grid th, .grid td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--border-2); font-size: 13px; vertical-align: middle; }
/* Ações: coluna fixa à direita, sempre visível, botões em linha única */
.grid th.right, .grid td.right { white-space: nowrap; position: sticky; right: 0; background: var(--surface); box-shadow: -6px 0 8px -6px rgba(9,30,66,.15); }
.grid thead th.right { background: var(--surface-2); }
.grid td.right .btn { margin: 2px; }
.grid thead th {
  color: var(--subtle); font-weight: 600; text-transform: uppercase; font-size: 11px; letter-spacing: .04em;
  background: var(--surface-2); border-bottom: 1px solid var(--border);
  position: sticky; top: 0;
}
.grid thead th[data-sort] { cursor: pointer; user-select: none; white-space: nowrap; }
.grid thead th[data-sort]:hover { color: var(--text); background: var(--border-2); }
.grid thead th[data-sort].sorted-asc::after { content: " ▲"; font-size: 9px; color: var(--primary); }
.grid thead th[data-sort].sorted-desc::after { content: " ▼"; font-size: 9px; color: var(--primary); }
.grid tbody tr:hover { background: var(--surface-hover); }
.grid tbody tr:last-child td { border-bottom: none; }
.grid .right, th.right, td.right { text-align: right; }
.empty { text-align: center; color: var(--subtle); padding: 36px; }
.mono { font-family: "SFMono-Regular", "Consolas", "Liberation Mono", monospace; color: var(--primary); font-weight: 600; }
.os-link { color: var(--primary); font-weight: 600; text-decoration: none; border-bottom: 1px dashed var(--primary); cursor: pointer; }
.os-link:hover { color: var(--primary-h); border-bottom-style: solid; }
.user-chip { color: var(--text); font-size: 13px; font-weight: 600; padding: 4px 10px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); white-space: nowrap; }
.grid td.nowrap { white-space: nowrap; }
.badge.pausado { background: var(--warn-bg); color: var(--warn-fg); font-weight: 700; }
.btn.spinning { animation: girar 0.8s linear infinite; }
@keyframes girar { to { transform: rotate(360deg); } }
.encos-campos { display: grid; gap: 8px; }
.encos-campos .fld-row { display: grid; grid-template-columns: 150px 1fr; align-items: center; gap: 10px; }
.encos-campos .fld-row label { color: var(--muted); font-size: 12px; text-align: right; }
.encos-campos .fld-row select { width: 100%; min-width: 0; }
/* Horário de execução (data + hora inicial/final) nos modais encerrar/encaminhar */
.fld-row:has(> .hr-exec) > label { display: block; color: var(--muted); font-size: 12px; margin-bottom: 4px; text-align: left; }
.hr-exec { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.hr-exec .input.sm { min-width: 0; width: auto; }
.hr-exec input[type="date"] { max-width: 160px; }
.hr-exec input[type="time"] { max-width: 110px; }
.cell-status { max-width: 340px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--muted); }
.solucao { white-space: pre-wrap; background: var(--surface-2); border: 1px solid var(--border-2); padding: 8px 10px; border-radius: var(--radius); font-size: 12px; max-height: 180px; overflow: auto; margin: 0; color: var(--text); }
.hint { color: var(--muted); font-size: 13px; margin: 4px 20px 18px; line-height: 1.6; }
.hint code { background: var(--surface-2); border: 1px solid var(--border-2); padding: 1px 6px; border-radius: var(--radius); font-family: "Consolas", monospace; color: var(--text); }

/* ===================== Lozenges (badges de status JIRA) ===================== */
.badge {
  display: inline-block; padding: 2px 6px; border-radius: var(--radius);
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em;
  line-height: 16px; white-space: nowrap;
}
.badge.aberto        { background: var(--info-bg);   color: var(--info-fg); }   /* em andamento → azul */
.badge.encerrado     { background: var(--ok-bg);     color: var(--ok-fg); }     /* concluído → verde */
.badge.neutro        { background: var(--gray-bg);   color: var(--gray-fg); }
.badge.naoencontrado { background: var(--danger-bg); color: var(--danger-fg); }
.badge.sucesso       { background: var(--ok-bg);     color: var(--ok-fg); }
.badge.falha         { background: var(--danger-bg); color: var(--danger-fg); }
.badge.parcial       { background: var(--warn-bg);   color: var(--warn-fg); }
.badge.cancelado     { background: var(--gray-bg);   color: var(--gray-fg); }

.lvl-INFO { color: var(--muted); }
.lvl-WARNING { color: var(--warn-fg); font-weight: 600; }
.lvl-ERROR { color: var(--danger); font-weight: 600; }

/* ===================== Arquivo de log ===================== */
.logfile {
  margin: 0 20px 20px; background: #091E42; border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; font-family: "Consolas", monospace;
  font-size: 12px; line-height: 1.6; max-height: 70vh; overflow: auto;
  white-space: pre-wrap; color: #C1C7D0;
}

/* ===================== Modal ===================== */
.modal { position: fixed; inset: 0; background: rgba(9,30,66,.54); display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal-box { background: var(--surface); border-radius: var(--radius-lg); width: min(720px, 92vw); max-height: 85vh; overflow: auto; box-shadow: var(--shadow); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 24px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); }
.modal-head h2 { margin: 0; font-size: 18px; font-weight: 600; }
.modal-body { padding: 24px; }
.modal-body h3 { font-size: 14px; color: var(--text); margin: 24px 0 12px; }
.kv { display: grid; grid-template-columns: 170px 1fr; gap: 10px 16px; margin-bottom: 20px; }
.kv dt { color: var(--subtle); font-weight: 600; font-size: 12px; }
.kv dd { margin: 0; }
.timeline { border-left: 2px solid var(--border); padding-left: 20px; }
.timeline-item { margin-bottom: 18px; position: relative; }
.timeline-item::before { content: ""; width: 10px; height: 10px; background: var(--primary); border: 2px solid var(--surface); border-radius: 50%; position: absolute; left: -26px; top: 3px; }
.timeline-item h4 { margin: 0 0 6px; font-size: 13px; font-weight: 600; }
.timeline-item pre { background: var(--surface-2); border: 1px solid var(--border-2); padding: 10px; border-radius: var(--radius); white-space: pre-wrap; font-size: 12px; margin: 6px 0 0; }

/* ===================== Toast ===================== */
.toast { position: fixed; bottom: 24px; right: 24px; background: #091E42; color: #fff; padding: 12px 18px; border-radius: var(--radius); box-shadow: var(--shadow); z-index: 60; font-size: 13px; }
.toast.ok { border-left: 4px solid var(--ok); }
.toast.err { border-left: 4px solid var(--danger); }

/* Encaminhar (picker de usuário) */
.modal-box-sm { width: min(480px, 92vw); }
.muted-sm { color: var(--subtle); font-size: 12px; }
.enc-fav { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.enc-lista { margin-top: 10px; max-height: 320px; overflow: auto; display: flex; flex-direction: column; gap: 4px; }
.enc-user {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  text-align: left; width: 100%; background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 8px 12px; cursor: pointer; font-size: 13px;
}
.enc-user:hover { background: var(--info-bg); border-color: var(--primary); }
.enc-fav .enc-user { width: auto; }
.enc-user.fav { border-color: var(--primary); color: var(--primary-a); font-weight: 600; }
.enc-cod { color: var(--subtle); font-size: 11px; font-family: "Consolas", monospace; }
.enc-steps { margin: 8px 0; padding-left: 20px; color: var(--muted); font-size: 12px; line-height: 1.7; }
.enc-steps strong { color: var(--text); }

.hidden { display: none !important; }

@media (max-width: 1000px) {
  .cards { grid-template-columns: repeat(2, 1fr); }
  .sidebar { width: 200px; }
}
@media (max-width: 720px) {
  .app-body { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; border-right: none; border-bottom: 1px solid var(--border); }
  .tabs { flex-direction: row; flex-wrap: wrap; }
}
