/* css/components.css — Cards, tables, forms, badges, modals */

/* ── Buttons ────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 16px; border-radius: 8px;
  font-size: 13px; font-weight: 500; font-family: 'Outfit', sans-serif;
  cursor: pointer; border: none; transition: all .15s;
  white-space: nowrap; flex-shrink: 0;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #2563eb; transform: translateY(-1px); }
.btn-ghost { background: var(--bg3); color: var(--text2); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg4); color: var(--text); }
.btn-danger { background: var(--red-dim); color: var(--red); border: 1px solid var(--red); }
.btn-danger:hover { background: var(--red); color: #fff; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none !important; }

/* ── Cards ──────────────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px; margin-bottom: 18px;
}
.stat-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px;
  position: relative; overflow: hidden;
}
.stat-card::after { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px; }
.stat-card.blue::after   { background: var(--accent); }
.stat-card.green::after  { background: var(--green); }
.stat-card.yellow::after { background: var(--yellow); }
.stat-card.red::after    { background: var(--red); }
.stat-label { font-size: 11px; color: var(--text3); text-transform: uppercase; letter-spacing: .8px; font-family: 'JetBrains Mono', monospace; margin-bottom: 8px; }
.stat-value { font-family: 'Syne', sans-serif; font-size: 28px; font-weight: 800; color: var(--text); line-height: 1; margin-bottom: 5px; }
.stat-sub   { font-size: 12px; color: var(--text2); }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 18px; }

.card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  gap: 10px; flex-wrap: wrap;
}
.card-title  { font-family: 'Syne', sans-serif; font-size: 14px; font-weight: 700; color: var(--text); }

/* ── Table (with responsive wrapper) ───────────────────────────────────── */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; width: 100%; }
.table { width: 100%; border-collapse: collapse; min-width: 500px; }
.table th {
  padding: 9px 12px; text-align: left;
  font-size: 11px; font-weight: 500; color: var(--text3);
  text-transform: uppercase; letter-spacing: .8px;
  font-family: 'JetBrains Mono', monospace;
  background: var(--bg3); border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table td {
  padding: 10px 12px; font-size: 13px; color: var(--text2);
  border-bottom: 1px solid var(--border); vertical-align: middle;
}
.table tr:last-child td { border-bottom: none; }
.table tbody tr { cursor: pointer; transition: background .1s; }
.table tbody tr:hover td { background: var(--bg3); }
.ticket-id    { font-family: 'JetBrains Mono', monospace; font-size: 12px; color: var(--accent2); white-space: nowrap; }
.ticket-title { color: var(--text); font-weight: 500; }

/* ── Priority / Status badges ───────────────────────────────────────────── */
.priority {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 500; padding: 3px 8px;
  border-radius: 20px; font-family: 'JetBrains Mono', monospace;
  white-space: nowrap;
}
.priority.alta    { background: var(--red-dim);    color: var(--red); }
.priority.media   { background: var(--yellow-dim); color: var(--yellow); }
.priority.baixa   { background: var(--green-dim);  color: var(--green); }
.priority.critica { background: rgba(239,68,68,.25); color: #ff6b6b; }

.status-tag {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 500; padding: 3px 9px;
  border-radius: 20px; font-family: 'JetBrains Mono', monospace;
  white-space: nowrap;
}
.status-tag.aberto    { background: var(--accent-dim); color: var(--accent2); }
.status-tag.andamento { background: var(--yellow-dim); color: var(--yellow); }
.status-tag.resolvido { background: var(--green-dim);  color: var(--green); }
.status-tag.fechado   { background: rgba(148,163,184,.1); color: var(--text3); }
.dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex-shrink: 0; }

.tag { display: inline-flex; align-items: center; padding: 3px 9px; border-radius: 5px; font-size: 11px; background: var(--bg4); color: var(--text2); font-family: 'JetBrains Mono', monospace; }

/* ── Filter bar ─────────────────────────────────────────────────────────── */
.filter-bar { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; align-items: center; }
.filter-chip {
  padding: 5px 13px; border-radius: 20px;
  font-size: 12px; cursor: pointer;
  background: var(--bg3); color: var(--text2);
  border: 1px solid var(--border);
  font-family: 'JetBrains Mono', monospace;
  transition: all .15s; white-space: nowrap;
}
.filter-chip:hover  { border-color: var(--border2); color: var(--text); }
.filter-chip.active { background: var(--accent-dim); color: var(--accent2); border-color: var(--accent); }

/* ── Forms ──────────────────────────────────────────────────────────────── */
.form-group   { margin-bottom: 14px; }
.form-row     { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-label   { display: block; font-size: 11px; font-weight: 500; color: var(--text2); margin-bottom: 6px; font-family: 'JetBrains Mono', monospace; text-transform: uppercase; letter-spacing: .5px; }
.form-input, .form-select, .form-textarea {
  width: 100%; background: var(--bg3); border: 1px solid var(--border);
  border-radius: 8px; padding: 10px 13px;
  color: var(--text); font-size: 13px; font-family: 'Outfit', sans-serif;
  outline: none; transition: border-color .15s;
}
.form-input:focus, .form-select:focus, .form-textarea:focus { border-color: var(--accent); }
.form-input::placeholder, .form-textarea::placeholder { color: var(--text3); }
.form-select option { background: var(--bg3); }
.form-textarea { resize: vertical; min-height: 80px; }

/* ── Modals ─────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.7);
  backdrop-filter: blur(4px);
  display: none; align-items: center; justify-content: center;
  z-index: 1000; padding: 16px;
}
.modal-overlay.open { display: flex; animation: fadeIn .15s; }
.modal {
  background: var(--bg2); border: 1px solid var(--border2);
  border-radius: 14px; width: 580px; max-width: 100%;
  max-height: 90vh; overflow-y: auto;
  box-shadow: 0 24px 80px rgba(0,0,0,.6);
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  gap: 10px; position: sticky; top: 0; background: var(--bg2); z-index: 1;
}
.modal-title { font-family: 'Syne', sans-serif; font-size: 15px; font-weight: 700; color: var(--text); }
.modal-close {
  width: 28px; height: 28px; background: var(--bg3); border: none; border-radius: 6px;
  color: var(--text2); cursor: pointer; display: flex; align-items: center; justify-content: center;
  font-size: 14px; transition: all .1s; flex-shrink: 0;
}
.modal-close:hover { background: var(--bg4); color: var(--text); }
.modal-body   { padding: 20px; }
.modal-footer {
  display: flex; gap: 10px; justify-content: flex-end;
  padding: 14px 20px; border-top: 1px solid var(--border);
  flex-wrap: wrap;
}

/* ── Attendant cards ────────────────────────────────────────────────────── */
.attendant-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.attendant-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px;
  transition: all .15s; position: relative; overflow: hidden;
}
.attendant-card:hover { border-color: var(--border2); transform: translateY(-1px); }
.attendant-card::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px; }
.attendant-card.ativo::before  { background: var(--green); }
.attendant-card.inativo::before{ background: var(--text3); }
.att-header  { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 12px; }
.att-avatar  { width: 42px; height: 42px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 15px; font-weight: 700; color: #fff; flex-shrink: 0; }
.att-name    { font-size: 14px; font-weight: 600; color: var(--text); line-height: 1.2; }
.att-email   { font-size: 11px; color: var(--text3); font-family: 'JetBrains Mono', monospace; margin-top: 3px; word-break: break-all; }
.att-stats   { display: flex; gap: 8px; margin-top: 10px; }
.att-stat    { flex: 1; background: var(--bg3); border-radius: 7px; padding: 8px; text-align: center; }
.att-stat-val{ font-family: 'Syne', sans-serif; font-size: 16px; font-weight: 700; color: var(--text); }
.att-stat-lbl{ font-size: 10px; color: var(--text3); font-family: 'JetBrains Mono', monospace; margin-top: 2px; }
.att-actions { display: flex; gap: 8px; margin-top: 12px; }
.role-tag    { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 20px; font-size: 11px; font-family: 'JetBrains Mono', monospace; font-weight: 500; }
.role-tag.admin    { background: var(--purple-dim); color: var(--purple); }
.role-tag.atendente{ background: var(--accent-dim); color: var(--accent2); }

/* ── Permissions ────────────────────────────────────────────────────────── */
.perm-section { background: var(--bg3); border: 1px solid var(--border); border-radius: 8px; padding: 14px; margin-top: 12px; }
.perm-title   { font-size: 11px; font-family: 'JetBrains Mono', monospace; color: var(--text3); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 10px; }
.perm-grid    { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.perm-item    { display: flex; align-items: center; gap: 8px; cursor: pointer; padding: 6px 8px; border-radius: 6px; transition: background .1s; }
.perm-item:hover { background: var(--bg4); }
.perm-checkbox {
  width: 16px; height: 16px;
  border: 1.5px solid var(--border2);
  border-radius: 4px;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  transition: all .15s;
  flex-shrink: 0;
  position: relative;
}
/* Checked: fundo azul, sem texto — só cor */
.perm-checkbox.checked {
  background: var(--accent);
  border-color: var(--accent);
}
/* Tick visível apenas no createticket (classe extra) */
.perm-checkbox.checked.show-tick::after {
  content: '';
  display: block;
  width: 4px; height: 8px;
  border: 2px solid #fff;
  border-top: none; border-left: none;
  transform: rotate(45deg) translateY(-1px);
}
.perm-label   { font-size: 12px; color: var(--text2); }
.perm-item:hover .perm-label { color: var(--text); }

/* ── Companies ──────────────────────────────────────────────────────────── */
.companies-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.company-card   { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; transition: all .15s; }
.company-card:hover { border-color: var(--border2); transform: translateY(-1px); }
.company-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; gap: 8px; flex-wrap: wrap; }
.company-name   { font-family: 'Syne', sans-serif; font-size: 14px; font-weight: 700; color: var(--text); }
.company-cnpj   { font-size: 11px; color: var(--text3); font-family: 'JetBrains Mono', monospace; margin-bottom: 6px; }
.company-stats  { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 10px; margin-bottom: 10px; }
.company-stat   { background: var(--bg3); border-radius: 7px; padding: 7px; text-align: center; }
.company-stat-val{ font-family: 'Syne', sans-serif; font-size: 14px; font-weight: 700; color: var(--text); word-break: break-all; }
.company-stat-lbl{ font-size: 10px; color: var(--text3); font-family: 'JetBrains Mono', monospace; margin-top: 2px; }
.company-actions{ display: flex; gap: 8px; }

/* ── Companies toolbar ───────────────────────────────────────────────────── */
.companies-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin-bottom: 16px; flex-wrap: wrap;
}
.view-toggle-btn {
  padding: 7px 9px !important;
  color: var(--text3); border-color: var(--border) !important;
  display: flex; align-items: center; justify-content: center;
  transition: color .15s, background .15s, border-color .15s;
}
.view-toggle-btn.active {
  color: var(--accent) !important; border-color: var(--accent) !important;
  background: rgba(59,130,246,.08) !important;
}
.view-toggle-btn:hover:not(.active) { color: var(--text); }

