/* ==========================================================================
   project-stpower v1 — giao diện tối, theo bản giả lập đã duyệt
   QUYẾT ĐỊNH THIẾT KẾ CUỐI (anh Đức chốt 07/11/2026):
   1. Ảnh bìa thẻ dự án: chiều cao ĐỒNG BỘ ở mọi thẻ — khung tỉ lệ 16/9 cố
      định, ảnh cắt vừa khung (object-fit: cover), không thẻ nào cao hơn thẻ khác.
   2. Tiêu đề và tên dự án: màu NỔI BẬT #4cc9f0 (cyan sáng, tương phản tốt
      trên nền tối), in đậm — áp thống nhất cho danh sách dự án và mọi chỗ
      hiển thị tên dự án (chi tiết, bản đồ, thống kê, nhật ký, trang khách).
   ========================================================================== */
:root {
  --bg: #0b1220; --bg2: #0f172a; --card: #111c30; --card2: #16233c;
  --line: #22304d; --text: #e6edf7; --muted: #93a4bd;
  --accent: #22c55e; --accent2: #38bdf8;
  --project: #4cc9f0;            /* màu tên dự án — nổi bật trên nền tối */
  --project-soft: #9be7ff;
  --warn: #f59e0b; --bad: #ef4444; --ok: #22c55e;
  --radius: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg); color: var(--text);
  font-family: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 15px; line-height: 1.5; min-height: 100vh;
}
a { color: var(--accent2); }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 14px; color: var(--text); background: #0b1526; border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent2); outline-offset: 0; border-color: var(--accent2); }
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; font-weight: 600; }

