/* KODS – giao diện quản lý. Màu thép mạ kẽm, điểm nhấn đỏ cửa ngăn cháy. */

@font-face { font-family: 'Be Vietnam Pro'; font-style: normal; font-display: swap; font-weight: 400; src: url(/fonts/be-vietnam-pro-vietnamese-400-normal.woff2) format('woff2'); unicode-range: U+0102-0103,U+0110-0111,U+0128-0129,U+0168-0169,U+01A0-01A1,U+01AF-01B0,U+0300-0301,U+0303-0304,U+0308-0309,U+0323,U+0329,U+1EA0-1EF9,U+20AB; }
@font-face { font-family: 'Be Vietnam Pro'; font-style: normal; font-display: swap; font-weight: 400; src: url(/fonts/be-vietnam-pro-latin-ext-400-normal.woff2) format('woff2'); unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF; }
@font-face { font-family: 'Be Vietnam Pro'; font-style: normal; font-display: swap; font-weight: 400; src: url(/fonts/be-vietnam-pro-latin-400-normal.woff2) format('woff2'); unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }
@font-face { font-family: 'Be Vietnam Pro'; font-style: normal; font-display: swap; font-weight: 500; src: url(/fonts/be-vietnam-pro-vietnamese-500-normal.woff2) format('woff2'); unicode-range: U+0102-0103,U+0110-0111,U+0128-0129,U+0168-0169,U+01A0-01A1,U+01AF-01B0,U+0300-0301,U+0303-0304,U+0308-0309,U+0323,U+0329,U+1EA0-1EF9,U+20AB; }
@font-face { font-family: 'Be Vietnam Pro'; font-style: normal; font-display: swap; font-weight: 500; src: url(/fonts/be-vietnam-pro-latin-ext-500-normal.woff2) format('woff2'); unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF; }
@font-face { font-family: 'Be Vietnam Pro'; font-style: normal; font-display: swap; font-weight: 500; src: url(/fonts/be-vietnam-pro-latin-500-normal.woff2) format('woff2'); unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }
@font-face { font-family: 'Be Vietnam Pro'; font-style: normal; font-display: swap; font-weight: 600; src: url(/fonts/be-vietnam-pro-vietnamese-600-normal.woff2) format('woff2'); unicode-range: U+0102-0103,U+0110-0111,U+0128-0129,U+0168-0169,U+01A0-01A1,U+01AF-01B0,U+0300-0301,U+0303-0304,U+0308-0309,U+0323,U+0329,U+1EA0-1EF9,U+20AB; }
@font-face { font-family: 'Be Vietnam Pro'; font-style: normal; font-display: swap; font-weight: 600; src: url(/fonts/be-vietnam-pro-latin-ext-600-normal.woff2) format('woff2'); unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF; }
@font-face { font-family: 'Be Vietnam Pro'; font-style: normal; font-display: swap; font-weight: 600; src: url(/fonts/be-vietnam-pro-latin-600-normal.woff2) format('woff2'); unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }
@font-face { font-family: 'Be Vietnam Pro'; font-style: normal; font-display: swap; font-weight: 700; src: url(/fonts/be-vietnam-pro-vietnamese-700-normal.woff2) format('woff2'); unicode-range: U+0102-0103,U+0110-0111,U+0128-0129,U+0168-0169,U+01A0-01A1,U+01AF-01B0,U+0300-0301,U+0303-0304,U+0308-0309,U+0323,U+0329,U+1EA0-1EF9,U+20AB; }
@font-face { font-family: 'Be Vietnam Pro'; font-style: normal; font-display: swap; font-weight: 700; src: url(/fonts/be-vietnam-pro-latin-ext-700-normal.woff2) format('woff2'); unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF; }
@font-face { font-family: 'Be Vietnam Pro'; font-style: normal; font-display: swap; font-weight: 700; src: url(/fonts/be-vietnam-pro-latin-700-normal.woff2) format('woff2'); unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }

:root {
  --bg: #ECEFF2;
  --surface: #FFFFFF;
  --surface-2: #F6F8FA;
  --surface-3: #EEF2F5;
  --ink: #18222A;
  --ink-2: #3E4B55;
  --muted: #66727C;
  --line: #D3DAE0;
  --line-2: #E4E9ED;
  --brand: #B42318;
  --brand-dark: #8F1B12;
  --brand-soft: #FCEDEB;
  --steel: #2D3E4A;
  --focus: #2F6690;
  --green: #1D7447; --green-bg: #E5F3EB;
  --blue: #22598A; --blue-bg: #E6EFF7;
  --amber: #8F5B00; --amber-bg: #FCF1D9;
  --red: #B42318; --red-bg: #FCEDEB;
  --grey: #56626C; --grey-bg: #EDF0F2;
  --violet: #57479A; --violet-bg: #EEEAF9;
  --radius: 8px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(24, 34, 42, .06), 0 2px 8px rgba(24, 34, 42, .05);
  --nav-w: 232px;
  --font: 'Be Vietnam Pro', 'Segoe UI', Roboto, system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font);
  font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased;
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 21px; line-height: 1.3; }
h2 { font-size: 16px; }
h3 { font-size: 14.5px; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.num, td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }
.grow { flex: 1; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ── Khởi động ── */
.boot { min-height: 100vh; display: grid; place-items: center; }
.boot-mark { font-weight: 700; letter-spacing: .3em; color: var(--brand); font-size: 22px; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .boot-mark { animation: none; } }

/* ── Khung ứng dụng ── */
.shell { display: grid; grid-template-columns: var(--nav-w) 1fr; min-height: 100vh; }
.nav {
  position: sticky; top: 0; height: 100vh; overflow-y: auto; background: var(--surface);
  border-right: 1px solid var(--line); display: flex; flex-direction: column; z-index: 30;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 16px 16px 12px; }
.brand-mark { width: 34px; height: 34px; flex: none; }
.brand-mark img { width: 34px; height: 34px; object-fit: contain; }
.brand-name { font-weight: 700; font-size: 15px; letter-spacing: .02em; line-height: 1.2; }
.brand-sub { font-size: 11.5px; color: var(--muted); line-height: 1.3; }
.nav-group { padding: 6px 8px 4px; }
.nav-group > .nav-title {
  font-size: 12px; font-weight: 600; color: var(--muted); padding: 8px 10px 4px; display: flex; align-items: center; gap: 8px;
}
.nav a.nav-item {
  display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: var(--radius-sm); color: var(--ink-2);
  font-size: 13.5px; text-decoration: none; border-left: 3px solid transparent;
}
.nav a.nav-item:hover { background: var(--surface-2); color: var(--ink); }
.nav a.nav-item.active { background: var(--brand-soft); color: var(--brand-dark); border-left-color: var(--brand); font-weight: 500; }
.nav-foot { margin-top: auto; padding: 12px 16px 16px; font-size: 11.5px; color: var(--muted); border-top: 1px solid var(--line-2); }
.demo-flag { margin: 0 12px 8px; padding: 6px 10px; border-radius: var(--radius-sm); background: var(--amber-bg); color: var(--amber); font-size: 12px; font-weight: 500; }

.main { min-width: 0; display: flex; flex-direction: column; }
.top {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px;
  padding: 10px 24px; background: rgba(236, 239, 242, .92); backdrop-filter: blur(6px); border-bottom: 1px solid var(--line-2);
}
.menu-btn { display: none; }
.gsearch { position: relative; flex: 1; max-width: 460px; }
.gsearch input[type=search] { width: 100%; padding: 8px 12px 8px 34px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); }
.gsearch svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.gsearch .menu { position: absolute; left: 0; right: 0; top: calc(100% + 6px); }
.top-user { margin-left: auto; position: relative; }
.user-btn { display: flex; align-items: center; gap: 8px; border: 1px solid transparent; background: none; padding: 4px 8px; border-radius: 999px; cursor: pointer; }
.user-btn:hover { background: var(--surface); border-color: var(--line); }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--steel); color: #fff; display: grid; place-items: center; font-size: 12px; font-weight: 600; flex: none; }
.user-meta { text-align: left; line-height: 1.25; }
.user-meta b { display: block; font-size: 13px; font-weight: 600; }
.user-meta span { font-size: 11.5px; color: var(--muted); }
.view { padding: 20px 24px 64px; max-width: 1480px; width: 100%; }

