:root {
  --bg: #0f1117;
  --bg-2: #171a23;
  --surface: #1d2230;
  --surface-2: #242a3b;
  --border: #2c3347;
  --text: #e6e9f0;
  --text-dim: #9aa3b8;
  --primary: #6c63ff;
  --primary-2: #8f88ff;
  --green: #2a9d8f;
  --amber: #f77f00;
  --red: #e63946;
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.5;
}

.wrap {
  max-width: 820px;
  margin: 0 auto;
  padding: 24px 16px 60px;
}

/* Header */
.site-header {
  padding: 18px 4px 22px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}
.brand { display: flex; gap: 14px; align-items: flex-start; }
.logo {
  font-size: 34px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 60px; height: 60px;
  display: flex; align-items: center; justify-content: center;
}
.site-header h1 { margin: 0; font-size: 22px; }
.site-header p { margin: 4px 0 0; color: var(--text-dim); font-size: 14px; }

/* Tabs */
.tabs { display: flex; gap: 8px; margin-bottom: 18px; }
.tab {
  flex: 1;
  padding: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-dim);
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
}
.tab.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.tab:hover:not(.active) { background: var(--surface-2); color: var(--text); }

/* Panels */
.panel { display: none; }
.panel.active { display: block; animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; } }

/* Fields */
.field { margin-bottom: 16px; }
.field label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 14px; }
.field input, .field select, .field textarea {
  width: 100%;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(108,99,255,.15);
}
.field small { display: block; margin-top: 6px; color: var(--text-dim); font-size: 12px; }

/* Field validation state */
.field.ok input, .field.ok select, .field.ok textarea { border-color: rgba(42,157,143,.7); }
.field.err input, .field.err select, .field.err textarea {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(230,57,70,.12);
}
.field .field-hint.err { color: var(--red); }

/* Buttons */
.btn {
  padding: 13px 22px;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: all .15s;
}
.btn.primary { background: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-2); }
.btn.secondary { background: var(--surface-2); color: var(--text); }
.btn.secondary:hover { background: var(--border); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* Messages */
.msg { margin-top: 14px; font-size: 14px; padding: 12px; border-radius: 10px; display: none; }
.msg.ok { display: block; background: rgba(42,157,143,.12); color: #7fd6cc; border: 1px solid rgba(42,157,143,.4); }
.msg.err { display: block; background: rgba(230,57,70,.12); color: #f08a94; border: 1px solid rgba(230,57,70,.4); }

/* Success (ticket created) */
.success-card {
  text-align: center;
  padding: 30px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.success-card .big { font-size: 40px; }
.success-card h2 { margin: 12px 0 6px; }
.success-card .small { color: var(--text-dim); font-size: 14px; }

.success-card .code-line {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin: 14px 0;
}
.success-card .code {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: 2px;
  color: var(--primary-2);
  background: var(--surface-2);
  display: inline-block;
  padding: 8px 18px;
  border-radius: 10px;
}
.success-card .icon-btn {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  width: 44px;
  height: 44px;
  border-radius: 10px;
  font-size: 20px;
  cursor: pointer;
  transition: all .15s;
  flex-shrink: 0;
}
.success-card .icon-btn:hover { background: var(--primary); border-color: var(--primary); color: #fff; }
.success-card .success-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-top: 18px;
}

/* Ticket view */
.ticket-view { margin-top: 20px; }
.ticket-view.hidden { display: none; }
.ticket-head {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 16px;
}
.ticket-head h3 { margin: 0 0 6px; font-size: 18px; }
.ticket-head .meta { color: var(--text-dim); font-size: 13px; display: flex; flex-wrap: wrap; gap: 8px; }
.ticket-head .meta span code { background: var(--surface-2); padding: 2px 8px; border-radius: 6px; color: var(--primary-2); }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
}

/* Thread */
.thread { margin-top: 16px; }
.msg-bubble {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 16px;
  margin-bottom: 12px;
}
.msg-bubble.staff { background: var(--surface-2); border-color: var(--primary); }
.msg-bubble .from { font-size: 13px; font-weight: 700; margin-bottom: 4px; display: flex; justify-content: space-between; }
.msg-bubble .from .when { color: var(--text-dim); font-weight: 400; font-size: 12px; }
.msg-bubble .body { white-space: pre-wrap; word-break: break-word; }

/* Reply box */
.reply-box { margin-top: 16px; }
.reply-box textarea { margin-bottom: 10px; }

/* Footer */
.site-footer { margin-top: 40px; border-top: 1px solid var(--border); padding-top: 16px; color: var(--text-dim); font-size: 13px; text-align: center; }
.site-footer a { color: var(--primary-2); text-decoration: none; }

/* Responsive */
@media (max-width: 640px) {
  .site-header h1 { font-size: 19px; }
  .brand { flex-direction: column; align-items: center; text-align: center; }
  .logo { width: 52px; height: 52px; font-size: 28px; }
  .btn { width: 100%; }
}

@media (max-width: 480px) {
  .wrap { padding: 14px 12px 48px; }
  .tabs { flex-direction: column; }
  .tab { flex: 1 1 auto; }
  .site-header h1 { font-size: 18px; }
  .ticket-head .meta { flex-direction: column; gap: 6px; }
  .success-card { padding: 22px 14px; }
}
