*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Ubuntu', Helvetica, sans-serif;
  min-height: 100vh;
  background: linear-gradient(135deg, #1a4f8c 0%, #14c9a0 100%);
  background-attachment: fixed;
  color: #1a2535;
}

h1, h2, h3, h4 { font-family: 'Ubuntu', Helvetica, sans-serif; }

button { font-family: 'Ubuntu', Helvetica, sans-serif; cursor: pointer; transition: background 0.15s, box-shadow 0.15s; }
a { color: inherit; text-decoration: none; }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.2); border-radius: 3px; }

/* ── Container ──────────────────────────────────────────── */
.hd-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Header ─────────────────────────────────────────────── */
.hd-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 28px;
  height: 56px;
  background: #ffffff;
  border-bottom: 1px solid #e5e5e5;
  position: sticky;
  top: 0;
  z-index: 100;
  flex-shrink: 0;
}

.hd-logo { display: flex; align-items: center; gap: 4px; cursor: pointer; }
.logo-img { height: 30px; width: auto; object-fit: contain; }
.logo-tag {
  font-family: 'Poppins', sans-serif;
  font-size: 1.20rem; font-weight: 600; color: #2f3643; letter-spacing: -0.02em;
  position: relative; top: -1px; padding-left: 5px;
}
.logo-tag::before { content: '['; color: #178de8; margin-right: 2px; }
.logo-tag::after  { content: ']'; color: #178de8; margin-left: 2px; }

.hd-nav { display: flex; align-items: center; gap: 8px; }
.hd-nav-link {
  font-family: 'Ubuntu', Helvetica, sans-serif;
  font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em;
  color: #1a1a1a; opacity: 0.5; cursor: pointer; padding: 5px 10px;
}
.hd-nav-link:hover { opacity: 1; }
.hd-nav-link.active { opacity: 1; color: #1a4f8c; }
.hd-nav-sep { width: 1px; height: 20px; background: rgba(26,26,26,0.15); margin: 0 4px; }

.hd-user-chip {
  font-size: 0.75rem; color: #4a5568;
  background: #f0f4f8; padding: 4px 10px; border-radius: 12px;
}
.hd-user-chip-initial { display: none; }

/* ── Main content ────────────────────────────────────────── */
.hd-content {
  padding: 22px 28px 40px;
  display: flex;
  flex-direction: column;
  gap: 26px;
  flex: 1;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
}

.hd-section { display: flex; flex-direction: column; gap: 10px; }

.section-header { display: flex; justify-content: space-between; align-items: center; }
.section-header h2 {
  margin: 0;
  font-size: 0.72rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.1em;
  color: rgba(255,255,255,0.85);
  padding-left: 10px; border-left: 3px solid #14c9a0;
}

.empty-msg {
  color: rgba(255,255,255,0.7);
  font-size: 0.88rem; padding: 12px 0; margin: 0;
}

/* ── Card ───────────────────────────────────────────────── */
.card {
  background: rgba(255,255,255,0.96);
  border-radius: 10px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.12);
  overflow: hidden;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  background: rgba(26,79,140,0.05);
  border-bottom: 1px solid #e8eef5;
}
.card-header h3 { margin: 0; font-size: 1rem; font-weight: 700; color: #1a4f8c; }
.card-body { padding: 20px; }
.card-body.tight { padding: 14px 20px; }

/* ── Form ────────────────────────────────────────────────── */
.field-group { margin-bottom: 14px; }
.field-group > label {
  display: block;
  font-size: 0.72rem; font-weight: 700;
  color: #718096;
  margin-bottom: 4px;
  text-transform: uppercase; letter-spacing: 0.05em;
}
.field-input, .field-textarea, .field-select {
  width: 100%;
  padding: 9px 11px;
  border: 1.5px solid #e2e8f0;
  border-radius: 6px;
  font-size: 0.9rem;
  font-family: 'Ubuntu', Helvetica, sans-serif;
  color: #1a202c;
  background: #fff;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field-textarea { min-height: 140px; resize: vertical; line-height: 1.5; }
.field-input:focus, .field-textarea:focus, .field-select:focus {
  border-color: #14c9a0;
  box-shadow: 0 0 0 3px rgba(20,201,160,0.15);
}

.field-error { color: #e53e3e; font-size: 0.78rem; margin-top: 4px; font-weight: 600; }
.field-hint { color: #718096; font-size: 0.74rem; margin-top: 4px; }

.honeypot { position: absolute !important; left: -9999px !important; width: 1px !important; height: 1px !important; opacity: 0 !important; pointer-events: none !important; }

/* ── Captcha (slide-to-verify) ───────────────────────────── */
.captcha-instruction {
  font-size: 0.72rem; font-weight: 600; color: #4a5568;
  text-transform: uppercase; letter-spacing: 0.05em;
  margin-bottom: 4px;
  line-height: 1.3;
}

.captcha-row {
  display: flex; gap: 10px; align-items: center;
}
.captcha-puzzle {
  display: flex; flex-direction: column; gap: 6px;
  width: 200px; flex-shrink: 0;
}

.captcha-puzzle-stage {
  position: relative;
  width: 100%;
  border-radius: 10px;
  overflow: hidden;
  user-select: none;
  touch-action: none;
  box-shadow: 0 1px 0 rgba(255,255,255,0.6) inset, 0 4px 16px rgba(15,23,41,0.12);
}

.captcha-puzzle-bg {
  position: absolute; inset: 0;
  pointer-events: none;
}
.captcha-puzzle-bg svg { display: block; width: 100%; height: 100%; }

.captcha-puzzle-piece {
  position: absolute;
  cursor: grab;
  filter: drop-shadow(0 6px 14px rgba(0,0,0,0.45)) drop-shadow(0 0 1px rgba(255,255,255,0.4));
  outline: none;
}
.captcha-puzzle-piece:active { cursor: grabbing; }
.captcha-puzzle-piece svg { display: block; width: 100%; height: 100%; pointer-events: none; }

/* Slide-to-verify track */
.captcha-track {
  position: relative;
  height: 26px;
  border-radius: 13px;
  background: #eef2f7;
  border: 1px solid #dde4ec;
  display: flex; align-items: center;
  user-select: none;
  touch-action: none;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(15,23,41,0.04) inset;
}
.captcha-track-fill {
  position: absolute; left: 0; top: 0; bottom: 0;
  background: linear-gradient(90deg, rgba(26,79,140,0.18), rgba(20,201,160,0.28));
  transition: width 0.05s linear;
  pointer-events: none;
  border-radius: 13px;
}
.captcha-track-handle {
  position: relative;
  width: 30px; height: 24px;
  background: linear-gradient(180deg, #1a4f8c, #0f3262);
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  color: white;
  font-size: 0.95rem; font-weight: 700;
  cursor: grab;
  margin: 0 1px;
  box-shadow: 0 2px 6px rgba(15,23,41,0.4);
  z-index: 2;
  outline: none;
  transition: filter 0.15s;
}
.captcha-track-handle:hover { filter: brightness(1.08); }
.captcha-track-handle:active { cursor: grabbing; }
.captcha-track-handle:focus-visible {
  box-shadow: 0 0 0 3px rgba(20,201,160,0.55), 0 3px 10px rgba(15,23,41,0.4);
}
.captcha-track-arrow {
  font-family: -apple-system, sans-serif;
  line-height: 1; transform: scaleX(1.4);
}
.captcha-track-label {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  font-size: 0.62rem; font-weight: 600;
  color: #718096;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  transition: opacity 0.15s;
}

.captcha-reload {
  background: #edf2f7; color: #4a5568; border: 1px solid #dde4ec;
  border-radius: 6px; padding: 6px 10px; font-size: 0.7rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.05em;
  white-space: nowrap; flex-shrink: 0;
  align-self: stretch;
}
.captcha-reload:hover { color: #1a4f8c; background: #fff; border-color: #14c9a0; }

/* ── Buttons ─────────────────────────────────────────────── */
.btn-primary {
  background: linear-gradient(90deg, #1a4f8c, #14c9a0);
  color: white; border: none; border-radius: 6px;
  padding: 9px 18px; font-weight: 600; font-size: 0.88rem; letter-spacing: 0.01em;
}
.btn-primary:hover { opacity: 0.9; box-shadow: 0 3px 10px rgba(20,201,160,0.3); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary {
  background: #edf2f7; color: #4a5568; border: none;
  border-radius: 6px; padding: 9px 18px; font-weight: 600; font-size: 0.88rem;
}
.btn-secondary:hover { background: #e2e8f0; }

.btn-sm { padding: 4px 10px; font-size: 0.75rem; border-radius: 4px; border: none; font-weight: 600; }
.btn-sm.btn-primary { padding: 4px 10px; font-size: 0.75rem; }

.btn-danger { background: #fff5f5; color: #c53030; border: none; }
.btn-danger:hover { background: #fed7d7; }

.btn-info { background: #ebf8ff; color: #2b6cb0; border: none; }
.btn-info:hover { background: #bee3f8; }

.btn-back {
  background: none; color: #1a1a1a; border: none;
  padding: 5px 14px; font-size: 0.72rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.1em; opacity: 0.5;
}
.btn-back:hover { opacity: 1; }

/* ── Status badges ───────────────────────────────────────── */
.status-badge {
  display: inline-block;
  padding: 2px 9px; border-radius: 9px;
  font-size: 0.68rem; font-weight: 700;
  color: white; text-transform: uppercase; letter-spacing: 0.04em;
}
.status-new            { background: #2b6cb0; }
.status-inprogress     { background: #14c9a0; }
.status-awaitingclient { background: #f6b93b; }
.status-resolved       { background: #38a169; }
.status-closed         { background: #718096; }

/* ── Tickets list ────────────────────────────────────────── */
.tickets-table {
  width: 100%; border-collapse: collapse;
  background: rgba(255,255,255,0.96);
  border-radius: 10px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.12);
  overflow: hidden;
}
.tickets-table th {
  background: #f7f9fc;
  padding: 10px 14px; text-align: left;
  font-size: 0.72rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: #718096; border-bottom: 1px solid #e8eef5;
}
.tickets-table td {
  padding: 10px 14px; border-bottom: 1px solid #f0f4f8;
  font-size: 0.86rem; color: #2d3748; vertical-align: middle;
}
.tickets-table tr:last-child td { border-bottom: none; }
.tickets-table tr:hover td { background: #fafcff; cursor: pointer; }
.tickets-table .ticket-num { font-weight: 700; color: #1a4f8c; font-family: 'Poppins', sans-serif; }
.tickets-table .ticket-preview { color: #4a5568; max-width: 480px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tickets-table .ticket-time { color: #a0aec0; font-size: 0.78rem; white-space: nowrap; }

.unread-dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: #e53e3e; margin-right: 6px; vertical-align: middle;
}

.ticket-delete-x {
  background: none; border: none; color: #cbd5e0;
  font-size: 1.4rem; line-height: 1;
  width: 26px; height: 26px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%; cursor: pointer;
  transition: background 0.12s, color 0.12s, transform 0.1s;
  padding: 0;
}
.ticket-delete-x:hover { background: #fff5f5; color: #c53030; transform: scale(1.15); }

/* ── Filters ─────────────────────────────────────────────── */
.filter-row { display: flex; gap: 6px; flex-wrap: wrap; }
.filter-chip {
  background: rgba(255,255,255,0.18);
  color: white; border: 1px solid rgba(255,255,255,0.3);
  border-radius: 14px; padding: 4px 12px;
  font-size: 0.74rem; font-weight: 600;
  cursor: pointer; transition: background 0.12s;
}
.filter-chip:hover { background: rgba(255,255,255,0.3); }
.filter-chip.active { background: white; color: #1a4f8c; border-color: white; }
.filter-chip .count {
  margin-left: 6px; font-size: 0.7rem; opacity: 0.7;
  background: rgba(0,0,0,0.06); padding: 1px 6px; border-radius: 8px;
}
.filter-chip.active .count { background: rgba(26,79,140,0.1); }

/* ── Ticket detail ───────────────────────────────────────── */
.ticket-meta-bar {
  display: flex; flex-wrap: wrap; gap: 18px;
  padding: 14px 20px; background: #f7f9fc;
  border-bottom: 1px solid #e8eef5;
  font-size: 0.78rem; color: #4a5568;
}
.meta-item strong { color: #2d3748; font-weight: 700; }

.messages { display: flex; flex-direction: column; gap: 14px; padding: 20px; }
.msg {
  display: flex; flex-direction: column; gap: 6px;
  max-width: 75%; padding: 10px 14px; border-radius: 10px;
  font-size: 0.86rem; line-height: 1.5;
  word-wrap: break-word; overflow-wrap: anywhere;
}
.msg.client { background: #edf2f7; color: #1a202c; align-self: flex-start; border-bottom-left-radius: 2px; }
.msg.admin  { background: linear-gradient(135deg, #1a4f8c, #14c9a0); color: white; align-self: flex-end; border-bottom-right-radius: 2px; }
.msg-meta { font-size: 0.7rem; opacity: 0.65; }
.msg.admin .msg-meta { color: rgba(255,255,255,0.85); }
.msg-attachments { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.msg-attachment {
  display: inline-flex; align-items: center; gap: 4px;
  background: rgba(255,255,255,0.5); padding: 3px 8px; border-radius: 6px;
  font-size: 0.72rem; color: #2d3748;
}
.msg.admin .msg-attachment { background: rgba(255,255,255,0.2); color: white; }

.reply-box { padding: 14px 20px; border-top: 1px solid #e8eef5; background: #fafcff; }
.reply-box .field-textarea { min-height: 90px; }
.reply-actions { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.reply-actions .spacer { flex: 1; }

/* ── Attachments grid (pre-submit list) ──────────────────── */
.attach-list { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; }
.attach-item {
  display: flex; align-items: center; gap: 8px;
  background: #f7f9fc; padding: 4px 10px; border-radius: 6px;
  font-size: 0.78rem; color: #2d3748;
}
.attach-item .remove {
  background: none; border: none; color: #a0aec0; cursor: pointer;
  font-size: 0.9rem; padding: 0 4px;
}
.attach-item .remove:hover { color: #e53e3e; }

/* ── Diagnostics panel (admin) ───────────────────────────── */
.diag-panel { padding: 0; }
.diag-tabs { display: flex; border-bottom: 1px solid #e8eef5; background: #f7f9fc; }
.diag-tab {
  background: none; border: none; padding: 10px 16px;
  font-size: 0.74rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.05em;
  color: #718096; cursor: pointer;
  border-bottom: 2px solid transparent;
}
.diag-tab.active { color: #1a4f8c; border-bottom-color: #14c9a0; }
.diag-tab:hover { color: #2d3748; }
.diag-tabbody { padding: 16px 20px; }

.diag-grid {
  display: grid; grid-template-columns: 200px 1fr;
  gap: 6px 14px; font-size: 0.82rem;
}
.diag-grid dt { color: #718096; font-weight: 700; text-transform: uppercase; font-size: 0.7rem; letter-spacing: 0.05em; padding-top: 2px; }
.diag-grid dd { margin: 0; color: #2d3748; word-break: break-word; }

pre.diag-json {
  background: #1a2535; color: #e6f0ff;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.78rem; line-height: 1.5;
  padding: 14px; border-radius: 6px;
  overflow: auto; max-height: 520px; margin: 0;
}

.console-errors { display: flex; flex-direction: column; gap: 10px; }
.console-error-item {
  background: #fff5f5; border-left: 3px solid #e53e3e;
  padding: 8px 12px; border-radius: 4px; font-size: 0.8rem;
}
.console-error-item .when { color: #a0aec0; font-size: 0.72rem; }
.console-error-item pre { margin: 4px 0 0; font-family: ui-monospace, monospace; font-size: 0.74rem; white-space: pre-wrap; color: #2d3748; }

/* ── Login ────────────────────────────────────────────────── */
.login-page { display: flex; justify-content: center; align-items: center; min-height: 100vh; padding: 20px; }
.login-card {
  background: rgba(255,255,255,0.97);
  padding: 2.5rem 2rem 2rem; border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
  width: 360px; display: flex; flex-direction: column;
}
.login-logo { text-align: center; margin-bottom: 4px; }
.login-logo-img { height: 36px; width: auto; }
.login-subtitle {
  text-align: center; color: #718096; font-size: 0.85rem;
  margin: 0 0 1.5rem; text-transform: uppercase;
  letter-spacing: 0.08em; font-weight: 500;
}
.login-input {
  width: 100%; padding: 0.75rem 1rem; margin-bottom: 0.5rem;
  border: 1.5px solid #e2e8f0; border-radius: 8px;
  font-size: 0.95rem; font-family: 'Ubuntu', Helvetica, sans-serif;
  color: #1a2535; outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.login-input:focus { border-color: #14c9a0; box-shadow: 0 0 0 3px rgba(20,201,160,0.15); }
.login-error { color: #e53e3e; font-size: 0.82rem; margin: 0 0 0.75rem; }
.login-btn {
  width: 100%; padding: 0.8rem; margin-top: 0.75rem;
  background: linear-gradient(90deg, #1a4f8c, #14c9a0);
  color: white; border: none; border-radius: 8px;
  font-size: 0.95rem; font-weight: 700;
  letter-spacing: 0.03em;
}
.login-btn:hover { opacity: 0.9; box-shadow: 0 4px 12px rgba(20,201,160,0.35); }

/* ── Toast notifications ─────────────────────────────────── */
.toast-stack {
  position: fixed; right: 20px; bottom: 20px;
  display: flex; flex-direction: column; gap: 10px;
  z-index: 2000; max-width: 360px;
}
.toast {
  background: white; color: #1a2535;
  border-left: 4px solid #14c9a0;
  border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,0.18);
  padding: 12px 14px; font-size: 0.86rem;
  display: flex; flex-direction: column; gap: 4px;
  animation: toast-in 0.18s ease;
  cursor: pointer;
}
.toast.info  { border-left-color: #2b6cb0; }
.toast.alert { border-left-color: #e53e3e; }
.toast strong { font-size: 0.74rem; color: #1a4f8c; text-transform: uppercase; letter-spacing: 0.06em; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ── Stats row (admin) ───────────────────────────────────── */
.stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.stat-card {
  background: rgba(255,255,255,0.96);
  border-radius: 10px;
  padding: 14px 18px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.12);
}
.stat-card .label {
  font-size: 0.7rem; font-weight: 700;
  color: #718096; text-transform: uppercase; letter-spacing: 0.06em;
}
.stat-card .value {
  font-size: 1.8rem; font-weight: 700; color: #1a4f8c;
  font-family: 'Poppins', sans-serif; line-height: 1.1; margin-top: 4px;
}
.stat-card.new       .value { color: #2b6cb0; }
.stat-card.progress  .value { color: #14c9a0; }
.stat-card.awaiting  .value { color: #f6b93b; }
.stat-card.resolved  .value { color: #38a169; }

/* ── Hero (client landing) ──────────────────────────────── */
.hero {
  text-align: center; padding: 8px 0 4px;
  color: white;
}
.hero h1 {
  font-family: 'Poppins', sans-serif;
  margin: 0 0 6px; font-size: 1.8rem; font-weight: 700; letter-spacing: -0.02em;
}
.hero p { margin: 0; opacity: 0.85; font-size: 0.95rem; }

/* responsive */
@media (max-width: 720px) {
  .hd-content { padding: 14px 16px 32px; }
  .ticket-meta-bar { gap: 10px; padding: 12px 16px; }
  .msg { max-width: 92%; }
}

@media (max-width: 600px) {
  .hd-header { padding: 0 14px; }
  .logo-img {
    width: 25px;
    object-fit: cover;
    object-position: left center;
  }
  .hd-nav-link { padding: 5px 6px; font-size: 0.66rem; letter-spacing: 0.06em; }
  .col-description { display: none; }
  .hd-user-chip-full { display: none; }
  .hd-user-chip-initial { display: inline; text-transform: uppercase; }
}
