/* ============================================================
   Central de Atendimento TI — Design System
   Reformulação visual: telas separadas, layout limpo.
   ============================================================ */

:root {
  --bg: #f2f5f9;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;

  --text: #0f172a;
  --text-muted: #64748b;
  --text-faint: #94a3b8;

  --primary: #2563eb;
  --primary-strong: #1d4ed8;
  --primary-soft: #eff6ff;
  --primary-ring: rgba(37, 99, 235, 0.18);
  /* Azul como TEXTO (link, eyebrow, aba ativa). No claro e' o proprio --primary; no escuro o azul
     de preencher botao (branco em cima) fica escuro demais pra ser letra sobre fundo escuro. */
  --primary-ink: #2563eb;

  --sidebar-bg: #0d1526;
  --sidebar-bg-2: #101c36;
  --sidebar-text: #cbd5e1;
  --sidebar-active: #2563eb;

  --success: #16a34a;
  --success-soft: #ecfdf3;
  --warning: #b45309;
  --warning-soft: #fffbeb;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --info: #0369a1;
  --info-soft: #f0f9ff;
  --purple: #7c3aed;
  --purple-soft: #f5f3ff;
  --neutral-soft: #f1f5f9;

  /* Bordas e fundos de apoio que eram cor fixa — viram token pra ter versao escura. */
  --topbar-bg: rgba(255, 255, 255, 0.92);
  --info-border: #bae6fd;
  --primary-border: #bfdbfe;
  --primary-hover-soft: #dbeafe;
  --warning-border: #fde68a;
  --warning-ink: #78716c;
  --success-border: #bbf7d0;
  --success-hover-soft: #d1fae5;
  --danger-border: #fecaca;
  --metric-warning: #f59e0b;

  /* Series do grafico "Entrada x saida" (validadas para daltonismo no claro e no escuro). */
  --serie-recebidos: #2563eb;
  --serie-encerrados: #16a34a;

  /* Tipo de resolucao — slots 1-3 da paleta categorica validada (ver bloco "Tipo de resolucao"). */
  --tipo-ti: #2a78d6;
  --tipo-operacional: #eb6834;
  --tipo-melhoria: #1baf7a;
  --tipo-nao-classificado: #94a3b8;
  --tipo-sem-resolucao: #d5dde8;

  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --radius-pill: 999px;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 4px 16px rgba(15, 23, 42, 0.07);
  --shadow-lg: 0 20px 50px rgba(15, 23, 42, 0.22);

  --font: Inter, "Segoe UI", system-ui, -apple-system, Arial, sans-serif;

  color-scheme: light;
}

/* ---------- Reset ---------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

img {
  max-width: 100%;
  display: block;
}

h1, h2, h3, h4, p, dl, dd, dt, figure {
  margin: 0;
}

button {
  font-family: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

input,
select,
textarea {
  font-family: inherit;
  font-size: 14px;
}

/* Base de cor dos campos com especificidade ZERO (:where): vale onde nenhum componente definiu cor
   propria. Sem isso, textarea/select soltos (ex.: o composer de tratativa) herdavam o cinza padrao
   do navegador no tema escuro. */
:where(textarea, select, input:not([type="checkbox"], [type="radio"], [type="file"], [type="range"], [type="color"])) {
  background-color: var(--surface);
  color: var(--text);
}

::placeholder {
  color: var(--text-faint);
}

/* ---------- Tipografia utilitária ---------- */

.eyebrow {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--primary-ink);
}

.subtitle {
  color: var(--text-muted);
  font-size: 14px;
}

/* ---------- Botões ---------- */

.btn-primary,
.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  border: 1px solid transparent;
  transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, transform 0.05s ease;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
  background: var(--primary-strong);
}

.btn-primary:disabled {
  opacity: 0.65;
  cursor: progress;
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-strong);
}

.btn-secondary:hover {
  background: var(--surface-soft);
  border-color: var(--text-faint);
}

.btn-primary:active,
.btn-secondary:active {
  transform: translateY(1px);
}

.btn-primary:focus-visible,
.btn-secondary:focus-visible,
.tab-button:focus-visible,
.side-nav button:focus-visible {
  outline: 3px solid var(--primary-ring);
  outline-offset: 1px;
}

/* ---------- Campos de formulário ---------- */

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--text);
}

.field > span {
  font-weight: 600;
  color: var(--text-muted);
  font-size: 12.5px;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-ring);
}

.field textarea {
  resize: vertical;
  min-height: 96px;
}

.field input[readonly] {
  background: var(--neutral-soft);
  color: var(--text-muted);
  cursor: not-allowed;
}

.field input[readonly]:focus {
  border-color: var(--border-strong);
  box-shadow: none;
}

.field small {
  color: var(--text-faint);
  font-size: 12px;
}

.field.compact {
  min-width: 130px;
}

.field.compact input,
.field.compact select {
  padding: 8px 10px;
  font-size: 13px;
}

.checkbox-field > span {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  color: var(--text);
}

.checkbox-field input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
}

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

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.form-grid .field.full {
  grid-column: 1 / -1;
}

/* ---------- Mensagens ---------- */

.mensagem {
  font-size: 13.5px;
  color: var(--text-muted);
  min-height: 1.2em;
}

.mensagem.erro {
  color: var(--danger);
  font-weight: 600;
}

.mensagem.sucesso {
  color: var(--success);
  font-weight: 600;
}

.empty {
  padding: 28px 16px;
  text-align: center;
  color: var(--text-faint);
  font-size: 14px;
  background: var(--surface-soft);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
}

/* ============================================================
   LOGIN
   ============================================================ */