/* ---------- Top bar ---------- */
.topbar { position: sticky; top: 0; z-index: 40; background: rgba(11,18,32,.96); border-bottom: 1px solid var(--line); backdrop-filter: blur(6px); }
.topbar-in { max-width: 1240px; margin: 0 auto; padding: 12px 18px; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.logo { font-size: 19px; font-weight: 800; letter-spacing: .2px; }
.logo span { color: var(--accent2); }
.role-badge { font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 999px; background: #12324a; color: var(--project-soft); border: 1px solid #1e4a68; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.topbar-right .who { font-size: 13px; color: var(--muted); }
.topbar-right .who b { color: var(--text); }

/* ---------- Tabs ---------- */
.tabs { max-width: 1240px; margin: 0 auto; padding: 0 18px; display: flex; gap: 6px; flex-wrap: wrap; border-bottom: 1px solid var(--line); }
.tab { background: none; border: none; color: var(--muted); font-size: 14px; font-weight: 700; padding: 12px 14px; border-bottom: 3px solid transparent; }
.tab.on { color: var(--text); border-bottom-color: var(--accent2); }
.tab:hover { color: var(--text); }

.wrap { max-width: 1240px; margin: 0 auto; padding: 20px 18px 60px; }
.view { display: none; }
.view.on { display: block; }
h1.page-title { font-size: 22px; margin: 4px 0 4px; color: var(--text); }
.sub { color: var(--muted); font-size: 13.5px; margin-bottom: 16px; }

/* ---------- Buttons ---------- */
.btn { background: var(--accent2); color: #06202e; border: none; font-weight: 700; font-size: 14px; padding: 9px 16px; border-radius: 9px; width: auto; }
.btn:hover { filter: brightness(1.1); }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
.btn.danger { background: var(--bad); color: #fff; }
.btn.small { padding: 6px 11px; font-size: 13px; border-radius: 8px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- Cards / grid dự án ---------- */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.toolbar input, .toolbar select { width: auto; flex: 1; min-width: 180px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.pcard { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; }
.pcard .cover {
  /* Ảnh bìa đồng bộ: khung 16/9 cố định, ảnh cắt vừa khung */
  aspect-ratio: 16 / 9; width: 100%; overflow: hidden; background: linear-gradient(135deg, #0d3a5c, #134e6b 55%, #0f766e);
  display: flex; align-items: center; justify-content: center; position: relative; flex: none;
}
.pcard .cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pcard .cover .cover-fallback { font-size: 30px; font-weight: 800; color: rgba(255,255,255,.85); letter-spacing: 1px; }
.pcard .cover .code-chip { position: absolute; left: 10px; top: 10px; background: rgba(6,20,32,.75); color: #fff; font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px; }
.pbody { padding: 14px 15px 15px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
/* Tên dự án — màu nổi bật, áp dụng mọi nơi hiển thị tên dự án */
.p-name { color: var(--project); font-weight: 800; font-size: 17px; line-height: 1.35; }
.p-name.big { font-size: 22px; }
.p-meta { color: var(--muted); font-size: 13.5px; display: flex; gap: 6px; align-items: flex-start; }
.p-meta svg { flex: none; margin-top: 2px; }
.badge { display: inline-block; font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 999px; }
.badge.ok { background: #0f2f1d; color: #4ade80; border: 1px solid #1d5c34; }
.badge.warn { background: #3a2a05; color: #fbbf24; border: 1px solid #7a5b0b; }
.badge.bad { background: #3d0f0f; color: #f87171; border: 1px solid #7f1d1d; }
.badge.info { background: #12324a; color: var(--project-soft); border: 1px solid #1e4a68; }
.wbar { height: 8px; border-radius: 999px; background: #1c2a44; overflow: hidden; }
.wbar > i { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.wbar.warn > i { background: var(--warn); }
.wbar.bad > i { background: var(--bad); }
.p-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: auto; padding-top: 6px; }

/* ---------- Panel / form ---------- */
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.panel h3 { margin: 0 0 4px; font-size: 17px; color: var(--text); }
.panel h3 .p-name { font-size: 17px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; }
.kv { display: grid; grid-template-columns: 170px 1fr; gap: 8px 14px; font-size: 14.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

/* ---------- Bảng ---------- */
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th, .tbl td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl th { color: var(--muted); font-size: 12.5px; text-transform: uppercase; letter-spacing: .4px; }
.tbl tr:hover td { background: rgba(255,255,255,.02); }
.tbl .p-name { font-size: 14.5px; }
.num { text-align: right !important; font-variant-numeric: tabular-nums; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 13px; word-break: break-all; }

/* ---------- QR Design ---------- */
.tpl-list { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.tpl { background: var(--card2); border: 2px solid var(--line); color: var(--text); border-radius: 10px; padding: 10px 14px; font-weight: 700; width: auto; }
.tpl.on { border-color: var(--accent2); background: #12324a; }
.sticker { background: #fff; color: #111; border-radius: 12px; padding: 14px; width: 230px; text-align: center; }
.sticker .st-head { font-weight: 800; font-size: 14px; padding: 6px; border-radius: 8px 8px 0 0; }
.sticker .st-qr img { width: 180px; height: 180px; display: block; margin: 8px auto; }
.sticker .st-foot { font-size: 12.5px; font-weight: 700; padding: 6px; border-radius: 0 0 8px 8px; }
.sticker.tpl-navy .st-head { background: #0d3a5c; color: #fff; }
.sticker.tpl-navy .st-foot { background: #eef3f7; color: #0d3a5c; }
.sticker.tpl-min { border: 1.5px solid #d5dde5; }
.sticker.tpl-min .st-head { color: #0d3a5c; padding-bottom: 0; }
.sticker.tpl-min .st-foot { color: #71808f; }
.sticker.tpl-ind { border: 3px solid #14181c; }
.sticker.tpl-ind .st-head { background: #f5a623; color: #14181c; }
.sticker.tpl-ind .st-foot { background: #14181c; color: #ffd88a; }
.sticker.tpl-custom .st-head { background: var(--tpl-color, #0d3a5c); color: #fff; }
.sticker.tpl-custom .st-foot { background: var(--tpl-bg, #eef3f7); color: var(--tpl-color, #0d3a5c); }
.qr-preview { display: flex; gap: 18px; flex-wrap: wrap; align-items: flex-start; }

/* ---------- Thống kê ---------- */
.stat-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-bottom: 16px; }
.stat-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.stat-card .v { font-size: 30px; font-weight: 800; color: var(--project); }
.stat-card .l { color: var(--muted); font-size: 13px; font-weight: 600; }
.chart { display: flex; align-items: flex-end; gap: 6px; height: 150px; padding: 10px 4px 0; }
.chart .bar { flex: 1; background: var(--accent2); border-radius: 5px 5px 0 0; min-height: 3px; position: relative; }
.chart .bar span { position: absolute; bottom: -18px; left: 50%; transform: translateX(-50%); font-size: 10.5px; color: var(--muted); }
.chart-wrap { padding-bottom: 22px; }

/* ---------- Nhật ký ---------- */
.timeline { display: flex; flex-direction: column; gap: 12px; }
.jitem { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.jitem .j-head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 6px; }
.jitem .j-date { font-weight: 800; }
.jtype { font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 999px; }
.jtype.warranty { background: #3d0f0f; color: #f87171; }
.jtype.clean { background: #0f2f1d; color: #4ade80; }
.jtype.check { background: #12324a; color: var(--project-soft); }
.jitem .j-tech { color: var(--muted); font-size: 13px; }
.j-photos { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.j-photos img { width: 110px; height: 82px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); cursor: zoom-in; }

/* ---------- Bản đồ ---------- */
#map { height: 520px; border-radius: var(--radius); border: 1px solid var(--line); z-index: 1; }
.leaflet-popup-content { color: #111; }
.leaflet-popup-content .p-name { color: #0b6fa4; }

/* ---------- Login ---------- */
.login-wrap { max-width: 420px; margin: 60px auto; }
.login-card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 28px; }
.login-card h1 { margin: 0 0 4px; font-size: 22px; }
.login-card h1 span { color: var(--accent2); }
.login-card p { color: var(--muted); font-size: 13.5px; margin: 0 0 20px; }
.field { margin-bottom: 14px; }
.err { background: #3d0f0f; border: 1px solid #7f1d1d; color: #fca5a5; border-radius: 9px; padding: 10px 12px; font-size: 13.5px; margin-bottom: 14px; display: none; }
.hint { font-size: 12.5px; color: var(--muted); margin-top: 14px; line-height: 1.6; }

/* ---------- Modal / overlay ---------- */
.overlay { position: fixed; inset: 0; background: rgba(3,7,18,.7); display: none; align-items: flex-start; justify-content: center; z-index: 100; padding: 30px 14px; overflow-y: auto; }
.overlay.on { display: flex; }
.sheet { background: var(--bg2); border: 1px solid var(--line); border-radius: 16px; width: 100%; max-width: 720px; padding: 20px; }
.sheet-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 12px; }
.sheet-head h3 { margin: 0; font-size: 18px; }
.x { background: transparent; border: 1px solid var(--line); color: var(--text); border-radius: 8px; padding: 5px 10px; width: auto; }
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.85); display: none; align-items: center; justify-content: center; z-index: 200; padding: 20px; }
.lightbox.on { display: flex; }
.lightbox img { max-width: 92vw; max-height: 88vh; border-radius: 10px; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #12324a; color: #fff; border: 1px solid #1e4a68; padding: 10px 18px; border-radius: 999px; font-weight: 600; font-size: 14px; display: none; z-index: 300; box-shadow: 0 8px 30px rgba(0,0,0,.5); }
.toast.on { display: block; }

/* ---------- Guest ---------- */
.guest-hero { border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); margin-bottom: 16px; }
/* Ảnh bìa trang khách/chi tiết: cao cố định 320px, rộng 100% (KHÔNG dùng
   aspect-ratio + max-height cùng lúc: trình duyệt sẽ co chiều rộng theo
   chiều cao bị chặn, làm ảnh bìa chỉ còn nửa khung). */
.guest-hero .cover { height: 320px; width: 100%; background: linear-gradient(135deg, #0d3a5c, #134e6b 55%, #0f766e); display: flex; align-items: center; justify-content: center; }
.guest-hero .cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.guest-hero .cover .cover-fallback { font-size: 40px; font-weight: 800; color: rgba(255,255,255,.85); }
.contact-box { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 720px) {
  .form-grid, .contact-box { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 130px 1fr; }
  #map { height: 380px; }
  .guest-hero .cover { height: 220px; }
  .topbar-right .who { display: none; }
}

/* ---------- In tem ---------- */
.print-area { display: none; }
@media print {
  body * { visibility: hidden; }
  .print-area, .print-area * { visibility: visible; }
  .print-area { display: block; position: absolute; inset: 0; background: #fff; }
  .print-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; padding: 12px; }
}
.print-grid { display: flex; gap: 14px; flex-wrap: wrap; }
