:root {
  --ink: #17222c;
  --ink-2: #4a5a68;
  --muted: #7b8894;
  --paper: #f3f5f7;
  --card: #ffffff;
  --line: #dfe5ea;
  --brand: #0d6f8f;
  --brand-ink: #0a566f;
  --brand-soft: #e2f1f6;
  --note: #fff7d6;
  --note-line: #efd98a;
  --note-ink: #6b5200;
  --ok: #1f8a5b;  --ok-soft: #e1f4ea;
  --warn: #c98200; --warn-soft: #fff1d6;
  --bad: #c8393b;  --bad-soft: #fbe4e4;
  --radius: 10px;
  --side: 232px;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--paper); color: var(--ink); font-size: 15px; line-height: 1.45; min-height: 100vh; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.2; letter-spacing: -.01em; }
h1 { font-size: 1.55rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }
p { margin: 0 0 .75rem; }
small, .muted { color: var(--muted); }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* ---------- layout */
.side {
  position: fixed; inset: 0 auto 0 0; width: var(--side); background: var(--ink); color: #dfe7ee;
  display: flex; flex-direction: column; padding: 18px 14px; gap: 18px; overflow-y: auto;
}
.main { margin-left: var(--side); padding: 28px 36px 60px; max-width: 1240px; }
body.auth .main { margin: 0; padding: 0; max-width: none; }
.brand { display: flex; gap: 10px; align-items: center; color: #fff; padding: 4px 6px; }
.brand:hover { text-decoration: none; }
.brand-mark { background: var(--brand); color: #fff; font-weight: 800; font-size: .8rem; letter-spacing: .08em; padding: 8px 7px; border-radius: 8px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text small { color: #9fb0bd; font-size: .72rem; }
.side nav { display: flex; flex-direction: column; gap: 2px; }
.side nav a { color: #c9d4dd; padding: 8px 10px; border-radius: 7px; font-size: .93rem; }
.side nav a:hover { background: rgba(255,255,255,.07); text-decoration: none; color: #fff; }
.side nav a.on { background: var(--brand); color: #fff; }
.nav-sep { font-size: .68rem; text-transform: uppercase; letter-spacing: .1em; color: #7d8d9a; padding: 14px 10px 4px; }
.side-user { margin-top: auto; border-top: 1px solid rgba(255,255,255,.12); padding-top: 14px; font-size: .88rem; }
.side-user b { display: block; color: #fff; }
.side-user small { display: block; color: #9fb0bd; }
.side-user-links { display: flex; gap: 12px; margin-top: 6px; }
.side-user-links a { color: #c9d4dd; font-size: .85rem; }
.menu-btn { display: none; }

/* ---------- headers & cards */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); margin: 2px 0 0; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; }
.card + .card { margin-top: 16px; }
.card h2 { margin-bottom: 12px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.grid-5 { grid-template-columns: repeat(5, minmax(0,1fr)); }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat b { display: block; font-size: 1.7rem; line-height: 1.1; }
.stat span { color: var(--muted); font-size: .85rem; }
.stat.bad b { color: var(--bad); } .stat.warn b { color: var(--warn); } .stat.ok b { color: var(--ok); }
.stat.highlight { border-color: var(--brand); background: var(--brand-soft); }
.stat.highlight b { color: var(--brand-ink); }

/* ---------- buttons */
.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink); font: inherit; font-size: .92rem; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: #f5f7f9; text-decoration: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-ink); }
.btn.danger { color: var(--bad); border-color: #efc7c7; }
.btn.sm { padding: 5px 10px; font-size: .82rem; }
.btn.block { width: 100%; justify-content: center; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- forms */
label { display: block; font-size: .85rem; font-weight: 600; color: var(--ink-2); margin-bottom: 4px; }
input[type=text], input[type=email], input[type=password], input[type=url], input[type=tel], input[type=date], input[type=number], input[type=time], select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; font: inherit; background: #fff; color: var(--ink);
}
textarea { min-height: 110px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--brand); outline: none; box-shadow: 0 0 0 3px rgba(13,111,143,.15); }
.field { margin-bottom: 14px; }
.field .hint { font-size: .8rem; color: var(--muted); margin-top: 4px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: end; }
.row > * { flex: 1 1 160px; }
.row > .auto { flex: 0 0 auto; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.check input { width: auto; }
input[type=file] { font-size: .88rem; }

/* ---------- chips */
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; font-size: .78rem; font-weight: 600; white-space: nowrap; }
.chip.analise { background: #e7ebef; color: #45535f; }
.chip.andamento { background: var(--brand-soft); color: var(--brand-ink); }
.chip.aguardando { background: var(--warn-soft); color: #8a5a00; }
.chip.finalizado { background: var(--ok-soft); color: #196a48; }
.chip.urgente { background: var(--bad-soft); color: var(--bad); }
.chip.baixa, .chip.normal { background: #eef1f4; color: var(--ink-2); }
.chip.ok { background: var(--ok-soft); color: #196a48; }
.chip.warn { background: var(--warn-soft); color: #8a5a00; }
.chip.bad { background: var(--bad-soft); color: var(--bad); }
.chip.neutral { background: #eef1f4; color: var(--ink-2); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot.ok { background: var(--ok); } .dot.warn { background: var(--warn); } .dot.bad { background: var(--bad); }

/* ---------- tables */
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: 10px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: .76rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #f8fafb; }
td.num, th.num { text-align: right; }
.table-card { padding: 0; overflow-x: auto; }
.table-card table { min-width: 640px; }
.table-card th:first-child, .table-card td:first-child { padding-left: 18px; }
.table-card th:last-child, .table-card td:last-child { padding-right: 18px; }
.ticket-title { font-weight: 600; color: var(--ink); }
.ticket-title:hover { color: var(--brand); }
.proto { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .82rem; color: var(--muted); }

.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; margin-bottom: 14px; }
.filters > * { flex: 0 1 180px; }
.filters .grow { flex: 1 1 220px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; flex-wrap: wrap; }
.tabs a { padding: 8px 12px; color: var(--ink-2); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.on { color: var(--brand-ink); border-color: var(--brand); font-weight: 600; }
.tabs a:hover { text-decoration: none; color: var(--brand); }

/* ---------- flashes */
.flashes { margin-bottom: 16px; }
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 8px; font-size: .92rem; border: 1px solid; }
.flash.ok { background: var(--ok-soft); border-color: #b9e3cc; color: #196a48; }
.flash.error { background: var(--bad-soft); border-color: #f0bcbc; color: var(--bad); }
.flash.warn { background: var(--warn-soft); border-color: #f2d9a3; color: #8a5a00; }
.flash.message { background: var(--brand-soft); border-color: #b9dbe7; color: var(--brand-ink); }

/* ---------- ticket detail */
.ticket-layout { display: grid; grid-template-columns: minmax(0,1fr) 300px; gap: 18px; align-items: start; }
.ticket-head { margin-bottom: 18px; }
.ticket-head h1 { font-size: 1.4rem; }
.ticket-head .meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; color: var(--muted); font-size: .9rem; }
.sla-bar { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 16px 0 0; }
.sla { border: 1px solid var(--line); border-left: 4px solid var(--muted); border-radius: 8px; padding: 10px 14px; background: var(--card); }
.sla.ok { border-left-color: var(--ok); } .sla.warn { border-left-color: var(--warn); } .sla.bad { border-left-color: var(--bad); }
.sla small { display: block; font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; }
.sla b { font-size: 1.05rem; }
.sla .sub { font-size: .82rem; color: var(--muted); }
.sla .meter { height: 5px; background: #e9edf1; border-radius: 4px; margin-top: 8px; overflow: hidden; }
.sla .meter i { display: block; height: 100%; background: var(--ok); }
.sla.warn .meter i { background: var(--warn); } .sla.bad .meter i { background: var(--bad); }

.timeline { display: flex; flex-direction: column; gap: 12px; }
.msg { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.msg.team { border-left: 4px solid var(--brand); }
.msg.partner { border-left: 4px solid #b7c3cd; }
.msg.internal { background: var(--note); border-color: var(--note-line); border-left: 4px solid #d9b93f; margin-left: 28px; }
.msg.system { background: transparent; border: 1px dashed var(--line); color: var(--muted); font-size: .9rem; }
.msg-head { display: flex; justify-content: space-between; gap: 10px; font-size: .85rem; margin-bottom: 6px; flex-wrap: wrap; }
.msg-head b { color: var(--ink); }
.msg.internal .msg-head b { color: var(--note-ink); }
.lock { font-size: .75rem; font-weight: 700; color: var(--note-ink); background: #fbe9a4; padding: 2px 7px; border-radius: 4px; }
.msg-body { white-space: normal; word-break: break-word; }
.msg-body a { word-break: break-all; }
.atts { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.att { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; background: #f4f6f8; border: 1px solid var(--line); border-radius: 7px; font-size: .84rem; color: var(--ink); }
.att img { max-height: 120px; max-width: 200px; border-radius: 5px; display: block; }
.att.img { padding: 4px; }
.desc { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 14px; }

.reply { margin-top: 18px; }
.reply-tabs { display: flex; gap: 0; margin-bottom: -1px; }
.reply-tabs button { font: inherit; padding: 9px 16px; border: 1px solid var(--line); border-bottom: 0; background: #eef1f4; color: var(--ink-2); border-radius: 8px 8px 0 0; cursor: pointer; }
.reply-tabs button.on { background: var(--card); color: var(--ink); font-weight: 600; }
.reply-tabs button.on.note { background: var(--note); color: var(--note-ink); }
.reply-box { background: var(--card); border: 1px solid var(--line); border-radius: 0 8px 8px 8px; padding: 14px 16px; }
.reply-box.note { background: var(--note); border-color: var(--note-line); }
.reply-box .foot { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; justify-content: space-between; margin-top: 10px; }
.reply-box .foot > div { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.notify-list { display: flex; gap: 10px; flex-wrap: wrap; margin: 8px 0 0; }
.notify-list label { font-weight: 500; display: inline-flex; gap: 5px; align-items: center; margin: 0; }
.notify-list input { width: auto; }

.side-panel .card { padding: 14px 16px; }
.kv { display: grid; grid-template-columns: 105px 1fr; gap: 6px 10px; font-size: .9rem; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }
.events { list-style: none; margin: 0; padding: 0; font-size: .82rem; color: var(--ink-2); }
.events li { padding: 5px 0; border-bottom: 1px dashed var(--line); }
.events li:last-child { border: 0; }
.events time { color: var(--muted); display: block; font-size: .75rem; }

.stars { display: flex; gap: 4px; flex-direction: row-reverse; justify-content: flex-end; }
.stars input { display: none; }
.stars label { font-size: 1.8rem; color: #ccd4da; cursor: pointer; margin: 0; }
.stars input:checked ~ label, .stars label:hover, .stars label:hover ~ label { color: #e5a400; }
.star-show { color: #e5a400; letter-spacing: 1px; }

/* ---------- lists */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); align-items: center; }
.list li:last-child { border: 0; }
.list .who { color: var(--muted); font-size: .85rem; }
.empty { color: var(--muted); padding: 24px; text-align: center; border: 1px dashed var(--line); border-radius: var(--radius); }

/* ---------- FAQ */
details { border: 1px solid var(--line); border-radius: 8px; background: var(--card); padding: 0 16px; margin-bottom: 8px; }
summary { cursor: pointer; padding: 12px 0; font-weight: 600; }
details p { padding-bottom: 12px; }

/* ---------- login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(160deg, #17222c 0%, #0d6f8f 100%); padding: 20px; }
.login { background: #fff; border-radius: 14px; padding: 32px 30px; width: 100%; max-width: 380px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.login .brand { color: var(--ink); padding: 0; margin-bottom: 20px; }
.login .brand-text small { color: var(--muted); }

.email-body { white-space: pre-wrap; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .82rem; background: #f7f9fa; padding: 12px; border-radius: 8px; margin-top: 8px; }

@media (max-width: 900px) {
  .side { transform: translateX(-100%); transition: transform .2s; z-index: 20; }
  body.nav-open .side { transform: none; }
  .menu-btn { display: block; position: fixed; top: 10px; left: 10px; z-index: 30; border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 6px 10px; font-size: 1.1rem; }
  .main { margin-left: 0; padding: 60px 16px 40px; }
  .grid-2, .grid-3, .grid-4, .grid-5 { grid-template-columns: 1fr 1fr; }
  .ticket-layout { grid-template-columns: 1fr; }
  .sla-bar { grid-template-columns: 1fr; }
  .msg.internal { margin-left: 0; }
}
@media (max-width: 560px) { .grid-2, .grid-3, .grid-4, .grid-5 { grid-template-columns: 1fr; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
