:root { color-scheme: light; font-family: Inter, Arial, sans-serif; color: #1d2939; background: #f4f6f8; }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 320px; }
.site-header { background: #fff; border-bottom: 1px solid #dce3e9; }
.header-inner { max-width: 940px; margin: auto; min-height: 72px; padding: 10px 24px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.brand { display: flex; align-items: center; gap: 11px; font-size: 16px; font-weight: 750; color: #172330; }
.brand img { border-radius: 8px; }
.header-label { color: #526475; font-size: 13px; font-weight: 600; }
main { max-width: 940px; min-height: calc(100vh - 120px); padding: 40px 24px 60px; margin: auto; }
.portal-nav { display: flex; gap: 18px; border-bottom: 1px solid #dce3e9; margin-bottom: 28px; }
.portal-tab { min-height: 42px; width: auto; padding: 0 4px; border: 0; border-bottom: 3px solid transparent; border-radius: 0; background: transparent; color: #526475; font-weight: 750; }
.portal-tab:hover { background: transparent; color: #1855a7; }
.portal-tab.active { border-bottom-color: #2463c8; color: #174da4; }
.page-heading { margin-bottom: 26px; }
.eyebrow { color: #167b66; font-size: 11px; font-weight: 800; }
h1 { margin: 8px 0 6px; font-size: 30px; line-height: 1.2; }
.page-heading p { margin: 0; color: #586b7d; font-size: 15px; line-height: 1.6; }
.request-panel { padding: 28px; background: #fff; border: 1px solid #dce3e9; border-radius: 8px; box-shadow: 0 6px 24px rgba(17, 36, 50, .04); }
.panel-heading { display: flex; justify-content: space-between; align-items: baseline; gap: 14px; border-bottom: 1px solid #e4e9ee; padding-bottom: 18px; margin-bottom: 22px; }
h2 { margin: 0; font-size: 18px; }
.panel-heading span { color: #718092; font-size: 12px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px 22px; }
.contact-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px 22px; }
.contact-status { min-height: 20px; color: #526475; font-size: 13px; }
.contact-status:empty { min-height: 0; }
.attachment-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; font-size: 12px; color: #526475; }
.attachment-picker { position: relative; display: inline-flex; width: max-content; min-height: 44px; align-items: center; padding: 0 15px; border: 1px solid #b8c8d9; border-radius: 6px; color: #174da4; cursor: pointer; }
.attachment-picker:focus-within { outline: 3px solid #96b7eb; }
.attachment-picker input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.selected-attachments { width: 100%; overflow-wrap: anywhere; color: #344457; }
label { display: flex; flex-direction: column; gap: 8px; color: #344457; font-size: 13px; font-weight: 700; }
label.full { grid-column: 1 / -1; }
input, textarea { width: 100%; border: 1px solid #c8d2dc; border-radius: 6px; padding: 11px 12px; background: #fff; color: #152334; font: inherit; font-size: 15px; font-weight: 400; outline: none; }
input { min-height: 44px; }
textarea { min-height: 172px; resize: vertical; line-height: 1.55; }
input:focus, textarea:focus { border-color: #2968d4; box-shadow: 0 0 0 3px rgba(41, 104, 212, .13); }
input:read-only { background: #f3f6f9; color: #344457; }
input[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: #c74242; }
.honeypot { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.form-footer { display: flex; justify-content: space-between; align-items: center; gap: 18px; padding-top: 22px; }
.form-footer p { margin: 0; color: #657589; font-size: 13px; }
button { min-height: 44px; border: 0; border-radius: 6px; padding: 0 24px; background: #2463c8; color: #fff; font: inherit; font-size: 14px; font-weight: 750; cursor: pointer; white-space: nowrap; }
button:hover { background: #174da4; }
button:disabled { opacity: .65; cursor: wait; }
.notice { margin-top: 22px; border-left: 3px solid #168169; background: #eef8f4; padding: 14px 16px; color: #185542; line-height: 1.5; font-size: 14px; }
.notice.error { border-color: #c74242; background: #fff2f2; color: #9a3030; }
.history-section { min-width: 0; }
.history-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.secondary-button { width: auto; min-height: 38px; border: 1px solid #c8d2dc; background: #fff; color: #344457; padding: 0 14px; }
.secondary-button:hover { background: #edf3f8; }
.history-layout { display: grid; grid-template-columns: minmax(240px, 300px) minmax(0, 1fr); gap: 16px; align-items: start; }
.ticket-list { min-width: 0; display: grid; gap: 8px; }
.ticket-item { width: 100%; display: grid; gap: 5px; text-align: left; white-space: normal; min-height: 78px; padding: 13px 15px; border: 1px solid #dce3e9; background: #fff; color: #1d2939; }
.ticket-item:hover, .ticket-item.active { border-color: #2463c8; background: #f2f7ff; }
.ticket-item strong { overflow-wrap: anywhere; }
.ticket-meta { color: #5b6f81; font-size: 12px; font-weight: 600; }
.ticket-detail { min-width: 0; padding: 22px; border: 1px solid #dce3e9; border-radius: 8px; background: #fff; }
.ticket-detail h2 { overflow-wrap: anywhere; }
.ticket-detail p { overflow-wrap: anywhere; white-space: pre-wrap; line-height: 1.6; }
.ticket-detail dt { margin-top: 17px; color: #5b6f81; font-size: 12px; font-weight: 750; text-transform: uppercase; }
.ticket-detail dd { margin: 5px 0 0; overflow-wrap: anywhere; white-space: pre-wrap; line-height: 1.6; }
.ticket-detail .secondary-button { margin-bottom: 15px; }
.empty-history { padding: 22px; border: 1px dashed #c8d2dc; border-radius: 6px; background: #fff; color: #5b6f81; }
footer { max-width: 940px; margin: auto; padding: 0 24px 22px; color: #7a8794; font-size: 12px; }
@media (max-width: 640px) {
  .header-inner { min-height: 64px; padding: 10px 16px; }
  .header-label { font-size: 12px; }
  main { padding: 28px 16px 45px; }
  h1 { font-size: 25px; }
  .request-panel { padding: 20px 16px; }
  .panel-heading { flex-direction: column; gap: 5px; }
  .form-grid { grid-template-columns: minmax(0, 1fr); gap: 18px; }
  .contact-fields { grid-template-columns: minmax(0, 1fr); gap: 18px; }
  .form-footer { align-items: stretch; flex-direction: column; }
  button { width: 100%; }
  .portal-tab, .secondary-button { width: auto; }
  .history-layout { display: block; }
  .ticket-detail { margin-top: 12px; }
  .history-layout.show-detail .ticket-list { display: none; }
  footer { padding: 0 16px 20px; }
}

/* Customer history workspace */
.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; }
body.history-mode main, body.history-mode .header-inner, body.history-mode footer { max-width: 1480px; }
body.history-mode main { padding-top: 24px; padding-bottom: 20px; }
body.history-mode .portal-nav { margin-bottom: 16px; }
body.history-mode .page-heading { margin-bottom: 14px; }
body.history-mode .page-heading h1 { font-size: 26px; }
.history-heading p { margin: 3px 0 0; font-size: 13px; color: #5b6f81; }
.history-layout { display: grid; grid-template-columns: minmax(330px, 39%) minmax(0, 1fr); gap: 12px; min-height: 0; height: max(400px, calc(100dvh - 350px)); align-items: stretch; }
.history-sidebar, .ticket-detail { min-width: 0; min-height: 0; border: 1px solid #dce3e9; border-radius: 8px; background: #fff; }
.history-sidebar { display: flex; flex-direction: column; overflow: hidden; }
.history-controls { display: grid; grid-template-columns: minmax(0, 1fr) 170px auto; gap: 8px; align-items: center; padding: 12px; border-bottom: 1px solid #e4e9ee; }
.history-controls label { min-width: 0; }
.history-controls input, .history-controls select { width: 100%; height: 38px; min-height: 38px; padding: 6px 10px; border: 1px solid #c8d2dc; border-radius: 6px; background: #fff; color: #152334; font: inherit; font-size: 13px; }
.history-controls input:focus, .history-controls select:focus, .calendar-panel button:focus-visible, .ticket-item:focus-visible { outline: 3px solid #96b7eb; outline-offset: -2px; }
.history-view-switch { display: flex; border: 1px solid #c8d2dc; border-radius: 6px; overflow: hidden; }
.view-button { min-height: 36px; padding: 0 11px; border-radius: 0; background: #fff; color: #344457; font-size: 13px; }
.view-button.active, .view-button:hover { background: #e8f1ff; color: #174da4; }
.calendar-panel { padding: 9px 14px 10px; border-bottom: 1px solid #e4e9ee; }
.calendar-heading { display: flex; align-items: center; justify-content: space-between; }
.calendar-heading strong { font-size: 14px; }
.calendar-arrow { width: 32px; min-height: 32px; padding: 0; background: #fff; color: #344457; font-size: 22px; }
.calendar-arrow:hover { background: #edf3f8; }
.calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 2px; }
.calendar-weekday { text-align: center; color: #718092; font-size: 11px; font-weight: 700; padding: 4px 0; }
.calendar-day { min-height: 33px; padding: 0; position: relative; border-radius: 5px; background: #fff; color: #344457; font-size: 12px; }
.calendar-day:hover, .calendar-day.selected { background: #2463c8; color: #fff; }
.calendar-day.has-tickets { font-weight: 800; }
.calendar-day.has-tickets::after { content: ''; position: absolute; width: 4px; height: 4px; border-radius: 50%; background: #168169; bottom: 3px; left: calc(50% - 2px); }
.calendar-day.selected::after, .calendar-day:hover::after { background: #fff; }
.calendar-spacer { min-height: 33px; }
.calendar-clear { min-height: 30px; padding: 0 5px; margin-top: 4px; background: transparent; color: #174da4; font-size: 12px; }
.calendar-clear:hover { background: #edf3f8; }
.ticket-list { min-width: 0; display: block; overflow-y: auto; overscroll-behavior: contain; }
.ticket-group { padding: 9px 14px 6px; border-top: 1px solid #e4e9ee; color: #5b6f81; background: #f8fafc; font-size: 12px; font-weight: 800; }
.ticket-group:first-child { border-top: 0; }
.ticket-item { width: 100%; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 5px 10px; text-align: left; white-space: normal; min-height: 80px; padding: 10px 14px; border: 0; border-bottom: 1px solid #e4e9ee; border-left: 3px solid transparent; border-radius: 0; background: #fff; color: #1d2939; }
.ticket-item:hover, .ticket-item.active { border-left-color: #2463c8; background: #f2f7ff; }
.ticket-item strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.ticket-item .ticket-number { grid-column: 1 / 2; }
.ticket-item time { justify-self: end; }
.status-pill { justify-self: end; width: max-content; padding: 2px 7px; border-radius: 4px; color: #146b58; background: #e5f5ef; font-size: 11px; font-weight: 800; }
.status-pill.closed { color: #586b7d; background: #eef1f4; }
.ticket-detail { display: block; overflow-y: auto; overscroll-behavior: contain; padding: 24px 28px; }
.ticket-detail h2 { font-size: 21px; line-height: 1.35; overflow-wrap: anywhere; }
.detail-head { padding-bottom: 18px; border-bottom: 1px solid #e4e9ee; }
.detail-head .ticket-meta { margin: 0 0 7px; }
.detail-head .status-pill { display: inline-block; margin-top: 10px; }
.detail-dates { display: flex; flex-wrap: wrap; gap: 8px 24px; margin: 18px 0 22px; color: #5b6f81; font-size: 12px; }
.detail-section { padding: 17px 0; border-top: 1px solid #e4e9ee; }
.detail-section h3 { margin: 0 0 8px; color: #344457; font-size: 13px; }
.detail-section p { margin: 0; font-size: 14px; }
.detail-back { display: none; }
@media (max-width: 1050px) {
  .history-controls { grid-template-columns: minmax(0, 1fr) 150px; }
  .history-view-switch { grid-column: 1 / -1; width: max-content; }
}
@media (max-width: 640px) {
  body.history-mode main { padding-top: 14px; }
  body.history-mode .page-heading { margin-bottom: 10px; }
  .history-heading { margin-bottom: 10px; }
  .history-layout { display: block; height: max(350px, calc(100dvh - 325px)); min-height: 0; }
  .history-sidebar, .ticket-detail { height: 100%; }
  .history-controls { grid-template-columns: minmax(0, 1fr) 135px; }
  .history-layout.show-detail .history-sidebar { display: none; }
  .history-layout:not(.show-detail) .ticket-detail { display: none; }
  .ticket-detail { margin-top: 0; padding: 16px; }
  .detail-back { display: inline-flex; align-items: center; width: auto; margin-bottom: 14px; }
  .ticket-item { min-height: 74px; }
}
