/* =============================================================================
   app.css — the two apps built on tokens.css.

   PORTAL (customer): four destinations, a floating Get Help button, and cards
   big enough to tap without aiming. Nothing here should ever surface a priority,
   an SLA or an assignee — see the customerDto in functions-servicedesk.

   DESK (internal): the same tokens at a tighter rhythm, plus the two views the
   spec cares about — "what needs my attention today" and triage.
   ============================================================================= */

/* =============================================================================
   PORTAL
   ============================================================================= */

.sd-greeting { display: grid; gap: 3px; margin: 6px 0 18px; }
.sd-greeting__hi { font-size: clamp(23px, 6.2vw, 30px); font-weight: 800; letter-spacing: -.03em; }
.sd-greeting__sub { color: var(--sd-muted); font-size: 14.5px; }

/* Service card — icon, name, health, open count. */
.sd-service { display: grid; gap: 10px; }
.sd-service__top { display: flex; align-items: center; gap: 11px; }
.sd-service__icon {
  width: 40px; height: 40px; border-radius: 12px; flex: none;
  display: grid; place-items: center; font-size: 20px;
  background: var(--sd-primary-tint);
}
.sd-service__name { font-weight: 700; font-size: 16px; letter-spacing: -.01em; }
.sd-service__desc { color: var(--sd-muted); font-size: 13px; }
.sd-service__foot { display: flex; align-items: center; gap: 8px; }

/* Request row — reference, title, status. Used in both apps. */
.sd-req { display: grid; gap: 7px; }
.sd-req__top { display: flex; align-items: center; gap: 9px; }
.sd-req__title { font-weight: 650; font-size: 15px; letter-spacing: -.01em; }
.sd-req__meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; color: var(--sd-muted); font-size: 12.5px; }

/* The single most important control on the customer's screen. */
.sd-fab {
  position: fixed; z-index: 40;
  right: max(16px, calc(50vw - 574px));
  bottom: calc(76px + env(safe-area-inset-bottom, 0px));
  border: none; cursor: pointer; font: inherit; font-weight: 700; font-size: 15.5px;
  color: #fff; background: var(--sd-primary);
  padding: 15px 22px; border-radius: 999px;
  box-shadow: 0 10px 28px -8px color-mix(in srgb, var(--sd-primary) 70%, transparent), var(--sd-shadow);
  display: inline-flex; align-items: center; gap: 9px;
  transition: transform .15s var(--sd-ease), box-shadow .15s var(--sd-ease);
}
.sd-fab:hover { transform: translateY(-2px); }
.sd-fab:active { transform: translateY(0); }

