:root {
  --navy: #0e2a47;
  --navy-soft: #1a3b62;
  --accent: #ff7a1a;
  --accent-soft: #fff1e3;
  --bg: #f3f5f9;
  --card: #ffffff;
  --text: #1a2436;
  --muted: #6b7280;
  --border: #e3e7ee;
  --shadow: 0 4px 14px rgba(7, 24, 42, 0.06);
}

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

.topbar {
  background: var(--navy);
  color: white;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 3px solid var(--accent);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 38px; height: 38px;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 13px;
}
.brand-text strong { display: block; font-size: 15px; }
.brand-text span { font-size: 12px; opacity: 0.85; }
.topbar-actions { display: flex; align-items: center; gap: 14px; }
.kpi { font-size: 13px; opacity: 0.85; }

.cta {
  background: var(--accent);
  color: white;
  border: none;
  padding: 9px 14px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
}
.cta:hover { filter: brightness(1.05); }
.ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 9px 14px; border-radius: 8px; font-size: 13px; cursor: pointer;
}
.ghost:hover { color: var(--text); }

main {
  display: grid;
  grid-template-columns: 220px 1fr 1.2fr;
  gap: 18px;
  padding: 18px 24px;
  min-height: calc(100vh - 65px);
}
@media (max-width: 1024px) {
  main { grid-template-columns: 1fr; }
  .detail { order: 3; }
}

.filters {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  height: fit-content;
  box-shadow: var(--shadow);
}
.filters h2 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.5px; margin: 0 0 12px; color: var(--muted); }
.filters label { display: block; margin-bottom: 12px; }
.filters label span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.filters input, .filters select {
  width: 100%; padding: 8px 10px;
  border: 1px solid var(--border); border-radius: 6px;
  background: white; font-size: 13px;
}

.content {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  box-shadow: var(--shadow);
}
.list-header { display: flex; align-items: baseline; justify-content: space-between; padding: 4px 8px 14px; }
.list-header h1 { margin: 0; font-size: 18px; color: var(--navy); }
.muted { color: var(--muted); font-size: 13px; }

.ticket-list { list-style: none; margin: 0; padding: 0; }
.ticket-list li {
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  margin-bottom: 4px;
  transition: background 0.1s;
}
.ticket-list li:hover { background: #f8fafc; }
.ticket-list li.active { background: var(--accent-soft); border-color: #ffd6b3; }
.ticket-list .row1 { display: flex; align-items: center; gap: 8px; }
.ticket-list .row1 .subj { flex: 1; font-weight: 600; color: var(--navy); }
.ticket-list .row2 { display: flex; align-items: center; gap: 8px; margin-top: 4px; font-size: 12px; color: var(--muted); }
.tag {
  display: inline-block;
  padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.3px;
}
.tag.sw-sage { background: #e0e7ff; color: #3730a3; }
.tag.sw-silae { background: #d1fae5; color: #065f46; }
.tag.sw-lucca { background: #fce7f3; color: #9d174d; }
.tag.status-open { background: #fee2e2; color: #991b1b; }
.tag.status-in_progress { background: #fff1e3; color: #9a3412; }
.tag.status-waiting_client { background: #fef9c3; color: #854d0e; }
.tag.status-resolved { background: #d1fae5; color: #065f46; }
.tag.status-closed { background: #e5e7eb; color: #374151; }
.tag.prio-urgent { background: #fecaca; color: #7f1d1d; }
.tag.prio-high { background: #fed7aa; color: #7c2d12; }
.tag.prio-normal { background: #e5e7eb; color: #374151; }
.tag.prio-low { background: #f3f4f6; color: #6b7280; }

.detail {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 22px;
  box-shadow: var(--shadow);
  min-height: 320px;
}
.detail .placeholder { display: flex; align-items: center; justify-content: center; min-height: 280px; }
.detail h1 { margin: 0; color: var(--navy); font-size: 20px; }
.detail .meta { margin: 8px 0 18px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.detail .desc {
  padding: 14px; background: #f8fafc; border-radius: 8px;
  border-left: 3px solid var(--accent); white-space: pre-wrap;
  margin-bottom: 18px;
}
.detail .timeline { margin-top: 8px; }
.detail .msg {
  padding: 12px 14px; margin-bottom: 10px;
  border-radius: 8px; border: 1px solid var(--border);
  background: white;
}
.detail .msg.svd { background: var(--accent-soft); border-color: #ffd6b3; }
.detail .msg header { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-bottom: 6px; font-weight: 600; }
.detail .reply { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }
.detail .reply textarea { width: 100%; padding: 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 14px; font-family: inherit; }
.detail .status-bar { display: flex; gap: 10px; align-items: center; padding: 10px 0 14px; }
.detail .status-bar select { padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; }

.modal {
  position: fixed; inset: 0;
  background: rgba(7, 24, 42, 0.55);
  display: flex; align-items: center; justify-content: center;
  z-index: 50;
}
.modal[hidden] { display: none; }
.modal-card {
  background: white;
  border-radius: 12px;
  width: min(620px, 92vw);
  padding: 22px 26px;
  max-height: 92vh; overflow: auto;
}
.modal-card header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.modal-card header h2 { margin: 0; color: var(--navy); font-size: 18px; }
.modal-card header button { background: none; border: none; font-size: 18px; cursor: pointer; color: var(--muted); }

.modal-card form label { display: block; margin-bottom: 12px; font-size: 13px; }
.modal-card form label span { display: block; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.modal-card form input, .modal-card form select, .modal-card form textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px;
  font-size: 14px; font-family: inherit;
}
.modal-card form .row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.modal-card form .actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }
.error { color: #991b1b; font-size: 13px; margin: 4px 0 0; }
