/* Bradwell OS – giao diện quản trị: thanh trên đen, menu trái, vùng làm việc dạng bảng. Màu thương hiệu: đen #141414 + vàng #F7D21E */
:root {
  --ink: #141414; --ink-2: #2a2a2a; --yel: #F7D21E; --yel-soft: #FBEA94; --yel-ink: #7a5f00;
  --bg: #f5f5f2; --surface: #ffffff; --line: #e4e4df; --mut: #62625c; --soft: #efefea; --text: #141414;
  --good: #1f7a46; --good-s: #e0f2e7; --warn: #9a6400; --warn-s: #fcf0d2; --bad: #b42323; --bad-s: #fbe3e3; --info: #2557b8; --info-s: #e3ebfb;
  --on-ink: #ffffff; --on-ink-mut: #b5b5ad; --side: #fbfbf8;
  --f: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; --fh: "Montserrat", "Be Vietnam Pro", system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #111110; --surface: #1a1a18; --line: #2c2c29; --mut: #a2a29a; --soft: #232320; --side: #161614; --ink-2: #222220; --text: #ecece6;
  --yel-ink: #f7d21e; --good: #6fd39a; --good-s: #15301f; --warn: #f1c35d; --warn-s: #33290f; --bad: #ff8b8b; --bad-s: #3a1717; --info: #8fb0ff; --info-s: #1b2540;
  color-scheme: dark } }
:root[data-theme="dark"] {
  --bg: #111110; --surface: #1a1a18; --line: #2c2c29; --mut: #a2a29a; --soft: #232320; --side: #161614; --ink-2: #222220; --text: #ecece6;
  --yel-ink: #f7d21e; --good: #6fd39a; --good-s: #15301f; --warn: #f1c35d; --warn-s: #33290f; --bad: #ff8b8b; --bad-s: #3a1717; --info: #8fb0ff; --info-s: #1b2540;
  color-scheme: dark }
* { box-sizing: border-box }
[hidden] { display: none !important }
html, body { height: 100% }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--f); font-size: 14px; line-height: 1.45; -webkit-text-size-adjust: 100% }
button, input, select, textarea { font: inherit; color: inherit }
:focus-visible { outline: 2px solid var(--yel); outline-offset: 2px }
.num { font-variant-numeric: tabular-nums }
h1, h2, h3 { margin: 0; text-wrap: balance }
a { color: var(--info) }

