:root {
  --bg: #f5f5fb;
  --card: #fff;
  --ink: #1d1d2b;
  --muted: #6b6b80;
  --line: #e2e2ec;
  --brand: #5549dc;
  --brand-ink: #fff;
  --ok: #1f8a4c;
  --warn: #b26a00;
  --bad: #c62828;
  --note: #fff8e1;
  --note-line: #f1d38a;
  --radius: 10px;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
a { color: var(--brand); }
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px; }
main.wrap { padding-top: 20px; padding-bottom: 60px; }
h1 { font-size: 22px; margin: 4px 0 16px; }
h2 { font-size: 17px; margin: 0 0 12px; }
h3 { font-size: 15px; margin: 0 0 8px; }

.top { background: var(--brand); color: var(--brand-ink); }
.top-inner { display: flex; align-items: center; gap: 20px; min-height: 54px; flex-wrap: wrap; }
.top a { color: var(--brand-ink); text-decoration: none; opacity: .85; }
.top a:hover, .top a.on { opacity: 1; }
.top a.on { border-bottom: 2px solid #fff; }
.brand { font-weight: 700; font-size: 17px; opacity: 1 !important; }
.top nav { display: flex; gap: 16px; flex: 1; flex-wrap: wrap; }
.me { display: flex; gap: 12px; align-items: center; }
.me form { margin: 0; }
.linkish { background: none; border: 0; color: var(--brand-ink); opacity: .85; cursor: pointer; font: inherit; padding: 0; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 16px; }
.narrow { max-width: 720px; }
.center { max-width: 420px; margin: 60px auto; }
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; }
.flash-ok { background: #e7f6ec; color: #145c32; }
.flash-err { background: #fdecec; color: #8e1c1c; }
.errors { background: #fdecec; color: #8e1c1c; padding: 10px 14px 10px 30px; border-radius: 8px; }

label { display: block; font-weight: 600; margin: 14px 0 6px; }
label.inline { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; margin: 0 14px 0 0; }
.hint { color: var(--muted); font-size: 13px; margin: 4px 0; font-weight: 400; }
input[type=text], input[type=email], input[type=url], input[type=search], input[type=number], select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid #cfcfdc; border-radius: 8px; font: inherit; background: #fff; color: inherit;
}
textarea { min-height: 130px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: -1px; }
.btn { display: inline-block; background: var(--brand); color: #fff; border: 0; border-radius: 8px; padding: 9px 18px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn:hover { filter: brightness(1.08); }
.btn-ghost { background: #fff; color: var(--brand); border: 1px solid var(--brand); }
.btn-google { background: #fff; color: #222; border: 1px solid #cfcfdc; width: 100%; text-align: center; }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.actions { margin-top: 18px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.or { text-align: center; color: var(--muted); margin: 18px 0 4px; }

.prio { display: flex; gap: 8px; flex-wrap: wrap; }
.prio label { margin: 0; font-weight: 500; border: 1px solid #cfcfdc; border-radius: 8px; padding: 8px 12px; cursor: pointer; display: flex; gap: 6px; align-items: center; }
.prio label:has(input:checked) { border-color: var(--brand); background: #eeecfd; }
.prio small { color: var(--muted); }

.files .file-list { list-style: none; padding: 0; margin: 8px 0 0; }
.files .file-list li { display: flex; align-items: center; gap: 10px; padding: 4px 0; font-size: 14px; }
.files .file-list img { width: 48px; height: 48px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); }
.files .file-list button { margin-left: auto; }
.files .file-list .too-big { color: var(--bad); }

table.list { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
table.list th, table.list td { padding: 9px 10px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; font-size: 14px; }
table.list th { background: #fafafe; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
table.list tr:last-child td { border-bottom: 0; }
table.list tr.clickable:hover { background: #fafaff; cursor: pointer; }
table.list a.t { color: var(--ink); text-decoration: none; font-weight: 600; }
.scroll-x { overflow-x: auto; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.nowrap { white-space: nowrap; }

.badge { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; background: #eee; }
.st-new { background: #e3e0ff; color: #3a2fb8; }
.st-open { background: #dff1ff; color: #0b5c99; }
.st-waiting { background: #fff1d6; color: #8a5300; }
.st-resolved { background: #e3f5e9; color: #1d6b3a; }
.pr-5 { background: #fde2e2; color: #a01818; }
.pr-4 { background: #ffe9d6; color: #9a4a00; }
.pr-3 { background: #eef0f4; color: #3d4452; }
.pr-2, .pr-1 { background: #f2f2f2; color: #666; }
.sla { font-size: 12px; font-weight: 600; white-space: nowrap; }
.sla-ok, .sla-met { color: var(--ok); }
.sla-risk { color: var(--warn); }
.sla-breached, .sla-missed { color: var(--bad); }

.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; align-items: center; }
.filters select, .filters input { width: auto; min-width: 140px; }
.filters input[type=search] { min-width: 200px; flex: 1; }
.tabs { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.tabs a { padding: 6px 12px; border-radius: 99px; text-decoration: none; background: #fff; border: 1px solid var(--line); color: var(--ink); font-size: 14px; }
.tabs a.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.tabs .count { opacity: .7; margin-left: 4px; }

.ticket-grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 18px; align-items: start; }
@media (max-width: 860px) { .ticket-grid { grid-template-columns: 1fr; } }
.meta { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; font-size: 14px; margin: 0; }
.meta dt { color: var(--muted); }
.meta dd { margin: 0; }
.signal-box { display: flex; align-items: center; gap: 8px; background: #eef4ff; border: 1px solid #c9dafc; border-radius: 8px; padding: 8px 10px; margin-top: 10px; font-size: 14px; flex-wrap: wrap; }
.signal-box strong { font-size: 15px; }

.thread { list-style: none; padding: 0; margin: 0; }
.msg { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; margin-bottom: 12px; }
.msg.mine-resolver { border-left: 4px solid var(--brand); }
.msg.internal { background: var(--note); border-color: var(--note-line); }
.msg-head { display: flex; gap: 8px; align-items: baseline; font-size: 13px; color: var(--muted); margin-bottom: 6px; flex-wrap: wrap; }
.msg-head strong { color: var(--ink); font-size: 14px; }
.msg-body { word-wrap: break-word; overflow-wrap: anywhere; }
.event { font-size: 13px; color: var(--muted); padding: 2px 4px 12px; }
.tag { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; padding: 1px 6px; border-radius: 4px; }
.tag-internal { background: var(--note-line); color: #6b4a00; }
.tag-team { background: #e3e0ff; color: #3a2fb8; }
.atts { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; }
.att { display: flex; flex-direction: column; gap: 4px; font-size: 13px; max-width: 180px; text-decoration: none; }
.att img { width: 180px; height: 120px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); }
.att .file { display: block; padding: 10px; border: 1px solid var(--line); border-radius: 6px; background: #fafafe; word-break: break-all; }
.reply.internal-on textarea { background: var(--note); }

.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat .n { font-size: 26px; font-weight: 700; line-height: 1.2; }
.stat .l { color: var(--muted); font-size: 13px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 860px) { .two-col { grid-template-columns: 1fr; } }
.bars { width: 100%; border-collapse: collapse; font-size: 14px; }
.bars td { padding: 4px 6px; vertical-align: middle; }
.bars td.label { width: 40%; }
.bars td.num { width: 60px; text-align: right; color: var(--muted); }
.bar { height: 14px; background: var(--brand); border-radius: 3px; min-width: 2px; }
.weeks { display: flex; align-items: flex-end; gap: 6px; height: 160px; padding-top: 10px; }
.week { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; font-size: 11px; color: var(--muted); }
.week .pair { display: flex; align-items: flex-end; gap: 2px; height: 120px; width: 100%; justify-content: center; }
.week .o { background: var(--brand); width: 40%; border-radius: 2px 2px 0 0; }
.week .r { background: #9ad1ad; width: 40%; border-radius: 2px 2px 0 0; }
.legend { display: flex; gap: 14px; font-size: 13px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; }
.inline-form { display: inline; }
.row-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row-form input[type=text], .row-form input[type=email], .row-form select { width: auto; flex: 1; min-width: 140px; }
