/* ============================================================
   TickIt — Support Ticket System  ·  Styles
   Mobile-first, modern SaaS look.
   ============================================================ */

:root {
  --primary: #d4af37;              /* gold */
  --primary-600: #a8871f;          /* dark gold */
  --primary-050: #faf5e4;          /* light gold tint */
  --violet: #b18f1f;               /* secondary accent */
  --grad: linear-gradient(135deg, #e6c44a, #b18f1f);
  --bg: #f5f4f0;                   /* warm off-white */
  --surface: #ffffff;
  --surface-2: #f8f7f4;
  --text: #17150f;                 /* near-black */
  --text-soft: #44403c;
  --text-muted: #8a8478;
  --border: #e7e3da;
  --border-strong: #cfc8b8;
  --success: #10b981;
  --success-050: #d1fae5;
  --warning: #f59e0b;
  --warning-050: #fef3c7;
  --danger: #ef4444;
  --danger-050: #fee2e2;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(23, 21, 15, .05), 0 1px 3px rgba(23, 21, 15, .06);
  --shadow-md: 0 6px 18px rgba(23, 21, 15, .07);
  --shadow-lg: 0 16px 40px rgba(23, 21, 15, .16);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

img, svg { vertical-align: middle; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0 0 .5em; font-weight: 700; letter-spacing: -.02em; }
p { margin: 0 0 1em; }

.container {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 20px;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--primary);
  color: #fff;
  padding: 10px 16px;
  border-radius: 0 0 10px 0;
  z-index: 100;
}
.skip-link:focus { left: 0; }

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

/* ---------- Header / navigation ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, .86);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 64px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 800;
  font-size: 18px;
  letter-spacing: -.02em;
}
.brand:hover { text-decoration: none; }

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 11px;
  background: var(--grad);
  color: #fff;
  box-shadow: 0 6px 14px rgba(177, 143, 31, .35);
}

.main-nav {
  display: flex;
  align-items: center;
  gap: 6px;
}

.nav-link {
  padding: 9px 14px;
  border-radius: 10px;
  color: var(--text-soft);
  font-weight: 600;
  font-size: 14.5px;
  transition: background .15s ease, color .15s ease;
}
.nav-link:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-link.is-active { background: var(--primary-050); color: var(--primary-600); }
.nav-link--staff { color: var(--text-muted); }

.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 42px;
  height: 42px;
  padding: 0 10px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
}
.nav-toggle span {
  display: block;
  height: 2px;
  width: 100%;
  background: var(--text);
  border-radius: 2px;
  transition: transform .2s ease, opacity .2s ease;
}
.nav-toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.nav-toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border: 1px solid transparent;
  border-radius: 11px;
  font-family: var(--font);
  font-size: 15px;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  text-decoration: none;
  transition: transform .12s ease, box-shadow .15s ease, background .15s ease, border-color .15s ease;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:focus-visible { outline: 3px solid rgba(212, 175, 55, .45); outline-offset: 2px; }

.btn-primary { background: var(--grad); color: #1c1a12; box-shadow: 0 8px 18px rgba(177, 143, 31, .28); }
.btn-primary:hover { box-shadow: 0 10px 24px rgba(177, 143, 31, .36); }

.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); box-shadow: var(--shadow-sm); }
.btn-secondary:hover { border-color: var(--border-strong); background: var(--surface-2); }

.btn-dark { background: #0f172a; color: #fff; }
.btn-dark:hover { background: #1e293b; }

.btn-danger { background: var(--danger-050); color: #b91c1c; }
.btn-danger:hover { background: #fecaca; }

.btn-success { background: var(--success-050); color: #047857; }
.btn-success:hover { background: #a7f3d0; }

.btn-delete { background: transparent; color: #b91c1c; border-color: #fecaca; }
.btn-delete:hover { background: #fee2e2; border-color: #fca5a5; }

.btn-warning { background: var(--warning-050); color: #92400e; }
.btn-warning:hover { background: #fde68a; }

.btn-sm { padding: 8px 13px; font-size: 13.5px; border-radius: 9px; }
.btn-block { width: 100%; }

/* ---------- Forms ---------- */
.field { margin-bottom: 18px; }
.field label {
  display: block;
  margin-bottom: 7px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-soft);
}
.field .hint { display: block; margin-top: 6px; font-size: 12.5px; color: var(--text-muted); }

