:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --text: #1f2733;
  --muted: #6b7684;
  --border: #dde1e6;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
}

* { box-sizing: border-box; }

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

.navbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  row-gap: 0.5rem;
  background: #111827;
  color: #fff;
  padding: 0.75rem 1.5rem;
}

.navbar .brand { display: flex; align-items: center; }
.navbar .brand img { height: 38px; display: block; }

.nav-links { display: flex; flex-wrap: wrap; gap: 1rem; row-gap: 0.35rem; align-items: center; }
.nav-links a { color: #d1d5db; text-decoration: none; }
.nav-links a:hover { color: #fff; }
.nav-user { color: #9ca3af; font-size: 0.9rem; }

.container { max-width: 960px; margin: 1.5rem auto; padding: 0 1rem; }

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.card.narrow { max-width: 480px; margin: 2rem auto; }

h1 { font-size: 1.5rem; margin-top: 0; }
h2 { font-size: 1.1rem; }

label { display: block; margin-bottom: 0.75rem; font-weight: 600; font-size: 0.9rem; }
label.checkbox { font-weight: 400; }

input[type="text"], input[type="email"], input[type="password"], textarea, select {
  display: block;
  width: 100%;
  margin-top: 0.25rem;
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font: inherit;
}

label.checkbox input { display: inline; width: auto; }

button, .button {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 0.5rem 1rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}

button:hover, .button:hover { background: var(--accent-dark); }

button.danger { background: #dc2626; }
button.danger:hover { background: #b91c1c; }
button:disabled, button.danger:disabled {
  background: #e5e7eb;
  color: #9ca3af;
  cursor: not-allowed;
}

.filters { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 1rem 0; }
.filters select { width: auto; margin: 0; }

.ticket-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.ticket-table th, .ticket-table td {
  text-align: left;
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

.ticket-table th { color: var(--muted); font-weight: 600; }
.ticket-table a { color: var(--accent); text-decoration: none; font-weight: 600; }

.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  background: #e5e7eb;
  color: #374151;
  text-transform: capitalize;
}

.status-open { background: #dbeafe; color: #1e40af; }
.status-in_progress { background: #fef3c7; color: #92400e; }
.status-resolved { background: #d1fae5; color: #065f46; }
.status-closed { background: #e5e7eb; color: #4b5563; }

.priority-low { background: #e5e7eb; color: #4b5563; }
.priority-medium { background: #dbeafe; color: #1e40af; }
.priority-high { background: #ffedd5; color: #9a3412; }
.priority-urgent { background: #fee2e2; color: #991b1b; }

.flash { padding: 0.75rem 1rem; border-radius: 6px; margin-bottom: 1rem; }
.flash-error { background: #fee2e2; color: #991b1b; }
.flash-success { background: #d1fae5; color: #065f46; }

.muted { color: var(--muted); font-size: 0.9rem; }
.preserve-lines { white-space: pre-wrap; }

.card.danger-zone { border-color: #fca5a5; }
.card.danger-zone h2 { color: #b91c1c; }

.comment.internal { background: #fffbeb; border-color: #fcd34d; }
.internal-badge { background: #fef3c7; color: #92400e; }
.comment-meta { margin-top: 0; }

.inline-form { display: flex; gap: 1rem; align-items: flex-end; flex-wrap: wrap; }
.inline-form label { margin-bottom: 0; }
.inline-form select { width: auto; }

.badges { display: flex; gap: 0.5rem; margin: 0.5rem 0; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.inline-form.compact { gap: 0.5rem; }
.inline-form.compact select { padding: 0.3rem; }
.inline-form.compact button { padding: 0.3rem 0.75rem; }

.group-list { margin: 0.5rem 0 1rem; padding-left: 1.25rem; }
.group-list li { margin-bottom: 0.35rem; }
.group-list input[type="text"] { width: auto; margin: 0; }

/* Collapsible checkbox pickers (groups/categories on the user admin) */
.field-label { display: block; font-weight: 600; font-size: 0.9rem; }

.picker { position: relative; margin-top: 0.25rem; }

.picker summary {
  list-style: none;
  cursor: pointer;
  padding: 0.5rem 1.5rem 0.5rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--card);
  font-weight: 400;
  font-size: 0.9rem;
  max-width: 240px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.picker summary::-webkit-details-marker { display: none; }

.picker summary::after {
  content: "\25BE";
  position: absolute;
  right: 0.5rem;
  top: 0.5rem;
  color: var(--muted);
}

.picker[open] summary { border-color: var(--accent); }

.picker-options {
  position: absolute;
  z-index: 10;
  top: calc(100% + 4px);
  left: 0;
  min-width: 220px;
  max-height: 220px;
  overflow-y: auto;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.5rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.picker-options label.checkbox {
  display: block;
  margin: 0 0 0.35rem;
  font-size: 0.9rem;
  white-space: nowrap;
}

.picker-options label.checkbox:last-child { margin-bottom: 0; }

.inline-form .picker { margin-top: 0; }
.inline-form.compact .picker summary { padding: 0.3rem 1.4rem 0.3rem 0.5rem; }
.inline-form.compact .picker summary::after { top: 0.3rem; }

/* Attachments */
.attachments { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 1rem; }
.attachment {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--accent);
  text-decoration: none;
  font-size: 0.95rem;
  max-width: 360px;
  word-break: break-all;
}
.attachment:hover { border-color: var(--accent); }
.attachment-thumb {
  max-width: 330px;
  max-height: 240px;
  object-fit: contain;
  border-radius: 6px;
  background: #fff;
}
input[type="file"] {
  display: block;
  margin-top: 0.35rem;
  font: inherit;
  font-weight: 400;
  font-size: 1rem;
}
input[type="file"]::file-selector-button {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 0.65rem 1.5rem;
  font: inherit;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  margin-right: 0.75rem;
}
input[type="file"]::file-selector-button:hover { background: var(--accent-dark); }

/* Ticket history */
.history-list { list-style: none; margin: 0; padding: 0; }
.history-list li { padding: 0.35rem 0; border-bottom: 1px solid var(--border); font-size: 0.9rem; }
.history-list li:last-child { border-bottom: none; }

/* Dashboard */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 0.75rem;
  margin: 1rem 0;
}
.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  text-decoration: none;
  color: var(--text);
}
.stat-card:hover { border-color: var(--accent); }
.stat-number { font-size: 1.8rem; font-weight: 700; }
.dashboard-columns {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
}
.stat-table { width: 100%; border-collapse: collapse; }
.stat-table td { padding: 0.35rem 0; border-bottom: 1px solid var(--border); font-size: 0.9rem; }
.stat-table tr:last-child td { border-bottom: none; }
.stat-value { text-align: right; font-weight: 700; }
.filters input[type="search"] {
  width: auto;
  margin: 0;
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font: inherit;
}

/* Reporter portal ticket cards */
.ticket-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}
.ticket-card {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem;
  text-decoration: none;
  color: var(--text);
}
.ticket-card:hover { border-color: var(--accent); }
.ticket-card-title { font-weight: 700; font-size: 1.05rem; }
.ticket-card-excerpt { margin: 0; color: var(--muted); font-size: 0.9rem; line-height: 1.5; }
.ticket-card .muted { margin: 0; font-size: 0.8rem; }
.ticket-card .badges { margin: 0; }

/* Landing page */
.hero { text-align: center; padding: 3rem 1rem 2rem; }
.hero-icon { height: 72px; margin-bottom: 1rem; }
.hero h1 { font-size: 2.5rem; margin: 0 0 0.75rem; }
.hero .accent { color: var(--accent); }
.hero-sub {
  max-width: 560px;
  margin: 0 auto 1.5rem;
  color: var(--muted);
  font-size: 1.1rem;
  line-height: 1.6;
}
.button.big { font-size: 1.1rem; padding: 0.75rem 2rem; }

.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
  margin: 2rem 0;
}
.feature h3 { margin-top: 0; font-size: 1rem; }
.feature p { color: var(--muted); margin-bottom: 0; line-height: 1.5; }

.steps { text-align: center; padding: 1rem 0 2rem; }
.steps ol {
  max-width: 480px;
  margin: 1rem auto 0;
  text-align: left;
  line-height: 2;
}
.roles-heading { margin-top: 3rem; }
.steps .roles { text-align: left; }
.steps .roles-note { margin-bottom: 0; }

.docs { padding: 1rem 0 2rem; }
.docs h2 { text-align: center; font-size: 1.5rem; margin-bottom: 0.75rem; }
.docs-intro {
  max-width: 640px;
  margin: 0 auto 2.5rem;
  text-align: center;
  color: var(--muted);
  line-height: 1.6;
}

.doc-block {
  display: flex;
  align-items: center;
  gap: 2.5rem;
  margin-bottom: 3rem;
}
.doc-block:nth-of-type(even) { flex-direction: row-reverse; }

.doc-text { flex: 1; min-width: 240px; }
.doc-text h3 { margin-top: 0; font-size: 1.15rem; }
.doc-text p { color: var(--muted); line-height: 1.65; margin-bottom: 0; }

.doc-block img {
  width: 58%;
  min-width: 0;
  height: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

/* Landing page navigation: sticky navbar + smooth anchor scrolling */
html { scroll-behavior: smooth; }
body.landing .navbar { position: sticky; top: 0; z-index: 100; }
body.landing section[id] { scroll-margin-top: 76px; }
.nav-cta { padding: 0.35rem 1rem; }
.nav-links a.nav-cta { color: #fff; }

.contact { padding: 1rem 0 2rem; }
.contact h2 { text-align: center; font-size: 1.5rem; margin-bottom: 0.75rem; }
.contact .card.narrow { margin-top: 0; }
.contact textarea { resize: vertical; }

/* Honeypot field: off-screen for people, present for bots */
.hp-field {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.landing-footer { text-align: center; padding: 1rem 0 2rem; }
.footer-links a { color: var(--muted); }
.footer-links a:hover { color: var(--accent); }

/* Legal pages (privacy / terms / cookies) */
.legal-page { max-width: 720px; margin: 0 auto; padding: 1rem 0 2rem; }
.legal-page h1 { margin-bottom: 0.25rem; }
.legal-page h2 { margin-top: 1.75rem; }
.legal-page p, .legal-page li { line-height: 1.6; }

/* Cookie consent banner */
#cookie-banner {
  position: fixed;
  left: 1rem;
  right: 1rem;
  bottom: 1rem;
  z-index: 100;
  max-width: 640px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.9rem 1.2rem;
  background: #fff;
  border: 1px solid var(--border, #d1d5db);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}
#cookie-banner[hidden] { display: none; }
#cookie-banner p { margin: 0; font-size: 0.9rem; }
.cookie-actions { display: flex; gap: 0.5rem; flex-shrink: 0; }
button.cookie-secondary { background: #6b7280; }
button.cookie-secondary:hover { background: #4b5563; }

/* Small screens */
@media (max-width: 640px) {
  .navbar { padding: 0.6rem 1rem; }
  .nav-links { gap: 0.75rem; font-size: 0.95rem; }
  .container { margin-top: 1rem; }
  .page-header { flex-wrap: wrap; gap: 0.5rem; }
  .filters input[type="search"] { width: 100%; }
  /* Wide tables scroll sideways instead of clipping the page */
  .ticket-table { display: block; overflow-x: auto; }
  .attachment { max-width: 100%; }
  .attachment-thumb { max-width: 100%; }
  .hero { padding: 2rem 0.5rem 1.5rem; }
  .hero h1 { font-size: 1.8rem; }
  .hero-sub { font-size: 1rem; }
  /* Documentation blocks stack, text above its screenshot */
  .doc-block, .doc-block:nth-of-type(even) { flex-direction: column; gap: 1rem; }
  .doc-block img { width: 100%; }
  #cookie-banner { flex-direction: column; align-items: flex-start; gap: 0.6rem; }
}
