:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --border: #e5e7eb;
  --text: #111827;
  --text-2: #374151;
  --muted: #6b7280;
  --faint: #9ca3af;
  --accent: #2563eb;
  --accent-soft: #eff4ff;

  --sidebar: #0f172a;
  --sidebar-hover: #1e293b;
  --sidebar-active: #1e293b;
  --sidebar-text: #cbd5e1;
  --sidebar-muted: #64748b;

  --s-hi: #047857;   --s-hi-bg: #d1fae5;   /* từ 8 điểm */
  --s-mid: #059669;  --s-mid-bg: #ecfdf5;  /* 7 điểm */
  --s-low: #b45309;  --s-low-bg: #fef3c7;  /* 5–6 điểm */
  --s-none: #6b7280; --s-none-bg: #f3f4f6;

  --ok: #047857;
  --bad: #b91c1c;
  --warn: #b45309;

  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05);
  --sidebar-w: 248px;
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

button, input, select, textarea { font: inherit; color: inherit; }

button {
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 8px;
  padding: 6px 12px;
  font-weight: 500;
}
button:hover { background: var(--surface-2); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover { background: #1d4ed8; }
button.danger { color: var(--bad); }
button.ghost { border-color: transparent; background: none; }
button.ghost:hover { background: var(--surface-2); }
button.link { border: 0; background: none; padding: 0; color: var(--accent); font-weight: 400; }
button.link:hover { text-decoration: underline; background: none; }
button:disabled { opacity: .55; cursor: default; }

input[type=text], input[type=password], input[type=search], input[type=url], select, textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 10px;
  background: var(--surface);
}
textarea { min-height: 120px; resize: vertical; line-height: 1.6; }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* Ô mật khẩu có nút con mắt ẩn/hiện */
.pw-wrap { position: relative; display: block; flex: 1; min-width: 0; }
.pw-wrap input { padding-right: 40px; }
.pw-wrap > .pw-eye {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  width: auto; margin: 0;
  border: 0; background: none; padding: 4px 6px; border-radius: 6px;
  color: var(--muted); display: grid; place-items: center;
}
.pw-wrap > .pw-eye:hover { color: var(--text); background: var(--surface-2); }

label { display: block; font-weight: 600; font-size: 13px; margin: 12px 0 4px; }
.hint { color: var(--muted); font-size: 13px; font-weight: 400; }
.msg { font-size: 13px; }
.msg.error { color: var(--bad); }
.msg.success { color: var(--ok); }

/* =========================================================
   Khung ứng dụng: menu trái + nội dung
   ========================================================= */
body.app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }

