:root {
  --bg: #f5f1ea; --card: #fffdf9; --text: #2a2520; --muted: #8a8076; --line: #e7dfd3;
  --brand: #1c1a17; --brand-2: #2b2723; --gold: #b8955a; --gold-2: #d9bf8c; --gold-soft: #f1e7d6;
  --primary: #1c1a17; --link: #8c6a35;
  --ok: #3f6b4a; --ok-bg: #e4ede3; --warn: #a2672a; --warn-bg: #f6e8d4;
  --bad: #a33a2c; --bad-bg: #f6e1dc; --info: #3e5a7a; --info-bg: #e3e9f0; --muted-bg: #efe9e0;
  --shadow: 0 1px 2px rgba(40,30,20,.04), 0 6px 18px rgba(40,30,20,.06);
  --serif: "Playfair Display", Georgia, serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14120f; --card: #1e1b17; --text: #efe8dd; --muted: #a39887; --line: #34302a;
    --brand: #0e0d0b; --brand-2: #1e1b17; --gold-soft: #2c261d; --primary: #b8955a; --link: #d9bf8c;
    --ok: #9cc3a3; --ok-bg: #22322613; --warn: #e3b47a; --warn-bg: #3a2c1b;
    --bad: #f0a093; --bad-bg: #3d211c; --info: #a9c0dc; --info-bg: #1f2a36; --muted-bg: #2a2621;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.5 "Be Vietnam Pro", -apple-system, "Segoe UI", Roboto, Arial, sans-serif; background: var(--bg); color: var(--text); padding-bottom: 76px; }
a { color: var(--link); text-decoration: none; }
h1 { font-family: var(--serif); font-weight: 600; font-size: 26px; margin: 10px 0 4px; letter-spacing: .2px; }
h2 { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 1.6px; color: var(--muted); margin: 26px 0 10px; }
h2::after { content: ""; display: block; width: 28px; height: 2px; background: var(--gold); margin-top: 6px; }
.box h2::after, .head h2::after { display: none; }
h3 { font-size: 15px; margin: 14px 0 8px; }
.wrap { max-width: 980px; margin: 0 auto; padding: 12px 16px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.t-bad { color: var(--bad); }
.empty { color: var(--muted); padding: 12px; background: var(--card); border-radius: 10px; border: 1px dashed var(--line); }

.top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 16px; background: var(--brand); color: #fff; padding: 12px 18px; border-bottom: 1px solid #3a332a; }
.top .brand { color: var(--gold-2); font-family: var(--serif); font-size: 20px; font-weight: 600; letter-spacing: 4px; }
.top .brand small { font-family: "Be Vietnam Pro", sans-serif; font-size: 9px; letter-spacing: 3px; color: #8f8576; display: block; margin-top: -2px; }
.top .topnav { display: none; flex: 1; gap: 4px; }
.top .topnav a { color: #bdb3a3; padding: 6px 12px; border-radius: 6px; position: relative; font-size: 14px; }
.top .topnav a.on, .top .topnav a:hover { color: var(--gold-2); background: rgba(184,149,90,.12); }
.top .who { margin-left: auto; color: #d8cfc1; font-size: 13px; border: 1px solid #4a4237; border-radius: 16px; padding: 4px 12px; }
.badge { background: var(--gold); color: #fff; border-radius: 9px; font-size: 11px; padding: 0 6px; margin-left: 4px; }

.bottomnav { position: fixed; bottom: 0; left: 0; right: 0; z-index: 10; display: flex; background: var(--card); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.bottomnav a { flex: 1; display: flex; flex-direction: column; align-items: center; padding: 8px 0 6px; color: var(--muted); font-size: 11px; position: relative; }
.bottomnav a.on { color: var(--gold); }
.bottomnav a.on::before { content: ""; position: absolute; top: 0; left: 30%; right: 30%; height: 2px; background: var(--gold); }
.bottomnav svg { width: 22px; height: 22px; margin-bottom: 2px; }
.bottomnav .dot, .people .dot { position: absolute; top: 6px; right: 30%; width: 8px; height: 8px; border-radius: 50%; background: var(--bad); }
@media (min-width: 820px) {
  .top .topnav { display: flex; }
  .bottomnav { display: none; }
  body { padding-bottom: 20px; }
}

.flash { background: var(--info-bg); color: var(--info); padding: 10px 12px; border-radius: 8px; margin-bottom: 10px; }
.flash.bad { background: var(--bad-bg); color: var(--bad); }
.head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.crumb { margin: 4px 0; font-size: 14px; }

.cards { display: grid; gap: 10px; grid-template-columns: 1fr; }
@media (min-width: 700px) { .cards { grid-template-columns: 1fr 1fr; } }
.card { display: block; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; color: var(--text); box-shadow: var(--shadow); }
.card strong { font-weight: 600; }
a.card:active { transform: scale(.99); }
.card .row1 { display: flex; gap: 8px; align-items: baseline; }
.card .meta, p.meta { display: flex; flex-wrap: wrap; gap: 4px 12px; color: var(--muted); font-size: 13px; margin: 4px 0; }
.card.task { border-left: 4px solid var(--line); }
.card.s-doing { border-left-color: var(--gold); }
.card.s-blocked { border-left-color: var(--bad); }
.card.s-done { border-left-color: var(--ok); opacity: .85; }
.prio { display: inline-flex; flex: none; min-width: 26px; height: 22px; padding: 0 5px; align-items: center; justify-content: center; border-radius: 6px; background: var(--brand); color: var(--gold-2); font-size: 12px; font-weight: 600; }
.pills { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.pill { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 10px; background: var(--muted-bg); color: var(--muted); white-space: nowrap; }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill.info { background: var(--info-bg); color: var(--info); }
.note { background: var(--muted-bg); border-radius: 8px; padding: 8px 10px; margin: 8px 0; font-size: 14px; }
.note.bad { background: var(--bad-bg); color: var(--bad); }

.track { border-top: 1px solid var(--line); margin-top: 8px; padding-top: 8px; font-size: 14px; }
.stepbar { display: flex; gap: 2px; margin: 6px 0; }
.stepbar i { flex: 1; height: 7px; border-radius: 2px; background: var(--line); }
.stepbar i.sep { margin-left: 4px; }
.stepbar i.done { background: var(--gold); }
.stepbar i.doing { background: var(--brand); box-shadow: 0 0 0 1px var(--gold); }
.stepbar i.na { background: transparent; border: 1px dashed var(--line); height: 7px; }
.steplist { padding-left: 26px; font-size: 14px; }
.steplist li { margin: 4px 0; }
.steplist .tag { font-size: 11px; color: var(--muted); }
.steplist .st-done { color: var(--link); }
.steplist .st-doing { font-weight: 700; color: var(--warn); }
.steplist .st-na { color: var(--muted); text-decoration: line-through; }
.steplist .phase-sep { list-style: none; margin-left: -26px; font-weight: 700; margin-top: 10px; color: var(--muted); }
.track-box h3 { margin: 0; }

.box { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; margin: 12px 0; box-shadow: var(--shadow); }
.box h2 { color: var(--text); font-family: var(--serif); text-transform: none; letter-spacing: 0; font-size: 18px; }
.box h2 { margin-top: 0; }
details summary { cursor: pointer; color: var(--link); padding: 6px 0; }

.tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; -webkit-overflow-scrolling: touch; }
.tabs a { white-space: nowrap; padding: 7px 12px; border-radius: 18px; background: var(--card); border: 1px solid var(--line); color: var(--text); font-size: 14px; }
.tabs a.on { background: var(--brand); color: var(--gold-2); border-color: var(--brand); }
.tabs small { opacity: .7; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; margin: 8px 0; }
.gallery img { width: 100%; aspect-ratio: 4/3; object-fit: cover; border-radius: 8px; display: block; background: var(--muted-bg); }
.files { list-style: none; padding: 0; margin: 8px 0; }
.files li { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px; margin-bottom: 6px; }
.files li > a { display: block; font-weight: 600; word-break: break-word; }
.ext { display: inline-block; min-width: 38px; text-align: center; font-size: 11px; text-transform: uppercase; background: var(--gold-soft); color: var(--link); font-weight: 600; border-radius: 4px; padding: 1px 4px; margin-right: 8px; }

.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.92); z-index: 50; display: flex; align-items: center; justify-content: center; }
.lightbox img { max-width: 100%; max-height: 100%; object-fit: contain; }
.lightbox .x, .lightbox .nav { position: absolute; color: #fff; font-size: 28px; background: none; border: 0; padding: 14px; }
.lightbox .x { top: 0; right: 0; }
.lightbox .prev { left: 0; top: 45%; }
.lightbox .next { right: 0; top: 45%; }

.form { display: flex; flex-direction: column; gap: 10px; }
.form.row { flex-direction: row; }
.form.row input { flex: 1; }
.form label { display: flex; flex-direction: column; gap: 4px; font-size: 14px; color: var(--muted); }
.form label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--text); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(184,149,90,.18); }
input, select, textarea { font: inherit; font-size: 16px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); color: var(--text); width: 100%; }
input[type=checkbox], input[type=radio] { width: auto; }
fieldset { border: 1px solid var(--line); border-radius: 8px; display: flex; flex-direction: column; gap: 6px; }
.btn { display: inline-block; font: inherit; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); color: var(--text); cursor: pointer; text-align: center; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--gold-2); letter-spacing: .3px; }
.btn.primary:hover { background: #2b2620; }
.btn.bad { color: var(--bad); }
.btn.big { padding: 12px; font-size: 16px; font-weight: 600; }
.btn.small { padding: 4px 10px; font-size: 13px; }
button.link { background: none; border: 0; padding: 0; font: inherit; font-size: 13px; cursor: pointer; }
button.link.bad { color: var(--bad); }
form.inline { display: inline; margin-left: 8px; }

.seg { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.seg label { display: block; }
.seg input { position: absolute; opacity: 0; }
.seg span { display: block; text-align: center; padding: 10px 4px; border-radius: 8px; border: 1px solid var(--line); color: var(--text); font-size: 14px; }
.seg input:checked + span { color: #fff; font-weight: 600; }
.seg .s-todo input:checked + span { background: #8a8076; }
.seg .s-doing input:checked + span { background: #3e5a7a; }
.seg .s-blocked input:checked + span { background: #a33a2c; }
.seg .s-done input:checked + span { background: #3f6b4a; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 10px 0; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px 8px; color: var(--text); text-align: center; box-shadow: var(--shadow); }
.stat b { display: block; font-family: var(--serif); font-size: 30px; font-weight: 600; line-height: 1.1; }
.stat span { font-size: 12px; color: var(--muted); }
.stat.bad b { color: var(--bad); }
.stat.warn b { color: var(--warn); }
.stat.ok b { color: var(--ok); }

.filters { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.filters input { flex: 1 1 200px; }
.filters select { flex: 1 1 140px; width: auto; min-width: 0; max-width: 100%; }
.people { display: flex; gap: 6px; overflow-x: auto; padding: 4px 0; }
.people a { position: relative; white-space: nowrap; padding: 6px 12px; border-radius: 18px; background: var(--card); border: 1px solid var(--line); color: var(--text); font-size: 14px; }
.people a.on { background: var(--brand); color: var(--gold-2); }
.people .dot { top: 2px; right: 2px; }

.feed { list-style: none; padding: 0; margin: 8px 0; }
.feed li { padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.feed.big li { display: flex; gap: 10px; }
.feed .ic { width: 22px; flex: none; }
.feed li.new { background: var(--warn-bg); border-radius: 6px; padding-left: 6px; }
.feed .a-done b { color: var(--ok); }
.feed .a-blocked b { color: var(--bad); }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; margin: 10px 0; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.tbl { width: 100%; border-collapse: collapse; background: var(--card); font-size: 14px; }
.tbl th, .tbl td { text-align: left; padding: 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl tr.off { opacity: .5; }
.tbl tr.phase-sep td { font-weight: 700; background: var(--muted-bg); }
.steps-edit select { min-width: 130px; }

.login { max-width: 380px; margin: 8vh auto 0; background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 28px 24px; box-shadow: var(--shadow); }
body.guest { background: radial-gradient(ellipse at top, #2b2620 0%, #14120f 70%); min-height: 100vh; }
body.guest .login { background: rgba(30,27,23,.85); border-color: #3a332a; color: #efe8dd; }
body.guest .login label { color: #a39887; }
body.guest .login input { background: #14120f; border-color: #3a332a; color: #efe8dd; }
body.guest .btn.primary { background: var(--gold); border-color: var(--gold); color: #1c1a17; font-weight: 600; }
.login .tag { letter-spacing: 4px; font-size: 11px; color: var(--gold); text-transform: uppercase; }
.login h1 { font-size: 40px; letter-spacing: 10px; margin: 0; color: var(--gold-2); }

/* Bảng danh sách (trang Google Drive) */
table.list { width: 100%; border-collapse: collapse; margin-top: 12px; font-size: 14px; }
table.list th { text-align: left; font-weight: 600; color: var(--muted); border-bottom: 1px solid var(--line); padding: 6px 4px; }
table.list td { border-bottom: 1px solid var(--line); padding: 6px 4px; vertical-align: top; }
table.list tr.muted td { opacity: .55; }
.box form.inline:first-of-type { margin-left: 0; }
.box > form.inline { display: inline-block; margin: 4px 8px 4px 0; }
