/*
 * Helpdesk styles. Everything is built from the tokens below, so changing the
 * look starts here. Layout idea: a dark sidebar, then a ticket list pane, the
 * conversation, and a details pane, all on a light grey ground.
 */

@font-face {
  font-family: "Geist";
  src: url("/assets/geist-latin-90ac0fe7.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

@font-face {
  font-family: "Geist Mono";
  src: url("/assets/geist-mono-latin-7f2504bb.woff2") format("woff2");
  font-weight: 500;
  font-display: swap;
}

:root {
  --font-sans: "Geist", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  --ground: #F4F5F7;
  --surface: #FFFFFF;
  --surface-2: #F7F8FA;
  --ink: #171A21;
  --ink-2: #3D4350;
  --muted: #5B6271;
  --line: #E7E9EE;
  --line-2: #EEF0F4;
  --field: #D5DAE2;
  --accent: #3355FF;
  --accent-strong: #2440D8;
  --accent-tint: #EEF1FF;
  --accent-ring: #C9D3FF;
  --sidebar: #0E1116;
  --sidebar-2: #161A22;
  --sidebar-line: #22262E;
  --sidebar-text: #D9DCE2;
  --sidebar-muted: #8C93A1;

  --ok-bg: #E5F4EC;   --ok-fg: #1F6B44;
  --warn-bg: #FDF1D8; --warn-fg: #7A4F00;
  --bad-bg: #FDE8E4;  --bad-fg: #9A2B16;
  --quiet-bg: #F1F3F6;
  --note-bg: #FFF8E6; --note-line: #D9B95E; --note-fg: #7A4F00;

  --radius-sm: 10px; --radius: 14px; --radius-lg: 16px;
  --shadow: 0 1px 2px rgba(14, 17, 22, .04), 0 8px 24px rgba(14, 17, 22, .06);
  --shadow-lg: 0 1px 2px rgba(14, 17, 22, .04), 0 12px 32px rgba(14, 17, 22, .08);
  --shadow-accent: 0 6px 16px rgba(51, 85, 255, .30);
  --focus: 0 0 0 3px rgba(51, 85, 255, .25);
  --ease: cubic-bezier(.2, .7, .2, 1);
}

/* Base */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; line-height: 1.2; text-wrap: balance; }
h1 { font-size: 28px; font-weight: 700; letter-spacing: -.02em; }
h2 { font-size: 18px; font-weight: 650; letter-spacing: -.01em; }
p { margin: 0; }
a { color: var(--accent); text-decoration: none; transition: color .18s ease, background-color .18s ease; }
a:hover { color: var(--accent-strong); }
code, .mono { font-family: var(--font-mono); font-size: .9em; }
kbd {
  font-family: var(--font-mono); font-size: 11px; line-height: 1.6;
  border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px;
  padding: 0 5px; color: var(--muted); background: var(--surface);
}
.muted, .meta { color: var(--muted); }
.break { overflow-wrap: anywhere; }
.truncate { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.icon { flex: none; }
[hidden] { display: none !important; }

:focus-visible { outline: none; box-shadow: var(--focus); }

/* Buttons */
.btn, .button, input[type=submit], button.secondary {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 14px; border-radius: var(--radius-sm);
  border: 1px solid transparent; font: inherit; font-weight: 600; white-space: nowrap;
  cursor: pointer; text-decoration: none;
  transition: background-color .18s ease, border-color .18s ease, box-shadow .18s ease, transform .18s ease, color .18s ease;
}
.btn:hover, .button:hover, input[type=submit]:hover { transform: translateY(-1px); }
.btn-primary, .button, input[type=submit] { background: var(--accent); color: #FFFFFF; box-shadow: var(--shadow-accent); }
.btn-primary:hover, .button:hover, input[type=submit]:hover { background: var(--accent-strong); color: #FFFFFF; }
.btn-secondary, button.secondary, input[type=submit].secondary { background: var(--surface); color: var(--ink); border-color: var(--line); box-shadow: none; }
.btn-secondary:hover, button.secondary:hover { background: var(--surface-2); color: var(--ink); }
.btn-dark { background: var(--ink); color: #FFFFFF; }
.btn-dark:hover { background: #000000; }
.btn-note { background: var(--ink); color: #FFFFFF; }
.btn-sm { height: 32px; padding: 0 10px; }
.btn kbd { background: transparent; color: inherit; opacity: .75; border-color: currentColor; }
button.link, .link button, button.link-quiet {
  background: none; border: 0; padding: 0; font: inherit; cursor: pointer; color: var(--accent);
}
button.link:hover { color: var(--accent-strong); text-decoration: underline; }
form.button_to { display: inline; }

/* Forms */
label { display: block; margin: 16px 0 6px; font-weight: 600; }
input[type=text], input[type=email], input[type=password], input[type=search], textarea, select {
  width: 100%; padding: 9px 12px; font: inherit; color: var(--ink);
  background: var(--surface); border: 1px solid var(--field); border-radius: var(--radius-sm);
  transition: border-color .18s ease, box-shadow .18s ease;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus); }
textarea { resize: vertical; line-height: 1.55; }
select { appearance: none; padding-right: 32px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%235B6271' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; }
fieldset { border: 0; padding: 0; margin: 0; }

/* Flash messages float above the page and fade away on their own */
.flash {
  padding: 10px 14px; border-radius: var(--radius-sm); font-weight: 500;
  border: 1px solid transparent; margin-bottom: 16px;
}
.flash.notice { background: var(--ok-bg); color: var(--ok-fg); border-color: #C6E7D4; }
.flash.alert { background: var(--bad-bg); color: var(--bad-fg); border-color: #F6CBC2; }
.app-main > .flash {
  position: fixed; z-index: 20; right: 24px; bottom: 24px; margin: 0; box-shadow: var(--shadow-lg);
  animation: toast 4.5s var(--ease) both;
}
@keyframes toast { 0% { transform: translateY(12px); } 8%, 85% { transform: none; opacity: 1; } 100% { opacity: 0; visibility: hidden; } }

/* Pills, badges, tags, avatars */
.pill, .status { display: inline-flex; align-items: center; font-size: 12px; font-weight: 600; border-radius: 999px; padding: 2px 9px; background: var(--quiet-bg); color: var(--muted); }
.pill-open, .status.open { background: var(--accent-tint); color: var(--accent-strong); }
.pill-pending, .status.pending { background: var(--warn-bg); color: var(--warn-fg); }
.pill-closed, .status.closed { background: var(--quiet-bg); color: var(--muted); }
.badge { display: inline-flex; font-size: 12px; font-weight: 600; border-radius: 999px; padding: 1px 8px; }
.badge-calm { background: var(--quiet-bg); color: var(--muted); }
.badge-soon { background: var(--warn-bg); color: var(--warn-fg); }
.badge-late { background: var(--bad-bg); color: var(--bad-fg); }
.tag { display: inline-flex; align-items: center; gap: 2px; font-size: 12px; color: var(--accent-strong); background: var(--accent-tint); border-radius: 999px; padding: 1px 8px; }
.tag a { color: inherit; }
.inbox-name { font-size: 12px; color: var(--muted); }

.avatar { flex: none; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; font-weight: 600; }
.avatar-sm { width: 30px; height: 30px; font-size: 11px; }
.avatar-md { width: 36px; height: 36px; font-size: 13px; }
.avatar-lg { width: 56px; height: 56px; font-size: 18px; }
.avatar-peach { background: #FFE6D5; color: #8A3B0A; }
.avatar-mint  { background: #DDF4EC; color: #1F6B44; }
.avatar-lilac { background: #EDE4FF; color: #5B2DB3; }
.avatar-sky   { background: #E3E8FF; color: #2440D8; }
.avatar-sand  { background: #F4EBD9; color: #6B4E16; }
.avatar-rose  { background: #FCE4EC; color: #9C1F4C; }

/* App shell */
.app { display: flex; min-height: 100vh; }
.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.page { width: 100%; max-width: 980px; margin: 0 auto; padding: 32px 36px 48px; animation: rise .5s var(--ease) both; }
.page > h1 { margin-bottom: 12px; }
.page > .meta { margin-bottom: 16px; }
.page > p:has(.button) { margin: 16px 0 20px; }

/* Sidebar */
.sidebar {
  flex: none; width: 232px; position: sticky; top: 0; height: 100vh; overflow-y: auto;
  background: var(--sidebar); color: var(--sidebar-text);
  padding: 18px 12px; display: flex; flex-direction: column; gap: 20px;
}
.sidebar a { color: var(--sidebar-text); }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; font-weight: 700; font-size: 16px; color: #FFFFFF; }
.sidebar .brand { color: #FFFFFF; }
.brand-mark { width: 30px; height: 30px; border-radius: 9px; display: inline-flex; align-items: center; justify-content: center; color: #FFFFFF; background: linear-gradient(135deg, var(--accent), #00B89F); }
.sidebar-search {
  display: flex; align-items: center; gap: 8px; padding: 0 10px; height: 38px;
  background: var(--sidebar-2); border: 1px solid var(--sidebar-line); border-radius: var(--radius-sm); color: var(--sidebar-muted);
}
.sidebar-search:focus-within { border-color: var(--accent); box-shadow: var(--focus); }
.sidebar-search input[type=search] { background: transparent; border: 0; padding: 0; color: #FFFFFF; box-shadow: none; }
.sidebar-search input::placeholder { color: var(--sidebar-muted); }
.sidebar-search kbd { background: var(--sidebar-2); border-color: #2A303B; color: #AEB4C0; }
.sidebar-group { display: flex; flex-direction: column; gap: 2px; }
.sidebar-label { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--sidebar-muted); padding: 0 10px 6px; }
.sidebar-group a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 9px; }
.sidebar-group a > span:first-child:not(.dot) { flex: 1; }
.sidebar-group a:hover { background: #1A1F29; color: #FFFFFF; }
.sidebar-group a.active { background: var(--accent); color: #FFFFFF; font-weight: 600; }
.sidebar-group .count { font-size: 12px; font-variant-numeric: tabular-nums; color: var(--sidebar-muted); }
.sidebar-group a.active .count { color: #DDE3FF; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.dot-0 { background: #5B7CFF; } .dot-1 { background: #F2A33A; } .dot-2 { background: #22C3A6; } .dot-3 { background: #E5689A; }
.dot + span { flex: 1; }
.saved-view { display: flex; align-items: center; }
.saved-view a { flex: 1; }
.saved-view .remove { background: none; border: 0; color: var(--sidebar-muted); font: inherit; font-size: 16px; padding: 4px 8px; border-radius: 6px; cursor: pointer; opacity: 0; transition: opacity .18s ease; }
.saved-view:hover .remove, .saved-view .remove:focus-visible { opacity: 1; }
.sidebar-footer { margin-top: auto; border-top: 1px solid var(--sidebar-line); padding-top: 12px; }
.me { display: flex; align-items: center; gap: 10px; padding: 10px 10px 2px; }
.me .avatar { background: #22283A; color: #AFC0FF; }
.me-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.me-name { font-weight: 600; color: #FFFFFF; }
.me .link-quiet { color: var(--sidebar-muted); font-size: 12px; text-align: left; }
.me .link-quiet:hover { color: #FFFFFF; }

/* Inbox workspace: list | conversation | details */
.workspace { flex: 1; display: grid; grid-template-columns: minmax(300px, 380px) minmax(0, 1fr); min-height: 100vh; }
.workspace.has-ticket { grid-template-columns: minmax(300px, 360px) minmax(0, 1fr) 300px; }

.list-pane { background: var(--surface); border-right: 1px solid var(--line); display: flex; flex-direction: column; height: 100vh; position: sticky; top: 0; }
.list-header { padding: 20px 18px 12px; border-bottom: 1px solid var(--line-2); display: flex; flex-direction: column; gap: 12px; animation: rise .5s var(--ease) both; }
.list-title { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.list-title h1 { font-size: 22px; }
.list-sort { font-size: 12px; color: var(--muted); }
.list-filters { display: flex; gap: 8px; }
.list-filters select { height: 34px; padding-top: 0; padding-bottom: 0; font-size: 13px; }
.list-query { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; color: var(--muted); background: var(--surface-2); border-radius: 8px; padding: 6px 10px; }
.ticket-list { list-style: none; margin: 0; padding: 8px; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; flex: 1; animation: rise .5s .08s var(--ease) both; }
.ticket-item {
  display: flex; gap: 12px; padding: 12px; border-radius: 12px; color: var(--ink);
  transition: background-color .2s ease, transform .2s ease, box-shadow .2s ease;
}
.ticket-item:hover { background: #F7F8FF; color: var(--ink); transform: translateX(2px); }
.ticket-item.current { background: var(--accent-tint); box-shadow: inset 0 0 0 1px var(--accent-ring); }
.ticket-item-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.ticket-item-top { display: flex; justify-content: space-between; gap: 8px; }
.ticket-item-customer { font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ticket-item-top time { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.ticket-item-subject { font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ticket-item-preview { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ticket-item-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 6px; }
.ticket-item-assignee { margin-left: auto; font-size: 12px; color: var(--muted); }
.empty-state { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 48px 24px; text-align: center; color: var(--muted); }
.save-view { display: flex; gap: 8px; padding: 12px 16px 16px; border-top: 1px solid var(--line-2); }
.save-view input[type=text] { height: 38px; }

.detail-pane { min-width: 0; display: flex; flex-direction: column; }
.detail-empty { align-items: center; justify-content: center; padding: 48px 32px; }
.overview { max-width: 520px; text-align: center; display: flex; flex-direction: column; gap: 10px; animation: rise .5s .08s var(--ease) both; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-top: 18px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; display: flex; flex-direction: column; gap: 2px; text-align: left; }
.stat-value { font-size: 24px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat-label { font-size: 12px; color: var(--muted); }
.stat.satisfaction .stat-value strong { color: var(--ok-fg); font-weight: 700; }

.ticket-header {
  position: sticky; top: 0; z-index: 5; background: rgba(255, 255, 255, .92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line); padding: 16px 28px;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px;
}
.back-link { display: none; align-items: center; gap: 4px; width: 100%; font-size: 13px; color: var(--muted); }
.ticket-heading { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.ticket-heading h1 { font-size: 22px; }
.ticket-kicker { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.ticket-actions { display: flex; gap: 8px; }
.rating { margin: 16px 28px 0; padding: 10px 14px; border-radius: var(--radius-sm); background: var(--ok-bg); color: var(--ok-fg); }
.rating.bad { background: var(--bad-bg); color: var(--bad-fg); }

.conversation { flex: 1; width: 100%; max-width: 820px; margin: 0 auto; padding: 24px 28px; display: flex; flex-direction: column; gap: 18px; animation: rise .5s .08s var(--ease) both; }
.message { display: flex; gap: 12px; align-items: flex-start; }
.message-content { max-width: min(78%, 620px); display: flex; flex-direction: column; gap: 6px; }
.message header { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; font-size: 13px; }
.message header time { color: var(--muted); }
.message-body { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 12px 16px; box-shadow: 0 1px 2px rgba(14, 17, 22, .04); line-height: 1.6; }
.message-body p + p { margin-top: 10px; }
.message.agent { flex-direction: row-reverse; }
.message.agent .message-content { align-items: flex-end; }
.message.agent .message-body { background: var(--accent); border-color: var(--accent); color: #FFFFFF; }
.message.agent .message-body a { color: #FFFFFF; text-decoration: underline; }
.message.internal .message-body { background: var(--note-bg); border: 1px dashed var(--note-line); color: var(--ink); }
.message-label { color: var(--note-fg); font-weight: 600; }
.attachments { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.attachments a { display: inline-flex; align-items: center; gap: 6px; }

/* Composer */
.composer {
  width: calc(100% - 56px); max-width: 764px; margin: 0 auto 24px; position: sticky; bottom: 16px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  overflow: hidden; transition: border-color .25s ease; animation: rise .5s .16s var(--ease) both;
}
.composer-tabs { display: flex; align-items: center; gap: 4px; padding: 4px 8px 0; border-bottom: 1px solid var(--line-2); }
.composer-tabs button { border: 0; border-bottom: 2px solid transparent; background: none; padding: 10px 12px; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; }
.composer-tabs button[aria-selected=true] { color: var(--accent-strong); border-bottom-color: var(--accent); }
.composer-hint { margin-left: auto; font-size: 12px; color: var(--muted); padding-right: 6px; }
.composer textarea { display: block; border: 0; border-radius: 0; padding: 14px 16px; min-height: 96px; box-shadow: none; resize: vertical; background: transparent; }
.composer-bar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 10px; }
.composer-tools { display: flex; gap: 4px; }
.composer-send { display: flex; gap: 8px; }
.canned-picker { display: inline-flex; align-items: center; gap: 6px; margin: 0; padding: 0 8px; border-radius: 8px; color: var(--ink-2); font-weight: 400; }
.canned-picker:hover { background: var(--quiet-bg); }
.canned-picker select { width: auto; border: 0; background-color: transparent; padding: 6px 24px 6px 0; background-position: right 4px center; box-shadow: none; }
.composer.is-note { border-color: var(--note-line); }
.composer.is-note, .composer.is-note textarea { background: var(--note-bg); }
.composer.is-note .composer-tabs button[aria-selected=true] { color: var(--note-fg); border-bottom-color: #C08A00; }

/* Details pane */
.side-pane { background: var(--surface); border-left: 1px solid var(--line); padding: 22px 20px; display: flex; flex-direction: column; gap: 22px; height: 100vh; position: sticky; top: 0; overflow-y: auto; animation: rise .5s .08s var(--ease) both; }
.customer-card { display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; padding-bottom: 18px; border-bottom: 1px solid var(--line-2); }
.customer-card strong { font-size: 16px; margin-top: 6px; }
.mini-stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; width: 100%; margin-top: 12px; }
.mini-stats > div { background: var(--surface-2); border-radius: 12px; padding: 10px; display: flex; flex-direction: column; }
.mini-stats .stat-value { font-size: 18px; }
.side-section { display: flex; flex-direction: column; gap: 10px; }
.side-label { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.ticket-controls { display: grid; grid-template-columns: 80px minmax(0, 1fr); gap: 8px; align-items: center; }
.ticket-controls label { margin: 0; font-weight: 400; color: var(--muted); }
.ticket-controls select { height: 36px; padding-top: 0; padding-bottom: 0; }
.ticket-controls input[type=submit] { grid-column: 2; }
.facts { margin: 0; display: grid; grid-template-columns: 80px minmax(0, 1fr); row-gap: 8px; column-gap: 8px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.tag-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.ticket-tags .tag { padding: 2px 4px 2px 10px; font-size: 12px; }
.tag-remove { background: none; border: 0; color: var(--accent-strong); font: inherit; padding: 0 5px; cursor: pointer; border-radius: 999px; }
.tag-remove:hover { background: #DCE3FF; }
.add-tag input[type=text] { width: 96px; padding: 3px 10px; border: 1px dashed #C5CBD6; border-radius: 999px; font-size: 12px; }
.other-tickets ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.other-tickets a { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; color: var(--ink); }
.other-tickets a:hover { background: var(--surface-2); }
.portal-link { margin-top: auto; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.copy-link { width: 100%; }
.portal-link form.button_to { display: block; }
button.reset-link { color: var(--muted); font-size: 13px; padding: 4px 6px; border-radius: 6px; }
button.reset-link:hover { color: var(--accent-strong); }
button.reset-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Plain pages: canned replies, agents, inboxes */
table.tickets { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow); overflow: hidden; }
table.tickets th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--surface-2); }
table.tickets td { padding: 14px 16px; border-bottom: 1px solid var(--line-2); }
table.tickets tr:last-child td { border-bottom: 0; }
table.tickets tbody tr { transition: background-color .2s ease; }
table.tickets tbody tr:hover { background: #F7F8FF; }
td.actions { text-align: right; white-space: nowrap; }
td.actions form, td.actions a { display: inline; margin-left: 12px; }
.canned-replies { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.canned-replies li { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 16px 18px; display: flex; flex-direction: column; gap: 8px; }
.canned-replies li p { color: var(--muted); flex: 1; }
.card-actions { display: flex; gap: 16px; align-items: center; }
.card-actions form { display: inline; }
.page form:not(.button_to) { max-width: 620px; }
.page form input[type=submit] { margin-top: 20px; }
.empty { color: var(--muted); }

/* Sign in, password reset and invitations */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(1200px 600px at 10% -10%, #E6EBFF 0%, transparent 60%), var(--ground); }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow-lg); padding: 32px; animation: rise .5s var(--ease) both; }
.auth-card .brand { padding: 0; margin-bottom: 24px; color: var(--ink); }
.auth-card h1 { font-size: 24px; margin-bottom: 8px; }
.auth-card .demo-hint { margin: 16px 0 0; padding: 12px 14px; background: var(--accent-tint); color: var(--ink); border-radius: var(--radius-sm); font-size: 13px; line-height: 1.5; }
.auth-card form { display: flex; flex-direction: column; margin: 8px 0 16px; }
.auth-card form label { margin: 14px 0 6px; }
.auth-card form input[type=submit] { margin-top: 20px; }
.auth-card form br { display: none; }
.auth-card input[type=submit] { width: 100%; margin-top: 6px; }

/* Customer portal */
body.portal { background: var(--ground); }
body.portal > main { max-width: 760px; margin: 0 auto; padding: 40px 24px 64px; display: flex; flex-direction: column; gap: 16px; animation: rise .5s var(--ease) both; }
body.portal .conversation { padding: 8px 0; max-width: none; }
body.portal .reply { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); padding: 16px; }
body.portal .reply label { margin-top: 0; }
body.portal .reply input[type=submit] { margin-top: 12px; }
.portal-header { display: flex; flex-direction: column; gap: 8px; }
.portal-header .brand { padding: 0; margin-bottom: 16px; color: var(--ink); }
body.portal .message.customer { flex-direction: row-reverse; }
body.portal .message.customer .message-content { align-items: flex-end; }
body.portal .message.customer .message-body { background: var(--accent); border-color: var(--accent); color: #FFFFFF; }
body.portal .message.agent { flex-direction: row; }
body.portal .message.agent .message-content { align-items: flex-start; }
body.portal .message.agent .message-body { background: var(--surface); border-color: var(--line); color: var(--ink); }
.rating-prompt { padding: 12px 16px; border-radius: var(--radius-sm); background: var(--accent-tint); }
.rating-choices { display: flex; gap: 12px; }
.rating-choices legend { font-weight: 600; margin-bottom: 8px; }
.rating-choices label { display: inline-flex; align-items: center; gap: 8px; margin: 0; padding: 10px 14px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); font-weight: 500; cursor: pointer; }
.rating-choices label:has(input:checked) { border-color: var(--accent); box-shadow: var(--focus); }

/* Motion */
@keyframes rise { from { transform: translateY(8px); } to { transform: none; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Smaller screens: the panes stack and the sidebar becomes a top bar */
@media (max-width: 1180px) {
  .workspace.has-ticket { grid-template-columns: minmax(280px, 340px) minmax(0, 1fr); }
  .workspace.has-ticket .side-pane { grid-column: 2; height: auto; position: static; border-left: 0; border-top: 1px solid var(--line); }
}
@media (max-width: 860px) {
  .app { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 10px; padding: 12px; }
  .sidebar .sidebar-group:not(.filters), .sidebar .sidebar-label { display: none; }
  .sidebar .filters { flex-direction: row; overflow-x: auto; width: 100%; }
  .sidebar-search { flex: 1; }
  .workspace, .workspace.has-ticket { grid-template-columns: minmax(0, 1fr); }
  .list-pane, .side-pane { height: auto; position: static; }
  .workspace.has-ticket .list-pane { display: none; }
  .workspace.has-ticket .side-pane { grid-column: 1; }
  .detail-empty { display: none; }
  .back-link { display: inline-flex; }
  .page { padding: 24px 16px; }
  .composer { width: calc(100% - 24px); position: static; }
  .composer-hint { display: none; }
  .sidebar .filters a { white-space: nowrap; }
  .sidebar .brand-name { display: none; }
  .conversation { padding: 16px 12px; }
  .stats { grid-template-columns: minmax(0, 1fr); }
}
