body { background: var(--sky); }
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: linear-gradient(160deg, #eaf7ee, #eaf6fd); }
.login-card { width: 100%; max-width: 380px; padding: 28px; text-align: center; }
.login-card .field { text-align: left; }
.login-logo { width: 130px; margin-bottom: 8px; }
.login-card h2 { font-size: 18px; margin-bottom: 2px; }
.login-card .hint { margin: 0 0 18px; }
.err { color: var(--red); font-size: 14px; }

.app { min-height: 100vh; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 20px; background: #fff; border-bottom: 3px solid var(--green); box-shadow: 0 2px 10px rgba(31, 52, 70, .05); }
.brand .sub { font-size: 12px; color: var(--muted); font-weight: 500; }
.top-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.who { font-size: 13px; color: var(--ink-2); }

.layout { flex: 1; display: grid; grid-template-columns: 290px 1fr; min-height: 0; }
.sidebar { background: #fff; border-right: 1px solid var(--line); padding: 16px; display: flex; flex-direction: column; gap: 10px; height: calc(100vh - 64px); position: sticky; top: 64px; }
.sidebar h3 { font-size: 16px; }
.filters { display: flex; gap: 4px; flex-wrap: wrap; }
.filters button { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 3px 11px; font-size: 13px; cursor: pointer; }
.filters button.on { background: var(--green); border-color: var(--green); color: #fff; }
.queue { overflow: auto; flex: 1; display: flex; flex-direction: column; gap: 8px; padding-bottom: 12px; }
.q-item { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; cursor: pointer; display: flex; gap: 10px; background: #fff; transition: .12s; }
.q-item:hover { border-color: var(--blue); }
.q-item.on { border-color: var(--green); background: var(--green-50); box-shadow: inset 3px 0 0 var(--green); }
.q-item.flag { border-left: 3px solid var(--red); }
.avatar { width: 36px; height: 36px; border-radius: 50%; flex: none; display: grid; place-items: center; font-weight: 700; font-size: 14px; color: #fff; background: linear-gradient(135deg, var(--green), var(--blue)); overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.q-main { min-width: 0; flex: 1; }
.q-name { font-weight: 600; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.q-sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.q-badges { display: flex; gap: 4px; margin-top: 4px; flex-wrap: wrap; }
.unread { width: 9px; height: 9px; border-radius: 50%; background: var(--blue); flex: none; margin-top: 6px; }

.main { padding: 18px 22px 40px; min-width: 0; }
.empty { display: grid; place-items: center; text-align: center; height: 70vh; color: var(--muted); }
.empty img { width: 160px; opacity: .85; }

.p-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; flex-wrap: wrap; margin-bottom: 12px; }
.p-head h2 { font-size: 22px; }
.p-meta { color: var(--ink-2); font-size: 13.5px; }
.p-actions { display: flex; gap: 6px; flex-wrap: wrap; }

.flag-banner { border-radius: 12px; padding: 11px 14px; margin-bottom: 12px; display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.flag-banner.red { background: var(--red-50); border: 1.5px solid #f0b3b0; color: #8f2a27; }
.flag-banner.ok { background: #fff; border: 1px solid var(--line); color: var(--ink-2); }
.flag-banner b { display: block; }

.info-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 14px; }
.info { padding: 12px 14px; font-size: 13.5px; }
.info h4 { font-size: 14.5px; margin-bottom: 6px; color: var(--ink); }
.kv { display: flex; gap: 6px; padding: 2px 0; }
.kv > span:first-child { color: var(--muted); min-width: 78px; flex: none; }
.allergy-has { color: var(--red); font-weight: 700; }
.hist-item { display: flex; justify-content: space-between; gap: 8px; padding: 3px 0; border-bottom: 1px dashed var(--line); cursor: pointer; }
.hist-item:last-child { border: 0; }
.hist-item:hover { color: var(--blue-600); }

.work { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); gap: 14px; align-items: start; }
.chat { display: flex; flex-direction: column; height: 680px; overflow: hidden; }
.chat-head { padding: 12px 14px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.chat-body { flex: 1; overflow: auto; padding: 14px; display: flex; flex-direction: column; gap: 8px; background: linear-gradient(180deg, #f7fbfe, #fff); }
.msg { max-width: 82%; padding: 8px 12px; border-radius: 14px; font-size: 14px; white-space: pre-wrap; word-wrap: break-word; }
.msg .t { font-size: 11px; color: var(--muted); margin-top: 3px; }
.msg.in { align-self: flex-start; background: #fff; border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg.out { align-self: flex-end; background: var(--green-50); border: 1px solid #c9ead3; border-bottom-right-radius: 4px; }
.msg.system { align-self: center; max-width: 92%; background: var(--blue-50); color: #145f86; font-size: 12.5px; border-radius: 10px; }
.msg img { max-width: 220px; border-radius: 8px; display: block; }
.quick { display: flex; gap: 6px; padding: 8px 12px 0; overflow-x: auto; }
.quick button { flex: none; border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 3px 10px; font-size: 12.5px; cursor: pointer; }
.quick button:hover { border-color: var(--green); color: var(--green-600); }
.chat-input { display: flex; gap: 8px; padding: 10px 12px 12px; align-items: flex-end; }
.chat-input textarea { min-height: 42px; max-height: 140px; }

.record { display: flex; flex-direction: column; }
.rec-head { display: flex; gap: 8px; align-items: center; padding: 12px 14px 0; }
.case-select { flex: 1; padding: 7px 10px; font-weight: 600; }
.tabs { display: flex; gap: 4px; padding: 10px 14px 0; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs button { border: 0; background: none; padding: 8px 12px; font-weight: 600; font-size: 14px; color: var(--muted); cursor: pointer; border-bottom: 2.5px solid transparent; white-space: nowrap; }
.tabs button.on { color: var(--green-600); border-bottom-color: var(--green); }
.tab { padding: 14px; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 6px; }
.chip { border: 1px solid var(--line); border-radius: 999px; padding: 2px 10px; font-size: 12.5px; cursor: pointer; background: #fff; }
.chip:hover { border-color: var(--blue); color: var(--blue-600); }
.rf-box { border: 1px solid #f3c4c2; border-radius: 10px; padding: 8px 12px; background: #fffafa; }
.rf-box summary { cursor: pointer; font-weight: 600; color: var(--red); }
.rf-box .check { font-size: 13.5px; padding: 3px 0; }
.rf-box .check input { accent-color: var(--red); }

.med-table-wrap { overflow-x: auto; }
.med-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.med-table th { text-align: left; font-weight: 600; color: var(--ink-2); background: var(--blue-50); padding: 7px 6px; }
.med-table td { padding: 5px 3px; border-bottom: 1px solid var(--line); vertical-align: top; }
.med-table input { width: 100%; border: 1px solid var(--line); border-radius: 7px; padding: 6px 7px; font-size: 13.5px; }
.med-table input:focus { outline: none; border-color: var(--blue); }
.med-table td.warn input { border-color: var(--red); background: var(--red-50); }
.med-table .rm { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 18px; }
.med-actions { display: flex; gap: 8px; margin: 12px 0 8px; flex-wrap: wrap; }
.fu-fields { margin-top: 12px; }
.fu-info { font-size: 13px; color: var(--ink-2); margin-bottom: 10px; }
.rec-foot { display: flex; gap: 8px; justify-content: flex-end; align-items: center; padding: 12px 14px; border-top: 1px solid var(--line); background: #fbfdfe; border-radius: 0 0 var(--radius) var(--radius); margin-top: auto; }
.rec-foot .hint { margin-right: auto; }

.modal { position: fixed; inset: 0; background: rgba(20, 40, 55, .45); display: grid; place-items: center; z-index: 60; padding: 16px; }
.modal-card { width: 100%; max-width: 560px; padding: 20px; max-height: 92vh; overflow: auto; }
.modal-card h3 { margin-bottom: 14px; }
.modal-actions { display: flex; gap: 8px; align-items: center; }

@media (max-width: 1200px) { .work { grid-template-columns: 1fr; } .chat { height: 520px; } }
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; max-height: 320px; border-right: 0; border-bottom: 1px solid var(--line); }
  .info-grid { grid-template-columns: 1fr; }
  .main { padding: 14px 16px 40px; }
  .topbar { padding: 10px 16px; }
  .who { display: none; }
}

/* delivery */
.dv-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.seg2 { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg2 button { border: 0; background: #fff; padding: 7px 12px; font-weight: 600; cursor: pointer; font-size: 13.5px; }
.seg2 button.on { background: var(--green); color: #fff; }
.dv-box { border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-bottom: 12px; background: #fbfdfe; }
.dv-box h5 { margin: 0 0 8px; font-size: 14px; }
.q-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.q-table th { text-align: left; background: var(--blue-50); padding: 6px 8px; font-weight: 600; }
.q-table td { padding: 7px 8px; border-bottom: 1px solid var(--line); }
.q-table tr.best td { background: var(--green-50); font-weight: 600; }
.price { font-size: 16px; font-weight: 700; color: var(--green-600); }
.track { word-break: break-all; }
.pod img { max-width: 160px; border-radius: 8px; border: 1px solid var(--line); margin: 4px 6px 0 0; }
.tl { list-style: none; padding: 0; margin: 0; font-size: 13px; }
.tl li { padding: 5px 0 5px 16px; border-left: 2px solid var(--line); position: relative; }
.tl li::before { content: ''; position: absolute; left: -6px; top: 10px; width: 10px; height: 10px; border-radius: 50%; background: var(--blue); }
.tl li span { color: var(--muted); font-size: 12px; }