/* ── Companies list view ─────────────────────────────────────────────────── */
.companies-grid.list-view { display: flex; flex-direction: column; gap: 6px; }
.companies-grid.list-view .company-card {
  padding: 11px 16px; transform: none !important;
  display: grid; grid-template-columns: minmax(0,1fr) auto auto;
  align-items: center; gap: 16px;
}
.companies-grid.list-view .company-card:hover { background: var(--bg3); transform: none !important; }
.companies-grid.list-view .company-header { margin-bottom: 2px; flex-wrap: nowrap; }
.companies-grid.list-view .company-cnpj { margin-bottom: 0; }
.companies-grid.list-view .company-info-col { min-width: 0; }
.companies-grid.list-view .company-stats {
  display: flex; gap: 20px; margin: 0;
}
.companies-grid.list-view .company-stat {
  background: none; padding: 0; border-radius: 0;
  min-width: 42px;
}
.companies-grid.list-view .company-stat-val { font-size: 13px; }
.companies-grid.list-view .company-actions { flex-shrink: 0; }

/* ── Inventory ──────────────────────────────────────────────────────────── */
.inv-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.machine-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px;
  cursor: pointer; transition: all .15s;
  position: relative; overflow: hidden;
}
.machine-card:hover { border-color: var(--border2); transform: translateY(-2px); box-shadow: var(--shadow); }
.machine-card.online::before, .machine-card.offline::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px; }
.machine-card.online::before  { background: var(--green); }
.machine-card.offline::before { background: var(--text3); }
.machine-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 12px; gap: 8px; }
.machine-name   { font-family: 'Syne', sans-serif; font-size: 13px; font-weight: 700; color: var(--text); word-break: break-word; }
.machine-empresa{ font-size: 11px; color: var(--text3); font-family: 'JetBrains Mono', monospace; margin-top: 2px; }
.online-badge   { display: flex; align-items: center; gap: 5px; font-size: 11px; color: var(--text2); font-family: 'JetBrains Mono', monospace; white-space: nowrap; flex-shrink: 0; }
.online-badge.on  { color: var(--green); }
.online-badge.off { color: var(--text3); }
.pulse { width: 7px; height: 7px; border-radius: 50%; background: var(--text3); flex-shrink: 0; }
.pulse.on { background: var(--green); animation: pulse 2s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }
.machine-specs { display: flex; flex-direction: column; gap: 6px; }
.spec-row      { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.spec-label    { color: var(--text3); width: 48px; flex-shrink: 0; font-family: 'JetBrains Mono', monospace; font-size: 11px; }
.spec-val      { color: var(--text); font-weight: 500; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.usage-bar     { height: 4px; background: var(--bg4); border-radius: 2px; margin-top: 10px; overflow: hidden; }
.usage-fill    { height: 100%; border-radius: 2px; }
.usage-row     { display: flex; align-items: center; justify-content: space-between; margin-top: 4px; }
.usage-label   { font-size: 10px; color: var(--text3); font-family: 'JetBrains Mono', monospace; }

.spec-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.spec-block { background: var(--bg3); border-radius: 8px; padding: 12px; }
.spec-block-label { font-size: 10px; color: var(--text3); font-family: 'JetBrains Mono', monospace; text-transform: uppercase; letter-spacing: .5px; margin-bottom: 5px; }
.spec-block-val   { font-family: 'Syne', sans-serif; font-size: 14px; font-weight: 700; color: var(--text); word-break: break-word; }
.spec-block-sub   { font-size: 11px; color: var(--text3); margin-top: 4px; }

/* ── KB ─────────────────────────────────────────────────────────────────── */
.kb-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 18px; }
.kb-cat-card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; cursor: pointer; transition: all .15s; display: flex; align-items: center; gap: 12px; }
.kb-cat-card:hover { border-color: var(--border2); transform: translateY(-1px); }
.kb-cat-icon  { width: 40px; height: 40px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 18px; flex-shrink: 0; }
.kb-cat-name  { font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 2px; }
.kb-cat-count { font-size: 11px; color: var(--text3); font-family: 'JetBrains Mono', monospace; }
.kb-article   { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 13px 16px; cursor: pointer; transition: all .15s; display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.kb-article:hover { border-color: var(--border2); background: var(--bg3); }
.kb-article-title { font-size: 13px; font-weight: 500; color: var(--text); margin-bottom: 3px; }
.kb-article-meta  { font-size: 11px; color: var(--text3); font-family: 'JetBrains Mono', monospace; }

/* ── Agent section ──────────────────────────────────────────────────────── */
.agent-section { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; margin-bottom: 14px; }
.agent-title { font-family: 'Syne', sans-serif; font-size: 15px; font-weight: 700; color: var(--text); margin-bottom: 6px; }
.agent-desc  { font-size: 13px; color: var(--text2); margin-bottom: 16px; line-height: 1.6; }
.code-block  { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 13px 14px; font-family: 'JetBrains Mono', monospace; font-size: 12px; color: var(--accent2); overflow-x: auto; margin-bottom: 8px; position: relative; line-height: 1.8; -webkit-overflow-scrolling: touch; }
.copy-btn    { position: absolute; top: 8px; right: 8px; background: var(--bg3); border: 1px solid var(--border); color: var(--text3); border-radius: 6px; padding: 3px 9px; font-size: 11px; cursor: pointer; font-family: 'JetBrains Mono', monospace; }
.copy-btn:hover { color: var(--text); background: var(--bg4); }
.steps { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.step  { display: flex; gap: 12px; align-items: flex-start; }
.step-num  { width: 24px; height: 24px; flex-shrink: 0; background: var(--accent-dim); color: var(--accent2); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; font-family: 'JetBrains Mono', monospace; }
.step-text { font-size: 13px; color: var(--text2); padding-top: 3px; line-height: 1.5; }
.step-text strong { color: var(--text); }

/* ── Access denied ──────────────────────────────────────────────────────── */
.access-denied { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 60px 20px; color: var(--text3); text-align: center; }
.access-denied .icon  { font-size: 48px; opacity: .4; }
.access-denied .title { font-family: 'Syne', sans-serif; font-size: 18px; font-weight: 700; color: var(--text2); }

/* ── Toast ──────────────────────────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 20px; right: 20px; z-index: 9999;
  background: var(--bg4); border: 1px solid var(--border2);
  color: var(--text); padding: 11px 16px;
  border-radius: 10px; font-size: 13px;
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
  transform: translateY(100px); opacity: 0;
  transition: all .3s cubic-bezier(.34,1.56,.64,1);
  pointer-events: none; max-width: calc(100vw - 40px);
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast.error { border-color: var(--red); background: rgba(239,68,68,.1); color: var(--red); }

/* ── Autocomplete ────────────────────────────────────────────────────────── */
.autocomplete-wrap {
  position: relative;
}
.autocomplete-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
  z-index: 500;
  max-height: 220px;
  overflow-y: auto;
  overflow-x: hidden;
}
.autocomplete-dropdown.open { display: block; }

.autocomplete-item {
  display: flex;
  align-items: center;
  padding: 9px 13px;
  font-size: 13px;
  color: var(--text2);
  cursor: pointer;
  transition: background .1s;
  gap: 6px;
}
.autocomplete-item:hover { background: var(--bg4); color: var(--text); }
.autocomplete-item:first-child { border-radius: 8px 8px 0 0; }
.autocomplete-item:last-child  { border-radius: 0 0 8px 8px; }
.autocomplete-empty {
  color: var(--text3);
  cursor: default;
  font-size: 12px;
  justify-content: center;
}
.autocomplete-empty:hover { background: transparent; }

/* ── Custom Select (dropdown estilizado) ─────────────────────────────────── */
.custom-select-wrap {
  position: relative;
}
.custom-select-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 13px;
  color: var(--text);
  font-size: 13px;
  font-family: 'Outfit', sans-serif;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
  user-select: none;
}
.custom-select-trigger:hover {
  border-color: var(--border2);
}
.custom-select-wrap.open .custom-select-trigger {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59,130,246,.12);
}
.custom-select-arrow {
  font-size: 11px;
  color: var(--text3);
  transition: transform .2s;
  flex-shrink: 0;
  margin-left: 8px;
}
.custom-select-wrap.open .custom-select-arrow {
  transform: rotate(180deg);
}
.custom-select-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
  z-index: 600;
  max-height: 220px;
  overflow-y: auto;
  overflow-x: hidden;
}
.custom-select-wrap.open .custom-select-dropdown { display: block; }
body.light .custom-select-trigger { background: #fff; border-color: var(--border); }
body.light .custom-select-dropdown { background: #fff; border-color: var(--border2); box-shadow: 0 8px 24px rgba(0,0,0,.12); }

/* ── Ticket search bar ───────────────────────────────────────────────────── */
.tickets-toolbar {
  margin-bottom: 12px;
}
.ticket-search-wrap {
  display: flex;
  align-items: center;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0 14px;
  gap: 10px;
  transition: border-color .2s, box-shadow .2s;
}
.ticket-search-wrap:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59,130,246,.1);
}
.ticket-search-icon {
  font-size: 14px;
  flex-shrink: 0;
  opacity: .6;
}
.ticket-search-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 13px;
  font-family: 'Outfit', sans-serif;
  padding: 11px 0;
  min-width: 0;
}
.ticket-search-input::placeholder { color: var(--text3); }
.ticket-search-clear {
  background: none;
  border: none;
  color: var(--text3);
  cursor: pointer;
  font-size: 12px;
  padding: 3px 5px;
  border-radius: 4px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: color .1s, background .1s;
}
.ticket-search-clear:hover {
  color: var(--text);
  background: var(--bg4);
}

