:root {
  --bg: #EEF3F2;
  --surface: #FFFFFF;
  --surface-2: #F6F9F8;
  --ink: #15232A;
  --muted: #586A72;
  --line: #D5DFDD;
  --primary: #0B6E61;
  --primary-hover: #095A50;
  --primary-ink: #FFFFFF;
  --primary-soft: #DDEFEA;
  --ok: #2B7A4B;
  --risk: #B26B00;
  --bad: #C0392B;
  --pause: #687B86;
  --note: #FFF4CC;
  --note-line: #E3C55C;
  --focus: #1D8CF0;
  --shadow: 0 1px 2px rgba(21, 35, 42, .06), 0 8px 24px rgba(21, 35, 42, .08);
  --font: "IBM Plex Sans Hebrew", "Segoe UI", Arial, sans-serif;
  --display: "Fredoka", "IBM Plex Sans Hebrew", "Segoe UI", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0E1618;
    --surface: #152024;
    --surface-2: #1A272B;
    --ink: #E4EDEB;
    --muted: #94A7AC;
    --line: #27383C;
    --primary: #36B3A0;
    --primary-hover: #4CC5B2;
    --primary-ink: #06201C;
    --primary-soft: #143430;
    --ok: #5CC488;
    --risk: #E5A33A;
    --bad: #F07563;
    --pause: #8FA2AC;
    --note: #2F2A12;
    --note-line: #7C6A22;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .35);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink); font: 15px/1.55 var(--font);
  padding: env(safe-area-inset-top, 0) env(safe-area-inset-right, 0) env(safe-area-inset-bottom, 0) env(safe-area-inset-left, 0);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: var(--display); font-weight: 600; line-height: 1.2; margin: 0; letter-spacing: 0; }
h1 { font-size: 1.9rem; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.05rem; }
p { margin: 0; }
a { color: var(--primary); }
.muted { color: var(--muted); }
.small { font-size: .86rem; }
.hidden { display: none !important; }
.boot { padding: 4rem; text-align: center; color: var(--muted); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---------- controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  font: 500 .95rem/1 var(--font); padding: .7rem 1.1rem; border-radius: 10px; border: 1px solid transparent;
  background: var(--primary); color: var(--primary-ink); cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--primary-hover); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.quiet { background: transparent; color: var(--primary); padding: .45rem .6rem; }
