/* Trang chủ + tài khoản + quản trị. Màu chính xanh lá đậm, giống Chọn Ảnh và Sổ Việc. */
:root {
  --bg: #f3f5f0;
  --surface: #ffffff;
  --surface-2: #eef3ec;
  --ink: #142019;
  --ink-2: #33463a;
  --muted: #627266;
  --line: #dde5dc;
  --line-2: #c8d5c7;
  --brand: #14532d;
  --brand-ink: #f0fdf4;
  --brand-soft: #dcfce7;
  --soft: #e6efe4;
  --ok: #15803d;
  --warn: #a16207;
  --warn-soft: #fef6d8;
  --danger: #b91c1c;
  --danger-soft: #fde8e8;
  --shadow: 0 1px 2px rgba(20, 32, 25, .05), 0 8px 28px rgba(20, 32, 25, .07);
  --r: 18px;
  --r-sm: 10px;
  --font: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b130e; --surface: #121e16; --surface-2: #172619; --ink: #ebf4ee; --ink-2: #c6d8cb; --muted: #8fa596;
    --line: #22352a; --line-2: #2d4536; --brand: #4ade80; --brand-ink: #062712; --brand-soft: #173b25; --soft: #18291e;
    --ok: #4ade80; --warn: #facc15; --warn-soft: #3a3210; --danger: #f87171; --danger-soft: #3b1717;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 28px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.6 var(--font); }
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }
.wrap { max-width: 1040px; margin: 0 auto; padding: 0 20px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ------------------------------------------------ nút */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: 999px; border: 1px solid transparent;
  font-weight: 600; font-size: 15px; line-height: 1.2; text-decoration: none; cursor: pointer;
  transition: background .15s ease, border-color .15s ease, opacity .15s ease;
}
.btn:disabled { opacity: .55; cursor: default; }
.btn-sm { padding: 8px 14px; font-size: 14px; }
.btn-primary { background: var(--brand); color: var(--brand-ink); }
.btn-primary:hover:not(:disabled) { filter: brightness(1.08); }
.btn-ghost { background: transparent; border-color: var(--line-2); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn:focus-visible, .tab:focus-visible, select:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }

/* ------------------------------------------------ đầu trang */
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 18px; padding-bottom: 6px; }
.logo { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 700; font-size: 18px; letter-spacing: -.01em; }
.logo svg { width: 34px; height: 34px; flex: none; }
.nav { display: flex; align-items: center; gap: 8px; }
.menu { position: relative; }
.menu summary { list-style: none; cursor: pointer; }
.menu summary::-webkit-details-marker { display: none; }
.avatar {
  width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center;
  background: var(--brand); color: var(--brand-ink); font-weight: 700;
}
.menu-pop {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 20; min-width: 230px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow);
  padding: 6px; display: grid;
}
.menu-head { padding: 10px 12px 12px; border-bottom: 1px solid var(--line); margin-bottom: 6px; display: grid; }
.menu-head span { color: var(--muted); font-size: 14px; }
.menu-pop a { padding: 9px 12px; border-radius: 9px; text-decoration: none; }
.menu-pop a:hover { background: var(--surface-2); }

/* ------------------------------------------------ trang chủ */
.hero { padding: 52px 0 34px; max-width: 680px; }
.eyebrow { margin: 0 0 12px; color: var(--brand); font-weight: 600; font-size: 14px; letter-spacing: .02em; }
h1 { margin: 0; font-size: clamp(30px, 5.2vw, 46px); line-height: 1.15; letter-spacing: -.025em; font-weight: 700; }
.lead { margin: 16px 0 0; color: var(--ink-2); font-size: 18px; max-width: 560px; }
.hello { margin: 18px 0 0; padding: 12px 16px; border-radius: 12px; background: var(--brand-soft); color: var(--ink); font-size: 15px; }

