/* The signed-in portal shares the login palette; login layout stays in portal.css. */
body:has(#workspace:not([hidden])) {
  color-scheme: light;
  --bg: #f3f9fb;
  --surface: #fff;
  --line: #dceaf0;
  --text: #16374c;
  --muted: #587286;
  --accent: #009fba;
  --danger: #b42318;
  min-height: 100dvh;
  color: var(--text);
  background: radial-gradient(ellipse at 90% 15%, #dff5f4 0, transparent 35%),
    radial-gradient(ellipse at 6% 65%, #e3f3f8 0, transparent 35%), #f4f9fb;
}
body:has(#workspace:not([hidden])) .topbar {
  height: 86px;
  padding-inline: max(28px, calc((100% - 1240px) / 2));
  gap: 22px;
  background: rgba(255,255,255,.9);
  border-color: #dceaf0;
}
body:has(#workspace:not([hidden])) .topbar img { width: 182px; }
.session-identity-wrap { position: relative; margin-inline-start: auto; min-width: 0; }
.session-identity { display: flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 650; min-width: 0; border-radius: 12px; }
.session-identity.is-menu-trigger { cursor: pointer; padding: 3px 7px; margin: -3px -7px; }
.session-identity.is-menu-trigger:hover,.session-identity.is-menu-trigger:focus-visible { background: #edf8fa; outline: 2px solid #a8d5df; outline-offset: 2px; }
#session-menu-caret { color: #087f97; font-size: 17px; }
.session-menu { position: absolute; z-index: 20; inset-block-start: calc(100% + 12px); inset-inline-start: 0; min-width: 225px; padding: 6px; border: 1px solid #d7e7ee; border-radius: 13px; background: #fff; box-shadow: 0 14px 38px #16374c22; }
.session-menu button { display: block; width: 100%; padding: 11px 12px; text-align: start; border: 0; border-radius: 8px; background: transparent; color: #16374c; font-size: 13px; font-weight: 700; }
.session-menu button:hover,.session-menu button:focus-visible { background: #edf8fa; color: #087f97; }
#preview-selector { color-scheme: light; width: min(520px, calc(100vw - 32px)); height: fit-content; max-height: calc(100dvh - 48px); inset: 0; margin: auto; padding: 27px; border: 1px solid #d7e9ee; border-radius: 22px; background: #fff; color: #16374c; box-shadow: 0 24px 72px #16374c35; }
#preview-selector::backdrop { background: #16374c55; backdrop-filter: blur(5px); }
.preview-selector-heading { display: flex; align-items: start; justify-content: space-between; gap: 16px; }
.preview-selector-heading h2 { margin: 5px 0 10px; font-size: 23px; }
#preview-selector .muted { font-size: 13px; line-height: 1.65; }
#preview-selector label { margin: 18px 0 7px; color: #456276; }
#preview-selector select { width: 100%; min-height: 44px; padding: 9px 12px; border: 1px solid #d7e7ee; border-radius: 11px; background: #f8fbfc; color: #16374c; }
#preview-selector-status { min-height: 20px; margin: 16px 0 0; color: #587286; font-size: 12px; }
#preview-selector-status.error { color: #b42318; }
.preview-selector-actions { display: flex; justify-content: flex-start; gap: 10px; flex-wrap: wrap; margin-top: 15px; }
.preview-selector-actions .primary { border: 0; border-radius: 11px; background: #008ca3; color: #fff; }
.preview-selector-actions .quiet { min-height: 42px; }
#session-avatar { display: grid; place-items: center; width: 40px; height: 40px; flex-shrink: 0; border: 1px solid #c7e8ec; border-radius: 50%; background: #e6f7f8; color: #087f97; font-size: 14px; }
#session-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 220px; }
body:has(#workspace:not([hidden])) .topbar #logout { margin: 0; }
body:has(#workspace:not([hidden])) main { width: min(1240px, calc(100% - 56px)); }
body:has(#workspace:not([hidden])) .quiet { background: #fff; border: 1px solid #d7e7ee; border-radius: 12px; color: #456276; min-height: 40px; }
body:has(#workspace:not([hidden])) .quiet:hover { background: #edf8fa; border-color: #a8d5df; color: #087f97; }
body:has(#workspace:not([hidden])) button:disabled { cursor: default; }
body:has(#workspace:not([hidden])) #notice { color: #17684f; background: #effaf5; border-color: #b7e2d0; border-radius: 14px; }
body:has(#workspace:not([hidden])) #notice.error { color: #b42318; background: #fff4f2; border-color: #f6c9c0; }
#workspace .workspace-heading { position: relative; display: grid; grid-template-columns: minmax(0,1fr) 270px; gap: 20px; min-height: 260px; margin: 30px 0 28px; padding: 30px 40px; border: 1px solid #d7e9ee; border-radius: 28px; background: linear-gradient(110deg,#eaf8fa,#fff 62%); box-shadow: 0 14px 40px #16374c08; overflow: hidden; }
#workspace .workspace-welcome { align-self: center; min-width: 0; }
#workspace .workspace-kicker { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 750; color: #087f97; }
#workspace .workspace-kicker::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: #00b7a2; box-shadow: 0 0 0 4px #00b7a216; }
#workspace h1 { font-size: clamp(27px, 2.4vw, 36px); font-weight: 750; letter-spacing: -.025em; margin: 12px 0 10px; }
#workspace .workspace-heading p { font-size: 15px; line-height: 1.7; max-width: 580px; }
#workspace .workspace-illustration { width: 250px; height: 225px; object-fit: contain; align-self: center; justify-self: center; mix-blend-mode: multiply; margin-block: -18px; }
#workspace .welcome-actions { display: flex; align-items: center; gap: 22px; margin-top: 24px; flex-wrap: wrap; }
#workspace .customer-label { color: #587286; font-size: 13px; overflow-wrap: anywhere; }
#workspace .primary, #ticket-dialog .primary { min-height: 48px; gap: 10px; border: 0; border-radius: 15px; padding: 12px 22px; color: #fff; font-size: 15px; background: linear-gradient(135deg,#008577,#007fa3 60%,#096c8d); box-shadow: 0 8px 20px #0090b126; }
#workspace .primary:hover, #ticket-dialog .primary:hover { background: linear-gradient(135deg,#00786c,#006e90 60%,#065876); }
#workspace .primary > span { font-size: 23px; line-height: 1; font-weight: 400; }
#workspace .ticket-board { background: #fff; border: 1px solid #dceaf0; border-radius: 24px; box-shadow: 0 14px 40px #16374c06; overflow: hidden; }
#workspace .board-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 24px 28px 18px; }
#workspace .board-heading .eyebrow { font-size: 11px; color: #587286; font-weight: 500; }
#workspace .board-heading h2 { font-size: 22px; font-weight: 750; margin: 4px 0 0; }
#workspace #refresh { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; }
#workspace #refresh > span { font-size: 21px; line-height: 1; }
#workspace .toolbar { margin: 0; padding: 0 28px 18px; border-bottom: 1px solid #e4eef3; gap: 20px; }
#workspace .tabs { padding: 4px; background: #f2f7fa; border: 1px solid #e5eff3; border-radius: 14px; gap: 4px; }
#workspace .tabs button { color: #587286; font-size: 13px; padding: 10px 18px; border-radius: 10px; min-height: 40px; }
#workspace .tabs button.selected { background: #fff; color: #087f97; font-weight: 750; box-shadow: 0 2px 8px #16374c0b; }
#workspace .toolbar-hint { color: #587286; font-size: 12px; }
#workspace .table-wrap { border: 0; border-radius: 0; background: #fff; }
#workspace table { font-size: 14px; table-layout: fixed; }
#workspace th { color: #587286; background: #f8fbfc; font-size: 12px; padding: 15px 18px; text-align: start; }
#workspace th:first-child { width: 90px; }
#workspace th:nth-child(2) { width: 34%; }
#workspace th:nth-child(3) { width: 165px; }
#workspace th:nth-child(4), #workspace th:nth-child(5) { width: auto; }
#workspace td { padding: 21px 18px; border-color: #e8f0f4; line-height: 1.6; font-size: 13px; vertical-align: middle; overflow-wrap: anywhere; text-align: start; }
#workspace td:first-child { color: #587286; font-size: 12px; font-variant-numeric: tabular-nums; }
#workspace td:nth-child(4), #workspace td:nth-child(5) { color: #587286; font-size: 12px; font-variant-numeric: tabular-nums; }
#workspace tr:hover td { background: #f6fbfc; }
#workspace .ticket-link { color: #16374c; font-size: 14px; font-weight: 650; line-height: 1.65; width: 100%; max-width: none; overflow-wrap: anywhere; text-decoration: none; padding: 3px 0; text-align: start; }
#workspace .ticket-link:hover { color: #0087a5; }
#workspace .ticket-unread { display: inline-flex; align-items: center; margin-top: 5px; padding: 4px 9px; border-radius: 999px; background: #fff0dd; color: #96530a; font-size: 11px; font-weight: 750; line-height: 1.4; }
#workspace .ticket-unread::before { content: ''; width: 6px; height: 6px; margin-inline-end: 6px; border-radius: 50%; background: #e89321; }
#workspace .badge, #ticket-dialog .badge { border: 0; background: #e9f5fb; color: #16769b; gap: 6px; padding: 5px 10px; font-size: 12px; font-weight: 650; }
#workspace .badge::before, #ticket-dialog .badge::before { content: ''; width: 5px; height: 5px; background: currentColor; border-radius: 50%; flex-shrink: 0; }
#workspace .badge[data-status="in_progress"], #ticket-dialog .badge[data-status="in_progress"] { background: #e9f9f7; color: #078374; }
#workspace .badge[data-status="resolved"], #workspace .badge[data-status="closed"], #ticket-dialog .badge[data-status="resolved"], #ticket-dialog .badge[data-status="closed"] { background: #edf6ef; color: #327c4c; }
#workspace .badge[data-status="waiting"], #ticket-dialog .badge[data-status="waiting"] { background: #fff7e9; color: #9b6812; }
#workspace .priority-high { color: #a36613; }
#workspace .priority-urgent { color: #b42318; }
#workspace .empty { padding: 56px 20px 62px; background: linear-gradient(#fff,#fafdfe); }
#workspace .empty > span { display: inline-grid; place-items: center; width: 60px; height: 60px; margin: 0 0 18px; padding: 0; border: 1px solid #c9e7e8; background: #edfafa; color: #009b9f; font-size: 25px; }
#workspace .empty h2 { font-weight: 650; margin-bottom: 8px; }
#workspace .empty p { margin-bottom: 0; font-size: 14px; }
#workspace .pagination { margin: 0; padding: 18px 28px; border-top: 1px solid #e8f0f4; gap: 18px; }
#workspace .pagination .quiet { font-size: 12px; min-height: 36px; }
#ticket-dialog { color-scheme: light; --text: #16374c; --muted: #587286; --line: #dceaf0; --accent: #009fba; --surface: #fff; --danger: #b42318; background: #fff; color: #16374c; width: min(620px, calc(100vw - 32px)); height: fit-content; max-height: calc(100dvh - 48px); inset: 0; margin: auto; padding: 32px; border: 1px solid #d7e9ee; border-radius: 26px; box-shadow: 0 26px 90px #16374c33; }
#ticket-dialog::backdrop { background: #16374c50; backdrop-filter: blur(6px); }
#ticket-dialog .dialog-header { border-color: #e2edf2; margin-bottom: 24px; padding-bottom: 22px; align-items: flex-start; }
#ticket-dialog .eyebrow { color: #008ca3; font-size: 11px; font-weight: 650; }
#ticket-dialog h2 { color: #16374c; font-size: 25px; line-height: 1.45; font-weight: 750; }
#ticket-dialog #close-dialog { width: 36px; height: 36px; min-height: 36px; padding: 0; flex-shrink: 0; border-radius: 50%; }
#ticket-dialog label { color: #456276; font-size: 13px; margin: 18px 0 8px; }
#ticket-dialog input, #ticket-dialog select, #ticket-dialog textarea { color-scheme: light; background: #f9fcfd; color: #16374c; border: 1px solid #d7e7ee; border-radius: 13px; padding: 12px 14px; font-size: 16px; }
#ticket-dialog textarea { min-height: 160px; }
#ticket-dialog input:focus, #ticket-dialog select:focus, #ticket-dialog textarea:focus { outline: none; border-color: #00a7bd; background: #fff; box-shadow: 0 0 0 3px #009fca15; }
#ticket-dialog input::placeholder, #ticket-dialog textarea::placeholder { color: #587286; }
#ticket-dialog .dialog-actions { border-color: #e2edf2; padding-top: 20px; margin-top: 20px; display: flex; justify-content: flex-start; }
#ticket-dialog .detail-meta { gap: 12px; font-size: 12px; padding-bottom: 20px; }
#ticket-dialog .detail-description { margin: 24px 0; font-size: 16px; line-height: 1.8; }
#ticket-dialog .muted { font-size: 12px; }
#ticket-dialog .attachment-picker { margin-top: 20px; padding-top: 4px; border-top: 1px solid #e2edf2; }
#ticket-dialog input[type="file"] { padding: 10px; font-size: 13px; }
#ticket-dialog input[type="file"]::file-selector-button { padding: 8px 12px; margin-inline-end: 12px; border: 1px solid #bddfe8; border-radius: 8px; color: #087f97; background: #edf8fa; font: inherit; cursor: pointer; }
#ticket-dialog .attachment-hint { color: #587286; font-size: 12px; line-height: 1.7; margin: 8px 0; }
#ticket-dialog .attachment-list { list-style: none; margin: 8px 0 0; padding: 0; }
#ticket-dialog .attachment-list li { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid #e4eef3; font-size: 13px; }
#ticket-dialog .attachment-list li > :first-child { flex: 1; min-width: 0; overflow-wrap: anywhere; }
#ticket-dialog .attachment-list a { color: #087f97; text-decoration: underline; text-underline-offset: 3px; }
#ticket-dialog .attachment-list small { display: block; margin-top: 3px; color: #587286; font-size: 11px; }
#ticket-dialog .attachment-remove { flex-shrink: 0; min-height: 36px; padding: 7px 10px; color: #b42318; }
#ticket-dialog .detail-files h3 { font-size: 16px; margin: 22px 0 8px; }
#ticket-dialog .attachment-status { color: #087f97; font-size: 13px; line-height: 1.7; }
#ticket-dialog .attachment-status.error { color: #b42318; }
#ticket-dialog .ticket-conversation { margin-top: 27px; padding-top: 23px; border-top: 1px solid #e2edf2; }
#ticket-dialog .ticket-conversation h3 { margin: 0 0 5px; font-size: 17px; }
#ticket-dialog .ticket-conversation > .muted { margin-bottom: 17px; }
#ticket-dialog .conversation-list { display: grid; gap: 12px; list-style: none; margin: 0; padding: 0; }
#ticket-dialog .conversation-message { padding: 14px 16px; border: 1px solid #c9e5ea; border-radius: 16px; background: #ecf9fa; }
#ticket-dialog .conversation-message.from-customer { border-color: #e1e9ef; background: #f6f8fa; }
#ticket-dialog .conversation-meta { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; color: #087f97; font-size: 12px; }
#ticket-dialog .from-customer .conversation-meta { color: #587286; }
#ticket-dialog .conversation-meta time { font-size: 11px; font-weight: 400; }
#ticket-dialog .conversation-text { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.7; margin: 8px 0 0; font-size: 14px; }
#ticket-dialog .conversation-empty { padding: 15px; border: 1px dashed #d7e7ee; border-radius: 13px; color: #587286; font-size: 13px; }
#ticket-dialog .conversation-reply { margin-top: 20px; }
#ticket-dialog .conversation-reply label { display: block; margin: 0 0 8px; }
#ticket-dialog .conversation-reply textarea { min-height: 100px; }
#ticket-dialog .conversation-reply .primary { margin-top: 10px; }
#ticket-dialog .conversation-status { min-height: 1.3em; margin: 10px 0 0; color: #087f97; font-size: 12px; }
#ticket-dialog .conversation-status.error { color: #b42318; }
#ticket-dialog .ticket-closure { margin: 22px 0 4px; padding: 18px 20px; border: 1px solid #bee1d8; border-radius: 18px; background: #f0faf6; }
#ticket-dialog .ticket-closure h3 { margin: 0 0 10px; color: #17684f; font-size: 16px; }
#ticket-dialog .closure-note { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.75; font-size: 14px; }
#ticket-dialog .ticket-rating { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; margin-top: 16px; padding-top: 14px; border-top: 1px solid #d3e9dc; font-size: 12px; }
#ticket-dialog .rating-stars { color: #df9b19; font-size: 22px; letter-spacing: 2px; line-height: 1; }
#ticket-dialog .ticket-rating-form { margin-top: 16px; padding-top: 14px; border-top: 1px solid #d3e9dc; }
#ticket-dialog .ticket-rating-form label { display: block; margin: 0 0 10px; }
#ticket-dialog .ticket-rating-form select { display: block; max-width: 260px; margin-top: 8px; }
#ticket-dialog .ticket-rating-form .primary { margin-top: 6px; }
#ticket-dialog .rating-status { margin: 9px 0 0; min-height: 1.3em; color: #17684f; font-size: 12px; }
#ticket-dialog .rating-status.error { color: #b42318; }
body:has(#rating-result:not([hidden])) { color-scheme: light; background: #f3f9fb; color: #16374c; }
body:has(#rating-result:not([hidden])) .topbar { background: #fff; border-color: #dceaf0; }
body:has(#rating-result:not([hidden])) .topbar #logout { display: none; }
body:has(#rating-result:not([hidden])) footer { color: #587286; }
#rating-result { width: min(560px, 100%); margin: 8vh auto; padding: 36px; border: 1px solid #d7e9ee; border-radius: 24px; background: #fff; box-shadow: 0 20px 55px #16374c12; }
#rating-result .eyebrow { color: #087f97; }
#rating-result h1 { margin: 15px 0 10px; color: #16374c; font-size: 27px; }
#rating-result p { color: #587286; line-height: 1.7; }
#rating-result .primary { margin-top: 10px; text-decoration: none; background: #087f97; color: #fff; border: 0; }
body:has(#workspace:not([hidden])) footer { color: #587286; padding: 26px 16px max(24px, env(safe-area-inset-bottom)); }
@media (max-width: 1000px) {
  #workspace .workspace-heading { grid-template-columns: minmax(0,1fr) 200px; padding: 28px; }
  #workspace .workspace-illustration { width: 195px; height: 195px; }
  #workspace th, #workspace td { padding-inline: 12px; }
  #workspace th:nth-child(2) { width: 29%; }
  #workspace .toolbar-hint { display: none; }
}
@media (max-width: 820px) {
  body:has(#workspace:not([hidden])) .topbar { height: 72px; padding-inline: 16px; gap: 14px; }
  body:has(#workspace:not([hidden])) .topbar img { width: 138px; }
  body:has(#workspace:not([hidden])) .portal-label { display: none; }
  #session-name { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .session-identity { gap: 0; }
  #session-avatar { width: 34px; height: 34px; font-size: 12px; }
  body:has(#workspace:not([hidden])) .topbar #logout { min-height: 36px; padding: 7px 10px; }
  body:has(#workspace:not([hidden])) main { width: calc(100% - 28px); }
  #workspace .workspace-heading { min-height: 0; margin: 20px 0; padding: 24px; grid-template-columns: minmax(0,1fr); border-radius: 22px; gap: 0; }
  #workspace .workspace-illustration { display: none; }
  #workspace .workspace-heading p { font-size: 14px; }
  #workspace .welcome-actions { gap: 13px; margin-top: 20px; }
  #workspace .workspace-heading .primary { width: 100%; }
  #workspace .customer-label { font-size: 12px; }
  #workspace .ticket-board { border-radius: 20px; }
  #workspace .board-heading { padding: 20px 18px 16px; }
  #workspace .board-heading h2 { font-size: 20px; }
  #workspace #refresh { font-size: 12px; padding: 8px 10px; }
  #workspace .toolbar { padding: 0 18px 16px; }
  #workspace .tabs { width: 100%; }
  #workspace .tabs button { flex: 1; padding: 9px 10px; }
  #workspace table, #workspace tbody { display: block; width: 100%; }
  #workspace thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  #workspace th:nth-child(4) { display: table-cell; }
  #workspace tr { display: grid; grid-template-columns: minmax(0,1fr) auto; grid-template-areas: 'number status' 'title title' 'created created' 'updated updated'; padding: 17px 18px; gap: 10px 16px; border-top: 1px solid #e8f0f4; }
  #workspace tr:first-child { border-top: 0; }
  #workspace td { display: block; padding: 0; border: 0; background: none; font-size: 12px; }
  #workspace tr:hover td { background: none; }
  #workspace td:first-child { grid-area: number; align-self: center; }
  #workspace td:nth-child(2) { grid-area: title; }
  #workspace td:nth-child(3) { grid-area: status; justify-self: end; }
  #workspace td:nth-child(4) { display: block; grid-area: created; }
  #workspace td:nth-child(5) { display: block; grid-area: updated; font-size: 11px; color: #587286; }
  #workspace td:nth-child(n+4)::before { content: attr(data-label) ' · '; color: #587286; font-size: 11px; }
  #workspace .ticket-link { font-size: 15px; padding: 0 0 3px; }
  #workspace .pagination { padding: 14px 16px; gap: 12px; }
  #workspace .empty { padding: 42px 18px; }
  #ticket-dialog { width: calc(100vw - 24px); max-height: calc(100dvh - 24px); border-radius: 22px; padding: 22px; }
  #ticket-dialog h2 { font-size: 22px; }
  #ticket-dialog .primary { width: 100%; }
  #ticket-dialog textarea { min-height: 135px; }
}