.btn.quiet:hover { background: var(--primary-soft); }
.btn.danger { background: transparent; color: var(--bad); border-color: var(--line); }
.btn.big { padding: 1rem 1.5rem; font-size: 1.05rem; border-radius: 14px; }
.btn.sm { padding: .45rem .7rem; font-size: .85rem; border-radius: 8px; }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.grow { flex: 1; }
label.field { display: grid; gap: .3rem; font-weight: 500; font-size: .9rem; }
.field-title { display: inline-flex; align-items: center; gap: .2rem; }
.required-star { color: #c62828; font-weight: 700; }
form.validation-attempted input:required:invalid,
form.validation-attempted select:required:invalid,
form.validation-attempted textarea:required:invalid,
form input[aria-invalid="true"],
form select[aria-invalid="true"],
form textarea[aria-invalid="true"] {
  border-color: #d32f2f !important;
  outline: 1px solid #d32f2f;
  background-color: #fff6f6;
}
form.validation-attempted label.field:has(:required:invalid) > .field-title { color: #b42318; }
form.validation-attempted label.field:has(:required:invalid)::after {
  content: "יש למלא שדה חובה";
  color: #b42318;
  font-size: .78rem;
  font-weight: 500;
}
label.field > span.hint { font-weight: 400; color: var(--muted); font-size: .82rem; }
input, select, textarea {
  font: 400 .95rem/1.4 var(--font); color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 9px; padding: .62rem .75rem; width: 100%; min-width: 0;
}
textarea { resize: vertical; min-height: 6rem; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); outline: none; box-shadow: 0 0 0 3px var(--primary-soft); }
input[type=checkbox] { width: auto; accent-color: var(--primary); }
.check { display: inline-flex; gap: .45rem; align-items: center; font-size: .9rem; cursor: pointer; }
.form { display: grid; gap: .9rem; }
.form-grid { display: grid; gap: .9rem; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }

/* ---------- chips ---------- */
.chip { display: inline-flex; align-items: center; gap: .3rem; font-size: .78rem; font-weight: 500; padding: .18rem .6rem; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); color: var(--ink); white-space: nowrap; }
.chip.status-פתוח { background: var(--primary-soft); border-color: transparent; color: var(--primary); }
.chip.status-בטיפול { background: #E3EEFB; border-color: transparent; color: #1F5FA6; }
.chip.status-ממתין { background: #F3EBDD; border-color: transparent; color: #8A5A00; }
.chip.status-נסגר { color: var(--muted); }
.chip.p-דחוף { background: var(--bad); color: #fff; border-color: transparent; }
.chip.p-גבוה { color: var(--bad); border-color: currentColor; }
.chip.brand-קיווי::before, .chip.brand-הוניגמן::before, .chip.brand-אידישקייט::before, .chip.brand-מטה::before { content: ""; width: .5rem; height: .5rem; border-radius: 50%; background: var(--b); }
.chip.brand-קיווי { --b: #5BAA3C; }
.chip.brand-הוניגמן { --b: #8B4C8F; }
.chip.brand-אידישקייט { --b: #2F6DB5; }
.chip.brand-מטה { --b: var(--pause); }
@media (prefers-color-scheme: dark) {
  .chip.status-בטיפול { background: #172C44; color: #8EBBEF; }
  .chip.status-ממתין { background: #33291A; color: #E5B865; }
}

/* ---------- top bar ---------- */
.topbar { position: sticky; top: 0; z-index: 20; background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar-in { display: flex; align-items: center; gap: 1rem; padding: .6rem 1.2rem; max-width: 1500px; margin: 0 auto; }
.logo { display: flex; align-items: center; gap: .55rem; font-family: var(--display); font-weight: 600; font-size: 1.25rem; color: var(--ink); text-decoration: none; }
.logo img { width: 30px; height: 30px; }
.who { margin-inline-start: auto; display: flex; align-items: center; gap: .5rem; }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); font-weight: 600; font-family: var(--display); }
.menu { position: relative; }
.menu-list { position: absolute; inset-inline-end: 0; top: calc(100% + 6px); background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); min-width: 220px; padding: .35rem; z-index: 30; }
.menu-list button { display: block; width: 100%; text-align: start; background: none; border: 0; padding: .6rem .75rem; border-radius: 8px; font: inherit; color: var(--ink); cursor: pointer; }
.menu-list button:hover { background: var(--surface-2); }
.menu-list .sep { border-top: 1px solid var(--line); margin: .3rem 0; }

/* ---------- auth ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; }
.auth-card { width: min(420px, 100%); background: var(--surface); border-radius: 18px; box-shadow: var(--shadow); padding: 2rem; display: grid; gap: 1.2rem; }
.auth-card .logo { font-size: 1.5rem; }
.auth-card .logo img { width: 40px; height: 40px; }
.alert { padding: .75rem 1rem; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line); font-size: .92rem; }
.alert.bad { border-color: var(--bad); color: var(--bad); background: transparent; }
.alert.warn { background: #FFF1D6; border-color: #E9C27A; color: #6B4700; }
@media (prefers-color-scheme: dark) { .alert.warn { background: #33281A; border-color: #6E5420; color: #F0C987; } }

/* ---------- agent layout ---------- */
.desk { display: grid; grid-template-columns: 236px 1fr; gap: 1.2rem; max-width: 1500px; margin: 0 auto; padding: 1.2rem; align-items: start; }
.nav { position: sticky; top: 72px; display: grid; gap: .15rem; }
.nav button { display: flex; justify-content: space-between; align-items: center; gap: .5rem; width: 100%; background: none; border: 0; padding: .6rem .8rem; border-radius: 10px; font: 500 .95rem var(--font); color: var(--ink); cursor: pointer; text-align: start; }
.nav button:hover { background: var(--surface); }
.nav button[aria-current=true] { background: var(--surface); box-shadow: inset -3px 0 0 var(--primary); color: var(--primary); }
.nav .count { font-size: .8rem; font-weight: 600; min-width: 1.6rem; text-align: center; padding: .05rem .45rem; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.nav .count.alarm { background: var(--bad); color: #fff; }
.nav .count.warn { background: var(--risk); color: #fff; }
.nav hr { border: 0; border-top: 1px solid var(--line); margin: .6rem .4rem; }
.pulse { display: grid; gap: .55rem; margin-top: .8rem; padding: .9rem; border-radius: 14px; background: var(--surface); }
.pulse div { display: flex; justify-content: space-between; align-items: baseline; font-size: .86rem; color: var(--muted); }
.pulse strong { font-family: var(--display); font-size: 1.15rem; color: var(--ink); font-weight: 600; }

.board { background: var(--surface); border-radius: 16px; box-shadow: var(--shadow); min-width: 0; }
.board-head { display: flex; gap: .7rem; align-items: center; flex-wrap: wrap; padding: 1rem 1.1rem; border-bottom: 1px solid var(--line); }
.board-head h2 { margin-inline-end: auto; }
.board-head input[type=search] { width: 230px; }
.board-head select { width: auto; }
.queue { list-style: none; margin: 0; padding: 0; }
.qrow { display: grid; grid-template-columns: 4.2rem minmax(0, 1fr) 9rem 8rem 10.5rem; gap: .9rem; align-items: center; padding: .85rem 1.1rem; border-bottom: 1px solid var(--line); cursor: pointer; position: relative; }
.qrow:hover { background: var(--surface-2); }
.qrow[aria-selected=true] { background: var(--primary-soft); }
.qrow.urgent::before { content: ""; position: absolute; inset-inline-start: 0; top: .5rem; bottom: .5rem; width: 4px; border-radius: 0 4px 4px 0; background: var(--bad); }
.qid { font-family: var(--display); font-weight: 500; color: var(--muted); }
.qsubj { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qmeta { display: flex; gap: .35rem; flex-wrap: wrap; margin-top: .25rem; align-items: center; }
.qcell { font-size: .88rem; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty { padding: 3rem 1.5rem; text-align: center; color: var(--muted); display: grid; gap: .8rem; justify-items: center; }
.more { padding: 1rem; text-align: center; }

/* ---------- SLA fuse (the signature element) ---------- */
.fuse { display: grid; gap: .3rem; }
.fuse-label { font-size: .8rem; font-weight: 600; display: flex; justify-content: space-between; gap: .4rem; }
.fuse-track { height: 6px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--line); overflow: hidden; }
.fuse-fill { height: 100%; border-radius: 6px; background: var(--ok); transition: width .4s ease; margin-inline-start: auto; }
.fuse.ok .fuse-label { color: var(--ok); }
.fuse.risk .fuse-label { color: var(--risk); } .fuse.risk .fuse-fill { background: var(--risk); }
.fuse.breached .fuse-label, .fuse.missed .fuse-label { color: var(--bad); } .fuse.breached .fuse-fill, .fuse.missed .fuse-fill { background: var(--bad); }
.fuse.breached .fuse-track { background: repeating-linear-gradient(-45deg, transparent 0 5px, color-mix(in srgb, var(--bad) 22%, transparent) 5px 10px); }
.fuse.paused .fuse-label { color: var(--pause); } .fuse.paused .fuse-fill { background: var(--pause); }
.fuse.met .fuse-label { color: var(--muted); } .fuse.met .fuse-fill { background: var(--line); }
.fuse.big .fuse-track { height: 10px; }
.fuse.big .fuse-label { font-size: .9rem; }

/* ---------- drawer & dialogs ---------- */
.scrim { position: fixed; inset: 0; background: rgba(8, 18, 20, .35); z-index: 40; }
.drawer { position: fixed; top: 0; bottom: 0; inset-inline-end: 0; width: min(760px, 100%); background: var(--bg); z-index: 41; display: flex; flex-direction: column; box-shadow: var(--shadow); animation: slide .22s ease-out; }
@keyframes slide { from { transform: translateX(-24px); opacity: .4; } to { transform: none; opacity: 1; } }
.drawer-head { background: var(--surface); padding: 1rem 1.25rem; border-bottom: 1px solid var(--line); display: grid; gap: .6rem; padding-top: max(1rem, env(safe-area-inset-top)); }
.drawer-body { flex: 1; overflow: auto; padding: 1.1rem 1.25rem 2rem; display: grid; gap: 1rem; align-content: start; }
.panel { background: var(--surface); border-radius: 14px; padding: 1rem 1.1rem; display: grid; gap: .8rem; border: 1px solid var(--line); }
.controls { display: grid; gap: .7rem; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
dialog { border: 0; border-radius: 18px; padding: 0; width: min(560px, calc(100% - 2rem)); background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(8, 18, 20, .45); }
.dlg { padding: 1.4rem; display: grid; gap: 1rem; }
.dlg.wide { width: min(860px, 100%); }

/* ---------- thread ---------- */
.thread { display: grid; gap: .75rem; }
.msg { padding: .8rem 1rem; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); max-width: 92%; }
.msg.it { background: var(--primary-soft); border-color: transparent; justify-self: end; }
.msg.mine { justify-self: start; }
.msg.note { background: var(--note); border: 1px dashed var(--note-line); justify-self: end; }
.msg-head { display: flex; gap: .5rem; align-items: baseline; font-size: .82rem; color: var(--muted); margin-bottom: .3rem; flex-wrap: wrap; }
.msg-head strong { color: var(--ink); font-weight: 600; }
.msg-body { white-space: pre-wrap; overflow-wrap: anywhere; }
.event { font-size: .82rem; color: var(--muted); text-align: center; display: flex; align-items: center; gap: .6rem; }
.event::before, .event::after { content: ""; flex: 1; border-top: 1px dashed var(--line); }
.composer { display: grid; gap: .6rem; }

/* ---------- requester home ---------- */
.home { max-width: 820px; margin: 0 auto; padding: 1.6rem 1.2rem 3rem; display: grid; gap: 1.4rem; }
.hello { display: grid; gap: .9rem; padding: 1.6rem; border-radius: 20px; background: var(--surface); box-shadow: var(--shadow); }
.hello h1 { font-size: 2rem; }
.tabs { display: flex; gap: .3rem; border-bottom: 1px solid var(--line); }
.tabs button { background: none; border: 0; padding: .6rem .9rem; font: 500 .95rem var(--font); color: var(--muted); cursor: pointer; border-bottom: 3px solid transparent; margin-bottom: -1px; }
.tabs button[aria-selected=true] { color: var(--primary); border-bottom-color: var(--primary); }
.cards { display: grid; gap: .8rem; }
.tcard { background: var(--surface); border-radius: 16px; padding: 1rem 1.1rem; border: 1px solid var(--line); display: grid; gap: .6rem; cursor: pointer; text-align: start; font: inherit; color: inherit; width: 100%; }
.tcard:hover { border-color: var(--primary); }
.tcard.attention { border-color: var(--risk); box-shadow: inset 4px 0 0 var(--risk); }
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: .4rem; }
.steps span { font-size: .78rem; color: var(--muted); padding-top: .4rem; border-top: 4px solid var(--line); }
.steps span.on { color: var(--primary); border-top-color: var(--primary); font-weight: 600; }

/* ---------- new ticket ---------- */
.tiles { display: grid; gap: .6rem; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.tile { display: grid; gap: .4rem; justify-items: start; text-align: start; padding: .9rem; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font: inherit; color: var(--ink); }
.tile svg { width: 26px; height: 26px; color: var(--primary); }
.tile b { font-weight: 600; font-size: .95rem; }
.tile small { color: var(--muted); font-size: .78rem; line-height: 1.35; }
.tile[aria-pressed=true] { border-color: var(--primary); background: var(--primary-soft); box-shadow: 0 0 0 2px var(--primary); }
.urg { display: grid; gap: .5rem; }
.urg label { display: grid; grid-template-columns: auto 1fr auto; gap: .7rem; align-items: center; padding: .7rem .9rem; border-radius: 12px; border: 1px solid var(--line); cursor: pointer; }
.urg label:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.urg input { width: auto; accent-color: var(--primary); }
.urg .promise { font-size: .8rem; color: var(--muted); white-space: nowrap; }
.tip { padding: .8rem 1rem; border-radius: 12px; background: var(--surface-2); border-inline-start: 4px solid var(--primary); font-size: .9rem; }

/* ---------- rating ---------- */
.stars { display: flex; gap: .2rem; direction: ltr; justify-content: flex-end; }
.stars button { background: none; border: 0; font-size: 2rem; line-height: 1; cursor: pointer; color: var(--line); padding: .1rem; }
.stars button.on { color: #E3A008; }

/* ---------- admin ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: start; padding: .6rem .7rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-weight: 600; color: var(--muted); font-size: .82rem; }
tr.off td { color: var(--muted); }

/* ---------- toasts ---------- */
#toasts { position: fixed; bottom: max(1rem, env(safe-area-inset-bottom)); inset-inline-start: 50%; transform: translateX(50%); display: grid; gap: .5rem; z-index: 60; width: min(440px, calc(100% - 2rem)); }
.toast { padding: .8rem 1rem; border-radius: 12px; background: var(--ink); color: var(--bg); box-shadow: var(--shadow); font-weight: 500; }
.toast.bad { background: var(--bad); color: #fff; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .qrow { grid-template-columns: 3.6rem minmax(0, 1fr) 9.5rem; }
  .qrow .qcell.store, .qrow .qcell.assignee { display: none; }
}
@media (max-width: 820px) {
  .desk { grid-template-columns: 1fr; padding: .7rem; }
  .nav { position: static; display: flex; overflow-x: auto; gap: .3rem; padding-bottom: .2rem; }
  .nav button { width: auto; white-space: nowrap; background: var(--surface); }
  .nav hr, .pulse { display: none; }
  .board-head input[type=search] { width: 100%; }
  .qrow { grid-template-columns: 1fr; gap: .45rem; }
  .qrow .qid { font-size: .85rem; }
  .hello h1 { font-size: 1.6rem; }
  .topbar-in { padding: .55rem .8rem; }
  .who .name { display: none; }
}
textarea.note { background: var(--note); border-color: var(--note-line); }

/* Mobile-first ticket creation: full usable viewport and touch controls. */
.ticket-mobile { max-width:100%; }
.ticket-mobile .tile, .ticket-mobile .urg label { min-height:56px; }
.ticket-mobile button[type="submit"] { min-height:48px; }
@media (max-width: 650px) {
  dialog:has(.ticket-mobile) {
    position:fixed; inset:0; margin:0; padding:0; width:100%; max-width:100%;
    height:100dvh; max-height:100dvh; border:0; border-radius:0;
    overflow-y:auto; overscroll-behavior:contain;
    padding-top:env(safe-area-inset-top); padding-bottom:env(safe-area-inset-bottom);
  }
  dialog:has(.ticket-mobile) .ticket-mobile { padding:1rem .85rem 1.4rem; gap:.75rem; }
  .ticket-mobile h2 { font-size:1.45rem; margin:0; }
  .ticket-mobile h3 { font-size:1.08rem; margin:.3rem 0 0; }
  .ticket-mobile .tiles { grid-template-columns:repeat(2,minmax(0,1fr)); gap:.55rem; }
  .ticket-mobile .tile { padding:.75rem; min-height:104px; gap:.25rem; }
  .ticket-mobile .tile svg { width:24px; height:24px; }
  .ticket-mobile .tile b { font-size:.9rem; line-height:1.35; }
  .ticket-mobile .tile small { font-size:.75rem; }
  .ticket-mobile .urg label { grid-template-columns:auto minmax(0,1fr); gap:.5rem; }
  .ticket-mobile .urg .promise { grid-column:2; white-space:normal; }
  .ticket-mobile .form-grid { grid-template-columns:1fr; }
  .ticket-mobile input, .ticket-mobile textarea, .ticket-mobile select { font-size:16px; min-height:48px; }
  .ticket-mobile textarea { min-height:125px; }
  .ticket-mobile .form > .row:last-child { position:sticky; bottom:0; background:var(--surface); padding:.8rem 0 max(.65rem,env(safe-area-inset-bottom)); margin-bottom:-.5rem; border-top:1px solid var(--line); z-index:2; }
  .ticket-mobile .form > .row:last-child button { flex:1; min-height:50px; }
}

/* Mobile ticket detail: usable controls instead of a narrow desktop drawer. */
@media (max-width: 650px) {
  .drawer { width: 100vw; max-width: 100vw; inset-inline: 0; }
  .drawer-head { padding: .75rem .85rem; }
  .drawer-body { padding: .8rem .7rem 5rem; }
  .drawer .panel { padding: .8rem; }
  .drawer .controls { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .drawer .controls .field { min-width: 0; }
  .drawer .composer .row { flex-wrap: wrap; }
  .drawer .composer button, .drawer .panel > div > button { min-height: 44px; }
  .drawer .composer input[type=file] { font-size: 16px; }
}

.store-multi-list { max-height: 260px; overflow-y: auto; padding: .65rem; border: 1px solid var(--line); border-radius: 12px; display: grid; gap: .35rem; }
.store-multi-list .check { padding: .35rem; }

/* Touch-first organizational service selection */
.service-choices { display:grid; grid-template-columns:repeat(auto-fit,minmax(145px,1fr));gap:.55rem; }
.service-choice { min-height:48px; padding:.7rem .8rem; border:1px solid var(--line);border-radius:12px;background:var(--surface);color:var(--ink);font:inherit;text-align:right;cursor:pointer; }
.service-choice[aria-pressed="true"] { border:2px solid #087c74;background:#e7f6f3;font-weight:700; }
@media(max-width:650px) {.service-choices {grid-template-columns:repeat(2,minmax(0,1fr));}}

.service-choices.service-missing { outline: 2px solid #d32f2f; border-radius: 8px; padding: 8px; background: #fff6f6; }

/* Ticket details use the main application workspace, never a floating overlay. */
[hidden] { display:none !important; }
.ticket-page {
  width: min(1420px, 100%);
  margin: 0 auto;
  background: var(--bg);
  min-height: calc(100dvh - 66px);
  display: flex;
  flex-direction: column;
}
.ticket-page .drawer-head {
  position: sticky;
  top: 56px;
  z-index: 5;
  border: 1px solid var(--line);
  border-radius: 0 0 16px 16px;
  padding: 1.1rem clamp(1rem,3vw,2.5rem);
}
.ticket-page .drawer-body {
  overflow: visible;
  flex: none;
  width: 100%;
  padding: 1.5rem clamp(1rem,3vw,2.5rem) 3rem;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.25rem;
}
.ticket-page .panel { max-width: 100%; }
.ticket-page .drawer-head .row { flex-wrap: wrap; }
@media(max-width:700px) {
  .ticket-page .drawer-head { position:static; border-radius:0; }
  .ticket-page .drawer-body { padding:1rem .7rem 2rem; }
}

/* Administration is a full page, rather than a floating dialog. */
.admin-page { width:min(1450px,100%); margin:0 auto; padding:clamp(1rem,2.5vw,2.5rem); display:grid; gap:1.5rem; min-height:calc(100dvh - 65px); align-content:start; }
.admin-page-header { align-items:center; border-bottom:1px solid var(--line); padding-bottom:1rem; }
.admin-page-header h1 { font-size:clamp(1.4rem,2.4vw,2rem); margin:0; }
.admin-page > .tabs { display:flex; flex-wrap:wrap; gap:.35rem; }
.admin-page > .form { width:100%; min-width:0; }
.admin-page .panel { max-width:100%; min-width:0; }
@media(max-width:700px){.admin-page {padding:.75rem;}.admin-page > .tabs {overflow-x:auto; flex-wrap:nowrap;}.admin-page > .tabs button {white-space:nowrap;}}

/* Keep the uploaded brand artwork in a compact preview in Admin. */
.admin-page .branding-logo-preview {
  display: block;
  width: auto !important;
  height: auto !important;
  max-width: 180px !important;
  max-height: 110px !important;
  object-fit: contain !important;
  justify-self: start;
  border-radius: 8px;
}

/* Clickable service KPI cards by department */
.department-metric-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(230px,1fr));gap:1rem}
.department-metric-card{display:flex;flex-direction:column;align-items:stretch;gap:.45rem;padding:1.1rem 1.25rem;border:1px solid var(--line);border-radius:16px;background:var(--surface);color:var(--ink);text-align:start;font:inherit;cursor:pointer;min-width:0;transition:border-color .15s,box-shadow .15s,transform .15s}
.department-metric-card:hover,.department-metric-card:focus-visible{border-color:var(--primary);box-shadow:var(--shadow);transform:translateY(-1px)}
.department-metric-card[aria-pressed="true"]{outline:2px solid var(--primary);outline-offset:1px;background:var(--primary-soft)}
.department-metric-name{font-weight:650;font-size:1rem}
.department-metric-total{font-size:2rem;font-weight:750;line-height:1.15}
.department-metric-split{font-weight:600;font-size:.91rem}
.department-metric-detail{display:grid;gap:1rem;padding:1.25rem;border:1px solid var(--line);border-radius:16px;background:var(--surface)}
@media(max-width:600px){.department-metric-grid{grid-template-columns:repeat(1,minmax(0,1fr))}}

/* Responsive administration and metrics: prevent desktop-width content shrinking mobile viewport. */
html,body,#root{max-width:100%;min-width:0;overflow-x:clip}
@media(max-width:700px){
  .topbar-in{display:flex;flex-wrap:wrap;gap:.45rem;padding:.55rem .65rem}
  .topbar-in .logo{flex:1 1 calc(100% - 65px);min-width:0;font-size:1rem;line-height:1.3}
  .topbar-in .logo span{min-width:0;overflow-wrap:anywhere}
  .topbar-in .logo img{flex:none;width:27px;height:27px}
  .topbar-in .who{margin-inline-start:auto;flex:0 0 auto}
  .topbar-in > .btn{flex:1 1 auto;min-height:40px;white-space:normal;font-size:.85rem}
  .admin-page{width:100%;min-width:0;padding:.75rem .65rem;gap:1rem}
  .admin-page-header{min-width:0;padding-bottom:.6rem}
  .admin-page-header h1{font-size:1.5rem}
  .admin-page > .tabs,.admin-page .tabs{max-width:100%;min-width:0;overflow-x:auto;overscroll-behavior-x:contain;scrollbar-width:thin}
  .admin-page .tabs button{flex:none;white-space:nowrap;min-height:43px}
  .admin-page > .form,.admin-page .form,.admin-page .panel,.admin-page .row{min-width:0;max-width:100%}
  .admin-page .form-grid{grid-template-columns:minmax(0,1fr)}
  .admin-page .form-grid > *{min-width:0;max-width:100%}
  .admin-page .table-wrap{width:100%;max-width:100%;overflow-x:auto;-webkit-overflow-scrolling:touch}
  .admin-page .table-wrap table{width:max-content;min-width:100%;font-size:.86rem}
  .admin-page .table-wrap th,.admin-page .table-wrap td{white-space:nowrap;padding:.55rem .65rem}
  .department-metric-grid{grid-template-columns:minmax(0,1fr);gap:.7rem}
  .department-metric-card{padding:1rem;min-width:0}
  .department-metric-total{font-size:2.1rem}
  .department-metric-detail{min-width:0;padding:.8rem}
  .admin-page .form-grid .panel{padding:1rem}
}
@media(min-width:701px) and (max-width:1020px){
 .topbar-in{flex-wrap:wrap}
 .topbar-in .logo{flex:1 1 100%}
 .admin-page .form-grid{grid-template-columns:repeat(2,minmax(0,1fr))}
}

/* Mobile width containment: grid's implicit auto track formerly expanded to desktop content width. */
@media(max-width:700px){
  html{width:100%;overflow-x:hidden}
  body,#root{width:100%;max-width:100vw;overflow-x:hidden}
  .topbar,.topbar-in{width:100%;max-width:100vw;min-width:0}
  .topbar-in{box-sizing:border-box;justify-content:flex-start}
  .topbar-in .logo{flex:1 1 100%;max-width:100%;width:100%}
  .topbar-in > .btn{flex:0 1 auto;max-width:100%;font-size:.8rem;padding:.45rem .5rem}
  .topbar-in .who{margin-inline-start:0}
  .admin-page,.ticket-page{grid-template-columns:minmax(0,1fr);max-width:100%;overflow:hidden}
  .admin-page > *, .admin-page .form > *, .admin-page .panel > *{min-width:0;max-width:100%}
  .admin-page .form,.admin-page .form-grid,.admin-page .department-metric-grid,.admin-page .department-metric-detail{grid-template-columns:minmax(0,1fr);width:100%;min-width:0}
  .admin-page > .tabs,.admin-page .tabs{width:100%;max-width:100%;overflow-x:auto;overflow-y:hidden}
  .admin-page .table-wrap{display:block;overflow-x:auto;max-width:100%}
  .admin-page .department-metric-card{width:100%;max-width:100%}
}

/* Dedicated mobile service-metrics layout: isolate intrinsically wide tables from cards. */
.service-metrics-content{min-width:0;width:100%;max-width:100%;overflow:visible}
.service-metric-summary{min-width:0;width:100%}
.service-metric-summary>.service-metric-tile{min-width:0;width:100%;overflow-wrap:anywhere}
.service-metrics-table-scroll{min-width:0;width:100%;max-width:100%;overflow-x:auto;overflow-y:hidden;-webkit-overflow-scrolling:touch;direction:rtl}
.service-metrics-table-scroll table{width:max-content;min-width:100%;table-layout:auto}
@media(max-width:700px){
  .admin-page{display:block!important;width:100%!important;max-width:100%!important;overflow:visible!important}
  .admin-page>.admin-page-header,.admin-page>.tabs,.admin-page>.form{margin-bottom:1rem}
  .admin-page .service-metrics-content{display:flex!important;flex-direction:column!important;align-items:stretch!important;gap:.9rem!important;overflow:visible!important}
  .admin-page .service-metrics-content>*{min-width:0!important;width:100%!important;max-width:100%!important}
  .admin-page .service-metric-summary{display:grid!important;grid-template-columns:minmax(0,1fr)!important;gap:.7rem!important}
  .admin-page .service-metric-summary>.service-metric-tile{grid-column:1!important;max-width:100%!important}
  .admin-page .department-metric-grid{display:grid!important;grid-template-columns:minmax(0,1fr)!important}
  .admin-page .service-metrics-table-scroll{display:block!important;max-width:calc(100vw - 1.3rem)!important;overflow-x:auto!important}
  .admin-page .service-metrics-table-scroll table{min-width:600px;width:max-content!important}
}

/* Main ticket desk: truly viewport-bound layout on narrow mobile screens. */
@media(max-width:820px){
  #root>div,.desk{min-width:0;max-width:100%;width:100%}
  .desk{display:grid;grid-template-columns:minmax(0,1fr)!important;gap:.65rem;padding:.6rem}
  .desk>*{min-width:0;max-width:100%;width:100%}
  .desk .nav{display:flex;min-width:0;max-width:100%;width:100%;overflow-x:auto;overflow-y:hidden;white-space:nowrap;scrollbar-width:thin;-webkit-overflow-scrolling:touch}
  .desk .nav button{flex:0 0 auto;min-width:max-content;width:auto}
  .desk .board{min-width:0;max-width:100%;width:100%;overflow:hidden}
  .desk .board-head{display:grid;grid-template-columns:minmax(0,1fr);gap:.65rem;padding:.8rem}
  .desk .board-head>*{min-width:0;max-width:100%;width:100%;margin-inline:0}
  .desk .board-head input,.desk .board-head select{width:100%;min-width:0}
  .desk .board-head .row{display:flex;flex-wrap:wrap;width:100%;min-width:0}
  .desk .board-head .row>*{min-width:0;max-width:100%}
  .desk .queue,.desk .qrow{min-width:0;max-width:100%;width:100%}
  .desk .qrow{display:grid;grid-template-columns:minmax(0,1fr)!important;gap:.4rem;padding:.8rem .7rem}
  .desk .qrow>*{min-width:0;max-width:100%}
  .desk .qrow .qcell{white-space:normal;overflow-wrap:anywhere;text-overflow:clip}
  .desk .qrow .row{min-width:0;max-width:100%;flex-wrap:wrap}
  .desk .qrow .chip{max-width:100%;white-space:normal;overflow-wrap:anywhere}
  .desk .qrow .fuse{min-width:0;max-width:100%;width:100%}
}

/* Compact ticket filters: full controls on desktop, collapsible on phones. */
.desk-extra-filters,.desk-filter-actions{display:contents}
.desk-filter-toggle{display:none}
@media(max-width:820px){
  .desk .board-head{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:.55rem;padding:.75rem}
  .desk .board-head h2{grid-column:1/-1;margin:0;font-size:1.45rem}
  .desk .board-head>input[type=search]{grid-column:1/-1;min-height:44px}
  .desk .desk-filter-actions{display:flex;grid-column:1/-1;align-items:center;gap:.5rem;width:100%}
  .desk .desk-filter-actions>.btn{width:auto;min-height:40px;flex:0 0 auto}
  .desk .desk-filter-toggle{display:inline-flex}
  .desk .desk-extra-filters{display:none;grid-column:1/-1;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:.5rem;width:100%;min-width:0}
  .desk .desk-extra-filters.mobile-expanded{display:grid}
  .desk .desk-extra-filters>select{width:100%;min-width:0;font-size:.86rem;min-height:42px}
  .desk .desk-extra-filters>.btn{grid-column:1/-1;width:auto;justify-self:start}
}
@media(max-width:390px){
  .desk .desk-extra-filters{grid-template-columns:minmax(0,1fr)}
}

/* Requester/store mobile dashboard — isolated from staff desk layout. */
@media(max-width:820px){
  .home{display:grid;grid-template-columns:minmax(0,1fr);width:100%;max-width:100%;min-width:0;margin:0;padding:.75rem .65rem 2rem;gap:1rem}
  .home>*{min-width:0;max-width:100%;width:100%}
  .home .hello{min-width:0;max-width:100%;padding:1rem .9rem;border-radius:16px;overflow-wrap:anywhere}
  .home .hello h1{font-size:clamp(1.35rem,5vw,1.8rem);line-height:1.3;margin:0;overflow-wrap:anywhere}
  .home .hello p{font-size:.95rem;line-height:1.55;margin:.4rem 0}
  .home .hello .btn.big{width:100%;max-width:100%;min-height:48px;font-size:1rem}
  .home>.row{display:flex;flex-wrap:wrap;gap:.6rem;min-width:0;align-items:center}
  .home>.row .tabs{max-width:100%;min-width:0;flex:1 1 100%;overflow-x:auto;white-space:nowrap}
  .home>.row .tabs button{white-space:nowrap;flex-shrink:0}
  .home>.row input[type=search]{flex:1 1 100%;width:100%;min-width:0}
  .home .cards,.home .tcard{width:100%;max-width:100%;min-width:0}
  .home .tcard{overflow-wrap:anywhere}
  .topbar{overflow:visible}
  .topbar-in{overflow:visible}
  .topbar .who,.topbar .menu{position:relative}
  .topbar .menu-list{position:absolute;inset-inline-end:0;inset-inline-start:auto;max-width:calc(100vw - 1rem);width:max-content;min-width:min(220px,calc(100vw - 1rem));top:calc(100% + 4px);z-index:100}
}

/* User-menu alignment in RTL: logical inline-end anchored the popup outside right viewport. */
.topbar .who .menu .menu-list{
  position:absolute;
  right:0!important;
  left:auto!important;
  inset-inline-start:auto!important;
  inset-inline-end:auto!important;
  width:220px;
  min-width:0!important;
  max-width:calc(100vw - 20px)!important;
  box-sizing:border-box;
  direction:rtl;
  z-index:101;
  overflow-wrap:anywhere;
}
.topbar .who .menu .menu-list[hidden],.topbar .who .menu .menu-list.hidden{display:none!important}
.topbar .who .menu .menu-list button{width:100%;text-align:right;white-space:normal}

/* Admin avatar sits at the opposite edge from requester; clamp menu to viewport via click handler. */
@media(max-width:820px){
 .topbar .who .menu .menu-list.admin-user-menu{
   position:fixed!important;
   right:auto!important;
   inset-inline-start:auto!important;
   inset-inline-end:auto!important;
   width:min(230px,calc(100vw - 20px))!important;
   max-height:calc(100dvh - 95px);
   overflow-y:auto;
 }
}

/* New ticket dialog close button: external CSS is required by the site's CSP. */
.ticket-dialog-wrap { position:relative; }
.ticket-dialog-wrap > .ticket-dialog-title { margin:0; padding-left:52px; }
.ticket-dialog-wrap > .ticket-dialog-close {
  position:absolute; top:12px; left:12px; right:auto;
  width:38px; min-width:38px; max-width:38px; height:38px;
  padding:0; border:1px solid #cdd8d5; border-radius:9px;
  background:#fff; color:#263c38;
  font-size:25px; line-height:1; cursor:pointer;
  display:flex; align-items:center; justify-content:center;
  z-index:10; justify-self:start; align-self:start;
}
.ticket-dialog-wrap > .ticket-dialog-close:hover { background:#eef5f3; }
.ticket-dialog-wrap > .ticket-dialog-close:focus-visible { outline:3px solid #147c70; outline-offset:2px; }

/* Readability enhancements for administration and BI screens. */
.admin-page h1,.admin-page h2,.admin-page h3,
.service-metrics-content h3 { font-weight:700; letter-spacing:0; }
.admin-page .table-wrap table,.service-metrics-content table {
  font-size:15px; line-height:1.55;
}
.admin-page .table-wrap th,.service-metrics-content th {
  font-size:14.5px; font-weight:700; color:var(--ink);
  white-space:nowrap; padding:12px 14px;
}
.admin-page .table-wrap td,.service-metrics-content td {
  color:var(--ink); padding:11px 14px; vertical-align:middle;
}
.admin-page .table-wrap tbody tr:hover,.service-metrics-content tbody tr:hover {
  background:var(--surface-2);
}
.admin-page .field-title,.admin-page label,
.service-metrics-content .field-title { line-height:1.5; }
.admin-page input,.admin-page select,.admin-page textarea {
  font-size:15px;
}
.admin-page .small.muted,.service-metrics-content .small.muted {
  font-size:13px; line-height:1.5;
}
@media (max-width:700px){
  .admin-page .table-wrap th,.admin-page .table-wrap td { padding:10px; }
}

/* Opt-in browser password saving on the login screen */
.auth-remember{display:flex;align-items:center;gap:.6rem;cursor:pointer;font-weight:500;margin:.35rem 0 0}
.auth-remember input[type=checkbox]{width:18px;height:18px;flex:none;accent-color:var(--primary);margin:0}
.auth-remember+ .small{margin:.1rem 0 .35rem;font-size:.82rem;line-height:1.5}

/* Private staff discussion - distinct from the requester-visible channel */
.ticket-channel-tabs{display:flex;gap:8px;flex-wrap:wrap;margin:14px 0 10px;padding:5px;border:1px solid var(--line);border-radius:12px;background:var(--surface-2)}
.ticket-channel-tabs .btn{flex:1;min-width:180px}
.ticket-channel-tabs [aria-pressed="true"]{background:var(--primary-soft);border:1px solid var(--primary);color:var(--primary)}
.ticket-channel-tabs [aria-pressed="false"]{background:transparent;border:1px solid transparent;color:var(--muted)}
.ticket-internal-channel.hidden,.ticket-public-channel.hidden{display:none!important}
.internal-discussion{border:1px solid var(--primary);background:var(--surface)}
.internal-discussion .internal-participants{display:flex;gap:8px;flex-wrap:wrap;align-items:center;margin:10px 0}
.internal-person{display:inline-flex;gap:5px;align-items:center;padding:5px 10px;border-radius:99px;border:1px solid var(--line);background:var(--primary-soft);font-size:.86rem}
.internal-person .btn{min-height:22px;padding:0 5px}
.internal-invite-row{display:grid;grid-template-columns:minmax(180px,2fr) minmax(120px,1fr) auto;gap:8px;margin:12px 0}
.internal-invite-row select{min-width:0}
.internal-message-list{display:grid;gap:10px;margin:14px 0}
.internal-message{padding:13px;border:1px solid var(--line);background:var(--surface-2);border-radius:10px;overflow-wrap:anywhere}
.internal-message .msg-body{white-space:pre-wrap}
.internal-inbox-entry{display:flex;justify-content:flex-start;text-align:right;margin:4px 0;width:100%;white-space:normal}
.internal-inbox{max-height:75vh;overflow:auto}
@media(max-width:640px){.ticket-channel-tabs .btn{min-width:0;font-size:.88rem}.internal-invite-row{grid-template-columns:1fr}.internal-discussion{padding:12px}}

.internal-invite-panel{padding:13px;border:1px solid var(--line);border-radius:12px;background:var(--surface-2);display:grid;gap:10px}
.internal-person-picker{background:var(--surface);border:1px solid var(--line);border-radius:10px;max-height:180px;overflow:auto;padding:7px;display:grid;gap:4px}
.internal-person-option{padding:7px 9px;cursor:pointer;border-radius:8px;font-size:.9rem}
.internal-person-option:hover{background:var(--primary-soft)}
.internal-person-option input{width:16px;height:16px;accent-color:var(--primary);margin-inline-end:6px}
.internal-invite-panel .internal-invite-row{display:flex;gap:8px;align-items:center;flex-wrap:wrap;margin:0}
.internal-invite-panel .internal-invite-row select{flex:1;min-width:180px}
.internal-alert-count{display:inline-flex;min-width:22px;height:22px;border-radius:99px;align-items:center;justify-content:center;padding:0 5px;background:var(--primary-soft);color:var(--primary);font-size:.75rem;font-weight:700}
.internal-alert-count.hidden{display:none!important}

/* Internal discussions dialog: safe, reachable close control on mobile and desktop */
dialog.internal-inbox-dialog{
  box-sizing:border-box;
  width:min(880px,calc(100% - 1rem))!important;
  max-width:calc(100% - 1rem);
  max-height:calc(100dvh - 1rem);
  margin:auto;
  padding:0;
  overflow:hidden;
  border-radius:16px;
}
.internal-inbox-shell{
  display:flex;
  flex-direction:column;
  min-height:0;
  max-height:calc(100dvh - 1rem);
  background:var(--surface);
}
.internal-inbox-toolbar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  flex:none;
  padding:12px 16px;
  border-bottom:1px solid var(--line);
  background:var(--surface);
}
.internal-inbox-close{flex:none;white-space:nowrap}
.internal-inbox-shell>.internal-inbox{
  flex:1;
  min-height:0;
  max-height:none;
  overflow-y:auto;
  overscroll-behavior:contain;
  padding:16px;
}
@media(max-width:640px){
  dialog.internal-inbox-dialog{
    width:calc(100% - 12px)!important;
    max-width:calc(100% - 12px);
    max-height:calc(100dvh - 12px);
  }
  .internal-inbox-shell{max-height:calc(100dvh - 12px)}
  .internal-inbox-toolbar{padding:10px 12px}
  .internal-inbox-shell>.internal-inbox{padding:12px}
}
