Browse Source

feat(web): 改造代客建单对话框与客户搜索

sy 2 days ago
parent
commit
73d3317ef4

+ 180 - 59
web-scaffold/src/pages/WorkOrderManagementPage.tsx

@@ -1,18 +1,19 @@
 import { detailLinkState } from "../lib/detail-navigation";
+import { isImeComposing } from "../lib/ime";
 import { PageIntro } from "../components/PageIntro";
-import { OpsNotice } from "../components/OperationsKit";
+import { OpsDialog, OpsNotice } from "../components/OperationsKit";
 import { FilterSelect } from "../components/ui/filter-select";
 import { DateRangeFilter } from "../components/ui/date-range-filter";
 import { TicketState } from "../components/ticketState";
 import { WorkOrderLedgerList } from "../components/work-order/WorkOrderLedgerList";
-import { useEffect, useRef, useState, type FormEvent, type ReactNode } from "react";
+import { useEffect, useId, useRef, useState, type FormEvent, type KeyboardEvent } from "react";
 import {
-  ArrowRight, Check, ClipboardCheck, ClipboardList, Clock3, Inbox, Info, Plus, Search, X,
+  ArrowRight, ChevronDown, ClipboardCheck, ClipboardList, Clock3, Headphones, Inbox, Plus, Search, Wrench, X,
 } from "lucide-react";
 import { Button } from "../components/ui/button";
 import { Input } from "../components/ui/input";
 import { SearchInput } from "../components/ui/search-input";
