:root {
  --navy: #0b2545;
  --navy-2: #13315c;
  --orange: #f26b1d;
  --orange-dark: #d9560b;
  --yellow: #ffc914;
  --sand: #fbf6ec;
  --card: #ffffff;
  --text: #1c2333;
  --muted: #6b7385;
  --line: #e7e2d6;
  --ok: #1b998b;
  --danger: #d64045;
  --radius: 14px;
  --shadow: 0 6px 24px rgba(11, 37, 69, 0.08);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: var(--sand);
  line-height: 1.5;
}
body.guest {
  min-height: 100vh;
  background:
    radial-gradient(circle at 15% 20%, rgba(255, 201, 20, 0.35), transparent 40%),
    radial-gradient(circle at 85% 80%, rgba(242, 107, 29, 0.3), transparent 45%),
    linear-gradient(160deg, var(--navy) 0%, var(--navy-2) 100%);
}
a { color: var(--orange-dark); }
h1, h2 { line-height: 1.2; color: var(--navy); margin: 0 0 12px; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.2rem; }
hr { border: 0; border-top: 1px solid var(--line); margin: 20px 0; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.center { text-align: center; }
.pre { white-space: pre-wrap; overflow-wrap: anywhere; }

/* Ball logo */
.ball {
  display: inline-block; width: 28px; height: 28px; flex: none;
  background: url(/static/img/favicon.svg) center / contain no-repeat;
}
.ball.big { width: 56px; height: 56px; margin-bottom: 8px; }

/* Top bar */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--navy);
  border-bottom: 4px solid var(--orange);
  color: #fff;
}
.topbar-inner {
  max-width: 1100px; margin: 0 auto; padding: 10px 16px;
  display: flex; align-items: center; gap: 16px;
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-weight: 800; font-size: 1.15rem; letter-spacing: 0.3px; }
.brand .ball { background-color: #fff; border-radius: 50%; }
.nav { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.nav a {
  color: #dbe4f3; text-decoration: none; padding: 8px 12px; border-radius: 999px; font-weight: 600;
}
.nav a:hover { background: rgba(255, 255, 255, 0.1); color: #fff; }
.nav a.active { background: var(--orange); color: #fff; }
.nav a.admin-link { border: 1px solid rgba(255, 201, 20, 0.6); color: var(--yellow); }
.nav a.admin-link.active { background: var(--yellow); color: var(--navy); }
.nav-me { display: flex; align-items: center; gap: 8px; margin-left: 10px; font-weight: 600; }
.nav-toggle { display: none; margin-left: auto; background: none; border: 0; color: #fff; font-size: 1.6rem; cursor: pointer; }

@media (max-width: 760px) {
  .nav-toggle { display: block; }
  .nav {
    display: none; position: absolute; left: 0; right: 0; top: 100%;
    flex-direction: column; align-items: stretch; background: var(--navy); padding: 8px 16px 16px;
    border-bottom: 4px solid var(--orange);
  }
  .nav-open .nav { display: flex; }
  .nav a { border-radius: 10px; }
  .nav-me { margin: 8px 0 0; }
}

/* Layout */
.container { max-width: 1100px; margin: 0 auto; padding: 24px 16px 48px; }
.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 20px; margin-bottom: 20px; border: 1px solid var(--line);
}
.card.narrow { max-width: 520px; margin-left: auto; margin-right: auto; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 20px; align-items: start; }
.grid-2 > .card { margin-bottom: 0; }

/* Auth */
.auth-wrap { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 24px 16px; }
.auth-card {
  width: 100%; max-width: 420px; background: var(--card); border-radius: 20px; padding: 28px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3); border-top: 6px solid var(--orange);
}
.auth-logo { text-align: center; margin-bottom: 16px; }
.auth-logo h1 { margin-bottom: 4px; }
.auth-logo p { color: var(--muted); margin: 0; }

/* Forms */
.form { display: flex; flex-direction: column; gap: 14px; }
.form label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 0.95rem; color: var(--navy); }
.form small { font-weight: 400; color: var(--muted); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 420px) { .row2 { grid-template-columns: 1fr; } }
input, select, textarea {
  font: inherit; color: var(--text); background: #fff;
  border: 1.5px solid var(--line); border-radius: 10px; padding: 10px 12px; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--orange); box-shadow: 0 0 0 3px rgba(242, 107, 29, 0.2); }
input[type="file"] { padding: 8px; }
textarea { resize: vertical; }
.check { flex-direction: row !important; align-items: center; gap: 8px !important; font-weight: 500 !important; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--orange); }
.code-input { font-size: 1.8rem; letter-spacing: 10px; text-align: center; font-weight: 700; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 700; cursor: pointer; text-decoration: none;
  padding: 10px 18px; border-radius: 999px; border: 2px solid var(--navy);
  background: #fff; color: var(--navy); transition: transform 0.05s, background 0.15s;
}
.btn:hover { background: #f1f4f9; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--orange); border-color: var(--orange); color: #fff; }
.btn-primary:hover { background: var(--orange-dark); border-color: var(--orange-dark); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #b8323a; }
.btn-block { width: 100%; }
.btn-small { padding: 6px 12px; font-size: 0.875rem; }
.btn-icon { width: 44px; height: 44px; padding: 0; font-size: 1.6rem; line-height: 1; }
.btn-link { background: none; border: 0; color: var(--orange-dark); font: inherit; cursor: pointer; text-decoration: underline; padding: 0; }
.danger-title { color: var(--danger); }

.alert { padding: 10px 14px; border-radius: 10px; margin-bottom: 14px; font-weight: 500; }
.alert-error { background: #fdecec; color: #a32a2f; border: 1px solid #f5c2c4; }
.alert-ok { background: #e6f6f3; color: #11695f; border: 1px solid #b6e3db; }

/* Avatars */
.avatar { border-radius: 50%; object-fit: cover; flex: none; display: inline-block; vertical-align: middle; border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,0.08); }
.avatar-letter { display: inline-flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; line-height: 1; }

/* Badges */
.badge { display: inline-block; font-size: 0.75rem; font-weight: 700; padding: 2px 10px; border-radius: 999px; background: #eef1f6; color: var(--navy); white-space: nowrap; }
.badge-admin { background: var(--yellow); color: var(--navy); }
.status-open { background: #fff1e6; color: var(--orange-dark); }
.status-in_progress { background: #e7efff; color: #2d5bd0; }
.status-closed { background: #eceef2; color: #555; }

/* Calendar */
.cal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.cal-title { text-align: center; flex: 1; }
.cal-title h1 { margin-bottom: 8px; }
.cal-pick { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.cal-pick select { width: auto; }
.cal-pick input { width: 96px; }
.cal-help { text-align: center; margin: 12px 0; font-size: 0.9rem; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.cal-weekdays span { text-align: center; font-size: 0.8rem; font-weight: 700; color: var(--muted); text-transform: uppercase; padding: 4px 0; }
.day {
  --heat: 0;
  position: relative; min-height: 84px; padding: 6px; border-radius: 10px;
  border: 1.5px solid var(--line); background: #fff; font: inherit; text-align: left; cursor: pointer;
  display: flex; flex-direction: column; gap: 2px; align-items: flex-start; overflow: hidden;
  transition: transform 0.08s, box-shadow 0.15s;
}
.day:hover { box-shadow: 0 4px 12px rgba(11, 37, 69, 0.12); transform: translateY(-1px); }
.day.blank { background: transparent; border: 0; cursor: default; box-shadow: none; transform: none; }
.day.past { opacity: 0.55; cursor: default; }
.day .num { font-weight: 700; color: var(--navy); }
.day.today .num { background: var(--navy); color: #fff; border-radius: 999px; padding: 0 8px; }
.day.has { background: rgba(255, 201, 20, calc(0.15 + var(--heat) * 0.45)); border-color: rgba(242, 107, 29, calc(0.2 + var(--heat) * 0.5)); }
.day.hot { background: linear-gradient(150deg, var(--orange), #ff9a3c); border-color: var(--orange-dark); color: #fff; }
.day.hot .num, .day.hot .count { color: #fff; }
.day.hot::after { content: "🔥"; position: absolute; top: 4px; right: 6px; font-size: 0.95rem; }
.day.mine { box-shadow: inset 0 0 0 3px var(--ok); }
.day.mine::before { content: "✓"; position: absolute; bottom: 4px; right: 6px; font-weight: 800; color: var(--ok); }
.day.hot.mine::before { color: #fff; }
.day.selected { outline: 3px solid var(--navy); outline-offset: 1px; }
.day .count { font-size: 0.75rem; font-weight: 700; color: var(--orange-dark); }
.day .faces { display: flex; margin-top: auto; }
.day .faces .avatar { margin-right: -5px; border-width: 1px; }
@media (max-width: 600px) {
  .cal-grid { gap: 3px; }
  .day { min-height: 58px; padding: 4px; }
  .day .faces { display: none; }
  .day .count { font-size: 0.65rem; }
  .day.hot::after { font-size: 0.7rem; top: 2px; right: 3px; }
  .cal-weekdays span { font-size: 0.65rem; }
  .card { padding: 14px; }
}
.people { list-style: none; padding: 0; margin: 0 0 16px; display: flex; flex-direction: column; gap: 8px; }
.people li { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.people.small { margin: 6px 0 0; gap: 4px; font-size: 0.9rem; }
.tooltip {
  position: absolute; z-index: 30; background: var(--navy); color: #fff; padding: 10px 12px; border-radius: 10px;
  box-shadow: var(--shadow); max-width: 260px; pointer-events: none;
}
.tooltip .people li { font-weight: 500; }

/* Chat */
.chat-card { display: flex; flex-direction: column; height: calc(100vh - 140px); min-height: 420px; padding: 0; overflow: hidden; }
.chat-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.chat-head h1 { margin: 0; font-size: 1.3rem; }
.status { font-size: 0.8rem; font-weight: 700; color: var(--muted); }
.status.online { color: var(--ok); }
.status.online::before { content: "● "; }
.chat-log { flex: 1; overflow-y: auto; padding: 16px 20px; display: flex; flex-direction: column; gap: 12px; background: #fdfbf6; }
.msg { display: flex; gap: 10px; align-items: flex-start; max-width: 85%; }
.msg.mine { align-self: flex-end; flex-direction: row-reverse; }
.bubble { background: #fff; border: 1px solid var(--line); border-radius: 4px 14px 14px 14px; padding: 8px 12px; min-width: 0; }
.msg.mine .bubble { background: #fff1e6; border-color: #fbd3b6; border-radius: 14px 4px 14px 14px; }
.msg-head { display: flex; gap: 8px; align-items: baseline; font-size: 0.85rem; }
.msg-head strong { color: var(--navy); }
.msg-head time { color: var(--muted); font-size: 0.75rem; }
.msg p { margin: 2px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg-del { background: none; border: 0; cursor: pointer; opacity: 0.5; padding: 0 2px; margin-left: auto; }
.msg-del:hover { opacity: 1; }
.chat-form { display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line); }
.chat-error { color: var(--danger); margin: 0; padding: 0 20px; min-height: 0; font-size: 0.85rem; }
.chat-error:not(:empty) { padding-bottom: 10px; }

/* Tickets */
.ticket-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.ticket-list a {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: 12px; text-decoration: none; color: var(--text);
}
.ticket-list a:hover { border-color: var(--orange); background: #fffaf4; }
.ticket-snippet { flex-basis: 100%; color: var(--muted); font-size: 0.9rem; overflow-wrap: anywhere; }
.ticket-list time { font-size: 0.8rem; }
.ticket-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.ticket-head h1, .ticket-head h2 { margin: 0; }
.meta { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; margin: 12px 0; }
.meta dt { font-weight: 700; color: var(--muted); }
.meta dd { margin: 0; }
.inline-form { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; border-top: 1px solid var(--line); padding-top: 14px; }
.inline-form label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; }
.replies { list-style: none; padding: 0; margin: 0 0 16px; display: flex; flex-direction: column; gap: 14px; }
.replies li { display: flex; gap: 12px; }
.replies li > div { flex: 1; min-width: 0; }
.replies p { margin: 4px 0 0; }
.replies .from-admin > div { background: #fffbea; border-radius: 10px; padding: 8px 12px; border: 1px solid #f7e3a1; }
.filters { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { padding: 4px 12px; border-radius: 999px; border: 1.5px solid var(--line); text-decoration: none; color: var(--navy); font-weight: 600; font-size: 0.875rem; }
.chip.active { background: var(--navy); color: #fff; border-color: var(--navy); }

/* Settings */
.pfp-row { display: flex; gap: 16px; align-items: center; margin-bottom: 14px; }
.pfp-row p { margin: 4px 0 0; font-size: 0.9rem; }

/* Admin */
.tabs { display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; }
.tabs a { padding: 8px 16px; border-radius: 999px; background: #fff; border: 1.5px solid var(--line); text-decoration: none; color: var(--navy); font-weight: 700; }
.tabs a.active { background: var(--navy); border-color: var(--navy); color: #fff; }
.user-table { display: flex; flex-direction: column; }
.user-row { display: grid; grid-template-columns: minmax(200px, 1.2fr) 2fr auto; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.user-row:last-child { border-bottom: 0; }
.user-row.is-banned { opacity: 0.7; }
.user-id { display: flex; gap: 12px; align-items: center; min-width: 0; }
.user-id strong { overflow-wrap: anywhere; }
.tags { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: 2px; }
.name-form { display: flex; gap: 6px; }
.name-form input { padding: 6px 10px; min-width: 0; }
@media (max-width: 760px) {
  .user-row { grid-template-columns: 1fr; }
  .name-form { flex-wrap: wrap; }
  .name-form input { flex: 1 1 120px; }
}
