:root {
  --bg: #f4f5f8;
  --surface: #ffffff;
  --text: #16181d;
  --muted: #5f6672;
  --border: #dde1e7;
  --primary: #2f6df6;
  --primary-hover: #2459d1;
  --primary-text: #ffffff;
  --danger: #d23f3f;
  --success: #1f9d55;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 8px 24px rgba(16, 24, 40, 0.06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --surface: #171a21;
    --text: #e8eaef;
    --muted: #9aa3b2;
    --border: #2a2f3a;
    --primary: #5b8cff;
    --primary-hover: #7aa0ff;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); }

/* ---------- Header / Footer ---------- */
.site-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; font-weight: 600; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 8px;
  background: var(--primary); color: #fff;
  display: grid; place-items: center;
  font-size: 13px; font-weight: 700; letter-spacing: 0.5px;
}
.lang-switch { display: flex; border: 1px solid var(--border); border-radius: 999px; overflow: hidden; background: var(--surface); }
.lang-switch button {
  border: 0; background: transparent; color: var(--muted);
  padding: 6px 12px; cursor: pointer; font: inherit; font-size: 13px; font-weight: 600;
}
.lang-switch button[aria-pressed="true"] { background: var(--primary); color: #fff; }
.user-box { display: flex; align-items: center; gap: 12px; font-size: 14px; color: var(--muted); }
.site-footer { text-align: center; color: var(--muted); font-size: 13px; padding: 20px; }
.site-footer a { color: inherit; }

/* ---------- Layout ---------- */
.container { flex: 1; width: 100%; max-width: 680px; margin: 0 auto; padding: 16px 16px 48px; }
.container.wide { max-width: 1100px; }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow);
}
.card.narrow { max-width: 440px; margin: 40px auto; }
h1 { font-size: 26px; margin: 0 0 6px; letter-spacing: -0.01em; }
h2 { font-size: 20px; margin: 0 0 8px; }
.lead { color: var(--muted); margin: 0 0 24px; }
.muted { color: var(--muted); }
.hidden { display: none !important; }
pre {
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
  padding: 12px; overflow: auto; font-size: 13px;
}
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.95em; }

/* ---------- Formular ---------- */
.field { margin-bottom: 18px; }
.field label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 6px; }
input[type="text"], input[type="email"], input[type="password"], input[type="search"], select, textarea {
  width: 100%; font: inherit; color: inherit;
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 12px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 25%, transparent);
}
textarea { resize: vertical; min-height: 140px; }
input[type="file"] { font: inherit; font-size: 14px; color: var(--muted); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.hint { font-size: 13px; color: var(--muted); margin: 6px 0 0; }
.error { color: var(--danger); font-size: 13px; margin: 6px 0 0; }
.error:empty { display: none; }
.form-error { margin: 0 0 14px; font-weight: 600; }
.field.invalid input, .field.invalid textarea { border-color: var(--danger); }
.honeypot { position: absolute; left: -10000px; top: auto; width: 1px; height: 1px; overflow: hidden; }
.checkbox label { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; font-size: 14px; }
.checkbox input { margin-top: 4px; flex: none; }

.btn-primary, .btn-secondary {
  font: inherit; font-weight: 600; border-radius: 8px;
  padding: 11px 18px; cursor: pointer; border: 1px solid transparent;
  text-decoration: none; display: inline-block; text-align: center;
}
.btn-primary { background: var(--primary); color: var(--primary-text); width: 100%; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:disabled { opacity: 0.6; cursor: default; }
.btn-secondary { background: transparent; color: var(--text); border-color: var(--border); }
.btn-secondary:hover { border-color: var(--muted); }
.btn-secondary.small { padding: 6px 12px; font-size: 13px; }
.btn-secondary.danger { color: var(--danger); }

.file-list { list-style: none; padding: 0; margin: 10px 0 0; display: flex; flex-direction: column; gap: 6px; }
.file-list li {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  font-size: 13px; background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; padding: 6px 10px;
}
.file-list button { border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 18px; line-height: 1; }
.file-list button:hover { color: var(--danger); }

.success { text-align: center; }
.success-icon {
  width: 56px; height: 56px; border-radius: 50%;
  background: color-mix(in srgb, var(--success) 15%, transparent);
  color: var(--success); display: grid; place-items: center;
  font-size: 28px; font-weight: 700; margin: 0 auto 16px;
}
.success p { margin: 0 0 20px; }

/* ---------- Admin ---------- */
.toolbar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tabs button {
  font: inherit; font-size: 13px; font-weight: 600;
  border: 1px solid var(--border); background: var(--surface); color: var(--muted);
  border-radius: 999px; padding: 6px 12px; cursor: pointer;
}
.tabs button[aria-pressed="true"] { background: var(--primary); border-color: var(--primary); color: #fff; }
.toolbar input[type="search"] { flex: 1; min-width: 200px; }
.split { display: grid; grid-template-columns: 360px minmax(0, 1fr); gap: 16px; align-items: start; }
.ticket-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; max-height: 78vh; overflow: auto; }
.ticket-list li { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; cursor: pointer; }
.ticket-list li.empty { cursor: default; text-align: center; }
.ticket-list li:hover { border-color: var(--muted); }
.ticket-list li[aria-selected="true"] {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary) 25%, transparent);
}
.ticket-list .row { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; color: var(--muted); }
.ticket-list .subject { font-weight: 600; margin: 4px 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge {
  display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px;
  background: var(--bg); border: 1px solid var(--border);
  text-transform: uppercase; letter-spacing: 0.03em; white-space: nowrap;
}
.badge.open { color: var(--primary); }
.badge.in_progress { color: #b7791f; }
.badge.waiting { color: #8a63d2; }
.badge.resolved { color: var(--success); }
.badge.closed { color: var(--muted); }
.ticket-detail { min-height: 200px; }
.detail-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 12px; }
.detail-head h2 { margin: 0; }
.ticket-detail dl { display: grid; grid-template-columns: 130px 1fr; gap: 6px 12px; margin: 0 0 16px; font-size: 14px; }
.ticket-detail dt { color: var(--muted); }
.ticket-detail dd { margin: 0; word-break: break-word; }
.message-box { white-space: pre-wrap; word-break: break-word; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 12px; margin-bottom: 16px; }
.attachments { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.attachments:empty { display: none; }
.attachments a { display: block; }
.attachments img { width: 120px; height: 120px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); display: block; }
.attachments .file { width: 120px; height: 120px; display: grid; place-items: center; border: 1px solid var(--border); border-radius: 8px; font-size: 12px; padding: 8px; text-align: center; word-break: break-all; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.actions .btn-primary { width: auto; }

@media (max-width: 860px) {
  .split { grid-template-columns: 1fr; }
  .ticket-list { max-height: 40vh; }
}
@media (max-width: 560px) {
  .grid-2 { grid-template-columns: 1fr; }
  .card { padding: 20px; }
  h1 { font-size: 22px; }
  .ticket-detail dl { grid-template-columns: 1fr; gap: 2px; }
  .ticket-detail dt { margin-top: 6px; }
}
