*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #16181c;
  --surface: #1e2126;
  --surface2: #252830;
  --border: #2d3038;
  --text: #e5e7eb;
  --text-muted: #9b9d9f;
  --accent: #ef6136;
  --accent-hover: #d4522a;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;
}

html { font-size: 14px; }
body { background: var(--bg); color: var(--text); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; min-height: 100vh; -webkit-font-smoothing: antialiased; line-height: 1.55; overflow-x: hidden; }
h1, h2, h3, h4 { font-weight: 700; letter-spacing: -0.01em; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
a.linklike { color: var(--accent); cursor: pointer; font-weight: 600; }
a.linklike:hover { text-decoration: underline; }

/* ── Nav / Header ── */
.nav { background: #26282c; border-bottom: 1px solid var(--border); padding: 0 20px; display: flex; align-items: center; height: 52px; gap: 8px; position: sticky; top: 0; z-index: 100; }
.nav-logo { font-weight: 700; font-size: 15px; color: var(--text); margin-right: 12px; display: flex; align-items: center; gap: 8px; }
.nav-logo img { height: 22px; display: block; }
.nav-logo span { color: var(--accent); }
.nav-links { display: flex; gap: 2px; flex: 1; }
.nav-link { color: var(--text-muted); padding: 6px 12px; border-radius: 6px; font-size: 13px; cursor: pointer; border: none; background: none; font-family: inherit; font-weight: 500; text-decoration: none; }
.nav-link:hover, .nav-link.active { background: var(--surface2); color: var(--text); text-decoration: none; }
.nav-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.nav-user { font-size: 12px; color: var(--text-muted); }
.nav-logout { color: #ef9a7c; font-size: 13px; font-weight: 600; cursor: pointer; background: none; border: none; padding: 0; font-family: inherit; }
.nav-logout:hover { color: var(--accent); opacity: 1; text-decoration: underline; }

/* ── Layout ── */
.page { padding: 20px; max-width: 1100px; margin: 0 auto; }

/* ── Mobile nav strip ── */
.mobile-nav { display: none; background: #26282c; border-bottom: 1px solid var(--border); padding: 0 12px; overflow-x: auto; white-space: nowrap; }
.mobile-nav button { display: inline-block; color: var(--text-muted); font-size: 13px; padding: 10px 12px; background: none; border: none; font-family: inherit; cursor: pointer; }
.mobile-nav button.active { color: var(--text); font-weight: 600; }
@media (max-width: 768px) {
  .nav { padding: 0 12px; height: 48px; }
  .nav-links { display: none; }
  .nav-logo { font-size: 14px; }
  .mobile-nav { display: block; }
  .page { padding: 12px; }
  .view-toggle, .board { display: none !important; }
}

/* ── Tabs ── */
.tab { display: none; }
.tab.active { display: block; }

/* ── Guide/detail panels ── */
.card, .detail { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 16px; }
.detail summary { cursor: pointer; font-weight: 600; color: var(--text); }
.detail ul { margin: 10px 0 0; padding-left: 20px; }
.detail li { margin-bottom: 6px; font-size: 13px; }

/* ── Buttons ── */
button { font-family: inherit; font-size: 13px; font-weight: 500; padding: 7px 12px; border: 1px solid var(--border); background: var(--surface2); color: var(--text); border-radius: 7px; cursor: pointer; transition: opacity 0.15s; }
button:hover { opacity: 0.85; }
button:active { opacity: 0.7; transform: translateY(1px); }
button[type="submit"],
form.inline button[type="submit"],
.modal-content #d-save,
.modal-content #d-create-job { background: var(--accent); color: #fff; border-color: var(--accent); }
button[type="submit"]:hover { background: var(--accent-hover); border-color: var(--accent-hover); opacity: 1; }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }

/* ── Forms ── */
input, select, textarea { font-family: inherit; font-size: 13px; background: var(--surface2); border: 1px solid var(--border); color: var(--text); border-radius: 7px; padding: 8px 11px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px rgba(239,97,54,0.2); }
input::placeholder, textarea::placeholder { color: var(--text-muted); }
select { cursor: pointer; }
textarea { min-height: 100px; resize: vertical; }

form.inline { background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; padding: 16px; margin-bottom: 16px; }
form.inline label { display: block; margin-top: 14px; font-weight: 600; font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.4px; margin-bottom: 5px; }
form.inline input, form.inline select, form.inline textarea { width: 100%; }
form.inline button[type="submit"] { margin-top: 14px; }
form.inline input[type="checkbox"] { width: auto; }

.filters { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.filters select, .filters input { flex: 1 1 160px; min-width: 0; }

/* ── Tables ── */
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; padding: 9px 12px; border-bottom: 1px solid var(--border); background: var(--surface2); white-space: nowrap; }
td { padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 13px; vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--surface2); }

/* ── Status pills ── */
.status-pill { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px; background: var(--surface2); color: var(--text-muted); }
.status-open { background: #451a03; color: #fcd34d; }
.status-in_progress { background: #1e3a5f; color: #93c5fd; }
.status-resolved { background: #052e16; color: #86efac; }
.status-closed { background: #1f2937; color: #9ca3af; }

/* ── Priority ── */
td .priority-urgent, td .priority-high { color: #fca5a5; font-weight: 600; }
td .priority-normal { color: #93c5fd; }
td .priority-low { color: var(--text-muted); }

/* ── View toggle ── */
.view-toggle { display: flex; gap: 4px; margin-bottom: 16px; }
.view-toggle button { padding: 6px 12px; }
.view-toggle button.active { background: var(--accent); color: #fff; border-color: var(--accent); }
@media (max-width: 768px) { .view-toggle, .board { display: none !important; } }

/* ── Board ── */
.board { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.board-col { background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; padding: 10px; min-height: 140px; }
.board-col h4 { margin: 2px 0 10px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); font-weight: 700; }
.board-col.dragover { border-color: var(--accent); background: rgba(239,97,54,0.07); }
.board-card { background: var(--surface); border: 1px solid var(--border); border-radius: 7px; padding: 10px 11px; margin-bottom: 8px; cursor: grab; transition: border-color 0.15s; }
.board-card:hover { border-color: var(--accent); }
.board-card.dragging { opacity: 0.4; }
.board-card strong { display: block; margin-bottom: 4px; font-size: 13px; font-weight: 600; }
.board-card .meta { color: var(--text-muted); font-size: 11px; }

/* ── SimPro badge ── */
.simpro-badge { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 20px; background: #1e3a5f; color: #93c5fd; margin-left: 6px; vertical-align: middle; white-space: nowrap; }

/* ── Email source badge ── */
.email-badge { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 20px; background: #052e16; color: #86efac; margin-left: 6px; vertical-align: middle; white-space: nowrap; }

/* ── Ticket conversation thread ── */
.thread { margin: 14px 0; display: flex; flex-direction: column; gap: 10px; max-height: 260px; overflow-y: auto; }
.thread-msg { background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; }
.thread-msg-staff { border-left: 3px solid var(--accent); }
.thread-msg-reporter { border-left: 3px solid var(--info); }
.thread-meta { font-size: 11px; color: var(--text-muted); margin-bottom: 4px; }
.thread-body { font-size: 13px; white-space: pre-wrap; }

/* ── Bulk action bar ── */
#bulkActionBar { margin-bottom: 14px; padding: 11px 14px; background: #2d1a0a; border: 1px solid #7c3a1a; border-radius: 8px; font-weight: 600; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 13px; }

/* ── Modals ── */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.72); z-index: 200; display: none; align-items: center; justify-content: center; padding: 20px; backdrop-filter: blur(2px); }
.modal-backdrop.open { display: flex; }
.modal-content { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 22px; max-width: 520px; width: 100%; max-height: 87vh; overflow-y: auto; }
.modal-content h3 { margin: 0 0 14px; font-size: 16px; }
.modal-content input, .modal-content select { width: 100%; margin-top: 8px; }
.modal-content button { margin-top: 10px; margin-right: 8px; }
.modal-content select { margin-right: 0; }
.modal-content label { display: block; margin-top: 12px; font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.4px; }
#d-simpro-search { border-top: 1px solid var(--border); padding-top: 10px; margin-top: 10px; }
.simpro-result-row { padding: 7px 0; border-bottom: 1px solid var(--border); cursor: pointer; color: var(--accent); font-weight: 600; font-size: 13px; }
.simpro-result-row:last-child { border-bottom: none; }

/* ── Knowledge base ── */
.kb-row { margin-bottom: 10px; }
.kb-row .detail { padding: 14px 16px; }
.kb-row .detail button { margin-right: 6px; }

/* ── Misc ── */
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 12px; }
.divider { border: none; border-top: 1px solid var(--border); margin: 14px 0; }
code { background: var(--surface2); border: 1px solid var(--border); border-radius: 4px; padding: 1px 6px; font-size: 12px; }

/* Error/success messages */
.error-msg, #userError, #venueError, #selfError { background: #450a0a; border: 1px solid var(--danger); border-radius: 7px; padding: 10px 12px; color: #fca5a5; font-size: 13px; margin-top: 10px; }
.success-msg { background: #052e16; border: 1px solid var(--success); border-radius: 7px; padding: 10px 12px; color: #86efac; font-size: 13px; }
#d-simpro-error { color: #fca5a5; font-size: 13px; margin-top: 6px; }
#bulk-simpro-error { color: #fca5a5; font-size: 13px; margin-top: 6px; }

/* ── Public header (shared across ticket-new, portal, login pages) ── */
.public-header { background: #26282c; border-bottom: 1px solid var(--border); padding: 15px 24px; display: flex; align-items: center; justify-content: space-between; }
.public-header img.logo { height: 26px; display: block; }
.public-header .header-right { display: flex; align-items: center; gap: 12px; }
.pub-whoami { color: #b7b9bd; font-size: 13px; }
@media (max-width: 600px) { .public-header { justify-content: center; } .public-header .header-right { display: none; } }

/* ── Login pages ── */
.login-wrap { max-width: 360px; margin: 80px auto; padding: 0 20px; }
.login-wrap h1 { font-size: 22px; margin-bottom: 20px; }
.login-wrap input { width: 100%; margin-top: 10px; }
.login-wrap button { margin-top: 16px; width: 100%; padding: 12px; background: var(--accent); color: #fff; border: none; border-radius: 8px; font-weight: 600; font-size: 14px; }
.login-wrap button:hover { background: var(--accent-hover); opacity: 1; }
.login-wrap #error { margin-top: 14px; padding: 10px 12px; border-radius: 7px; background: #450a0a; border: 1px solid var(--danger); color: #fca5a5; font-size: 13px; display: none; }
.hint { color: var(--text-muted); font-size: 13px; margin: 8px 0 4px; }

/* ── Landing page ── */
.landing-wrap { max-width: 640px; margin: 80px auto; padding: 0 20px; text-align: center; }
.landing-wrap h1 { font-size: 2rem; margin-bottom: 12px; }
.landing-wrap p { color: var(--text-muted); font-size: 15px; }
.landing-actions { display: flex; gap: 16px; justify-content: center; margin-top: 32px; flex-wrap: wrap; }
.landing-actions a { display: inline-block; padding: 14px 28px; border-radius: 8px; text-decoration: none; font-weight: 600; font-size: 14px; }
.landing-actions .primary { background: var(--accent); color: #fff; }
.landing-actions .primary:hover { background: var(--accent-hover); }
.landing-actions .secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.landing-actions .secondary:hover { opacity: 0.85; }
.landing-footer { margin-top: 60px; font-size: 12px; color: var(--text-muted); }
.landing-footer a { color: var(--text-muted); }

/* ── Public ticket form ── */
.ticket-form-wrap { max-width: 560px; margin: 40px auto; padding: 0 20px; }
.ticket-form-wrap label { display: block; margin-top: 16px; font-weight: 600; font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.4px; margin-bottom: 5px; }
.ticket-form-wrap input, .ticket-form-wrap select, .ticket-form-wrap textarea { width: 100%; }
.ticket-form-wrap button { margin-top: 24px; padding: 12px 24px; background: var(--accent); color: #fff; border: none; border-radius: 8px; font-weight: 600; font-size: 14px; cursor: pointer; }
.ticket-form-wrap button:hover { background: var(--accent-hover); opacity: 1; }
.ticket-form-wrap button:disabled { opacity: 0.5; cursor: default; }
.ticket-form-wrap #result { margin-top: 20px; padding: 14px; border-radius: 8px; background: #052e16; border: 1px solid var(--success); color: #86efac; display: none; }
.ticket-form-wrap #error { margin-top: 20px; padding: 14px; border-radius: 8px; background: #450a0a; border: 1px solid var(--danger); color: #fca5a5; display: none; }
.back-link { display: inline-block; margin-bottom: 16px; color: var(--text-muted); font-size: 13px; }
.back-link:hover { color: var(--text); }

/* ── Portal ticket cards ── */
.ticket-card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 16px; margin-bottom: 12px; }
.ticket-card h3 { margin: 0 0 8px; font-size: 15px; font-weight: 600; }
.ticket-card p { font-size: 13px; color: var(--text-muted); margin-bottom: 8px; }
.ticket-card .meta { color: var(--text-muted); font-size: 12px; margin-top: 8px; }
.portal-content { max-width: 760px; margin: 24px auto; padding: 0 20px; }
.portal-content h2 { margin-bottom: 16px; font-size: 18px; }
.portal-content > p { color: var(--text-muted); font-size: 13px; margin-bottom: 20px; }
