:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --line: #dde3ec;
  --text: #16202e;
  --muted: #64748b;
  --brand: #1b3a5c;
  --brand-soft: #e8eef5;
  --urgent: #c02626;
  --high: #d97706;
  --ok: #12805c;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(16, 24, 40, .08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 "Segoe UI", Arial, system-ui, sans-serif;
  -webkit-text-size-adjust: 100%;
}

.wrap { max-width: 900px; margin: 0 auto; padding: 0 14px; }

#topbar {
  background: var(--brand);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 20;
  box-shadow: var(--shadow);
}
#topbar .wrap {
  display: flex; align-items: center; justify-content: space-between;
  min-height: 54px; gap: 12px;
}
.brand { font-weight: 700; font-size: 18px; }
.who { display: flex; align-items: center; gap: 10px; font-size: 14px; opacity: .95; }

main { padding-bottom: 60px; }
.loading { padding: 40px 0; text-align: center; color: var(--muted); }

h2 { font-size: 20px; margin: 20px 0 12px; }
h3 { font-size: 16px; margin: 18px 0 8px; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}

label { display: block; font-size: 14px; font-weight: 600; margin: 12px 0 5px; }
input, select, textarea, button { font: inherit; font-family: inherit; }
input, select, textarea {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  color: var(--text);
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--brand);
  outline-offset: -1px;
}
textarea { min-height: 110px; resize: vertical; }
.hint { color: var(--muted); font-size: 13px; margin-top: 6px; }

button {
  cursor: pointer;
  border: 0;
  border-radius: 9px;
  padding: 11px 16px;
  background: var(--brand);
  color: #fff;
  font-weight: 600;
}
button:disabled { opacity: .55; cursor: default; }
button.ghost { background: var(--brand-soft); color: var(--brand); }
button.small { padding: 7px 12px; font-size: 14px; }
button.link {
  background: none; color: inherit; padding: 4px;
  text-decoration: underline; font-weight: 400;
}
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row > * { flex: 0 0 auto; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 10px; }

.tabs { display: flex; gap: 6px; margin: 16px 0; }
.tabs button {
  flex: 1; background: var(--surface); color: var(--muted);
  border: 1px solid var(--line);
}
.tabs button[aria-selected="true"] { background: var(--brand); color: #fff; border-color: var(--brand); }

.badge {
  display: inline-block; font-size: 12px; font-weight: 700;
  padding: 3px 9px; border-radius: 999px;
  background: var(--brand-soft); color: var(--brand); white-space: nowrap;
}
.badge.urgent  { background: #fdeaea; color: var(--urgent); }
.badge.high    { background: #fdf1e0; color: var(--high); }
.badge.pending { background: #eef0f3; color: var(--muted); }
.badge.closed  { background: #e7f5ef; color: var(--ok); }

.ticket {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px; margin-bottom: 10px;
  cursor: pointer; box-shadow: var(--shadow);
}
.ticket:hover { border-color: var(--brand); }
.ticket .head { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.ticket .id { color: var(--muted); font-size: 13px; font-weight: 700; }
.ticket .desc {
  margin: 7px 0; display: -webkit-box; -webkit-line-clamp: 2;
  -webkit-box-orient: vertical; overflow: hidden;
}
.ticket .meta { color: var(--muted); font-size: 13px; display: flex; gap: 10px; flex-wrap: wrap; }
.ticket.is-urgent { border-right: 4px solid var(--urgent); }
.ticket.is-high   { border-right: 4px solid var(--high); }

.filters { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.filters select { padding: 9px 10px; font-size: 14px; }
@media (min-width: 700px) { .filters { grid-template-columns: repeat(4, 1fr); } }

.empty { text-align: center; color: var(--muted); padding: 32px 12px; }

dialog {
  width: min(760px, 100%); max-height: 92vh; border: 0; padding: 0;
  border-radius: 14px 14px 0 0; margin: auto auto 0;
  background: var(--bg); color: var(--text);
}
dialog::backdrop { background: rgba(10, 18, 30, .5); }
.sheet { padding: 16px; overflow: auto; max-height: 92vh; }
@media (min-width: 700px) { dialog { border-radius: 14px; margin: auto; } }

.kv { display: grid; grid-template-columns: 90px 1fr; gap: 6px 10px; font-size: 15px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

.thread { display: flex; flex-direction: column; gap: 8px; }
.msg { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 10px; }
.msg.admin { background: var(--brand-soft); border-color: #cfdcea; }
.msg .by { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.msg.note { background: #fffbe9; border-color: #f0e2a8; }

.timeline { font-size: 13px; color: var(--muted); }
.timeline div { padding: 2px 0; }

img.shot { max-width: 100%; border-radius: 10px; border: 1px solid var(--line); }

.toast {
  position: fixed; inset-inline: 14px; bottom: 16px; margin: 0 auto;
  max-width: 420px; background: #16202e; color: #fff;
  padding: 12px 16px; border-radius: 10px; text-align: center; z-index: 60;
}
.toast.err { background: var(--urgent); }

.apt {
  border-top: 1px solid var(--line);
  padding: 12px 0;
}
.apt:last-child { padding-bottom: 0; }
.apt .meta {
  color: var(--muted); font-size: 13px; margin-top: 5px;
  display: flex; gap: 10px; flex-wrap: wrap; align-items: center;
}
.apt code {
  background: var(--brand-soft); color: var(--brand);
  padding: 2px 8px; border-radius: 6px;
  font-size: 14px; font-weight: 700; letter-spacing: .1em;
}

.devcode {
  background: #fff8e1; border: 1px dashed #e0b400; color: #6b5200;
  padding: 10px; border-radius: 9px; margin-top: 12px; font-size: 14px;
}
