:root {
  --ink: #171717;
  --muted: #767676;
  --paper: #f5f3ee;
  --card: #ffffff;
  --line: #e4e0d7;
  --blue: #315fdd;
  --green: #2b7c5d;
  --amber: #a36e16;
  --red: #b94932;
  --shadow: 0 18px 45px rgba(28, 25, 20, 0.08);
}

* { box-sizing: border-box; }
html { background: var(--paper); }
body { margin: 0; min-width: 320px; color: var(--ink); background: var(--paper); font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }
.hidden { display: none !important; }

.loading-screen, .auth-shell { min-height: 100vh; display: grid; place-items: center; padding: 28px; }
.loading-screen { align-content: center; gap: 14px; color: var(--muted); font-size: 13px; }
.brand-mark { width: 46px; height: 46px; display: grid; place-items: center; border: 1px solid #d9d5cc; border-radius: 14px; background: #fff; color: #111; font-size: 24px; font-weight: 900; box-shadow: var(--shadow); }
.auth-card { width: min(980px, 100%); min-height: 590px; display: grid; grid-template-columns: 1.05fr .95fr; border: 1px solid var(--line); border-radius: 28px; overflow: hidden; background: var(--card); box-shadow: var(--shadow); }
.auth-story { position: relative; padding: 58px; display: flex; flex-direction: column; justify-content: space-between; color: #fff; background: #181818; overflow: hidden; }
.auth-story::after { content: ""; position: absolute; width: 330px; height: 330px; right: -120px; bottom: -120px; border: 76px solid #2c2c2c; border-radius: 50%; }
.auth-brand { position: relative; z-index: 1; display: flex; align-items: center; gap: 12px; font-size: 12px; letter-spacing: .17em; font-weight: 800; }
.auth-brand .brand-mark { background: #fff; box-shadow: none; }
.auth-copy { position: relative; z-index: 1; max-width: 420px; }
.auth-copy small { color: #f0be4b; text-transform: uppercase; letter-spacing: .13em; font-weight: 800; }
.auth-copy h1 { margin: 12px 0 18px; font-size: clamp(38px, 5vw, 62px); line-height: .98; letter-spacing: -.055em; }
.auth-copy p { margin: 0; color: #bdbdbd; font-size: 13px; line-height: 1.75; }
.auth-form-panel { padding: 58px; display: flex; flex-direction: column; justify-content: center; }
.eyebrow { margin: 0 0 8px; color: var(--blue); font-size: 10px; font-weight: 900; text-transform: uppercase; letter-spacing: .13em; }
.auth-form-panel h2 { margin: 0; font-size: 30px; letter-spacing: -.04em; }
.auth-form-panel > p { color: var(--muted); font-size: 12px; line-height: 1.65; }
.form-stack { display: grid; gap: 14px; margin-top: 22px; }
.field { display: grid; gap: 7px; color: #303030; font-size: 11px; font-weight: 750; }
.field input, .field select, .field textarea { width: 100%; border: 1px solid #dcd8cf; border-radius: 11px; background: #fff; padding: 12px 13px; color: var(--ink); outline: none; }
.field textarea { min-height: 90px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: #8da5e8; box-shadow: 0 0 0 3px rgba(49, 95, 221, .1); }
.help { color: #888; font-size: 9px; font-weight: 500; line-height: 1.5; }
.error-box { border: 1px solid #f0c7bd; border-radius: 10px; background: #fff2ee; padding: 10px 12px; color: #9d3f2b; font-size: 10px; line-height: 1.5; }
.primary, .secondary, .danger, .ghost { border: 0; border-radius: 11px; padding: 11px 15px; font-size: 10px; font-weight: 850; }
.primary { background: var(--ink); color: #fff; }
.primary:hover { background: #303030; transform: translateY(-1px); }
.primary:disabled, .secondary:disabled, .danger:disabled { cursor: wait; opacity: .55; transform: none; }
.secondary { border: 1px solid var(--line); background: #fff; color: var(--ink); }
.danger { background: #b94932; color: #fff; }
.ghost { background: transparent; color: var(--muted); }

.app-shell { min-height: 100vh; }
.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 20; width: 220px; display: flex; flex-direction: column; background: #181818; color: #fff; }
.side-brand { height: 82px; padding: 19px 22px; display: flex; align-items: center; gap: 11px; border-bottom: 1px solid #303030; }
.side-brand .brand-mark { width: 38px; height: 38px; border-radius: 11px; box-shadow: none; }
.side-brand b, .side-brand small { display: block; }
.side-brand b { font-size: 13px; }
.side-brand small { margin-top: 3px; color: #888; font-size: 8px; letter-spacing: .16em; }
.side-nav { display: grid; gap: 4px; padding: 20px 13px; }
.nav-button { display: grid; grid-template-columns: 25px 1fr; align-items: center; gap: 8px; border: 0; border-radius: 10px; background: transparent; padding: 11px 12px; color: #aaa; text-align: left; font-size: 10px; font-weight: 700; }
.nav-button span { font-size: 16px; text-align: center; }
.nav-button:hover, .nav-button.active { background: #2c2c2c; color: #fff; }
.account-block { margin-top: auto; padding: 18px; border-top: 1px solid #303030; }
.account-block b, .account-block small { display: block; }
.account-block b { overflow: hidden; text-overflow: ellipsis; font-size: 10px; }
.account-block small { overflow: hidden; margin-top: 4px; color: #858585; font-size: 8px; text-overflow: ellipsis; }
.account-block .role { display: inline-block; margin-top: 10px; border-radius: 6px; background: #293c32; padding: 5px 7px; color: #8ce0af; font-size: 7px; font-weight: 900; text-transform: uppercase; }
.logout { width: 100%; margin-top: 10px; border: 0; background: transparent; color: #aaa; padding: 5px 0; text-align: left; font-size: 9px; }
.main { margin-left: 220px; }
.topbar { position: sticky; top: 0; z-index: 10; height: 67px; display: flex; align-items: center; justify-content: space-between; padding: 0 30px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.9); backdrop-filter: blur(14px); }
.topbar strong { font-size: 11px; }
.topbar span { color: var(--muted); font-size: 9px; }
.page { width: min(1220px, 100%); margin: 0 auto; padding: 30px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 20px; }
.page-head h1 { margin: 0; font-size: 34px; letter-spacing: -.05em; }
.page-head p { margin: 8px 0 0; color: var(--muted); font-size: 11px; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.notice { display: flex; gap: 12px; align-items: center; margin-bottom: 15px; border: 1px solid #f0dfb5; border-radius: 13px; background: #fff8e8; padding: 13px 15px; color: #75643e; font-size: 10px; }
.notice strong { color: #8b6518; }
.cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 13px; }
.card { border: 1px solid var(--line); border-radius: 15px; background: var(--card); box-shadow: 0 7px 22px rgba(31, 27, 20, .035); }
.metric { min-height: 145px; padding: 18px; }
.metric small { color: #858585; font-size: 8px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
.metric strong { display: block; margin: 23px 0 7px; font-size: 35px; letter-spacing: -.06em; }
.metric p { margin: 0; color: #929292; font-size: 9px; }
.metric.red strong { color: var(--red); }
.metric.amber strong { color: var(--amber); }
.metric.green strong { color: var(--green); }
.dashboard-grid { display: grid; grid-template-columns: 1.45fr .75fr; gap: 14px; margin-top: 14px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; padding: 17px 18px; border-bottom: 1px solid var(--line); }
.panel-head h2 { margin: 0; font-size: 14px; }
.panel-head small { color: var(--muted); font-size: 8px; }
.focus-list { display: grid; }
.focus-row { display: grid; grid-template-columns: 5px minmax(0,1fr) 95px; align-items: center; gap: 12px; padding: 14px 17px; border-bottom: 1px solid #efede8; }
.focus-row:last-child { border-bottom: 0; }
.focus-bar { height: 32px; border-radius: 99px; background: #d2d2d2; }
.focus-bar.red { background: var(--red); }
.focus-bar.amber { background: #e6ad32; }
.focus-row b, .focus-row small { display: block; }
.focus-row b { font-size: 10px; line-height: 1.4; }
.focus-row small { margin-top: 3px; color: var(--muted); font-size: 8px; }
.pill { justify-self: start; border-radius: 999px; padding: 6px 8px; background: #efefec; color: #666; font-size: 8px; font-weight: 800; white-space: nowrap; }
.pill.red { background: #ffebe6; color: var(--red); }
.pill.amber { background: #fff1d4; color: #946114; }
.team-mini { padding: 7px 18px 18px; }
.team-row { display: grid; grid-template-columns: 33px 1fr auto; align-items: center; gap: 9px; padding: 12px 0; border-bottom: 1px solid #efede8; }
.team-row:last-child { border-bottom: 0; }
.avatar { width: 33px; height: 33px; display: grid; place-items: center; border-radius: 10px; background: #e9efff; color: #3156b5; font-size: 9px; font-weight: 900; }
.team-row b, .team-row small { display: block; }
.team-row b { font-size: 10px; }
.team-row small { margin-top: 3px; color: #888; font-size: 8px; }
.team-row > strong { font-size: 11px; }

.filters { display: grid; grid-template-columns: minmax(220px,1fr) 180px 180px; gap: 9px; margin-bottom: 13px; }
.filters input, .filters select { border: 1px solid var(--line); border-radius: 11px; background: #fff; padding: 11px 12px; color: #333; font-size: 10px; outline: none; }
.table-card { overflow: hidden; }
.task-head, .task-row { display: grid; grid-template-columns: minmax(260px,1.55fr) 115px 118px 125px 126px 25px; gap: 12px; align-items: center; }
.task-head { padding: 12px 17px; border-bottom: 1px solid var(--line); background: #efede8; color: #777; font-size: 8px; font-weight: 900; text-transform: uppercase; letter-spacing: .07em; }
.task-row { width: 100%; min-height: 70px; border: 0; border-bottom: 1px solid #efede8; background: #fff; padding: 12px 17px; text-align: left; }
.task-row:hover { background: #fbfaf7; }
.task-row:last-child { border-bottom: 0; }
.task-title b, .task-title small { display: block; }
.task-title b { margin: 5px 0 3px; font-size: 10px; line-height: 1.4; }
.task-title small { color: #888; font-size: 8px; }
.priority { width: max-content; border-radius: 5px; padding: 3px 6px; background: #eee; color: #555; font-size: 7px; font-weight: 900; text-transform: uppercase; }
.priority.Cao { background: #ffebe6; color: #b94529; }
.priority.Trung-bình { background: #fff3d6; color: #926413; }
.progress { display: grid; gap: 6px; }
.progress b { font-size: 10px; }
.progress-track { height: 5px; overflow: hidden; border-radius: 99px; background: #e7e5e0; }
.progress-track i { display: block; height: 100%; border-radius: inherit; background: var(--blue); }
.status { width: max-content; border-radius: 999px; padding: 6px 8px; background: #eee; color: #555; font-size: 8px; font-weight: 800; }
.status.Hoàn-thành { background: #e5f4eb; color: #29704f; }
.status.Đang-thực-hiện { background: #e8eeff; color: #3156b5; }
.status.Chờ-phản-hồi { background: #fff0d6; color: #946114; }
.empty { padding: 55px 20px; color: var(--muted); text-align: center; font-size: 11px; }

.editor-list { display: grid; gap: 13px; }
.editor-card { overflow: hidden; }
.editor-card-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); background: #efede8; }
.editor-card-head b { font-size: 10px; }
.editor-card-head button { border: 1px solid #f1c8be; border-radius: 8px; background: #fff6f3; padding: 7px 9px; color: #ae4229; font-size: 8px; font-weight: 850; }
.editor-grid { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 12px; padding: 16px; }
.editor-grid .wide { grid-column: span 2; }
.editor-grid .full { grid-column: 1/-1; }
.save-bar { position: sticky; bottom: 14px; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 16px; border: 1px solid var(--line); border-radius: 14px; background: rgba(255,255,255,.95); padding: 12px 14px; box-shadow: var(--shadow); backdrop-filter: blur(12px); }
.save-bar b, .save-bar small { display: block; }
.save-bar b { font-size: 10px; }
.save-bar small { margin-top: 3px; color: var(--muted); font-size: 8px; }

.member-list { overflow: hidden; }
.member-head, .member-row { display: grid; grid-template-columns: 42px minmax(190px,1fr) 120px 90px 90px 170px; gap: 10px; align-items: center; }
.member-head { padding: 12px 17px; background: #efede8; color: #777; font-size: 8px; font-weight: 900; text-transform: uppercase; }
.member-row { padding: 13px 17px; border-bottom: 1px solid #efede8; }
.member-row:last-child { border-bottom: 0; }
.member-row.inactive { opacity: .55; }
.member-identity b, .member-identity small { display: block; }
.member-identity b { font-size: 10px; }
.member-identity small { margin-top: 3px; color: var(--muted); font-size: 8px; }
.member-actions { display: flex; justify-content: flex-end; gap: 6px; }
.member-actions button { border: 1px solid var(--line); border-radius: 8px; background: #fff; padding: 7px 8px; font-size: 8px; font-weight: 800; }

.backdrop { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 20px; background: rgba(20,20,20,.46); backdrop-filter: blur(3px); }
.modal { position: relative; width: min(650px,100%); max-height: 92vh; overflow: auto; border-radius: 20px; background: #fff; padding: 27px; box-shadow: 0 25px 70px rgba(0,0,0,.22); }
.modal.wide { width: min(820px,100%); }
.close { position: absolute; top: 17px; right: 17px; width: 34px; height: 34px; border: 0; border-radius: 9px; background: #efede8; font-size: 18px; }
.modal h2 { margin: 2px 45px 8px 0; font-size: 24px; letter-spacing: -.04em; }
.modal > p { margin: 0 0 18px; color: var(--muted); font-size: 10px; line-height: 1.6; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }
.form-grid .full { grid-column: 1/-1; }
.actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.permission-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 10px; }
.permission-check { display: flex; align-items: flex-start; gap: 9px; border: 1px solid var(--line); border-radius: 11px; padding: 12px; background: #fff; }
.permission-check:has(input:checked) { border-color: #91a6e2; background: #f4f7ff; }
.permission-check input { width: 17px; height: 17px; accent-color: var(--blue); }
.permission-check b, .permission-check small { display: block; }
.permission-check b { font-size: 9px; }
.permission-check small { margin-top: 3px; color: var(--muted); font-size: 8px; line-height: 1.45; }
.task-detail { display: grid; gap: 13px; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.detail-box { border-radius: 11px; background: #f3f1ec; padding: 12px; }
.detail-box small, .detail-box b { display: block; }
.detail-box small { color: #888; font-size: 8px; text-transform: uppercase; letter-spacing: .06em; }
.detail-box b { margin-top: 6px; font-size: 10px; }
.detail-description { color: #555; font-size: 10px; line-height: 1.7; }
.attachment { color: var(--blue); font-weight: 800; text-decoration: none; }
.history { border-top: 1px solid var(--line); padding-top: 14px; }
.history h3 { font-size: 11px; }
.history-item { padding: 9px 0; border-bottom: 1px solid #efede8; font-size: 9px; }
.history-item small { display: block; margin-top: 3px; color: var(--muted); }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 100; border-radius: 12px; background: #181818; padding: 12px 16px; color: #fff; box-shadow: var(--shadow); font-size: 10px; font-weight: 800; }

@media (max-width: 1060px) {
  .cards { grid-template-columns: repeat(2,1fr); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .task-head, .task-row { grid-template-columns: minmax(230px,1.5fr) 100px 105px 115px 25px; }
  .task-head span:nth-child(5), .task-row > span:nth-child(5) { display: none; }
  .editor-grid { grid-template-columns: repeat(2,1fr); }
  .member-head, .member-row { grid-template-columns: 42px minmax(180px,1fr) 105px 80px 150px; }
  .member-head span:nth-child(5), .member-row > span:nth-child(5) { display: none; }
}

@media (max-width: 760px) {
  .auth-card { grid-template-columns: 1fr; }
  .auth-story { min-height: 275px; padding: 35px; }
  .auth-copy h1 { font-size: 42px; }
  .auth-form-panel { padding: 35px; }
  .sidebar { position: fixed; inset: auto 0 0 0; width: auto; height: 62px; flex-direction: row; }
  .side-brand, .account-block { display: none; }
  .side-nav { width: 100%; grid-template-columns: repeat(auto-fit,minmax(0,1fr)); padding: 5px 8px; }
  .nav-button { display: grid; grid-template-columns: 1fr; gap: 0; place-items: center; padding: 5px; text-align: center; font-size: 7px; }
  .nav-button span { font-size: 16px; }
  .main { margin-left: 0; padding-bottom: 68px; }
  .topbar { height: 60px; padding: 0 15px; }
  .page { padding: 22px 14px; }
  .page-head { align-items: flex-start; }
  .page-head h1 { font-size: 27px; }
  .page-head p { line-height: 1.5; }
  .filters { grid-template-columns: 1fr 1fr; }
  .filters input { grid-column: 1/-1; }
  .task-head { display: none; }
  .task-row { grid-template-columns: 1fr auto; gap: 8px; padding: 14px; }
  .task-row > span:nth-child(2), .task-row > span:nth-child(4) { display: none; }
  .task-row > span:nth-child(3) { grid-row: 2; }
  .task-row > span:nth-child(5) { display: block; grid-column: 2; grid-row: 2; }
  .editor-grid { grid-template-columns: 1fr; }
  .editor-grid .wide, .editor-grid .full { grid-column: auto; }
  .member-head { display: none; }
  .member-row { grid-template-columns: 42px 1fr auto; }
  .member-row > span:nth-child(3), .member-row > span:nth-child(4), .member-row > span:nth-child(5) { display: none; }
  .member-actions { grid-column: 2/-1; justify-content: flex-start; }
  .form-grid, .permission-grid, .detail-grid { grid-template-columns: 1fr; }
  .form-grid .full { grid-column: auto; }
  .toast { left: 14px; right: 14px; bottom: 75px; text-align: center; }
}

@media (max-width: 440px) {
  .auth-shell { padding: 0; }
  .auth-card { min-height: 100vh; border: 0; border-radius: 0; }
  .auth-story { min-height: 230px; padding: 28px; }
  .auth-copy h1 { margin-bottom: 12px; font-size: 34px; }
  .auth-form-panel { padding: 28px; }
  .cards { grid-template-columns: 1fr 1fr; gap: 9px; }
  .metric { min-height: 124px; padding: 14px; }
  .metric strong { margin-top: 18px; font-size: 29px; }
  .page-head { display: block; }
  .head-actions { margin-top: 14px; }
}