.login-view {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(1000px 600px at 85% -10%, rgba(37, 99, 235, 0.25), transparent 60%),
    radial-gradient(800px 500px at -10% 110%, rgba(124, 58, 237, 0.18), transparent 55%),
    linear-gradient(160deg, #0b1220 0%, #101c36 55%, #0b1220 100%);
}

.login-panel {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  width: min(880px, 100%);
  border-radius: 20px;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}

.login-brand-side {
  padding: 48px 40px;
  color: #e2e8f0;
  background: linear-gradient(160deg, rgba(37, 99, 235, 0.16), rgba(13, 21, 38, 0.4));
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 10px;
}

.login-brand-side h1 {
  font-size: 40px;
  line-height: 1.1;
  color: #fff;
}

.login-brand-side .subtitle {
  color: #94a3b8;
  font-size: 15px;
}

.login-brand-side .eyebrow {
  color: #93c5fd;
}

.brand-icon.large {
  width: 56px;
  height: 56px;
  margin-bottom: 12px;
  border-radius: 14px;
}

.login-card {
  background: var(--surface);
  padding: 48px 40px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
}

.login-card h2 {
  font-size: 22px;
}

.login-card form {
  margin-top: 20px;
}

/* ============================================================
   LAYOUT DA APLICAÇÃO
   ============================================================ */

.app-layout {
  display: grid;
  grid-template-columns: 264px minmax(0, 1fr);
  min-height: 100vh;
}

/* ---------- Sidebar ---------- */

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 24px 16px;
  background: linear-gradient(180deg, var(--sidebar-bg) 0%, var(--sidebar-bg-2) 100%);
  color: var(--sidebar-text);
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-lockup.compact {
  padding: 4px 8px;
}

.brand-lockup .eyebrow {
  color: #7da2f0;
}

.brand-lockup strong {
  font-size: 16px;
  color: #f8fafc;
}

.brand-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  flex-shrink: 0;
}

.side-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.side-nav-label {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #475569;
  padding: 14px 12px 4px;
}

.side-nav button,
.side-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--sidebar-text);
  font-size: 14px;
  font-weight: 500;
  text-align: left;
  text-decoration: none;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.side-nav button:hover:not(.disabled),
.side-nav a:hover {
  background: rgba(148, 163, 184, 0.12);
  color: #f1f5f9;
}

.side-nav button.active,
.side-nav a.active {
  background: var(--sidebar-active);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.35);
}

.side-nav button.disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.nav-icon {
  width: 20px;
  text-align: center;
  font-size: 14px;
  flex-shrink: 0;
}

.sidebar-foot {
  padding: 12px;
  border-top: 1px solid rgba(148, 163, 184, 0.15);
  font-size: 13px;
  color: #94a3b8;
}

.sidebar-foot small {
  color: #475569;
  font-size: 11.5px;
}

/* ---------- Área principal ---------- */

.main-area {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 32px;
  background: var(--topbar-bg);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.topbar h1 {
  font-size: 20px;
  line-height: 1.25;
}

.session {
  display: flex;
  align-items: center;
  gap: 16px;
}

.session-user {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1.3;
}

.session-user span {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
}

.session-user strong {
  font-size: 13.5px;
  color: var(--text);
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workspace {
  padding: 28px 32px 48px;
}

.view {
  display: flex;
  flex-direction: column;
  gap: 20px;
  animation: view-in 0.22s ease;
}

@keyframes view-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ---------- Painéis / cartões ---------- */

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.section-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.section-header h2 {
  font-size: 18px;
  margin-top: 2px;
}

.section-header p:not(.eyebrow) {
  color: var(--text-muted);
  font-size: 13.5px;
  margin-top: 2px;
}

.queue-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* ---------- Hero ---------- */

.hero-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 28px 32px;
  border-radius: var(--radius-lg);
  color: #f1f5f9;
  background:
    radial-gradient(600px 300px at 90% -40%, rgba(96, 165, 250, 0.35), transparent 60%),
    linear-gradient(135deg, #16244a 0%, #0d1526 70%);
  box-shadow: var(--shadow-md);
}

.hero-panel .eyebrow {
  color: #93c5fd;
}

.hero-panel h2 {
  font-size: 24px;
  color: #fff;
  margin: 4px 0 6px;
}

.hero-panel p:not(.eyebrow) {
  color: #a8b6cf;
  font-size: 14px;
  max-width: 60ch;
}

.hero-status {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 14px 20px;
  border-radius: var(--radius-md);
  background: rgba(37, 99, 235, 0.18);
  border: 1px solid rgba(96, 165, 250, 0.35);
}

.hero-status span {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #93c5fd;
  font-weight: 700;
}

.hero-status strong {
  font-size: 15px;
  color: #fff;
}

/* ---------- Métricas ---------- */

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
}

.metric {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  box-shadow: var(--shadow-sm);
  border-top: 3px solid var(--border-strong);
}

.metric span {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
}

.metric strong {
  font-size: 28px;
  line-height: 1.2;
  color: var(--text);
}

.metric small {
  font-size: 11.5px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}

.metric-primary  { border-top-color: var(--primary); }
.metric-success  { border-top-color: var(--success); }
.metric-warning  { border-top-color: var(--metric-warning); }
.metric-danger   { border-top-color: var(--danger); }
.metric-neutral  { border-top-color: var(--border-strong); }
.metric-project  { border-top-color: var(--purple); }

/* ---------- Ações do solicitante (Início) ---------- */

.action-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

.action-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  text-align: left;
  text-decoration: none;
  color: var(--text);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease;
}

.action-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.action-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: var(--primary-soft);
  color: var(--primary-ink);
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 4px;
}

.action-card strong {
  font-size: 15px;
}

.action-card small {
  color: var(--text-muted);
  font-size: 13px;
}

.notice-strip {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px 20px;
  border-radius: var(--radius-md);
  background: var(--warning-soft);
  border: 1px solid var(--warning-border);
}

.notice-strip strong {
  font-size: 13.5px;
  color: var(--warning);
}

.notice-strip p {
  font-size: 13.5px;
  color: var(--warning-ink);
}

/* ---------- Filtros ---------- */

.filter-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  padding: 16px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin: 0;
}

.requester-filters {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: flex-end;
}