.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  background: var(--sidebar); color: var(--sidebar-text);
  display: flex; flex-direction: column;
  padding: 18px 12px;
}
.sidebar .brand { display: flex; align-items: center; gap: 10px; padding: 0 10px 18px; color: #fff; }
.sidebar .brand:hover { text-decoration: none; }
.sidebar .brand img { width: 28px; height: 28px; }
.sidebar .brand b { display: block; font-size: 16px; line-height: 1.2; }
.sidebar .brand span { display: block; font-size: 12px; color: var(--sidebar-muted); }

.nav-section { margin-top: 14px; }
.nav-section > .title {
  font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--sidebar-muted); padding: 0 10px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; border-radius: 8px;
  color: var(--sidebar-text); font-size: 14px;
}
.nav-item:hover { background: var(--sidebar-hover); color: #fff; text-decoration: none; }
.nav-item.active { background: var(--sidebar-active); color: #fff; font-weight: 600; }
.nav-item .ico { width: 18px; text-align: center; opacity: .8; flex-shrink: 0; }
.nav-item .label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item .badge {
  font-size: 11px; font-weight: 600; color: var(--sidebar-text);
  background: #334155; border-radius: 999px; padding: 0 7px; line-height: 18px;
}
.dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; display: inline-block; }

.sidebar .spacer { flex: 1; }
.sidebar .user {
  border-top: 1px solid #1e293b; margin-top: 14px; padding: 12px 10px 0;
  display: flex; align-items: center; gap: 10px; font-size: 13px;
}
.sidebar .user .avatar {
  width: 30px; height: 30px; border-radius: 50%; background: #334155; color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: 13px; flex-shrink: 0;
}
.sidebar .user { flex-wrap: wrap; }
.sidebar .user .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #fff; }
.sidebar .user .u-actions { width: 100%; display: flex; gap: 6px; }
.sidebar .user .u-actions button { flex: 1; }
.sidebar .user .role { color: var(--sidebar-muted); font-size: 12px; }
.sidebar .user button { color: var(--sidebar-text); border-color: #334155; background: none; padding: 4px 8px; font-size: 12px; }
.sidebar .user button:hover { background: var(--sidebar-hover); }

.main { min-width: 0; display: flex; flex-direction: column; }

.pagebar {
  display: flex; align-items: center; gap: 16px;
  padding: 18px 28px; background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 5;
}
.pagebar h1 { font-size: 20px; margin: 0; letter-spacing: -.01em; }
.pagebar .sub { color: var(--muted); font-size: 13px; }
.pagebar .titles { flex: 1; min-width: 0; }
.pagebar .actions { display: flex; gap: 10px; align-items: center; }
.pagebar .actions input[type=search] { width: 260px; }
.menu-btn { display: none; }
.clock { text-align: right; line-height: 1.25; font-variant-numeric: tabular-nums; white-space: nowrap; }
.clock b { display: block; font-size: 18px; letter-spacing: .02em; }
.clock span { font-size: 12px; color: var(--muted); }

.content { padding: 24px 28px 48px; }

/* =========================================================
   Thành phần chung
   ========================================================= */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-head {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 18px; border-bottom: 1px solid var(--border);
}
.card-head h2, .card-head h3 { margin: 0; font-size: 15px; flex: 1; min-width: 0; }
.card-body { padding: 16px 18px; }

.section-title { display: flex; align-items: baseline; gap: 10px; margin: 28px 0 12px; }
.section-title h2 { font-size: 16px; margin: 0; }

.score {
  display: inline-grid; place-items: center; flex-shrink: 0;
  min-width: 26px; height: 22px; padding: 0 5px; border-radius: 6px;
  font-size: 12px; font-weight: 700;
  background: var(--s-none-bg); color: var(--s-none);
}
.score.hi { background: var(--s-hi-bg); color: var(--s-hi); }
.score.mid { background: var(--s-mid-bg); color: var(--s-mid); }
.score.low { background: var(--s-low-bg); color: var(--s-low); }

.tag {
  display: inline-block; font-size: 12px; color: var(--text-2); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 6px; padding: 0 7px; line-height: 20px;
}
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }

.segmented { display: inline-flex; background: #eceef1; border-radius: 9px; padding: 3px; flex-shrink: 0; }
.segmented button { border: 0; background: none; border-radius: 7px; padding: 5px 14px; color: var(--text-2); font-weight: 500; }
.segmented button:hover { background: rgba(255,255,255,.6); }
.segmented button.active { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.segmented .count { color: var(--muted); font-weight: 400; margin-left: 5px; font-size: 12px; }

.empty { text-align: center; color: var(--muted); padding: 36px 12px; }

/* =========================================================
   Trang Tổng quan
   ========================================================= */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.kpi { padding: 16px 18px; }
.kpi .k-label { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.kpi .k-value { font-size: 30px; font-weight: 700; letter-spacing: -.02em; margin: 4px 0 2px; }
.kpi .k-foot { font-size: 12px; color: var(--muted); }
.kpi .k-foot.bad { color: var(--bad); }

.overview-row { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 16px; margin-top: 16px; }

.digest-card .card-body ul { margin: 0; padding-left: 18px; }
.digest-card .card-body li { margin: 6px 0; color: var(--text-2); }

.bars { list-style: none; margin: 0; padding: 0; }
.bars li { display: grid; grid-template-columns: minmax(0, 1fr) 40px; gap: 4px 10px; align-items: center; margin-bottom: 12px; }
.bars li:last-child { margin-bottom: 0; }
.bars .b-name { display: flex; align-items: center; gap: 8px; font-size: 13px; min-width: 0; }
.bars .b-name a { color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bars .b-num { text-align: right; font-weight: 600; font-size: 13px; }
.bars .b-track { grid-column: 1 / -1; height: 6px; background: #eef0f3; border-radius: 99px; overflow: hidden; }
.bars .b-fill { height: 100%; border-radius: 99px; }

.board { display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); gap: 16px; }
.board .card { display: flex; flex-direction: column; }
.board .card-head .count { font-size: 12px; color: var(--muted); }
.board ul { list-style: none; margin: 0; padding: 4px 0; flex: 1; }
.board li { display: flex; gap: 10px; padding: 10px 18px; border-bottom: 1px solid #f1f2f4; }
.board li:last-child { border-bottom: 0; }
.board li .t { min-width: 0; flex: 1; }
.board li a.title {
  color: var(--text); font-weight: 500; line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.board li a.title:hover { color: var(--accent); text-decoration: none; }
.board li .m { font-size: 12px; color: var(--muted); margin-top: 2px; }
.board .card-foot { padding: 10px 18px; border-top: 1px solid var(--border); font-size: 13px; }

/* =========================================================
   Danh sách tin (Nổi bật / Tất cả / theo chủ đề)
   ========================================================= */
.list-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 24px; align-items: start; }
.list-tools { display: flex; gap: 12px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.list-tools input[type=search] { max-width: 320px; }
.rail { position: sticky; top: 92px; display: flex; flex-direction: column; gap: 16px; }

.day {
  font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em;
  margin: 22px 0 10px;
}
.day:first-child { margin-top: 0; }

.article {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 18px; margin-bottom: 10px;
  display: flex; gap: 14px;
}
.article .a-body { flex: 1; min-width: 0; }
.article h3 { font-size: 15px; margin: 0 0 4px; line-height: 1.45; font-weight: 600; }
.article h3 a { color: var(--text); }
.article h3 a:hover { color: var(--accent); text-decoration: none; }
.article .summary { margin: 0 0 8px; color: var(--text-2); }
.article .meta { font-size: 12px; color: var(--muted); display: flex; flex-wrap: wrap; align-items: center; gap: 4px 0; }
.article .meta > * + *::before { content: "·"; margin: 0 8px; color: #d1d5db; }
.article .meta .topic { display: inline-flex; align-items: center; gap: 5px; }
.article .meta button.link { font-size: 12px; font-weight: 600; }
.article .dups { margin: 8px 0 0; padding-left: 18px; font-size: 13px; }
.article .dups li { margin: 2px 0; }
/* Nút lưu bài */
.save-btn {
  display: inline-flex; align-items: center; gap: 5px; border: 0; background: none; padding: 0;
  color: var(--muted); font-size: 12px; font-weight: 600;
}
.save-btn:hover { color: var(--accent); background: none; }
.save-btn.on { color: #b45309; }
.save-btn.compact { padding: 3px; border-radius: 6px; align-self: flex-start; flex-shrink: 0; }
.save-btn.compact:hover { background: var(--surface-2); }

/* Nhãn danh mục của bài */
.cats { display: inline-flex; flex-wrap: wrap; gap: 4px 10px; }
.cat { display: inline-flex; align-items: center; gap: 5px; }
.cat .dot { width: 7px; height: 7px; }
.cat b { color: var(--text-2); font-weight: 700; }
.cat.other { opacity: .55; }

.analysis { margin-top: 12px; padding: 14px 16px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; }
.analysis .note { font-size: 12px; color: var(--muted); margin-top: 10px; }

.more { display: block; margin: 16px auto; }

/* =========================================================
   Văn bản Markdown (phân tích)
   ========================================================= */
.md { font-size: 14px; line-height: 1.65; }
.md h3 { font-size: 16px; margin: 22px 0 8px; }
.md h4 { font-size: 15px; margin: 16px 0 6px; }
.md > :first-child { margin-top: 0; }
.md p { margin: 8px 0; }
.md ul, .md ol { margin: 8px 0; padding-left: 22px; }
.md li { margin: 5px 0; }
.md a.ref { font-size: 11px; font-weight: 700; vertical-align: super; line-height: 0; padding: 0 1px; }

/* =========================================================
   Trang Phân tích
   ========================================================= */
.digest-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 24px; align-items: start; }
.digest-doc { padding: 28px 34px; }
.digest-doc h1 { font-size: 24px; margin: 0 0 4px; letter-spacing: -.01em; }
.digest-doc .sub { color: var(--muted); font-size: 13px; margin-bottom: 20px; }
.digest-doc .sources { margin-top: 28px; padding-top: 14px; border-top: 1px solid var(--border); font-size: 13px; }
.digest-doc .sources ol { padding-left: 22px; margin: 8px 0 0; color: var(--text-2); }
.digest-doc .sources li { margin: 3px 0; }
.digest-list { list-style: none; margin: 0; padding: 6px; }
.digest-list a { display: block; padding: 8px 12px; border-radius: 8px; color: var(--text-2); }
.digest-list a:hover { background: var(--surface-2); text-decoration: none; }
.digest-list a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.digest-list .when { display: block; font-size: 12px; color: var(--muted); font-weight: 400; }

/* =========================================================
   Trang Cài đặt
   ========================================================= */
.tabs-line { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 22px; overflow-x: auto; }
.tabs-line a {
  padding: 10px 14px; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent;
  margin-bottom: -1px; white-space: nowrap;
}
.tabs-line a:hover { color: var(--text); text-decoration: none; }
.tabs-line a.active { color: var(--text); border-bottom-color: var(--accent); }

.toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar .grow { flex: 1; min-width: 200px; }
.toolbar p { margin: 0; }

.watch-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.watch-card { padding: 16px 18px; display: flex; flex-direction: column; gap: 10px; }
.watch-card.off { opacity: .6; }
.watch-card .w-head { display: flex; align-items: center; gap: 10px; }
.watch-card .w-head b { font-size: 15px; flex: 1; min-width: 0; }
.watch-card .chips { display: flex; flex-wrap: wrap; gap: 6px; }
.watch-card .chips .tag.ex { color: var(--bad); }
.watch-card .note { color: var(--muted); font-size: 13px; }
.watch-card .w-foot { display: flex; gap: 8px; margin-top: auto; padding-top: 6px; }

.table-card { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
th { font-size: 12px; color: var(--muted); font-weight: 600; background: var(--surface-2); }
td .sub { font-size: 12px; color: var(--muted); }
td.actions { white-space: nowrap; text-align: right; }
td.actions button { margin-left: 6px; }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.status .dot { width: 8px; height: 8px; }
.status.ok { color: var(--ok); }   .status.ok .dot { background: var(--ok); }
.status.bad { color: var(--bad); } .status.bad .dot { background: var(--bad); }
.status.off { color: var(--muted); } .status.off .dot { background: var(--faint); }

.stats-inline { display: flex; gap: 18px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.stats-inline b { color: var(--text); }

.two-col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.sys-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.sys-grid .card-body p { margin: 0 0 8px; }
code.cmd { display: block; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font-size: 12px; overflow-x: auto; white-space: pre; }

pre.report { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; font-size: 12px; white-space: pre-wrap; margin: 12px 0 0; }

/* Cửa sổ nổi để thêm/sửa */
dialog {
  border: 0; border-radius: 14px; padding: 0; width: min(640px, calc(100vw - 32px));
  box-shadow: 0 20px 50px rgba(15, 23, 42, .25);
}
dialog::backdrop { background: rgba(15, 23, 42, .45); }
dialog .d-head { padding: 16px 22px; border-bottom: 1px solid var(--border); display: flex; align-items: center; }
dialog .d-head h3 { margin: 0; font-size: 16px; flex: 1; }
dialog .d-body { padding: 6px 22px 18px; max-height: calc(100vh - 200px); overflow-y: auto; }
dialog .d-foot { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; gap: 8px; align-items: center; justify-content: flex-end; }
dialog .d-foot .msg { flex: 1; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.form-grid .full { grid-column: 1 / -1; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 400; margin-top: 14px; }
.check-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 14px; margin-top: 6px; }
.check-list label { display: flex; align-items: center; gap: 8px; font-weight: 400; margin: 0; }
.check-list .dot { width: 8px; height: 8px; }
.pw-cell { display: flex; align-items: center; gap: 4px; white-space: nowrap; }
.pw-cell code { font-family: ui-monospace, Consolas, monospace; font-size: 13px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: 1px 7px; }
.pw-cell .pw-btn { padding: 3px 6px; font-size: 12px; color: var(--muted); display: inline-flex; align-items: center; }
.pw-cell .pw-btn:hover { color: var(--text); }
/* Tab Tài khoản gọn */
.me-card { margin-bottom: 16px; }
.me-row { display: flex; align-items: center; gap: 14px; padding: 14px 18px; }
.me-info { flex: 1; min-width: 0; line-height: 1.5; }
.acct { display: flex; align-items: center; gap: 10px; }
.acct-avatar {
  width: 30px; height: 30px; border-radius: 50%; background: var(--sidebar); color: #fff; flex-shrink: 0;
  display: grid; place-items: center; font-weight: 700; font-size: 13px;
}
.acct-avatar.lg { width: 40px; height: 40px; font-size: 16px; }
.acct-text { min-width: 0; }
.acct-text .tag { margin-left: 6px; font-size: 11px; line-height: 18px; }
.users-table td { padding: 9px 14px; font-size: 13px; }
.users-table th { padding: 8px 14px; }
.cats-mini { display: flex; flex-wrap: wrap; gap: 2px 10px; font-size: 12px; }
.cats-mini .more-n { color: var(--muted); font-weight: 600; }
.icon-btn { border: 0; background: none; padding: 3px 5px; border-radius: 6px; color: var(--muted); display: inline-grid; place-items: center; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.done { color: var(--ok); }
.user-cats { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 13px; }

/* =========================================================
   Đăng nhập
   ========================================================= */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: var(--sidebar); }
.login-box { width: 100%; max-width: 380px; background: var(--surface); border-radius: 16px; padding: 30px 28px; }
.login-box h1 { font-size: 21px; margin: 0 0 4px; }
.login-box p { color: var(--muted); margin: 0 0 14px; font-size: 14px; }
.login-box button[type="submit"] { width: 100%; margin-top: 18px; padding: 9px; }
/* Tài khoản đã dùng trên máy này (trang đăng nhập) */
.recent { margin: 4px 0 6px; }
.recent-title { font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.recent-item { display: flex; align-items: center; gap: 4px; margin-bottom: 4px; }
.recent-pick {
  flex: 1; display: flex; align-items: center; gap: 10px; text-align: left;
  padding: 7px 10px; border-radius: 10px; font-weight: 600;
}
.recent-pick.active { border-color: var(--accent); background: var(--accent-soft); }
.recent-pick .avatar {
  width: 26px; height: 26px; border-radius: 50%; background: var(--sidebar); color: #fff;
  display: grid; place-items: center; font-size: 12px; flex-shrink: 0;
}
.recent-forget { border: 0; background: none; color: var(--muted); font-size: 18px; line-height: 1; padding: 4px 8px; }
.recent-forget:hover { color: var(--bad); background: none; }

/* =========================================================
   Màn hình nhỏ
   ========================================================= */
@media (max-width: 1200px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .list-layout, .digest-layout { grid-template-columns: minmax(0, 1fr); }
  .rail { position: static; }
}
@media (max-width: 900px) {
  body.app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; z-index: 20; left: 0; top: 0; width: 270px; transform: translateX(-100%); transition: transform .2s; }
  body.nav-open .sidebar { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.35); }
  .menu-btn { display: inline-block; }
  .pagebar { padding: 12px 16px; flex-wrap: wrap; }
  .pagebar .actions { width: 100%; }
  .clock b { font-size: 15px; }
  .pagebar .actions input[type=search] { width: 100%; }
  .content { padding: 16px 14px 40px; }
  .overview-row, .two-col { grid-template-columns: minmax(0, 1fr); }
  .board { grid-template-columns: minmax(0, 1fr); }
  .form-grid { grid-template-columns: 1fr; }
  .digest-doc { padding: 18px; }
}
@media (max-width: 520px) {
  .kpis { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
  .kpi .k-value { font-size: 24px; }
}

/* =========================================================
   Task Bizhub Việt — công việc & push việc
   ========================================================= */
input[type=date], input[type=number] { width: 100%; border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; background: var(--surface); }
input[type=color] { width: 60px; height: 34px; border: 1px solid var(--border); border-radius: 8px; padding: 2px; background: var(--surface); }
button.small { padding: 3px 9px; font-size: 12px; border-radius: 7px; }
.danger-link { color: var(--bad) !important; font-size: 12px; }
.nav-item .badge.hot { background: #dc2626; color: #fff; }
.overview-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.content > * + * { margin-top: 16px; }

/* Nhãn nhỏ */
.chip {
  display: inline-flex; align-items: center; gap: 5px; white-space: nowrap;
  font-size: 12px; line-height: 20px; padding: 0 8px; border-radius: 99px;
  background: #f1f3f6; color: var(--text-2); font-weight: 500;
}
.chip.muted { background: #f3f4f6; color: var(--muted); }
.chip.danger { background: #fee2e2; color: #b91c1c; font-weight: 600; }
.chip.warn { background: #ffedd5; color: #c2410c; font-weight: 600; }
.chip.info { background: var(--accent-soft); color: #1d4ed8; }
.chip.push { background: #fff7ed; color: #c2410c; }
.chip.kind-push { background: #fff7ed; color: #c2410c; }
.chip.kind-mine { background: #eff6ff; color: #1d4ed8; }
.chip.prio-urgent { background: #dc2626; color: #fff; font-weight: 600; }
.chip.prio-high { background: #fee2e2; color: #b91c1c; }
.chip.prio-normal { background: #f1f3f6; color: var(--text-2); }
.chip.prio-low { background: #f3f4f6; color: var(--faint); }
.chip.st-todo { background: #f1f3f6; color: var(--text-2); }
.chip.st-doing { background: #dbeafe; color: #1d4ed8; }
.chip.st-waiting { background: #fef3c7; color: #b45309; }
.chip.st-done { background: #d1fae5; color: #047857; }
.chip.st-paused { background: #e5e7eb; color: var(--muted); }
.count-pill { font-size: 12px; font-weight: 600; color: var(--muted); background: #f1f3f6; border-radius: 99px; padding: 0 8px; line-height: 20px; }

/* Thanh lọc */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px 12px; }
.filters select { width: auto; max-width: 180px; padding: 5px 8px; }
.filters input[type=search] { width: 230px; padding: 5px 10px; }

/* Dòng việc */
.task-list { display: flex; flex-direction: column; gap: 8px; }
.today-card .task-list, .sub-card .task-list, .task-list.flat { gap: 0; }
.task-row {
  display: flex; gap: 14px; align-items: flex-start;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 14px 10px 16px; border-left: 4px solid #d1d5db;
}
.today-card .task-row, .sub-card .task-row, .task-list.flat .task-row { border-radius: 0; border-width: 0 0 1px 4px; }
.today-card .task-row:last-child, .sub-card .task-row:last-child, .task-list.flat .task-row:last-child { border-bottom-width: 0; }
.today-card .task-row:last-child { border-bottom-left-radius: var(--radius); }
.task-row.child { margin-left: 26px; background: var(--surface-2); }
.task-row.done .tr-title { color: var(--muted); text-decoration: line-through; }
.prio-line-urgent { border-left-color: #dc2626 !important; }
.prio-line-high { border-left-color: #f97316 !important; }
.prio-line-normal { border-left-color: #93c5fd !important; }
.prio-line-low { border-left-color: #e5e7eb !important; }
.tr-main { flex: 1; min-width: 0; }
.tr-title { font-weight: 600; color: var(--text); font-size: 14px; }
.tr-title:hover { color: var(--accent); }
.tr-parent { display: block; font-size: 12px; color: var(--muted); }
.tr-meta { display: flex; flex-wrap: wrap; gap: 4px 6px; margin-top: 5px; align-items: center; }
.tr-log { margin-top: 5px; font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tr-side { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; flex-shrink: 0; }
.tr-side > .chip { font-size: 11px; }
.tr-actions { display: flex; gap: 5px; }
.today-card.danger .card-head h2 { color: #b91c1c; }
.today-card.push .card-head h2 { color: #c2410c; }
.empty.small { padding: 16px 12px; font-size: 13px; }

/* Hộp thoại form */
.seg-input { display: flex; width: 100%; }
.seg-input button { flex: 1; }
.quick-dates { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; }
.quick-dates button { padding: 1px 8px; font-size: 12px; border-radius: 99px; color: var(--text-2); }

/* Kanban */
.kanban { display: grid; grid-template-columns: repeat(5, minmax(200px, 1fr)); gap: 12px; overflow-x: auto; align-items: start; padding-bottom: 6px; }
.kb-col { background: #eceef1; border-radius: 12px; padding: 10px; min-height: 200px; transition: background .15s; }
.kb-col.over { background: #dbeafe; }
.kb-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.kb-items { display: flex; flex-direction: column; gap: 8px; }
.kb-card { background: var(--surface); border-radius: 9px; padding: 9px 11px; border-left: 4px solid #d1d5db; box-shadow: 0 1px 2px rgba(0,0,0,.06); cursor: grab; }
.kb-card.dragging { opacity: .5; }
.kb-title { display: block; color: var(--text); font-weight: 600; font-size: 13px; line-height: 1.4; }
.kb-mobile-status { display: none; margin-top: 6px; font-size: 12px; padding: 3px 6px; }

/* Lịch */
.cal-nav { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.cal-nav .hint { margin-left: auto; }
.cal { overflow-x: auto; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(110px, 1fr)); }
.cal-dow { padding: 8px 10px; font-size: 12px; font-weight: 600; color: var(--muted); border-bottom: 1px solid var(--border); }
.cal-cell { min-height: 108px; padding: 6px 7px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); min-width: 0; }
.cal-cell:nth-child(7n) { border-right: 0; }
.cal-cell.other { background: var(--surface-2); }
.cal-cell.other .cal-date { color: var(--faint); }
.cal-cell.today { background: var(--accent-soft); }
.cal-cell.today .cal-date { background: var(--accent); color: #fff; border-radius: 99px; padding: 0 7px; display: inline-block; }
.cal-date { font-size: 12px; font-weight: 600; margin-bottom: 4px; }
.cal-item { display: block; font-size: 11.5px; line-height: 1.35; padding: 2px 5px; border-radius: 5px; margin-bottom: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text-2); background: #eff6ff; }
.cal-item.push { background: #fff7ed; color: #c2410c; }
.cal-item.late { background: #fee2e2; color: #b91c1c; }
.cal-item.done { text-decoration: line-through; color: var(--faint); background: #f3f4f6; }

/* Danh sách đơn giản */
.simple-list { list-style: none; margin: 0; padding: 4px 18px; }
.simple-list li { display: flex; align-items: center; gap: 4px; padding: 9px 0; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.simple-list li:last-child { border-bottom: 0; }
.simple-list a { color: var(--text); font-weight: 600; }
.sl-right { margin-left: auto; display: flex; gap: 5px; align-items: center; }
.bars .b-track { display: flex; }
.bars .b-fill.done { background: #cbd5e1; border-radius: 0 99px 99px 0; }
.bars li { grid-template-columns: minmax(0, 1fr) 60px; }

/* Chi tiết việc */
dialog.wide { width: min(1000px, calc(100vw - 32px)); max-height: calc(100vh - 40px); }
.detail .d-head { align-items: flex-start; gap: 10px; }
.detail .d-head h3 { font-size: 18px; margin-top: 2px; line-height: 1.35; }
.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) 290px; gap: 16px; padding: 16px 22px 22px; max-height: calc(100vh - 170px); overflow-y: auto; }
.detail-text { white-space: pre-wrap; line-height: 1.6; color: var(--text-2); background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px; }
.detail-main > * + * { margin-top: 14px; }
.sub-card { box-shadow: none; }
.sub-card .card-head { padding: 10px 14px; }
.sub-card .card-head h3 { font-size: 14px; }
.info { padding: 6px 14px; }
.info-row { display: flex; justify-content: space-between; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.info-row:last-child { border-bottom: 0; }
.info-row > span:last-child { text-align: right; font-weight: 500; }
.detail-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.detail-actions select { padding: 5px 8px; }
.timeline { list-style: none; margin: 0; padding: 8px 14px 12px 30px; position: relative; }
.timeline::before { content: ""; position: absolute; left: 18px; top: 14px; bottom: 14px; width: 2px; background: var(--border); }
.timeline li { position: relative; padding: 7px 0; font-size: 13px; line-height: 1.5; }
.timeline li::before { content: ""; position: absolute; left: -16px; top: 13px; width: 10px; height: 10px; border-radius: 50%; background: #cbd5e1; border: 2px solid var(--surface); }
.timeline li.tl-push::before { background: #f97316; }
.timeline li.tl-update::before { background: var(--accent); }
.timeline li.tl-system { color: var(--muted); font-size: 12.5px; }
.tl-head { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.tl-head .link { margin-left: auto; }
.tl-response { color: #047857; }

@media (max-width: 900px) {
  .task-row { flex-direction: column; gap: 8px; }
  .tr-side { flex-direction: row; flex-wrap: wrap; align-items: center; }
  .task-row.child { margin-left: 12px; }
  .filters select, .filters input[type=search] { flex: 1 1 140px; max-width: none; width: auto; }
  .kanban { grid-template-columns: minmax(0, 1fr); }
  .kb-mobile-status { display: block; width: 100%; }
  .detail-grid { grid-template-columns: minmax(0, 1fr); padding: 14px; }
  .cal-grid { grid-template-columns: repeat(7, minmax(44px, 1fr)); }
  .cal-cell { min-height: 70px; padding: 4px; }
  .cal-item { font-size: 10px; padding: 1px 3px; }
  .check-list { grid-template-columns: minmax(0, 1fr); }
  .main { min-width: 0; overflow-x: hidden; }
  .card-head { flex-wrap: wrap; }
  .today-card .card-head .hint { flex-basis: 100%; }
  .pagebar .clock { display: none; }
  .tr-meta .chip { white-space: normal; }
}
.form-grid textarea { min-height: 72px; }