/* ── Nút ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 34px; padding: 6px 14px;
  border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  cursor: pointer; white-space: nowrap; font-weight: 500; font-size: 13.5px; text-decoration: none;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.dark { background: var(--steel); border-color: var(--steel); color: #fff; }
.btn.dark:hover { background: #1F2D37; }
.btn.danger { color: var(--red); border-color: #EBC4BF; }
.btn.danger:hover { background: var(--red-bg); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-3); }
.btn.sm { min-height: 28px; padding: 3px 10px; font-size: 12.5px; }
.btn.icon { padding: 6px; min-width: 34px; }
.btn svg { flex: none; }
.btn-group { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ── Đầu trang ── */
.page-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head .titles { flex: 1; min-width: 240px; }
.page-head .crumb { font-size: 12.5px; color: var(--muted); margin-bottom: 2px; }
.page-head .crumb a { color: var(--muted); }
.page-head h1 { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); font-size: 13px; margin-top: 2px; }

/* ── Thẻ, khối ── */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel + .panel, .panel + .section, .section + .section, .section + .panel { margin-top: 16px; }
.section { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.section-head { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line-2); flex-wrap: wrap; }
.section-head h2, .section-head h3 { flex: 1; }
.section-body { padding: 16px; }
.section-note { font-size: 12.5px; color: var(--muted); padding: 0 16px 12px; margin-top: -4px; }

/* ── Chip trạng thái ── */
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 1px 9px; border-radius: 999px; font-size: 12px; font-weight: 500; white-space: nowrap; line-height: 20px; background: var(--grey-bg); color: var(--grey); }
.chip::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85; }
.chip.green { background: var(--green-bg); color: var(--green); }
.chip.blue { background: var(--blue-bg); color: var(--blue); }
.chip.amber { background: var(--amber-bg); color: var(--amber); }
.chip.red { background: var(--red-bg); color: var(--red); }
.chip.violet { background: var(--violet-bg); color: var(--violet); }
.chip.plain::before { display: none; }

