:root {
  --ink: #132028;
  --sea: #0f6b5c;
  --sea-dark: #0a4f44;
  --sun: #d9a21b;
  --paper: #f3f7f6;
  --card: #ffffff;
  --line: #d5e3df;
  --muted: #5a6f78;
  --danger: #9b2c2c;
  --ok: #0f6b5c;
  --radius: 10px;
  --shadow: 0 10px 30px rgba(19, 32, 40, 0.06);
  font-size: 16px;
}

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

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: Figtree, system-ui, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(ellipse 80% 50% at 10% -10%, rgba(15, 107, 92, 0.12), transparent 55%),
    radial-gradient(ellipse 60% 40% at 100% 0%, rgba(217, 162, 27, 0.1), transparent 50%),
    var(--paper);
  min-height: 100vh;
  line-height: 1.55;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--sea);
  color: #fff;
  padding: 0.5rem 1rem;
  z-index: 100;
}
.skip-link:focus { left: 0.5rem; top: 0.5rem; }

.wrap {
  width: min(920px, calc(100% - 2rem));
  margin-inline: auto;
}

.is-staff .wrap { width: min(1100px, calc(100% - 2rem)); }

.site-header {
  border-bottom: 1px solid var(--line);
  background: rgba(243, 247, 246, 0.85);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 0;
  flex-wrap: wrap;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  text-decoration: none;
  color: var(--ink);
  font-family: "Bricolage Grotesque", Figtree, sans-serif;
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
}
.brand em { font-style: normal; color: var(--sea); font-weight: 600; }
.brand-mark {
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 0.4rem;
  background: linear-gradient(135deg, var(--sea), #1a9a84);
  box-shadow: inset 0 0 0 2px rgba(255,255,255,0.25);
}

.nav { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.nav a {
  color: var(--sea);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95rem;
}
.nav a:hover, .nav a:focus-visible { text-decoration: underline; }
.nav-user { color: var(--muted); font-size: 0.9rem; }

.main { padding: 2rem 0 3rem; }

.hero {
  margin-bottom: 2rem;
}
.hero h1 {
  font-family: "Bricolage Grotesque", Figtree, sans-serif;
  font-size: clamp(1.75rem, 4vw, 2.4rem);
  letter-spacing: -0.03em;
  margin: 0 0 0.5rem;
  line-height: 1.15;
}
.hero p { margin: 0; color: var(--muted); max-width: 36rem; }

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  margin-bottom: 1.5rem;
}
.panel h2 {
  font-family: "Bricolage Grotesque", Figtree, sans-serif;
  font-size: 1.25rem;
  margin: 0 0 1rem;
}

.grid-2 {
  display: grid;
  gap: 1.5rem;
}
@media (min-width: 800px) {
  .grid-2 { grid-template-columns: 1.2fr 0.8fr; align-items: start; }
}

label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.35rem;
  font-size: 0.95rem;
}
.field { margin-bottom: 1rem; }
.hint { display: block; color: var(--muted); font-size: 0.85rem; font-weight: 400; margin-top: 0.25rem; }

input[type="text"],
input[type="email"],
input[type="password"],
select,
textarea {
  width: 100%;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  color: var(--ink);
  background: #fff;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--sea);
  outline-offset: 1px;
  border-color: var(--sea);
}
textarea { min-height: 140px; resize: vertical; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.7rem 1.2rem;
  border-radius: 8px;
  border: none;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  background: var(--sea);
  color: #fff;
}
.btn:hover, .btn:focus-visible { background: var(--sea-dark); }
.btn-secondary {
  background: transparent;
  color: var(--sea);
  border: 1px solid var(--sea);
}
.btn-secondary:hover, .btn-secondary:focus-visible {
  background: rgba(15, 107, 92, 0.08);
}
.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
}
.btn-row { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; }

