:root {
  color-scheme: light;
  --bg: #f6f6f3;
  --surface: #ffffff;
  --surface-2: #eeeeea;
  --line: #deded8;
  --text: #1d1d1b;
  --muted: #66665f;
  --accent: #c2410c;
  --accent-soft: #fdebe0;
  --accent-text: #ffffff;
  --red: #b91c1c;
  --red-soft: #fde8e8;
  --amber: #92580a;
  --amber-soft: #fbf0d5;
  --green: #15703d;
  --green-soft: #dff5e6;
  --shadow: 0 8px 30px rgba(20, 20, 15, .16);
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #161614;
    --surface: #20201d;
    --surface-2: #2b2b27;
    --line: #3a3a35;
    --text: #efefe9;
    --muted: #a6a69c;
    --accent: #f0813f;
    --accent-soft: #43261a;
    --accent-text: #1c0f07;
    --red: #f58a8a;
    --red-soft: #44201f;
    --amber: #e8b75c;
    --amber-soft: #3d3119;
    --green: #6fd196;
    --green-soft: #1b3a28;
    --shadow: 0 8px 30px rgba(0, 0, 0, .5);
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  display: flex;
  flex-direction: column;
}
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
input, select, textarea {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 9px;
  min-height: 34px;
  width: 100%;
}
textarea { resize: vertical; }
:is(a, button, input, select, textarea):focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.btn {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 6px;
  padding: 6px 12px;
  min-height: 34px;
  cursor: pointer;
  font-weight: 600;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--red); border-color: var(--red); }
.btn.danger:hover { background: var(--red-soft); }
.btn.danger.solid { background: var(--red); color: var(--surface); }
.btn.danger.solid:hover { background: var(--red); filter: brightness(1.08); }
.btn:disabled { opacity: .55; cursor: default; }

