/* ===========================================================================
   Ask-IT — app styles: ticket form states, client portal, staff desk.
   Loaded after site.css and uses its tokens (--ink, --teal, --accent …).
   =========================================================================== */

/* --- small utilities ------------------------------------------------------ */
.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; }
.row { display: flex; align-items: center; }
.wrap-row { flex-wrap: wrap; }
.gap-4 { gap: 4px; }
.gap-20 { gap: 20px; }
.mono { font-family: 'IBM Plex Mono', ui-monospace, Menlo, monospace; font-size: 0.95em; }
.small { font-size: 13px; }
.back { font-size: 14px; text-decoration: none; }
.back:hover { text-decoration: underline; }
.linklike { background: none; border: 0; padding: 0; font: inherit; color: var(--teal); cursor: pointer; text-decoration: underline; }
.inline-form { display: inline; margin: 0; }

/* --- form states (public ticket form and everywhere else) ----------------- */
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.field-error { font-size: 13px; font-weight: 500; color: #9B2C16; }
[aria-invalid="true"] { border: 2px solid #B3261E !important; background: #FFFBFA; }
.consent--bad { border-color: #D9A08B; background: #FDF1EE; }
.error-list { margin: 8px 0 0; padding-left: 18px; }
.error-list a { color: #7A2D12; }
.form-error strong { display: block; }
.tick-badge { width: 56px; height: 56px; border-radius: 50%; background: #E3F0EC; color: var(--teal); display: flex; align-items: center; justify-content: center; }
.ref-big { font-family: 'IBM Plex Mono', ui-monospace, monospace; font-weight: 500; color: var(--accent); white-space: nowrap; }
.fact { background: var(--ground); border-radius: var(--radius); padding: 18px; display: flex; flex-direction: column; gap: 4px; }
.fact strong { font-weight: 500; }
.static-val { padding: 12px 0; font-size: 16px; }
button[disabled] { opacity: 0.7; cursor: progress; }

/* --- status pills ---------------------------------------------------------- */
.sp { display: inline-block; font-size: 12px; font-weight: 600; line-height: 1.4; padding: 4px 10px; border-radius: 999px; white-space: nowrap; vertical-align: middle; }
.sp--new    { background: #F8E1DA; color: #8E2F12; }
.sp--urgent { background: #F8E1DA; color: #8E2F12; }
.sp--open   { background: #E3F0EC; color: #0B5A50; }
.sp--wait   { background: #FBEBD9; color: #7F4210; }
.sp--closed { background: #ECE7DC; color: #4A5A61; }
.sp--quote  { background: #E6ECF7; color: #28437A; }
.tag-mini { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px; color: #28437A; }

/* --- panels, tables, segmented filters ------------------------------------ */
.panel--flush { padding: 0; overflow: hidden; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 22px 24px 14px; flex-wrap: wrap; }
.table-scroll { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-size: 12px; font-weight: 600; letter-spacing: 0.4px; text-transform: uppercase; color: var(--muted-2); padding: 12px 16px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { font-size: 15px; padding: 14px 16px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover td { background: #FBFAF7; }
.row-link { color: var(--ink); text-decoration: none; font-weight: 500; }
.row-link:hover { text-decoration: underline; }
.empty { padding: 36px 24px; display: flex; flex-direction: column; gap: 14px; align-items: flex-start; color: var(--muted); }

.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg a, .seg--radio label { font-size: 14px; padding: 8px 14px; border-radius: 999px; background: var(--ground-2); color: var(--ink-soft); text-decoration: none; cursor: pointer; }
.seg a.is-on { background: var(--deep); color: #FFFFFF; }
.seg--radio { border: 0; padding: 0; margin: 0; }
.seg--radio input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.seg--radio input:checked + label { background: var(--deep); color: #FFFFFF; }
.seg--radio input:focus-visible + label { outline: 2px solid var(--teal); outline-offset: 2px; }

.callout { background: #FBF3E6; border: 1px solid #EBD3AE; border-radius: var(--radius-lg); padding: 18px 22px; display: flex; justify-content: space-between; align-items: center; gap: 20px; flex-wrap: wrap; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; margin: 0; font-size: 14px; }
.kv dt { color: var(--muted-2); }
.kv dd { margin: 0; text-align: right; overflow-wrap: anywhere; }

/* --- the ticket thread ---------------------------------------------------- */
.thread { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.msg { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 18px 22px; display: flex; flex-direction: column; gap: 10px; }
.msg--staff { border-color: #C9D8D4; background: #FBFDFC; }
.msg--note { background: #FBF3E6; border: 1px dashed #D9B77E; }
.msg__head { display: flex; justify-content: space-between; gap: 16px; font-size: 14px; flex-wrap: wrap; }
.msg__body { font-size: 15px; line-height: 1.65; overflow-wrap: anywhere; }
.msg__body p + p { margin-top: 10px; }
.files { list-style: none; margin: 0; padding: 0; display: flex; gap: 8px; flex-wrap: wrap; }
.file-chip { display: inline-flex; gap: 6px; align-items: center; font-size: 13px; border: 1px solid var(--line); border-radius: 6px; padding: 7px 11px; text-decoration: none; color: var(--ink); background: var(--panel); }
.file-chip:hover { border-color: var(--teal); }

/* =========================================================================
   Client portal
   ========================================================================= */
body.app { display: flex; flex-direction: column; min-height: 100vh; }
.app-top { background: var(--panel); border-bottom: 1px solid var(--line); }
.app-top__inner { min-height: 76px; display: flex; align-items: center; justify-content: space-between; gap: 24px; flex-wrap: wrap; padding-top: 10px; padding-bottom: 10px; }
.app-top__left { display: flex; align-items: center; gap: 40px; }
.app-top__label { font-size: 14px; color: var(--muted-2); }
.app-nav { display: flex; gap: 28px; font-size: 15px; }
.app-nav a { color: var(--muted); text-decoration: none; padding: 6px 0; border-bottom: 3px solid transparent; }
.app-nav a.is-current { color: var(--ink); font-weight: 600; border-bottom-color: var(--accent); }
.app-top__right { display: flex; align-items: center; gap: 18px; font-size: 14px; }
.app-user { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.3; }
.app-user span { color: var(--muted-2); font-size: 13px; }
.app-main { flex: 1 0 auto; }
.app-page { padding-top: 40px; padding-bottom: 64px; }
.app-foot { border-top: 1px solid var(--line); padding: 20px 0; font-size: 13px; color: var(--muted-2); }

.auth-wrap { display: flex; gap: 48px; justify-content: center; align-items: flex-start; padding-top: 64px; padding-bottom: 80px; flex-wrap: wrap; }
.auth-card { width: 100%; max-width: 460px; }
.auth-aside { width: 300px; padding-top: 12px; }

.ticket-layout { display: flex; gap: 32px; align-items: flex-start; }
.ticket-main { flex: 1 1 auto; min-width: 0; }
.ticket-side { width: 300px; flex: 0 0 auto; padding-top: 38px; }

/* =========================================================================
   Staff desk
   ========================================================================= */
body.desk { background: var(--ground); }
.desk-shell { display: flex; min-height: 100vh; }
.desk-side { width: 236px; flex: 0 0 auto; background: var(--deep); color: var(--on-deep-3); padding: 26px 16px; display: flex; flex-direction: column; gap: 28px; position: sticky; top: 0; height: 100vh; }
.desk-side__brand { padding: 0 10px; display: flex; flex-direction: column; gap: 2px; }
.logo--light .logo__word { color: #FFFFFF; }
.desk-side__label { font-size: 12px; letter-spacing: 0.8px; text-transform: uppercase; }
.desk-side__nav { display: flex; flex-direction: column; gap: 2px; }
.desk-side__nav a { display: flex; justify-content: space-between; align-items: center; padding: 11px 12px; border-radius: 6px; color: #C3D2D0; text-decoration: none; font-size: 15px; }
.desk-side__nav a:hover { background: #163A42; color: #FFFFFF; }
.desk-side__nav a.is-current { background: #1E434B; color: #FFFFFF; font-weight: 600; }
.desk-side__nav .count { font-size: 12px; background: #2E5A63; color: #E6EEED; padding: 1px 8px; border-radius: 999px; }
.desk-side__me { margin-top: auto; padding: 14px 10px 0; border-top: 1px solid #1E434B; display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.desk-side__me strong { color: #FFFFFF; }
.desk-side__me a { color: #A9BDBC; }
.desk-main { flex: 1 1 auto; min-width: 0; }
.desk-page { padding: 30px 36px 64px; }
.desk-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.search { min-width: 300px; min-height: 42px; padding: 9px 12px; font-size: 15px; }
.stat-tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 16px 18px; display: flex; flex-direction: column; gap: 2px; }
.stat-tile strong { font-family: var(--serif); font-size: 30px; font-weight: 600; }
.stat-tile strong.is-hot { color: #B3261E; }
.tbl--queue .urg-col { width: 6px; padding: 0; }
.urg-p1 { background: #B3261E; }
.urg-p2 { background: #D9A441; }
.urg-p3 { background: #C9C1B3; }

.desk-ticket { display: flex; gap: 28px; align-items: flex-start; }
.desk-ticket__main { flex: 1 1 auto; min-width: 0; }
.desk-ticket__side { width: 320px; flex: 0 0 auto; padding-top: 34px; }
.desk-ticket__side .card { padding: 20px; gap: 12px; }
.desk-ticket__side .field select, .desk-ticket__side .field input { min-height: 42px; padding: 9px 12px; font-size: 15px; }
details.card > summary { cursor: pointer; list-style: none; }
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary::after { content: ' +'; color: var(--muted-2); }
details.card[open] > summary::after { content: ' −'; }
.audit { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; font-size: 13px; }

.composer .when-note { display: none; }
.composer:has(#m-note:checked) .when-note { display: inline; }
.composer:has(#m-note:checked) .when-reply { display: none; }
.composer:has(#m-note:checked) textarea { background: #FFFBF3; border-color: #D9B77E; }
.composer__label { font-size: 14px; }

/* --- narrow screens -------------------------------------------------------- */
@media (max-width: 960px) {
  .ticket-layout, .desk-ticket { flex-direction: column; }
  .ticket-side, .desk-ticket__side { width: 100%; padding-top: 0; }
  .desk-shell { flex-direction: column; }
  .desk-side { width: 100%; height: auto; position: static; padding: 14px 16px; gap: 12px; }
  .desk-side__nav { flex-direction: row; flex-wrap: wrap; }
  .desk-side__me { display: none; }
  .desk-page { padding: 22px 16px 48px; }
  .search { min-width: 0; width: 100%; }
}
@media (max-width: 640px) {
  .app-top__left { gap: 20px; }
  .app-user { display: none; }
  .auth-wrap { padding-top: 28px; }
  .tbl th:nth-child(4), .tbl td:nth-child(4) { display: none; }
  .kv dd { text-align: left; }
}
