/* ========== Showroom Trà Hùng Phát — phong cách Matcha ========== */
:root {
  --bg: #F4F1E8;
  --card: #FFFDF7;
  --card-2: #F7F4EA;
  --line: #E6E1D2;
  --text: #1F271B;
  --muted: #6E7766;
  --matcha: #78A04F;
  --matcha-deep: #3F5F2E;
  --leaf: #DDE7C7;
  --leaf-2: #EEF3E2;
  --danger: #B0412F;
  --danger-bg: #F6E3DE;
  --warn: #A6741B;
  --warn-bg: #F6ECD4;
  --mark: #F3E39A;
  --shadow: 0 1px 2px rgba(47, 74, 36, .05), 0 6px 24px rgba(47, 74, 36, .07);
  --radius: 20px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --top: 64px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111510; --card: #1A2017; --card-2: #20271C; --line: #2C3527; --text: #E9EEDF; --muted: #93A086;
    --matcha: #8FB46A; --matcha-deep: #B8D08A; --leaf: #2E3B25; --leaf-2: #232C1D;
    --danger: #E07A66; --danger-bg: #3A2420; --warn: #E0B25E; --warn-bg: #352C1A; --mark: #6B5A1C;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 24px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
  .logo, .login-logo { filter: drop-shadow(0 0 1px rgba(255,255,255,.35)); }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font-family: 'Be Vietnam Pro', system-ui, -apple-system, 'Segoe UI', sans-serif; font-size: 15px; line-height: 1.55; min-height: 100dvh; -webkit-font-smoothing: antialiased; }