/* ── Inventory toolbar ───────────────────────────────────────────────────── */
.inv-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.inv-company-filter {
  position: relative;
  flex: 1;
  min-width: 180px;
  max-width: 280px;
}
.inv-company-input {
  padding-right: 32px !important;
  font-size: 13px;
}
.inv-company-clear {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text3);
  cursor: pointer;
  font-size: 11px;
  padding: 2px 4px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  line-height: 1;
}
.inv-company-clear:hover { color: var(--text); background: var(--bg4); }

/* ── Active filter tags ──────────────────────────────────────────────────── */
.inv-filter-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--accent-dim);
  border: 1px solid var(--accent);
  color: var(--accent2);
  font-size: 11px;
  font-family: 'JetBrains Mono', monospace;
  padding: 3px 8px 3px 10px;
  border-radius: 20px;
}
.inv-filter-tag button {
  background: none;
  border: none;
  color: var(--accent2);
  cursor: pointer;
  font-size: 11px;
  padding: 0;
  line-height: 1;
  opacity: .7;
}
.inv-filter-tag button:hover { opacity: 1; }

@media (max-width: 640px) {
  .inv-toolbar { gap: 8px; }
  .inv-company-filter { max-width: 100%; min-width: 0; flex: 1 1 100%; order: -1; }
}