/* ── Thanh công cụ danh sách ── */
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding: 12px; border-bottom: 1px solid var(--line-2); }
.toolbar .search { position: relative; flex: 1 1 240px; max-width: 360px; }
.toolbar .search input { width: 100%; padding-left: 32px; }
.toolbar .search svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.toolbar select, .toolbar input[type=date] { width: auto; max-width: 210px; }
.toggle { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border: 1px solid var(--line); border-radius: 999px; font-size: 12.5px; cursor: pointer; background: var(--surface); user-select: none; }
.toggle input { margin: 0; }
.toggle.on { background: var(--blue-bg); border-color: #B9D0E6; color: var(--blue); }
.date-range { display: inline-flex; align-items: center; gap: 4px; }
.toolbar .filters { display: contents; }
.toolbar .filter-btn { display: none; }
.toolbar .ref-filter { min-width: 200px; flex: 0 1 240px; }
.date-range span { color: var(--muted); font-size: 12px; }

/* ── Bảng ── */
.table-wrap { overflow-x: auto; }
table.grid { width: 100%; border-collapse: collapse; }
table.grid th, table.grid td { padding: 8px 12px; border-bottom: 1px solid var(--line-2); text-align: left; vertical-align: top; }
table.grid th { font-size: 12px; font-weight: 600; color: var(--muted); background: var(--surface-2); position: sticky; top: 0; white-space: nowrap; }
table.grid th.sortable { cursor: pointer; }
table.grid th.sortable:hover { color: var(--ink); }
table.grid th .arrow { font-size: 10px; margin-left: 3px; }
table.grid tbody tr { cursor: pointer; }
table.grid tbody tr:hover td { background: #F8FAFB; }
table.grid tbody tr.static { cursor: default; }
table.grid td.code { font-weight: 600; white-space: nowrap; }
table.grid td.wrap { max-width: 360px; }
table.grid tfoot td { font-weight: 600; background: var(--surface-2); border-bottom: none; }
table.grid tr.warn td { background: #FFFBF2; }
table.grid td.tog { color: var(--muted); cursor: pointer; text-align: center; padding-left: 8px; padding-right: 0; }
table.grid.prod td { white-space: nowrap; }
table.grid.prod td.name { white-space: normal; min-width: 240px; max-width: 340px; }
table.grid.prod td.name .small { white-space: normal; }
table.grid.prod tr.detail > td { white-space: normal; }
table.grid tr.detail > td { background: var(--surface-2); padding-top: 4px; padding-bottom: 12px; }
table.grid.sub { background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--radius-sm); }
table.grid.sub th { background: var(--surface); position: static; }
table.grid.sub td, table.grid.sub th { padding: 6px 10px; font-size: 13px; }
table.grid tr.bad td { background: #FFF6F5; }
.late { color: var(--red); font-weight: 500; }
.neg { color: var(--red); }
.pos { color: var(--green); }
.bar { display: inline-flex; align-items: center; gap: 8px; min-width: 110px; }
.bar i { display: block; height: 6px; flex: 1; background: var(--line-2); border-radius: 3px; overflow: hidden; position: relative; }
.bar i b { position: absolute; inset: 0 auto 0 0; background: var(--blue); border-radius: 3px; }
.bar.done i b { background: var(--green); }
.bar span { font-size: 12px; font-variant-numeric: tabular-nums; color: var(--ink-2); min-width: 34px; text-align: right; }
.pager { display: flex; align-items: center; gap: 8px; padding: 10px 12px; font-size: 13px; color: var(--muted); }
.pager .grow { flex: 1; }
.empty { padding: 40px 16px; text-align: center; color: var(--muted); }
.empty b { display: block; color: var(--ink); font-size: 15px; margin-bottom: 4px; }
.empty .btn { margin-top: 12px; }

/* ── Biểu mẫu ── */
input[type=text], input[type=tel], input[type=email], input[type=number], input[type=date], input[type=password], input[type=search], select, textarea {
  width: 100%; min-height: 34px; padding: 6px 10px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--focus); box-shadow: 0 0 0 3px rgba(47, 102, 144, .14); }
input[readonly], textarea[readonly] { background: var(--surface-2); color: var(--ink-2); }
input:disabled, select:disabled, textarea:disabled { background: var(--surface-2); color: var(--ink-2); opacity: 1; -webkit-text-fill-color: var(--ink-2); }
textarea { resize: vertical; min-height: 64px; line-height: 1.5; }
input[type=number]::-webkit-inner-spin-button { opacity: .4; }
input.money, input.number { text-align: right; font-variant-numeric: tabular-nums; }
.fgrid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px 16px; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field > label { font-size: 12.5px; font-weight: 500; color: var(--ink-2); }
.field > label .req { color: var(--brand); margin-left: 2px; }
.field .help { font-size: 11.5px; color: var(--muted); line-height: 1.4; }
.field.w2 { grid-column: span 2; } .field.w3 { grid-column: span 3; } .field.w4 { grid-column: span 4; }
.field.err input, .field.err select, .field.err textarea, .field.err .ref-box { border-color: var(--red); }
.checks { display: flex; flex-wrap: wrap; gap: 6px 14px; padding: 4px 0; }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 13.5px; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--brand); margin: 0; }
.switch-row { min-height: 34px; display: flex; align-items: center; }
.form-error { margin-bottom: 12px; padding: 10px 14px; border-radius: var(--radius-sm); background: var(--red-bg); color: var(--red); border: 1px solid #EFC7C2; }
.form-error:empty { display: none; }
.meta-line { font-size: 12px; color: var(--muted); margin-top: 16px; }

/* Ô chọn tham chiếu */
.ref-box { position: relative; display: flex; align-items: stretch; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); min-height: 34px; }
.ref-box:focus-within { border-color: var(--focus); box-shadow: 0 0 0 3px rgba(47, 102, 144, .14); }
.ref-box input.ref-text { border: none; box-shadow: none !important; min-height: 32px; background: transparent; flex: 1; min-width: 0; padding-right: 4px; }
.ref-box .ref-btn { border: none; background: none; color: var(--muted); padding: 0 8px; cursor: pointer; display: grid; place-items: center; }
.ref-box .ref-btn:hover { color: var(--ink); }
.ref-box.disabled { background: var(--surface-2); }
.ref-box.disabled .ref-btn.clear { display: none; }
.menu { position: absolute; z-index: 60; left: 0; top: calc(100% + 4px); min-width: 100%; max-height: 300px; overflow-y: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 8px 24px rgba(24, 34, 42, .14); padding: 4px; }
.menu .opt { padding: 7px 10px; border-radius: var(--radius-sm); cursor: pointer; line-height: 1.35; }
.menu .opt .sub { display: block; font-size: 12px; color: var(--muted); }
.menu .opt.active, .menu .opt:hover { background: var(--blue-bg); }
.menu .grp { font-size: 11.5px; font-weight: 600; color: var(--muted); padding: 8px 10px 2px; }
.menu .none { padding: 8px 10px; color: var(--muted); font-size: 13px; }
.dropdown { position: relative; }
.dropdown .menu { left: auto; right: 0; min-width: 220px; }
.dropdown .menu a, .dropdown .menu button { display: flex; width: 100%; align-items: center; gap: 8px; padding: 8px 10px; border: none; background: none; text-align: left; cursor: pointer; border-radius: var(--radius-sm); color: var(--ink); text-decoration: none; font-size: 13.5px; }
.dropdown .menu a:hover, .dropdown .menu button:hover { background: var(--surface-2); }
.dropdown .menu .danger { color: var(--red); }
.dropdown .menu hr { border: none; border-top: 1px solid var(--line-2); margin: 4px 0; }

