:root {
  --bg: #f7f9fc;
  --surface: #ffffff;
  --text: #101828;
  --heading: #081426;
  --muted: #475467;
  --line: #eaecf0;
  --primary: #155eef;
  --primary-soft: #eef4ff;
  --green: #12a150;
  --green-soft: #ecf6f1;
  --orange: #f79009;
  --orange-soft: #fff4e8;
  --red: #f04438;
  --red-soft: #fef3f2;
  --gray-soft: #f2f4f7;
  --radius: 14px;
  --font-body: "Source Sans 3", "Segoe UI", system-ui, sans-serif;
  --font-head: Manrope, "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 var(--font-body); }
a { color: var(--primary); text-decoration: none; }
h1 { margin: 0; font: 800 28px/1.2 var(--font-head); color: var(--heading); }
h2 { margin: 0; font: 800 17px/1.25 var(--font-head); color: var(--heading); }
small { display: block; color: var(--muted); font-size: 12px; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
[hidden] { display: none !important; }
.muted { color: var(--muted); font-size: 13px; }
.grow { flex: 1; min-width: 0; }
.pad { padding: 16px; }

/* Nút */
.btn { height: 40px; padding: 0 14px; display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--text); font: 700 13px var(--font-body); cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--bg); }
.btn svg { width: 16px; height: 16px; }
.btn-primary { border-color: var(--primary); background: var(--primary); color: #fff; }
.btn-primary:hover { background: #0f4fd1; }
.icon-btn { width: 34px; height: 34px; display: grid; place-items: center; border: 0; border-radius: 10px; background: none; color: var(--muted); cursor: pointer; }
.icon-btn:hover { background: var(--bg); }
.icon-btn.small svg { width: 16px; height: 16px; }

/* Thanh trên + menu */
.topbar { position: sticky; top: 8px; z-index: 20; margin: 8px 16px 0; height: 56px; padding: 0 16px; display: flex; align-items: center; justify-content: space-between; background: var(--surface); border-radius: var(--radius); box-shadow: 0 1px 3px rgba(16, 24, 40, .06); }
.topbar-start { display: flex; align-items: center; gap: 24px; min-width: 0; }
.topbar-end { display: flex; align-items: center; gap: 6px; }
.menu-toggle { display: none; }
.brand { display: flex; align-items: center; gap: 8px; color: var(--heading); font: 600 14px var(--font-head); white-space: nowrap; }
.brand b { color: var(--primary); }
.brand-mark { width: 26px; height: 26px; display: grid; place-items: center; border-radius: 8px; background: var(--primary); color: #fff; font-weight: 800; }
.menu { display: flex; align-items: center; gap: 4px; }
.menu-item { position: relative; height: 56px; padding: 0 8px; display: inline-flex; align-items: center; gap: 4px; border: 0; background: none; color: var(--muted); font: 600 13px var(--font-head); white-space: nowrap; cursor: pointer; }
.menu-item:hover { color: var(--heading); }
.caret { font-size: 10px; opacity: .6; }
.menu .active > .menu-item, .menu a.menu-item.active { color: var(--primary); }
.menu .active > .menu-item::after, .menu a.menu-item.active::after { content: ""; position: absolute; left: 8px; right: 8px; bottom: 8px; height: 2px; border-radius: 2px; background: var(--primary); }
.menu-group { position: relative; }
.dropdown { position: absolute; top: calc(100% - 4px); left: 0; min-width: 300px; padding: 6px; display: none; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 12px 32px rgba(16, 24, 40, .12); }
.menu-group.open .dropdown { display: grid; }
.dropdown a { padding: 10px 12px; border-radius: 10px; color: var(--heading); }
.dropdown a:hover, .dropdown a.current { background: var(--primary-soft); }
.dropdown b { display: block; font: 700 13.5px var(--font-head); }
.avatar { position: relative; width: 34px; height: 34px; margin-left: 6px; display: grid; place-items: center; border-radius: 50%; background: var(--primary-soft); color: var(--primary); font: 700 11px var(--font-head); }
.avatar i { position: absolute; right: -1px; bottom: -1px; width: 11px; height: 11px; border: 2px solid #fff; border-radius: 50%; background: var(--green); }

/* Thông báo dùng thử */
.trial-notice { margin: 10px 16px 0; padding: 8px 16px; display: flex; align-items: center; gap: 12px; background: var(--primary-soft); border: 1px solid var(--line); border-radius: var(--radius); }
.trial-notice > svg { color: var(--primary); }
.trial-notice p { flex: 1; margin: 0; font-size: 13px; }
.trial-notice p span { color: var(--muted); }

/* Bố cục trang */
.dashboard-page { max-width: 1400px; margin: 0 auto; padding: 24px 16px 64px; display: grid; gap: 16px; align-content: start; }
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin: 8px 0 4px; }
.page-header p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.page-tools { display: flex; justify-content: flex-end; }
.page-tools a { display: inline-flex; align-items: center; gap: 6px; font: 700 13px var(--font-head); }
.page-tools svg { width: 16px; height: 16px; }
.dashboard-layout { display: grid; grid-template-columns: minmax(0, 1fr) 316px; gap: 16px; align-items: start; }
.stack { display: grid; gap: 16px; align-content: start; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-2-wide { display: grid; grid-template-columns: 1.45fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.tile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; min-width: 0; }
.card-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; }
.section-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 14px 16px; }
.section-heading p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.section-heading > a { flex-shrink: 0; font-size: 12px; font-weight: 700; }

/* Thẻ chỉ số */
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; padding: 12px; }
.stat-grid.five { grid-template-columns: repeat(5, 1fr); }
.stat { position: relative; padding: 16px; border-radius: 12px; }
.stat.blue { background: var(--primary-soft); }
.stat.green { background: var(--green-soft); }
.stat.orange { background: var(--orange-soft); }
.stat.red { background: var(--red-soft); }
.stat > span { color: var(--muted); font-size: 12px; font-weight: 650; }
.stat strong { display: block; margin: 8px 0 10px; font: 800 26px/1.2 var(--font-head); }
.stat small { font-size: 11.5px; }
.stat .stat-icon { position: absolute; top: 14px; right: 14px; width: 36px; height: 36px; display: grid; place-items: center; border-radius: 10px; background: rgba(255, 255, 255, .6); }
.stat.blue .stat-icon { color: var(--primary); }
.stat.green .stat-icon { color: var(--green); }
.stat.orange .stat-icon { color: var(--orange); }

/* Biểu đồ */
.insight-grid { display: grid; grid-template-columns: 1fr 1fr; border-top: 1px solid var(--line); }
.insight + .insight { border-left: 1px solid var(--line); }
.insight .section-heading { border-bottom: 1px solid var(--line); padding-bottom: 20px; }
.chart { padding: 16px; }
.chart svg { width: 100%; height: 210px; stroke: none; }
.chart text { fill: var(--muted); font: 10px var(--font-body); }
.chart .val { fill: var(--text); font-weight: 700; }
.chart .grid { stroke: var(--line); stroke-dasharray: 3 3; }
.split-bars { display: grid; gap: 14px; }
.split-label { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 6px; font-size: 13px; }
.bar { height: 8px; border-radius: 8px; background: var(--gray-soft); overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 8px; }

/* Danh sách */
ul, ol { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--line); }
.list b { display: block; font-size: 14px; }
.empty-day { justify-content: center; color: var(--muted); font-size: 13px; }
.meter { width: 120px; }
.meter > div { height: 6px; border-radius: 6px; background: var(--line); overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--primary); border-radius: 6px; }
.meter small { margin-top: 4px; text-align: right; }
.time { width: 56px; flex-shrink: 0; padding: 6px 0; text-align: center; border-radius: 10px; background: var(--primary-soft); color: var(--primary); font: 800 13px var(--font-head); }
.activity li { display: flex; gap: 10px; padding: 12px 16px; font-size: 13px; border-top: 1px solid var(--line); }
.activity .dot { flex-shrink: 0; width: 8px; height: 8px; margin-top: 6px; border-radius: 50%; background: var(--primary); }
.check { width: 26px; height: 26px; display: grid; place-items: center; border-radius: 50%; background: var(--green-soft); color: var(--green); }
.check svg { width: 14px; height: 14px; }
.steps li { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-top: 1px solid var(--line); }
.step-dot { width: 30px; height: 30px; display: grid; place-items: center; flex-shrink: 0; border-radius: 50%; color: #fff; font: 800 12px var(--font-head); text-shadow: 0 0 2px rgba(0, 0, 0, .4); }

/* Badge */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 700; white-space: nowrap; }
.badge.green { background: var(--green-soft); color: var(--green); }
.badge.orange { background: var(--orange-soft); color: #b54708; }
.badge.blue { background: var(--primary-soft); color: var(--primary); }
.badge.red { background: var(--red-soft); color: var(--red); }
.badge.gray { background: var(--gray-soft); color: var(--muted); }

/* Thanh lọc */
.toolbar { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; padding: 0 16px 14px; }
.search { flex: 1; min-width: 220px; height: 40px; padding: 0 12px; display: flex; align-items: center; gap: 8px; border: 1px solid #d0d5dd; border-radius: 12px; color: var(--muted); }
.search:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; font: inherit; font-size: 14px; color: var(--text); }
.field { display: grid; gap: 4px; font-size: 12px; font-weight: 650; color: var(--muted); }
.field select, .field input { height: 40px; padding: 0 10px; border: 1px solid #d0d5dd; border-radius: 12px; background: var(--surface); font: 14px var(--font-body); color: var(--text); }
.segmented { display: inline-flex; padding: 3px; gap: 2px; border-radius: 12px; background: var(--gray-soft); }
.segmented button { height: 32px; padding: 0 12px; border: 0; border-radius: 9px; background: none; color: var(--muted); font: 700 12.5px var(--font-body); cursor: pointer; }
.segmented button.active { background: var(--surface); color: var(--heading); box-shadow: 0 1px 2px rgba(16, 24, 40, .1); }

/* Bảng */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th { padding: 10px 16px; text-align: left; background: var(--bg); color: var(--muted); font: 700 12px var(--font-body); white-space: nowrap; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafbfd; }
.right { text-align: right; }
.pos { color: var(--green); font-weight: 700; white-space: nowrap; }
.neg { color: var(--red); font-weight: 700; white-space: nowrap; }
.no-match { padding: 24px; text-align: center; color: var(--muted); font-size: 13px; }
.person { display: flex; align-items: center; gap: 10px; }
.person b { display: block; font-size: 13.5px; white-space: nowrap; }
.avatar-sm { width: 32px; height: 32px; display: grid; place-items: center; flex-shrink: 0; border-radius: 50%; background: var(--primary-soft); color: var(--primary); font: 800 11px var(--font-head); }
.pager { display: inline-flex; align-items: center; gap: 8px; }
.pager button { width: 28px; height: 28px; border: 1px solid var(--line); border-radius: 8px; background: none; color: var(--muted); }
.empty { padding: 48px 16px; display: grid; justify-items: center; gap: 8px; color: var(--muted); text-align: center; }
.empty.big svg { width: 32px; height: 32px; color: var(--primary); }
.empty p { margin: 0; }

/* Tab */
.tab-list { display: flex; gap: 4px; padding: 0 12px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tab-list button { position: relative; height: 46px; padding: 0 12px; border: 0; background: none; color: var(--muted); font: 700 13px var(--font-head); white-space: nowrap; cursor: pointer; }
.tab-list button.active { color: var(--primary); }
.tab-list button.active::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 2px; border-radius: 2px; background: var(--primary); }

/* Dải ngày + điểm danh */
.week-strip { display: flex; align-items: center; gap: 8px; padding: 0 16px 14px; }
.days { flex: 1; display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.day { padding: 8px 0; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); cursor: pointer; }
.day b { font: 800 16px var(--font-head); }
.day.active { border-color: var(--primary); background: var(--primary); color: #fff; }
.day.active small { color: rgba(255, 255, 255, .8); }
.roster-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 16px 14px; }
.roster-head span { font: 800 14px var(--font-head); color: var(--green); }

/* Cơ sở */
.tile { padding: 18px; display: grid; gap: 10px; }
.tile-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.with-icon { display: flex; align-items: center; gap: 6px; margin: 0; }
.tile dl { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 6px 0 0; }
.tile dt { color: var(--muted); font-size: 12px; }
.tile dd { margin: 2px 0 0; font: 800 15px var(--font-head); }

/* Cộng đồng */
.cover-art { height: 120px; background: linear-gradient(120deg, #155eef 0%, #6aa2ff 55%, #b8d4ff 100%); }
.cover-body { display: flex; align-items: flex-end; gap: 14px; padding: 0 20px 14px; margin-top: -32px; }
.cover-body h1 { font-size: 22px; }
.cover-body p { margin: 2px 0 0; }
.cover-logo { width: 72px; height: 72px; display: grid; place-items: center; flex-shrink: 0; border: 4px solid #fff; border-radius: 18px; background: var(--primary); color: #fff; font: 800 28px var(--font-head); }
.composer { padding: 14px 16px; display: grid; gap: 10px; }
.composer textarea { width: 100%; padding: 10px 12px; border: 1px solid #d0d5dd; border-radius: 12px; resize: vertical; font: 14px var(--font-body); }
.composer-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.post { padding: 16px; display: grid; gap: 10px; }
.post p { margin: 0; font-size: 14.5px; }
.post-meta { display: flex; align-items: center; gap: 12px; }
.post-meta .btn { height: 32px; }
.post-meta .liked { color: var(--red); border-color: var(--red-soft); background: var(--red-soft); }

/* Thông báo nhanh */
.toast { position: fixed; left: 50%; bottom: 24px; z-index: 50; transform: translateX(-50%); padding: 10px 16px; border-radius: 12px; background: var(--heading); color: #fff; font-size: 13.5px; box-shadow: 0 8px 24px rgba(16, 24, 40, .25); }

@media (max-width: 1200px) {
  .topbar-start { gap: 12px; }
  .brand span:last-child { display: none; }
  .menu-item { padding: 0 6px; }
  .dashboard-layout { grid-template-columns: minmax(0, 1fr) 260px; }
  .stat-grid.five { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 1060px) {
  .menu-toggle { display: grid; }
  .menu { position: fixed; top: 72px; left: 16px; right: 16px; max-height: calc(100vh - 88px); overflow-y: auto; padding: 8px; display: none; flex-direction: column; align-items: stretch; gap: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 12px 32px rgba(16, 24, 40, .14); }
  .menu-open .menu { display: flex; }
  .menu-item { width: 100%; height: 44px; justify-content: space-between; }
  .menu .active > .menu-item::after, .menu a.menu-item.active::after { display: none; }
  .dropdown { position: static; min-width: 0; box-shadow: none; border: 0; padding: 0 0 6px 8px; }
  .dashboard-layout, .grid-3 { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .topbar { margin: 8px 8px 0; }
  .menu { left: 8px; right: 8px; }
  .trial-notice { margin: 8px 8px 0; flex-wrap: wrap; }
  .dashboard-page { padding: 16px 8px 48px; }
  h1 { font-size: 23px; }
  .stat-grid, .stat-grid.five, .insight-grid, .grid-2, .grid-2-wide { grid-template-columns: 1fr; }
  .insight + .insight { border-left: 0; border-top: 1px solid var(--line); }
  .days { gap: 3px; }
  .day b { font-size: 14px; }
  .week-strip { padding: 0 8px 12px; gap: 4px; }
  .week-strip > .btn { padding: 0 8px; }
}
