* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: #F6F5F1;
  color: #20242E;
}

a { text-decoration: none; color: inherit; }

.muted { color: #9A968A; }
.small { font-size: 12px; }
.mono { font-family: "SFMono-Regular", Consolas, monospace; }

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: #20242E;
  border-bottom: 1px solid #14161C;
}
.topbar-left { display: flex; align-items: center; gap: 20px; }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.brand { display: flex; align-items: center; gap: 8px; }
.brand-mark {
  width: 26px; height: 26px; border-radius: 6px;
  background: #EDEBE3; color: #20242E;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 13px;
}
.brand-name { color: #fff; font-weight: 700; font-size: 14px; }
.nav-link { color: #9CA8C9; font-size: 13px; font-weight: 600; }
.nav-link-active, .nav-link:hover { color: #fff; }
.session-info { color: #9CA8C9; font-size: 12px; }
.role-tag { font-weight: 700; }
.role-administrator { color: #F5A6A0; }
.role-user { color: #A9BBF0; }
.role-viewer { color: #C7CCDA; }
.link-btn {
  background: none; border: none; color: #fff; font-weight: 600;
  font-size: 12px; cursor: pointer; padding: 0;
}
.link-btn-danger { color: #B0281E; }

/* Page layout */
.page { max-width: 1100px; margin: 0 auto; padding: 28px 24px 60px; }
.page-narrow { max-width: 640px; }
.page-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 20px; }
.eyebrow { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; font-weight: 700; color: #B8541A; margin-bottom: 4px; }
h1 { font-size: 26px; margin: 0 0 6px; color: #20242E; }

/* Flash messages */
.flash { padding: 10px 14px; border-radius: 6px; font-size: 14px; margin-bottom: 16px; }
.flash-success { background: #E1F3E9; color: #1F6E4A; }
.flash-error { background: #FBEBDF; color: #B0281E; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 18px; border-radius: 6px; font-weight: 600; font-size: 14px;
  border: none; cursor: pointer;
}
.btn-primary { background: #20242E; color: #fff; }
.btn-primary:hover { transform: translateY(-1px); }
.btn-plain { background: none; color: #6B6B63; padding: 10px 8px; }
.btn-block { width: 100%; justify-content: center; }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 8px; border-radius: 4px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; }
.badge-muted { background: #EDEBE3; color: #6B6B63; }
.status-open { background: #FBE4E1; color: #B0281E; }
.status-pending { background: #FBF3D9; color: #8A6D1D; }
.status-on-hold { background: #EFE7F8; color: #6B4FA0; }
.status-solved { background: #E1F3E9; color: #1F6E4A; }
.status-closed { background: #EDEBE3; color: #6B6B63; }

.priority { font-size: 11px; font-weight: 700; text-transform: uppercase; }
.priority-low { color: #6B6B63; }
.priority-normal { color: #3454D1; }
.priority-high { color: #B8541A; }
.priority-urgent { color: #B0281E; }

/* Forms */
.field { margin-bottom: 14px; display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: #6B6B63; }
input[type="text"], input[type="email"], input[type="password"], textarea, select {
  padding: 9px 12px; border: 1px solid #E2E0D8; border-radius: 6px; font-size: 14px;
  font-family: inherit; background: #fff; color: #20242E;
}
textarea { resize: vertical; }
.stack { display: flex; flex-direction: column; }
.card { background: #fff; border: 1px solid #E2E0D8; border-radius: 10px; padding: 20px; margin-bottom: 20px; }
.card-title { font-size: 12px; font-weight: 700; text-transform: uppercase; color: #6B6B63; margin-bottom: 12px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-span-2 { grid-column: span 2; }
.form-actions { display: flex; gap: 10px; align-items: center; margin-top: 6px; }

.pill-choice { display: flex; gap: 8px; }
.pill-radio { position: relative; }
.pill-radio input { position: absolute; opacity: 0; }
.pill-radio span {
  display: inline-block; padding: 7px 14px; border-radius: 6px; border: 1px solid #E2E0D8;
  font-size: 13px; font-weight: 600; color: #6B6B63; cursor: pointer;
}
.pill-radio input:checked + span { border-color: #B8541A; color: #B8541A; background: #FBEBDF; }

/* Filter bar */
.filter-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 16px; }
.search-input { flex: 1; min-width: 200px; }
.filter-pills { display: flex; flex-wrap: wrap; gap: 6px; }
.pill { padding: 5px 10px; border-radius: 5px; font-size: 11px; font-weight: 700; text-transform: uppercase; background: #F1EFE8; color: #6B6B63; }
.pill-active { background: #20242E; color: #fff; }
.select-inline { font-size: 13px; padding: 8px 10px; }

/* Ticket table */
.ticket-table { background: #fff; border: 1px solid #E2E0D8; border-radius: 10px; overflow: hidden; }
.ticket-row {
  display: grid; grid-template-columns: 80px 2fr 1.2fr 100px 120px 1.2fr 160px;
  gap: 10px; padding: 12px 16px; align-items: center; border-bottom: 1px solid #EFEDE6; font-size: 13px;
}
.ticket-row:last-child { border-bottom: none; }
.ticket-row-head { font-size: 11px; font-weight: 700; text-transform: uppercase; color: #9A968A; background: #FAF9F6; }
a.ticket-row:hover { background: #FAF9F6; }
.ticket-subject { font-weight: 600; }
.unassigned { color: #B0281E; font-weight: 600; }
.empty-state { padding: 40px; text-align: center; color: #9A968A; font-size: 14px; }

.user-row-head, .user-row { grid-template-columns: 1fr 1fr 140px 100px; }

/* Ticket detail */
.detail-layout { display: flex; gap: 24px; align-items: flex-start; }
.detail-main { flex: 1; min-width: 0; }
.detail-rail { width: 240px; flex-shrink: 0; background: #fff; border: 1px solid #E2E0D8; border-radius: 10px; padding: 18px; }
.detail-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.requester-line { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.avatar { width: 26px; height: 26px; border-radius: 50%; background: #3454D1; color: #fff; font-size: 10px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.requester-name { font-weight: 600; font-size: 14px; }
.description-text { font-size: 14px; line-height: 1.6; color: #3A3A34; margin: 0; }

.thread { display: flex; flex-direction: column; gap: 10px; margin-bottom: 20px; }
.thread-entry { background: #EEF2F8; border: 1px solid #E2E0D8; border-radius: 8px; padding: 14px; }
.thread-internal { background: #FDF8E8; border-color: #F3D98A; }
.thread-entry-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.thread-author { font-size: 12px; font-weight: 700; display: flex; align-items: center; gap: 5px; }
.internal-tag { font-size: 10px; font-weight: 700; text-transform: uppercase; color: #8A6D1D; }
.thread-entry p { margin: 0; font-size: 14px; line-height: 1.6; color: #3A3A34; }

.reply-card { padding: 0; overflow: hidden; }
.reply-tabs { display: flex; background: #FAF9F6; border-bottom: 1px solid #E2E0D8; }
.reply-tab { flex: none; padding: 10px 16px; font-size: 12px; font-weight: 600; color: #9A968A; background: none; border: none; border-bottom: 2px solid transparent; cursor: pointer; }
.reply-tab-active { color: #20242E; border-bottom-color: #20242E; }
#reply-form { padding: 14px; }
.muted-card { color: #9A968A; font-size: 13px; }

.rail-footer { margin-top: 12px; padding-top: 12px; border-top: 1px solid #EFEDE6; }
.tag-list { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { padding: 3px 8px; border-radius: 4px; font-size: 11px; background: #F1EFE8; color: #6B6B63; }

/* Login */
.login-body { background: #20242E; min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-wrap { width: 100%; max-width: 380px; padding: 20px; }
.login-brand { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 22px; }
.brand-name-lg { color: #fff; font-weight: 700; font-size: 18px; }
.login-card { background: #fff; border-radius: 12px; padding: 26px; }
.login-card h1 { font-size: 18px; margin-bottom: 4px; }
.login-card .muted { font-size: 12px; margin-bottom: 18px; }
.demo-accounts { margin-top: 16px; background: #2C3040; color: #9CA8C9; border-radius: 8px; padding: 14px; font-size: 12px; }
.demo-title { color: #C7CCDA; font-weight: 700; margin-bottom: 6px; }

.error-page { text-align: center; color: #fff; }
.error-page h1 { font-size: 60px; margin-bottom: 4px; }
