:root {
  color-scheme: light;
  --brand: #d42a1f;
  --brand-dark: #a91f17;
  --brand-soft: #fdf1f0;
  --brand-line: #f3c9c5;
  --ink: #1d1d1f;
  --ink-2: #4b4b50;
  --ink-3: #7a7a80;
  --line: #e3e3e6;
  --bg: #f6f6f7;
  --card: #ffffff;
  --ok: #1e7b34;
  --ok-soft: #e7f4ea;
  --warn: #b45309;
  --warn-soft: #fdf3e6;
  --bad: #c62828;
  --bad-soft: #fdecec;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .06), 0 2px 8px rgba(0, 0, 0, .05);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font-size: 15px; line-height: 1.45; -webkit-text-size-adjust: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand-dark); }
.loading { padding: 40px 16px; text-align: center; color: var(--ink-3); }

/* ---------- khung trang */
.top {
  position: sticky; top: 0; z-index: 20;
  background: var(--brand); color: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .15);
}
.top-row { display: flex; align-items: center; gap: 12px; padding: 10px 16px; max-width: 1180px; margin: 0 auto; }
.brand { font-weight: 800; letter-spacing: .3px; white-space: nowrap; }
.brand small { display: block; font-weight: 500; opacity: .85; font-size: 11px; letter-spacing: 0; }
.week {
  display: flex; align-items: center; gap: 4px; margin: 0 auto;
  background: rgba(255, 255, 255, .14); border-radius: 999px; padding: 3px;
}
.week button { border: 0; background: transparent; color: #fff; width: 34px; height: 34px; border-radius: 50%; cursor: pointer; font-size: 18px; }
.week button:hover { background: rgba(255, 255, 255, .18); }
.week .label { text-align: center; min-width: 150px; cursor: pointer; }
.week .label b { display: block; font-size: 16px; }
.week .label span { font-size: 12px; opacity: .9; }
.user { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; background: #fff; color: var(--brand);
  display: grid; place-items: center; font-weight: 800; border: 0; cursor: pointer;
}
.nav { display: flex; gap: 2px; overflow-x: auto; max-width: 1180px; margin: 0 auto; padding: 0 10px; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a {
  color: #fff; text-decoration: none; padding: 9px 12px 10px; white-space: nowrap; opacity: .82;
  border-bottom: 3px solid transparent; font-size: 14px;
}
.nav a.on { opacity: 1; border-bottom-color: #fff; font-weight: 700; }
.nav a .n { display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 4px; border-radius: 9px; background: rgba(255, 255, 255, .25); font-size: 11px; text-align: center; }

main { max-width: 1180px; margin: 0 auto; padding: 16px; }
.head { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-start; justify-content: space-between; margin-bottom: 12px; }
.head h1 { font-size: 20px; margin: 0 0 2px; }
.head p { margin: 0; color: var(--ink-2); font-size: 13px; max-width: 720px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- nút & form */
.btn {
  border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 9px 14px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px; text-decoration: none; color: var(--ink);
}
.btn:hover { border-color: #c9c9ce; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.danger { color: var(--bad); }
.btn.small { padding: 5px 10px; font-size: 13px; border-radius: 8px; }
.btn:disabled { opacity: .55; cursor: default; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #fff; }
.seg button { border: 0; background: transparent; padding: 7px 12px; cursor: pointer; font-size: 13px; }
.seg button.on { background: var(--ink); color: #fff; }

.f { display: block; margin-bottom: 12px; }
.f > span { display: block; font-size: 13px; font-weight: 600; color: var(--ink-2); margin-bottom: 4px; }
.f > span em { color: var(--bad); font-style: normal; }
.f small { display: block; color: var(--ink-3); font-size: 12px; margin-top: 3px; }
input[type=text], input[type=number], input[type=password], input[type=date], select, textarea {
  width: 100%; border: 1px solid #cfcfd4; border-radius: 9px; padding: 9px 11px; background: #fff; font-size: 16px;
}
textarea { resize: vertical; min-height: 44px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-line); border-color: var(--brand); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.check { display: flex; align-items: center; gap: 8px; margin: 4px 0 12px; color: var(--ink-2); }
.check input { width: 18px; height: 18px; }

/* ---------- thẻ mục */
.group-title { display: flex; align-items: baseline; gap: 10px; margin: 18px 0 8px; }
.group-title h2 { font-size: 16px; margin: 0; }
.group-title span { color: var(--ink-3); font-size: 13px; }
.list { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 12px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; min-width: 0;
}
.card.mine { border-left: 4px solid var(--brand); }
.card.hidden { opacity: .6; }
.card .t { font-weight: 700; font-size: 15px; overflow-wrap: anywhere; }
.card .meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; color: var(--ink-3); font-size: 12px; }
.tag { display: inline-block; padding: 1px 8px; border-radius: 999px; background: #eee; color: var(--ink-2); font-size: 12px; }
.tag.ok { background: var(--ok-soft); color: var(--ok); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.bad { background: var(--bad-soft); color: var(--bad); }
.tag.who { background: var(--brand-soft); color: var(--brand-dark); }
.kv { font-size: 13.5px; color: var(--ink); white-space: pre-wrap; overflow-wrap: anywhere; }
.kv b { color: var(--ink-3); font-weight: 600; }
.kv .ok { color: var(--ok); font-weight: 700; }
.kv .bad { color: var(--bad); font-weight: 700; }
.thumbs { display: flex; gap: 6px; flex-wrap: wrap; }
.thumbs img { width: 76px; height: 76px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); cursor: zoom-in; background: #f0f0f0; }
.card .foot { display: flex; gap: 6px; margin-top: 4px; flex-wrap: wrap; }
.empty {
  border: 1px dashed #cfcfd4; border-radius: var(--radius); padding: 22px; text-align: center; color: var(--ink-3); background: #fff;
}

/* ---------- hộp thoại */
dialog {
  border: 0; border-radius: 16px; padding: 0; width: min(720px, calc(100vw - 24px)); max-width: calc(100vw - 24px); max-height: calc(100vh - 24px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, .3);
}
dialog::backdrop { background: rgba(20, 20, 25, .45); }
.dlg { display: flex; flex-direction: column; max-height: calc(100vh - 24px); }
.dlg header { padding: 14px 18px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.dlg header h3 { margin: 0; font-size: 17px; flex: 1; }
.dlg .body { padding: 16px 18px 6px; overflow: auto; }
.dlg footer { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; align-items: center; flex-wrap: wrap; }
.dlg footer .msg { margin-right: auto; color: var(--bad); font-size: 13px; }
.x { border: 0; background: transparent; font-size: 22px; cursor: pointer; color: var(--ink-3); width: 36px; height: 36px; border-radius: 50%; }
.x:hover { background: #f0f0f0; }

.imgzone { border: 1.5px dashed #cfcfd4; border-radius: 12px; padding: 10px; background: #fafafa; }
.imgzone.drag { border-color: var(--brand); background: var(--brand-soft); }
.imgzone .pics { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.pic { position: relative; }
.pic img { width: 96px; height: 96px; object-fit: cover; border-radius: 9px; border: 1px solid var(--line); display: block; }
.pic button {
  position: absolute; top: -7px; right: -7px; width: 24px; height: 24px; border-radius: 50%; border: 0;
  background: var(--ink); color: #fff; cursor: pointer; font-size: 14px; line-height: 24px;
}
.pic.new img { outline: 2px solid var(--ok); }
.imgzone .hint { font-size: 12px; color: var(--ink-3); margin-left: 6px; }

.viewer { background: #000; width: min(1100px, 96vw); }
.viewer img { display: block; max-width: 100%; max-height: 86vh; margin: 0 auto; }

/* ---------- bảng */
.table-wrap { overflow-x: auto; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); }
table.t { border-collapse: collapse; width: 100%; font-size: 14px; }
table.t th, table.t td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: center; white-space: nowrap; }
table.t th { background: #fafafa; font-size: 12px; color: var(--ink-2); font-weight: 700; position: sticky; top: 0; }
table.t td:first-child, table.t th:first-child { text-align: left; }
table.t td.zero { color: #c4c4c8; }
table.t td.miss { background: var(--warn-soft); color: var(--warn); font-weight: 700; }
table.t input, table.t select { font-size: 14px; padding: 6px 8px; }

.panel { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; box-shadow: var(--shadow); }
.panel h2 { font-size: 16px; margin: 0 0 12px; }
.note { background: var(--brand-soft); border: 1px solid var(--brand-line); border-radius: 10px; padding: 10px 12px; font-size: 13px; color: var(--ink-2); }
code { background: #f1f1f3; padding: 1px 5px; border-radius: 5px; font-size: 12.5px; }

/* ---------- đăng nhập */
.login { max-width: 440px; margin: 7vh auto; padding: 0 16px; }
.login .box { background: #fff; border-radius: 18px; box-shadow: var(--shadow); padding: 22px; border: 1px solid var(--line); }
.login h1 { font-size: 22px; margin: 0 0 4px; }
.login .sub { color: var(--ink-3); margin: 0 0 18px; font-size: 14px; }
.people { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 14px; }
.people button {
  border: 1px solid var(--line); background: #fff; border-radius: 12px; padding: 12px 10px; cursor: pointer; text-align: left;
}
.people button b { display: block; }
.people button span { font-size: 12px; color: var(--ink-3); }
.people button.on { border-color: var(--brand); background: var(--brand-soft); box-shadow: 0 0 0 2px var(--brand-line); }
.pin { letter-spacing: 6px; text-align: center; font-size: 22px !important; }

#toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%) translateY(20px); opacity: 0; pointer-events: none;
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; transition: .2s; z-index: 100; max-width: 92vw;
}
#toast.on { opacity: 1; transform: translateX(-50%); }
#toast.bad { background: var(--bad); }

/* ---------- phần A–D, chip mục con, ô nhập nhanh */
.nav a .pc { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 6px; background: rgba(255, 255, 255, .22); font-size: 12px; }
.nav a.on .pc { background: #fff; color: var(--brand); }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin: 0 0 14px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 13px; border-radius: 999px; text-decoration: none;
  background: #fff; border: 1px solid var(--line); color: var(--ink); font-size: 14px;
}
.chip b { color: var(--brand); }
.chip.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.chip.on b { color: #fff; }
.chip .n { min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--brand-soft); color: var(--brand-dark); font-size: 11px; text-align: center; }
.chip.on .n { background: rgba(255, 255, 255, .25); color: #fff; }
.grow { flex: 1; }
.quick { border-top: 3px solid var(--brand); }
.quick-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.quick-head h2 { margin: 0; flex: 1; }
.quick-foot { display: flex; align-items: center; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.quick-foot .msg { margin-right: auto; color: var(--bad); font-size: 13px; }
.inline { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); font-weight: 600; }
.inline select { width: auto; font-size: 14px; padding: 6px 8px; }
.link { border: 0; background: none; color: var(--brand-dark); cursor: pointer; padding: 2px 0 10px; font-size: 13px; font-weight: 600; text-align: left; }
.more { border-left: 3px solid var(--brand-line); padding-left: 12px; margin-bottom: 8px; }
.group-title .seg { margin-left: 4px; }
.pick { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-2); cursor: pointer; user-select: none; }
.pick input { width: 18px; height: 18px; accent-color: var(--ok); }

/* ---------- bảng 6 ngày (C1, D) */
.wk { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.wk.k-week .wk-h, .wk.k-week .wk-r { grid-template-columns: 112px minmax(140px, 1.1fr) 1.5fr 1.5fr 150px 92px; }
.wk.k-plan .wk-h, .wk.k-plan .wk-r { grid-template-columns: 112px minmax(160px, 1fr) 2fr 92px; }
.wk-h, .wk-r { display: grid; gap: 0; }
.wk-h { background: #fafafa; border-bottom: 1px solid var(--line); font-size: 12px; font-weight: 700; color: var(--ink-2); }
.wk-h > div { padding: 8px 8px; }
.wk-r { border-bottom: 1px solid var(--line); align-items: start; }
.wk-r.alt { background: #fcfcfd; }
.wk-r.hidden { opacity: .55; }
.wk-r.bad { background: var(--warn-soft); }
.wk-r .c { padding: 5px 4px; min-width: 0; }
.wk-r .c-day { padding-left: 8px; }
.wk-r .c-day select { border: 0; background: transparent; padding: 6px 2px; font-weight: 700; font-size: 14px; }
.wk-r .c-day small { display: block; color: var(--ink-3); font-size: 12px; padding-left: 3px; }
.wk-r input, .wk-r textarea, .wk-r select { font-size: 14px; padding: 7px 8px; border-color: transparent; background: transparent; }
.wk-r input:hover, .wk-r textarea:hover, .wk-r .c:not(.c-day) select:hover { border-color: #dcdce0; }
.wk-r input:focus, .wk-r textarea:focus, .wk-r select:focus { background: #fff; border-color: var(--brand); }
.wk-r textarea { resize: none; overflow: hidden; min-height: 36px; line-height: 1.4; }
.wk-r .c-act { display: flex; align-items: center; gap: 2px; padding-top: 8px; }
.wk-r .ml { display: none; }
.wk-r .row-note { grid-column: 1 / -1; color: var(--warn); font-size: 12px; padding: 0 10px; }
.wk-r .row-note:empty { display: none; }
.ib { border: 0; background: transparent; width: 28px; height: 28px; border-radius: 8px; cursor: pointer; color: var(--ink-3); font-size: 16px; }
.ib:hover { background: #f0f0f2; color: var(--ink); }
.st { width: 18px; text-align: center; font-size: 13px; font-weight: 700; }
.st.ok { color: var(--ok); }
.st.busy { color: var(--ink-3); }
.st.warn, .st.err { color: var(--warn); }
.wk-foot { display: flex; align-items: center; gap: 12px; margin: 10px 0 20px; flex-wrap: wrap; }
.wk-status { color: var(--ink-3); font-size: 13px; }
table.t.wrap td { white-space: pre-wrap; text-align: left; vertical-align: top; min-width: 90px; }
table.t.wrap th { text-align: left; }
table.t tr.dim td { opacity: .5; }

/* ---------- duyệt báo cáo */
.part-h { font-size: 15px; margin: 20px 0 8px; color: var(--brand-dark); letter-spacing: .3px; }
.review { padding: 0; overflow: hidden; }
.review-h { display: flex; align-items: center; gap: 8px; padding: 10px 14px; background: #fafafa; border-bottom: 1px solid var(--line); }
.rv { display: flex; align-items: flex-start; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.rv:last-child { border-bottom: 0; }
.rv .pick { padding-top: 2px; font-size: 0; }
.rv .pick input { width: 20px; height: 20px; }
.rv.off .rv-main { opacity: .5; }
.rv-main { flex: 1; min-width: 0; cursor: pointer; }
.rv-t { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; font-weight: 600; }
.rv-d { color: var(--ink-2); font-size: 13px; margin-top: 3px; overflow-wrap: anywhere; }
.rv-d .ok, .rv-t .ok, table.t .ok { color: var(--ok); font-weight: 700; }
.rv-d .bad, .rv-t .bad, table.t .bad { color: var(--bad); font-weight: 700; }
.sum { font-size: 14px; color: var(--ok); }

@media (max-width: 640px) {
  .wk-h { display: none; }
  .wk.k-week .wk-r, .wk.k-plan .wk-r { grid-template-columns: 1fr 1fr; padding: 6px 4px; }
  .wk-r .c-day { display: flex; align-items: baseline; gap: 6px; }
  .wk-r .c-act { justify-content: flex-end; padding-top: 4px; grid-row: 1; grid-column: 2; }
  .wk-r .c-cong_viec, .wk-r .c-ke_hoach, .wk-r .c-ket_qua { grid-column: 1 / -1; }
  .wk-r .ml { display: block; font-size: 11px; color: var(--ink-3); font-weight: 600; padding: 0 8px; }
  .wk-r input, .wk-r textarea, .wk-r .c:not(.c-day) select { border-color: #e3e3e6; background: #fff; font-size: 16px; }
  .quick-head .inline { width: 100%; }
}

@media (max-width: 640px) {
  .top-row { flex-wrap: wrap; padding: 8px 12px; gap: 8px; }
  .brand small { display: none; }
  .week { order: 3; width: 100%; justify-content: space-between; }
  .user .name { display: none; }
  .user { margin-left: auto; }
  main { padding: 12px; }
  .list { grid-template-columns: 1fr; }
  .grid2 { grid-template-columns: 1fr 1fr; }
  /* trình duyệt mặc định giới hạn max-width của dialog → bỏ để phủ kín màn hình điện thoại */
  dialog { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; border-radius: 0; margin: 0; }
  .dlg { max-height: 100dvh; height: 100dvh; }
  dialog.viewer { height: auto; }
}