.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; padding-bottom: 56px; }
.card {
  position: relative; display: flex; flex-direction: column; gap: 14px;
  padding: 24px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); box-shadow: var(--shadow); text-decoration: none;
  transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease;
}
a.card[href]:hover { transform: translateY(-2px); border-color: var(--accent); box-shadow: 0 2px 4px rgba(20, 32, 25, .06), 0 14px 36px rgba(20, 32, 25, .11); }
a.card:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.card-top { display: flex; align-items: center; gap: 14px; }
.icon { width: 52px; height: 52px; flex: none; }
.icon svg { width: 100%; height: 100%; display: block; }
.card h2 { margin: 0; font-size: 21px; line-height: 1.25; letter-spacing: -.01em; }
.card .tagline { margin: 2px 0 0; color: var(--muted); font-size: 15px; line-height: 1.4; }
.card ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 7px; color: var(--ink-2); font-size: 15px; }
.card li { display: flex; gap: 9px; align-items: baseline; }
.card li::before { content: ""; flex: none; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); transform: translateY(-2px); }
.card .note { margin: 0; color: var(--muted); font-size: 13.5px; }
.cta {
  margin-top: auto; align-self: flex-start; display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 18px; border-radius: 999px; background: var(--accent); color: #fff;
  font-weight: 600; font-size: 15px;
}
.cta svg { width: 16px; height: 16px; transition: transform .15s ease; }
a.card[href]:hover .cta svg { transform: translateX(3px); }
.card.soon, .card.wait { box-shadow: none; background: transparent; border-style: dashed; }
.card.soon .icon { filter: grayscale(.85); opacity: .6; }
.card.soon h2, .card.soon ul { opacity: .75; }
.badge {
  margin-top: auto; align-self: flex-start; padding: 6px 14px; border-radius: 999px;
  background: var(--soft); color: var(--muted); font-weight: 600; font-size: 14px;
}
.card.wait .badge { background: var(--warn-soft); color: var(--warn); }
/* màu riêng của từng công cụ lấy từ congcu.json: --a (nền sáng), --a-toi (nền tối) */
.card { --accent: var(--a, var(--brand)); }
@media (prefers-color-scheme: dark) { .card { --accent: var(--a-toi, var(--a, var(--brand))); } }
.icon img { width: 100%; height: 100%; display: block; }
.icon-chu { width: 100%; height: 100%; display: grid; place-items: center; border-radius: 14px; background: var(--accent); color: #fff; font-weight: 700; font-size: 24px; }

.foot { border-top: 1px solid var(--line); padding: 22px 20px 34px; color: var(--muted); font-size: 14px;
        display: flex; justify-content: space-between; gap: 10px 20px; flex-wrap: wrap; }
.foot-links { display: flex; gap: 6px 18px; flex-wrap: wrap; }
.foot-links a { color: var(--muted); text-decoration: none; }
.foot-links a:hover { color: var(--ink); text-decoration: underline; }
.narrow { max-width: 720px; }
.prose { max-width: 720px; }
.prose h1 { margin-bottom: 14px; }
.prose h2 { margin: 28px 0 8px; font-size: 21px; }
.prose p, .prose li { color: var(--ink-2); }
.prose a { color: var(--brand); }

/* ------------------------------------------------ đăng nhập / đăng ký */
.auth { min-height: calc(100vh - 80px); display: grid; place-items: start center; padding: 28px 16px 60px; }
.auth-card {
  width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); box-shadow: var(--shadow); padding: 28px;
}
.auth-card h1 { font-size: 26px; }
.auth-card .sub { margin: 8px 0 20px; color: var(--muted); font-size: 15px; }
.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; border-radius: 12px; background: var(--surface-2); margin-bottom: 20px; }
.tab { border: 0; background: transparent; padding: 9px; border-radius: 9px; font-weight: 600; cursor: pointer; color: var(--muted); }
.tab[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .08); }
.f { display: grid; gap: 6px; margin-bottom: 14px; font-size: 14px; font-weight: 600; color: var(--ink-2); }
.f input, .f select {
  width: 100%; padding: 11px 13px; border-radius: var(--r-sm); border: 1px solid var(--line-2);
  background: var(--surface); font-size: 16px; font-weight: 400;
}
.f input:focus, .f select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.f .hint { font-weight: 400; color: var(--muted); font-size: 13px; }
.err { margin: 0 0 14px; padding: 10px 13px; border-radius: var(--r-sm); background: var(--danger-soft); color: var(--danger); font-size: 14.5px; }
.err:empty { display: none; }
.full { width: 100%; }
.fine { margin: 16px 0 0; color: var(--muted); font-size: 13.5px; text-align: center; }