/* Lưới dòng chi tiết */
.cgrid-wrap { overflow-x: auto; }
table.cgrid { border-collapse: separate; border-spacing: 0; width: 100%; table-layout: fixed; }
table.cgrid input[type=number] { -moz-appearance: textfield; appearance: textfield; }
table.cgrid input[type=number]::-webkit-inner-spin-button, table.cgrid input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
table.cgrid input, table.cgrid select { padding-left: 7px; padding-right: 7px; }
table.cgrid select { appearance: none; -webkit-appearance: none; padding-right: 18px; background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%2366727C' stroke-width='1.5'/%3E%3C/svg%3E") no-repeat right 6px center; }
table.cgrid select:disabled { background-color: var(--surface-2); }
table.cgrid .ref-box .ref-btn { display: none; }
table.cgrid .ref-box:focus-within .ref-btn.clear:not([hidden]) { display: grid; }
table.cgrid th { font-size: 12px; font-weight: 600; color: var(--muted); text-align: left; padding: 6px 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border-bottom: 1px solid var(--line-2); background: var(--surface-2); }
table.cgrid th:first-child, table.cgrid td:first-child { padding-left: 12px; }
table.cgrid td { padding: 4px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
table.cgrid td.idx { color: var(--muted); font-size: 12px; text-align: right; width: 32px; }
table.cgrid td.ro { font-variant-numeric: tabular-nums; text-align: right; padding-right: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink-2); }
table.cgrid input, table.cgrid select { min-height: 32px; padding: 4px 8px; }
table.cgrid .ref-box { min-height: 32px; }
table.cgrid .ref-box input.ref-text { min-height: 30px; }
table.cgrid tfoot td { font-weight: 600; padding: 8px 10px; border-bottom: none; }
table.cgrid td.acts { white-space: nowrap; padding-right: 6px; }
table.cgrid td.acts .btn.icon { min-width: 26px; padding: 4px; }
.child-foot { display: flex; gap: 8px; padding: 10px 12px; flex-wrap: wrap; align-items: center; }
.child-foot .grow { flex: 1; }

/* Khối tổng tiền */
.totals { display: grid; grid-template-columns: 1fr minmax(260px, 380px); gap: 16px; padding: 16px; }
.totals .words { color: var(--ink-2); font-size: 13px; align-self: end; font-style: italic; }
.totals dl { margin: 0; display: grid; grid-template-columns: 1fr auto; gap: 6px 16px; align-items: center; }
.totals dt { color: var(--ink-2); font-size: 13px; }
.totals dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; min-width: 150px; }
.totals dd input, .totals dd select { width: 170px; text-align: right; }
.totals dt.big, .totals dd.big { font-size: 16px; font-weight: 700; color: var(--ink); padding-top: 6px; border-top: 1px solid var(--line-2); }