body.noscroll { overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--matcha-deep); }
h1, h2, h3 { letter-spacing: -.01em; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.mono { font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace; }
.grow { flex: 1; min-width: 0; }
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.ic { width: 18px; height: 18px; flex: none; }
kbd { font: 600 11px ui-monospace, Consolas, monospace; padding: 2px 6px; border-radius: 6px; border: 1px solid var(--line); background: var(--card-2); color: var(--muted); }
mark { background: var(--mark); color: inherit; border-radius: 3px; padding: 0 1px; }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes pop { 0% { transform: scale(.6); } 60% { transform: scale(1.15); } 100% { transform: scale(1); } }
@keyframes rot { to { transform: rotate(360deg); } }

/* ---------- Thanh trên: logo + tìm kiếm luôn hiện ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in srgb, var(--bg) 86%, transparent); backdrop-filter: saturate(1.4) blur(14px); -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
  padding-top: env(safe-area-inset-top);
}
.topbar-in { max-width: 1180px; margin: 0 auto; display: flex; align-items: center; gap: 10px; padding: 10px 16px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); flex: none; min-width: 0; }
.brand .logo { height: 34px; width: auto; display: block; }
.brand span { font-weight: 700; font-size: 15px; white-space: nowrap; max-width: 200px; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 1000px) { .brand span { display: none; } }
@media (max-width: 520px) { .brand .logo { height: 28px; } .topbar-in { gap: 8px; padding: 8px 12px; } }

.searchbox { position: relative; flex: 1; max-width: 560px; margin: 0 auto; }
.searchbox input {
  width: 100%; height: 42px; padding: 0 70px 0 40px; border-radius: 14px; border: 1.5px solid var(--line);
  background: var(--card); outline: none; font-size: 15px; transition: border-color .2s, box-shadow .2s;
}
.searchbox input::-webkit-search-cancel-button { display: none; }
.searchbox input:focus { border-color: var(--matcha); box-shadow: 0 0 0 4px color-mix(in srgb, var(--matcha) 18%, transparent); }
.searchbox .s-ic { position: absolute; left: 13px; top: 12px; color: var(--muted); pointer-events: none; }
.searchbox .s-kbd { position: absolute; right: 10px; top: 11px; pointer-events: none; }
.searchbox input:focus ~ .s-kbd, .searchbox input:not(:placeholder-shown) ~ .s-kbd { display: none; }
.searchbox .s-clear { position: absolute; right: 6px; top: 5px; width: 32px; height: 32px; border: 0; border-radius: 10px; background: none; color: var(--muted); display: grid; place-items: center; }
@media (max-width: 520px) { .searchbox .s-kbd { display: none; } .searchbox input { font-size: 16px; padding-right: 40px; } }

.icon-btn {
  position: relative; width: 40px; height: 40px; border-radius: 12px; border: 0; background: transparent; color: var(--text);
  display: grid; place-items: center; flex: none; transition: background .2s, transform .15s var(--ease);
}
.icon-btn:hover { background: var(--card-2); }
.icon-btn:active { transform: scale(.92); }
.icon-btn:disabled { opacity: .35; pointer-events: none; }
.icon-btn .ic { width: 20px; height: 20px; }
.badge-dot { position: absolute; top: 3px; right: 2px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--danger); color: #fff; font: 700 10.5px/18px system-ui; font-style: normal; text-align: center; box-shadow: 0 0 0 2px var(--bg); animation: pop .35s var(--ease); }
.me-btn { padding: 0; }

/* Tab trên máy tính, thanh dưới trên điện thoại */
.tabs { max-width: 1180px; margin: 0 auto; display: flex; gap: 4px; padding: 0 16px 8px; }
.tabs a, .tabbar a { display: flex; align-items: center; gap: 7px; text-decoration: none; color: var(--muted); font-weight: 600; font-size: 14px; border-radius: 12px; transition: background .25s, color .25s; }
.tabs a { padding: 7px 14px; }
.tabs a:hover { background: var(--card-2); color: var(--text); }
.tabs a.active { background: var(--leaf); color: var(--matcha-deep); }
.tabbar { display: none; }
@media (max-width: 760px) {
  .tabs { display: none; }
  .tabbar {
    display: flex; position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(10px + env(safe-area-inset-bottom)); z-index: 30;
    gap: 2px; padding: 5px; border-radius: 22px; width: max-content; max-width: calc(100% - 20px);
    background: color-mix(in srgb, var(--card) 90%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
    box-shadow: 0 10px 34px rgba(47, 74, 36, .18); border: 1px solid var(--line);
    transition: transform .3s var(--ease), opacity .25s;
  }
  .tabbar a { flex-direction: column; gap: 2px; padding: 6px 12px; font-size: 10.5px; min-width: 62px; border-radius: 17px; }
  .tabbar a .ic { width: 22px; height: 22px; }
  .tabbar a.active { background: var(--leaf); color: var(--matcha-deep); }
  body.searching .tabbar { transform: translate(-50%, 140%); opacity: 0; }
}
@media (max-width: 380px) { .tabbar a { min-width: 0; padding: 6px 9px; } }

/* ---------- Kết quả tìm kiếm ---------- */
.search-panel {
  position: absolute; left: 50%; transform: translateX(-50%); top: calc(100% - 4px); width: min(640px, calc(100% - 24px));
  max-height: min(70dvh, 560px); overflow-y: auto; overscroll-behavior: contain;
  background: var(--card); border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 18px 50px rgba(30, 45, 20, .2);
  padding: 6px; animation: spIn .22s var(--ease);
}
@keyframes spIn { from { opacity: 0; transform: translate(-50%, -6px); } }
@media (max-width: 760px) { .search-panel { max-height: calc(100dvh - 90px); } }
.sp-empty { padding: 18px 14px; color: var(--muted); font-size: 14px; }
.sp-group { padding: 10px 12px 4px; font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.sp-group small { font-weight: 600; background: var(--card-2); padding: 1px 7px; border-radius: 999px; margin-left: 4px; }
.sr { display: flex; gap: 12px; align-items: flex-start; width: 100%; text-align: left; border: 0; background: none; padding: 10px 12px; border-radius: 12px; transition: background .15s; }
.sr.sel, .sr:hover { background: var(--leaf-2); }
.sr-ic { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; flex: none; }
.sr-ic.book { background: var(--warn-bg); color: var(--warn); }
.sr-ic.check { background: var(--leaf); color: var(--matcha-deep); }
.sr-main { min-width: 0; display: flex; flex-direction: column; gap: 1px; font-size: 14px; }
.sr-main small { color: var(--muted); font-size: 12px; }
.sr-h { font-weight: 700; }
.sr-snip { color: var(--text); opacity: .88; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* ---------- Khung trang ---------- */
.shell { max-width: 1180px; margin: 0 auto; padding: 18px 16px calc(100px + env(safe-area-inset-bottom)); }
.view { animation: viewIn .38s var(--ease) both; }
@keyframes viewIn { from { opacity: 0; transform: translateY(10px); } }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 4px 0 16px; }
.page-head h1 { margin: 0; font-size: 24px; }
.page-head p { margin: 2px 0 0; }
.back { display: inline-flex; align-items: center; gap: 4px; text-decoration: none; font-weight: 600; font-size: 14px; margin-bottom: 10px; color: var(--muted); }
.back:hover { color: var(--matcha-deep); }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 14px; border: 1px solid color-mix(in srgb, var(--line) 55%, transparent); }
.card.pad0 { padding: 0; overflow: hidden; }
.card h3 { margin: 0 0 12px; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.card h3 + h3, .card .row + h3, .card .field + h3, .card .grid2 + h3, .card .radio-cards + p + .grid2 + h3 { margin-top: 18px; }
form.card h3:not(:first-child) { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 18px 4px 10px; }
.section-title h2 { margin: 0; font-size: 16px; }
.empty { text-align: center; color: var(--muted); padding: 30px 12px; }
.empty .big { font-size: 34px; margin-bottom: 6px; }
.empty.small { padding: 18px; font-size: 14px; }
.tip { display: flex; align-items: center; gap: 10px; padding: 11px 14px; border-radius: 14px; background: var(--leaf-2); color: var(--matcha-deep); font-size: 13.5px; margin-bottom: 14px; animation: fadeIn .3s; }
.tip span { flex: 1; }
.skeleton { height: 54px; border-radius: 12px; background: linear-gradient(90deg, var(--card-2), var(--leaf-2), var(--card-2)); background-size: 200% 100%; animation: shimmer 1.2s linear infinite; margin-bottom: 8px; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- Nút ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 0; border-radius: 13px; padding: 10px 16px;
  font-weight: 600; font-size: 14.5px; background: var(--card-2); color: var(--text); text-decoration: none; white-space: nowrap;
  border: 1px solid color-mix(in srgb, var(--line) 80%, transparent);
  transition: transform .15s var(--ease), background .2s, opacity .2s, box-shadow .2s;
}
.btn:hover { background: var(--leaf-2); }
.btn:active { transform: scale(.97); }
.btn:disabled, .btn.disabled { opacity: .45; pointer-events: none; }
.btn.primary { background: linear-gradient(135deg, var(--matcha), #4E7535); color: #fff; border-color: transparent; box-shadow: 0 6px 16px rgba(78, 117, 53, .25); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.soft { background: var(--leaf); color: var(--matcha-deep); border-color: transparent; }
.btn.danger { background: var(--danger-bg); color: var(--danger); border-color: transparent; }
.btn.block { width: 100%; }
.btn.sm { padding: 7px 12px; font-size: 13px; border-radius: 11px; }
.btn.sq { padding: 0; width: 38px; height: 38px; border-radius: 11px; }
.btn.sm.sq { width: 36px; height: auto; }
.btn.loading { position: relative; color: transparent !important; }
.btn.loading::after { content: ''; position: absolute; width: 16px; height: 16px; border: 2px solid; border-color: var(--matcha-deep) transparent var(--matcha-deep) var(--matcha-deep); border-radius: 50%; animation: rot .7s linear infinite; }
.btn.primary.loading::after { border-color: #fff transparent #fff #fff; }
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--leaf); color: var(--matcha-deep); white-space: nowrap; text-decoration: none; }
.chip .ic { width: 13px; height: 13px; }
.chip.warn { background: var(--warn-bg); color: var(--warn); }
.chip.danger { background: var(--danger-bg); color: var(--danger); }
.chip.ghost { background: var(--card-2); color: var(--muted); }
.seg { display: inline-flex; background: var(--card-2); border: 1px solid var(--line); border-radius: 14px; padding: 3px; gap: 2px; margin-bottom: 14px; }
.seg button { border: 0; background: none; padding: 7px 14px; border-radius: 11px; font-weight: 600; font-size: 13.5px; color: var(--muted); transition: background .25s, color .25s, box-shadow .25s; }
.seg button.on { background: var(--card); color: var(--matcha-deep); box-shadow: 0 1px 4px rgba(47, 74, 36, .12); }
.seg.sm { margin: 0; }
.seg.sm button { padding: 5px 10px; font-size: 12.5px; }

/* ---------- Avatar & vòng tiến độ ---------- */
.avatar { width: 40px; height: 40px; border-radius: 50%; flex: none; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 14px; background: var(--av, var(--matcha)); }
.avatar.sm { width: 34px; height: 34px; font-size: 12.5px; }
.avatar.xs { width: 22px; height: 22px; font-size: 9.5px; display: inline-grid; vertical-align: middle; }
.avatar.lg { width: 60px; height: 60px; font-size: 20px; }
.ring { --size: 52px; --w: 6px; width: var(--size); height: var(--size); border-radius: 50%; flex: none; display: grid; place-items: center; position: relative;
  background: conic-gradient(var(--matcha) calc(var(--p) * 1%), var(--leaf-2) 0); transition: --p .6s var(--ease); }
.ring::before { content: ''; position: absolute; inset: var(--w); border-radius: 50%; background: var(--card); }
.ring b { position: relative; font-size: 14px; font-weight: 700; }
.ring b small { font-size: .62em; opacity: .7; }
.ring.lg { --size: 104px; --w: 10px; }
.ring.lg b { font-size: 28px; }
.ring.full { background: conic-gradient(var(--matcha-deep) 100%, transparent 0); }
@property --p { syntax: '<number>'; inherits: false; initial-value: 0; }

/* ---------- Checklist trong ngày ---------- */
.hero { display: flex; align-items: center; gap: 16px; position: relative; overflow: hidden;
  background: linear-gradient(140deg, color-mix(in srgb, var(--leaf) 80%, var(--card)), var(--card) 70%); }
.hero::after { content: ''; position: absolute; right: -50px; bottom: -70px; width: 200px; height: 200px; border-radius: 0 50% 0 50%; background: color-mix(in srgb, var(--matcha) 9%, transparent); transform: rotate(18deg); pointer-events: none; }
.hero-txt { flex: 1; min-width: 0; position: relative; z-index: 1; }
.hero-txt small { color: var(--muted); font-weight: 600; font-size: 13px; }
.hero h1 { margin: 2px 0 10px; font-size: 22px; line-height: 1.25; }
.hero-meta { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; font-size: 14px; }
.hero-meta b { font-size: 18px; }
#ringBox { position: relative; z-index: 1; }
#ringBox .ring::before { background: var(--card); }
@media (max-width: 420px) { .ring.lg { --size: 84px; --w: 8px; } .ring.lg b { font-size: 22px; } .hero h1 { font-size: 19px; } }

.wstrip { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-bottom: 14px; }
.wday { display: flex; flex-direction: column; align-items: center; padding: 7px 0 8px; border-radius: 14px; background: var(--card); text-decoration: none; color: var(--text); border: 1.5px solid transparent; transition: background .2s, border-color .2s, transform .15s var(--ease); box-shadow: var(--shadow); }
.wday:active { transform: scale(.94); }
.wday small { font-size: 11px; color: var(--muted); font-weight: 600; }
.wday b { font-size: 15px; }
.wday i { width: 60%; height: 4px; border-radius: 4px; margin-top: 4px; background: linear-gradient(90deg, var(--matcha) calc(var(--p) * 1%), var(--leaf-2) 0); }
.wday.on { border-color: var(--matcha); background: var(--leaf-2); }
.wday.full b { color: var(--matcha-deep); }
.wday.fut { opacity: .4; pointer-events: none; box-shadow: none; }

.stage { padding: 0; overflow: hidden; transition: box-shadow .3s; }
.stage-head { width: 100%; display: flex; align-items: center; gap: 12px; padding: 14px 16px; border: 0; background: none; text-align: left; }
.stage-no { width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center; flex: none; background: var(--leaf-2); color: var(--matcha-deep); font-weight: 700; transition: background .3s, color .3s; }
.stage.full .stage-no { background: var(--matcha); color: #fff; animation: pop .45s var(--ease); }
.stage-name { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.stage-name b { font-size: 15.5px; }
.bar { height: 5px; border-radius: 5px; background: var(--leaf-2); overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 5px; background: var(--matcha); transition: width .5s var(--ease); }
.stage-cnt { font-weight: 700; font-size: 13.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.stage.full .stage-cnt { color: var(--matcha-deep); }
.chev { color: var(--muted); transition: transform .3s var(--ease); }
.stage-head.open .chev { transform: rotate(180deg); }
.collapse { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .38s var(--ease); }
.collapse > div { overflow: hidden; min-height: 0; }
.collapse.open { grid-template-rows: 1fr; }
.ci-list { border-top: 1px solid var(--line); }

.ci { display: flex; gap: 12px; padding: 12px 16px; border-bottom: 1px solid color-mix(in srgb, var(--line) 70%, transparent); transition: background .3s; }
.ci:last-child { border-bottom: 0; }
.ci.flash { animation: flash 2.2s var(--ease); }
@keyframes flash { 0%, 40% { background: var(--mark); } }
.tick { width: 30px; height: 30px; border-radius: 10px; flex: none; border: 2px solid color-mix(in srgb, var(--matcha) 55%, var(--line)); background: var(--card); padding: 0; display: grid; place-items: center; margin-top: 1px; transition: background .25s, border-color .25s, transform .15s var(--ease); }
.tick svg { width: 18px; height: 18px; fill: none; stroke: #fff; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 24; stroke-dashoffset: 24; transition: stroke-dashoffset .3s var(--ease) .05s; }
.tick:active { transform: scale(.88); }
.tick:disabled { cursor: default; opacity: .9; }
.ci.done .tick { background: var(--matcha); border-color: var(--matcha); }
.ci.done .tick svg { stroke-dashoffset: 0; }
.ci.pop .tick { animation: pop .45s var(--ease); }
.ci-main { flex: 1; min-width: 0; cursor: pointer; outline: none; }
.ci-title { font-weight: 600; transition: color .3s; }
.ci.done .ci-title { color: var(--muted); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--matcha) 60%, transparent); text-decoration-thickness: 2px; }
.ci-note-ic { color: var(--warn); display: inline-flex; vertical-align: -3px; }
.ci-note-ic .ic { width: 15px; height: 15px; }
.ci-std { font-size: 13.5px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ci-meta { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 3px; }
.ci-meta span { display: inline-flex; align-items: center; gap: 4px; }
.ci-meta .ic { width: 13px; height: 13px; }
.ci-meta .ok { color: var(--matcha-deep); font-weight: 600; animation: fadeIn .3s; }
.ci-note { margin-top: 6px; font-size: 13px; padding: 6px 10px; border-radius: 10px; background: var(--warn-bg); color: var(--warn); }
.leafy { position: fixed; width: 12px; height: 12px; z-index: 90; pointer-events: none; border-radius: 0 50% 0 50%; background: linear-gradient(135deg, #9CC26E, #4E7535); animation: leafy 1.2s var(--ease) forwards; }
@keyframes leafy { 0% { opacity: 1; transform: translate(0, 0) rotate(0) scale(.6); } 100% { opacity: 0; transform: translate(var(--dx), var(--dy)) rotate(var(--rot)) scale(1.1); } }
.kv { margin-bottom: 14px; }
.kv > span { display: block; font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 2px; }
.kv p { margin: 0; display: flex; gap: 6px; align-items: flex-start; }

/* ---------- Bảng tuần ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 14px; }
.stat { background: var(--card); border-radius: 18px; padding: 14px 16px; box-shadow: var(--shadow); border: 1px solid color-mix(in srgb, var(--line) 55%, transparent); }
.stat small { color: var(--muted); font-size: 12px; display: block; font-weight: 600; }
.stat b { font-size: 22px; font-weight: 700; }
.stat.accent { background: var(--leaf); }
.stat.accent b { color: var(--matcha-deep); }
.stat.review b { font-size: 16px; }
.stat.review.ok b { color: var(--matcha-deep); }
.stat.review p { margin: 4px 0 0; font-size: 13px; color: var(--muted); }
.stat.actions { display: flex; flex-direction: column; gap: 6px; justify-content: center; }
.wgrid-wrap { overflow-x: auto; }
.wgrid { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 13.5px; }
.wgrid th, .wgrid td { padding: 8px 6px; border-bottom: 1px solid var(--line); text-align: center; min-width: 44px; }
.wgrid th { font-size: 13px; position: sticky; top: 0; background: var(--card); z-index: 1; }
.wgrid th small { display: block; color: var(--muted); font-size: 11px; }
.wgrid .w-item { text-align: left; position: sticky; left: 0; background: var(--card); z-index: 2; min-width: 190px; max-width: 280px; border-right: 1px solid var(--line); }
.wgrid th.w-item { z-index: 3; }
.wgrid td.today, .wgrid th.today { background: var(--leaf-2); }
.wgrid td.fut { background: repeating-linear-gradient(135deg, transparent 0 6px, color-mix(in srgb, var(--line) 35%, transparent) 6px 7px); }
.w-stage td { background: var(--card-2) !important; font-weight: 700; color: var(--matcha-deep); text-align: left; position: sticky; left: 0; }
.wtick { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 8px; background: var(--matcha); color: #fff; }
.wtick .ic { width: 15px; height: 15px; stroke-width: 3; }
.wnote { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--warn); margin-left: 3px; vertical-align: top; }
.wgrid td[title] { cursor: help; }
.wgrid tfoot td { font-weight: 700; background: var(--card-2); border-bottom: 0; }
.wgrid tfoot td.full { color: var(--matcha-deep); }

/* ---------- Tổng quan quản lý ---------- */
.ov-grid { display: grid; grid-template-columns: 1fr 340px; gap: 18px; align-items: start; }
.ov-grid aside { position: sticky; top: calc(var(--top) + 50px); }
@media (max-width: 960px) { .ov-grid { grid-template-columns: 1fr; } .ov-grid aside { position: static; } }
.staff-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.scard { display: block; text-decoration: none; color: inherit; margin: 0; transition: transform .2s var(--ease), box-shadow .25s; }
.scard:hover { transform: translateY(-2px); box-shadow: 0 10px 30px rgba(47, 74, 36, .12); }
.scard.full { background: linear-gradient(150deg, var(--leaf-2), var(--card) 60%); }
.scard.pulse { animation: pulse 1s var(--ease); }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--matcha) 55%, transparent); } 100% { box-shadow: 0 0 0 14px transparent; } }
.scard-top { display: flex; gap: 12px; align-items: center; }
.scard-top b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.scard-top small { display: block; font-size: 12.5px; }
.segs { display: flex; gap: 4px; margin: 14px 0 10px; }
.segs i { flex: 1; height: 7px; border-radius: 4px; background: linear-gradient(90deg, var(--matcha) var(--p), var(--leaf-2) 0); }
.segs i.full { background: var(--matcha-deep); }
.scard-foot { display: flex; justify-content: space-between; align-items: center; font-size: 13px; color: var(--muted); font-weight: 600; }
.live-dot { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; color: var(--matcha-deep); }
.live-dot::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--matcha); animation: blink 1.6s infinite; }
@keyframes blink { 50% { opacity: .25; } }
.feed { padding: 6px; max-height: 70vh; overflow-y: auto; }
.fitem { display: flex; gap: 10px; padding: 9px 10px; border-radius: 12px; text-decoration: none; color: inherit; font-size: 13.5px; transition: background .2s; }
.fitem:hover { background: var(--card-2); }
.fitem.new { animation: fnew 1.6s var(--ease); }
@keyframes fnew { from { background: var(--leaf); transform: translateY(-6px); opacity: 0; } 20% { opacity: 1; transform: none; } }
.f-ic { flex: none; width: 22px; text-align: center; }
.f-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.f-main em { font-style: normal; color: var(--muted); }
.f-main q { font-size: 13px; color: var(--warn); }
.f-main time { font-size: 11.5px; color: var(--muted); }
.fitem.a-day_done, .fitem.a-stage_done { background: var(--leaf-2); }

/* ---------- Mẫu checklist ---------- */
.stage-edit { padding: 8px 8px 4px; }
.se-head { display: flex; align-items: center; gap: 8px; padding: 8px 10px; }
.se-head h3 { flex: 1; margin: 0; color: var(--matcha-deep); }
.ie { display: flex; align-items: center; gap: 10px; padding: 10px; border-top: 1px solid color-mix(in srgb, var(--line) 70%, transparent); }
.ie-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; align-items: flex-start; }
.ie-main small { color: var(--muted); font-size: 13px; }
.ie-act { display: flex; gap: 2px; }
.ie-act .icon-btn { width: 34px; height: 34px; }
.ie.off { opacity: .7; }

/* ---------- Nhân viên ---------- */
.search-local { margin-bottom: 12px; }
.ulist { display: flex; flex-direction: column; }
.urow { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.urow:last-child { border-bottom: 0; }
.urow.off { opacity: .55; }
.u-main { flex: 1; min-width: 160px; display: flex; flex-direction: column; }
.u-main small { font-size: 12.5px; }
.u-act { display: flex; gap: 2px; margin-left: auto; }
.pw-code { background: var(--leaf-2); color: var(--matcha-deep); padding: 1px 7px; border-radius: 6px; cursor: copy; font-weight: 700; animation: fadeIn .25s; }
.pw-row { display: flex; gap: 6px; }
.pw-row .pw-input { position: relative; flex: 1; min-width: 0; }
.pw-row .pw-input .input { padding-right: 42px; }
.pw-row .pw-input .input.mono { font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace; letter-spacing: .06em; }
.pw-row .eye { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); border: 0; background: none; color: var(--muted); padding: 6px; display: flex; }
.pw-opts { margin-top: 8px; padding: 10px 12px; background: var(--card-2); border-radius: 12px; display: flex; flex-wrap: wrap; gap: 12px; align-items: center; font-size: 13px; animation: fadeIn .25s var(--ease); }
.pw-opts label { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.pw-opts input { accent-color: var(--matcha); }
.share-card { width: 100%; border-radius: 16px; border: 1px solid var(--line); display: block; animation: fadeIn .3s var(--ease); }
.share-text { margin: 12px 0; padding: 12px 14px; border-radius: 12px; background: var(--card-2); font-size: 13px; white-space: pre-wrap; user-select: all; }

/* ---------- Form ---------- */
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.input { width: 100%; padding: 11px 14px; border-radius: 13px; border: 1.5px solid var(--line); background: var(--card); outline: none; transition: border-color .2s, box-shadow .2s; font-size: 15px; }
.input:focus { border-color: var(--matcha); box-shadow: 0 0 0 4px color-mix(in srgb, var(--matcha) 18%, transparent); }
textarea.input { resize: vertical; min-height: 70px; line-height: 1.5; }
@media (max-width: 760px) { .input { font-size: 16px; } }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 560px) { .grid2 { grid-template-columns: 1fr; } }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 4px 0 14px; cursor: pointer; }
.switch span small { display: block; color: var(--muted); font-size: 12.5px; }
.switch input { appearance: none; width: 46px; height: 28px; border-radius: 999px; background: var(--line); position: relative; transition: background .25s; flex: none; margin: 0; cursor: pointer; }
.switch input::after { content: ''; position: absolute; left: 3px; top: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: transform .25s var(--ease); }
.switch input:checked { background: var(--matcha); }
.switch input:checked::after { transform: translateX(18px); }
.err { color: var(--danger); font-size: 13px; min-height: 18px; margin: -4px 0 6px; }
.radio-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 8px; margin-bottom: 8px; }
.rc { cursor: pointer; }
.rc input { position: absolute; opacity: 0; }
.rc span { display: block; height: 100%; padding: 12px 14px; border-radius: 14px; border: 1.5px solid var(--line); transition: border-color .2s, background .2s; }
.rc span small { display: block; color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.rc input:checked + span { border-color: var(--matcha); background: var(--leaf-2); }
.rc input:focus-visible + span { box-shadow: 0 0 0 4px color-mix(in srgb, var(--matcha) 18%, transparent); }
.logo-box { padding: 18px; border-radius: 14px; background: repeating-conic-gradient(var(--card-2) 0 25%, var(--card) 0 50%) 0 0 / 18px 18px; display: flex; justify-content: center; margin-bottom: 8px; }
.logo-box img { height: 80px; width: auto; }
.me-card { display: flex; align-items: center; gap: 16px; }
.me-card h1 { margin: 0; font-size: 20px; }
.me-card p { margin: 0; }

/* ---------- Sổ tay ---------- */
.hb-layout { display: grid; grid-template-columns: 260px 1fr; gap: 18px; align-items: start; }
.hb-toc { position: sticky; top: calc(var(--top) + 54px); max-height: calc(100dvh - var(--top) - 70px); overflow-y: auto; }
.hb-toc-in { padding: 6px 4px; }
.toc-title { display: flex; align-items: center; gap: 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 4px 10px 8px; }
.hb-toc nav a, .toc-sheet a { display: block; text-decoration: none; color: var(--muted); font-size: 13.5px; padding: 6px 10px; border-radius: 10px; border-left: 2px solid transparent; transition: background .2s, color .2s, border-color .2s; }
.hb-toc nav a.l2, .toc-sheet a.l2 { font-weight: 600; color: var(--text); margin-top: 4px; }
.hb-toc nav a.l3, .toc-sheet a.l3 { padding-left: 22px; font-size: 13px; }
.hb-toc nav a:hover { background: var(--card-2); }
.hb-toc nav a.on { background: var(--leaf); color: var(--matcha-deep); border-left-color: var(--matcha); }
.toc-btn { display: none; }
@media (max-width: 900px) { .hb-layout { grid-template-columns: 1fr; } .hb-toc { display: none; } .toc-btn { display: inline-flex; } }
@media (max-width: 560px) { .hide-sm { display: none; } }
.hb { padding: 22px 28px 30px; }
@media (max-width: 560px) { .hb { padding: 16px 16px 24px; } }
.hb-bar { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-bottom: 6px; }
.hb-meta { margin-bottom: 8px; }
.md { font-size: 15.5px; line-height: 1.7; overflow-wrap: anywhere; }
.md h1 { font-size: 26px; line-height: 1.25; margin: 10px 0 14px; color: var(--matcha-deep); }
.md h2 { font-size: 21px; margin: 34px 0 10px; padding-top: 18px; border-top: 1px solid var(--line); color: var(--matcha-deep); }
.md h3 { font-size: 17px; margin: 24px 0 8px; }
.md h4 { font-size: 15.5px; margin: 18px 0 6px; }
.md p { margin: 0 0 12px; }
.md ul, .md ol { margin: 0 0 12px; padding-left: 22px; }
.md li { margin: 3px 0; }
.md li::marker { color: var(--matcha); }
.md strong { font-weight: 700; }
.md figure { margin: 16px 0; }
.md img { max-width: 100%; height: auto; border-radius: 14px; cursor: zoom-in; display: block; }
.md blockquote { margin: 0 0 12px; padding: 10px 14px; border-left: 3px solid var(--matcha); background: var(--leaf-2); border-radius: 0 12px 12px 0; }
.md hr { border: 0; border-top: 1px solid var(--line); margin: 22px 0; }
.md code { background: var(--card-2); padding: 1px 5px; border-radius: 5px; font-size: .92em; }
.md-table { overflow-x: auto; margin: 0 0 16px; border-radius: 14px; border: 1px solid var(--line); }
.md table { border-collapse: collapse; width: 100%; font-size: 14.5px; }
.md th { background: var(--leaf-2); text-align: left; font-weight: 700; color: var(--matcha-deep); }
.md th, .md td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; min-width: 120px; }
.md tr:last-child td { border-bottom: 0; }
.md .flash, .md [data-b].flash { animation: flash 2.6s var(--ease); border-radius: 8px; }
.md [data-b] { scroll-margin-top: calc(var(--top) + 20px); }
.hist { display: flex; flex-direction: column; }
.hrow { display: flex; align-items: center; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.hrow small { display: block; }

/* Trình soạn */
.editor { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.ed-tools { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.ed-tools > button { border: 1px solid var(--line); background: var(--card-2); border-radius: 10px; height: 36px; min-width: 38px; display: inline-flex; align-items: center; justify-content: center; gap: 1px; padding: 0 8px; }
.ed-tools > button small { font-weight: 700; font-size: 11px; }
.ed-tools > button:hover { background: var(--leaf-2); }
.ed-panes { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.ed-src { width: 100%; height: 100%; min-height: 50dvh; resize: none; border: 1.5px solid var(--line); border-radius: 14px; padding: 14px; background: var(--card); font-size: 13.5px; line-height: 1.6; outline: none; }
.ed-src:focus { border-color: var(--matcha); }
.ed-pre { border: 1px solid var(--line); border-radius: 14px; padding: 14px 18px; overflow-y: auto; min-height: 50dvh; background: var(--card); }
.ed-tabs { display: none; }
.ed-help { margin: 8px 0 0; }
@media (max-width: 900px) {
  .ed-tabs { display: inline-flex; }
  .ed-panes { grid-template-columns: 1fr; }
  .ed-panes.show-src .ed-pre, .ed-panes.show-pre .ed-src { display: none; }
}

/* ---------- Hộp thoại ---------- */
.overlay { position: fixed; inset: 0; z-index: 60; background: rgba(17, 21, 16, .4); display: flex; align-items: center; justify-content: center; padding: 16px; opacity: 0; transition: opacity .28s var(--ease); }
.overlay.show { opacity: 1; }
.modal { width: 100%; max-width: 520px; max-height: calc(100dvh - 32px); display: flex; flex-direction: column; background: var(--card); border-radius: 24px; box-shadow: 0 30px 80px rgba(0, 0, 0, .25); transform: translateY(18px) scale(.98); transition: transform .32s var(--ease); }
.overlay.show .modal { transform: none; }
.modal.wide { max-width: 860px; }
.modal.full { max-width: 1180px; height: calc(100dvh - 32px); }
.modal.nudge { animation: nudge .4s var(--ease); }
@keyframes nudge { 20% { translate: 0 -6px; } 45% { translate: 0 2px; } 70% { translate: 0 -2px; } }
.modal-head { display: flex; align-items: flex-start; gap: 12px; padding: 18px 18px 8px 22px; }
.modal-head > div { flex: 1; min-width: 0; }
.modal-head h2 { margin: 0; font-size: 18px; line-height: 1.35; }
.modal-head .sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.modal-head .icon-btn { background: var(--card-2); border-radius: 50%; width: 36px; height: 36px; margin: -4px -2px 0 0; }
.modal-body { padding: 8px 22px 16px; overflow-y: auto; overscroll-behavior: contain; flex: 1; min-height: 0; }
.modal.full .modal-body { display: flex; flex-direction: column; }
.modal-foot { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; padding: 12px 18px 18px; border-top: 1px solid var(--line); }
@media (max-width: 640px) {
  .overlay { align-items: flex-end; padding: 0; }
  .modal { max-width: none !important; border-radius: 24px 24px 0 0; max-height: 92dvh; transform: translateY(100%); padding-bottom: env(safe-area-inset-bottom); }
  .modal.full { height: 96dvh; max-height: 96dvh; }
  .modal-foot .btn { flex: 1; }
}
.notif-modal { max-width: 460px; }
.nlist { display: flex; flex-direction: column; margin: 0 -10px; }
.nitem { display: flex; gap: 12px; text-align: left; border: 0; background: none; padding: 11px 12px; border-radius: 14px; transition: background .2s; width: 100%; }
.nitem:hover { background: var(--card-2); }
.nitem.unread { background: var(--leaf-2); }
.n-ic { font-size: 19px; width: 26px; flex: none; text-align: center; }
.n-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.n-main b { font-weight: 600; font-size: 14px; }
.n-main small { color: var(--muted); font-size: 13px; white-space: pre-line; }
.n-main time { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.lightbox { position: fixed; inset: 0; z-index: 90; background: rgba(10, 12, 9, .9); display: grid; place-items: center; padding: 16px; opacity: 0; transition: opacity .25s; cursor: zoom-out; }
.lightbox.show { opacity: 1; }
.lightbox img { max-width: 100%; max-height: 90dvh; border-radius: 12px; transform: scale(.95); transition: transform .3s var(--ease); }
.lightbox.show img { transform: none; }

/* ---------- Toast ---------- */
.toasts { position: fixed; z-index: 100; top: calc(12px + env(safe-area-inset-top)); right: 16px; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; pointer-events: none; max-width: min(380px, calc(100% - 32px)); }
@media (max-width: 640px) { .toasts { left: 16px; right: 16px; align-items: stretch; max-width: none; } }
.toast { pointer-events: auto; background: var(--text); color: var(--bg); padding: 11px 16px; border-radius: 14px; font-size: 14px; box-shadow: 0 12px 32px rgba(0, 0, 0, .22); display: flex; flex-direction: column; animation: toastIn .35s var(--ease); transition: opacity .25s, transform .3s var(--ease); }
.toast b { font-weight: 700; }
.toast span { opacity: .9; white-space: pre-line; }
.toast.ok { background: linear-gradient(135deg, var(--matcha), #4E7535); color: #fff; }
.toast.err { background: var(--danger); color: #fff; }
.toast.link { cursor: pointer; }
.toast.out { opacity: 0; transform: translateY(-8px); }
@keyframes toastIn { from { opacity: 0; transform: translateY(-14px) scale(.97); } }

/* ---------- Đăng nhập ---------- */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; background: radial-gradient(ellipse at top, var(--leaf-2), var(--bg) 60%); }
.login .box { width: 100%; max-width: 380px; animation: viewIn .5s var(--ease); }
.login .brand { flex-direction: column; text-align: center; margin-bottom: 26px; gap: 0; }
.login-logo { height: 84px; width: auto; animation: float 4s ease-in-out infinite; }
.login h1 { margin: 18px 0 2px; font-size: 22px; }
.login .brand p { margin: 0; color: var(--muted); }
@keyframes float { 50% { transform: translateY(-5px); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
.hb-layout > *, .ov-grid > *, .md-table { min-width: 0; }