.input, .select, .textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(212, 175, 55, .18);
}
.textarea { resize: vertical; min-height: 120px; line-height: 1.55; }
.select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 40px;
}

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
.form-row { display: flex; gap: 12px; flex-wrap: wrap; }
.form-row .btn { margin-right: 0; }
.char-count { float: right; font-size: 12px; color: var(--text-muted); margin-top: 6px; }
.char-count.is-over { color: var(--danger); font-weight: 600; }

/* ---------- Alerts ---------- */
.alert {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid transparent;
  font-size: 14.5px;
  margin-bottom: 20px;
}
.alert svg { flex: none; margin-top: 2px; }
.alert a { font-weight: 600; }
.alert-success { background: #ecfdf5; border-color: #a7f3d0; color: #065f46; }
.alert-error { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.alert-info { background: #eff6ff; border-color: #bfdbfe; color: #1e40af; }
.alert-warning { background: #fffbeb; border-color: #fde68a; color: #92400e; }

/* ---------- Hero / page header ---------- */
.hero {
  text-align: center;
  padding: 56px 0 40px;
}
.hero h1 { font-size: clamp(28px, 5vw, 42px); line-height: 1.15; margin-bottom: 14px; }
.hero p { color: var(--text-soft); font-size: 17px; max-width: 620px; margin: 0 auto; }
.hero .hero-eyebrow {
  display: inline-block;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--primary-050);
  color: var(--primary-600);
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 18px;
}

.page-head { padding: 36px 0 8px; text-align: center; }
.page-head h1 { font-size: clamp(24px, 4vw, 32px); margin-bottom: 6px; }
.page-head p { color: var(--text-soft); margin: 0; }

/* ---------- Cards / panels ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card-pad { padding: 26px; }
.card + .card { margin-top: 20px; }

.card-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 17px;
  margin: 0 0 4px;
}
.card-subtitle { color: var(--text-muted); font-size: 14px; margin: 0 0 20px; }

.icon-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: var(--primary-050);
  color: var(--primary);
  flex: none;
}

/* ---------- Landing grid ---------- */
.landing-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 24px;
  align-items: start;
  padding: 8px 0 60px;
}

/* ---------- Ticket info / meta ---------- */
.ticket-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}
.ticket-head h1 { font-size: 22px; margin: 0; word-break: break-word; }
.ticket-head-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}
.see-all-tickets {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
  text-decoration: none;
  white-space: nowrap;
}
.see-all-tickets:hover { text-decoration: underline; }
.ticket-num {
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--primary-600);
  background: var(--primary-050);
  padding: 5px 11px;
  border-radius: 8px;
  letter-spacing: .3px;
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 22px;
}
.meta-item {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
}
.meta-item .meta-label {
  display: block;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.meta-item .meta-value { font-size: 14.5px; font-weight: 600; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 11px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 700;
  line-height: 1.4;
}
.badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.badge-open { background: var(--success-050); color: #047857; }
.badge-inprogress { background: #dbeafe; color: #1d4ed8; }
.badge-pending { background: var(--warning-050); color: #b45309; }
.badge-closed { background: #e2e8f0; color: #475569; }
.badge-archived { background: #cbd5e1; color: #334155; }
.prio-low { color: #64748b; }
.prio-normal { color: var(--primary-600); }
.prio-high { color: #b45309; }
.prio-urgent { color: #b91c1c; }

/* ---------- Thread (conversation) ---------- */
.thread { display: flex; flex-direction: column; gap: 16px; }

.msg { display: flex; gap: 12px; }
.msg-avatar {
  flex: none;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  background: #94a3b8;
  text-transform: uppercase;
}
.msg--client .msg-avatar { background: #94a3b8; }
.msg--admin .msg-avatar { background: var(--grad); }

.msg-body {
  max-width: 82%;
  min-width: 0;
}
.msg--client .msg-body { order: 0; }
.msg--admin .msg-body { margin-left: auto; }

.msg-meta {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 13px;
}
.msg-meta .who { font-weight: 700; }
.msg-meta .when { color: var(--text-muted); }

.msg-bubble {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
  white-space: pre-line;
  word-wrap: break-word;
  overflow-wrap: break-word;
  font-size: 15px;
  color: var(--text);
}
.msg--admin .msg-bubble {
  background: linear-gradient(135deg, #faf5e4, #fdf9ec);
  border-color: #e8d9a0;
}
.msg--admin .msg-meta { flex-direction: row-reverse; text-align: right; }
.msg--admin .msg-meta .who { color: var(--primary-600); }

.msg-role {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .4px;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--primary-050);
  color: var(--primary-600);
}
.msg--client .msg-role { background: #e2e8f0; color: #475569; }

/* ---------- Reply box ---------- */
.reply-box { margin-top: 24px; }
.reply-note {
  font-size: 13px;
  color: var(--text-muted);
  margin: 8px 0 0;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ---------- History box ---------- */
.history-card { position: sticky; top: 84px; }
.history-list { list-style: none; margin: 0; padding: 0; }
.history-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 4px;
  border-bottom: 1px solid var(--border);
}
.history-item:last-child { border-bottom: 0; }
.history-item .h-num { font-family: ui-monospace, monospace; font-size: 13px; font-weight: 700; }
.history-item .h-subj {
  color: var(--text-soft);
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.history-item .h-time { font-size: 12px; color: var(--text-muted); }

/* ---------- Two-column ticket layout ---------- */
.ticket-layout {
  display: grid;
  grid-template-columns: 1.7fr 1fr;
  gap: 24px;
  align-items: start;
  padding: 12px 0 60px;
}

/* ---------- Admin ---------- */
.admin-header {
  background: #0f172a;
  color: #fff;
}
.admin-header .header-inner { height: 60px; }
.admin-header .brand { color: #fff; }
.admin-header .brand-mark { background: var(--grad); }
.admin-nav { display: flex; align-items: center; gap: 6px; }
.admin-nav .nav-link { color: #cbd5e1; }
.admin-nav .nav-link:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.admin-nav .nav-link.is-active { background: rgba(255, 255, 255, .12); color: #fff; }

/* Light hamburger bars so the toggle is visible on the dark admin navbar */
.admin-header .nav-toggle {
  border-color: rgba(255, 255, 255, .2);
}
.admin-header .nav-toggle span { background: #fff; }

/* Dark dropdown/menu theme for the admin page when the mobile nav is open */
.admin-header .main-nav {
  background: #0f172a;
  border-bottom: 1px solid rgba(255, 255, 255, .1);
  box-shadow: 0 18px 30px rgba(0, 0, 0, .35);
}
.admin-header .main-nav .nav-link { color: #cbd5e1; }
.admin-header .main-nav .nav-link:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.admin-header .main-nav .nav-link.is-active { background: rgba(255, 255, 255, .12); color: #fff; }

.admin-shell { padding: 28px 0 60px; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-sm);
}
.stat-card .stat-value { font-size: 28px; font-weight: 800; letter-spacing: -.02em; }
.stat-card .stat-label { font-size: 13px; color: var(--text-muted); font-weight: 600; }
.stat-card.stat-open .stat-value { color: #047857; }
.stat-card.stat-pending .stat-value { color: #b45309; }
.stat-card.stat-closed .stat-value { color: #475569; }
.stat-card.stat-total .stat-value { color: var(--primary-600); }

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
}
.filter-bar .search-input {
  flex: 1 1 240px;
  min-width: 160px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-family: var(--font);
  font-size: 14.5px;
}
.filter-bar .search-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px rgba(212,175,55,.18); }

.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--border); border-radius: 11px; padding: 3px; gap: 2px; }

/* Mobile-only status dropdown: hidden on desktop, shown in the <=720px media query */
.filter-bar .status-select { display: none; }
.seg a {
  padding: 7px 14px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-soft);
}
.seg a:hover { text-decoration: none; color: var(--text); }
.seg a.is-active { background: var(--primary); color: #1c1a12; }

.seg button {
  border: 0;
  background: transparent;
  padding: 7px 14px;
  border-radius: 8px;
  font-family: var(--font);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-soft);
  cursor: pointer;
}
.seg button:hover { color: var(--text); }
.seg button.is-active { background: var(--primary); color: #1c1a12; }

.seg label {
  padding: 7px 14px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-soft);
  cursor: pointer;
  user-select: none;
}
.seg label:hover { color: var(--text); }

/* ---------- Lookup tabs (CSS-only — no JS required) ---------- */
.lookup-tabs input[type="radio"] { position: absolute; opacity: 0; pointer-events: none; }
.lookup-tabs .lookup-panel { display: none; }
.lookup-tabs #tab-view:checked ~ .lookup-panel[data-panel="view"],
.lookup-tabs #tab-recover:checked ~ .lookup-panel[data-panel="recover"] { display: block; }
.lookup-tabs #tab-view:checked ~ .seg label[for="tab-view"],
.lookup-tabs #tab-recover:checked ~ .seg label[for="tab-recover"] { background: var(--primary); color: #1c1a12; }

.table-wrap { overflow-x: auto; }
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14.5px;
}
.table th {
  text-align: left;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-muted);
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table tbody tr { transition: background .12s ease; }
.table tbody tr:hover { background: var(--surface-2); }
.table .t-row { display: block; }
.table .t-num { font-family: ui-monospace, monospace; font-weight: 700; font-size: 13px; color: var(--primary-600); }
.table .t-subj { font-weight: 600; }
.table .t-email { color: var(--text-muted); font-size: 13px; }

.pagination { display: flex; gap: 6px; justify-content: center; margin-top: 22px; flex-wrap: wrap; }
.pagination a, .pagination span {
  padding: 8px 13px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-soft);
}
.pagination a:hover { text-decoration: none; border-color: var(--primary); color: var(--primary); }
.pagination .current { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ---------- Auth / login ---------- */
.auth-wrap {
  min-height: calc(100vh - 64px - 120px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
}
.auth-card { width: 100%; max-width: 420px; padding: 34px; }
.auth-card .brand { margin-bottom: 8px; }
.auth-card h1 { font-size: 22px; margin-bottom: 4px; }
.auth-card .auth-sub { color: var(--text-muted); margin: 0 0 22px; }

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 26px 0;
  margin-top: auto;
}
.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  color: var(--text-muted);
  font-size: 14px;
}
.footer-inner p { margin: 0; }
.footer-inner a { color: var(--text-muted); font-weight: 600; }

/* ---------- Utilities ---------- */
.site-main { min-height: 60vh; display: flex; flex-direction: column; }
.mt-0 { margin-top: 0; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 20px; }
.mb-0 { margin-bottom: 0; }
.muted { color: var(--text-muted); }
.small { font-size: 13px; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.table th.text-right,
.table td.text-right { text-align: right; }
.flex { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.grow { flex: 1 1 auto; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .landing-grid, .ticket-layout { grid-template-columns: 1fr; }
  .history-card { position: static; }
}

@media (max-width: 720px) {
  .nav-toggle { display: flex; }
  .main-nav {
    position: absolute;
    top: 64px;
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-md);
    padding: 10px 14px;
    gap: 4px;
    display: none;
  }
  .main-nav.is-open { display: flex; }
  .nav-link { padding: 12px 14px; }

  /* Add horizontal breathing room on small screens (admin dashboard et al.) */
  .container { padding-left: 34px; padding-right: 34px; }
  .admin-shell { padding-left: 0; padding-right: 0; }
  .admin-shell h1 { font-size: 26px; }

  /* Full-bleed heading sections (public hero / page-head) get the same edge
     buffer so their text never runs flush against the sides of the phone */
  .hero, .page-head { padding-left: 34px; padding-right: 34px; }

  /* Admin dashboard: spread the 6 stat cards into a clean 2-column grid
     so they breathe instead of cramming into tiny auto-fit columns */
  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
  }
  .stat-card { padding: 16px; }
  .stat-card .stat-value { font-size: 24px; }

  /* Search field takes the full row on phones so it never squeezes
     or overflows next to the segmented control */
  .filter-bar { gap: 8px; }
  .filter-bar .search-input { flex: 1 1 100%; min-width: 0; }
  /* On phones the status options become a full-width dropdown instead of a
     long inline line that overflows past the viewport edge */
  .filter-bar .seg { display: none; }
  .filter-bar .status-select {
    display: block;
    flex: 1 1 100%;
    width: 100%;
    padding: 10px 14px;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
  }

  .form-grid { grid-template-columns: 1fr; }
  .hero { padding: 40px 0 28px; }
  .msg-body { max-width: 100%; }
  .msg--admin .msg-body { margin-left: 0; }
  .card-pad { padding: 20px; }
  .table .hide-sm { display: none; }

  /* Ticket table: scale it down on small screens so the dashboard
     fits instead of feeling squished against the page edges */
  .table { font-size: 13.5px; }
  .table th { padding: 9px 8px; font-size: 11px; }
  .table td { padding: 10px 8px; }
  .table .t-num { font-size: 12px; }
  .table .t-email { font-size: 12px; }
}

@media (max-width: 480px) {
  /* On very small phones drop the Client column entirely, leaving the
     lean Ticket Number | Subject | Status layout the dashboard needs */
  .table .hide-xs { display: none; }

  /* On the smallest screens keep a comfortable edge buffer so nothing on
     any page runs flush against the sides of the phone */
  .container { padding-left: 26px; padding-right: 26px; }
  .hero, .page-head { padding-left: 26px; padding-right: 26px; }
}

/* ---------- Attachments ---------- */
.attachments { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.attach {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 100%;
  padding: 8px 12px 8px 8px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  text-decoration: none;
  color: var(--text);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.attach:hover { text-decoration: none; border-color: var(--primary); box-shadow: var(--shadow-sm); }
.attach-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--primary-050);
  color: var(--primary-600);
  flex: none;
}
.attach-meta { display: flex; flex-direction: column; min-width: 0; }
.attach-name {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 240px;
}
.attach-size { font-size: 12px; color: var(--text-muted); }
.attach-img {
  flex-direction: column;
  align-items: flex-start;
  padding: 8px;
  width: 180px;
}
.attach-img img {
  width: 100%;
  height: 120px;
  object-fit: cover;
  border-radius: 8px;
  background: var(--surface-2);
}
.attach-img .attach-name { max-width: 164px; }

/* ---------- Admin status controls ---------- */
.status-box {
  margin-top: 24px;
  border: 1px dashed var(--border-strong);
  border-radius: 12px;
  padding: 16px;
  background: var(--surface-2);
}
.status-box h3 { margin-top: 0; }
.status-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.status-form { margin-bottom: 14px; }
.status-form textarea { min-height: 70px; margin-bottom: 8px; }
.status-form .btn { margin-top: 2px; }
.stat-card.stat-inprogress .stat-value { color: #1d4ed8; }
.stat-card.stat-archived .stat-value { color: #334155; }

/* ---------- Modal ---------- */
.modal-open { overflow: hidden; }
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(15, 23, 42, .55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
/* The flex display above overrides the hidden attribute — this keeps the
   modal hidden until it is explicitly opened. */
.modal-backdrop[hidden] { display: none; }
.modal {
  width: 100%;
  max-width: 480px;
  background: var(--surface);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-close {
  background: none;
  border: 0;
  font-size: 24px;
  line-height: 1;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0 6px;
}
.modal-close:hover { color: var(--text); }
.modal-body { padding: 20px; }
.modal-body .field { margin-bottom: 0; }
.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
}

/* ---------- CC recipients (new ticket) ---------- */
.cc-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1.3fr auto;
  gap: 10px;
  margin-bottom: 10px;
  align-items: center;
}
@media (max-width: 720px) {
  .cc-row { grid-template-columns: 1fr 1fr; }
  .cc-row .cc-email { grid-column: 1 / -1; }
  .cc-row .cc-remove { grid-column: 1 / -1; width: max-content; }
}

/* ---------- Admin ticket page layout ---------- */
.ticket-subject { font-size: 20px; margin: 0 0 16px; font-weight: 600; }
.divider { border: 0; border-top: 1px solid var(--border); margin: 20px 0; }
.section-title {
  font-size: 13px;
  margin: 0 0 14px;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--text-muted);
}
.info-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  align-items: start;
}
.info-box {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  background: var(--surface);
  min-width: 0;
}
.info-box h3 {
  margin: 0 0 10px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--text-muted);
}
.info-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 0;
  border-bottom: 1px dashed var(--border);
}
.info-row:last-child { border-bottom: 0; }
.info-label { font-size: 13px; color: var(--text-muted); flex: none; }
.info-value { font-size: 13.5px; font-weight: 600; text-align: right; word-break: break-word; min-width: 0; position: relative; }
/* Editable dropdown rows (Status / Category / Priority) should not be
   cramped against the right edge like a squished table cell. Give the
   button a comfortable minimum width and let it breathe. */
.info-value:has(.inline-edit) {
  flex: 1;
  display: flex;
  justify-content: flex-end;
}
.info-value:has(.inline-edit) .inline-edit {
  min-width: 148px;
  justify-content: space-between;
  white-space: nowrap;
}

/* ---------- Inline edit (click-to-change) values ---------- */
.inline-edit {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  background: none;
  border: 1px dashed transparent;
  border-radius: 8px;
  padding: 3px 7px;
  margin: -3px -7px;
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  color: inherit;
  text-align: right;
  cursor: pointer;
}
.inline-edit:hover,
.inline-edit[aria-expanded="true"] {
  border-color: var(--border-strong);
  background: var(--surface-2);
}
.inline-edit-wrap {
  position: relative;
}
.inline-arrow {
  flex: none;
  font-size: 9px;
  color: var(--text-muted);
  transition: transform .15s ease;
}
.inline-edit[aria-expanded="true"] .inline-arrow {
  transform: rotate(180deg);
}
.inline-menu {
  position: absolute;
  z-index: 60;
  top: calc(100% + 4px);
  right: 0;
  min-width: 172px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 11px;
  box-shadow: 0 10px 28px rgba(23, 21, 15, .16);
  padding: 5px;
}
.inline-menu-item {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  border-radius: 7px;
  padding: 8px 11px;
  font: inherit;
  font-size: 13.5px;
  color: var(--text);
  cursor: pointer;
}
.inline-menu-item:hover { background: var(--surface-2); }
.inline-menu-item:focus-visible {
  outline: 2px solid var(--primary-600);
  outline-offset: -2px;
  background: var(--surface-2);
}
.inline-menu-item--danger { color: var(--danger); }
.inline-menu-item--danger:hover { background: var(--danger-050); }
.inline-menu-item--danger:focus-visible { background: var(--danger-050); }
@media (max-width: 720px) {
  .info-cols { grid-template-columns: 1fr; }
}

/* Hide honeypot field from humans (kept in DOM for bots to find). */
input[name="website"] {
  position: absolute !important;
  left: -9999px !important;
  top: -9999px !important;
  width: 1px !important;
  height: 1px !important;
  overflow: hidden !important;
  opacity: 0;
  pointer-events: none;
}
