:root {
  --bg: #f6f4ef; --panel: #fffdf8; --fg: #1f2a26; --mute: #6b7771; --line: #e3ded2;
  --accent: #0f6b52; --accent-fg: #fff; --warn: #b4531a; --warn-bg: #fbeadb; --ok-bg: #dcefe6;
  --chip: #ece8dc; --shadow: 0 1px 2px rgba(0, 0, 0, .06);
  --side-bg: #23443a; --side-fg: #f3efe4; --side-mute: #b7c3bb; --side-on-bg: #f6f1e3; --side-on-fg: #1f3d33; --gold: #d6b25e;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14191a; --panel: #1c2324; --fg: #e8ece9; --mute: #93a29b; --line: #2c3638;
    --accent: #4fc39d; --accent-fg: #06231a; --warn: #f0a266; --warn-bg: #3a2a1c; --ok-bg: #1d3a2f;
    --chip: #273133; --shadow: none; color-scheme: dark;
    --side-bg: #0f1918; --side-fg: #e8ece9; --side-mute: #93a29b; --side-on-bg: #24312f; --side-on-fg: #4fc39d; --gold: #d6b25e;
  }
}
:root[data-theme="dark"] {
  --bg: #14191a; --panel: #1c2324; --fg: #e8ece9; --mute: #93a29b; --line: #2c3638;
  --accent: #4fc39d; --accent-fg: #06231a; --warn: #f0a266; --warn-bg: #3a2a1c; --ok-bg: #1d3a2f;
  --chip: #273133; --shadow: none; color-scheme: dark;
    --side-bg: #0f1918; --side-fg: #e8ece9; --side-mute: #93a29b; --side-on-bg: #24312f; --side-on-fg: #4fc39d; --gold: #d6b25e;
}
* { box-sizing: border-box }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 14px/1.5 "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent) }
.wrap { max-width: 1240px; margin: 0 auto; padding: 14px 16px 60px }
header { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 12px }
h1 { font-size: 18px; margin: 0; letter-spacing: -.01em }
h1 small { font-weight: 400; color: var(--mute); font-size: 12px; margin-left: 8px }
nav { display: flex; gap: 4px; flex-wrap: wrap }
button, input, select, textarea { font: inherit; color: inherit }
button { cursor: pointer; border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 6px 11px }
button:hover { border-color: var(--accent) }
button:disabled { opacity: .5; cursor: default }
button.on, button.pri { background: var(--accent); color: var(--accent-fg); border-color: var(--accent) }
button.sm { padding: 3px 8px; font-size: 12px }
.bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px }
.status, .sub { font-size: 12px; color: var(--mute) }
.sub { overflow-wrap: anywhere }
.banner { background: var(--warn-bg); color: var(--warn); border-radius: 8px; padding: 8px 12px; margin-bottom: 12px; font-size: 13px }
.note { background: var(--ok-bg); border-radius: 8px; padding: 8px 12px; margin-bottom: 12px; font-size: 13px }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; align-items: start }
.col { background: var(--chip); border-radius: 10px; padding: 8px; min-width: 0 }
.col h3 { margin: 2px 4px 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--mute); display: flex; justify-content: space-between }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; margin-bottom: 6px; box-shadow: var(--shadow); cursor: pointer; min-width: 0 }
.card b { display: block; overflow-wrap: anywhere }
.tag { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 99px; background: var(--warn-bg); color: var(--warn); margin-top: 3px }
.tag.ok { background: var(--ok-bg); color: var(--accent) }
.tag.mute { background: var(--chip); color: var(--mute) }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin-bottom: 12px }
.panel h2 { font-size: 13px; margin: 0 0 8px; text-transform: uppercase; letter-spacing: .06em; color: var(--mute) }
.row { display: flex; gap: 8px; align-items: center; justify-content: space-between; padding: 6px 0; border-top: 1px solid var(--line); flex-wrap: wrap }
.row:first-of-type { border-top: 0 }
.row.c { cursor: pointer }
.tblw { overflow-x: auto }
table { border-collapse: collapse; width: 100% }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap }
tr.c { cursor: pointer } tr.c:hover { background: var(--chip) }
input, select, textarea { background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; width: 100%; min-width: 0 }
input[readonly] { opacity: .7 }
textarea { min-height: 60px; resize: vertical }
.drawer { position: fixed; inset: 0; background: rgba(0, 0, 0, .4); display: flex; justify-content: flex-end; z-index: 20 }
.sheet { background: var(--bg); width: min(600px, 100%); height: 100%; overflow-y: auto; padding: 16px 16px 40px }
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px }
label { display: block; font-size: 11px; color: var(--mute); margin-bottom: 2px; text-transform: uppercase; letter-spacing: .04em }
.full { grid-column: 1 / -1 }
.stages { display: flex; gap: 4px; flex-wrap: wrap; margin: 8px 0 12px }
.changed { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) }
.sticky { position: sticky; bottom: 0; background: var(--bg); padding: 10px 0; border-top: 1px solid var(--line); margin-top: 12px }

