:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --ink: #1b2333;
  --muted: #6b7590;
  --line: #e2e7f0;
  --brand: #2f5bea;
  --brand-dark: #1f42b5;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

a { color: var(--brand); }

main {
  max-width: 1040px;
  margin: 0 auto;
  padding: 28px 20px 60px;
}

/* Header ------------------------------------------------------------ */
.site-header {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.brand { font-size: 20px; font-weight: 700; text-decoration: none; color: var(--brand); }
.brand span { color: var(--ink); font-weight: 500; margin-left: 4px; }
.site-header nav { display: flex; align-items: center; gap: 16px; }
.site-header nav a { text-decoration: none; color: var(--ink); font-size: 15px; }
.site-header nav a:hover { color: var(--brand); }
.site-footer { text-align: center; color: var(--muted); padding: 24px; font-size: 14px; }

/* Blocks ------------------------------------------------------------ */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 20px;
}
.card.narrow { max-width: 560px; margin-inline: auto; }
h1 { font-size: 26px; margin: 0 0 12px; }
h2 { font-size: 18px; margin: 0 0 12px; }
.muted { color: var(--muted); }
.help { display: block; color: var(--muted); font-size: 13px; }
.error, .errorlist { color: #b3261e; }
.errorlist { list-style: none; padding: 0; margin: 4px 0 0; font-size: 14px; }

.hero { text-align: center; padding: 40px 0 8px; }
.hero-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 20px; }
.steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }

/* Forms ------------------------------------------------------------- */
.field { margin: 0 0 16px; }
.field label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 5px; }
.field.checkbox { display: flex; align-items: center; gap: 8px; }
.field.checkbox label { margin: 0; font-weight: 400; }
input[type="text"], input[type="email"], input[type="password"], textarea, select {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  background: #fff;
}
textarea { resize: vertical; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--brand); border-color: var(--brand); }

.btn {
  display: inline-block;
  background: var(--brand);
  color: #fff;
  border: 0;
  border-radius: 8px;
  padding: 10px 18px;
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
.btn:hover { background: var(--brand-dark); }
.btn-secondary { background: #eef1f9; color: var(--ink); }
.btn-secondary:hover { background: #e0e5f3; }
.inline-form { display: inline; }
.linkish { background: none; border: 0; font: inherit; color: var(--ink); cursor: pointer; padding: 0; }
.linkish:hover { color: var(--brand); }

/* Flashes ----------------------------------------------------------- */
.flashes { list-style: none; padding: 0; margin: 0 0 18px; }
.flash { padding: 11px 14px; border-radius: 8px; margin-bottom: 8px; border: 1px solid var(--line); background: #fff; }
.flash-success { background: #e8f6ed; border-color: #b7e0c6; }
.flash-error { background: #fdeceb; border-color: #f3c2be; }
.flash-info { background: #eaf0fe; border-color: #c3d3fb; }
.flash-warning { background: #fff7e3; border-color: #f0dcae; }

/* Tickets ----------------------------------------------------------- */
.ticket-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.ticket-number { font-size: 26px; font-weight: 700; letter-spacing: 1px; color: var(--brand); }
.meta { display: flex; flex-wrap: wrap; gap: 22px; margin: 14px 0 0; }
.meta dt { font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
.meta dd { margin: 2px 0 0; }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  background: #eef1f9;
  color: var(--ink);
  white-space: nowrap;
}
.status-new { background: #e4ecff; color: #1f42b5; }
.status-open { background: #fff2d9; color: #8a5b00; }
.status-pending { background: #f0e7fd; color: #5b34ad; }
.status-resolved { background: #e2f6e8; color: #1d6b38; }
.status-closed { background: #eceef3; color: #5a6377; }
.priority-urgent { background: #fde5e3; color: #a8261c; }
.priority-high { background: #ffeede; color: #96500b; }
.badge-internal { background: #fdf0cd; color: #7a5a00; }

.message { border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px; margin-bottom: 12px; }
.message header { display: flex; gap: 10px; align-items: center; font-size: 14px; margin-bottom: 6px; }
.message time { color: var(--muted); font-size: 13px; margin-left: auto; }
.message p { margin: 0; }
.message-staff { background: #f5f8ff; border-color: #d3e0fb; }
.message-internal { background: #fffbef; border-color: #f0e1b4; }
.attachments { list-style: none; padding: 0; margin: 10px 0 0; display: flex; flex-wrap: wrap; gap: 8px; }
.attachments li { background: #eef1f9; border-radius: 6px; padding: 5px 10px; font-size: 13px; }
.attachments a { text-decoration: none; font-weight: 600; }
.attachments .muted { margin-left: 6px; }
input[type="file"] { width: 100%; padding: 8px; border: 1px dashed var(--line); border-radius: 8px; background: #fff; font: inherit; }

.reply-form { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 18px; }

/* Staff queue ------------------------------------------------------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; color: var(--muted); font-size: 14px; }
.stat-value { display: block; font-size: 26px; font-weight: 700; color: var(--ink); }

.filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.filter-field { display: flex; flex-direction: column; font-size: 13px; }
.filter-field label { font-weight: 600; color: var(--muted); margin-bottom: 4px; }
.filter-field input, .filter-field select { min-width: 160px; }

.table-wrap { overflow-x: auto; }
table.tickets { width: 100%; border-collapse: collapse; font-size: 14px; }
table.tickets th, table.tickets td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.tickets th { font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
table.tickets tr:last-child td { border-bottom: 0; }

.pagination {
  display: flex; flex-wrap: wrap; gap: 14px; align-items: center;
  justify-content: space-between; margin: -6px 0 22px; font-size: 14px;
}
.pagination .pages { display: flex; gap: 10px; align-items: center; }
.pagination a { text-decoration: none; padding: 5px 10px; border-radius: 6px; background: var(--card); border: 1px solid var(--line); }
.pagination a:hover { background: #eef1f9; }
.pagination .disabled { padding: 5px 10px; color: #b3bacb; }
.pagination .current { font-weight: 600; }

.two-col { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; align-items: start; }
@media (max-width: 800px) { .pagination {
  display: flex; flex-wrap: wrap; gap: 14px; align-items: center;
  justify-content: space-between; margin: -6px 0 22px; font-size: 14px;
}
.pagination .pages { display: flex; gap: 10px; align-items: center; }
.pagination a { text-decoration: none; padding: 5px 10px; border-radius: 6px; background: var(--card); border: 1px solid var(--line); }
.pagination a:hover { background: #eef1f9; }
.pagination .disabled { padding: 5px 10px; color: #b3bacb; }
.pagination .current { font-weight: 600; }

.two-col { grid-template-columns: 1fr; } }
