:root {
  --navy: #0f2747;
  --navy-700: #1a3a63;
  --blue: #2563eb;
  --blue-700: #1d4ed8;
  --ink: #0f172a;
  --slate: #475569;
  --muted: #64748b;
  --line: #e2e8f0;
  --bg: #f1f5f9;
  --card: #ffffff;
  --gold: #b8862b;
  --green: #15803d;
  --green-bg: #dcfce7;
  --amber: #b45309;
  --amber-bg: #fef3c7;
  --red: #b91c1c;
  --red-bg: #fee2e2;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(15,23,42,.06), 0 8px 24px rgba(15,23,42,.06);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--blue-700); }

.site-header {
  background: linear-gradient(180deg, var(--navy) 0%, var(--navy-700) 100%);
  color: #fff;
  border-bottom: 3px solid var(--gold);
}
.site-header .wrap { display: flex; align-items: center; gap: 14px; padding: 18px 22px; }
.crest {
  width: 42px; height: 42px; flex: none; border-radius: 50%;
  background: var(--gold); color: var(--navy);
  display: grid; place-items: center; font-weight: 800; font-size: 18px;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.25);
}
.site-header h1 { font-size: 18px; margin: 0; line-height: 1.2; letter-spacing: .2px; }
.site-header .sub { margin: 2px 0 0; font-size: 13px; color: #c7d2e4; }
.site-header nav { margin-left: auto; display: flex; gap: 18px; }
.site-header nav a { color: #dbe4f0; text-decoration: none; font-size: 14px; }
.site-header nav a:hover { color: #fff; }

.wrap { max-width: 760px; margin: 0 auto; padding: 0 22px; }
.page { padding: 28px 0 64px; }
.lead { color: var(--slate); font-size: 16px; margin: 0 0 22px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 26px;
}
.card + .card { margin-top: 18px; }

h2 { font-size: 20px; margin: 0 0 4px; }
.section-note { color: var(--muted); font-size: 14px; margin: 0 0 18px; }

label { display: block; font-weight: 600; font-size: 14px; margin: 16px 0 6px; color: var(--ink); }
label .req { color: var(--red); }
.hint { font-weight: 400; color: var(--muted); font-size: 13px; }

input, select, textarea {
  width: 100%;
  font: inherit;
  color: var(--ink);
  padding: 11px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 9px;
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
textarea { min-height: 120px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 560px) { .row { grid-template-columns: 1fr; } }

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

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: 600; cursor: pointer;
  padding: 12px 20px; border-radius: 9px; border: 1px solid transparent;
  background: var(--blue); color: #fff;
  transition: background .15s, transform .05s;
}
.btn:hover { background: var(--blue-700); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .6; cursor: progress; }
.btn.secondary { background: #fff; color: var(--navy); border-color: #cbd5e1; }
.btn.secondary:hover { background: #f8fafc; }
.btn.ghost { background: transparent; color: var(--slate); border-color: transparent; padding: 8px 10px; }
.btn-row { margin-top: 22px; display: flex; gap: 10px; align-items: center; }

.msg { margin-top: 16px; padding: 12px 14px; border-radius: 9px; font-size: 14px; display: none; }
.msg.show { display: block; }
.msg.error { background: var(--red-bg); color: var(--red); border: 1px solid #fecaca; }
.msg.ok { background: var(--green-bg); color: var(--green); border: 1px solid #bbf7d0; }

.success-ticket {
  font-size: 26px; font-weight: 800; letter-spacing: 1px; color: var(--navy);
  background: #f8fafc; border: 1px dashed #cbd5e1; border-radius: 10px;
  padding: 14px; text-align: center; margin: 10px 0 16px;
}

/* status badges */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12.5px; font-weight: 700; padding: 3px 10px; border-radius: 999px;
  white-space: nowrap;
}
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.b-New { background: #e0edff; color: #1d4ed8; }
.b-Acknowledged { background: #ede9fe; color: #6d28d9; }
.b-InProgress { background: var(--amber-bg); color: var(--amber); }
.b-Resolved { background: var(--green-bg); color: var(--green); }
.b-Closed { background: #e2e8f0; color: var(--slate); }

.pri { font-size: 12px; font-weight: 700; }
.pri-Urgent { color: var(--red); }
.pri-High { color: var(--amber); }
.pri-Normal { color: var(--muted); }
.pri-Low { color: var(--muted); }

/* timeline */
.timeline { list-style: none; margin: 8px 0 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 18px 24px; border-left: 2px solid var(--line); }
.timeline li:last-child { border-left-color: transparent; padding-bottom: 0; }
.timeline li::before {
  content: ""; position: absolute; left: -7px; top: 3px; width: 12px; height: 12px;
  border-radius: 50%; background: var(--blue); box-shadow: 0 0 0 3px #fff;
}
.timeline .when { color: var(--muted); font-size: 12.5px; }
.timeline .what { margin: 2px 0 0; }

.footer { text-align: center; color: var(--muted); font-size: 13px; padding: 26px 22px; }

/* ---------- admin ---------- */
.admin-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.admin-wrap { max-width: 1140px; }
.stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 18px; }
@media (max-width: 760px) { .stats { grid-template-columns: repeat(2, 1fr); } }
.stat { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; cursor: pointer; }
.stat:hover { border-color: var(--blue); }
.stat.active { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.stat .n { font-size: 24px; font-weight: 800; color: var(--navy); }
.stat .k { font-size: 12.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar input, .toolbar select { width: auto; }
.toolbar input[type=search] { min-width: 240px; flex: 1; }

table.tickets { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
table.tickets th, table.tickets td { text-align: left; padding: 11px 13px; border-bottom: 1px solid var(--line); font-size: 14px; vertical-align: top; }
table.tickets th { background: #f8fafc; color: var(--slate); font-size: 12px; text-transform: uppercase; letter-spacing: .4px; }
table.tickets tr:last-child td { border-bottom: none; }
table.tickets tbody tr { cursor: pointer; }
table.tickets tbody tr:hover { background: #f8fbff; }
.tnum { font-weight: 700; color: var(--navy); white-space: nowrap; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }

/* modal */
.overlay { position: fixed; inset: 0; background: rgba(15,23,42,.55); display: none; align-items: flex-start; justify-content: center; padding: 30px 16px; overflow-y: auto; z-index: 50; }
.overlay.show { display: flex; }
.modal { background: #fff; border-radius: 14px; max-width: 640px; width: 100%; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal header { display: flex; align-items: center; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.modal header h3 { margin: 0; font-size: 17px; }
.modal .x { margin-left: auto; background: none; border: none; font-size: 22px; cursor: pointer; color: var(--muted); line-height: 1; }
.modal .body { padding: 20px 22px; }
.kv { display: grid; grid-template-columns: 120px 1fr; gap: 6px 14px; font-size: 14px; margin-bottom: 8px; }
.kv .k { color: var(--muted); }
.desc-box { background: #f8fafc; border: 1px solid var(--line); border-radius: 9px; padding: 12px 14px; white-space: pre-wrap; margin: 10px 0 4px; }
.divider { height: 1px; background: var(--line); margin: 18px 0; }
.note-internal { color: var(--slate); }
.note-public { color: var(--ink); }
.tag-pub { font-size: 11px; font-weight: 700; color: var(--green); background: var(--green-bg); padding: 1px 7px; border-radius: 999px; margin-left: 6px; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; margin: 10px 0; }
.check input { width: auto; }
.login-card { max-width: 380px; margin: 60px auto; }
.spin { display:inline-block; width:14px; height:14px; border:2px solid rgba(255,255,255,.5); border-top-color:#fff; border-radius:50%; animation:spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