/* Tiến trình đơn hàng */
.flow { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); margin-bottom: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.flow .step { position: relative; padding: 12px 14px 12px 22px; min-width: 0; border-right: 1px solid var(--line-2); }
.flow .step:last-child { border-right: none; }
.flow .step::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--line-2); }
.flow .step.done::before { background: var(--green); }
.flow .step.active::before { background: var(--blue); }
.flow .step.skip { opacity: .55; }
.flow .step .lbl { font-size: 12px; color: var(--muted); font-weight: 500; }
.flow .step .val { font-weight: 600; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.flow .step.done .val { color: var(--green); }
.flow .step.active .val { color: var(--blue); }
.flow .step a { color: inherit; }
.flow .step .mini { height: 4px; border-radius: 2px; background: var(--line-2); margin-top: 6px; overflow: hidden; }
.flow .step .mini b { display: block; height: 100%; background: var(--blue); }
.flow .step.done .mini b { background: var(--green); }

/* Tệp đính kèm */
.files { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; }
.file { display: flex; gap: 10px; align-items: center; padding: 8px; border: 1px solid var(--line-2); border-radius: var(--radius-sm); background: var(--surface-2); min-width: 0; }
.file .thumb { width: 44px; height: 44px; border-radius: 4px; background: var(--surface-3); flex: none; display: grid; place-items: center; overflow: hidden; color: var(--muted); font-size: 11px; font-weight: 600; }
.file .thumb img { width: 100%; height: 100%; object-fit: cover; }
.file .info { min-width: 0; flex: 1; }
.file .info a { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; color: var(--ink); }
.file .info span { font-size: 11.5px; color: var(--muted); }
.dropzone { border: 1.5px dashed var(--line); border-radius: var(--radius); padding: 14px; text-align: center; color: var(--muted); font-size: 13px; margin-top: 10px; }
.dropzone.over { border-color: var(--focus); background: var(--blue-bg); }
@media (hover: none) { .dropzone { display: none; } }

/* Liên quan */
.related { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 16px; margin-top: 16px; }
.related .section-head h3 { font-size: 13.5px; }
.related table.grid th, .related table.grid td { padding: 6px 12px; font-size: 13px; }

/* ── Tổng quan ── */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; margin-bottom: 16px; }
.card { display: block; padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); color: var(--ink); text-decoration: none; position: relative; }
a.card:hover { border-color: #B8C3CC; text-decoration: none; }
.card .k { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.card .v { font-size: 22px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.card .v small { font-size: 13px; font-weight: 500; color: var(--muted); margin-left: 3px; }
.card .n { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.card.red .n { color: var(--red); }
.card.amber .n { color: var(--amber); }
.card.red { border-left: 3px solid var(--red); }
.card.amber { border-left: 3px solid #E0A23A; }
.dash { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.alist { list-style: none; margin: 0; padding: 4px 0; }
.alist li a { display: grid; grid-template-columns: 10px 1fr; gap: 10px; padding: 9px 16px; color: var(--ink); text-decoration: none; }
.alist li a:hover { background: var(--surface-2); }
.alist .dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; background: var(--amber); }
.alist .dot.red { background: var(--red); }
.alist .dot.blue { background: var(--blue); }
.alist .dot.green { background: var(--green); }
.alist .t { font-weight: 500; line-height: 1.35; }
.alist .s { font-size: 12.5px; color: var(--muted); }
.alist .kind { font-size: 11.5px; color: var(--muted); font-weight: 600; }
.pipe { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0; padding: 14px 16px 16px; }
.pipe .p { padding: 6px 12px; border-left: 3px solid var(--line-2); }
.pipe .p:nth-child(1) { border-color: #C9D3DB; }
.pipe .p:nth-child(2) { border-color: #9DB4C7; }
.pipe .p:nth-child(3) { border-color: #5F86A6; }
.pipe .p:nth-child(4) { border-color: var(--steel); }
.pipe .p b { display: block; font-size: 22px; font-variant-numeric: tabular-nums; }
.pipe .p span { font-size: 12.5px; color: var(--muted); }
.chart { padding: 8px 16px 16px; }
.chart svg { width: 100%; height: auto; display: block; }
.legend { display: flex; gap: 16px; font-size: 12.5px; color: var(--ink-2); padding: 0 16px; flex-wrap: wrap; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }

/* Lịch tiến độ */
.gantt { overflow-x: auto; }
.gantt table { border-collapse: collapse; min-width: 900px; width: 100%; table-layout: fixed; }
.gantt th, .gantt td { border-bottom: 1px solid var(--line-2); padding: 0; height: 38px; }
.gantt th { font-size: 11.5px; color: var(--muted); font-weight: 500; text-align: left; padding: 6px 4px; background: var(--surface-2); border-left: 1px solid var(--line-2); }
.gantt td.lbl { width: 300px; min-width: 240px; padding: 6px 12px; font-size: 13px; vertical-align: middle; }
.gantt td.lbl a { font-weight: 600; color: var(--ink); }
.gantt td.lbl .s { display: block; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 280px; }
.gantt td.track { position: relative; }
.gantt .bgcol { position: absolute; top: 0; bottom: 0; border-left: 1px solid var(--line-2); }
.gantt .today { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--brand); opacity: .7; z-index: 2; }
.gantt .bar-g { position: absolute; top: 10px; height: 18px; border-radius: 4px; background: #BFD3E4; overflow: hidden; z-index: 1; min-width: 6px; }
.gantt .bar-g b { position: absolute; inset: 0 auto 0 0; background: var(--blue); }
.gantt .bar-g.production { background: #C9D9C9; } .gantt .bar-g.production b { background: var(--green); }
.gantt .bar-g.design { background: #E6DCF5; } .gantt .bar-g.design b { background: var(--violet); }
.gantt .bar-g.late { outline: 2px solid var(--red); outline-offset: 1px; }

/* ── Hộp thoại, thông báo ── */
.overlay { position: fixed; inset: 0; background: rgba(24, 34, 42, .38); z-index: 100; display: grid; place-items: center; padding: 16px; }
.dialog { background: var(--surface); border-radius: 10px; width: min(560px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column; box-shadow: 0 20px 50px rgba(0, 0, 0, .25); }
.dialog.wide { width: min(860px, 100%); }
.dialog header { padding: 16px 20px 8px; }
.dialog .body { padding: 8px 20px 16px; overflow-y: auto; }
.dialog footer { padding: 12px 20px 16px; display: flex; gap: 8px; justify-content: flex-end; border-top: 1px solid var(--line-2); }
#toasts { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: var(--steel); color: #fff; padding: 10px 16px; border-radius: 8px; box-shadow: 0 8px 24px rgba(0, 0, 0, .2); font-size: 13.5px; max-width: min(560px, 92vw); pointer-events: auto; }
.toast.red { background: var(--red); }
.toast.green { background: var(--green); }

/* ── Đăng nhập ── */
.login { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(360px, 440px); }
.login-art { background: var(--steel); color: #fff; position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: flex-end; padding: 48px; }
.login-art .slats { position: absolute; inset: 0; background: repeating-linear-gradient(180deg, rgba(255,255,255,.07) 0 22px, rgba(0,0,0,.08) 22px 26px); }
.login-art .slats::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 6px; background: var(--brand); }
.login-art h2 { position: relative; font-size: 30px; font-weight: 700; line-height: 1.25; max-width: 520px; }
.login-art p { position: relative; color: rgba(255,255,255,.75); max-width: 480px; margin: 12px 0 0; }
.login-form { background: var(--surface); display: flex; flex-direction: column; justify-content: center; padding: 48px 40px; gap: 14px; }
.login-form .brand { padding: 0 0 12px; }
.login-form h1 { font-size: 20px; }
.login-form .btn { width: 100%; min-height: 40px; }
.login-note { font-size: 12.5px; color: var(--muted); }
.login-hint { padding: 10px 12px; border-radius: var(--radius-sm); background: var(--blue-bg); color: #1B4A73; font-size: 13px; line-height: 1.5; }
.login-help { font-size: 13px; color: var(--ink-2); background: var(--surface-2); border: 1px solid var(--line-2); border-radius: var(--radius-sm); padding: 10px 12px; }
.login-help ol { margin: 6px 0 0; padding-left: 20px; }
.login-help li { margin-bottom: 4px; }
.login-hint code, .login-help code, .cred code { background: rgba(255,255,255,.7); border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; font-size: 12.5px; }
.kbd-warn { padding: 8px 12px; border-radius: var(--radius-sm); background: var(--amber-bg); color: var(--amber); font-size: 13px; font-weight: 500; }
.field input[type=password][readonly] { background: var(--surface); color: var(--ink); }
.cred { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 14px; font-size: 14px; line-height: 1.8; white-space: pre-wrap; font-family: inherit; margin: 0; }

/* ── Trang in ── */
.print-bar { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; align-items: center; }
.paper { background: #fff; width: 210mm; min-height: 297mm; margin: 0 auto; padding: 14mm 14mm 16mm; box-shadow: var(--shadow); color: #111; font-size: 12.5px; line-height: 1.45; }
.paper .ph { display: grid; grid-template-columns: auto 1fr; gap: 14px; align-items: center; border-bottom: 2px solid var(--brand); padding-bottom: 10px; }
.paper .ph img { max-height: 54px; max-width: 150px; }
.paper .ph .logo-text { font-weight: 700; font-size: 22px; color: var(--brand); letter-spacing: .08em; }
.paper .ph b { font-size: 14px; display: block; }
.paper .doc-title { text-align: center; font-size: 19px; font-weight: 700; margin: 18px 0 2px; letter-spacing: .02em; }
.paper .doc-sub { text-align: center; font-size: 12px; color: #444; margin-bottom: 14px; }
.paper .kv { display: grid; grid-template-columns: 150px 1fr; gap: 3px 10px; margin-bottom: 12px; }
.paper .kv dt { color: #444; }
.paper .kv dd { margin: 0; font-weight: 500; }
.paper table.pt { width: 100%; border-collapse: collapse; margin: 8px 0; }
.paper table.pt th, .paper table.pt td { border: 1px solid #888; padding: 4px 6px; vertical-align: top; }
.paper table.pt th { background: #F1F3F5; font-weight: 600; font-size: 11.5px; text-align: center; }
.paper table.pt td.num { text-align: right; }
.paper table.pt tfoot td { font-weight: 600; }
.paper .words { font-style: italic; margin: 6px 0 10px; }
.paper .terms { white-space: pre-wrap; margin: 8px 0; }
.paper .signs { display: grid; grid-template-columns: repeat(var(--cols, 2), 1fr); gap: 12px; text-align: center; margin-top: 22px; }
.paper .signs b { display: block; }
.paper .signs i { display: block; font-size: 11px; color: #555; margin-bottom: 64px; }
.paper .center { text-align: center; }

/* ── Màn hình hẹp ── */
/* ── Trợ lý tự động ── */
.cards.c5 { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.asst-banner { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 14px; margin-bottom: 16px; border: 1px solid #EBD7A6; background: var(--amber-bg); color: var(--amber); border-radius: var(--radius); font-size: 13.5px; }
.asst-jobs { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 12px; padding: 16px; }
.asst-job { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); cursor: pointer; }
.asst-job:hover { border-color: #B8C3CC; }
.asst-job.on { border-color: var(--steel); box-shadow: inset 0 0 0 1px var(--steel); background: var(--surface-2); }
.asst-job.disabled { opacity: .6; cursor: not-allowed; }
.asst-job input[type=checkbox] { width: 17px; height: 17px; margin: 2px 0 0; accent-color: var(--brand); flex: none; }
.asst-job b { display: block; margin-bottom: 2px; }
.asst-job span { color: var(--muted); font-size: 13px; }
.asst-file { margin-top: 8px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.asst-file span.small { color: var(--ink); }
.asst-run { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 0 16px 16px; }
.asst-result { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; margin-top: 16px; }
.asst-apply { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 12px 16px; border-radius: var(--radius); background: var(--blue-bg); border: 1px solid #B9D0E6; color: var(--blue); }
.asst-apply > div { flex: 1 1 280px; }
.asst-apply.done { background: var(--green-bg); border-color: #B5DCC6; color: var(--green); }
.asst-more { padding: 10px 16px; }
.asst-line h3 { font-size: 13.5px; padding: 12px 16px 6px; border-top: 1px solid var(--line-2); }
table.grid.asst td { font-size: 13.5px; }
table.grid.asst td.name { min-width: 200px; }
.chg { display: grid; gap: 2px; font-size: 13px; }
.chg .f { color: var(--muted); }
.chg s { color: var(--muted); }
.notes { list-style: none; margin: 0; padding: 0; }
.notes li { display: flex; gap: 10px; align-items: flex-start; padding: 9px 16px; border-top: 1px solid var(--line-2); font-size: 13.5px; }
.notes li:first-child { border-top: none; }
.notes .dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; flex: none; background: var(--grey); }
.notes .dot.red { background: var(--red); } .notes .dot.amber { background: #D99A1E; } .notes .dot.blue { background: var(--blue); } .notes .dot.green { background: var(--green); }
.cfg { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0; }
.cfg-block { padding: 14px 16px; border-bottom: 1px solid var(--line-2); }
.cfg-block h3 { font-size: 14px; margin-bottom: 4px; }
.cfg-block p { margin: 0 0 8px; }
.cfg-block table.grid { margin-top: 8px; }
.cfg-block table.grid td { vertical-align: middle; }
.cfg-block table.people .checks { padding: 0; gap: 4px 12px; }
.cap-shared { margin-top: 8px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cfg-foot { display: flex; gap: 12px; align-items: center; justify-content: flex-end; padding: 14px 16px; }
.cfg-foot .form-error { flex: 1; margin: 0; }
.gantt .bar-g.plan { background-image: repeating-linear-gradient(135deg, rgba(255,255,255,.0) 0 6px, rgba(255,255,255,.35) 6px 9px); }
.gantt .deadline { position: absolute; top: 4px; bottom: 4px; width: 0; border-left: 2px dashed var(--red); opacity: .7; }

/* ── Quy trình đơn hàng ── */
.flowbox { margin-bottom: 16px; }
.flowbox .section-head { gap: 6px 10px; }
.flowbox .section-head h2 { flex: 0 0 auto; }
.cards.flow-tiles { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
@media (max-width: 640px) {
  .flowbox .section-head .grow { display: none; }
  .flowbox .section-head .fh-wait { flex: 1 1 100%; order: 3; }
  .flowbox .section-head .fh-board { margin-left: auto; }
  .cards.flow-tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .cards.flow-tiles .card { padding: 8px 10px; }
  .cards.flow-tiles .card .k { font-size: 11.5px; }
  .cards.flow-tiles .card .v { font-size: 18px; }
  .cards.flow-tiles .card .n { display: none; }
}
.flow-note { margin: 10px 16px 0; padding: 8px 12px; border-radius: var(--radius-sm); background: var(--surface-2); color: var(--muted); font-size: 12.5px; }
.stepper { list-style: none; margin: 0; padding: 14px 16px 6px; display: grid; grid-template-columns: repeat(11, minmax(0, 1fr)); gap: 6px; }
.stepper .st { position: relative; padding: 8px 8px 10px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--line-2); cursor: pointer; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.stepper .st:hover { border-color: #B8C3CC; }
.stepper .st.sel { box-shadow: inset 0 0 0 2px var(--steel); }
.stepper .st .no { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 11.5px; font-weight: 700; background: var(--line); color: var(--ink-2); }
.stepper .st b { font-size: 12.5px; line-height: 1.25; }
.stepper .st small { font-size: 11.5px; color: var(--muted); line-height: 1.3; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.stepper .st .mini { display: block; height: 3px; border-radius: 2px; background: var(--line-2); overflow: hidden; margin-top: 4px; }
.stepper .st .mini u { display: block; height: 100%; background: var(--blue); }
.stepper .st.done { background: var(--green-bg); border-color: #B5DCC6; }
.stepper .st.done .no { background: var(--green); color: #fff; }
.stepper .st.active { background: var(--blue-bg); border-color: #9FBEDC; }
.stepper .st.active .no { background: var(--blue); color: #fff; }
.stepper .st.blocked { background: var(--surface); border-style: dashed; }
.stepper .st.blocked .no { background: var(--red-bg); color: var(--red); }
.stepper .st.override { background: var(--amber-bg); border-color: #EBD7A6; }
.stepper .st.override .no { background: #D99A1E; color: #fff; }
.stepper .st.skip, .stepper .st.legacy { opacity: .6; }
.stepper .st.todo { background: var(--surface); }
.flow-detail { margin: 6px 16px 0; padding: 10px 12px; border: 1px solid var(--line-2); border-radius: var(--radius-sm); font-size: 13.5px; display: grid; gap: 4px; }
.flow-lines { margin: 2px 0 0; padding-left: 18px; font-size: 13px; }
.flow-need { margin-top: 6px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--amber-bg); border: 1px solid #EBD7A6; display: grid; gap: 6px; font-size: 13px; }
.flow-need.wait { background: var(--surface-2); border-color: var(--line); }
.flow-need.legacy { background: var(--surface-2); border-color: var(--line-2); color: var(--muted); }
.flow-need .fn-head { font-weight: 600; color: var(--amber); }
.flow-need.wait .fn-head { color: var(--ink-2); }
.flow-need .fn-list { margin: 0; padding-left: 18px; display: grid; gap: 2px; }
.flow-need .fn-how { color: var(--ink-2); }
.flow-need .fn-acts { display: flex; gap: 8px; flex-wrap: wrap; }
.flow-need .fn-acts .btn.locked { color: var(--muted); border-style: dashed; background: var(--surface-2); }
.flow-need .fn-next { color: var(--muted); font-size: 12.5px; }
.flowbox .fh-wait a { color: inherit; }
.flowbox .fh-wait a:hover { color: var(--blue); }
.fb-need { color: var(--amber); margin-top: 2px; }
.flow-actions { display: flex; gap: 8px; flex-wrap: wrap; padding: 12px 16px; }
.flow-actions .btn.locked { color: var(--muted); border-style: dashed; background: var(--surface-2); }
.flowbox .table-wrap { margin: 10px 16px 0; }
table.grid.batches td .ok { color: var(--green); font-weight: 500; }
.flow-pay { padding: 0 16px 10px; }
.flow-log { padding: 0 16px 12px; font-size: 13px; }
.flow-log summary { cursor: pointer; color: var(--blue); font-size: 13px; padding: 4px 0; }
.flow-log ul { list-style: none; margin: 4px 0 0; padding: 0; display: grid; gap: 4px; }
.flow-log li { padding: 4px 0; border-top: 1px solid var(--line-2); }
.fgrid.flow-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.fgrid.flow-form .field.w4 { grid-column: 1 / -1; }
@media (max-width: 640px) { .fgrid.flow-form { grid-template-columns: 1fr; } }
table.grid.fboard td.name { min-width: 220px; }
.dots { display: flex; gap: 3px; margin-bottom: 4px; }
.dots i { width: 16px; height: 8px; border-radius: 3px; background: var(--line-2); }
.dots i.done { background: var(--green); }
.dots i.active { background: var(--blue); }
.dots i.blocked { background: #E7B3AE; }
.dots i.override { background: #D99A1E; }
.dots i.skip, .dots i.legacy { background: #CFD6DC; }
@media (max-width: 640px) {
  table.grid.fboard thead { display: none; }
  table.grid.fboard, table.grid.fboard tbody, table.grid.fboard tr, table.grid.fboard td { display: block; width: 100%; }
  table.grid.fboard tr { padding: 10px 12px; border-bottom: 1px solid var(--line-2); }
  table.grid.fboard td { padding: 2px 0; border: 0; }
  table.grid.fboard td.name { min-width: 0; }
  table.grid.fboard td.nowrap { white-space: normal; }
  table.grid.fboard td.nowrap > * { display: inline; margin-right: 6px; }
}
.cards .card.sel { box-shadow: inset 0 0 0 2px var(--steel); }
@media (max-width: 1100px) {
  .stepper { display: flex; overflow-x: auto; padding-bottom: 10px; }
  .stepper .st { flex: 0 0 132px; }
}

@media (max-width: 1100px) {
  .dash { grid-template-columns: 1fr; }
  .flow { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .flow .step { border-bottom: 1px solid var(--line-2); }
}
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .nav { position: fixed; left: 0; top: 0; bottom: 0; width: min(86vw, 300px); transform: translateX(-100%); transition: transform .2s ease; box-shadow: 0 0 40px rgba(0,0,0,.2); }
  .shell.nav-open .nav { transform: none; }
  .shell.nav-open::after { content: ''; position: fixed; inset: 0; background: rgba(24,34,42,.35); z-index: 25; }
  .menu-btn { display: inline-flex; }
  .top { padding: 8px 12px; }
  .view { padding: 14px 12px 64px; }
  .user-meta { display: none; }
  .fgrid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .field.w3, .field.w4 { grid-column: span 2; }
  .login { grid-template-columns: 1fr; }
  .login-art { display: none; }
  .totals { grid-template-columns: 1fr; }
  .related { grid-template-columns: minmax(0, 1fr); }
  .related > .section { min-width: 0; }
}
@media (max-width: 640px) {
  .fgrid { grid-template-columns: 1fr; }
  .field.w2, .field.w3, .field.w4 { grid-column: span 1; }
  h1 { font-size: 18px; }
  .flow { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .toolbar .search { max-width: none; flex: 1 1 60%; }
  .toolbar .filter-btn { display: inline-flex; }
  .toolbar .filters { display: none; }
  .toolbar.open .filters { display: flex; flex-wrap: wrap; gap: 8px; flex-basis: 100%; }
  .toolbar .filters select, .toolbar .filters .ref-filter { flex: 1 1 100%; max-width: none; }
  .toolbar .filters .date-range { flex: 1 1 100%; }
  .toolbar .filters .date-range input { flex: 1; }
  /* Danh sách thành thẻ trên điện thoại */
  table.grid.cards-sm thead { display: none; }
  table.grid.cards-sm, table.grid.cards-sm tbody, table.grid.cards-sm tr, table.grid.cards-sm td { display: block; width: 100%; }
  table.grid.cards-sm tr { padding: 10px 12px; border-bottom: 1px solid var(--line-2); }
  table.grid.cards-sm td { border: none; padding: 1px 0; text-align: left; }
  table.grid.cards-sm td[data-l]:not(.code)::before { content: attr(data-l) ': '; color: var(--muted); font-size: 12px; }
  table.grid.cards-sm td.num { text-align: left; }
  table.grid.cards-sm td.tog { display: none; }
  table.grid.prod td, table.grid.prod td.name { white-space: normal; max-width: none; min-width: 0; }
  table.grid.cards-sm tr.detail > td { padding: 0; }
  table.grid.cards-sm tr.detail table.sub thead { display: none; }
  table.grid.cards-sm tfoot { display: block; }
  .pipe { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .dialog footer { flex-wrap: wrap; }
}

/* ── In ấn ── */
@media print {
  @page { size: A4; margin: 0; }
  body { background: #fff; }
  .nav, .top, .print-bar, #toasts { display: none !important; }
  .shell { display: block; }
  .view { padding: 0; max-width: none; }
  .paper { box-shadow: none; margin: 0; width: auto; min-height: auto; }
  .paper table.pt tr { break-inside: avoid; }
}

/* Danh sách gợi ý của ô chọn (tìm khách hàng…) nổi trên cả hộp thoại */
.menu.float { z-index: 150; }
/* Nhập file báo giá */
.qi-card { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; margin-top: 12px; display: grid; gap: 8px; }
.qi-card.done { border-color: #9CCBA9; background: #F4FAF5; }
.qi-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.qi-head select { width: auto; max-width: 100%; }
.dialog.xwide { width: min(1180px, 100%); }
.qi-items tr:not(.qi-group) td:nth-child(3) { min-width: 260px; }
.qi-items tr.qi-group td { background: var(--surface-3); color: var(--ink-2); }
.qi-items tr.qi-group.warn td { background: #FFF6E5; }
.qi-mismatch { border: 1px solid #E8B4AE; background: var(--red-bg); color: var(--red); border-radius: var(--radius-sm); padding: 8px 10px; display: grid; gap: 6px; }
.qi-mismatch .check { color: var(--ink); }
.qi-mismatch ul { margin: 0; padding-left: 18px; }
.qi-meta { display: flex; flex-wrap: wrap; gap: 4px 14px; color: var(--ink-2, var(--muted)); }
.qi-items { max-height: 260px; overflow: auto; border: 1px solid var(--line-2); border-radius: var(--radius-sm); }
.qi-items table.grid th, .qi-items table.grid td { padding: 5px 8px; font-size: 12.5px; }
.qi-items tr.warn td { background: #FFF6E5; }
.qi-totals { display: flex; flex-wrap: wrap; gap: 4px 16px; }
.qi-totals .ok { color: var(--green); }
.qi-warn { margin: 0; padding-left: 18px; color: var(--amber); }
.qi-form { margin-top: 2px; }
.qi-ok { color: var(--green); }
.qi-target { padding: 8px 0; }
/* Định mức – giá thành */
.cost-grid { display: grid; grid-template-columns: minmax(260px, 330px) minmax(0, 1fr); gap: 16px; padding: 16px; align-items: start; }
.cost-form { display: grid; gap: 12px; position: sticky; top: 12px; }
.cost-form h4 { margin: 4px 0 0; font-size: 12px; font-weight: 600; color: var(--ink-2); text-transform: uppercase; letter-spacing: .03em; }
.cost-form h4 .small { text-transform: none; letter-spacing: 0; font-weight: 400; }
.cost-fg { display: grid; gap: 10px; }
.cost-fg.two { grid-template-columns: 1fr 1fr; }
.cost-def { font-size: 11px; font-weight: 500; color: var(--blue); background: var(--blue-bg); border-radius: 999px; padding: 0 6px; margin-left: 4px; cursor: help; }
.cost-res { min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; transition: opacity .15s; }
.cost-res > * { min-width: 0; }
.cost-res.busy { opacity: .55; }
.cost-res .cards, .cp-cards { margin-bottom: 0; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
.cp-cards { padding: 12px 12px 4px; }
.card .v.sm { font-size: 17px; }
.cp-rev input { font-size: 18px; font-weight: 700; padding: 2px 8px; min-height: 32px; margin-top: 2px; }
table.grid.cost-lines th, table.grid.cost-lines td { padding: 6px 10px; font-size: 13px; }
table.grid.cost-sum td { padding: 6px 12px; font-size: 13px; }
table.grid.cost-sum tr.cost-strong td { font-weight: 600; }
.cost-note { padding: 10px 16px; font-size: 12.5px; color: var(--muted); border-bottom: 1px solid var(--line-2); }
.cost-note a { font-weight: 600; }
.cp-tools .cp-src { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.cp-tools .cp-src .ref-box { width: 190px; }
.cp-tools .cp-common { display: inline-flex; align-items: center; gap: 6px; }
.cp-tools .cp-common select { width: auto; }
#cbody > .section, #cbody .cost-file > .section, #cbody > section { border-radius: 0; border-left: 0; border-right: 0; margin: 0; }
#cbody > section + section { border-top: 0; }
.cp-table { min-width: 1000px; }
.cp-table.with-rev { min-width: 1130px; }
.cp-table .cp-name { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; line-height: 1.35; }
.cp-table tr.warn td { background: #FFFBF2; }
.cp-err { color: var(--red); line-height: 1.3; margin-top: 2px; }
.cp-busy .cp-cards .v, .cp-busy [data-c], .cp-busy [data-t], .cp-busy #cp-mats { opacity: .45; transition: opacity .15s; }
.cp-err:empty { display: none; }
.cp-others .cp-name { white-space: normal; }
.cp-mats, .cp-ref { max-height: 520px; overflow: auto; }
.cost-steps { display: grid; grid-template-columns: 270px minmax(0, 1fr); min-height: 380px; }
.cs-list { border-right: 1px solid var(--line-2); padding: 8px; display: flex; flex-direction: column; gap: 2px; max-height: 72vh; overflow: auto; }
.cs-kind { font-size: 11.5px; font-weight: 600; color: var(--muted); padding: 10px 10px 2px; text-transform: uppercase; letter-spacing: .03em; }
.cs-item { text-align: left; border: 0; background: none; padding: 7px 10px; border-radius: var(--radius-sm); cursor: pointer; display: grid; gap: 1px; color: var(--ink); }
.cs-item:hover { background: var(--surface-2); }
.cs-item.on { background: var(--blue-bg); color: var(--blue); }
.cs-item .t { font-weight: 500; }
.cs-item .s { font-size: 12px; color: var(--muted); }
.cs-edit { min-width: 0; }
.cs-table td.cs-bad, .cs-bad { color: var(--amber); }
.cs-table tfoot td.cs-note { font-weight: 400; font-size: 12px; color: var(--muted); white-space: normal; }
.cf-dl { margin: 0 0 12px; display: grid; grid-template-columns: 160px minmax(0, 1fr); gap: 8px 16px; }
.cf-dl dt { color: var(--muted); font-size: 13px; }
.cf-dl dd { margin: 0; }
@media (max-width: 900px) {
  .cost-grid, .cost-steps { grid-template-columns: minmax(0, 1fr); }
  .cost-form { position: static; }
  .cs-list { border-right: 0; border-bottom: 1px solid var(--line-2); max-height: 240px; }
  .cf-dl { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .cf-dl dd { margin-bottom: 8px; }
}