.app { display: grid; grid-template-rows: auto 1fr; height: 100%; height: 100dvh }
.top { background: #141414; color: var(--on-ink); display: flex; align-items: center; gap: 12px; min-height: 56px;
  padding: env(safe-area-inset-top, 0px) max(16px, env(safe-area-inset-right, 0px)) 0 max(16px, env(safe-area-inset-left, 0px)); border-bottom: 3px solid var(--yel) }
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--fh); font-weight: 800; letter-spacing: .02em; white-space: nowrap; color: #fff; text-decoration: none }
.brand small { font-family: var(--f); font-weight: 500; color: var(--on-ink-mut); letter-spacing: 0 }
.menu-btn { display: none; background: none; border: 0; color: #fff; font-size: 22px; padding: 6px; cursor: pointer }
.search { flex: 1; max-width: 420px; position: relative; display: flex; align-items: center; background: #262624; border-radius: 8px; padding: 0 10px; min-width: 0 }
.search input { background: none; border: 0; color: #fff; padding: 8px 6px; width: 100%; outline: none }
.search input::placeholder { color: #8d8d86 }
.search .kq { position: absolute; top: 100%; left: 0; right: 0; margin-top: 6px; background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 12px 30px rgba(0,0,0,.25); z-index: 15; overflow: hidden }
.search .kq button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 9px 12px; cursor: pointer; border-bottom: 1px solid var(--line) }
.search .kq button:hover { background: var(--soft) }
.top .sp { flex: 1 }
.demo { background: #3a3a37; color: var(--yel); font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 99px; letter-spacing: .05em; white-space: nowrap }
.who { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--on-ink-mut) }
.who select { background: #262624; color: #fff; border: 1px solid #3a3a37; border-radius: 7px; padding: 6px 8px }
.who b { color: #fff; font-weight: 600 }
.who button { background: #262624; color: #fff; border: 1px solid #3a3a37; border-radius: 7px; padding: 6px 10px; cursor: pointer }

.body { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 0 }
nav.side { background: var(--side); border-right: 1px solid var(--line); overflow-y: auto; padding: 12px 10px; display: grid; gap: 2px; align-content: start }
.side .grp { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--mut); font-weight: 700; padding: 12px 10px 4px }
.side button { display: flex; align-items: center; gap: 10px; width: 100%; border: 0; background: none; text-align: left; padding: 8px 10px; border-radius: 7px; cursor: pointer; color: inherit; font-weight: 500 }
.side button:hover { background: var(--soft) }
.side button[aria-current="page"] { background: var(--ink); color: #fff }
:root[data-theme="dark"] .side button[aria-current="page"] { background: var(--yel); color: #141414 }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .side button[aria-current="page"] { background: var(--yel); color: #141414 } }
.side .ico { width: 18px; height: 18px; flex: none; opacity: .85 }
.side .badge { margin-left: auto; background: var(--yel); color: #141414; font-size: 11px; font-weight: 700; border-radius: 99px; padding: 0 7px }
main { overflow-y: auto; padding: 20px max(16px, env(safe-area-inset-right, 0px)) calc(40px + env(safe-area-inset-bottom, 0px)) 24px; min-width: 0 }
.pagehead { display: flex; align-items: end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px }
.pagehead h1 { font-family: var(--fh); font-size: 22px; font-weight: 800 }
.pagehead .sub { color: var(--mut); font-size: 13px; margin-top: 2px }
.acts { display: flex; gap: 8px; flex-wrap: wrap; align-items: center }
.btn { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 7px 13px; cursor: pointer; font-weight: 600; font-size: 13px; white-space: nowrap }
.btn:hover { border-color: var(--mut) }
.btn.pri { background: var(--ink); color: #fff; border-color: var(--ink) }
:root[data-theme="dark"] .btn.pri { background: var(--yel); color: #141414; border-color: var(--yel) }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn.pri { background: var(--yel); color: #141414; border-color: var(--yel) } }
.btn.ok { background: var(--good); border-color: var(--good); color: #fff }
.btn.no { color: var(--bad) }
.btn.nho { padding: 4px 9px; font-size: 12px }
.btn:disabled { opacity: .45; cursor: not-allowed }

.grid { display: grid; gap: 14px }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; margin-bottom: 14px }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 14px; display: grid; gap: 4px; min-width: 0 }
.kpi .k { font-size: 12px; color: var(--mut); font-weight: 600 }
.kpi .v { font-family: var(--fh); font-size: 22px; font-weight: 800; overflow-wrap: anywhere }
.kpi .d { font-size: 12px; color: var(--mut) }
.kpi.y { border-top: 3px solid var(--yel) }
.two { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 14px }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; min-width: 0; margin-bottom: 14px }
.card > .ch { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--line); flex-wrap: wrap }
.card > .ch h2 { font-size: 14px; font-weight: 700 }
.card > .cb { padding: 12px 14px }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px }
.tbl th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--mut); font-weight: 700; padding: 9px 12px; border-bottom: 1px solid var(--line); background: var(--soft); white-space: nowrap }
.tbl td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: middle }
.tbl tr:last-child td { border-bottom: 0 }
.tbl tr.click { cursor: pointer }
.tbl tr.click:hover td { background: var(--soft) }
.tbl .r { text-align: right }
.tbl tfoot td { font-weight: 800; background: var(--soft) }
.scroll { overflow-x: auto; -webkit-overflow-scrolling: touch }
.chip { display: inline-block; font-size: 11.5px; font-weight: 700; padding: 2px 8px; border-radius: 99px; white-space: nowrap }
.chip.wrap { white-space: normal; line-height: 1.35 }
.c-good { background: var(--good-s); color: var(--good) } .c-warn { background: var(--warn-s); color: var(--warn) } .c-bad { background: var(--bad-s); color: var(--bad) } .c-info { background: var(--info-s); color: var(--info) } .c-mut { background: var(--soft); color: var(--mut) } .c-yel { background: var(--yel-soft); color: #5c4800 }
.list { display: grid }
.li { display: flex; gap: 10px; align-items: start; padding: 10px 14px; border-bottom: 1px solid var(--line) }
.li:last-child { border-bottom: 0 }
.li.click { cursor: pointer } .li.click:hover { background: var(--soft) }
.li .t { font-weight: 600 }
.li .s { font-size: 12.5px; color: var(--mut) }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; margin-top: 6px }
.ai-tag { display: inline-flex; align-items: center; gap: 4px; background: var(--ink); color: var(--yel); font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 99px }
.bar { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; min-width: 60px } .bar i { display: block; height: 100%; background: var(--yel) }
.callout { border-left: 4px solid var(--yel); background: var(--surface); border-radius: 8px; padding: 10px 14px; font-size: 13px; margin-bottom: 14px }
.callout.bad { border-left-color: var(--bad) }
.note { font-size: 12px; color: var(--mut) }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 12px; overflow-x: auto }
.tabs button { border: 0; background: none; padding: 8px 12px; cursor: pointer; font-weight: 600; color: var(--mut); border-bottom: 2px solid transparent; white-space: nowrap }
.tabs button[aria-selected="true"] { color: inherit; border-bottom-color: var(--yel) }
.kenh { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 12px }
.kenh button { font-weight: 600; padding: 7px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--mut); cursor: pointer }
.kenh button[aria-selected="true"] { background: var(--yel); border-color: var(--yel); color: #1b1b1b }
.loc { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px }
.loc input, .loc select { border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; background: var(--surface) }
.steps { display: flex; flex-wrap: wrap; margin: 4px 0 8px }
.step { flex: 1; min-width: 110px; padding: 9px 11px; border: 1px solid var(--line); background: var(--surface); font-size: 12.5px }
.step + .step { border-left: 0 }
.step:first-child { border-radius: 8px 0 0 8px } .step:last-child { border-radius: 0 8px 8px 0 }
.step b { display: block; font-size: 13px }
.step.done { background: var(--good-s) } .step.now { background: var(--yel-soft); color: #3c2f00 } .step.done b::before { content: "✓ " } .step.exc { background: var(--bad-s) }
.tl { display: grid }
.tl > div { border-left: 2px solid var(--line); padding: 0 0 12px 14px; position: relative; font-size: 13px }
.tl > div::before { content: ""; position: absolute; left: -6px; top: 3px; width: 10px; height: 10px; border-radius: 50%; background: var(--good) }
.tl time { color: var(--mut); font-size: 12px; margin-right: 6px }
.snbox { display: flex; gap: 8px; max-width: 560px; flex-wrap: wrap } .snbox input { flex: 1; min-width: 180px; border: 1px solid var(--line); border-radius: 8px; padding: 9px 12px; background: var(--surface) }
.empty { padding: 28px 14px; text-align: center; color: var(--mut) }
.loading { padding: 40px; text-align: center; color: var(--mut) }
.err { padding: 16px; border-radius: 10px; background: var(--bad-s); color: var(--bad) }

/* Modal, form */
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 20 }
.modal { position: fixed; z-index: 21; top: max(4vh, env(safe-area-inset-top, 0px)); left: 50%; transform: translateX(-50%); width: min(760px, calc(100% - 24px)); max-height: 92vh; max-height: 92dvh; overflow: auto; background: var(--surface); border-radius: 12px; box-shadow: 0 20px 50px rgba(0,0,0,.3) }
.modal.rong { width: min(1040px, calc(100% - 24px)) }
.modal .mh { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); z-index: 1 }
.modal .mh h2 { font-size: 16px; font-family: var(--fh) }
.modal .mb { padding: 16px 18px; display: grid; gap: 12px }
.modal .mf { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; padding: 12px 18px; border-top: 1px solid var(--line); position: sticky; bottom: 0; background: var(--surface) }
.fgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px }
label.f { display: grid; gap: 4px; font-size: 12px; color: var(--mut); font-weight: 600 }
label.f.full { grid-column: 1 / -1 }
.f input, .f select, .f textarea, .inp { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: var(--surface); width: 100%; min-width: 0; font-weight: 400; color: var(--text) }
.f textarea { min-height: 70px; resize: vertical }
.inp.so { text-align: right; font-variant-numeric: tabular-nums }
.chk { display: flex; gap: 8px; align-items: center; font-size: 13px }
.x { border: 0; background: var(--soft); width: 32px; height: 32px; border-radius: 8px; cursor: pointer; font-size: 18px; flex: none }
.files { display: grid; gap: 6px }
.file-it { display: flex; gap: 10px; align-items: center; border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; background: var(--surface); min-width: 0; text-decoration: none; color: inherit }
.file-it img { width: 120px; height: 75px; object-fit: cover; border-radius: 6px; flex: none; border: 1px solid var(--line) }
.file-ic { width: 44px; height: 44px; border-radius: 6px; background: var(--soft); display: grid; place-items: center; font-size: 11px; font-weight: 800; color: var(--mut); flex: none }
.file-it span { overflow-wrap: anywhere }
.report { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px }
.toast { position: fixed; bottom: calc(18px + env(safe-area-inset-bottom, 0px)); left: 50%; transform: translateX(-50%); background: #141414; color: #fff; padding: 10px 16px; border-radius: 8px; z-index: 30; font-size: 13px; border-left: 4px solid var(--yel); max-width: calc(100% - 32px) }
.toast.loi { border-left-color: #ff6b6b }
video.quet { width: 100%; max-height: 50vh; background: #000; border-radius: 10px }

/* Đăng nhập */
.login { min-height: 100%; min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; background: #141414 }
.login .box { width: min(420px, 100%); background: var(--surface); border-radius: 14px; padding: 26px 22px; display: grid; gap: 14px; border-top: 4px solid var(--yel) }
.login h1 { font-family: var(--fh); font-size: 20px }
.login .people { display: grid; grid-template-columns: 1fr 1fr; gap: 8px }
.login .people button { text-align: left; border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 10px; cursor: pointer }
.login .people button:hover { border-color: var(--yel) }
.login .people small { display: block; color: var(--mut); font-size: 11.5px }

@media (prefers-reduced-motion: no-preference) { .modal { animation: popm .16s ease-out } @keyframes popm { from { opacity: .4; transform: translate(-50%, 6px) } } }

/* Máy tính bảng */
@media (max-width: 1000px) {
  .two { grid-template-columns: minmax(0, 1fr) }
  .body { grid-template-columns: 64px minmax(0, 1fr) }
  .side .lbl, .side .grp, .side .badge { display: none }
  .side button { justify-content: center }
}
/* Điện thoại: menu trượt từ trái, bảng cuộn ngang */
@media (max-width: 700px) {
  .app { width: 100vw; overflow-x: hidden }
  .top { gap: 8px; padding-left: max(10px, env(safe-area-inset-left, 0px)); padding-right: max(10px, env(safe-area-inset-right, 0px)) }
  .menu-btn { display: block; padding: 4px }
  .brand span, .demo { display: none }
  .search { max-width: none; flex: 1 1 auto; min-width: 0 }
  .who { min-width: 0; flex: 0 1 auto }
  .who select { max-width: 104px; font-size: 12px; padding: 6px 4px }
  .who button { padding: 6px 8px }
  .who span.ten { display: none }
  .body { grid-template-columns: minmax(0, 1fr) }
  nav.side { position: fixed; z-index: 19; top: 0; bottom: 0; left: 0; width: 260px; transform: translateX(-105%); transition: transform .18s ease; box-shadow: 10px 0 30px rgba(0,0,0,.2);
    padding-top: calc(12px + env(safe-area-inset-top, 0px)); padding-bottom: env(safe-area-inset-bottom, 0px) }
  nav.side.mo { transform: none }
  .side .lbl, .side .grp, .side .badge { display: initial }
  .side button { justify-content: flex-start }
  main { padding: 14px 12px calc(40px + env(safe-area-inset-bottom, 0px)) }
  .pagehead h1 { font-size: 19px }
  .kpis { grid-template-columns: 1fr 1fr; gap: 8px }
  .kpi { padding: 10px } .kpi .v { font-size: 17px }
  .modal { top: 0; width: 100%; max-height: 100%; max-height: 100dvh; height: 100dvh; border-radius: 0; padding-top: env(safe-area-inset-top, 0px) }
  .modal .mf { padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px)) }
  .step { min-width: 50% }
}

/* iPhone/iPad: ô nhập dưới 16px làm Safari tự phóng to cả trang khi gõ (app đã cài thì không thu nhỏ lại được) */
@supports (-webkit-touch-callout: none) {
  input, select, textarea, .who select { font-size: 16px !important }
}