/* Thanh trên cùng */
.topbar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 8px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  flex: none;
}
.brand { display: flex; white-space: nowrap; align-items: center; gap: 8px; font-weight: 700; text-decoration: none; font-size: 15px; }
.brand-mark {
  width: 26px; height: 26px; border-radius: 7px; display: grid; place-items: center;
  background: var(--accent); color: var(--accent-text); font-weight: 800;
}
.nav { display: flex; gap: 2px; }
.nav a { padding: 6px 11px; border-radius: 6px; text-decoration: none; color: var(--muted); font-weight: 600; white-space: nowrap; }
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { background: var(--accent-soft); color: var(--accent); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.whoami { display: flex; align-items: center; gap: 8px; }
.whoami-label { color: var(--muted); font-size: 12px; white-space: nowrap; }
.whoami-name { font-weight: 600; white-space: nowrap; }
.link-btn { background: none; border: 0; padding: 4px; color: var(--muted); cursor: pointer; font-size: 13px; text-decoration: underline; white-space: nowrap; }
.link-btn:hover { color: var(--text); }
.auth-page { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: min(400px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 22px; }
.auth-card h1 { font-size: 20px; margin: 10px 0 4px; }
.auth-card > p { color: var(--muted); margin: 0 0 16px; }
.auth-card .field { margin-bottom: 12px; }
.auth-card .btn { width: 100%; }
.auth-error { background: var(--red-soft); color: var(--red); border-radius: 6px; padding: 7px 10px; margin-bottom: 12px; font-weight: 600; }
.credential-box { background: var(--surface-2); border-radius: 8px; padding: 10px 12px; margin-bottom: 12px; }
.credential-box code { font-size: 15px; font-weight: 700; overflow-wrap: anywhere; }
.credential-row { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 8px; padding: 3px 0; align-items: baseline; }
.warn-text { color: var(--amber); font-weight: 600; margin: 0 0 12px; }
.row-actions { display: flex; gap: 6px; }
.page.wide { max-width: 1500px; }
.dash-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; padding: 0 16px; }
.dash-card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; min-width: 0; }
.dash-card.full { grid-column: 1 / -1; }
.dash-card h2 { font-size: 15px; margin: 0 0 10px; }
.dash-card .table-wrap { margin: 0 -16px; border: 0; border-radius: 0; }
.dash-card details { margin-top: 10px; font-size: 13.5px; }
.dash-card summary { cursor: pointer; font-weight: 600; }
.dash-list { margin: 6px 0 0; padding-left: 18px; }
.dash-list li { margin-bottom: 3px; }
.dash-note { color: var(--muted); font-size: 12.5px; margin: 8px 0 0; }
.dash-compact td:first-child { min-width: 0; }
.dash-num { text-align: right; font-variant-numeric: tabular-nums; }
.funnel { display: grid; grid-template-columns: max-content minmax(0, 1fr) 2.5em; gap: 7px 10px; align-items: center; }
.funnel-track { height: 10px; }
.funnel-bar { height: 100%; min-width: 2px; background: var(--accent); border-radius: 0 4px 4px 0; }
.funnel-value { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.stock-line { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; }
@media (max-width: 900px) { .dash-grid { grid-template-columns: minmax(0, 1fr); } }
.report-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; }
.report-form select { width: auto; max-width: 100%; flex: 1 1 180px; }
.report-form input { width: 110px; }
.report-section { margin: 0 16px 12px; }
.report-num { width: 120px; text-align: right; font-variant-numeric: tabular-nums; }
.pay-close { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 0 16px 12px; padding: 10px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); }
.pay-close.closed { background: var(--green-soft); }
.pay-close span { flex: 1 1 240px; font-size: 13.5px; }
.status-dot:disabled { cursor: default; opacity: .75; }
.pay-summary { display: flex; flex-wrap: wrap; gap: 10px; padding: 0 16px 12px; }
.pay-stat { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 8px 14px; min-width: 150px; }
.pay-stat span { display: block; color: var(--muted); font-size: 12px; }
.pay-stat b { font-size: 17px; font-variant-numeric: tabular-nums; }
.payroll-table th { font-size: 12px; }
.payroll-table td { padding: 10px 12px; white-space: nowrap; }
.payroll-table td:first-child { min-width: 0; font-weight: 400; text-align: center; }
.payroll-table tr.unpaid { background: var(--amber-soft); }
.payroll-table tr.paid { background: var(--green-soft); }
.payroll-table tr.nobank { background: var(--surface-2); }
.status-dot { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--muted); background: var(--surface); cursor: pointer; display: inline-grid; place-items: center; padding: 0; color: var(--accent-text); }
.status-dot[aria-pressed="true"] { background: var(--green); border-color: var(--green); color: var(--surface); }
.pay-code { font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; }
.pay-name { font-weight: 600; font-size: 15px; white-space: normal; min-width: 180px; }
.pay-sub { color: var(--muted); font-size: 12.5px; }
.pay-account { font-family: Consolas, "Courier New", monospace; color: var(--muted); font-size: 13px; }
.bank-pill { display: inline-block; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 2px 11px; font-weight: 700; font-size: 12.5px; }
.pay-amount { width: 150px; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.pay-actions { display: flex; gap: 6px; }
.action-icon { width: 36px; height: 36px; display: inline-grid; place-items: center; border-radius: 7px; border: 1px solid var(--line); background: var(--surface); color: var(--text); cursor: pointer; padding: 0; }
.action-icon.qr { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.action-icon:disabled { opacity: .4; cursor: default; }
.qr-frame { background: #fff; border-radius: 10px; padding: 8px; display: grid; place-items: center; margin-bottom: 12px; }
.qr-frame canvas { max-width: 100%; height: auto; image-rendering: pixelated; }
.qr-info { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 4px 10px; margin-bottom: 12px; }
.qr-info dt { color: var(--muted); font-size: 12.5px; }
.qr-info dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.members-table select { width: 112px; }
.members-table input { width: 150px; }
.members-table th, .members-table td { padding: 8px; }
.members-table th { white-space: normal; }
.member-code { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--muted); }
.members-table td:first-child { min-width: 0; font-weight: 400; }
.members-table td:nth-child(2) { font-weight: 600; min-width: 150px; }
.bank-cell { display: flex; align-items: center; gap: 8px; }
.bank-cell small { color: var(--muted); display: block; }
.audit { margin: 18px 16px 0; }
.audit summary { cursor: pointer; font-weight: 700; color: var(--muted); font-size: 13px; padding: 4px 0; }
.audit-row { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-top: 1px solid var(--line); }
.audit-row:first-child { border-top: 0; }
.bank-current { background: var(--surface-2); border-radius: 8px; padding: 10px 12px; margin-bottom: 14px; }
.bank-number { font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.section-divider { border: 0; border-top: 1px solid var(--line); margin: 14px 0; }
.modal { max-height: calc(100% - 32px); overflow-y: auto; }
input:disabled, select:disabled, textarea:read-only { background: var(--surface-2); color: var(--muted); opacity: 1; }
.title-input:read-only { background: transparent; color: var(--text); }
.title-input:read-only:hover { border-color: transparent; }
.member-name { display: flex; align-items: center; gap: 8px; }
.members-table td:first-child { min-width: 170px; }
.members-table select { width: 120px; }
.members-table input { width: 190px; }
.skill-tags { display: flex; flex-wrap: wrap; gap: 4px; min-width: 150px; white-space: normal; }
.row-inactive { opacity: .6; }
.check-group { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.check { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.check input { width: 16px; height: 16px; min-height: 0; margin: 0; }
.icon-btn {
  position: relative; width: 36px; height: 36px; display: grid; place-items: center;
  border: 0; background: transparent; border-radius: 8px; cursor: pointer; color: var(--muted);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.badge {
  position: absolute; top: 1px; right: 0; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px;
  background: var(--red); color: var(--surface); font-size: 11px; font-weight: 700; line-height: 17px; text-align: center;
}

main { flex: 1; min-height: 0; overflow: auto; }

/* Thanh lọc */
.toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  padding: 12px 16px;
}
.toolbar h1 { font-size: 18px; margin: 0 8px 0 0; }
.toolbar input[type=search] { width: 230px; }
.toolbar select { width: auto; max-width: 170px; }
.toolbar .spacer { flex: 1; }
.toolbar .count { color: var(--muted); font-size: 13px; }

/* Bảng kanban */
.board-page { height: 100%; display: flex; flex-direction: column; }
.board {
  flex: 1; min-height: 0; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(250px, 1fr);
  gap: 10px; padding: 0 16px 16px; overflow-x: auto;
}
.column {
  background: var(--surface-2); border-radius: 10px; display: flex; flex-direction: column; min-height: 0;
  border: 2px solid transparent;
}
.column.drag-over { border-color: var(--accent); }
.column-head { display: flex; align-items: center; gap: 7px; padding: 10px 12px 6px; font-weight: 700; }
.column-head .n { color: var(--muted); font-weight: 600; margin-left: auto; font-variant-numeric: tabular-nums; }
.column-body { flex: 1; overflow-y: auto; padding: 4px 8px 8px; display: flex; flex-direction: column; gap: 7px; min-height: 60px; }
.column-more { color: var(--muted); font-size: 12.5px; padding: 4px 6px; }
.column-empty { color: var(--muted); font-size: 13px; padding: 10px 6px; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px;
  cursor: pointer; display: block; width: 100%; text-align: left; flex: none;
}
.card:hover { border-color: var(--accent); }
.card.dragging { opacity: .45; }
.card-title { font-weight: 600; overflow-wrap: anywhere; }
.card-tags { margin-top: 5px; display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.tag { font-size: 12px; color: var(--muted); }
.card-foot { display: flex; align-items: center; gap: 6px; margin-top: 8px; font-size: 12px; color: var(--muted); }
.card-foot .right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.pill { font-size: 12px; padding: 1px 7px; border-radius: 10px; white-space: nowrap; font-weight: 600; background: var(--surface-2); color: var(--muted); }
.pill.late { background: var(--red-soft); color: var(--red); }
.pill.soon { background: var(--amber-soft); color: var(--amber); }
.pill.ok { background: var(--green-soft); color: var(--green); }
.avatar {
  width: 20px; height: 20px; border-radius: 50%; display: inline-grid; place-items: center; flex: none;
  font-size: 10px; font-weight: 700; color: #fff;
}
.avatar.lg { width: 28px; height: 28px; font-size: 12px; }
.owner { display: inline-flex; align-items: center; gap: 5px; min-width: 0; }
.owner span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.unassigned { color: var(--amber); font-weight: 600; }

/* Nội dung dạng trang */
.page { max-width: 1120px; margin: 0 auto; padding: 4px 0 40px; }
.section { padding: 0 16px; margin-top: 18px; }
.section-title { font-size: 13px; font-weight: 700; color: var(--muted); margin: 0 0 8px; }
.list { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 12px; align-items: center;
  padding: 10px 14px; width: 100%; background: none; border: 0; border-top: 1px solid var(--line);
  cursor: pointer; text-align: left;
}
.row:first-child { border-top: 0; }
.row:hover { background: var(--surface-2); }
.row-title { font-weight: 600; overflow-wrap: anywhere; }
.row-sub { color: var(--muted); font-size: 12.5px; }
.empty { padding: 24px; text-align: center; color: var(--muted); }

.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; overflow-x: auto; margin: 0 16px; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 8px 12px; text-align: left; border-top: 1px solid var(--line); white-space: nowrap; }
td:first-child { white-space: normal; min-width: 240px; font-weight: 600; }
th { border-top: 0; font-size: 12px; color: var(--muted); position: sticky; top: 0; background: var(--surface); }
.tasks-table tbody tr { cursor: pointer; }
.tasks-table tbody tr:hover { background: var(--surface-2); }
.more { display: flex; justify-content: center; padding: 14px; }

/* Trang Discord */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; }
.panel h2 { font-size: 15px; margin: 0 0 6px; }
.panel p { margin: 0 0 10px; color: var(--muted); }
.panel ol { margin: 0 0 10px; padding-left: 20px; }
.panel code { background: var(--surface-2); padding: 1px 5px; border-radius: 4px; font-size: 13px; }
.status-line { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 10px; font-weight: 600; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 8px 16px; }
.person-row { display: grid; grid-template-columns: 130px minmax(0, 1fr); gap: 8px; align-items: center; }
.person-row label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.log-row { display: grid; grid-template-columns: 104px minmax(0, 1fr) auto; gap: 10px; padding: 7px 0; border-top: 1px solid var(--line); align-items: baseline; }
.log-row:first-child { border-top: 0; }
.log-detail { color: var(--muted); font-size: 12.5px; overflow-wrap: anywhere; }
.log-time { color: var(--muted); font-size: 12px; white-space: nowrap; }

/* Ngăn chi tiết bài */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, .35); z-index: 20; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(620px, 100%);
  background: var(--surface); z-index: 21; box-shadow: var(--shadow); display: flex; flex-direction: column;
}
.drawer-head { padding: 14px 18px 10px; border-bottom: 1px solid var(--line); }
.drawer-top { display: flex; gap: 8px; align-items: flex-start; }
.title-input {
  font-size: 18px; font-weight: 700; border-color: transparent; background: transparent; padding: 3px 6px; margin-left: -6px;
  resize: none; overflow: hidden; line-height: 1.3;
}
.title-input:hover { border-color: var(--line); }
.status-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 8px; }
.status-bar select { width: auto; font-weight: 600; }
.drawer-body { flex: 1; overflow-y: auto; padding: 14px 18px 18px; }
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; }
.field label, .field-label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 3px; }
.field.wide { grid-column: 1 / -1; }
.field.is-owner label { color: var(--accent); }
.link-row { display: grid; grid-template-columns: 56px minmax(0, 1fr) auto; gap: 8px; align-items: center; padding: 5px 0; border-top: 1px solid var(--line); }
.link-row:first-of-type { border-top: 0; }
.link-row a { color: var(--accent); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-none { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-edit { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 12.5px; text-decoration: underline; padding: 4px; }
.block-title { font-size: 13px; font-weight: 700; margin: 20px 0 8px; }
.timeline { display: flex; flex-direction: column; gap: 12px; }
.comment { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 9px; }
.comment-meta { font-size: 12.5px; color: var(--muted); }
.comment-meta b { color: var(--text); }
.comment-body { white-space: pre-wrap; overflow-wrap: anywhere; margin-top: 1px; }
.mention { color: var(--accent); font-weight: 600; background: var(--accent-soft); border-radius: 4px; padding: 0 3px; }
.activity { color: var(--muted); font-size: 12.5px; padding-left: 37px; }
.composer { position: relative; border-top: 1px solid var(--line); padding: 10px 18px 12px; background: var(--surface); }
.composer textarea { min-height: 62px; display: block; }
.composer-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 7px; }
.hint { color: var(--muted); font-size: 12.5px; }
.mention-menu {
  position: absolute; left: 18px; bottom: calc(100% - 6px); width: 240px; max-height: 230px; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); padding: 4px;
}
.mention-item { display: flex; gap: 7px; align-items: center; width: 100%; border: 0; background: none; padding: 6px 8px; border-radius: 5px; cursor: pointer; text-align: left; }
.mention-item.active, .mention-item:hover { background: var(--accent-soft); }