.lookup {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.lookup input {
  flex: 1;
  min-width: 220px;
  padding: 10px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 14px;
}

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

/* ---------- Abas da fila ---------- */

.queue-tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--neutral-soft);
  border-radius: var(--radius-md);
  overflow-x: auto;
}

.tab-button {
  flex: 1;
  white-space: nowrap;
  padding: 9px 16px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  transition: background-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.tab-button:hover {
  color: var(--text);
}

.tab-button.active {
  background: var(--surface);
  color: var(--primary-ink);
  box-shadow: var(--shadow-sm);
}

.tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  margin-left: 6px;
  border-radius: var(--radius-pill);
  background: var(--primary);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
}

/* ---------- Tabela da fila ---------- */

.queue-table {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.queue-table .empty {
  border: none;
  border-radius: 0;
}

.ticket-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  min-width: 960px;
}

.ticket-table thead th {
  position: sticky;
  top: 0;
  background: var(--surface-soft);
  color: var(--text-faint);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.ticket-table tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  color: var(--text-muted);
}

.ticket-table tbody tr:last-child td {
  border-bottom: none;
}

.ticket-table tbody tr {
  background: var(--surface);
  transition: background-color 0.12s ease;
}

.ticket-table tbody tr:hover {
  background: var(--primary-soft);
}

.ticket-title {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 220px;
}

.ticket-title strong {
  color: var(--text);
  font-size: 12.5px;
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
}

.ticket-title span {
  color: var(--text);
  font-weight: 500;
}

/* ---------- Pills: status / prioridade / badges ---------- */

.status,
.priority,
.ticket-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  background: var(--neutral-soft);
  color: var(--text-muted);
  border: 1px solid transparent;
}

.status-open     { background: var(--info-soft);    color: var(--info);    border-color: var(--info-border); }
.status-progress { background: var(--primary-soft); color: var(--primary-ink); border-color: var(--primary-border); }
.status-waiting  { background: var(--warning-soft); color: var(--warning); border-color: var(--warning-border); }
.status-paused   { background: var(--neutral-soft); color: var(--text-muted); border-color: var(--border-strong); }
.status-resolved { background: var(--success-soft); color: var(--success); border-color: var(--success-border); }
.status-canceled { background: var(--danger-soft);  color: var(--danger);  border-color: var(--danger-border); }
/* Selo do chamado excluido. Anda ao lado do status (nao no lugar dele) e por isso ganha um respiro
   a esquerda; risco na fonte pra se distinguir a olho do status, que e' um selo da mesma familia. */
.status-deleted  { background: var(--neutral-soft); color: var(--text-muted); border-color: var(--border-strong); margin-left: 6px; text-decoration: line-through; }

.priority-low      { background: var(--neutral-soft); color: var(--text-muted); }
.priority-medium   { background: var(--info-soft);    color: var(--info); }
.priority-high     { background: var(--warning-soft); color: var(--warning); }
.priority-critical { background: var(--danger-soft);  color: var(--danger); }
.priority-none     { background: var(--surface-soft); color: var(--text-faint); border-color: var(--border); }

/* Enquanto a TI nao carimbou a criticidade, o valor exibido e so a sugestao do solicitante — o
   contorno tracejado avisa que aquele nivel ainda nao foi confirmado por ninguem do atendimento. */
.priority-sugerida {
  border-style: dashed;
  border-color: currentColor;
  opacity: 0.75;
}

.ticket-badges {
  display: inline-flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.ticket-badge.project { background: var(--purple-soft);  color: var(--purple); }
.ticket-badge.paused  { background: var(--neutral-soft); color: var(--text-muted); }
.ticket-badge.late    { background: var(--danger-soft);  color: var(--danger); }
.ticket-badge.origem  { background: var(--success-soft); color: var(--success); }

/* ---------- Lista de chamados (cartões) ---------- */

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

.requester-ticket {
  display: flex;
  gap: 20px;
  justify-content: space-between;
  padding: 18px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.requester-ticket:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
}

.ticket-card-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ticket-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.ticket-card-head strong {
  font-size: 12.5px;
  color: var(--text-faint);
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
}

.ticket-card-head h3 {
  font-size: 15.5px;
  margin-top: 2px;
}

.ticket-card-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px 18px;
}

.ticket-card-meta div {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.ticket-card-meta dt {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
}

.ticket-card-meta dd {
  font-size: 13.5px;
  color: var(--text);
}

/* ---------- Botões de ação de chamado ---------- */

.ticket-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.ticket-actions.vertical {
  flex-direction: column;
  flex-shrink: 0;
  min-width: 170px;
  justify-content: flex-start;
}

.ticket-actions button {
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: var(--primary);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.ticket-actions button:hover {
  background: var(--primary-strong);
}

.ticket-actions button.secondary,
.ticket-actions button.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-strong);
}

.ticket-actions button.secondary:hover,
.ticket-actions button.btn-secondary:hover {
  background: var(--surface-soft);
}

.ticket-actions button.danger {
  color: var(--danger);
  border-color: var(--danger-border);
}

.ticket-actions button.danger:hover {
  background: var(--danger-soft);
}

.ticket-actions button:disabled {
  opacity: 0.6;
  cursor: progress;
}

/* ---------- Chamado completo (consulta de protocolo) ---------- */

.ticket {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

.ticket-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.ticket-header strong {
  font-size: 12.5px;
  color: var(--text-faint);
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
}

.ticket-header h3 {
  font-size: 16px;
  margin-top: 2px;
}

.ticket-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px 18px;
  padding: 14px 16px;
  background: var(--surface-soft);
  border-radius: var(--radius-sm);
}

.ticket-meta div {
  display: flex;
  flex-direction: column;
}

.ticket-meta dt {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
}

.ticket-meta dd {
  font-size: 13.5px;
  color: var(--text);
  overflow-wrap: anywhere;
}

.ticket-description {
  font-size: 14px;
  color: var(--text);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  padding: 14px 16px;
  background: var(--surface-soft);
  border-left: 3px solid var(--border-strong);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

/* ---------- Anexos ---------- */

.attachment-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.attachment-group + .attachment-group {
  margin-top: 10px;
}

.attachment-group-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
}