/* Bottom navigation — four destinations, nothing more. */
.sd-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 45;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: color-mix(in srgb, var(--sd-surface) 92%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  backdrop-filter: saturate(180%) blur(16px);
  border-top: 1px solid var(--sd-border);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.sd-nav__item {
  appearance: none; background: none; border: none; cursor: pointer; font: inherit;
  padding: 9px 4px 10px; display: grid; gap: 3px; justify-items: center;
  color: var(--sd-muted); font-size: 11px; font-weight: 600; position: relative;
}
.sd-nav__item[aria-current="page"] { color: var(--sd-primary-600); }
.sd-nav__icon { font-size: 19px; line-height: 1; }
.sd-nav__dot {
  position: absolute; top: 7px; right: calc(50% - 17px);
  min-width: 16px; height: 16px; padding: 0 4px; border-radius: 999px;
  background: var(--sd-err); color: #fff; font-size: 10px; font-weight: 700;
  display: grid; place-items: center;
}

/* Conversation thread — shared by portal and desk. */
.sd-thread { display: grid; gap: 12px; }
.sd-msg { display: grid; gap: 5px; max-width: 88%; }
.sd-msg__bubble {
  padding: 11px 14px; border-radius: 15px;
  background: var(--sd-surface); border: 1px solid var(--sd-border);
  font-size: 14.5px; line-height: 1.55;
}
.sd-msg__meta { font-size: 11.5px; color: var(--sd-muted); padding: 0 3px; }
.sd-msg--mine { justify-self: end; }
.sd-msg--mine .sd-msg__bubble {
  background: var(--sd-primary); border-color: transparent; color: #fff;
}
.sd-msg--mine .sd-msg__meta { text-align: right; }
/* An internal note must never look like something the customer was sent. */
.sd-msg--internal .sd-msg__bubble {
  background: var(--sd-warn-bg); border-color: color-mix(in srgb, var(--sd-warn) 35%, transparent);
  color: var(--sd-warn-fg);
}
.sd-msg--system { max-width: 100%; justify-self: center; text-align: center; }
.sd-msg--system .sd-msg__bubble {
  background: transparent; border: none; color: var(--sd-muted);
  font-size: 12.5px; font-style: italic; padding: 2px;
}

.sd-attach {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 11px; border-radius: 10px; font-size: 13px;
  background: var(--sd-surface-2); border: 1px solid var(--sd-border);
  color: var(--sd-text-2); text-decoration: none; max-width: 100%;
}
.sd-attach:hover { border-color: var(--sd-border-strong); }
.sd-attach__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* The composer at the foot of a request. */
.sd-composer {
  display: grid; gap: 10px; position: sticky; bottom: 0;
  background: color-mix(in srgb, var(--sd-bg) 92%, transparent);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  padding: 12px 0 4px;
}

/* The Get Help flow: one question per step. */
.sd-steps { display: grid; gap: 14px; }
.sd-step__q { font-size: 19px; font-weight: 750; letter-spacing: -.02em; margin: 0 0 12px; }
.sd-progress { display: flex; gap: 5px; margin-bottom: 4px; }
.sd-progress__bar { height: 4px; border-radius: 99px; background: var(--sd-border); flex: 1; }
.sd-progress__bar--on { background: var(--sd-primary); }

.sd-success { text-align: center; display: grid; gap: 10px; padding: 26px 12px; }
.sd-success__tick {
  width: 62px; height: 62px; border-radius: 50%; margin: 0 auto;
  background: var(--sd-ok-bg); color: var(--sd-ok-fg);
  display: grid; place-items: center; font-size: 30px;
}

/* =============================================================================
   DESK
   ============================================================================= */

.sd-compact {
  --sd-space: 12px;
  --sd-card-pad: 14px;
  --sd-radius: 13px;
}

/* Top tab bar — the desk's eight areas, capability-filtered. */
.sd-tabs {
  display: flex; gap: 3px; overflow-x: auto; scrollbar-width: none;
  border-bottom: 1px solid var(--sd-border); padding: 0 4px;
  background: color-mix(in srgb, var(--sd-surface) 70%, transparent);
  position: sticky; top: 53px; z-index: 25;
}
.sd-tabs::-webkit-scrollbar { display: none; }
.sd-tab {
  appearance: none; background: none; border: none; cursor: pointer; font: inherit;
  padding: 11px 13px; font-size: 14px; font-weight: 620; color: var(--sd-muted);
  border-bottom: 2.5px solid transparent; white-space: nowrap;
}
.sd-tab[aria-current="page"] { color: var(--sd-primary-600); border-bottom-color: var(--sd-primary); }
.sd-tab__count {
  display: inline-block; margin-left: 6px; padding: 1px 7px; border-radius: 999px;
  background: var(--sd-neutral-bg); color: var(--sd-neutral-fg); font-size: 11.5px; font-weight: 700;
}
.sd-tab__count--alert { background: var(--sd-err-bg); color: var(--sd-err-fg); }

/* The five numbers that open the internal dashboard. */
.sd-tiles { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(124px, 1fr)); }
.sd-tile {
  background: var(--sd-surface); border: 1px solid var(--sd-border);
  border-radius: 13px; padding: 13px 14px; display: grid; gap: 2px;
  cursor: pointer; text-align: left; font: inherit; color: inherit;
  border-left: 3px solid var(--sd-tile-accent, var(--sd-border-strong));
  transition: transform .14s var(--sd-ease), box-shadow .14s var(--sd-ease);
}
.sd-tile:hover { transform: translateY(-1px); box-shadow: var(--sd-shadow-sm); }
.sd-tile__n { font-size: 25px; font-weight: 800; letter-spacing: -.03em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.sd-tile__l { font-size: 12.5px; color: var(--sd-muted); font-weight: 600; }

/* Filter bar above every desk list. */
.sd-filters {
  display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
  padding: 11px 0; position: sticky; top: 97px; z-index: 20;
  background: color-mix(in srgb, var(--sd-bg) 90%, transparent);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
}
.sd-filters .sd-input, .sd-filters .sd-select { min-height: 38px; padding: 7px 11px; font-size: 14px; width: auto; }
.sd-filters .sd-input { min-width: 190px; flex: 1; }

/* A desk request row: dense, scannable, priority-striped. */
.sd-work { display: grid; gap: 9px; }
.sd-work__row { display: flex; align-items: flex-start; gap: 10px; }
.sd-work__title { font-weight: 650; font-size: 14.5px; letter-spacing: -.01em; flex: 1; }
.sd-work__meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; font-size: 12.5px; color: var(--sd-muted); }
.sd-work__sla { font-weight: 700; font-variant-numeric: tabular-nums; }
.sd-work__sla--risk { color: var(--sd-warn); }
.sd-work__sla--breached { color: var(--sd-err); }
.sd-work__sla--ok { color: var(--sd-ok); }

