/* BLT Tickets — plain, clean, no framework. */

:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --ink: #1c2733;
  --muted: #64748b;
  --line: #e2e8f0;
  --accent: #2563eb;
  --accent-ink: #ffffff;
  --danger: #dc2626;
  --ok: #16a34a;
  --warn: #d97706;
  --radius: 10px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

/* ---------- top bar ---------- */

#topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 10px 18px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { font-weight: 700; letter-spacing: .3px; }
#nav { display: flex; gap: 4px; flex: 1; }
#nav a {
  color: var(--muted);
  text-decoration: none;
  padding: 6px 10px;
  border-radius: 6px;
}
#nav a.active { color: var(--accent); background: #eff6ff; font-weight: 600; }
#nav a:hover { color: var(--ink); }
.topbar-right { display: flex; align-items: center; gap: 10px; color: var(--muted); }
#nav .nav-badge {
  display: inline-block;
  min-width: 18px;
  padding: 0 5px;
  margin-left: 4px;
  border-radius: 9px;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  line-height: 18px;
  text-align: center;
}

/* ---------- layout ---------- */

#view { max-width: 980px; margin: 0 auto; padding: 22px 16px 60px; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 18px;
}
.card h2 { margin: 0 0 12px; font-size: 18px; }
.card h3 { margin: 18px 0 8px; font-size: 15px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.loading, .empty { color: var(--muted); text-align: center; padding: 40px 0; }

/* ---------- forms ---------- */

label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-weight: 600; margin-bottom: 4px; font-size: 13px; }
input[type=text], input[type=email], input[type=password], textarea, select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
  background: #fff;
  color: var(--ink);
}
textarea { resize: vertical; min-height: 80px; }
input:focus, textarea:focus, select:focus { outline: 2px solid #bfdbfe; border-color: var(--accent); }

.btn {
  display: inline-block;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
  padding: 8px 16px;
  border-radius: 6px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.subtle { background: #fff; color: var(--ink); border-color: var(--line); font-weight: 500; }
.btn.subtle:hover { background: #f8fafc; }
.btn.danger { background: var(--danger); border-color: var(--danger); }
.btn.ok { background: var(--ok); border-color: var(--ok); }
.btn.small { padding: 4px 10px; font-size: 13px; }

.checklist { max-height: 160px; overflow: auto; border: 1px solid var(--line); border-radius: 6px; padding: 6px 10px; }
.checklist label { display: block; padding: 3px 0; cursor: pointer; }
.checklist input { margin-right: 8px; }

/* ---------- auth screen ---------- */

.auth-wrap { max-width: 400px; margin: 8vh auto 0; }
.auth-wrap .brand-big { text-align: center; font-size: 26px; font-weight: 700; margin-bottom: 18px; }
.tabs { display: flex; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tabs button {
  flex: 1;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 10px;
  font: inherit;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}
.tabs button.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ---------- badges ---------- */

.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.badge.u-very     { background: #fee2e2; color: #b91c1c; }
.badge.u-average  { background: #fef3c7; color: #92400e; }
.badge.u-general  { background: #e2e8f0; color: #475569; }
.badge.s-unassigned  { background: #fef3c7; color: #92400e; }
.badge.s-in_progress { background: #dbeafe; color: #1d4ed8; }
.badge.s-ended       { background: #dcfce7; color: #15803d; }
.deadline-over { color: var(--danger); font-weight: 700; }

/* ---------- ticket list ---------- */

.tlist { display: flex; flex-direction: column; gap: 8px; }
.trow {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  text-decoration: none;
  color: inherit;
}
.trow:hover { border-color: var(--accent); }
.trow .theme { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trow .meta { color: var(--muted); font-size: 13px; white-space: nowrap; }

/* ---------- ticket view ---------- */

.tk-head .theme-line { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.tk-head h2 { flex: 1; min-width: 200px; }
.tk-body { white-space: pre-wrap; margin: 10px 0 4px; }
.meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px 18px;
  margin-top: 12px;
  font-size: 13px;
}
.meta-grid .k { color: var(--muted); }
.filelist { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.filechip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 13px;
  background: #f8fafc;
  cursor: pointer;
  max-width: 100%;
}
.filechip:hover { border-color: var(--accent); color: var(--accent); }
.filechip .fname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 260px; }
.filechip .fsize { color: var(--muted); }

/* ---------- chat ---------- */

.chat { display: flex; flex-direction: column; gap: 10px; padding: 4px 0; }
.msg { max-width: 78%; }
.msg.mine { align-self: flex-end; }
.msg .who { font-size: 12px; color: var(--muted); margin: 0 6px 2px; }
.msg.mine .who { text-align: right; }
.msg .bubble {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 12px;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.msg.mine .bubble { background: #eff6ff; border-color: #bfdbfe; }
.msg .bubble img.thumb {
  display: block;
  max-width: 320px;
  max-height: 240px;
  border-radius: 8px;
  margin-top: 6px;
  cursor: pointer;
}
.stamp {
  align-self: center;
  text-align: center;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 13px;
  max-width: 90%;
}
.stamp.accepted { background: #f0fdf4; border-color: #bbf7d0; }
.stamp.denied   { background: #fef2f2; border-color: #fecaca; }
.stamp .verdict-btns { margin-top: 6px; display: flex; gap: 8px; justify-content: center; }
.sysnote { align-self: center; color: var(--muted); font-size: 12px; }

.composer { display: flex; gap: 8px; align-items: flex-end; margin-top: 14px; }
.composer textarea { flex: 1; min-height: 44px; max-height: 160px; }
.chat-closed { text-align: center; color: var(--muted); padding: 10px; border-top: 1px dashed var(--line); margin-top: 12px; }

/* ---------- rating ---------- */

.stars { display: inline-flex; flex-direction: row-reverse; gap: 2px; }
.stars input { display: none; }
.stars label { font-size: 26px; color: #cbd5e1; cursor: pointer; }
.stars input:checked ~ label, .stars label:hover, .stars label:hover ~ label { color: #f59e0b; }
.rating-show .starline { font-size: 20px; color: #f59e0b; letter-spacing: 2px; }

/* ---------- toast ---------- */

#toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: 10px 18px;
  border-radius: 8px;
  max-width: 90vw;
  z-index: 100;
  box-shadow: 0 4px 14px rgba(0,0,0,.25);
}
#toast.err { background: var(--danger); }

/* ---------- part 2: admin / inbox / filters ---------- */

.filterbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 12px; }
.filterbar label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; color: var(--muted); }
.filterbar select { width: auto; min-width: 140px; }
input[type=datetime-local] {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
  background: #fff;
  color: var(--ink);
}

.member-row { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.member-row:last-child { border-bottom: none; }
.member-row .mname { flex: 1; min-width: 160px; font-weight: 600; color: inherit; text-decoration: none; }
a.mname:hover { color: var(--accent); }
.member-row select { width: auto; max-width: 220px; }
.msub { display: block; color: var(--muted); font-size: 12px; font-weight: 400; }

.trow a.theme { color: inherit; text-decoration: none; }
.trow a.theme:hover { color: var(--accent); }

.nlist { display: flex; flex-direction: column; }
.notif { display: flex; gap: 12px; align-items: baseline; padding: 10px 6px; border-bottom: 1px solid var(--line); color: inherit; text-decoration: none; }
.notif:last-child { border-bottom: none; }
.notif:hover { background: #f8fafc; }
.notif .ntext { flex: 1; }
.notif.unread .ntext { font-weight: 700; }
.notif.unread::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); align-self: center; flex: none; }
.notif .nwhen { color: var(--muted); font-size: 12px; white-space: nowrap; }
.optin { display: flex; gap: 8px; align-items: center; cursor: pointer; }

.alist { display: flex; flex-direction: column; }
.arow { display: flex; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.arow:last-child { border-bottom: none; }
.arow .awhen { color: var(--muted); white-space: nowrap; flex: none; width: 150px; }
.arow .awhat a { color: var(--accent); }

@media (max-width: 640px) {
  #topbar { flex-wrap: wrap; }
  .msg { max-width: 95%; }
  .arow { flex-direction: column; gap: 2px; }
  .arow .awhen { width: auto; }
}
