:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --border: #e3e6eb;
  --text: #1b1f27;
  --muted: #6b7280;
  --accent: #2f5bff;
  --accent-dark: #1f42cc;
  --danger: #c0392b;
  --radius: 10px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0; }
h2 { font-size: 17px; margin: 0 0 8px; }
h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 18px 0 6px; }

.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.mono { font-family: var(--mono); font-size: 13px; }
.hint { font-size: 13px; color: var(--muted); margin: 6px 0 0; }

/* layout */
.topbar {
  display: flex; align-items: center; gap: 24px;
  padding: 0 24px; height: 56px;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { font-weight: 650; color: var(--text); }
.brand span { color: var(--accent); }
.topbar nav { display: flex; align-items: center; gap: 18px; flex: 1; }
.topbar nav a { color: var(--text); font-size: 14px; }
.session { display: flex; align-items: center; gap: 12px; font-size: 13px; color: var(--muted); }
.linklike { background: none; border: 0; color: var(--accent); cursor: pointer; font-size: 13px; padding: 0; }

.page { max-width: 1080px; margin: 0 auto; padding: 28px 24px 64px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.page-head.compact { margin-bottom: 8px; align-items: center; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.row input { flex: 1; min-width: 140px; }
.cols { display: grid; grid-template-columns: 1fr 300px; gap: 20px; align-items: start; }
.ticket-layout { display: grid; grid-template-columns: 1fr 280px; gap: 20px; align-items: start; }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px;
}

/* forms */
label { display: block; font-size: 13px; font-weight: 550; }
input, select, textarea {
  width: 100%; margin-top: 5px; padding: 9px 11px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text);
  font: inherit; font-weight: 400;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }
fieldset { border: 0; padding: 0; margin: 0; }
legend { font-size: 13px; font-weight: 550; padding: 0; }
label.inline { display: flex; align-items: center; gap: 8px; font-weight: 400; }
label.inline input { width: auto; margin: 0; }
.actions { display: flex; gap: 10px; }

.options { display: grid; gap: 8px; margin-top: 8px; }
.option {
  display: flex; gap: 10px; align-items: flex-start;
  border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px;
  cursor: pointer; font-weight: 400; background: var(--surface);
}
.option:has(input:checked) { border-color: var(--accent); background: #f2f5ff; }
.option input { width: auto; margin: 3px 0 0; }
.option small { display: block; color: var(--muted); }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 9px 16px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text);
  font-size: 14px; font-weight: 550; cursor: pointer; text-decoration: none;
}
.btn:hover { text-decoration: none; border-color: var(--muted); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.btn-sm { padding: 6px 12px; font-size: 13px; }

/* alerts */
.alert { padding: 11px 14px; border-radius: 8px; background: #eef1f6; margin-bottom: 16px; font-size: 14px; }
.alert-error { background: #fdecea; color: var(--danger); }

/* tables */
.table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 11px 14px; border-bottom: 1px solid var(--border); font-weight: 600; }
.table td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #fafbfd; cursor: pointer; }

ul.plain { list-style: none; padding: 0; margin: 0; }
ul.plain li { padding: 5px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
ul.plain li:last-child { border-bottom: 0; }

/* badges */
.badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: #eef1f6; color: var(--muted); white-space: nowrap; }
.badge-muted { background: #eef1f6; color: #4b5563; }
.badge-internal { background: #fff4d6; color: #92670a; }
.status-new { background: #e4ecff; color: #1f42cc; }
.status-analyzing { background: #ede4ff; color: #5b32c4; }
.status-in_progress { background: #dff3e6; color: #157347; }
.status-waiting_customer { background: #fff1d9; color: #9a6400; }
.status-resolved { background: #e3f2ec; color: #0f6b4b; }
.status-closed { background: #eceef2; color: #5b6270; }
.prio-p1 { background: #fdecea; color: #b02a1c; }
.prio-p2 { background: #fff0e2; color: #a45312; }
.prio-p3 { background: #eef1f6; color: #4b5563; }
.prio-p4 { background: #f2f4f7; color: #7a828f; }

/* stats */
.stats { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.stat {
  flex: 1 1 120px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 14px; color: var(--text);
}
.stat:hover { border-color: var(--muted); text-decoration: none; }
.stat.active { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.stat-value { display: block; font-size: 22px; font-weight: 650; }
.stat-label { display: block; font-size: 12.5px; color: var(--muted); }
.filters { margin-bottom: 16px; max-width: 320px; }

/* timeline */
.timeline { display: flex; flex-direction: column; gap: 14px; }
.message { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.message header { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; font-size: 13.5px; }
.message .body { white-space: pre-wrap; }
.message.from-team { border-left: 3px solid var(--accent); }
.message.internal { border-left: 3px solid #e0a800; background: #fffcf3; }

.sidebar dl { margin: 0; display: grid; grid-template-columns: 1fr; gap: 2px; }
.sidebar dt { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-top: 12px; }
.sidebar dd { margin: 0; font-size: 14px; }

/* misc */
.empty { text-align: center; padding: 56px 20px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.empty h1 { font-size: 40px; }
.empty p { color: var(--muted); }

.auth-card { max-width: 380px; margin: 8vh auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 28px; }
.auth-brand { font-size: 20px; font-weight: 650; }
.auth-brand span { color: var(--accent); }
.auth-card p { margin: 4px 0 20px; font-size: 14px; }
.auth-card h1 { margin: 18px 0 8px; }
.auth-alt { margin: 18px 0 0 !important; font-size: 13.5px; color: var(--muted); text-align: center; }

/* páginas públicas (cliente, sem login) */
.public-top {
  display: flex; align-items: baseline; justify-content: space-between; gap: 16px;
  padding: 16px 24px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.public-foot { max-width: 720px; margin: 0 auto; padding: 0 24px 48px; text-align: center; }
.page-narrow { max-width: 720px; padding-bottom: 32px; }
.alert-ok { background: #e3f2ec; color: #0f6b4b; }

.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.factline {
  display: flex; flex-wrap: wrap; gap: 8px 28px; margin: 0 0 20px;
  padding: 14px 16px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
}
.factline dt { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.factline dd { margin: 2px 0 0; font-size: 14px; }

.copyable { background: #f7f8fa; cursor: text; }

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

@media (max-width: 860px) {
  .ticket-layout, .cols { grid-template-columns: 1fr; }
  .topbar { gap: 14px; padding: 0 14px; }
  .page { padding: 20px 14px 48px; }
}