/* Two-pane detail: the request on the left, the actions on the right. */
.sd-split { display: grid; gap: 16px; align-items: start; }
@media (min-width: 900px) {
  .sd-split { grid-template-columns: minmax(0, 1fr) 300px; }
  .sd-split__side { position: sticky; top: 110px; }
}

.sd-kv { display: grid; gap: 9px; }
.sd-kv__row { display: flex; gap: 10px; align-items: baseline; font-size: 13.5px; }
.sd-kv__k { color: var(--sd-muted); min-width: 92px; flex: none; }
.sd-kv__v { font-weight: 600; overflow-wrap: anywhere; }

/* Suggested priority on the triage screen — a recommendation, never a decision. */
.sd-suggest {
  display: grid; gap: 4px; padding: 11px 13px; border-radius: 12px;
  background: var(--sd-accent-tint); border: 1px solid color-mix(in srgb, var(--sd-accent) 30%, transparent);
}
.sd-suggest__l { font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; font-weight: 750; color: var(--sd-warn-fg); }
.sd-suggest__v { font-size: 17px; font-weight: 800; letter-spacing: -.02em; }
.sd-suggest__why { font-size: 12.5px; color: var(--sd-text-2); }

/* Tables — reports, users, customers. Always scrollable rather than squeezed. */
.sd-tablewrap { overflow-x: auto; border: 1px solid var(--sd-border); border-radius: var(--sd-radius); background: var(--sd-surface); }
.sd-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.sd-table th, .sd-table td { padding: 10px 13px; text-align: left; border-bottom: 1px solid var(--sd-border); white-space: nowrap; }
.sd-table th { font-weight: 700; color: var(--sd-text-2); background: var(--sd-surface-2); position: sticky; top: 0; font-size: 12.5px; }
.sd-table tr:last-child td { border-bottom: none; }
.sd-table tbody tr:hover { background: var(--sd-surface-2); }
.sd-table td.sd-num { text-align: right; font-variant-numeric: tabular-nums; }

/* Pipeline strip on the leads / requirements screens. */
.sd-pipeline { display: grid; gap: 8px; grid-template-columns: repeat(auto-fit, minmax(104px, 1fr)); }
.sd-pipeline__cell {
  background: var(--sd-surface); border: 1px solid var(--sd-border); border-radius: 12px;
  padding: 11px 12px; display: grid; gap: 1px; cursor: pointer; text-align: left; font: inherit; color: inherit;
}
.sd-pipeline__cell[aria-pressed="true"] { border-color: var(--sd-primary); box-shadow: inset 0 0 0 1px var(--sd-primary); }
.sd-pipeline__n { font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; }
.sd-pipeline__l { font-size: 11.5px; color: var(--sd-muted); font-weight: 600; }

/* Notification tray. */
.sd-tray { display: grid; gap: 8px; max-height: 60vh; overflow-y: auto; }
.sd-tray__item {
  display: grid; gap: 3px; padding: 11px 13px; border-radius: 11px;
  background: var(--sd-surface-2); border: 1px solid var(--sd-border);
  cursor: pointer; text-align: left; font: inherit; color: inherit;
}
.sd-tray__item--unread { border-left: 3px solid var(--sd-primary); }
.sd-tray__t { font-weight: 650; font-size: 13.5px; }
.sd-tray__b { font-size: 12.5px; color: var(--sd-muted); }