.attachment-group.atendimento .attachments a {
  background: var(--success-soft);
  color: var(--success);
  border-color: var(--success-border);
}

.attachment-group.atendimento .attachments a:hover {
  background: var(--success-hover-soft);
}

.attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.attachments a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  background: var(--primary-soft);
  color: var(--primary-ink);
  border: 1px solid var(--primary-border);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.attachments a::before {
  content: "📎";
  font-size: 12px;
}

.attachments a:hover {
  background: var(--primary-hover-soft);
}

/* ---------- Histórico ---------- */

.history {
  list-style: none;
  margin: 0;
  padding: 0 0 0 18px;
  border-left: 2px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.history li {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.history li::before {
  content: "";
  position: absolute;
  left: -23.5px;
  top: 5px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid var(--surface);
  box-shadow: 0 0 0 1.5px var(--primary);
}

.history strong {
  font-size: 13.5px;
  color: var(--text);
}

.history span {
  font-size: 12px;
  color: var(--text-faint);
}

.history p {
  font-size: 13.5px;
  color: var(--text-muted);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* ---------- Composer de tratativa ---------- */

.action-composer {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-soft);
  padding: 16px;
}

.action-composer form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.action-composer-head {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.action-composer-head strong {
  font-size: 14px;
}

.action-composer-head span {
  font-size: 12.5px;
  color: var(--text-muted);
}

.action-composer textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  resize: vertical;
}

.action-composer textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-ring);
}

.action-composer .field {
  font-size: 13px;
  color: var(--text-muted);
}

.action-composer-actions {
  display: flex;
  gap: 8px;
}

.action-composer-actions button {
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: var(--primary);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
}

.action-composer-actions button:hover {
  background: var(--primary-strong);
}

.action-composer-actions button.secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-strong);
}

.action-composer-actions button.secondary:hover {
  background: var(--surface-soft);
}

.action-composer-message {
  font-size: 13px;
  color: var(--text-muted);
  min-height: 1.2em;
  margin: 0;
}

.action-composer-message.erro {
  color: var(--danger);
  font-weight: 600;
}

.ticket-inline-message {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0;
}

.ticket-inline-message.erro {
  color: var(--danger);
  font-weight: 600;
}

/* ---------- Formulário de novo chamado ---------- */

.ticket-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.form-step {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
  margin: 0;
  background: var(--surface);
}

.form-step legend {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14.5px;
  font-weight: 700;
  color: var(--text);
  padding: 0 8px;
}

.form-step legend span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}

.form-step .field {
  margin-top: 4px;
}

.form-footer {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

input[type="file"] {
  padding: 8px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  font-size: 13px;
  color: var(--text-muted);
  width: 100%;
}

input[type="file"]::file-selector-button {
  padding: 7px 14px;
  margin-right: 12px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: #fff;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
}

/* ---------- Drawer de detalhe ---------- */

.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(2px);
  z-index: 90;
}

.ticket-drawer {
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  width: min(600px, 100vw);
  background: var(--surface);
  z-index: 100;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  padding: 28px;
  animation: drawer-in 0.22s ease;
}

@keyframes drawer-in {
  from { transform: translateX(40px); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

.drawer-close {
  position: sticky;
  top: 0;
  float: right;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 20px;
  line-height: 1;
  z-index: 5;
}

.drawer-close:hover {
  background: var(--surface-soft);
  color: var(--text);
}

.detail-view {
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.detail-header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.detail-header h2 {
  font-size: 19px;
  margin: 4px 0 2px;
}

.detail-header strong {
  font-size: 12.5px;
  color: var(--text-faint);
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
}

.detail-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.detail-section h3 {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-faint);
}

.detail-facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 18px;
}

.detail-facts div {
  display: flex;
  flex-direction: column;
}

.detail-facts dt {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
}

.detail-facts dd {
  font-size: 13.5px;
  color: var(--text);
  overflow-wrap: anywhere;
}

/* ---------- Modal de aviso ---------- */

.notice-modal {
  position: fixed;
  inset: 0;
  z-index: 110;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(3px);
}

.notice-card {
  width: min(480px, 100%);
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 32px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 10px;
  animation: view-in 0.22s ease;
}

.notice-card h2 {
  font-size: 20px;
}

.notice-card p:not(.eyebrow) {
  color: var(--text-muted);
  font-size: 14px;
}

.notice-actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
  flex-wrap: wrap;
}

/* ---------- Grupos de projeto (legado) ---------- */

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