/* ── Dashboard bottom grid ───────────────────────────────────────────────── */
.dash-bottom-grid {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 16px;
  margin-bottom: 18px;
}
@media (max-width: 1100px) {
  .dash-bottom-grid { grid-template-columns: 1fr 280px; }
}
@media (max-width: 900px) {
  .dash-bottom-grid { grid-template-columns: 1fr; }
}

/* ── Machines widget ─────────────────────────────────────────────────────── */
.dash-machines-card {
  min-height: 200px;
}
.dash-machine-count {
  font-family: 'Syne', sans-serif;
  font-size: 20px;
  font-weight: 800;
  color: var(--text);
}
.dash-machine-count.online { color: var(--green); }

.dash-machine-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  cursor: pointer;
  transition: background .1s;
}
.dash-machine-row:hover { background: var(--bg3); }
.dash-machine-row:last-child { border-bottom: none !important; }

/* ── KB active category ──────────────────────────────────────────────────── */
.kb-cat-card.kb-cat-active {
  border-color: var(--accent);
  background: var(--accent-dim);
}
.kb-cat-card.kb-cat-active .kb-cat-name { color: var(--accent2); }

/* ── Dashboard charts grid ───────────────────────────────────────────────── */
.dash-charts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 18px;
}
@media (max-width: 1000px) {
  .dash-charts-grid { grid-template-columns: 1fr; }
}