.flash {
  padding: 0.85rem 1rem;
  border-radius: 8px;
  margin-bottom: 1.25rem;
  border: 1px solid var(--line);
}
.flash-success { background: #e8f5f1; border-color: #b7ddd3; color: var(--sea-dark); }
.flash-error { background: #fdf0f0; border-color: #f0c4c4; color: var(--danger); }
.flash-info { background: #fff8e8; border-color: #efd9a0; }

.meta { color: var(--muted); font-size: 0.9rem; }
.badge {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: #e4eeeb;
  color: var(--sea-dark);
}
.badge-open { background: #dff3ec; color: var(--sea-dark); }
.badge-pending { background: #fff3d6; color: #8a6500; }
.badge-resolved { background: #e4eef8; color: #1a4a7a; }
.badge-closed { background: #ececec; color: #555; }

.thread { display: flex; flex-direction: column; gap: 1rem; }
.message {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  background: #fff;
}
.message-staff { border-left: 4px solid var(--sea); }
.message-customer { border-left: 4px solid var(--sun); }
.message-system { border-left: 4px solid #999; background: #fafafa; color: var(--muted); }
.message-head {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
}
.message-body { white-space: pre-wrap; word-break: break-word; }

.table-wrap { overflow-x: auto; }
table.tickets {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}
table.tickets th, table.tickets td {
  text-align: left;
  padding: 0.65rem 0.5rem;
  border-bottom: 1px solid var(--line);
}
table.tickets th { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
table.tickets a { color: var(--sea); font-weight: 600; text-decoration: none; }
table.tickets a:hover { text-decoration: underline; }

.filters { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1rem; }
.filters a {
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  text-decoration: none;
  color: var(--ink);
  border: 1px solid var(--line);
  font-size: 0.9rem;
  font-weight: 600;
}
.filters a.active, .filters a:hover {
  background: var(--sea);
  color: #fff;
  border-color: var(--sea);
}

.site-footer {
  padding: 2rem 0;
  color: var(--muted);
  font-size: 0.9rem;
  border-top: 1px solid var(--line);
}

.ticket-head h1 {
  font-family: "Bricolage Grotesque", Figtree, sans-serif;
  font-size: 1.6rem;
  margin: 0 0 0.35rem;
}

.is-admin .wrap,
.is-staff .wrap { width: min(1120px, calc(100% - 2rem)); }

.admin-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0 0 1.75rem;
  padding: 0.35rem;
  background: rgba(255,255,255,0.72);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: var(--shadow);
  width: fit-content;
  max-width: 100%;
}
.admin-nav a {
  color: var(--ink-soft, var(--muted));
  font-weight: 600;
  text-decoration: none;
  font-size: 0.9rem;
  padding: 0.45rem 0.95rem;
  border-radius: 999px;
  transition: background 0.15s, color 0.15s;
}
.admin-nav a:hover,
.admin-nav a:focus-visible {
  background: rgba(15, 107, 92, 0.1);
  color: var(--sea-dark);
  text-decoration: none;
}
.admin-nav a.is-active {
  background: var(--sea);
  color: #fff;
}

.dash-hero {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 1.25rem;
  align-items: flex-end;
  margin-bottom: 1.5rem;
}
.dash-kicker {
  margin: 0 0 0.35rem;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--sea);
}
.dash-hero h1 {
  font-family: "Bricolage Grotesque", Figtree, sans-serif;
  font-size: clamp(1.75rem, 4vw, 2.35rem);
  letter-spacing: -0.03em;
  margin: 0 0 0.4rem;
  line-height: 1.15;
}
.dash-hero p { margin: 0; color: var(--muted); max-width: 34rem; }
.dash-hero-actions { display: flex; flex-wrap: wrap; gap: 0.65rem; }

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.85rem;
  margin-bottom: 1rem;
}
.stats-secondary {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  margin-bottom: 1.75rem;
}
@media (max-width: 900px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats-secondary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 520px) {
  .stats,
  .stats-secondary { grid-template-columns: 1fr; }
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1rem 1.1rem 1.05rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  text-decoration: none;
  color: inherit;
  position: relative;
  overflow: hidden;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
}
a.stat-card:hover,
a.stat-card:focus-visible {
  transform: translateY(-2px);
  border-color: #b7d5cd;
  box-shadow: 0 14px 34px rgba(19, 32, 40, 0.09);
}
.stat-card::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: var(--line);
}
.stat-card.accent-open::before { background: var(--sea); }
.stat-card.accent-pending::before { background: var(--sun); }
.stat-card.accent-resolved::before { background: #3b82a0; }
.stat-card.accent-closed::before { background: #8a969c; }

.stat-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-weight: 700;
}
.stat-value {
  font-family: "Bricolage Grotesque", Figtree, sans-serif;
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--ink);
  line-height: 1.1;
}
.stat-hint {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 0.15rem;
}

.dash-grid {
  display: grid;
  gap: 1.25rem;
}
@media (min-width: 960px) {
  .dash-grid { grid-template-columns: 1.55fr 0.9fr; align-items: start; }
}
.dash-side { display: flex; flex-direction: column; gap: 1.25rem; }

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}
.panel-head h2 { margin: 0; }
.text-link {
  color: var(--sea);
  font-weight: 700;
  text-decoration: none;
  font-size: 0.9rem;
}
.text-link:hover { text-decoration: underline; }
.row-sub { color: var(--muted); font-size: 0.85rem; margin-top: 0.15rem; }
.empty-state { color: var(--muted); margin: 0; }

.action-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.action-list a {
  display: block;
  text-decoration: none;
  color: inherit;
  padding: 0.85rem 0.95rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fbfdfc;
  transition: border-color 0.15s, background 0.15s;
}
.action-list a:hover,
.action-list a:focus-visible {
  border-color: #b7d5cd;
  background: #f0f7f4;
}
.action-list strong { display: block; color: var(--sea-dark); }
.action-list span { display: block; color: var(--muted); font-size: 0.85rem; margin-top: 0.15rem; }

.tip-list {
  margin: 0;
  padding-left: 1.1rem;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}
.tip-list a { color: var(--sea); font-weight: 600; }

.site-header .nav a.is-active {
  color: var(--sea-dark);
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

textarea.mail-body { min-height: 280px; }

.inline-role {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}
.inline-role select {
  width: auto;
  min-width: 7rem;
  padding: 0.4rem 0.6rem;
}
.inline-role .btn { padding: 0.4rem 0.75rem; font-size: 0.85rem; }

.audience-grid {
  display: grid;
  gap: 0.65rem;
}
@media (min-width: 700px) {
  .audience-grid { grid-template-columns: 1fr 1fr; }
}
.audience-option {
  display: block;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.85rem 1rem;
  cursor: pointer;
  background: #fff;
}
.audience-option:has(input:checked) {
  border-color: var(--sea);
  background: #f0f7f4;
  box-shadow: inset 0 0 0 1px var(--sea);
}
.audience-option input { margin-right: 0.5rem; }
.audience-option strong { display: inline; }
.audience-option span { display: block; color: var(--muted); font-size: 0.85rem; margin: 0.25rem 0 0 1.35rem; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