.project-group-header {
  display: flex;
  gap: 24px;
  align-items: center;
  padding: 12px 16px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.project-group-header span {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  font-weight: 700;
  display: block;
}

.project-group-header small {
  margin-left: auto;
  color: var(--text-faint);
}

.solution-ticket {
  display: flex;
  gap: 20px;
  padding: 18px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.solution-ticket-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.solution-ticket-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.solution-facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px 16px;
}

.solution-facts dt {
  font-size: 11px;
  text-transform: uppercase;
  color: var(--text-faint);
  font-weight: 700;
}

.solution-facts dd {
  font-size: 13px;
  color: var(--text);
}

.solution-actions {
  flex-shrink: 0;
  min-width: 190px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 14px;
  background: var(--surface-soft);
  border-radius: var(--radius-md);
}

.solution-actions > span {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  font-weight: 700;
}

.solution-actions > strong {
  font-size: 14px;
  margin-bottom: 6px;
}

/* ============================================================
   Abertura por tipo de pedido, regras documentadas e lista de sistemas
   ------------------------------------------------------------
   So tokens do :root — o tema escuro vem de graca.
   ============================================================ */

.field > span em,
.regra-bloco legend em {
  font-style: normal;
  font-weight: 500;
  color: var(--text-faint);
}

/* Escolha do tipo: tres cartoes-radio. O cartao inteiro e' o alvo de clique. */
.natureza-opcoes {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 4px;
}

.natureza-opcao {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  column-gap: 12px;
  row-gap: 2px;
  align-items: center;
  padding: 14px 16px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--surface);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.natureza-opcao:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.natureza-opcao input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.natureza-opcao:has(input:checked) {
  border-color: var(--primary);
  background: var(--primary-soft);
  box-shadow: 0 0 0 3px var(--primary-ring);
}

.natureza-opcao:has(input:focus-visible) {
  outline: 3px solid var(--primary-ring);
  outline-offset: 2px;
}

.natureza-icone {
  grid-row: 1 / span 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  background: var(--neutral-soft);
  color: var(--text-muted);
}

.natureza-icone svg {
  width: 20px;
  height: 20px;
}

.natureza-opcao:has(input:checked) .natureza-icone {
  background: var(--primary);
  color: #fff;
}

.natureza-opcao strong {
  font-size: 14px;
  color: var(--text);
}

.natureza-opcao small {
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.4;
}

[data-natureza-campos] {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.btn-pequeno {
  align-self: flex-start;
  padding: 7px 12px;
  font-size: 13px;
}

/* "Isso ja esta documentado?" */
.ja-pedido {
  margin-top: 14px;
  padding: 14px 16px;
  border: 1px solid var(--warning-border);
  border-left: 4px solid var(--warning);
  border-radius: var(--radius-sm);
  background: var(--warning-soft);
  font-size: 13.5px;
}

.ja-pedido > strong {
  display: block;
  color: var(--text);
}

.ja-pedido > p {
  margin: 2px 0 10px;
  color: var(--text-muted);
}

.ja-pedido ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ja-pedido details {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
}

.ja-pedido summary {
  cursor: pointer;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
}

.ja-pedido summary span {
  font-size: 12px;
  color: var(--text-faint);
}

.ja-pedido details p {
  margin: 8px 0;
  white-space: pre-wrap;
  color: var(--text);
}

/* Regra no chamado (o texto que o solicitante confirma) e regra atual na abertura de mudanca */
.regra-chamado,
.regra-atual {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 16px;
  border: 1px solid var(--success-border);
  border-left: 4px solid var(--success);
  border-radius: var(--radius-sm);
  background: var(--success-soft);
}

.regra-chamado-rotulo {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--success);
}

.regra-chamado p,
.regra-atual p {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: var(--text);
  font-size: 14px;
}

.regra-chamado small,
.regra-atual small {
  color: var(--text-muted);
  font-size: 12px;
}

/* Acesso: uma linha por pessoa + sistemas para marcar */
.acesso-pessoas {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.acesso-pessoa {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1.2fr) minmax(0, 1fr) auto;
  gap: 12px;
  align-items: end;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
}

.acesso-remover {
  width: 36px;
  height: 40px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 18px;
  line-height: 1;
}

.acesso-remover:hover {
  color: var(--danger);
  border-color: var(--danger-border);
}

/* Uma pessoa so: nao ha o que remover (o espaco fica, para a linha nao pular). */
.acesso-pessoa:only-child .acesso-remover {
  visibility: hidden;
}

.checks-sistema {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.check-sistema {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill);
  background: var(--surface);
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
}

.check-sistema input {
  width: 15px;
  height: 15px;
  accent-color: var(--primary);
}

.check-sistema:has(input:checked) {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary-ink);
  font-weight: 600;
}

.notice-inline.aviso-senha {
  margin-top: 0;
  border-left-color: var(--warning);
  background: var(--warning-soft);
}