/* ── Paste zone ──────────────────────────────────────────────────────────── */
.paste-zone { position: relative; }

.paste-zone.drag-over .form-textarea {
  border-color: var(--accent) !important;
  background: var(--accent-dim) !important;
}

.paste-overlay {
  position: absolute;
  inset: 0;
  background: var(--accent-dim);
  border: 2px dashed var(--accent);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  pointer-events: none;
}
.paste-overlay-inner {
  font-size: 14px;
  font-weight: 600;
  color: var(--accent2);
}

/* Preview das imagens coladas */
.paste-preview-item {
  position: relative;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg3);
}
.paste-preview-item img {
  display: block;
  max-height: 80px;
  max-width: 120px;
  object-fit: cover;
}
.paste-preview-remove {
  position: absolute;
  top: 2px; right: 2px;
  background: rgba(0,0,0,.7);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 18px; height: 18px;
  font-size: 10px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  line-height: 1;
}
.paste-preview-remove:hover { background: var(--red); }
.paste-preview-uploading {
  position: absolute; inset: 0;
  background: rgba(0,0,0,.5);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
}

/* ── Global Search ───────────────────────────────────────────────────────── */
@keyframes slideInRight {
  from { transform: translateX(20px); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

.gs-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.6);
  z-index: 1000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 80px;
  opacity: 0;
  transition: opacity .2s;
}
.gs-overlay.open { opacity: 1; }

