*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --orange: #E8620A;
  --orange-light: #FFF0E8;
  --orange-border: #F0874A;
  --bg: #f0eeea;
  --surface: #ffffff;
  --border: #dedad3;
  --text: #1a1a1a;
  --muted: #888;
  --green: #1f8a4c;
  --green-light: #e8f7ee;
  --red: #c0392b;
  --red-light: #fdecea;
  --yellow: #b8860b;
  --yellow-light: #fff8e1;
}
html, body { font-family: 'Segoe UI', system-ui, -apple-system, sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; font-size: 14px; }
a { text-decoration: none; }

/* ---------- HEADER / NAV ---------- */
header {
  background: var(--surface); border-bottom: 2px solid var(--orange);
  padding: 12px 22px; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  position: sticky; top: 0; z-index: 100; box-shadow: 0 2px 10px rgba(232,98,10,0.1);
  flex-wrap: wrap;
}
.logo { display: flex; align-items: center; gap: 8px; font-size: 16px; font-weight: 800; color: var(--orange); }
.logo-badge { background: var(--orange); color: white; font-size: 10px; font-weight: 700; padding: 3px 8px; border-radius: 4px; }
.nav-links { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.nav-links a, .nav-links span.nav-user { color: var(--text); font-size: 13px; font-weight: 600; padding: 7px 12px; border-radius: 7px; transition: background 0.15s; }
.nav-links a:hover { background: var(--orange-light); color: var(--orange); }
.nav-links a.active { background: var(--orange); color: white; }
.nav-user { color: var(--muted); font-size: 12px; }

.btn { display: inline-flex; align-items: center; gap: 6px; padding: 9px 16px; border-radius: 8px; border: none; cursor: pointer; font-size: 13px; font-weight: 700; transition: all 0.15s; white-space: nowrap; }
.btn-orange { background: var(--orange); color: white; }
.btn-orange:hover { background: #c4530a; }
.btn-ghost { background: white; color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg); }
.btn-danger { background: var(--red); color: white; }
.btn-danger:hover { background: #a3291c; }
.btn-sm { padding: 6px 11px; font-size: 12px; }
.btn-block { width: 100%; justify-content: center; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- LAYOUT ---------- */
.container { max-width: 1100px; margin: 0 auto; padding: 28px 20px 60px; }
.container-narrow { max-width: 460px; margin: 0 auto; padding: 50px 20px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 13px; padding: 24px; box-shadow: 0 2px 10px rgba(0,0,0,0.04); }
.page-title { font-size: 22px; font-weight: 800; margin-bottom: 6px; }
.page-sub { color: var(--muted); font-size: 13px; margin-bottom: 24px; }

/* ---------- FORMS ---------- */
.form-field { margin-bottom: 16px; }
.form-field label { display: block; font-size: 11px; font-weight: 700; color: var(--muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.04em; }
.form-field input, .form-field select, .form-field textarea {
  width: 100%; border: 1.5px solid var(--border); border-radius: 8px; padding: 11px 13px;
  font-size: 14px; font-family: inherit; color: var(--text); outline: none; background: var(--bg);
}
.form-field textarea { resize: vertical; min-height: 110px; }
.form-field input:focus, .form-field select:focus, .form-field textarea:focus { border-color: var(--orange); background: white; }
.form-error { background: var(--red-light); color: var(--red); border: 1px solid #f3c4be; border-radius: 8px; padding: 10px 13px; font-size: 12.5px; margin-bottom: 14px; display: none; }
.form-error.show { display: block; }
.form-success { background: var(--green-light); color: var(--green); border: 1px solid #b9e4c9; border-radius: 8px; padding: 10px 13px; font-size: 12.5px; margin-bottom: 14px; display: none; }
.form-success.show { display: block; }
.form-footnote { text-align: center; font-size: 12.5px; color: var(--muted); margin-top: 18px; }
.form-footnote a { color: var(--orange); font-weight: 700; }

/* ---------- AUTH BOX ---------- */
.auth-box { text-align: center; margin-bottom: 26px; }
.auth-badge {
  display: inline-flex; align-items: center; justify-content: center;
  width: 56px; height: 56px; border-radius: 14px;
  background: var(--orange); color: white; font-size: 22px; font-weight: 900;
  margin-bottom: 16px; box-shadow: 0 8px 20px rgba(232,98,10,0.3);
}
.auth-box h1 { font-size: 20px; font-weight: 800; margin-bottom: 6px; }
.auth-box p { font-size: 13px; color: var(--muted); }

/* ---------- DASHBOARD / TICKET LIST ---------- */
.dash-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 22px; flex-wrap: wrap; }
.stat-row { display: flex; gap: 12px; margin-bottom: 24px; flex-wrap: wrap; }
.stat-card { flex: 1; min-width: 140px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px 18px; }
.stat-card .stat-num { font-size: 24px; font-weight: 800; color: var(--orange); }
.stat-card .stat-label { font-size: 12px; color: var(--muted); margin-top: 2px; }

.ticket-list { display: flex; flex-direction: column; gap: 10px; }
.ticket-row {
  background: var(--surface); border: 1px solid var(--border); border-radius: 11px;
  padding: 16px 18px; display: flex; align-items: center; justify-content: space-between;
  gap: 14px; cursor: pointer; transition: all 0.15s; flex-wrap: wrap;
}
.ticket-row:hover { border-color: var(--orange-border); box-shadow: 0 3px 14px rgba(232,98,10,0.1); }
.ticket-row-new { border-color: var(--orange); background: var(--orange-light); }
.ticket-row-new:hover { box-shadow: 0 3px 14px rgba(232,98,10,0.2); }
.new-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--orange); margin-right: 7px; box-shadow: 0 0 0 3px rgba(232,98,10,0.18); }
.ticket-main { flex: 1; min-width: 200px; }
.ticket-subject { font-size: 14.5px; font-weight: 700; margin-bottom: 4px; }
.ticket-meta { font-size: 12px; color: var(--muted); display: flex; gap: 10px; flex-wrap: wrap; }
.ticket-tags { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }

.badge { display: inline-flex; align-items: center; padding: 4px 10px; border-radius: 99px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.badge-open { background: var(--green-light); color: var(--green); }
.badge-pending { background: var(--yellow-light); color: var(--yellow); }
.badge-closed { background: #eee; color: var(--muted); }
.badge-low { background: var(--green-light); color: var(--green); }
.badge-medium { background: var(--yellow-light); color: var(--yellow); }
.badge-high { background: var(--red-light); color: var(--red); }

.empty-state { text-align: center; padding: 70px 24px; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 12px; }
.empty-state .emoji { font-size: 42px; opacity: 0.4; }
.empty-state h2 { font-size: 15px; font-weight: 700; color: #555; }
.empty-state p { font-size: 12.5px; line-height: 1.6; max-width: 320px; }
.loading-state { text-align: center; padding: 60px 24px; color: var(--muted); font-size: 13px; }

/* ---------- MODAL ---------- */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 200; align-items: center; justify-content: center; padding: 16px; }
.modal-overlay.open { display: flex; }
.modal { background: white; border-radius: 14px; padding: 26px; width: 100%; max-width: 440px; box-shadow: 0 20px 60px rgba(0,0,0,0.3); max-height: 90vh; overflow-y: auto; }
.modal h2 { font-size: 16px; font-weight: 800; color: var(--orange); margin-bottom: 18px; }
.modal-actions { display: flex; gap: 8px; margin-top: 18px; justify-content: flex-end; }

/* ---------- TICKET DETAIL ---------- */
.ticket-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.ticket-header h1 { font-size: 19px; font-weight: 800; margin-bottom: 8px; }
.back-link { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); font-weight: 700; margin-bottom: 14px; }
.back-link:hover { color: var(--orange); }

.thread { display: flex; flex-direction: column; gap: 12px; margin: 20px 0; }
.msg { max-width: 78%; padding: 12px 15px; border-radius: 12px; font-size: 13.5px; line-height: 1.5; }
.msg-meta { font-size: 11px; color: var(--muted); margin-bottom: 4px; font-weight: 700; }
.msg.user { align-self: flex-start; background: var(--bg); border: 1px solid var(--border); border-bottom-left-radius: 3px; }
.msg.admin { align-self: flex-end; background: var(--orange-light); border: 1px solid var(--orange-border); border-bottom-right-radius: 3px; }
.msg.admin .msg-meta { color: var(--orange); }

.reply-box { display: flex; gap: 10px; align-items: flex-end; margin-top: 18px; }
.reply-box textarea { flex: 1; min-height: 50px; }

.select-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.select-row .form-field { margin-bottom: 0; min-width: 150px; }

/* ---------- ADMIN ---------- */
.filter-bar { display: flex; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; align-items: center; }
.filter-bar select { border: 1.5px solid var(--border); border-radius: 8px; padding: 8px 12px; font-size: 13px; background: white; cursor: pointer; }

/* ---------- LANDING (index) ---------- */
.hero { text-align: center; padding: 70px 20px 50px; }
.hero h1 { font-size: 30px; font-weight: 800; margin-bottom: 12px; }
.hero h1 span { color: var(--orange); }
.hero p { font-size: 14.5px; color: var(--muted); max-width: 480px; margin: 0 auto 28px; line-height: 1.6; }
.hero-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.feature-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; max-width: 900px; margin: 40px auto 0; padding: 0 20px; }
.feature-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 20px; text-align: center; }
.feature-card .icon { font-size: 26px; margin-bottom: 10px; }
.feature-card h3 { font-size: 14px; font-weight: 700; margin-bottom: 6px; }
.feature-card p { font-size: 12.5px; color: var(--muted); line-height: 1.5; }

/* ---------- UTIL ---------- */
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.mt-12 { margin-top: 12px; }
.mt-20 { margin-top: 20px; }
.hidden { display: none !important; }
@media (max-width: 600px) {
  .msg { max-width: 92%; }
  header { padding: 10px 14px; }
  .nav-links a, .nav-links span.nav-user { padding: 6px 9px; font-size: 12px; }
}