/* Bloco da regra dentro do composer de fechamento */
.regra-bloco {
  margin: 0;
  padding: 12px 14px 14px;
  border: 1px solid var(--success-border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.regra-bloco legend {
  padding: 0 6px;
  font-size: 13px;
  font-weight: 700;
  color: var(--success);
}

.regra-bloco-campos {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.notice-inline.regra-indisponivel {
  margin: 0;
}

/* Tela "Regras dos sistemas" */
.pill-contagem {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 20px;
  padding: 0 7px;
  border-radius: var(--radius-pill);
  background: var(--primary-soft);
  border: 1px solid var(--primary-border);
  color: var(--primary-ink);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}

.regra-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-soft);
}

.regras-lista {
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.regras-grupo {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.regras-grupo > h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.regra-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-left: 4px solid var(--success);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.regra-card.arquivada {
  border-left-color: var(--border-strong);
  opacity: 0.75;
}

.regra-card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.regra-card-head strong {
  font-size: 15px;
}

.regra-texto {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 14px;
  color: var(--text);
}

.regra-meta {
  margin: 0;
  font-size: 12.5px;
  color: var(--text-faint);
}

.link-protocolo {
  padding: 0;
  border: 0;
  background: none;
  color: var(--primary-ink);
  font: inherit;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

.regra-versoes summary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
}

.regra-versoes ol {
  margin: 10px 0 0;
  padding: 0 0 0 14px;
  border-left: 2px solid var(--border);
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.regra-versoes li span {
  font-size: 12px;
  color: var(--text-faint);
}

.regra-versoes li p {
  margin: 2px 0 0;
  white-space: pre-wrap;
  font-size: 13px;
  color: var(--text-muted);
}

/* Lista de sistemas (Configuracoes) */
.sistemas-novo {
  display: flex;
  align-items: flex-end;
  gap: 12px;
}

.sistemas-novo .field {
  flex: 1;
  max-width: 420px;
}

.sistemas-lista {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sistema-linha {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.sistema-linha input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  font-weight: 600;
}

.sistema-linha input:hover {
  border-color: var(--border);
}

.sistema-linha input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-ring);
  background: var(--surface);
}

.sistema-linha.inativo {
  background: var(--surface-soft);
}

.sistema-linha.inativo input {
  color: var(--text-faint);
  text-decoration: line-through;
}

.sistema-acoes {
  display: flex;
  gap: 6px;
}

.sistema-acoes .btn-secondary {
  padding: 6px 12px;
  font-size: 12.5px;
}

/* Selo do tipo de pedido */
.ticket-badge.natureza { background: var(--neutral-soft); color: var(--text-muted); border-color: var(--border-strong); }
.ticket-badge.natureza-defeito { background: var(--danger-soft); color: var(--danger); border-color: var(--danger-border); }
.ticket-badge.natureza-mudanca { background: var(--info-soft); color: var(--info); border-color: var(--info-border); }
.ticket-badge.natureza-acesso { background: var(--warning-soft); color: var(--warning); border-color: var(--warning-border); }

@media (max-width: 820px) {
  .natureza-opcoes {
    grid-template-columns: 1fr;
  }

  .acesso-pessoa {
    grid-template-columns: 1fr;
  }

  .acesso-pessoa .acesso-remover {
    justify-self: end;
  }

  .sistemas-novo {
    flex-direction: column;
    align-items: stretch;
  }

  .sistemas-novo .field {
    max-width: none;
  }

  .sistema-linha {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .sistema-acoes {
    grid-column: 1 / -1;
  }
}

/* ============================================================
   RESPONSIVO
   ============================================================ */

@media (max-width: 1080px) {
  .app-layout {
    grid-template-columns: 220px minmax(0, 1fr);
  }

  .workspace {
    padding: 20px 20px 40px;
  }

  .topbar {
    padding: 14px 20px;
  }

  .hero-panel {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (max-width: 820px) {
  .app-layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    flex-direction: column;
    padding: 16px;
    gap: 12px;
  }

  .side-nav {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 6px;
  }

  .side-nav-label {
    display: none;
  }

  .side-nav button,
  .side-nav a {
    width: auto;
    padding: 8px 14px;
    font-size: 13px;
  }

  .sidebar-foot {
    display: none;
  }

  .session-user strong {
    max-width: 150px;
  }

  .login-panel {
    grid-template-columns: 1fr;
  }

  .login-brand-side {
    padding: 32px 28px;
  }

  .login-card {
    padding: 32px 28px;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .detail-facts {
    grid-template-columns: 1fr;
  }

  .requester-ticket,
  .solution-ticket {
    flex-direction: column;
  }

  .ticket-actions.vertical {
    flex-direction: row;
    flex-wrap: wrap;
    min-width: 0;
  }

  .topbar h1 {
    font-size: 17px;
  }

  /* Com o botao de tema, a sessao nao cabia em 390px e a pagina rolava pro lado: espaco menor e,
     se ainda faltar, a sessao desce pra linha de baixo em vez de vazar. */
  .topbar {
    flex-wrap: wrap;
    padding: 14px 16px;
  }

  .session {
    gap: 8px;
    margin-left: auto;
  }

  .session-user strong {
    max-width: 130px;
  }
}

/* ============================================================
   Dashboard do atendimento
   ------------------------------------------------------------
   Duas familias de cor com trabalhos diferentes: as SERIES do grafico (recebidos = azul da marca,
   encerrados = verde) carregam identidade e passaram no validador de daltonismo contra o fundo
   branco desta tela; o resto (metric-success/warning/danger, ja existente) carrega ESTADO. Nenhuma
   informacao depende so da cor: toda barra tem legenda, rotulo e tooltip com o numero exato.
   ============================================================ */

.dash-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.dash-title h3 {
  margin: 0;
  font-size: 15px;
  color: var(--text);
}

.dash-hint {
  font-size: 12px;
  color: var(--text-faint);
}

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

.dash-range button {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 12.5px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  cursor: pointer;
}

.dash-range button:hover {
  border-color: var(--border-strong);
  color: var(--text);
}

.dash-range button.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.dash-custom-range {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  padding: 14px 16px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.dash-custom-range .field.compact {
  min-width: 150px;
}

.dash-custom-range button {
  padding: 9px 16px;
  font-size: 13px;
}

.dash-custom-range .mensagem {
  flex-basis: 100%;
  margin: 0;
}

.dash-custom-range .mensagem:empty {
  display: none;
}

.notice-inline {
  margin: 12px 0 0;
  padding: 10px 12px;
  border-left: 3px solid var(--primary);
  background: var(--primary-soft);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-muted);
}

.dash-columns {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 18px;
}

.dash-legend {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 12.5px;
  color: var(--text-muted);
}

.dash-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.dash-dot {
  width: 11px;
  height: 11px;
  border-radius: 3px;
  display: inline-block;
}

.dash-dot.recebidos,
.dash-bar.recebidos {
  background: var(--serie-recebidos);
}

.dash-dot.encerrados,
.dash-bar.encerrados {
  background: var(--serie-encerrados);
}

.dash-chart {
  display: flex;
  gap: 10px;
  align-items: stretch;
}

.dash-axis {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-faint);
  padding-bottom: 20px;
  flex: none;
}

.dash-cols {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  flex: 1;
  min-width: 0;
  height: 190px;
  overflow-x: auto;
}

.dash-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 18px;
  height: 100%;
}

/* O vao de 2px entre as duas barras e o que separa as series — nunca um contorno em volta delas. */
.dash-col-bars {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  width: 100%;
  height: 100%;
}

.dash-bar {
  flex: 1;
  border-radius: 4px 4px 0 0;
  min-height: 0;
}

.dash-col-label {
  font-size: 10px;
  color: var(--text-faint);
  white-space: nowrap;
}

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

.dash-rank-row {
  display: grid;
  grid-template-columns: minmax(120px, 1.3fr) 1fr auto;
  align-items: center;
  gap: 12px;
}

.dash-rank-nome {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  min-width: 0;
}

.dash-rank-nome small {
  display: block;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
}

.dash-rank-barra {
  height: 10px;
  background: var(--neutral-soft);
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.dash-rank-barra span {
  display: block;
  height: 100%;
  background: var(--serie-recebidos);
  border-radius: var(--radius-pill);
}

.dash-rank-num {
  font-size: 15px;
  color: var(--text);
}

.dash-faixas {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.dash-faixa {
  display: grid;
  grid-template-columns: 96px 1fr auto;
  align-items: center;
  gap: 10px;
  font-size: 12.5px;
  color: var(--text-muted);
}

.dash-faixa-barra {
  height: 10px;
  background: var(--neutral-soft);
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.dash-faixa-barra span {
  display: block;
  height: 100%;
  background: var(--warning);
  border-radius: var(--radius-pill);
}

.dash-subtitulo {
  margin: 4px 0 0;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-faint);
}

.dash-antigos {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.dash-antigos li {
  display: grid;
  gap: 2px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.dash-antigos li:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.dash-antigos span {
  font-size: 13px;
  color: var(--text);
}

.dash-antigos small {
  font-size: 11.5px;
  color: var(--text-muted);
}

.dash-link {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  font-weight: 700;
  font-size: 12px;
  color: var(--primary-ink);
  cursor: pointer;
  text-align: left;
}

.dash-link:hover {
  text-decoration: underline;
}

.dash-vazio,
.dash-nota {
  font-size: 12.5px;
  color: var(--text-muted);
  margin: 0;
}

/* ============================================================
   Tipo de resolucao (T.I / Operacional / Melhoria)
   ------------------------------------------------------------
   As tres cores de tipo sao os tres primeiros slots da paleta categorica e passaram no validador
   de daltonismo em TODOS os pares, no claro (fundo #fff) e no escuro. Ordem fixa: a cor segue o
   tipo em todo grafico. "Nao classificado" e "em aberto/cancelado" sao cinzas de proposito — sao o
   resto, nao uma identidade. O agua-marinha fica abaixo de 3:1 no fundo branco, entao toda barra
   traz os numeros escritos ao lado (legenda + linha de resumo) — a cor nunca carrega sozinha.
   ============================================================ */

.tipo-chave {
  width: 11px;
  height: 11px;
  border-radius: 3px;
  display: inline-block;
  flex: none;
}

.tipo-chave.tipo-ti, .tipo-seg.tipo-ti { background: var(--tipo-ti); }
.tipo-chave.tipo-operacional, .tipo-seg.tipo-operacional { background: var(--tipo-operacional); }
.tipo-chave.tipo-melhoria, .tipo-seg.tipo-melhoria { background: var(--tipo-melhoria); }
.tipo-chave.tipo-nao-classificado, .tipo-seg.tipo-nao-classificado { background: var(--tipo-nao-classificado); }
.tipo-chave.tipo-semResolucao, .tipo-seg.tipo-semResolucao { background: var(--tipo-sem-resolucao); }

/* Barra empilhada: cresce da esquerda (a base), vao de 2px entre fatias, so a ponta arredondada. */
.tipo-stack {
  display: flex;
  gap: 2px;
  width: var(--preenchido, 100%);
  height: 12px;
  min-width: 0;
}

.tipo-seg {
  flex-basis: 0;
  min-width: 3px;
  height: 100%;
  transition: filter 0.15s ease;
}

.tipo-seg:last-child {
  border-radius: 0 4px 4px 0;
}

.tipo-seg:hover {
  filter: brightness(1.15) saturate(1.1);
}

.dash-columns-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

@media (max-width: 900px) {
  .dash-columns-2 {
    grid-template-columns: 1fr;
  }
}

.tipo-rank {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.tipo-rank-row {
  display: grid;
  gap: 6px;
}

.tipo-rank-topo {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.tipo-rank-topo span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.tipo-rank-topo strong {
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}

.tipo-rank-row small {
  font-size: 11.5px;
  color: var(--text-muted);
}

.tipo-placar-total {
  margin: 0 0 10px;
  font-size: 13px;
  color: var(--text-muted);
}

.tipo-placar-total strong {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  margin-right: 4px;
}

.tipo-placar-lista {
  list-style: none;
  margin: 16px 0 12px;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(104px, 1fr));
  gap: 10px;
}

.tipo-placar-lista li {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  column-gap: 8px;
  padding: 10px 12px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.tipo-placar-lista strong {
  font-size: 20px;
  color: var(--text);
}

.tipo-placar-lista span,
.tipo-placar-lista small {
  grid-column: 1 / -1;
  font-size: 12px;
  color: var(--text-muted);
}

.tipo-placar-lista small {
  color: var(--text-faint);
}

.crit-comparacao {
  list-style: none;
  margin: 8px 0 10px;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.crit-comparacao li {
  display: grid;
  gap: 2px;
  padding: 10px 12px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.crit-comparacao strong {
  font-size: 20px;
  color: var(--text);
}

.crit-comparacao span {
  font-size: 12px;
  color: var(--text-muted);
}

.crit-comparacao small {
  font-size: 11px;
  color: var(--text-faint);
}

/* Seletor de (re)classificacao na fila e no detalhe — a borda esquerda leva a cor do tipo. */
.tipo-resolucao-select {
  display: block;
  margin-top: 6px;
  max-width: 190px;
  padding: 4px 8px;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-left: 4px solid var(--tipo-nao-classificado);
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.tipo-resolucao-select.tipo-ti { border-left-color: var(--tipo-ti); }
.tipo-resolucao-select.tipo-operacional { border-left-color: var(--tipo-operacional); }
.tipo-resolucao-select.tipo-melhoria { border-left-color: var(--tipo-melhoria); }

.tipo-resolucao-select:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

@media (max-width: 560px) {
  .crit-comparacao {
    grid-template-columns: 1fr;
  }
}

.tipo-rank + .dash-nota {
  margin-top: 12px;
}

/* ============================================================
   Tema escuro — "central de monitoramento a noite"
   ------------------------------------------------------------
   Nao e' preto neutro com um acento neon: e' o azul-marinho da sidebar estendido pro app todo.
   Profundidade por camadas (fundo abismo -> cartao -> campo, cada uma um tom mais clara), bordas
   com tinta azul, status luminosos. A ousadia fica num lugar so: o brilho azul no topo da pagina
   (luz de monitor) e o filete de luz na borda de cima dos cartoes.

   Contraste medido (WCAG, sobre o cartao #0d1426): texto 15.5, secundario 7.6, apagado 4.9,
   azul-texto 7.7, status todos > 6.6; botao azul com letra branca 4.5. Series e tipos de
   resolucao passaram no validador de daltonismo contra este cartao.

   O tema vem do atributo data-theme no <html>, que o script do <head> aplica ANTES de pintar
   (sem piscar branco). Sem escolha salva, segue o sistema operacional.
   ============================================================ */

:root[data-theme="dark"] {
  color-scheme: dark;

  --bg: #070b16;
  --surface: #0d1426;
  --surface-soft: #121b31;
  --border: #1d2946;
  --border-strong: #2e3d62;

  --text: #e6ecf7;
  --text-muted: #9aa8c2;
  --text-faint: #7384a3;

  --primary: #2f6df6;
  --primary-strong: #447ff8;
  --primary-ink: #7aa7ff;
  --primary-soft: rgba(79, 140, 255, 0.14);
  --primary-ring: rgba(79, 140, 255, 0.4);

  --sidebar-bg: #04070e;
  --sidebar-bg-2: #080f1e;
  --sidebar-text: #b6c2d9;
  --sidebar-active: #2f6df6;

  --success: #34d399;
  --success-soft: rgba(52, 211, 153, 0.12);
  --warning: #fbbf24;
  --warning-soft: rgba(251, 191, 36, 0.1);
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.12);
  --info: #38bdf8;
  --info-soft: rgba(56, 189, 248, 0.12);
  --purple: #a78bfa;
  --purple-soft: rgba(167, 139, 250, 0.14);
  --neutral-soft: #16203a;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.5);
  --shadow-md: inset 0 1px 0 rgba(148, 176, 255, 0.07), 0 14px 34px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 28px 70px rgba(0, 0, 0, 0.65);

  --topbar-bg: rgba(7, 11, 22, 0.78);
  --info-border: rgba(56, 189, 248, 0.35);
  --primary-border: rgba(122, 167, 255, 0.35);
  --primary-hover-soft: rgba(79, 140, 255, 0.22);
  --warning-border: rgba(251, 191, 36, 0.35);
  --warning-ink: #d6c9a4;
  --success-border: rgba(52, 211, 153, 0.35);
  --success-hover-soft: rgba(52, 211, 153, 0.2);
  --danger-border: rgba(248, 113, 113, 0.4);
  --metric-warning: #fbbf24;

  --serie-recebidos: #4a8df0;
  --serie-encerrados: #1fae6a;

  --tipo-ti: #3987e5;
  --tipo-operacional: #d95926;
  --tipo-melhoria: #199e70;
  --tipo-nao-classificado: #64748b;
  --tipo-sem-resolucao: #34425f;
}

/* A luz de monitor: um brilho azul largo e baixo no topo, fixo enquanto a pagina rola. */
:root[data-theme="dark"] body {
  background:
    radial-gradient(1100px 480px at 72% -220px, rgba(47, 109, 246, 0.2), transparent 72%),
    radial-gradient(700px 420px at 0% 100%, rgba(124, 58, 237, 0.07), transparent 70%),
    var(--bg);
  background-attachment: fixed;
}

:root[data-theme="dark"] .sidebar {
  border-right: 1px solid rgba(122, 167, 255, 0.08);
}

:root[data-theme="dark"] .topbar {
  border-bottom-color: rgba(122, 167, 255, 0.1);
}

:root[data-theme="dark"] ::selection {
  background: rgba(79, 140, 255, 0.35);
}

/* Troca de tema: as cores atravessam em vez de pular. So cor muda — nada se move. */
:root.tema-trocando,
:root.tema-trocando *,
:root.tema-trocando *::before,
:root.tema-trocando *::after {
  transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease, box-shadow 0.3s ease !important;
}

/* ---------- Botao de tema ---------- */

.theme-toggle {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-muted);
  transition: color 0.15s ease, border-color 0.15s ease, background-color 0.15s ease;
}

.theme-toggle:hover {
  color: var(--text);
  border-color: var(--text-faint);
}

.theme-toggle:focus-visible {
  outline: 3px solid var(--primary-ring);
  outline-offset: 1px;
}

.theme-toggle svg {
  width: 18px;
  height: 18px;
  grid-area: 1 / 1;
}

/* Mostra o destino, nao o estado: no claro a lua ("ir pro escuro"), no escuro o sol. */
.theme-toggle .icone-sol { display: none; }
:root[data-theme="dark"] .theme-toggle .icone-sol { display: block; color: #fbbf24; }
:root[data-theme="dark"] .theme-toggle .icone-lua { display: none; }

/* Na tela de login o botao flutua no canto, sobre o fundo que ja e' escuro nos dois temas. */
.login-view {
  position: relative;
}

.theme-toggle.login-theme-toggle {
  position: absolute;
  top: 20px;
  right: 20px;
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(148, 163, 184, 0.3);
  color: #cbd5e1;
}

.theme-toggle.login-theme-toggle:hover {
  color: #fff;
  border-color: rgba(203, 213, 225, 0.6);
}

.dash-faixas + .dash-subtitulo {
  margin-top: 18px;
}

/* Brilho das pilhas de tipo: faixa de luz parada fora da barra (a esquerda); a camada de animacao
   do app.js (brilharPilha) a faz atravessar uma vez, logo depois da barra crescer. Sem animacao,
   ela fica escondida — nunca aparece parada no meio. */
.tipo-stack {
  position: relative;
  overflow: hidden;
}

.tipo-stack::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(100deg, transparent 36%, rgba(255, 255, 255, 0.85) 50%, transparent 64%);
  transform: translateX(-100%);
}

:root[data-theme="dark"] .tipo-stack::after {
  background: linear-gradient(100deg, transparent 36%, rgba(215, 232, 255, 0.9) 50%, transparent 64%);
}
