:root {
  --brand: #880000;
  --brand-dark: #6a0000;
  --ink: #1c1d20;
  --ink-2: #565a63;
  --ink-3: #6f737c;
  --line: #e3e5ea;
  --line-strong: #cdd0d7;
  --bg: #f4f5f7;
  --surface: #ffffff;
  --blue: #1d74c4;
  --blue-soft: #e4f0fb;
  --danger: #c02020;
  --danger-soft: #fdecec;
  --warn: #8a5a00;
  --warn-soft: #fdf3dc;
  --good: #116a3c;
  --good-soft: #e4f5ec;
  --today: #fff2e0;
  --radius: 10px;
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 14px/1.5 'Be Vietnam Pro', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

h1 { font-size: 22px; line-height: 1.25; margin: 0; font-weight: 700; }
h2 { font-size: 16px; margin: 0; font-weight: 600; }
h3 { font-size: 13px; margin: 0; font-weight: 700; }
p { margin: 0; }
a { color: inherit; }

.muted { color: var(--ink-2); }
.small { font-size: 13px; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.text-danger { color: var(--danger); font-weight: 600; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.loading { padding: 48px; text-align: center; color: var(--ink-2); }

/* Thanh trên cùng */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 8px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; flex-shrink: 0; }
.brand-mark {
  display: inline-block;
  padding: 3px 8px;
  background: var(--brand);
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: .08em;
  border-radius: 5px;
}
.brand-mark-lg { font-size: 16px; padding: 5px 11px; align-self: flex-start; }
/* Logo Pix (img/logo-den.png) */
.brand-logo { display: block; height: 24px; width: auto; }
.brand-logo-lg { height: 44px; align-self: flex-start; }
.brand-name { font-weight: 600; white-space: nowrap; }
.nav { display: flex; gap: 2px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a {
  padding: 7px 11px;
  border-radius: 7px;
  color: var(--ink-2);
  text-decoration: none;
  white-space: nowrap;
  font-weight: 500;
}
.nav a:hover { background: var(--bg); color: var(--ink); }
.nav a.active { background: #f7e9e9; color: var(--brand); font-weight: 600; }
.topbar-actions { display: flex; gap: 8px; flex-shrink: 0; }
.topbar-actions { align-items: center; }
.save-indicator { font-size: 13px; color: var(--ink-2); white-space: nowrap; }

.main { max-width: 1240px; margin: 0 auto; padding: 20px; }
.view { display: flex; flex-direction: column; gap: 14px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.back { color: var(--ink-2); text-decoration: none; }
.back:hover { color: var(--ink); text-decoration: underline; }

/* Nút */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 36px;
  padding: 6px 13px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: none;
  color: inherit;
  font: inherit;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}
.btn:disabled { opacity: .6; cursor: progress; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--brand-dark); }
.btn-ghost { background: var(--surface); border-color: var(--line-strong); }
.btn-ghost:hover:not(:disabled) { background: var(--bg); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger-ghost { background: var(--surface); border-color: #e6b9b9; color: var(--danger); }
.btn-danger-ghost:hover:not(:disabled) { background: var(--danger-soft); }
.btn-block { width: 100%; }
.btn-icon { min-width: 36px; padding: 4px; }
.btn-group { display: flex; gap: 4px; }
.action-row { display: flex; flex-wrap: wrap; gap: 8px; }
:is(a, button, input, select, textarea, summary):focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

/* Khung nội dung */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; align-items: start; }
.detail-grid { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.count { min-width: 24px; padding: 0 7px; background: var(--bg); border-radius: 12px; text-align: center; font-weight: 600; font-size: 13px; }
.today-section { padding: 0 16px; }
.today-section > details > summary { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 58px; padding: 10px 0; cursor: pointer; list-style: none; }
.today-section > details > summary::-webkit-details-marker { display: none; }
.today-section > details > summary::before { content: '▸'; color: var(--ink-2); width: 12px; flex-shrink: 0; }
.today-section > details[open] > summary::before { content: '▾'; }
.today-section > details[open] { padding-bottom: 8px; }
.today-title { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.count-active { background: #f7e9e9; color: var(--brand); }
.empty { padding: 44px 16px; text-align: center; display: flex; flex-direction: column; gap: 12px; align-items: center; color: var(--ink-2); }
.empty-line { color: var(--ink-3); padding: 12px 0 4px; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.inline-field, .inline-check { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-2); }
.check-large { color: var(--ink); align-self: end; min-height: 38px; }

input, select, textarea {
  font: inherit;
  color: inherit;
  min-height: 38px;
  padding: 6px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  max-width: 100%;
}
input[type='checkbox'] { min-height: 0; width: 17px; height: 17px; accent-color: var(--brand); }
input[type='search'] { flex: 1; min-width: 200px; }
textarea { resize: vertical; width: 100%; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field > span { font-size: 13px; font-weight: 500; color: var(--ink-2); }
.field input, .field select { width: 100%; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* Thông báo */
.alert { padding: 10px 12px; border-radius: 8px; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.alert-error { background: var(--danger-soft); color: #8d1414; }
.alert-warn { background: var(--warn-soft); color: #6b4600; }
.alert-link { text-decoration: none; font-weight: 500; }
.alert-link:hover { text-decoration: underline; }
.conflict { font-size: 13px; }
.conflict ul { margin: 4px 0 0; padding-left: 18px; }

.badge { display: inline-block; padding: 1px 8px; border-radius: 11px; font-size: 12px; font-weight: 500; white-space: nowrap; }
.badge-muted { background: #eceef1; color: var(--ink-2); }
.badge-blue { background: var(--blue-soft); color: #145a99; }
.badge-outline { border: 1px solid var(--line-strong); color: var(--ink-2); }
.badge-warn { background: var(--warn-soft); color: #6b4600; }
.badge-good { background: var(--good-soft); color: var(--good); }

/* Danh sách đơn */
.order-list { display: flex; flex-direction: column; margin-top: 4px; }
.card.order-list { padding: 4px 16px; margin: 0; }
.order-row {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr) auto;
  gap: 4px 12px;
  align-items: center;
  padding: 10px 0;
  border-top: 1px solid var(--line);
  text-decoration: none;
}
.order-list > .order-row:first-child { border-top: 0; }
.order-row:hover strong { color: var(--brand); }
.order-main, .order-time { display: flex; flex-direction: column; min-width: 0; }
.order-items { color: var(--ink-2); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.order-time { font-size: 13px; font-variant-numeric: tabular-nums; }
.order-time .muted { font-size: 12px; }
.order-package { font-weight: 600; color: var(--ink); }
.order-money { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; font-variant-numeric: tabular-nums; font-weight: 500; }
.order-badges { display: inline-flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; font-weight: 400; }
.order-item { border-top: 1px solid var(--line); }
.order-list > .order-item:first-child { border-top: 0; }
.order-item .order-row { border-top: 0; padding-bottom: 6px; }
.order-actions { display: flex; flex-wrap: wrap; gap: 6px; padding-bottom: 12px; }
.btn-sm { min-height: 32px; padding: 4px 10px; font-size: 13px; }
/* Đơn hàng: tab theo tình trạng và đơn gọn hai dòng */
.order-tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; border-bottom: 1px solid var(--line-strong); }
.order-tabs::-webkit-scrollbar { display: none; }
.order-tab { flex-shrink: 0; display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 6px 12px; border: 0; border-bottom: 2px solid transparent; background: none; color: var(--ink-2); font: inherit; font-weight: 500; white-space: nowrap; cursor: pointer; }
.order-tab:hover { color: var(--ink); }
.order-tab-active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }
.order-tab-count { min-width: 20px; padding: 0 6px; border-radius: 10px; background: #eceef1; color: var(--ink-2); font-size: 12px; font-weight: 600; text-align: center; }
.order-tab-active .order-tab-count { background: #f7e9e9; color: var(--brand); }
.order-day { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 0 -16px; padding: 7px 16px; background: #f4f5f7; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); font-size: 13px; font-weight: 600; }
.order-day:first-child { margin-top: -4px; border-top: 0; border-radius: 10px 10px 0 0; }
.order-day + .order-item { border-top: 0; }
.order-day-verb { font-weight: 400; color: var(--ink-2); }
.order-day-count { flex-shrink: 0; font-weight: 400; color: var(--ink-2); }
.order-item .order-row.order-compact { display: block; padding: 10px 0 4px; }
.order-line { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.order-who { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.order-who .order-items { display: inline; }
.order-total { flex-shrink: 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.order-sub { margin-top: 2px; align-items: center; flex-wrap: wrap; font-size: 13px; color: var(--ink-2); }
.order-when { font-variant-numeric: tabular-nums; }
.order-sub .order-package { color: var(--ink); }
.order-due { margin-left: 2px; color: #8d1414; font-weight: 600; white-space: nowrap; }
.owed-note { margin: 10px 0 -4px; padding: 4px 10px; border-radius: 6px; background: var(--warn-soft); color: #6b4600; font-size: 13px; }
.order-sub .order-badges { align-items: center; }
.order-card .order-actions { padding: 4px 0 12px; align-items: center; }
.more-menu { position: relative; }
.more-menu > summary { list-style: none; cursor: pointer; }
.more-menu > summary::-webkit-details-marker { display: none; }
.more-list { position: absolute; z-index: 15; right: 0; top: calc(100% + 4px); display: flex; flex-direction: column; gap: 4px; min-width: 170px; padding: 6px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 8px; box-shadow: 0 8px 24px rgba(20, 20, 30, .16); }
.more-list .btn { justify-content: flex-start; width: 100%; }
.grid-2 .order-row { grid-template-columns: minmax(0, 1fr) auto; }
.grid-2 .order-time { grid-row: 2; grid-column: 1; }
.grid-2 .order-money { grid-row: 1 / span 2; grid-column: 2; }

/* Lịch */
.legend { display: flex; flex-wrap: wrap; gap: 12px; margin-left: auto; color: var(--ink-2); font-size: 13px; }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.swatch { display: inline-block; width: 16px; height: 10px; border-radius: 3px; }
.swatch-bar { background: var(--blue); }
.swatch-past { background: #7e8aa0; }
.swatch-conflict { background: var(--danger); }
.swatch-today { background: var(--today); border: 1px solid #f0d3a8; }

.cal-scroll { overflow: auto; max-height: calc(100vh - 210px); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.cal { --name: 164px; position: relative; width: calc(var(--days) * var(--day) + var(--name)); }
.cal-head { position: sticky; top: 0; z-index: 12; display: flex; background: var(--surface); border-bottom: 1px solid var(--line-strong); }
.cal-corner { position: sticky; left: 0; z-index: 13; width: var(--name); flex-shrink: 0; padding: 10px 10px; background: var(--surface); border-right: 1px solid var(--line-strong); font-weight: 600; display: flex; align-items: flex-end; justify-content: space-between; }
.cal-days { display: flex; }
.cal-day { padding: 5px 0 2px; text-align: center; font-size: 12px; color: var(--ink-2); border-left: 1px solid var(--line); white-space: nowrap; }
.cal-day strong { color: var(--ink); font-weight: 600; }
.cal-day.cal-today { background: var(--today); }
.cal-slots { display: flex; border-left: 1px solid var(--line); font-size: 12px; color: var(--ink-3); }
.cal-slots span { flex: 1; text-align: center; }
.cal-today-col { position: absolute; top: 0; bottom: 0; left: calc(var(--name) + var(--index) * var(--day)); width: var(--day); background: var(--today); opacity: .75; pointer-events: none; z-index: 0; }
.cal-group { position: relative; z-index: 5; background: #f4f5f7; border-top: 1px solid var(--line-strong); }
.cal-group-btn { position: sticky; left: 0; display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 4px 10px; border: 0; background: none; color: var(--ink); font: inherit; font-size: 13px; font-weight: 700; white-space: nowrap; cursor: pointer; }
.cal-group-btn:hover { color: var(--brand); }
.cal-caret { width: 12px; }
.cal-group-count { font-weight: 400; color: var(--ink-2); font-size: 12px; }
.cal-row { position: relative; display: flex; border-top: 1px solid var(--line); }
.cal-name { position: sticky; left: 0; z-index: 6; width: var(--name); flex-shrink: 0; display: flex; justify-content: space-between; gap: 6px; align-items: center; padding: 2px 10px; background: var(--surface); border-right: 1px solid var(--line-strong); font-size: 13px; font-weight: 500; }
/* Tên phải hiện đủ để phân biệt "đời 1" với "đời 2". */
.cal-name > span:first-child { line-height: 1.2; overflow-wrap: anywhere; }
.cal-track {
  position: relative;
  flex: 1;
  cursor: cell;
  z-index: 1;
  background-image:
    linear-gradient(to right, var(--line-strong) 1px, transparent 1px),
    linear-gradient(to right, #f0f1f4 1px, transparent 1px);
  background-size: var(--day) 100%, calc(var(--day) / 3) 100%;
}
.bar {
  position: absolute;
  height: 34px;
  padding: 2px 5px;
  overflow: clip;
  border-radius: 4px;
  background: var(--blue);
  color: #fff;
  font-size: 12px;
  line-height: 15px;
  white-space: nowrap;
  text-decoration: none;
  z-index: 2;
}
/* Chữ trượt theo khi cuộn ngang để không bị cột tên máy che. */
.bar-label { position: sticky; left: calc(var(--name) + 5px); display: block; width: fit-content; max-width: 100%; }
.bar-name, .bar-time { display: block; overflow: hidden; text-overflow: ellipsis; }
/* Thanh quá hẹp: ẩn chữ, vẫn giữ để đo được độ rộng khi mở rộng. */
.bar-tiny { padding: 2px 0; }
.bar-tiny .bar-label { visibility: hidden; }
.bar-tiny.bar-conflict::after { content: '⚠'; position: absolute; inset: 0; text-align: center; font-size: 12px; line-height: 34px; }
/* Đưa chuột vào thì thanh tự mở rộng để đọc đủ chữ. */
.bar { transition: width .14s ease-out, left .14s ease-out; }
.bar-open { z-index: 4; padding: 2px 5px; box-shadow: 0 0 0 2px #fff, 0 3px 10px rgba(20, 20, 30, .32); }
.bar-open:hover { z-index: 4; }
.bar-open .bar-label { visibility: visible; width: max-content; max-width: none; }
.bar-open .bar-name, .bar-open .bar-time { overflow: visible; }
.bar-open.bar-tiny.bar-conflict::after { content: none; }
@media (prefers-reduced-motion: reduce) { .bar { transition: none; } }
.card-badges { justify-content: flex-start; }
.bar-name { font-weight: 600; }
.bar-time { font-size: 12px; font-weight: 400; opacity: .95; }
.bar:hover { filter: brightness(1.1); z-index: 3; }
.cal-compact .cal-track { background-image: linear-gradient(to right, var(--line-strong) 1px, transparent 1px); background-size: var(--day) 100%; }
.cal-compact .cal-day { line-height: 1.25; padding: 4px 0; }
.btn-selected { background: #f7e9e9; border-color: #dcb6b6; color: var(--brand); font-weight: 600; }
.bar-past { background: #7e8aa0; }
.bar-conflict { background: var(--danger); }

/* Form đơn */
.order-form { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 14px; align-items: start; }
.summary { position: sticky; top: 68px; display: flex; flex-direction: column; gap: 10px; }
.picker { position: relative; }
.picker input { width: 100%; }
.picker-results {
  position: absolute;
  z-index: 20;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  max-height: 320px;
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(20, 20, 30, .14);
}
.picker-hint { padding: 8px 10px 2px; }
.picker-results .empty-line { padding: 10px; }
.picker-item { display: flex; justify-content: space-between; align-items: center; gap: 10px; width: 100%; min-height: 44px; padding: 7px 10px; border: 0; background: none; font: inherit; color: inherit; text-align: left; cursor: pointer; }
.picker-item:hover, .picker-item:focus { background: var(--bg); }
.picker-item > span:first-child { display: flex; flex-direction: column; min-width: 0; }
.picker-item > span:last-child { white-space: nowrap; font-variant-numeric: tabular-nums; }
.phone-orders { display: flex; flex-direction: column; gap: 4px; max-height: 280px; overflow: auto; }
.phone-order { display: flex; gap: 8px; align-items: flex-start; padding: 7px 8px; border: 1px solid var(--line); border-radius: 6px; cursor: pointer; }
.phone-order input { margin-top: 2px; flex-shrink: 0; }
.phone-order > span { display: flex; flex-direction: column; min-width: 0; }
.phone-order-off { opacity: .65; cursor: default; }
.billing-note { padding: 8px 10px; background: #f7f8fa; border-radius: 6px; color: var(--ink-2); line-height: 1.45; }
.billing-note strong { color: var(--ink); }
.points-box { display: flex; flex-direction: column; gap: 8px; padding: 10px 12px; background: var(--blue-soft); border-radius: 8px; }
.points-row { display: flex; align-items: flex-end; gap: 8px; }
.points-row .field { flex: 1; }
.order-points { color: #145a99; font-weight: 600; white-space: nowrap; }
.customer-suggest { display: flex; flex-direction: column; gap: 4px; padding: 8px; background: #f7f8fa; border-radius: 8px; }
.customer-option { display: flex; justify-content: space-between; align-items: center; gap: 12px; width: 100%; min-height: 40px; padding: 6px 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; font: inherit; color: inherit; text-align: left; cursor: pointer; }
.customer-option:hover { border-color: var(--line-strong); background: #fafbfc; }
.line { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); }
.line:first-child { border-top: 0; }
.line-over { background: var(--danger-soft); margin: 0 -8px; padding: 8px; border-radius: 6px; }
.line-name { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.line-qty { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-2); font-size: 13px; }
.line-qty input { width: 64px; }

.mini-table { width: 100%; border-collapse: collapse; }
.mini-table td { padding: 6px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.totals { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; margin: 0; }
.totals dt { color: var(--ink-2); }
.totals dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.totals .total { color: var(--ink); font-weight: 700; font-size: 16px; }

/* Bảng */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; padding: 6px 8px; font-size: 13px; font-weight: 500; color: var(--ink-2); border-bottom: 1px solid var(--line-strong); white-space: nowrap; }
.table th.num { text-align: right; }
.table td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #fafbfc; }
.table-card { display: flex; flex-direction: column; gap: 6px; padding: 14px 16px; }
.table-scroll { overflow-x: auto; }
.plain-list { margin: 0; padding-left: 18px; }
.info { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 16px; margin: 0; }
.info dt { font-size: 13px; color: var(--ink-2); }
.info dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }

/* Khách hàng */
.customer { padding: 0 16px; }
.customer > summary { display: flex; justify-content: space-between; gap: 10px; align-items: center; padding: 12px 0; cursor: pointer; }
.customer[open] { padding-bottom: 14px; }
.customer-name { display: flex; flex-direction: column; min-width: 0; }
.customer-meta { display: flex; align-items: center; gap: 8px; white-space: nowrap; color: var(--ink-2); }
.customer .action-row { margin: 4px 0 10px; }
.customer-meta { flex-wrap: wrap; justify-content: flex-end; }
.dialog .table td, .dialog .table th { padding: 6px; }
.dialog .form-actions { flex-wrap: wrap; }

/* Doanh thu */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 13px 15px; }
.stat-label { font-size: 13px; color: var(--ink-2); }
.stat-value { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-note { font-size: 12px; color: var(--ink-3); }
.bar-cell { width: 34%; min-width: 90px; }
.hbar { height: 12px; background: transparent; }
.hbar span { display: block; height: 100%; background: var(--blue); border-radius: 0 4px 4px 0; }

/* Kết nối */
.connect { max-width: 480px; margin: 8vh auto 0; display: flex; flex-direction: column; gap: 14px; padding: 26px; }

/* Thông báo nổi và hộp thoại */
.toasts { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 100; width: min(92vw, 440px); }
.toast { padding: 10px 14px; border-radius: 8px; background: #26282d; color: #fff; box-shadow: 0 6px 22px rgba(0, 0, 0, .25); }
.toast-error { background: #a31818; }
.toast-good { background: #115c37; }
.toast-warn { background: #7a5000; }
.dialog { border: 0; border-radius: 12px; padding: 0; width: min(92vw, 480px); color: inherit; box-shadow: 0 20px 60px rgba(0, 0, 0, .3); }
.dialog::backdrop { background: rgba(20, 20, 26, .45); }
.dialog-body { display: flex; flex-direction: column; gap: 12px; padding: 20px; }
.dialog-body h2 { font-size: 16px; }
.dialog-content { display: flex; flex-direction: column; gap: 8px; }

/* Biên nhận */
.receipt-void { padding: 8px 12px; border: 2px solid var(--danger); border-radius: 6px; color: var(--danger); font-weight: 700; text-align: center; print-color-adjust: exact; -webkit-print-color-adjust: exact; }
.receipt-actions { display: flex; justify-content: space-between; align-items: center; }
.receipt { background: #fff; max-width: 780px; width: 100%; margin: 0 auto; padding: 32px; border: 1px solid var(--line); border-radius: var(--radius); display: flex; flex-direction: column; gap: 10px; }
.receipt-head { display: flex; justify-content: space-between; gap: 16px; padding-bottom: 12px; border-bottom: 2px solid var(--brand); font-size: 13px; }
.receipt-head h1 { color: var(--brand); font-size: 20px; }
.receipt-title { text-align: right; }
.receipt-title h2 { font-size: 16px; }
.receipt h3 { margin-top: 8px; color: var(--brand); }
.receipt-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.receipt-table td, .receipt-table th { border: 1px solid var(--line-strong); padding: 6px 8px; text-align: left; }
.receipt-table th { background: #f7f7f8; font-weight: 600; }
.receipt-table .num, .receipt-table th.num { text-align: right; }
.receipt-money { max-width: 440px; margin-left: auto; }
.receipt-due td { font-weight: 700; background: #f8eded; }
.receipt ul { margin: 0; padding-left: 18px; font-size: 13px; }
.receipt-thanks { text-align: center; font-style: italic; color: var(--ink-2); margin-top: 8px; }

/* Màn hình nhỏ */
@media (max-width: 900px) {
  .topbar { flex-wrap: wrap; gap: 8px; padding: 8px 12px; }
  .nav { order: 3; flex-basis: 100%; }
  .topbar-actions { margin-left: auto; }
  .brand-name { display: none; }
  .main { padding: 12px; }
  .grid-2, .detail-grid, .order-form { grid-template-columns: minmax(0, 1fr); }
  .summary { position: static; }
  .legend { margin-left: 0; }
  .cal-scroll { max-height: none; }
}

@media (max-width: 560px) {
  h1 { font-size: 20px; }
  .more-list { right: auto; left: 0; }
  .form-grid, .info { grid-template-columns: minmax(0, 1fr); }
  .order-row { grid-template-columns: minmax(0, 1fr) auto; }
  .order-time { grid-row: 2; grid-column: 1; }
  .order-money { grid-row: 1 / span 2; grid-column: 2; }
  .toolbar > input[type='search'], .toolbar > select { flex-basis: 100%; }
  .inline-field { flex-basis: 100%; }
  .inline-field input { flex: 1; }
  .receipt { padding: 16px; }
  .receipt-head { flex-direction: column; }
  .receipt-title { text-align: left; }
  /* Thu cột tên thiết bị để còn chỗ cho lịch. */
  .cal { --name: 112px; }
  .cal-name { font-size: 12px; padding: 3px 6px 3px 8px; }
}

@media print {
  @page { size: A4; margin: 12mm; }
  body { background: #fff; }
  .topbar, .no-print, .toasts { display: none !important; }
  .main { padding: 0; max-width: none; }
  .receipt { border: 0; padding: 0; max-width: none; }
  .receipt-due td, .receipt-table th { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ==== Giao diện mới: màu trạng thái, Hôm nay, menu điện thoại, form nhanh, tiến trình đơn ==== */
:root {
  --st-upcoming: #5b55c9;
  --st-upcoming-soft: #ecebfb;
  --st-overdue: #c2410c;
  --st-overdue-soft: #fdeee4;
  --st-done: #7e8aa0;
}

/* Một bộ màu trạng thái dùng chung cho nhãn và thanh trên Lịch */
.badge-st-upcoming { background: var(--st-upcoming-soft); color: #4038a8; }
.badge-st-active { background: var(--blue-soft); color: #145a99; }
.badge-st-overdue { background: var(--st-overdue-soft); color: #9a3412; font-weight: 600; }
.badge-st-back { background: var(--good-soft); color: var(--good); }
.badge-st-past, .badge-st-early, .badge-st-cancelled { background: #eceef1; color: var(--ink-2); }
.bar-upcoming { background: var(--st-upcoming); }
.bar-active { background: var(--blue); }
.bar-done { background: var(--st-done); }
.bar.bar-overdue { background: var(--st-overdue); }
.bar.bar-conflict { background: var(--danger); }
.swatch-upcoming { background: var(--st-upcoming); }
.swatch-overdue { background: var(--st-overdue); }
.swatch-now { width: 3px; height: 14px; background: var(--danger); border-radius: 2px; }
.cal-now { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: var(--danger); z-index: 1; pointer-events: none; }
.cal-now::before { content: ''; position: absolute; top: 0; left: -4px; width: 10px; height: 10px; border-radius: 50%; background: var(--danger); }

/* Hôm nay: ô số ở đầu trang */
.today-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat-link { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; font: inherit; color: inherit; cursor: pointer; border-left-width: 4px; }
.stat-link:hover { background: #fafbfc; }
.stat-link .stat-value { font-size: 22px; line-height: 1.2; }
.stat-blue { border-left-color: var(--blue); }
.stat-warn { border-left-color: #d99a00; }
.stat-danger { border-left-color: var(--st-overdue); }
.stat-danger .stat-value, .stat-danger .stat-note { color: #9a3412; }
.stat-calm { border-left-color: var(--line-strong); }
.stat-calm .stat-value { color: var(--ink-3); }
.today-section-empty > details > summary h2 { color: var(--ink-2); font-weight: 500; }
.today-grid .order-card .order-actions { padding-top: 6px; }

/* Nút chọn nhanh */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { min-height: 34px; padding: 4px 12px; border: 1px solid var(--line-strong); border-radius: 999px; background: var(--surface); color: var(--ink); font: inherit; font-size: 13px; cursor: pointer; white-space: nowrap; }
.chip:hover:not(:disabled) { background: var(--bg); }
.chip-on { background: #f7e9e9; border-color: #dcb6b6; color: var(--brand); font-weight: 600; }
.chip:disabled { opacity: .45; cursor: default; }
.quick-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.quick-label { width: 40px; font-size: 13px; color: var(--ink-2); }
.when-text { padding: 8px 10px; border-radius: 8px; background: var(--blue-soft); color: #10406e; }
.mobile-submit { display: none; }

/* Chi tiết đơn: tiến trình và liên hệ */
.progress { display: flex; margin: 0; padding: 12px 16px; list-style: none; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; }
.progress-step { flex: 1; display: flex; align-items: center; gap: 8px; min-width: 120px; color: var(--ink-3); font-size: 13px; white-space: nowrap; }
.progress-step:not(:last-child)::after { content: ''; flex: 1; min-width: 12px; height: 2px; margin: 0 8px; background: var(--line-strong); }
.progress-dot { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; width: 24px; height: 24px; border: 2px solid var(--line-strong); border-radius: 50%; background: var(--surface); font-size: 12px; font-weight: 700; }
.progress-step.done { color: var(--good); }
.progress-step.done .progress-dot { background: var(--good); border-color: var(--good); color: #fff; }
.progress-step.done:not(:last-child)::after { background: var(--good); }
.progress-step.current { color: var(--ink); font-weight: 600; }
.progress-step.current .progress-dot { border-color: var(--brand); color: var(--brand); }
.progress-step.warn { color: #9a3412; font-weight: 600; }
.progress-step.warn .progress-dot { background: var(--st-overdue); border-color: var(--st-overdue); color: #fff; }
.contact-cell { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.contact-links { display: inline-flex; gap: 6px; }

/* Khách hàng */
.customer-who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.avatar { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; width: 36px; height: 36px; border-radius: 50%; color: #fff; font-weight: 700; }
.avatar-0 { background: #1d74c4; }
.avatar-1 { background: #5b55c9; }
.avatar-2 { background: #0f766e; }
.avatar-3 { background: #a85a00; }
.avatar-4 { background: #b0245e; }
.avatar-5 { background: #4b5563; }
.phone-link { color: inherit; text-decoration: underline dotted; text-underline-offset: 3px; }

/* Doanh thu */
.trend-up { color: var(--good); font-weight: 600; }
.trend-down { color: var(--danger); font-weight: 600; }
.day-chart { display: flex; align-items: flex-end; gap: 3px; height: 170px; padding-top: 8px; }
.dbar { flex: 1; min-width: 0; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; }
.dbar span { display: block; width: 100%; max-height: calc(100% - 18px); background: var(--blue); border-radius: 3px 3px 0 0; }
.dbar:hover span { filter: brightness(1.15); }
.dbar-today span { background: var(--brand); }
.dbar i { height: 18px; line-height: 18px; font-style: normal; font-size: 12px; color: var(--ink-3); }

/* Menu dưới đáy và nút "+" chỉ dùng trên điện thoại */
.nav-icon, .nav-short, .fab { display: none; }

@media (max-width: 900px) {
  .today-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
  body { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
  .topbar-create { display: none; }
  .nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    display: flex; gap: 0;
    padding: 0 0 env(safe-area-inset-bottom);
    background: var(--surface); border-top: 1px solid var(--line-strong);
    box-shadow: 0 -4px 16px rgba(20, 20, 30, .06);
  }
  .nav a { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 60px; padding: 6px 2px; border-radius: 0; font-size: 12px; }
  .nav a.active { background: none; color: var(--brand); }
  .nav-icon { display: block; width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
  .nav-full { display: none; }
  .nav-short { display: inline; }
  .fab { position: fixed; right: 16px; bottom: calc(76px + env(safe-area-inset-bottom)); z-index: 35; display: flex; align-items: center; justify-content: center; width: 56px; height: 56px; border-radius: 50%; background: var(--brand); color: #fff; font-size: 30px; line-height: 1; text-decoration: none; box-shadow: 0 6px 18px rgba(136, 0, 0, .35); }
  body[data-view="orderForm"] .fab, body[data-view="receipt"] .fab { display: none; }
  .toasts { bottom: calc(80px + env(safe-area-inset-bottom)); }
  body[data-view="orderForm"] .toasts { bottom: calc(150px + env(safe-area-inset-bottom)); }
  /* Vùng bấm tối thiểu 44px cho ngón tay */
  .btn, .btn-sm, .chip, .order-tab, input, select { min-height: 44px; }
  input[type='checkbox'] { min-height: 0; }
  .mobile-submit { position: fixed; left: 0; right: 0; bottom: calc(60px + env(safe-area-inset-bottom)); z-index: 34; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px; background: var(--surface); border-top: 1px solid var(--line-strong); box-shadow: 0 -4px 16px rgba(20, 20, 30, .08); }
  .mobile-total { display: flex; flex-direction: column; line-height: 1.25; }
  .mobile-total strong { font-size: 16px; font-variant-numeric: tabular-nums; }
  .mobile-submit .btn { min-width: 140px; }
  body[data-view="orderForm"] .main { padding-bottom: 96px; }
  .progress { padding: 10px 12px; }
  .progress-step { min-width: 0; flex-direction: column; gap: 4px; font-size: 12px; white-space: normal; text-align: center; }
  .progress-step:not(:last-child)::after { display: none; }
}

@media print {
  .fab, .mobile-submit, .progress { display: none !important; }
}

/* ==== Đăng nhập bằng mã PIN, cài đặt bảo mật, nhật ký ==== */
.user-menu > summary { max-width: 180px; overflow: hidden; text-overflow: ellipsis; }
.user-menu .more-list { right: 0; left: auto; min-width: 200px; }
.lock input#pin { font-size: 22px; letter-spacing: .3em; text-align: center; }
.settings-card h2 + p { margin-top: -6px; }
.settings-save { position: sticky; bottom: 0; z-index: 5; box-shadow: 0 -4px 16px rgba(20, 20, 30, .06); }
.staff-row { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) auto; gap: 8px; align-items: end; }
.log-table td { vertical-align: top; }
.log-table td:first-child { white-space: nowrap; }
.log-warn td { background: var(--warn-soft); }
code { padding: 1px 5px; background: #eceef1; border-radius: 4px; font-size: 13px; }
@media (max-width: 720px) {
  .settings-save { bottom: calc(60px + env(safe-area-inset-bottom)); }
  .staff-row { grid-template-columns: minmax(0, 1fr); }
  .user-menu > summary { max-width: 130px; }
}
/* Hai ô PIN luôn thẳng hàng kể cả khi nhãn xuống dòng */
.settings-card .form-grid { align-items: end; }
.settings-card .form-grid + .muted { margin-top: -4px; }

/* Biên nhận gọn: vừa một màn hình điện thoại để chụp gửi khách */
.receipt.receipt-compact { max-width: 560px; padding: 22px 24px; gap: 12px; }
.rc-sub { display: block; font-size: 12px; font-weight: 400; color: var(--ink-2); }
.rc-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding-bottom: 10px; border-bottom: 2px solid var(--brand); }
.rc-brand { display: flex; gap: 10px; align-items: flex-start; min-width: 0; }
.rc-brand strong { color: var(--brand); font-size: 16px; }
.rc-no { text-align: right; flex-shrink: 0; }
.rc-no strong { font-size: 13px; }
.rc-info { display: grid; grid-template-columns: 1fr; gap: 4px; margin: 0; font-size: 13px; }
.rc-info > div { display: grid; grid-template-columns: 84px minmax(0, 1fr); gap: 8px; }
.rc-info dt { color: var(--ink-2); }
.rc-info dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.rc-items { border-top: 1px dashed var(--line-strong); border-bottom: 1px dashed var(--line-strong); padding: 4px 0; }
.rc-line { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 6px 0; font-size: 13px; }
.rc-line + .rc-line { border-top: 1px solid var(--line); }
.rc-line .num { font-weight: 600; }
.rc-money { display: flex; flex-direction: column; gap: 3px; font-size: 13px; }
.rc-money-row { display: flex; justify-content: space-between; gap: 12px; }
.rc-due { margin-top: 4px; padding: 8px 10px; border-radius: 6px; background: #f8eded; color: var(--brand); font-weight: 700; font-size: 14px; print-color-adjust: exact; -webkit-print-color-adjust: exact; }
.rc-note { font-size: 12px; color: var(--ink-2); }
.rc-terms { font-size: 12px; color: var(--ink-2); line-height: 1.45; }
.rc-terms strong { color: var(--ink); }
.rc-terms ul { margin: 4px 0 0; padding-left: 16px; }
.receipt-compact .receipt-thanks { margin-top: 0; font-size: 13px; }
@media (max-width: 560px) {
  .receipt.receipt-compact { padding: 16px; }
  .rc-head { flex-direction: column; }
  .rc-no { text-align: left; }
  .receipt-actions { flex-wrap: wrap; gap: 8px; }
}
@media print {
  .receipt.receipt-compact { max-width: 148mm; margin: 0 auto; }
}

/* Quá giờ hẹn mà khách chưa lấy máy */
.badge-st-late { background: #fef3c7; color: #854d0e; font-weight: 600; }
.bar.bar-late { background: #a16207; }
.swatch-late { background: #a16207; }

/* Checklist giao / nhận máy */
.checklist { display: flex; flex-direction: column; gap: 8px; margin: 0; padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: 8px; }
.checklist legend { padding: 0 4px; font-weight: 600; font-size: 13px; }
.check-items { display: flex; flex-direction: column; gap: 2px; }
.check-item { display: flex; align-items: flex-start; gap: 10px; min-height: 40px; padding: 6px 8px; border-radius: 6px; cursor: pointer; }
.check-item:hover { background: var(--bg); }
.check-item input { width: 20px; height: 20px; margin-top: 1px; flex-shrink: 0; }
.check-item:has(input:checked) { background: var(--good-soft); }
.check-sub { display: block; font-size: 12px; color: var(--ink-2); }
.checklist > .chip { align-self: flex-start; }
.check-block { display: flex; flex-direction: column; gap: 6px; }
.check-label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.chip-expected { border-style: dashed; border-color: #b08a00; }
.chip-all { color: var(--good); border-color: #a9d9be; }
.check-given { padding: 6px 10px; border-radius: 6px; background: #f7f8fa; color: var(--ink-2); }
.dialog .check-note { width: 100%; }
.dialog { max-height: 92vh; }
.dialog-body { max-height: 92vh; overflow-y: auto; }

.check-extra { display: flex; gap: 8px; }
.check-extra input { flex: 1; min-width: 0; }

/* Phụ kiện gọn: món phụ ẩn đến khi bấm "+ N món khác"; món đã chọn luôn hiện */
.check-acc:not(.show-more) .chip-more:not(.chip-on) { display: none; }
.check-acc { gap: 5px; }
.dialog .check-block .chip, .dialog .checklist .chip { min-height: 30px; padding: 2px 10px; font-size: 13px; }
.chip-toggle { border-style: dashed; color: var(--ink-2); }
.check-extra .btn { min-height: 34px; }
.check-extra input { min-height: 34px; }
@media (max-width: 720px) {
  .dialog .check-block .chip, .dialog .checklist .chip { min-height: 38px; }
}

/* Bảng giá: các nhóm thiết bị dùng chung độ rộng cột để giá thẳng hàng */
.price-table { table-layout: fixed; min-width: 560px; }
.price-table .pc-price { width: 15%; }
.price-table .pc-free { width: 14%; }
.price-table td:first-child { overflow-wrap: anywhere; }

/* Doanh thu theo ngày: cột chồng Đã thu / Chưa thu (cùng một sắc xanh, đã kiểm tra tương phản) */
.day-card { gap: 12px; }
.day-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.day-legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 13px; color: var(--ink-2); }
.day-legend span { display: inline-flex; align-items: center; gap: 6px; }
.dc-sw-paid { background: #1d74c4; }
.dc-sw-due { background: #86b4e4; }
.dc-sw-avg { display: inline-block; width: 16px; height: 0; border-top: 1px solid var(--ink-2); }
.day-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.day-stats > div { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border-radius: 8px; background: #f7f8fa; }
.day-stats strong { font-size: 16px; }
.dc-wrap { position: relative; padding-left: 44px; }
.dc-plot { position: relative; height: 200px; margin-bottom: 22px; }
.dc-grid { position: absolute; left: 0; right: 0; height: 0; border-top: 1px solid #eceef1; }
.dc-grid span { position: absolute; right: calc(100% + 8px); top: -8px; font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; white-space: nowrap; }
.dc-avg { position: absolute; left: 0; right: 0; height: 0; border-top: 1px solid var(--ink-2); z-index: 2; pointer-events: none; }
.dc-avg span { position: absolute; right: 0; top: -18px; padding: 0 4px; font-size: 12px; color: var(--ink-2); background: var(--surface); }
.dc-cols { position: absolute; inset: 0; display: flex; align-items: flex-end; }
.dc-col { position: relative; flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; border-radius: 4px; outline-offset: -2px; }
.dc-weekend { background: #f7f8fa; }
.dc-col[tabindex] { cursor: pointer; }
.dc-col[tabindex]:hover, .dc-col[tabindex]:focus-visible { background: var(--blue-soft); }
.dc-bar { position: relative; z-index: 1; width: min(24px, 72%); display: flex; flex-direction: column; gap: 2px; min-height: 3px; }
.dc-bar i { display: block; min-height: 2px; }
.dc-paid { background: #1d74c4; }
.dc-due { background: #86b4e4; }
.dc-bar i:first-of-type { border-radius: 4px 4px 0 0; }
.dc-value { position: absolute; bottom: calc(100% + 4px); left: 50%; transform: translateX(-50%); font-size: 12px; font-weight: 600; color: var(--ink); white-space: nowrap; }
.dc-x { position: absolute; top: calc(100% + 4px); font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.dc-today .dc-x { color: var(--ink); font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }
.dc-tip { position: absolute; top: 0; z-index: 5; display: flex; flex-direction: column; gap: 3px; min-width: 190px; padding: 8px 10px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface); box-shadow: 0 8px 24px rgba(20, 20, 30, .14); font-size: 13px; pointer-events: none; }
.dc-tip span { display: flex; align-items: center; gap: 6px; }
.dc-tip b { margin-left: auto; padding-left: 12px; font-variant-numeric: tabular-nums; }
.dc-tip-total { padding-top: 3px; border-top: 1px solid var(--line); }
.dc-table summary { cursor: pointer; color: var(--ink-2); font-size: 13px; }
@media (max-width: 900px) { .dc-x-minor { display: none; } }
@media (max-width: 560px) {
  .day-stats { grid-template-columns: minmax(0, 1fr); gap: 6px; }
  .day-stats > div { flex-direction: row; flex-wrap: wrap; justify-content: space-between; align-items: baseline; column-gap: 8px; padding: 8px 10px; }
  .day-stats .stat-note { flex-basis: 100%; }
  .day-stats strong { font-size: 15px; }
  .dc-wrap { padding-left: 38px; }
  .dc-plot { height: 170px; }
}

/* Tiền lưu trữ của khách */
.alert-good { background: var(--good-soft); color: var(--good); }
.cancel-money { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.cancel-money p { margin: 0; }
.choice-list { border: 0; padding: 0; margin: 4px 0 0; display: flex; flex-direction: column; gap: 8px; }
.choice-list legend { font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.choice { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: 8px; cursor: pointer; }
.choice:has(input:checked) { border-color: var(--blue); background: var(--blue-soft); }
.choice input { margin-top: 3px; }
.choice span { display: flex; flex-direction: column; gap: 2px; }
.choice small { color: var(--ink-2); font-size: 13px; }
.credit-box { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; background: var(--good-soft); }
.credit-box .credit-row { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.credit-box .field { flex: 1; min-width: 160px; }
.credit-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.credit-list li { display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
.credit-list li:first-child { border-top: 0; }
.credit-list .credit-who { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.credit-list .credit-amount { font-weight: 600; font-variant-numeric: tabular-nums; }
.credit-soon { color: #8a5a00; font-weight: 500; }
.credit-history { width: 100%; border-collapse: collapse; font-size: 13px; }
.credit-history th, .credit-history td { text-align: left; padding: 6px 8px; border-top: 1px solid var(--line); vertical-align: top; }
.credit-history td.num, .credit-history th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.data-issues { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.data-issues li { padding: 8px 10px; border-radius: 8px; background: var(--warn-soft); }.stack-sm { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.stack-sm p { margin: 0; }
.credit-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 12px; align-items: center; padding: 12px 0; border-top: 1px solid var(--line); }
.order-list > .credit-item:first-child { border-top: 0; }
.credit-item .credit-who { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.credit-item .credit-amount { font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }
.credit-item .credit-actions { grid-column: 1 / -1; display: flex; gap: 8px; flex-wrap: wrap; }
/* Lịch 3 tuần trong form đơn: ngày nào còn đủ máy (chữ "Đủ"/"Kẹt N" đi kèm màu, không chỉ dựa vào màu). */
.avail-cal { margin-top: 4px; }
.avail-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.avail-day { display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 5px 2px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); font: inherit; font-size: 12px; cursor: pointer; min-height: 52px; }
.avail-day:hover:not([disabled]) { border-color: var(--line-strong); }
.avail-dow { color: var(--ink-3); font-size: 11px; }
.avail-date { font-weight: 600; color: var(--ink); }
.avail-state { font-size: 11px; }
.avail-ok { background: var(--good-soft); }
.avail-ok .avail-state { color: var(--good); }
.avail-stuck { background: var(--danger-soft); }
.avail-stuck .avail-state { color: var(--danger); font-weight: 600; }
.avail-past { background: var(--bg); color: var(--ink-3); cursor: default; }
.avail-on { outline: 2px solid var(--brand); outline-offset: 1px; }
.price-table col.pc-edit { width: 64px; }


/* Nhãn THỬ NGHIỆM khi máy chủ chạy dữ liệu thử. */
.test-badge { margin-left: 8px; padding: 2px 8px; border-radius: 999px; background: var(--warn-soft); color: var(--warn); border: 1px solid #e6c98a; font-size: 11px; font-weight: 700; letter-spacing: .03em; }


/* Máy giữ tạm cho khách đặt trên web (chưa xác nhận): thanh nét đứt trên Lịch. */
.bar-hold { background: repeating-linear-gradient(135deg, var(--warn-soft), var(--warn-soft) 6px, #fff 6px, #fff 12px); border: 1px dashed var(--warn); color: var(--warn); }
.nav-badge { display: inline-grid; place-items: center; min-width: 18px; height: 18px; margin-left: 4px; padding: 0 5px; border-radius: 999px; background: var(--brand); color: #fff; font-size: 11px; font-weight: 700; }
.req-card { display: grid; gap: 8px; }
.req-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; }
.req-pill { padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.req-pill.holding { background: var(--good-soft); color: var(--good); }
.req-pill.expired { background: var(--warn-soft); color: var(--warn); }
.req-pill.done { background: var(--bg); color: var(--ink-3); }
.req-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 4px 16px; margin: 0; }
.req-grid dt { color: var(--ink-3); font-size: 12px; }
.req-grid dd { margin: 0 0 6px; }

.text-good { color: var(--good); }
.section-title { margin: 24px 0 8px; font-size: 16px; }

/* Ảnh thiết bị trong hộp sửa thiết bị */
.equip-image { display: flex; gap: 12px; align-items: flex-start; }
.equip-thumb { width: 96px; height: 96px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line, #ddd); flex: none; }
.equip-thumb[hidden] { display: none; }

/* Hộp thư (views/mail.js) */
.mail-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.mail-list { padding: 0; overflow: hidden; }
.mail-row { display: block; padding: 12px 16px; border-bottom: 1px solid var(--line); color: inherit; text-decoration: none; }
.mail-row:last-child { border-bottom: 0; }
.mail-row:hover { background: var(--bg); }
.mail-top { display: flex; justify-content: space-between; gap: 12px; }
.mail-from { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-date { flex: none; }
.mail-subject { margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-snippet { margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-unread .mail-from, .mail-unread .mail-subject { font-weight: 700; }
.mail-title { word-break: break-word; }
.mail-meta { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0 0 12px; }
.mail-meta dt { color: var(--ink-2); }
.mail-meta dd { margin: 0; word-break: break-word; }
.mail-body { white-space: pre-wrap; word-break: break-word; border-top: 1px solid var(--line); padding-top: 12px; line-height: 1.6; }