/* ------------------------------------------------ trang tài khoản + quản trị */
.page { padding: 26px 0 60px; }
.page h1 { font-size: clamp(26px, 4vw, 34px); }
.page .sub { margin: 6px 0 22px; color: var(--muted); }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); padding: 22px; margin-bottom: 18px; }
.panel h2 { margin: 0 0 14px; font-size: 18px; }
.row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.row .f { flex: 1 1 220px; margin-bottom: 0; }
.tools { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.tools li { display: flex; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.tools li:last-child { border-bottom: 0; }
.muted { color: var(--muted); }
.lvl { font-weight: 600; }
.lvl.none { color: var(--muted); font-weight: 400; }

.stats { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }
.stat { padding: 10px 16px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); font-size: 14px; color: var(--muted); }
.stat b { display: block; font-size: 22px; color: var(--ink); line-height: 1.2; }
.stat.hot b { color: var(--warn); }

.switch { display: flex; align-items: center; gap: 12px; cursor: pointer; }
.switch input { appearance: none; width: 46px; height: 28px; border-radius: 999px; background: var(--line-2); position: relative; flex: none; cursor: pointer; transition: background .15s; margin: 0; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0, 0, 0, .2); }
.switch input:checked { background: var(--ok); }
.switch input:checked::after { transform: translateX(18px); }
.switch input:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.filters { display: flex; gap: 4px; padding: 4px; border-radius: 12px; background: var(--surface-2); flex-wrap: wrap; }
.filters .tab { padding: 7px 12px; }
.search { flex: 1 1 220px; padding: 10px 13px; border-radius: var(--r-sm); border: 1px solid var(--line-2); background: var(--surface); }
.search:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }

.users { display: grid; gap: 10px; }
.user { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; display: grid; gap: 12px; }
.user.locked { opacity: .7; border-style: dashed; }
.u-head { display: flex; gap: 12px; align-items: center; }
.u-head .avatar { width: 40px; height: 40px; flex: none; }
.u-id { min-width: 0; flex: 1; }
.u-id b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.u-id span { color: var(--muted); font-size: 14px; }
.tags { display: flex; gap: 6px; flex-wrap: wrap; }
.tag { padding: 3px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 600; background: var(--surface-2); color: var(--muted); }
.tag.admin { background: var(--brand-soft); color: var(--brand); }
.tag.lock { background: var(--danger-soft); color: var(--danger); }
.tag.wait { background: var(--warn-soft); color: var(--warn); }
.u-perms { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.perm { display: grid; gap: 4px; font-size: 13.5px; font-weight: 600; color: var(--ink-2); min-width: 0; }
.perm select { width: 100%; min-width: 0; text-overflow: ellipsis; padding: 9px 11px; border-radius: var(--r-sm); border: 1px solid var(--line-2); background: var(--surface); font-size: 15px; font-weight: 400; }
.perm select.on { border-color: var(--ok); background: var(--brand-soft); }
.u-meta { margin: 0; color: var(--muted); font-size: 13px; }
.u-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.empty { padding: 30px; text-align: center; color: var(--muted); }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); opacity: 0;
  background: var(--ink); color: var(--bg); padding: 11px 18px; border-radius: 12px; font-size: 15px;
  transition: opacity .2s, transform .2s; pointer-events: none; z-index: 50; max-width: calc(100% - 32px);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.bad { background: var(--danger); color: #fff; }

@media (max-width: 720px) {
  .hero { padding: 34px 0 24px; }
  .lead { font-size: 16.5px; }
  .grid { grid-template-columns: 1fr; gap: 14px; padding-bottom: 40px; }
  .card { padding: 20px; }
  .auth-card { padding: 22px; }
  .panel { padding: 18px; }
  .nav .btn-ghost.btn-sm { padding: 8px 12px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