/* Trang đăng nhập / nhận lời mời */
.auth { max-width: 412px; margin: 10vh auto; padding: 0 16px }
.auth .panel { padding: 20px }
.auth h1 { margin-bottom: 4px }
.auth form > * + * { margin-top: 10px }
.auth button.pri { width: 100% }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; color: var(--fg); text-transform: none; letter-spacing: 0; cursor: pointer }
.check input { flex: none; width: 20px; height: 20px; margin: 1px 0 0; accent-color: var(--accent); cursor: pointer }

/* Khung app: thanh bên + nội dung */
.layout { display: flex; min-height: 100vh }
.side {
  width: 240px; flex: none; position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 2px; padding: 16px 12px;
  background: var(--side-bg); color: var(--side-fg); transition: width .18s ease;
}
.brand { display: flex; gap: 10px; align-items: center; padding: 2px 6px 20px }
.brand .logo { width: 40px; height: 40px; flex: none; border-radius: 50%; display: grid; place-items: center; font-weight: 700; background: var(--side-on-bg); color: var(--side-on-fg) }
.brand b { display: block; font-size: 18px; white-space: nowrap } .brand b span { color: var(--gold) }
.brand small { display: block; font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--side-mute); white-space: nowrap }
.side .sec { padding: 4px 10px 8px; font-size: 11px; font-weight: 600; letter-spacing: .2em; text-transform: uppercase; color: var(--gold); white-space: nowrap }
.nav-item {
  position: relative; display: flex; align-items: center; gap: 12px; width: 100%; padding: 9px 12px;
  border: 0; border-radius: 9px; background: none; color: inherit; font-size: 15px; text-align: left; white-space: nowrap;
}
.nav-item:hover { background: rgba(255, 255, 255, .08); border: 0 }
.nav-item.on { background: var(--side-on-bg); color: var(--side-on-fg); font-weight: 600 }
.nav-item svg { width: 20px; height: 20px; flex: none }
.nav-item .badge { margin-left: auto; padding: 0 7px; border-radius: 99px; font-size: 11px; font-weight: 600; background: var(--gold); color: #1f2a26 }
.side hr { width: 100%; border: 0; border-top: 1px solid rgba(255, 255, 255, .16); margin: 10px 0 }
.side .grow { flex: 1 }
.side #out { border: 1px solid rgba(255, 255, 255, .25); justify-content: center }
.collapsed .side { width: 68px; padding: 16px 10px }
.collapsed .label, .collapsed .brand-text, .collapsed .sec { display: none }
.collapsed .brand { justify-content: center; padding: 2px 0 20px }
.collapsed .nav-item { justify-content: center; padding: 10px 0 }
.collapsed .nav-item .badge { position: absolute; top: 1px; right: 3px; margin: 0; padding: 0 5px; font-size: 10px }
.main { flex: 1; min-width: 0 }
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 14px; padding: 14px 24px; background: var(--bg); border-bottom: 1px solid var(--line) }
.top h1 { font-size: 20px }
.iconbtn { width: 38px; height: 38px; display: grid; place-items: center; padding: 0 }
.iconbtn svg { width: 20px; height: 20px }
.chip-user { margin-left: auto; display: flex; align-items: center; gap: 8px; min-width: 0; padding: 5px 12px 5px 6px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); font-size: 13px }
.chip-user .email { overflow: hidden; text-overflow: ellipsis; white-space: nowrap }
.avatar { width: 28px; height: 28px; flex: none; border-radius: 50%; display: grid; place-items: center; font-weight: 600; background: var(--accent); color: var(--accent-fg) }
.content { max-width: 1240px; padding: 16px 24px 60px }
.backdrop { position: fixed; inset: 0; z-index: 25; background: rgba(0, 0, 0, .35) }

@media (max-width: 800px) {
  .side { position: fixed; left: 0; z-index: 30; transform: translateX(-100%); transition: transform .2s ease }
  .side-open .side { transform: none; box-shadow: 0 0 24px rgba(0, 0, 0, .25) }
  .top { padding: 10px 16px }
  .content { padding: 12px 16px 60px }
  .chip-user .email { display: none }
  .chip-user { padding: 4px }
}
label .hint { text-transform: none; letter-spacing: 0; opacity: .8 }