/* Sign-in / landing. */
.sd-hero { display: grid; gap: 18px; justify-items: center; text-align: center; padding: 8vh 0 0; }
.sd-hero__mark {
  width: 66px; height: 66px; border-radius: 20px; background: var(--sd-grad); color: #fff;
  display: grid; place-items: center; font-size: 27px; font-weight: 800; box-shadow: var(--sd-shadow);
}
.sd-hero__lanes { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.sd-gbtn {
  display: inline-flex; align-items: center; gap: 11px;
  background: #fff; color: #1f2430; border: 1px solid #dadce0;
  padding: 12px 22px; border-radius: 12px; font-weight: 650; font-size: 15px;
  cursor: pointer; box-shadow: var(--sd-shadow-sm); min-height: 48px;
}
.sd-gbtn:hover { background: #f7f8fa; }
.sd-gbtn__g { width: 19px; height: 19px; flex: none; }

/* =============================================================================
   DESK — guided answers, leads workspace, knowledge
   ============================================================================= */
.sd-impact { color: var(--sd-warn-fg); font-weight: 650; font-size: 12.5px; }

.sd-details { display: grid; gap: 12px; border-top: 1px solid var(--sd-border); padding-top: 11px; }
.sd-details__sec { display: grid; gap: 5px; }
.sd-details__title { font-size: 11.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--sd-muted); }
.sd-details__row { display: grid; grid-template-columns: minmax(130px, 34%) 1fr; gap: 10px; font-size: 13.5px; }
.sd-details__row--long { grid-template-columns: 1fr; gap: 2px; }
.sd-details__k { color: var(--sd-muted); }
.sd-details__v { font-weight: 600; overflow-wrap: anywhere; }
.sd-chatbox summary { cursor: pointer; font-weight: 650; font-size: 13.5px; }

.sd-pipeline__v { font-size: 11.5px; color: var(--sd-text-2); font-weight: 650; font-variant-numeric: tabular-nums; }
.sd-leadcard { display: block; }

.sd-stages { list-style: none; margin: 4px 0; padding: 0; display: flex; gap: 4px; flex-wrap: wrap; }
.sd-stages__s {
  flex: 1; min-width: 92px; text-align: center; font-size: 12px; font-weight: 700; padding: 7px 8px;
  background: var(--sd-surface-2); color: var(--sd-muted); border: 1px solid var(--sd-border);
  clip-path: polygon(0 0, calc(100% - 8px) 0, 100% 50%, calc(100% - 8px) 100%, 0 100%, 8px 50%);
}
.sd-stages__s:first-child { clip-path: polygon(0 0, calc(100% - 8px) 0, 100% 50%, calc(100% - 8px) 100%, 0 100%); }
.sd-stages__s--done { background: var(--sd-ok-bg); color: var(--sd-ok-fg); border-color: transparent; }
.sd-stages__s--now { background: var(--sd-primary); color: #fff; border-color: transparent; }

.sd-logupdate { display: grid; gap: 10px; margin-bottom: 12px; }
.sd-kind {
  appearance: none; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
  padding: 6px 11px; border-radius: 999px; border: 1px solid var(--sd-border-strong);
  background: var(--sd-surface); color: var(--sd-text-2);
}
.sd-kind[aria-pressed="true"] { background: var(--sd-primary-tint); border-color: var(--sd-primary); color: var(--sd-primary-700); }

.sd-timeline { display: grid; gap: 0; }
.sd-tl { display: grid; grid-template-columns: 34px 1fr; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--sd-border); }
.sd-tl:last-child { border-bottom: none; }
.sd-tl__icon { width: 34px; height: 34px; border-radius: 10px; background: var(--sd-surface-2); display: grid; place-items: center; font-size: 16px; }
.sd-tl__body { display: grid; gap: 5px; font-size: 14px; min-width: 0; }
.sd-tl__meta { font-size: 12.5px; color: var(--sd-muted); }

.sd-contact { display: grid; gap: 2px; font-size: 13.5px; }
.sd-contact a { overflow-wrap: anywhere; }
.sd-contactrow { display: grid; gap: 6px; grid-template-columns: 1fr 1fr; margin-bottom: 10px; padding-bottom: 10px; border-bottom: 1px dashed var(--sd-border); }
@media (min-width: 760px) { .sd-contactrow { grid-template-columns: 1.2fr 1fr 1.4fr 1fr auto; } }

.sd-grid2 { display: grid; gap: 12px; }
@media (min-width: 640px) { .sd-grid2 { grid-template-columns: 1fr 1fr; } }
.sd-formsec { display: grid; gap: 14px; }
.sd-formsec__head { display: flex; gap: 12px; align-items: flex-start; }
.sd-formsec__n {
  width: 28px; height: 28px; border-radius: 50%; background: var(--sd-primary); color: #fff;
  display: grid; place-items: center; font-weight: 800; font-size: 13px; flex: none;
}
