:root {
  --bg: #f7f3e9;
  --fg: #1f2a22;
  --card: #fffdf7;
  --line: #e3dfd1;
  --muted: #657064;
  --green-900: #1f4f32;
  --green-800: #285f3d;
  --green-700: #2f7048;
  --orange: #f59f22;
  --red: #b3412a;
  --radius: 14px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141d17;
    --fg: #eef2ea;
    --card: #1c2820;
    --line: #2d3b31;
    --muted: #a3b0a2;
    --green-900: #0f2a1a;
    --green-800: #2f7048;
    --green-700: #3d8a5a;
    --orange: #ffb547;
    --red: #e5806b;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--fg);
  line-height: 1.55;
}

.container {
  max-width: 780px;
  margin: 0 auto;
  padding: 0 18px;
}

.topbar {
  background: var(--green-900);
  color: #fffaf0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.16);
}

.topbar-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding-top: 14px;
  padding-bottom: 14px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-badge {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--orange);
  color: #1f2a22;
  font-size: 20px;
  font-weight: 800;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.topbar h1 {
  margin: 0;
  font-size: 1.08rem;
  color: #fffaf0;
}

.subtitle {
  margin: 2px 0 0;
  font-size: 0.84rem;
  color: rgba(255, 250, 240, 0.84);
}

.tabs {
  display: flex;
  gap: 8px;
}

.tab {
  background: rgba(255, 255, 255, 0.12);
  color: #fffaf0;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 999px;
  padding: 7px 15px;
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
}

.tab.active {
  background: #fffaf0;
  color: #1f4f32;
}

main {
  padding-top: 22px;
  padding-bottom: 32px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.card h2 {
  margin: 0 0 8px;
  font-size: 1.25rem;
}

.muted {
  color: var(--muted);
  font-size: 0.9rem;
}

.req { color: var(--red); }

.honeypot {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.kind-grid {
  border: 0;
  padding: 0;
  margin: 16px 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}

.kind-grid legend {
  font-weight: 700;
  font-size: 0.92rem;
  margin-bottom: 8px;
}

.kind-pill {
  position: relative;
  display: block;
  cursor: pointer;
}

.kind-pill input {
  position: absolute;
  opacity: 0;
}

.kind-pill span {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 11px 12px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
  transition: border-color 0.15s, background 0.15s;
}

.kind-pill small {
  color: var(--muted);
  font-size: 0.78rem;
}

.kind-pill input:checked + span {
  border-color: var(--green-700);
  background: color-mix(in srgb, var(--green-700) 11%, var(--card));
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.field-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

label {
  font-weight: 600;
  font-size: 0.92rem;
}

input[type="text"],
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
  color: var(--fg);
  background: var(--bg);
}

input[type="text"]:focus,
textarea:focus {
  outline: 2px solid var(--green-700);
  border-color: var(--green-700);
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.diag-box {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 14px;
  background: var(--bg);
}

.diag-box summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
}

.diag-box textarea {
  margin-top: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.84rem;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
}

.actions-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 9px 20px;
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  border: 1px solid transparent;
}

.btn-primary {
  background: linear-gradient(135deg, var(--green-800), var(--green-700));
  color: #ffffff;
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-outline {
  background: transparent;
  color: var(--fg);
  border-color: var(--line);
}

.alert {
  padding: 11px 14px;
  border-radius: 10px;
  margin: 12px 0;
  font-size: 0.92rem;
}

.alert-error {
  background: color-mix(in srgb, var(--red) 14%, var(--card));
  border: 1px solid var(--red);
  color: var(--red);
}

.result-box {
  margin-top: 16px;
  padding: 18px;
  border-radius: 12px;
  border: 1px solid var(--green-700);
  background: color-mix(in srgb, var(--green-700) 9%, var(--card));
}

.track-row {
  display: flex;
  gap: 10px;
  margin: 14px 0;
}

.ticket-view {
  margin-top: 16px;
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.ticket-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.badge {
  display: inline-block;
  border-radius: 999px;
  padding: 3px 11px;
  font-size: 0.8rem;
  font-weight: 700;
}

.badge-open {
  background: color-mix(in srgb, var(--orange) 22%, var(--card));
  color: var(--fg);
}

.badge-closed {
  background: color-mix(in srgb, var(--green-700) 20%, var(--card));
  color: var(--green-700);
}

.reply-card {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg);
}

.reply-meta {
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 6px;
}

.reply-body {
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
}

.footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.82rem;
  padding-bottom: 24px;
}
