/* Hunter Ship 0.1: theo khung giao diện Hunter Dự án (Barlow, đỏ #ee3444). */
:root {
  --red: #ee3444; --blue: #2b4c7e; --ink: #141414; --bg: #f5f5f5; --muted: #6b6b6b; --line: #e4e4e4; --card: #fff;
  --green: #1f8a4c; --green-bg: #e7f5ec; --red-bg: #fdecee; --amber-bg: #fbf3dc; --blue-bg: #eaf0f7;
  --late: #b22130; --amber: #8a5a00; --r: 6px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 16px/1.45 Barlow, system-ui, sans-serif; color: var(--ink); background: var(--bg); hyphens: none; overflow-wrap: break-word; }
h1, h2, h3, h4, p { margin: 0; }
h1, h2, h3 { line-height: 1.2; text-wrap: balance; }
p, li, td { text-wrap: pretty; }
a { color: var(--blue); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }
.nw { white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.spread { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; }
.stack { display: grid; gap: 16px; }
.solo { padding: 48px 24px; text-align: center; }
.empty { color: var(--muted); padding: 16px 0; }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: 13.5px; }

/* Thanh trên */
.top { position: sticky; top: 0; z-index: 30; height: 72px; background: #fff; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 0 28px; }
.brand { display: flex; align-items: center; gap: 18px; text-decoration: none; color: var(--ink); white-space: nowrap; }
.brand img { height: 54px; width: auto; display: block; }
.brand span { border-left: 1px solid var(--line); padding-left: 18px; font-weight: 600; font-size: 19px; }
.who { display: flex; align-items: center; gap: 10px; min-width: 0; font-size: 14px; }
.who .name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 220px; }
.avatar { flex: none; display: grid; place-items: center; width: 36px; height: 36px; background: #e9edf3; border-radius: 50%; color: var(--blue); font-weight: 700; font-size: 14px; }

/* Bố cục workspace */
.layout { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: calc(100vh - 72px); }
.sidebar { padding: 24px 14px; border-right: 1px solid var(--line); background: #fafafa; }
.ws-name { padding: 0 12px 16px; display: grid; gap: 2px; }
.ws-name b { font-size: 18px; line-height: 1.25; }
.ws-name a { font-size: 13px; text-decoration: none; }
.nav { display: grid; gap: 4px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 11px 12px; border-radius: 4px; color: #4a4a4a; text-decoration: none; font-weight: 500; white-space: nowrap; }
.nav a:hover { background: #f0f0f0; }
.nav a.active { background: var(--red-bg); color: var(--late); font-weight: 700; box-shadow: inset 3px 0 var(--red); }
.nav .count { margin-left: auto; font-size: 12px; background: var(--red); color: #fff; padding: 0 6px; border-radius: 3px; line-height: 18px; }
.side-note { margin: 28px 12px 0; padding-top: 16px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.main { min-width: 0; padding: 28px 34px 40px; max-width: 1280px; }
.page-head { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; justify-content: space-between; margin-bottom: 20px; }
.page-head h1 { font-size: 28px; font-weight: 700; }
.page-head p { color: var(--muted); margin-top: 4px; max-width: 70ch; }

/* Khối */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); }
.card > .hd { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; }
.card > .hd h2 { font-size: 18px; font-weight: 700; }
.card > .bd { padding: 16px 20px; }
.card > .bd.flush { padding: 0; }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: var(--r); padding: 18px 20px; display: grid; gap: 4px; align-content: start; }
.kpi .lb { font-size: 13px; font-weight: 600; color: var(--muted); }
.kpi .v { font-size: 28px; font-weight: 700; line-height: 1.15; white-space: nowrap; font-variant-numeric: tabular-nums; }
.kpi .sub { font-size: 14px; color: var(--muted); }
.kpi.risk .v { color: var(--late); }
.kpi.good .v { color: var(--green); }
.grid2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.alerts { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.alert { display: grid; gap: 4px; align-content: start; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--r); background: #fff; text-decoration: none; color: var(--ink); }
.alert:hover { border-color: #c4c4c4; }
.alert b { font-size: 15px; }
.alert .n { font-size: 24px; font-weight: 700; white-space: nowrap; }
.alert.hot { border-color: #f3b6bc; background: #fffafa; }
.alert.hot .n { color: var(--late); }
.alert.zero { opacity: .6; }

/* Nút, ô nhập */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 8px 16px; border-radius: 4px; border: 1px solid var(--line); background: #fff; font-weight: 600; white-space: nowrap; text-decoration: none; color: var(--ink); font-size: 15px; }
.btn:hover { border-color: #c4c4c4; }
.btn.primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn.primary:hover { background: #d92a3a; }
.btn.sm { min-height: 34px; padding: 4px 12px; font-size: 14px; }
.btn:disabled { opacity: .55; cursor: default; }
.link { background: none; border: 0; padding: 0; color: var(--blue); text-decoration: underline; font-weight: 600; cursor: pointer; text-align: left; }
input[type=text], input[type=number], input[type=search], input[type=email], input[type=password], select, textarea { border: 1px solid #cfcfcf; border-radius: 4px; padding: 8px 10px; background: #fff; min-height: 40px; max-width: 100%; }
textarea { width: 100%; min-height: 160px; font-family: ui-monospace, Consolas, monospace; font-size: 13.5px; }
label.f { display: grid; gap: 4px; font-size: 14px; font-weight: 600; }
label.f small { font-weight: 400; color: var(--muted); }
label.f input, label.f select { width: 100%; }
.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.filters input[type=search] { min-width: 220px; flex: 1 1 220px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 4px; overflow: hidden; background: #fff; }
.seg button { border: 0; background: none; padding: 7px 14px; font-weight: 600; white-space: nowrap; }
.seg button.on { background: var(--ink); color: #fff; }

/* Bảng */
.tbl-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 15px; }
.tbl th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 10px 12px; border-bottom: 2px solid var(--ink); white-space: nowrap; }
.tbl td { padding: 11px 12px; border-bottom: 1px solid #efefef; vertical-align: top; white-space: nowrap; }
.tbl td .small { white-space: normal; min-width: 140px; }
.tbl tr.click { cursor: pointer; }
.tbl tr.click:hover td { background: #fafafa; }
.tbl th.num, .tbl td.num { text-align: right; }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; padding: 12px 20px; }

/* Nhãn */
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 99px; font-size: 12.5px; font-weight: 600; white-space: nowrap; background: #efefef; color: #444; }
.chip.ok { background: var(--green-bg); color: var(--green); }
.chip.bad { background: var(--red-bg); color: var(--late); }
.chip.warn { background: var(--amber-bg); color: var(--amber); }
.chip.info { background: var(--blue-bg); color: var(--blue); }

/* Biểu đồ */
.chart svg { width: 100%; height: auto; display: block; }
.legend { display: flex; flex-wrap: wrap; gap: 16px; font-size: 13px; color: var(--muted); margin-top: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
.bar { height: 8px; background: #eee; border-radius: 4px; overflow: hidden; min-width: 80px; }
.bar > i { display: block; height: 100%; background: var(--green); }

/* Dòng thời gian */
.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; }
.timeline li { display: grid; grid-template-columns: 130px minmax(0, 1fr); gap: 12px; padding: 10px 0; border-bottom: 1px solid #f0f0f0; font-size: 14.5px; }
.timeline .t { color: var(--muted); white-space: nowrap; }

/* Tài khoản hãng */
.accounts { display: grid; gap: 12px; }
.acc { border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px; display: grid; gap: 10px; background: #fff; }
.acc .hook { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; background: #f7f7f7; border-radius: 4px; padding: 8px 10px; }
.acc .hook code { flex: 1 1 260px; min-width: 0; overflow-wrap: anywhere; font-size: 13px; }
.steps { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.step { background: #fff; border: 1px solid var(--line); border-radius: var(--r); padding: 18px 20px; display: grid; gap: 8px; align-content: start; }
.step .no { width: 30px; height: 30px; border-radius: 50%; background: var(--red); color: #fff; display: grid; place-items: center; font-weight: 700; }
.ws-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.ws-card { display: grid; gap: 6px; padding: 18px 20px; border: 1px solid var(--line); border-radius: var(--r); background: #fff; text-decoration: none; color: var(--ink); }
.ws-card:hover { border-color: #c4c4c4; }
.ws-card b { font-size: 18px; }
.home { max-width: 1100px; margin: 0 auto; padding: 32px 24px; display: grid; gap: 20px; }

/* Hộp thoại */
dialog { border: 1px solid var(--line); border-radius: 8px; padding: 0; width: min(640px, calc(100vw - 24px)); max-height: calc(100vh - 32px); color: var(--ink); }
dialog.wide { width: min(980px, calc(100vw - 24px)); }
dialog::backdrop { background: rgba(20, 20, 20, .45); }
dialog form { padding: 24px 28px; display: grid; gap: 14px; }
dialog h3 { font-size: 21px; }
.dlg-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; padding-top: 4px; }
.kv { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 6px 14px; font-size: 15px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.note { background: var(--blue-bg); border-radius: 4px; padding: 10px 14px; font-size: 14px; }
.note.warn { background: var(--amber-bg); }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 6px; z-index: 60; max-width: calc(100vw - 32px); }
.toast.err { background: var(--late); }

@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid2 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 860px) {
  .top { padding: 0 16px; height: 64px; }
  .brand img { height: 44px; }
  .brand span { padding-left: 12px; font-size: 17px; }
  .who .name { display: none; }
  .layout { grid-template-columns: minmax(0, 1fr); }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--line); padding: 12px 12px 0; position: sticky; top: 64px; z-index: 20; }
  .ws-name { padding: 0 4px 8px; }
  .ws-name b { font-size: 16px; }
  .nav { display: flex; overflow-x: auto; gap: 4px; padding-bottom: 8px; scrollbar-width: none; }
  .nav a { padding: 9px 12px; }
  .nav a.active { box-shadow: inset 0 -3px var(--red); }
  .side-note { display: none; }
  .main { padding: 20px 16px 32px; }
  .page-head h1 { font-size: 24px; }
  .steps { grid-template-columns: minmax(0, 1fr); }
  .timeline li { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .kv { grid-template-columns: minmax(0, 1fr); gap: 0 0; }
  .kv dd { margin-bottom: 8px; }
  dialog form { padding: 20px 18px; }
}
@media (max-width: 420px) {
  .kpis { gap: 10px; }
  .kpi { padding: 14px; }
  .kpi .v { font-size: 22px; }
}
.mt { margin-top: 16px; }
.empty.in { padding: 16px 20px; }
.h3s { font-size: 16px; }
.h1s { font-size: 26px; }
.narrow { max-width: 560px; }
