:root {
  --bg: #F3F1EC;
  --card: #FFFFFF;
  --ink: #1A1D21;
  --ink-2: #2C3137;
  --muted: #5B6168;
  --line: #DDD8CF;
  --input: #CFC9BE;
  --accent: #B8430F;
  --accent-ink: #8F330B;
  --accent-soft: #FBE9DF;
  --steel: #2F5D8A;
  --steel-soft: #F1F5F9;
  --green: #2F7A4D;
  --green-ink: #1F5C39;
  --green-soft: #DDEFE3;
  --radius: 12px;
  font-family: 'Be Vietnam Pro', system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
button, input, select { font: inherit; color: inherit; }
a { color: var(--accent); }
.mono { font-family: 'IBM Plex Mono', ui-monospace, monospace; }
.strong { font-weight: 600; }
.big { font-size: 16px; }
.small { font-size: 13px; }
.muted { color: var(--muted); }
.center { text-align: center; }
.pad { padding: 16px; }
.grow { flex: 1 1 auto; min-width: 0; }
.mb { margin-bottom: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.error { color: #A3240C; background: #FCE8E4; border-radius: 8px; padding: 10px 12px; margin: 0; font-size: 14px; }

/* Khung app */
.app { min-height: 100vh; max-width: 560px; margin: 0 auto; display: flex; flex-direction: column; background: var(--bg); }
.app-main { flex: 1; padding-bottom: calc(72px + env(safe-area-inset-bottom)); }
.center-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }

.page-header {
  display: flex; align-items: center; gap: 8px;
  padding: calc(14px + env(safe-area-inset-top)) 14px 12px;
  background: var(--ink); color: #fff;
  position: sticky; top: 0; z-index: 5;
}
.page-header .step { font-size: 12px; color: #C9CDD2; letter-spacing: .04em; }
.page-header .title { margin: 0; font-size: 19px; font-weight: 700; }
.code-chip { font-family: 'IBM Plex Mono', monospace; font-size: 13px; font-weight: 600; background: var(--ink-2); padding: 6px 10px; border-radius: 6px; }
.icon-btn { width: 44px; height: 44px; border: 0; background: transparent; color: inherit; display: inline-flex; align-items: center; justify-content: center; border-radius: 8px; cursor: pointer; flex: none; }
.icon-btn.ghost { color: var(--muted); }
.icon-btn:hover { background: rgba(127,127,127,.12); }

.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  max-width: 560px; margin: 0 auto;
  background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.bottom-nav a, .bottom-nav button {
  min-height: 60px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: 12px; color: var(--muted); text-decoration: none; border: 0; background: none; cursor: pointer;
}
.bottom-nav a.active { color: var(--accent-ink); font-weight: 600; }

/* Nội dung */
.content { display: flex; flex-direction: column; gap: 14px; padding: 14px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card.list { padding: 0; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.login { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 14px; }
.login .step { font-size: 12px; letter-spacing: .08em; color: var(--accent-ink); font-weight: 700; }
.h2 { margin: 0; font-size: 22px; }
.h3 { margin: 0; font-size: 15px; font-weight: 700; }
.label { font-size: 13px; color: var(--muted); }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 8px; }

.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.field input {
  height: 44px; border: 1px solid var(--input); border-radius: 8px; padding: 0 12px;
  font-size: 16px; color: var(--ink); background: #fff; width: 100%;
}
.field input:focus, .search-input:focus-within { outline: 2px solid var(--steel); outline-offset: 1px; }
.field input.strong { font-weight: 600; }

/* Nút */
.btn {
  min-height: 48px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--input); background: #fff;
  font-size: 15px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  text-decoration: none; color: var(--ink); cursor: pointer;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-size: 16px; min-height: 52px; }
.btn.success { background: var(--green); border-color: var(--green); color: #fff; font-size: 16px; min-height: 52px; }
.btn.outline { border-color: var(--accent); color: var(--accent-ink); }
.btn.tiny { min-height: 34px; padding: 0 10px; font-size: 12px; font-weight: 500; color: var(--accent-ink); border-color: #E3C4B2; }
.btn.small-btn { min-height: 40px; font-size: 14px; padding: 0 12px; }
.btn:disabled { opacity: .6; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { min-height: 40px; padding: 0 14px; border-radius: 20px; border: 1px solid var(--input); background: #fff; font-size: 14px; cursor: pointer; }
.chip.on { border: 2px solid var(--accent); background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
.chip.dashed { border-style: dashed; color: var(--muted); }

.segmented { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); background: #E7E4DE; border-radius: 10px; padding: 4px; gap: 4px; }
.segmented button { min-height: 40px; font-size: 14px; padding: 0 4px; border: 0; border-radius: 8px; background: transparent; font-weight: 500; cursor: pointer; }
.segmented button.on { background: #fff; font-weight: 700; box-shadow: 0 1px 2px rgba(0,0,0,.08); }

.seg-row { display: flex; gap: 8px; }
.seg-row.wrap { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.seg-row.wrap .seg { padding: 0 6px; }
.seg { flex: 1; min-height: 44px; border-radius: 8px; border: 1px solid var(--input); background: #fff; font-size: 14px; cursor: pointer; }
.seg.a.on { border: 2px solid var(--steel); color: var(--steel); font-weight: 600; }
.seg.b.on { border: 2px solid var(--accent); color: var(--accent-ink); font-weight: 600; }
.seg.dark.on { border-color: var(--ink); background: var(--ink); color: #fff; font-weight: 600; }

.stepper { display: flex; align-items: center; gap: 4px; }
.stepper button { width: 44px; height: 44px; border-radius: 8px; border: 1px solid var(--input); background: #fff; font-size: 20px; cursor: pointer; }
.stepper output { width: 44px; text-align: center; font-size: 18px; font-weight: 700; }

/* Sơ đồ ống */
.hose-diagram { display: flex; align-items: center; padding: 4px 0; }
.hose-diagram .end { width: 34px; height: 26px; border-radius: 4px; color: #fff; font-size: 13px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.hose-diagram .end-a { background: var(--steel); }
.hose-diagram .end-b { background: var(--accent); }
.hose-diagram .ferrule { width: 14px; height: 18px; background: #8A9199; }
.hose-diagram .hose { flex: 1; height: 12px; background: var(--ink); border-radius: 2px; display: flex; align-items: center; justify-content: center; }
.hose-diagram .hose span { background: #fff; padding: 0 6px; font-size: 11px; font-weight: 600; font-family: 'IBM Plex Mono', monospace; }

.end-box { border-radius: 10px; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.end-box.a { background: var(--steel-soft); }
.end-box.b { background: #FDF1EA; }
.end-box.a .end-title { color: var(--steel); }
.end-box.b .end-title { color: var(--accent-ink); }
.end-title { font-size: 14px; font-weight: 700; }

.action-bar {
  position: sticky; bottom: calc(60px + env(safe-area-inset-bottom)); z-index: 4;
  display: flex; gap: 10px; padding: 12px 0;
  background: linear-gradient(to bottom, transparent, var(--bg) 25%);
}
.action-bar.column { flex-direction: column; gap: 6px; }

/* Danh mục */
.list-row { display: flex; align-items: center; gap: 8px; padding: 10px 8px 10px 16px; border-bottom: 1px solid #EEEAE3; }
.list-row:last-child { border-bottom: 0; }

/* Bàn giao */
.badge { font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 12px; white-space: nowrap; }
.badge.orange { color: var(--accent-ink); background: var(--accent-soft); }
.badge.green { color: var(--green-ink); background: var(--green-soft); }
.badge.gray { color: var(--ink); background: #E7E4DE; }
.spec { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 12px; margin: 0; font-size: 13px; }
.spec .full { grid-column: 1 / -1; }
.spec dt { color: var(--muted); }
.spec dd { margin: 0; font-weight: 600; }
.check-row { display: flex; align-items: center; gap: 12px; min-height: 44px; font-size: 14px; cursor: pointer; }
.check-row input { width: 22px; height: 22px; accent-color: var(--green); flex: none; }

/* Tìm đơn */
.search-bar { background: var(--ink); padding: 0 14px 14px; display: flex; flex-direction: column; gap: 12px; position: sticky; top: 72px; z-index: 4; }
.search-input { display: flex; align-items: center; gap: 8px; height: 48px; background: #fff; border-radius: 10px; padding: 0 12px; color: var(--muted); }
.search-input input { flex: 1; min-width: 0; height: 44px; border: 0; outline: 0; font-size: 16px; color: var(--ink); background: transparent; }
.filter-chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; }
.filter-chips button { min-height: 36px; padding: 0 12px; border-radius: 18px; border: 1px solid var(--muted); background: transparent; color: #fff; font-size: 13px; white-space: nowrap; cursor: pointer; }
.filter-chips button.on { background: #fff; color: var(--ink); border-color: #fff; font-weight: 600; }
.order-card { display: flex; flex-direction: column; gap: 10px; padding: 14px; }
.order-link { display: flex; flex-direction: column; gap: 6px; color: inherit; text-decoration: none; }
.divider { border-top: 1px solid #EEEAE3; padding-top: 8px; }

@media print {
  .bottom-nav, .action-bar, .page-header, .content > :not(.print-area) { display: none !important; }
  body, .app { background: #fff; }
  .print-area { border: 1px solid #000; }
}