/* Bảng thông báo, tạo bài, toast */
.popover {
  position: fixed; top: 54px; right: 16px; width: min(390px, calc(100% - 32px)); max-height: 70vh; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); z-index: 30;
}
.notif { display: block; width: 100%; padding: 10px 13px; border: 0; border-top: 1px solid var(--line); background: none; text-align: left; cursor: pointer; }
.notif:first-child { border-top: 0; }
.notif:hover { background: var(--surface-2); }
.notif.unread { background: var(--accent-soft); }
.notif-title { font-weight: 600; }
.notif-time { color: var(--muted); font-size: 12px; }
.modal {
  border: 0; border-radius: 12px; padding: 18px; width: min(460px, calc(100% - 32px));
  background: var(--surface); color: var(--text); box-shadow: var(--shadow);
}
.modal::backdrop { background: rgba(0, 0, 0, .4); }
.modal h2 { margin: 0 0 12px; font-size: 17px; }
.modal .fields { margin-bottom: 14px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 40;
  background: var(--text); color: var(--surface); padding: 8px 14px; border-radius: 8px; font-weight: 600;
  max-width: calc(100% - 32px);
}
.toast.error { background: var(--red); }

.nav-more, .column-tabs, .more-sheet { display: none; }

@media (max-width: 760px) {
  :root { --nav-height: calc(56px + env(safe-area-inset-bottom)); }
  body { height: 100dvh; }

  /* Thanh đầu một hàng, điều hướng chính xuống đáy màn hình cho dễ bấm bằng ngón cái */
  .topbar { gap: 8px; padding: calc(6px + env(safe-area-inset-top)) 12px 6px; }
  .whoami { display: none; }
  main { margin-bottom: var(--nav-height); }
  body:has(.topbar[hidden]) main { margin-bottom: 0; }
  .nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 15; gap: 0;
    height: var(--nav-height); padding-bottom: env(safe-area-inset-bottom);
    background: var(--surface); border-top: 1px solid var(--line);
  }
  .nav a, .nav-more {
    flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
    padding: 4px 2px; border: 0; border-radius: 0; background: none; color: var(--muted);
    font-size: 11px; font-weight: 600; white-space: nowrap; cursor: pointer;
  }
  .nav a::before, .nav-more::before { font-size: 19px; line-height: 1.2; }
  .nav a[data-nav=mine]::before { content: "📋"; }
  .nav a[data-nav=board]::before { content: "🗂️"; }
  .nav a[data-nav=all]::before { content: "📄"; }
  .nav a[data-nav=deadlines]::before { content: "⏰"; }
  .nav-more::before { content: "☰"; }
  .nav a.active, .nav-more.active { background: none; color: var(--accent); }
  .nav a.nav-extra { display: none; }

  /* Mục phụ và tài khoản */
  .more-sheet {
    display: flex; flex-direction: column; position: fixed; left: 8px; right: 8px; bottom: calc(var(--nav-height) + 8px); z-index: 16;
    max-height: calc(100dvh - var(--nav-height) - 72px); overflow-y: auto;
    background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 6px;
  }
  .more-who { padding: 10px 12px; color: var(--muted); font-size: 13px; font-weight: 600; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
  .more-item {
    display: flex; align-items: center; min-height: 46px; padding: 0 12px; width: 100%; border: 0; border-radius: 8px; background: none;
    text-decoration: none; text-align: left; font-size: 15px; font-weight: 600; cursor: pointer;
  }
  .more-item.active { background: var(--accent-soft); color: var(--accent); }

  /* iPhone tự phóng to khi ô nhập nhỏ hơn 16px */
  input, select, textarea { font-size: 16px; min-height: 44px; }
  input[type=date], input[type=month] { min-width: 0; -webkit-appearance: none; appearance: none; display: block; }
  input[type=checkbox], input[type=radio] { min-height: 0; width: 22px; height: 22px; }
  .btn { min-height: 42px; }
  .icon-btn { width: 44px; height: 44px; }
  .link-edit { padding: 10px 6px; }
  .table-wrap { margin: 0 12px; }
  .page { padding-bottom: 72px; }
  .toolbar { padding: 10px 12px; }
  .toolbar input[type=search] { width: 100%; flex: 1 1 100%; }
  .toolbar select { flex: 1 1 130px; min-width: 0; max-width: none; }
  .board-page .toolbar .count { display: none; }
  .toolbar input[type=month] { width: auto; flex: 1 1 150px; }
  .fields { grid-template-columns: minmax(0, 1fr); }
  .row { grid-template-columns: minmax(0, 1fr) auto; }
  .row .hide-sm { display: none; }
  .dash-grid { padding: 0 12px; }
  .pay-summary { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 0 12px 12px; }
  .pay-stat { min-width: 0; }

  /* Nút tạo bài nổi, để bộ lọc không chiếm chỗ */
  .btn.fab {
    position: fixed; right: 14px; bottom: calc(var(--nav-height) + 14px); z-index: 14;
    border-radius: 24px; min-height: 46px; padding: 0 18px; box-shadow: var(--shadow);
  }

  /* Bảng kanban: xem từng cột, chuyển cột bằng thanh tab */
  .column-tabs {
    display: flex; gap: 6px; overflow-x: auto; padding: 0 12px 10px; flex: none; scrollbar-width: none;
  }
  .column-tabs::-webkit-scrollbar { display: none; }
  .column-tab {
    flex: none; min-height: 36px; padding: 0 12px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface);
    font-size: 13px; font-weight: 600; color: var(--muted); white-space: nowrap; cursor: pointer;
  }
  .column-tab.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
  .board { grid-auto-columns: calc(100vw - 44px); gap: 8px; padding: 0 12px 12px; scroll-snap-type: x mandatory; scroll-padding: 0 12px; scrollbar-width: none; }
  .board::-webkit-scrollbar { display: none; }
  .column { scroll-snap-align: start; }
  .column-body { padding-bottom: 72px; }
  .card { padding: 11px 12px; }

  /* Bảng dữ liệu xếp thành từng thẻ, không phải vuốt ngang */
  main .table-wrap { overflow: visible; }
  main table, main tbody, main tr, main td { display: block; width: auto; }
  main thead { display: none; }
  main tr { padding: 10px 14px; border-top: 1px solid var(--line); }
  main tbody tr:first-child { border-top: 0; }
  main td, main td.dash-num, main table td {
    position: relative; min-width: 0; min-height: 26px; padding: 4px 0 4px 104px !important; border: 0;
    text-align: left; white-space: normal; overflow-wrap: anywhere;
  }
  main td::before {
    content: attr(data-label); position: absolute; left: 0; top: 5px; width: 96px;
    color: var(--muted); font-size: 12px; font-weight: 600; white-space: normal;
  }
  main td:first-child { min-width: 0; padding-left: 0 !important; font-size: 15px; }
  main td:first-child::before, main td[data-label=""]::before { content: none; }
  main td[data-label=""] { padding-left: 0 !important; }
  .status-dot { width: 36px; height: 36px; }
  main td:empty { display: none; }

  /* Chi tiết bài */
  .drawer { width: 100%; }
  .drawer-head { padding: calc(10px + env(safe-area-inset-top)) 14px 10px; }
  .drawer-body { padding: 12px 14px 16px; }
  .drawer-body .fields { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; align-items: end; }
  .status-bar select { flex: 1 1 130px; min-width: 0; }
  .status-bar .btn.primary { flex: 1 1 100%; order: 3; }
  .composer { padding: 8px 14px calc(8px + env(safe-area-inset-bottom)); }
  .composer textarea { min-height: 44px; }
  .composer-foot { justify-content: flex-end; margin-top: 6px; }
  .composer-foot .hint { display: none; }

  .modal { width: calc(100% - 24px); max-height: calc(100dvh - 24px); padding: 16px; }
  .toast { bottom: calc(var(--nav-height) + 10px); width: max-content; text-align: center; }
  .popover { top: calc(58px + env(safe-area-inset-top)); left: 8px; right: 8px; width: auto; max-height: calc(100dvh - var(--nav-height) - 72px); }
}
@media (max-width: 340px) {
  .drawer-body .fields { grid-template-columns: minmax(0, 1fr); }
}