-import { FieldHint } from "../components/ui/field-hint";
+import { FieldLabel } from "../components/ui/field-label";
 import { Link, useLocation, useNavigate, useSearchParams } from "react-router";
 import { customerGetList, orderGetList, rowsOf } from "../lib/api/bos";
 import {
@@ -41,23 +42,6 @@ const TAB_ORDER = ["unassigned", "pending", "processing", "completed", "rejected
  */
 const COMPLETED_SCOPE_HINT = "同一状态码 completed,两类都不是终态:主线=已完成待确认(等运营商回执);故障/售后=已处理待确认(等提交方确认)";
 
-function Drawer({ title, subtitle, onClose, children }: { title: string; subtitle: string; onClose: () => void; children: ReactNode }) {
-  const ref = useRef<HTMLDialogElement>(null);
-  useEffect(() => {
-    const dialog = ref.current;
-    if (!dialog) return;
-    const previous = document.activeElement as HTMLElement | null;
-    const overflow = document.body.style.overflow;
-    document.body.style.overflow = "hidden";
-    dialog.showModal();
-    return () => { dialog.close(); document.body.style.overflow = overflow; previous?.focus(); };
-  }, []);
-  return <dialog ref={ref} className="work-order-drawer" aria-labelledby="work-order-drawer-title" onCancel={onClose} onClick={(event) => { if (event.target === event.currentTarget) onClose(); }}>
-    <header><div><p>{subtitle}</p><h2 id="work-order-drawer-title">{title}</h2></div><Button variant="ghost" size="icon" aria-label="关闭抽屉" onClick={onClose}><X size={19} /></Button></header>
-    {children}
-  </dialog>;
-}
-
 /**
  * 代客建单(`/ticket/create@v1`)。
  *
@@ -65,79 +49,210 @@ function Drawer({ title, subtitle, onClose, children }: { title: string; subtitl
  * 手输别人的客户只会拿到 `11104`)。建单口只收故障/售后两类(create.rs `CREATE_TYPES`),
  * 开户/到期停机/服务开通由对应业务动作生成,在此提交会被服务端拒。
  */
-const CREATABLE: ["fault" | "after_sale", string][] = [["fault", "故障报修"], ["after_sale", "售后服务"]];
+const CREATABLE = [
+  { code: "fault", label: "故障报修", Icon: Wrench },
+  { code: "after_sale", label: "售后服务", Icon: Headphones },
+] as const;
+
+type TicketCustomer = { customer_id: string; customer_name: string | null };
+type TicketLookupState = "loading" | "ready" | "error";
 
-function Editor({ onClose, onCreated }: { onClose: () => void; onCreated: (message: string) => void }) {
+function TicketCreateDialog({ onClose, onCreated }: { onClose: () => void; onCreated: (message: string) => void }) {
+  const id = useId();
+  const searchInput = useRef<HTMLInputElement>(null);
+  const customerList = useRef<HTMLUListElement>(null);
   const submit = useSubmit();
-  const [ticketType, setTicketType] = useState<"fault" | "after_sale">("fault");
+  const [ticketType, setTicketType] = useState<(typeof CREATABLE)[number]["code"]>("fault");
   const [keyword, setKeyword] = useState("");
-  const [customerId, setCustomerId] = useState("");
+  const [customer, setCustomer] = useState<TicketCustomer | null>(null);
   const [orderId, setOrderId] = useState("");
   const [title, setTitle] = useState("");
   const [detail, setDetail] = useState("");
-  const [customers, setCustomers] = useState<{ customer_id: string; customer_name: string | null }[]>([]);
+  const [customers, setCustomers] = useState<TicketCustomer[]>([]);
+  const [customerLookup, setCustomerLookup] = useState<TicketLookupState>("loading");
+  const [customerOpen, setCustomerOpen] = useState(false);
+  const [activeCustomer, setActiveCustomer] = useState(0);
   const [orders, setSubs] = useState<{ subscription_id: string; plan_name: string | null; contract_no: string | null }[]>([]);
-  const [tip, setTip] = useState("");
+  const [subscriptionLookup, setSubscriptionLookup] = useState<TicketLookupState>("loading");
+  const [invalid, setInvalid] = useState<"customer" | "title" | null>(null);
 
-  function pickCustomer(id: string) { setCustomerId(id); setOrderId(""); }
+  const customerId = customer?.customer_id ?? "";
+  const customerOptionListId = `${id}-customer-options`;
+  const customerHints = { loading: "正在查找客户…", error: "客户读取失败,请重新搜索", ready: "没有找到客户" };
+  const subscriptionHints = { loading: "正在读取订阅…", error: "订阅读取失败", ready: orders.length ? "不关联订阅" : "该客户暂无订阅" };
+
+  function pickCustomer(next: TicketCustomer | null) {
+    setCustomer(next);
+    setCustomerOpen(!next);
+    setOrderId("");
+    setSubs([]);
+    setSubscriptionLookup("loading");
+    if (invalid === "customer") setInvalid(null);
+  }
+
+  function searchCustomers(value: string) {
+    setCustomerOpen(true);
+    setActiveCustomer(0);
+    if (value === keyword) return;
+    setKeyword(value);
+    setCustomers([]);
+    setCustomerLookup("loading");
+  }
+
+  function handleCustomerKeys(event: KeyboardEvent<HTMLInputElement>) {
+    if (customer || isImeComposing(event)) return;
+    if (event.key === "ArrowDown" || event.key === "ArrowUp") {
+      event.preventDefault();
+      setCustomerOpen(true);
+      if (!customers.length) return;
+      const step = event.key === "ArrowDown" ? 1 : -1;
+      const next = customerOpen
+        ? (activeCustomer + step + customers.length) % customers.length
+        : step === 1 ? 0 : customers.length - 1;
+      setActiveCustomer(next);
+      customerList.current?.children[next]?.scrollIntoView({ block: "nearest" });
+    } else if (customerOpen && event.key === "Enter") {
+      event.preventDefault();
+      const next = customers[activeCustomer];
+      if (next) pickCustomer(next);
+    } else if (customerOpen && event.key === "Escape") {
+      event.preventDefault();
+      event.stopPropagation();
+      setCustomerOpen(false);
+    }
+  }
+
+  useEffect(() => { searchInput.current?.focus({ preventScroll: true }); }, []);
 
   useEffect(() => {
     let alive = true;
     const timer = window.setTimeout(async () => {
       try {
         const r = await customerGetList({ page: 0, page_size: 20, keyword: keyword.trim() || undefined });
-        if (alive) setCustomers(rowsOf(r).map((c) => ({ customer_id: c.customer_id, customer_name: c.customer_name })));
-      } catch { if (alive) setCustomers([]); }
+        if (!alive) return;
+        setCustomers(rowsOf(r));
+        setCustomerLookup("ready");
+      } catch {
+        if (!alive) return;
+        setCustomers([]);
+        setCustomerLookup("error");
+      }
     }, 300);
     return () => { alive = false; window.clearTimeout(timer); };
   }, [keyword]);
 
   useEffect(() => {
-    if (!customerId) { setSubs([]); return; }
+    if (!customerId) return;
     let alive = true;
     fetchAllPages((page, page_size) => orderGetList({ customer_id: customerId, page, page_size }), { pageSize: LIST_PAGE_SIZE })
-      .then((r) => { if (alive) setSubs(rowsOf(r.items).map((s) => ({ subscription_id: s.subscription_id, plan_name: s.plan_name, contract_no: s.contract_no ?? null }))); })
-      .catch(() => { if (alive) setSubs([]); });
+      .then((r) => {
+        if (!alive) return;
+        setSubs(r.items.map((s) => ({ subscription_id: s.subscription_id, plan_name: s.plan_name, contract_no: s.contract_no ?? null })));
+        setSubscriptionLookup("ready");
+      })
+      .catch(() => { if (alive) setSubscriptionLookup("error"); });
     return () => { alive = false; };
   }, [customerId]);
 
   async function submitForm(event: FormEvent<HTMLFormElement>) {
     event.preventDefault();
-    setTip("");
-    if (!customerId) { setTip("请选择归属客户。"); return; }
-    if (title.trim().length < 2) { setTip("请填写事项标题(≥2 字)。"); return; }
-    const ok = await submit.run(() => ticketCreate({
+    if (submit.busy) return;
+    submit.clear();
+    if (!customerId) {
+      setInvalid("customer");
+      searchInput.current?.focus();
+      return;
+    }
+    if (title.trim().length < 2) { setInvalid("title"); return; }
+    setInvalid(null);
+    await submit.run(() => ticketCreate({
       ticket_type: ticketType,
       customer_id: customerId,
       title: title.trim(),
       detail: detail.trim() || undefined,
       subscription_id: orderId || undefined,
     }).then((r) => onCreated(`工单 ${r.ticket_no} 已创建。`)));
-    if (ok) return;
   }
   const failure = submit.error ? classifyTicketError(submit.error) : null;
+  const error = invalid === "customer" ? "请选择归属客户。" : invalid === "title" ? "事项标题至少填写 2 个字。" : failure?.message;
 
-  return <Drawer title="新建工单" subtitle="工单与任务 / 代客建单" onClose={onClose}>
-    <form className="work-order-editor" onSubmit={submitForm}>
-      <p className="work-order-editor-note"><Info size={17} />此处受理故障报修/售后服务。开户、到期停机、服务开通由对应业务动作生成工单,不得在此独立新建。</p>
-      <section><h3><span>01</span>事项类型</h3><div className="work-order-form-grid"><label>工单类型 <em>*</em><select value={ticketType} onChange={(event) => setTicketType(event.target.value as "fault" | "after_sale")}>{CREATABLE.map(([code, name]) => <option key={code} value={code}>{name}</option>)}</select></label></div></section>
-      <section><h3><span>02</span>归属客户与订阅</h3>
-        <div className="work-order-form-grid">
-          <label>客户检索<Input autoFocus maxLength={50} placeholder="输入客户名称或编号" value={keyword} onChange={(event) => setKeyword(event.target.value)} /></label>
-          <label>归属客户 <em>*</em><FieldHint label="归属客户说明">候选只含当前身份可见的客户;订阅随客户联动。</FieldHint><select value={customerId} onChange={(event) => pickCustomer(event.target.value)}><option value="">请选择</option>{customers.map((c) => <option key={c.customer_id} value={c.customer_id}>{c.customer_name ?? c.customer_id}</option>)}</select></label>
-          <label className="wide">关联订阅 <FieldHint label="关联订阅说明">不关联=通用故障/售后;选择订阅后工单会挂到该订阅,便于按订阅追溯处理。</FieldHint><select value={orderId} onChange={(event) => setOrderId(event.target.value)}><option value="">不关联</option>{orders.map((s) => <option key={s.subscription_id} value={s.subscription_id}>{s.plan_name ?? s.subscription_id}{s.contract_no ? ` · ${s.contract_no}` : ""}</option>)}</select></label>
+  return <OpsDialog title="代客建单" className="ticket-create-dialog" onClose={onClose}>
+    <form onSubmit={submitForm} aria-busy={submit.busy}>
+      <div className="ticket-create-body">
+        <section className="ticket-create-section" aria-label="客户与订阅">
+          <div className="ticket-create-customer-fields">
+            <div className="ticket-create-field" onBlur={(event) => {
+              if (!event.currentTarget.contains(event.relatedTarget)) setCustomerOpen(false);
+            }}>
+              <label htmlFor={`${id}-customer`} className="field-label-title">归属客户<em aria-hidden="true">*</em></label>
+              <div className="ticket-create-search">
+                <Search size={16} aria-hidden="true" className="ticket-create-search-icon" />
+                <Input id={`${id}-customer`} ref={searchInput} role="combobox" autoComplete="off" maxLength={50}
+                  aria-autocomplete="list" aria-expanded={customerOpen} aria-controls={customerOpen ? customerOptionListId : undefined}
+                  aria-activedescendant={customerOpen && customers[activeCustomer] ? `${customerOptionListId}-${activeCustomer}` : undefined}
+                  aria-required="true" aria-invalid={invalid === "customer" || undefined} aria-describedby={invalid === "customer" ? `${id}-error` : undefined}
+                  placeholder="输入客户名称或编号" value={customer?.customer_name || customerId || keyword} readOnly={Boolean(customer)}
+                  onChange={(event) => searchCustomers(event.target.value)} onKeyDown={handleCustomerKeys}
+                  onClick={() => { if (!customer) setCustomerOpen(true); }} />
+                {customer ? <button type="button" className="ticket-create-search-clear" aria-label="清除归属客户" onClick={() => {
+                  pickCustomer(null);
+                  searchCustomers("");
+                  searchInput.current?.focus();
+                }}><X size={15} aria-hidden="true" /></button> : <ChevronDown size={15} aria-hidden="true" className="ticket-create-search-chevron" />}
+                {customerOpen && <div className="ticket-create-customer-popup">
+                  <ul ref={customerList} id={customerOptionListId} role="listbox" aria-label="客户搜索结果">
+                    {customers.map((item, index) => <li key={item.customer_id} id={`${customerOptionListId}-${index}`} role="option"
+                      aria-selected={index === activeCustomer} onMouseEnter={() => setActiveCustomer(index)}
+                      onMouseDown={(event) => event.preventDefault()} onClick={() => pickCustomer(item)}>
+                      <span>{item.customer_name || item.customer_id}</span>
+                      {item.customer_name && <small>{item.customer_id}</small>}
+                    </li>)}
+                  </ul>
+                  {!customers.length && <p role="status">{customerHints[customerLookup]}</p>}
+                </div>}
+              </div>
+            </div>
+            <FieldLabel className="ticket-create-field" label="关联订阅">
+              <select className="ticket-create-control" value={orderId} data-placeholder={!orderId || undefined}
+                disabled={!customerId || subscriptionLookup !== "ready" || orders.length === 0} onChange={(event) => setOrderId(event.target.value)}>
+                <option value="">{customerId ? subscriptionHints[subscriptionLookup] : "请先选择归属客户"}</option>
+                {orders.map((order) => <option key={order.subscription_id} value={order.subscription_id}>{order.plan_name ?? order.subscription_id}{order.contract_no ? ` · ${order.contract_no}` : ""}</option>)}
+              </select>
+            </FieldLabel>
+          </div>
+        </section>
+        <section className="ticket-create-section" aria-label="工单信息">
+          <div className="ticket-create-information-fields">
+            <fieldset className="ticket-create-field">
+              <legend>工单类型</legend>
+              <div className="ticket-create-types">
+                {CREATABLE.map(({ code, label, Icon }) => <label key={code}>
+                  <input type="radio" className="sr-only" name="ticketType" value={code} checked={ticketType === code} onChange={() => setTicketType(code)} />
+                  <span><Icon size={16} aria-hidden="true" />{label}</span>
+                </label>)}
+              </div>
+            </fieldset>
+            <FieldLabel className="ticket-create-field" label="事项标题" required>
+              <Input required maxLength={100} placeholder="用一句话概括客户诉求" value={title}
+                aria-invalid={invalid === "title" || undefined} aria-describedby={invalid === "title" ? `${id}-error` : undefined}
+                onChange={(event) => { setTitle(event.target.value); if (invalid === "title") setInvalid(null); }} />
+            </FieldLabel>
+            <FieldLabel className="ticket-create-field" label="详细描述">
+              <textarea className="ticket-create-control" maxLength={1000} rows={4} placeholder="补充问题现象、影响范围或期望完成时间"
+                value={detail} onChange={(event) => setDetail(event.target.value)} />
+            </FieldLabel>
+          </div>
+        </section>
+      </div>
+      <footer>
+        {error && <p className="ops-form-error" id={`${id}-error`} role="alert">{error}</p>}
+        <div className="ticket-create-actions">
+          <Button variant="outline" type="button" onClick={onClose}>取消</Button>
+          <Button type="submit" disabled={submit.busy}>{submit.busy ? "正在创建…" : "创建工单"}</Button>
         </div>
-      </section>
-      <section><h3><span>03</span>事项内容</h3>
-        <label>事项标题 <em>*</em><Input required maxLength={100} placeholder="一句话说明诉求" value={title} onChange={(event) => setTitle(event.target.value)} /></label>
-        <label>详细描述<FieldHint label="详细描述说明">现象、影响范围、期望完成时间;建单后进入待分派/待处理,过程材料在详情内直传。</FieldHint><textarea maxLength={1000} rows={5} placeholder="现象、影响范围、期望完成时间" value={detail} onChange={(event) => setDetail(event.target.value)} /></label>
-      </section>
-      {tip && <p className="work-order-form-error" role="alert">{tip}</p>}
-      {failure && <p className="work-order-form-error" role="alert">{failure.message}</p>}
-      {submit.busy && <p className="work-order-editor-note">提交中…</p>}
-      <footer><Button variant="outline" type="button" onClick={onClose}>取消</Button><Button type="submit" disabled={submit.busy}><Check size={16} />创建工单</Button></footer>
+      </footer>
     </form>
-  </Drawer>;
+  </OpsDialog>;
 }
 
 /** 逗号分隔的多值参数(`type`/`status` 支持多选;Tab 与下拉框都写这一份)。 */
@@ -158,8 +273,14 @@ export function WorkOrderLedgerPage() {
   const location = useLocation();
   const navigate = useNavigate();
   const [editorOpen, setEditorOpen] = useState(false);
+  const editorTrigger = useRef<HTMLButtonElement>(null);
   const [notice, setNotice] = useState("");
 
+  function closeEditor() {
+    setEditorOpen(false);
+    window.requestAnimationFrame(() => editorTrigger.current?.focus({ preventScroll: true }));
+  }
+
   const query = params.get("q") ?? "";
   const types = multiOf(params, "type");
   const statuses = multiOf(params, "status");
@@ -259,7 +380,7 @@ export function WorkOrderLedgerPage() {
   return <section className="order-page work-order-ledger page-fill page-fill-window">
     <header className="order-heading">
       <div><h1>{clientView ? "工单进度" : "全部工单"}</h1><PageIntro>{clientView ? "跟进已提交的服务申请或故障报修,了解处理到了哪一步。" : "查询工单进度、责任团队和处理期限,从列表进入下一步办理。"}</PageIntro></div>
-      {!clientView && <Button onClick={() => setEditorOpen(true)}><Plus size={17} />代客建单</Button>}
+      {!clientView && <Button ref={editorTrigger} onClick={() => setEditorOpen(true)}><Plus size={17} />代客建单</Button>}
     </header>
     {!clientView && <div className="work-order-ledger-summary" role="group" aria-label="当前账号可见范围内的工单统计">
       <div className="work-order-metric work-order-metric-total">
@@ -318,6 +439,6 @@ export function WorkOrderLedgerPage() {
       {!list.loading && !fail && <ListPager total={total} page={currentPage - 1} pageSize={TICKET_PAGE_SIZE} unit="张" onPageChange={(next) => patchParams("page", [String(next + 1)])} />}
     </div>
     {notice && <OpsNotice message={notice} onClose={() => setNotice("")} />}
-    {editorOpen && <Editor onClose={() => setEditorOpen(false)} onCreated={(message) => { setEditorOpen(false); setNotice(message); reloadAll(); }} />}
+    {editorOpen && <TicketCreateDialog onClose={closeEditor} onCreated={(message) => { closeEditor(); setNotice(message); reloadAll(); }} />}
   </section>;
 }

+ 89 - 0
web-scaffold/src/styles/work-order-ledger.css

@@ -67,6 +67,95 @@
 .work-order-message-panel .work-order-process-form { flex: none; margin: 12px 24px; }
 .work-order-message-panel .work-order-process-form h2 { font-size: var(--type-body); font-weight: 600; overflow-wrap: anywhere; }
 
+.ops-dialog.ticket-create-dialog {
+  position: fixed;
+  inset: 0;
+  width: min(680px, calc(100vw - 24px));
+  max-height: calc(100dvh - 24px);
+  overflow: hidden;
+}
+.ticket-create-dialog[open] { display: flex; flex-direction: column; }
+.ticket-create-dialog > header { position: static; flex: none; }
+.ops-dialog.ticket-create-dialog > form { display: flex; flex-direction: column; min-height: 0; padding: 0; }
+.ticket-create-body { min-height: 0; overflow: auto; overscroll-behavior: contain; padding: 20px clamp(14px, 3vw, 24px); }
+.ticket-create-section + .ticket-create-section { margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--border-subtle); }
+.ticket-create-customer-fields, .ticket-create-information-fields { display: grid; gap: 13px; min-width: 0; }
+.ticket-create-customer-fields { grid-template-columns: minmax(0, 5fr) minmax(0, 4fr); align-items: start; }
+.ticket-create-field { display: grid; gap: 6px; min-width: 0; color: var(--field-label); font-size: var(--type-body); }
+.ticket-create-field em { margin-inline-start: 3px; color: var(--destructive); font-style: normal; }
+.ticket-create-field legend { margin-bottom: 6px; }
+.ticket-create-search { position: relative; display: block; }
+.ticket-create-search > :is(.ticket-create-search-icon, .ticket-create-search-chevron, .ticket-create-search-clear) { position: absolute; top: 50%; translate: 0 -50%; color: var(--icon); }
+.ticket-create-search-icon { inset-inline-start: 11px; pointer-events: none; }
+.ticket-create-search-chevron { inset-inline-end: 11px; pointer-events: none; }
+.ticket-create-search > input { padding-inline: 34px; text-overflow: ellipsis; }
+.ticket-create-search > input[readonly] { background: var(--surface-subtle); }
+.ticket-create-search-clear { inset-inline-end: 6px; display: grid; width: 25px; height: 25px; place-items: center; border-radius: 5px; cursor: pointer; }
+.ticket-create-search-clear:hover { background: var(--accent); color: var(--foreground); }
+.ticket-create-search-clear:focus-visible { outline: 2px solid var(--ring); }
+.ticket-create-customer-popup {
+  position: absolute;
+  z-index: 3;
+  inset-inline: 0;
+  top: calc(100% + 5px);
+  max-height: min(220px, 40dvh);
+  overflow: auto;
+  overscroll-behavior: contain;
+  padding: 4px;
+  border: 1px solid var(--border);
+  border-radius: 8px;
+  background: var(--card);
+  color: var(--foreground);
+  box-shadow: var(--shadow-card);
+}
+.ticket-create-customer-popup li { display: grid; gap: 2px; padding: 6px 8px; border-radius: 5px; cursor: pointer; overflow-wrap: anywhere; }
+.ticket-create-customer-popup li[aria-selected="true"] { background: var(--accent); }
+.ticket-create-customer-popup :is(small, p) { color: var(--muted-foreground); font-size: var(--type-support); }
+.ticket-create-customer-popup p { padding: 7px 8px; }
+.ticket-create-control {
+  width: 100%;
+  min-width: 0;
+  padding: 7px 10px;
+  border: 1px solid var(--input);
+  border-radius: 9px;
+  background-color: var(--card);
+  color: var(--foreground);
+  font-size: var(--type-body);
+  transition: border-color .15s, box-shadow .15s;
+}
+select.ticket-create-control {
+  height: 37px;
+  appearance: none;
+  padding: 0 34px 0 10px;
+  background-image: var(--select-chevron);
+  background-position: right 10px center;
+  background-repeat: no-repeat;
+  background-size: 16px;
+  cursor: pointer;
+  text-overflow: ellipsis;
+}
+textarea.ticket-create-control { min-height: 82px; line-height: 1.5; resize: vertical; }
+.ticket-create-control[data-placeholder], .ticket-create-control::placeholder { color: color-mix(in oklab, var(--muted-foreground) 70%, transparent); }
+.ticket-create-control option { color: var(--foreground); }
+.ticket-create-control:disabled { background-color: var(--surface-subtle); color: var(--muted-foreground); cursor: not-allowed; }
+.ticket-create-control:hover:enabled { border-color: var(--border-hover); }
+.ticket-create-control:focus-visible { outline: none; border-color: var(--ring); box-shadow: 0 0 0 3px var(--ring-glow); }
+.ticket-create-control[aria-invalid="true"] { border-color: var(--destructive); }
+.ticket-create-types { display: inline-grid; grid-template-columns: repeat(2, minmax(0, 1fr)); max-width: 290px; gap: 3px; padding: 3px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface-subtle); }
+.ticket-create-types label { position: relative; min-width: 0; cursor: pointer; }
+.ticket-create-types label > span { display: flex; align-items: center; justify-content: center; gap: 7px; min-height: 29px; padding: 3px 6px; border: 1px solid transparent; border-radius: 6px; transition: background-color .15s, color .15s; }
+.ticket-create-types label:hover > span { color: var(--foreground); }
+.ticket-create-types input:checked + span { border-color: var(--primary-border); background: var(--primary-soft); color: var(--primary-soft-foreground); font-weight: 600; }
+.ticket-create-types input:focus-visible + span { outline: 2px solid var(--ring); outline-offset: 1px; }
+.ticket-create-dialog footer { flex: none; display: grid; gap: 8px; padding: 12px clamp(14px, 3vw, 24px); border-top: 1px solid var(--border-subtle); background: var(--card); }
+.ticket-create-dialog footer .ops-form-error { margin: 0; padding: 8px 10px; }
+.ticket-create-actions { display: flex; justify-content: flex-end; gap: 8px; }
+
+@media (max-width: 480px) {
+  .ticket-create-customer-fields { grid-template-columns: minmax(0, 1fr); }
+  .ticket-create-actions > button { flex: 1; }
+}
+
 @media (max-width: 1150px) {
   .work-order-ledger-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
 }