.gs-modal {
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: 14px;
  width: 560px;
  max-width: calc(100vw - 32px);
  max-height: 70vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
  transform: translateY(-10px);
  transition: transform .2s;
}
.gs-overlay.open .gs-modal { transform: translateY(0); }

.gs-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.gs-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 15px;
  font-family: 'Outfit', sans-serif;
}
.gs-input::placeholder { color: var(--text3); }

.gs-results {
  overflow-y: auto;
  max-height: calc(70vh - 60px);
}
.gs-section {
  padding: 8px 16px 4px;
  font-size: 10px;
  font-family: 'JetBrains Mono', monospace;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: .5px;
  border-top: 1px solid var(--border);
}
.gs-section:first-child { border-top: none; }
.gs-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  cursor: pointer;
  transition: background .1s;
}
.gs-item:hover { background: var(--bg3); }
.gs-id {
  font-size: 11px;
  font-family: 'JetBrains Mono', monospace;
  color: var(--accent2);
  flex-shrink: 0;
}
.gs-title {
  font-size: 13px;
  color: var(--text);
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.gs-meta {
  font-size: 11px;
  color: var(--text3);
  flex-shrink: 0;
  max-width: 120px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}


/* ══════════════════════════════════════════════════════════════════════════
   LIGHT MODE OVERRIDES — corrigir textos que somem no tema claro
   ══════════════════════════════════════════════════════════════════════════ */
body.light .stat-card          { background: #fff; border-color: var(--border); }
body.light .stat-label         { color: var(--text3); }
body.light .stat-sub           { color: var(--text3); }

body.light .card               { background: #fff; border-color: var(--border); }
body.light .card-header        { border-bottom-color: var(--border); }

body.light .table thead th     { background: var(--bg3); color: var(--text3); border-bottom-color: var(--border); }
body.light .table tbody tr:hover { background: var(--bg3); }
body.light .ticket-id          { color: var(--accent); }
body.light .ticket-title       { color: var(--text); }

body.light .modal              { background: #fff; border-color: var(--border); }
body.light .modal-header       { border-bottom-color: var(--border); background: var(--bg3); }
body.light .modal-footer       { border-top-color: var(--border); background: var(--bg3); }
body.light .modal-body         { background: #fff; }

body.light .form-input,
body.light .form-select,
body.light .form-textarea      { background: #fff; border-color: var(--border2); color: var(--text); }
body.light .form-input:focus,
body.light .form-select:focus,
body.light .form-textarea:focus { border-color: var(--accent); }
body.light .form-label         { color: var(--text2); }

body.light .nav-item           { color: var(--text2); }
body.light .nav-item:hover     { background: var(--bg3); color: var(--text); }
body.light .nav-item.active    { color: var(--accent); }
body.light .nav-label          { color: var(--text3); }

body.light .sidebar            { background: #fff; border-right-color: var(--border); }
body.light .logo               { border-bottom-color: var(--border); }
body.light .sidebar-footer     { border-top-color: var(--border); background: var(--bg3); }
body.light .user-name          { color: var(--text); }
body.light .user-role          { color: var(--text3); }
body.light .logout-btn         { color: var(--text3); }

body.light .topbar             { background: #fff; border-bottom-color: var(--border); box-shadow: 0 1px 4px rgba(0,0,0,.08); }
body.light .page-title         { color: var(--text); }

body.light .filter-chip        { background: var(--bg3); color: var(--text2); border-color: var(--border); }
body.light .filter-chip.active { background: var(--accent-dim); color: var(--accent); border-color: var(--accent); }

body.light .company-card       { background: #fff; border-color: var(--border); }
body.light .company-status     { background: var(--bg3); }

body.light .machine-card       { background: #fff; border-color: var(--border); }
body.light .machine-empresa    { color: var(--text3); }
body.light .spec-label         { color: var(--text3); }
body.light .spec-val           { color: var(--text2); }
body.light .spec-block         { background: var(--bg3); }
body.light .spec-block-label   { color: var(--text3); }
body.light .spec-block-sub     { color: var(--text3); }

body.light .agent-section      { background: var(--bg3); border-color: var(--border); }
body.light .agent-desc         { color: var(--text2); }
body.light .step-num           { background: var(--accent-dim); color: var(--accent); }
body.light .step-text          { color: var(--text2); }
body.light .code-block         { background: var(--bg3); border-color: var(--border); color: var(--text); }

body.light .att-card           { background: #fff; border-color: var(--border); }
body.light .att-name           { color: var(--text); }
body.light .att-email          { color: var(--text3); }
body.light .att-role           { color: var(--text3); }

body.light .perm-label         { color: var(--text2); }
body.light .perm-section       { border-top-color: var(--border); }
body.light .perm-title         { color: var(--text3); }

body.light .kb-cat-card        { background: #fff; border-color: var(--border); }
body.light .kb-cat-name        { color: var(--text); }
body.light .kb-cat-count       { color: var(--text3); }
body.light .kb-article         { background: var(--bg3); border-color: var(--border); }
body.light .kb-article-title   { color: var(--text); }
body.light .kb-article-meta    { color: var(--text3); }

body.light .autocomplete-dropdown { background: #fff; border-color: var(--border2); box-shadow: 0 8px 24px rgba(0,0,0,.12); }
body.light .autocomplete-item  { color: var(--text2); }
body.light .autocomplete-item:hover { background: var(--bg3); color: var(--text); }

body.light .ticket-search-wrap { background: #fff; }
body.light .ticket-search-input { color: var(--text); }

body.light .dash-machine-row:hover { background: var(--bg3); }
body.light .gs-modal           { background: #fff; border-color: var(--border2); }
body.light .gs-header          { border-bottom-color: var(--border); }
body.light .gs-section         { border-top-color: var(--border); color: var(--text3); }
body.light .gs-item:hover      { background: var(--bg3); }
body.light .gs-title           { color: var(--text); }

body.light .toast              { background: var(--accent); color: #fff; }
body.light .toast.error        { background: var(--red); }

body.light .access-denied      { color: var(--text); }
body.light .inv-filter-tag     { background: var(--accent-dim); }

/* ══════════════════════════════════════════════════════════════════════════
   MOBILE FIXES — correções específicas para celular
   ══════════════════════════════════════════════════════════════════════════ */

/* Garantir que cards nunca somam — overflow hidden pode ocultar */
@media (max-width: 900px) {
  .company-card,
  .machine-card,
  .kb-cat-card,
  .att-card { 
    min-width: 0; 
    width: 100%;
    box-sizing: border-box;
  }

  /* Inventário toolbar: filtros em coluna no mobile */
  .inv-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  .inv-toolbar > div:first-child {
    flex-direction: column;
    gap: 6px;
  }
  .inv-company-filter {
    max-width: 100%;
    width: 100%;
  }

  /* Agente: grid Windows/Linux passa para coluna única */
  #agentContent [style*="grid-template-columns:1fr 1fr"],
  #agentContent [style*="grid-template-columns: 1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }

  /* Botão abrir ticket — mostrar label no mobile */
  .topbar-btn-new::after {
    content: 'Ticket';
    font-size: 12px;
    margin-left: 4px;
  }
}

@media (max-width: 640px) {
  /* Stats grid de relatório: 2 colunas */
  .stats-grid[style*="repeat(5"] {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  /* Cards de empresa — garantir visibilidade */
  .companies-grid,
  .kb-grid {
    overflow: visible !important;
    display: grid !important;
    grid-template-columns: 1fr !important;
  }

  /* Machine card: specs em 2 colunas */
  .machine-specs { 
    display: grid; 
    grid-template-columns: 1fr 1fr; 
    gap: 4px; 
  }

  /* Topbar: comprimir para caber em telas pequenas */
  .topbar-actions { gap: 4px; }
  .topbar-link-btn { padding: 6px 8px; font-size: 11px; }

  /* Dash charts: 1 coluna */
  .dash-charts-grid { grid-template-columns: 1fr !important; }
}

/* ── Agenda ───────────────────────────────────────────────────────────────── */
.agenda-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 10px;
  flex-wrap: wrap;
}
.agenda-section-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: .6px;
  margin-bottom: 10px;
  font-family: 'JetBrains Mono', monospace;
}
.agenda-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: background .15s, transform .15s;
}
.agenda-card:hover { background: var(--bg3); transform: translateX(2px); }
.agenda-card-hoje {
  background: rgba(59,130,246,.06);
  border-color: var(--accent);
  box-shadow: 0 2px 12px rgba(59,130,246,.12);
}
.agenda-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 4px;
}
.agenda-cor-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.agenda-card-titulo {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.agenda-card-desc {
  font-size: 12px;
  color: var(--text3);
  margin: 4px 0 6px 20px;
  line-height: 1.5;
}
.agenda-card-rec {
  font-size: 11px;
  color: var(--text3);
  font-family: 'JetBrains Mono', monospace;
  margin-left: 20px;
}
.agenda-hora {
  font-size: 11px;
  color: var(--text3);
  font-family: 'JetBrains Mono', monospace;
  white-space: nowrap;
}
.agenda-action-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  padding: 3px 5px;
  border-radius: 5px;
  opacity: .6;
  transition: opacity .15s, background .15s;
}
.agenda-action-btn:hover { opacity: 1; background: var(--bg4); }
.agenda-del-btn:hover { background: rgba(239,68,68,.12); }

/* Cor picker no modal */
.agenda-cor-opt {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform .15s, border-color .15s;
  flex-shrink: 0;
}
.agenda-cor-opt:hover { transform: scale(1.15); }
.agenda-cor-opt.active {
  border-color: #fff;
  box-shadow: 0 0 0 2px var(--accent);
  transform: scale(1.1);
}

/* Botões de dia (semana / mês) */
.agenda-day-btn {
  min-width: 36px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
  background: var(--bg3);
  border: 1px solid var(--border);
  font-size: 12px;
  font-weight: 600;
  color: var(--text3);
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
  user-select: none;
  padding: 0 8px;
}
.agenda-day-btn:hover { border-color: var(--accent); color: var(--text); }
.agenda-day-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
