/* =====================================================================
   Tiha QC Web – phong cách CTi Việt Nam (đỏ / trắng / thép)
   © VictorNguyen
   ===================================================================== */
:root {
  --red: #e30613;
  --red-2: #fa0000;
  --red-dark: #b0000c;
  --red-soft: #fdecee;
  --ink: #39464f;
  --ink-2: #5d6b75;
  --muted: #8a96a0;
  --steel: #1e2930;
  --steel-2: #33424c;
  --line: #e3e7eb;
  --bg: #f3f5f7;
  --white: #fff;
  --ok: #1f9d55;
  --ok-soft: #e6f6ec;
  --warn: #e08a00;
  --warn-soft: #fff4e0;
  --radius: 10px;
  --shadow: 0 2px 10px rgba(30, 41, 48, .08);
  --shadow-lg: 0 10px 30px rgba(30, 41, 48, .16);
  --font: "Barlow", Arial, Helvetica, sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  font-size: 15px;
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
img { max-width: 100%; display: block; }
[hidden] { display: none !important; }

/* ============================ HEADER ============================ */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: linear-gradient(90deg, var(--red-2) 0%, var(--red) 55%, var(--red-dark) 100%);
  box-shadow: 0 2px 12px rgba(176, 0, 12, .35);
}
.topbar-inner {
  max-width: 1180px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  height: 64px; padding: 0 16px 0 0;
}
.brand { display: flex; align-items: center; height: 100%; gap: 14px; }
.logo-box {
  height: 100%; min-width: 118px; padding: 0 14px;
  background: #fff; display: flex; align-items: center; justify-content: center;
  clip-path: polygon(0 0, 100% 0, 88% 100%, 0 100%);
  padding-right: 26px;
}
.logo-box img { height: 46px; width: auto; }
.logo-text { display: flex; flex-direction: column; align-items: center; line-height: .9; color: var(--red); }
.logo-text b { font-size: 30px; font-weight: 800; font-style: italic; letter-spacing: -1px; }
.logo-text small { font-size: 10px; font-weight: 700; letter-spacing: 1.5px; margin-top: 2px; }
.brand-title {
  color: #fff; font-weight: 700; font-size: 19px; letter-spacing: 1.5px;
  text-shadow: 0 1px 2px rgba(0,0,0,.2);
}
.mainnav { display: flex; gap: 4px; }
.mainnav a {
  color: #fff; font-weight: 600; text-transform: uppercase; font-size: 14px; letter-spacing: .5px;
  padding: 9px 14px; border-radius: 4px; position: relative; transition: background .15s;
}
.mainnav a:hover { background: rgba(255,255,255,.15); }
.mainnav a.active { background: rgba(0,0,0,.18); }
.mainnav a.active::after {
  content: ""; position: absolute; left: 14px; right: 14px; bottom: 3px; height: 2px; background: #fff;
}
.badge {
  display: inline-block; min-width: 20px; padding: 1px 6px; margin-left: 4px;
  background: #fff; color: var(--red); border-radius: 10px; font-size: 12px; font-weight: 700; text-align: center;
}

/* ============================ LAYOUT ============================ */
.app { flex: 1; width: 100%; max-width: 1180px; margin: 0 auto; padding: 0 0 24px; }
.page { padding: 16px; animation: fade .18s ease-out; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* Hero tông thép giống banner CTi */
.hero {
  position: relative; overflow: hidden;
  margin: 0 0 16px; padding: 22px 20px 20px; border-radius: var(--radius);
  color: #fff;
  background:
    radial-gradient(circle at 85% 20%, rgba(255,255,255,.12) 0, transparent 40%),
    repeating-linear-gradient(115deg, rgba(255,255,255,.03) 0 2px, transparent 2px 9px),
    linear-gradient(135deg, var(--steel) 0%, #3b4a55 55%, #26323a 100%);
  box-shadow: var(--shadow);
}
.hero::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 6px; background: var(--red);
}
.hero h1 {
  margin: 0; font-size: 26px; font-weight: 800; letter-spacing: 1px; text-transform: uppercase;
}
.hero p { margin: 4px 0 0; color: #c9d3da; font-size: 14px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 16px; }
.stat {
  background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.12);
  border-radius: 8px; padding: 10px 12px;
}
.stat b { display: block; font-size: 24px; font-weight: 800; line-height: 1.1; }
.stat span { font-size: 12px; color: #c9d3da; text-transform: uppercase; letter-spacing: .5px; }
.stat.red b { color: #ff6b74; }

.section-title {
  display: flex; align-items: center; gap: 10px;
  margin: 18px 0 10px; font-size: 16px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--steel);
}
.section-title::before { content: ""; width: 4px; height: 18px; background: var(--red); border-radius: 2px; }
.section-title .count { margin-left: auto; font-size: 13px; color: var(--muted); font-weight: 600; text-transform: none; }

/* ============================ SEARCH ============================ */
.searchbar {
  display: flex; align-items: center; gap: 8px;
  background: #fff; border: 2px solid var(--line); border-radius: 30px; padding: 4px 6px 4px 16px;
  box-shadow: var(--shadow); transition: border-color .15s;
}
.searchbar:focus-within { border-color: var(--red); }
.searchbar svg { width: 20px; height: 20px; stroke: var(--muted); fill: none; stroke-width: 2; flex: none; }
.searchbar input { flex: 1; border: 0; outline: 0; padding: 10px 0; font-size: 16px; background: transparent; min-width: 0; }
.searchbar .clear {
  border: 0; background: var(--bg); width: 30px; height: 30px; border-radius: 50%; cursor: pointer; color: var(--ink-2); flex: none;
}
.hint { color: var(--muted); font-size: 13px; margin: 8px 4px 0; }

.filters { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 6px; margin-bottom: 4px; }
.chip {
  border: 1.5px solid var(--line); background: #fff; border-radius: 20px; padding: 7px 14px;
  font-weight: 600; font-size: 14px; white-space: nowrap; cursor: pointer; color: var(--ink-2);
}
.chip.active { background: var(--red); color: #fff; border-color: var(--red); }

/* ============================ CARDS ============================ */
.list { display: grid; grid-template-columns: 1fr; gap: 10px; }
@media (min-width: 820px) { .list { grid-template-columns: 1fr 1fr; } }

.card {
  background: #fff; border-radius: var(--radius); box-shadow: var(--shadow);
  border: 1px solid var(--line); position: relative; overflow: hidden;
}
.item {
  display: block; padding: 14px 14px 12px 18px; cursor: pointer; transition: transform .12s, box-shadow .12s;
}
.item::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--red); }
.item.done::before { background: var(--ok); }
.item.partial::before { background: var(--warn); }
.item:active { transform: scale(.99); }
@media (hover: hover) { .item:hover { box-shadow: var(--shadow-lg); } }
.item-top { display: flex; align-items: flex-start; gap: 10px; }
.item-title { font-size: 17px; font-weight: 700; color: var(--steel); word-break: break-word; }
.item-sub { font-size: 14px; color: var(--red); font-weight: 600; margin-top: 1px; word-break: break-word; }
.item-plan { margin-left: auto; text-align: right; flex: none; }
.pill {
  display: inline-block; padding: 3px 9px; border-radius: 12px; font-size: 12px; font-weight: 700; white-space: nowrap;
  background: var(--bg); color: var(--ink-2);
}
.pill.red { background: var(--red-soft); color: var(--red); }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.dark { background: var(--steel); color: #fff; }
.pill.big { font-size: 13.5px; padding: 4px 11px; letter-spacing: .4px; }
.pill.ok.big { background: var(--ok); color: #fff; }
.item.complete { background: #f7fbf7; }
.why { margin-top: 8px; font-size: 13px; color: var(--ok); }
.why b { color: var(--ink); font-weight: 600; }
.item-plan small { display: block; color: var(--muted); font-size: 12px; margin-top: 3px; }
.kv { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 8px; font-size: 13.5px; }
.kv span { color: var(--muted); }
.kv b { font-weight: 600; color: var(--ink); }
.progress { margin-top: 10px; display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--ink-2); font-weight: 600; }
.bar { flex: 1; height: 7px; background: var(--bg); border-radius: 4px; overflow: hidden; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--red), var(--red-2)); border-radius: 4px; }
.bar i.full { background: linear-gradient(90deg, #1f9d55, #34c472); }

.empty {
  text-align: center; padding: 40px 20px; color: var(--muted);
}
.empty .ico {
  width: 74px; height: 74px; margin: 0 auto 12px; border-radius: 50%;
  border: 2px solid var(--red); display: flex; align-items: center; justify-content: center;
}
.empty .ico svg { width: 34px; height: 34px; stroke: var(--red); fill: none; stroke-width: 1.8; }

/* ============================ DETAIL ============================ */
.back {
  display: inline-flex; align-items: center; gap: 6px; color: var(--ink-2); font-weight: 600; margin-bottom: 10px; cursor: pointer;
  background: none; border: 0; padding: 4px 0;
}
.detail-head { padding: 16px 16px 14px 20px; }
.detail-head::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; background: var(--red); }
.detail-head h2 { margin: 0; font-size: 22px; font-weight: 800; color: var(--steel); word-break: break-word; }
.detail-head .sub { color: var(--red); font-weight: 700; font-size: 16px; margin-top: 2px; }
.detail-head .meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }

.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table td { padding: 8px 12px; border-top: 1px solid var(--line); vertical-align: top; }
.table td:first-child { color: var(--muted); width: 42%; }
.table td:last-child { font-weight: 600; word-break: break-word; }
.more { display: block; width: 100%; padding: 10px; border: 0; border-top: 1px solid var(--line); background: #fafbfc; color: var(--red); font-weight: 700; cursor: pointer; }

.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 14px 0; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 6px; padding: 13px 16px; font-weight: 700; font-size: 15px; letter-spacing: .5px;
  text-transform: uppercase; cursor: pointer; transition: filter .15s, transform .1s;
}
.btn:active { transform: scale(.98); }
.btn svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 2; }
.btn-red { background: linear-gradient(180deg, var(--red-2), var(--red)); color: #fff; box-shadow: 0 4px 12px rgba(227,6,19,.3); }
.btn-red:hover { filter: brightness(1.05); }
.btn-outline { background: #fff; color: var(--red); border: 2px solid var(--red); }
.btn-dark { background: var(--steel); color: #fff; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .55; pointer-events: none; }

.timeline { display: flex; flex-direction: column; gap: 10px; }
.tl { padding: 12px 14px; }
.tl-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tl-head b { font-size: 16px; color: var(--steel); }
.tl-head .by { margin-left: auto; color: var(--muted); font-size: 12.5px; }
.tl p { margin: 6px 0 0; font-size: 14px; white-space: pre-wrap; word-break: break-word; }
.thumbs { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.thumbs img { width: 68px; height: 68px; object-fit: cover; border-radius: 6px; cursor: zoom-in; border: 1px solid var(--line); background: var(--bg); }
.link-del { margin-left: 8px; color: var(--red); font-size: 12.5px; font-weight: 600; cursor: pointer; background: none; border: 0; padding: 0; }
.reply { margin-top: 10px; padding: 10px 12px; background: var(--bg); border-left: 3px solid var(--steel); border-radius: 4px; font-size: 14px; }
.reply small { display: block; color: var(--muted); margin-bottom: 4px; }

/* ============================ FORMS ============================ */
.form { padding: 16px; }
.form h3 { margin: 0 0 4px; font-size: 19px; text-transform: uppercase; font-weight: 800; color: var(--steel); }
.form .for { color: var(--red); font-weight: 700; margin-bottom: 12px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-weight: 700; font-size: 13px; color: var(--ink-2); margin-bottom: 6px; text-transform: uppercase; letter-spacing: .4px; }
.input, .textarea, .select {
  width: 100%; border: 1.5px solid var(--line); border-radius: 6px; padding: 12px; font-size: 16px; background: #fff; outline: 0;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus, .textarea:focus, .select:focus { border-color: var(--red); box-shadow: 0 0 0 3px rgba(227,6,19,.12); }
.textarea { min-height: 96px; resize: vertical; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.qty-wrap { display: flex; align-items: stretch; }
.qty-wrap button { width: 48px; border: 1.5px solid var(--line); background: var(--bg); font-size: 22px; font-weight: 700; cursor: pointer; }
.qty-wrap button:first-child { border-radius: 6px 0 0 6px; border-right: 0; }
.qty-wrap button:last-child { border-radius: 0 6px 6px 0; border-left: 0; }
.qty-wrap .input { border-radius: 0; text-align: center; font-weight: 700; font-size: 18px; }
.seg { display: flex; flex-wrap: wrap; gap: 8px; }
.seg button {
  border: 1.5px solid var(--line); background: #fff; border-radius: 6px; padding: 10px 12px; font-weight: 600; cursor: pointer; flex: 1 1 auto;
}
.seg button.on { border-color: var(--red); background: var(--red-soft); color: var(--red); }
.seg button.on.okc { border-color: var(--ok); background: var(--ok-soft); color: var(--ok); }

.photos { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.photo, .add-photo { position: relative; aspect-ratio: 1; border-radius: 8px; overflow: hidden; }
.photo img { width: 100%; height: 100%; object-fit: cover; }
.photo button {
  position: absolute; top: 4px; right: 4px; width: 24px; height: 24px; border-radius: 50%; border: 0;
  background: rgba(0,0,0,.6); color: #fff; font-size: 13px; cursor: pointer;
}
.field .add-photo, .add-photo {
  text-transform: none; letter-spacing: 0; margin: 0;
  border: 2px dashed #c9d1d8; background: #fafbfc; display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: var(--ink-2); font-size: 12px; font-weight: 600; cursor: pointer; text-align: center; gap: 4px;
}
.add-photo svg { width: 28px; height: 28px; stroke: var(--red); fill: none; stroke-width: 1.8; }
.add-photo input { display: none; }
.sticky-actions { padding: 6px 0 0; }

/* ============================ LOGIN ============================ */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px;
  background:
    radial-gradient(circle at 80% 10%, rgba(255,255,255,.10) 0, transparent 35%),
    repeating-linear-gradient(115deg, rgba(255,255,255,.035) 0 2px, transparent 2px 10px),
    linear-gradient(140deg, #182127 0%, #34434d 50%, #1b252b 100%);
}
.login-card { width: 100%; max-width: 400px; background: #fff; border-radius: 12px; overflow: hidden; box-shadow: 0 20px 50px rgba(0,0,0,.45); }
.login-top {
  background: linear-gradient(90deg, var(--red-2), var(--red) 60%, var(--red-dark));
  display: flex; align-items: center; gap: 14px; height: 78px; padding-right: 16px;
}
.login-top .logo-box { min-width: 130px; }
.login-top .brand-title { font-size: 18px; }
.login-body { padding: 22px 22px 18px; }
.login-body h2 { margin: 0 0 4px; font-size: 22px; font-weight: 800; color: var(--steel); text-transform: uppercase; }
.login-body p { margin: 0 0 18px; color: var(--muted); font-size: 14px; }
.check { display: flex; align-items: center; gap: 8px; margin: 4px 0 16px; font-weight: 600; color: var(--ink-2); }
.check input { width: 18px; height: 18px; accent-color: var(--red); }
.err { background: var(--red-soft); color: var(--red); padding: 10px 12px; border-radius: 6px; font-weight: 600; font-size: 14px; margin-bottom: 12px; }
.login-foot { text-align: center; color: #aab4bb; font-size: 12.5px; padding: 0 0 16px; }

/* ============================ ACCOUNT ============================ */
.profile { display: flex; align-items: center; gap: 14px; padding: 16px; }
.avatar {
  width: 56px; height: 56px; border-radius: 50%; flex: none;
  background: linear-gradient(135deg, var(--red-2), var(--red-dark)); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 22px; font-weight: 800;
}
.profile b { font-size: 18px; color: var(--steel); display: block; }
.profile span { color: var(--muted); font-size: 14px; }

/* ============================ FOOTER / NAV ============================ */
.footer { background: var(--steel); color: #b8c3ca; font-size: 13px; }
.footer-inner { max-width: 1180px; margin: 0 auto; padding: 14px 16px; display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.footer b { color: #fff; }

.bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
  display: none; background: #fff; border-top: 1px solid var(--line);
  padding-bottom: var(--safe-b); box-shadow: 0 -4px 16px rgba(0,0,0,.06);
}
.bottomnav a {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0 7px;
  font-size: 11.5px; font-weight: 600; color: var(--muted); position: relative;
}
.bottomnav svg { width: 24px; height: 24px; stroke: currentColor; fill: none; stroke-width: 1.9; stroke-linejoin: round; stroke-linecap: round; }
.bottomnav a.active { color: var(--red); }
.bottomnav a.active::before { content: ""; position: absolute; top: 0; left: 30%; right: 30%; height: 3px; background: var(--red); border-radius: 0 0 3px 3px; }
.bottomnav .dot { position: absolute; top: 6px; left: calc(50% + 8px); width: 9px; height: 9px; background: var(--red); border-radius: 50%; border: 2px solid #fff; }

@media (max-width: 760px) {
  .mainnav { display: none; }
  .bottomnav { display: flex; }
  .app { padding-bottom: calc(76px + var(--safe-b)); }
  .footer { display: none; }
  .topbar-inner { height: 56px; }
  .logo-box { min-width: 96px; padding-right: 22px; }
  .logo-box img { height: 38px; }
  .logo-text b { font-size: 25px; }
  .brand-title { font-size: 16px; letter-spacing: 1px; }
  .hero h1 { font-size: 22px; }
  .page { padding: 12px; }
}
@media (max-width: 420px) { .photos { grid-template-columns: repeat(3, 1fr); } }

/* ============================ TOAST / LIGHTBOX / LOADING ============================ */
.toast {
  position: fixed; left: 50%; bottom: calc(90px + var(--safe-b)); transform: translateX(-50%); z-index: 100;
  background: var(--steel); color: #fff; padding: 12px 18px; border-radius: 8px; font-weight: 600; box-shadow: var(--shadow-lg);
  max-width: 90vw; text-align: center;
}
.toast.ok { background: var(--ok); }
.toast.bad { background: var(--red); }
.lightbox { position: fixed; inset: 0; z-index: 120; background: rgba(0,0,0,.92); display: flex; align-items: center; justify-content: center; }
.lightbox img { max-width: 96vw; max-height: 90vh; object-fit: contain; }
.lb-close { position: absolute; top: 14px; right: 14px; width: 42px; height: 42px; border-radius: 50%; border: 0; background: rgba(255,255,255,.15); color: #fff; font-size: 20px; cursor: pointer; }
.loading { display: flex; justify-content: center; padding: 40px; }
.spinner { width: 34px; height: 34px; border: 3px solid var(--line); border-top-color: var(--red); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================ v1.4 ============================ */
mark { background: #ffe066; color: inherit; padding: 0 1px; border-radius: 2px; }
.kv.hits { border-top: 1px dashed var(--line); padding-top: 6px; }
.segtabs { display: grid; grid-template-columns: 1fr 1fr; gap: 0; margin: 0 0 12px; border-radius: 8px; overflow: hidden; border: 2px solid var(--red); background: #fff; }
.segtabs button { border: 0; background: #fff; color: var(--red); font-weight: 700; padding: 11px 6px; cursor: pointer; font-size: 14.5px; }
.segtabs button b { display: inline-block; margin-left: 4px; min-width: 24px; padding: 0 6px; border-radius: 10px; background: var(--red-soft); }
.segtabs button.on { background: var(--red); color: #fff; }
.segtabs button.on b { background: rgba(255,255,255,.25); }
.install-card { display: flex; flex-direction: column; gap: 12px; }
.install-row { display: flex; gap: 12px; align-items: center; }
.install-row img { border-radius: 12px; box-shadow: var(--shadow); }
.install-row b { display: block; font-size: 17px; color: var(--steel); }
.install-row span { color: var(--muted); font-size: 14px; }
.install-help { background: var(--bg); border-radius: 8px; padding: 12px 14px; font-size: 14px; line-height: 1.55; }
.install-help ol { margin: 6px 0 6px 18px; padding: 0; }
.install-help small { color: var(--ink-2); display: block; margin-top: 4px; }
.ios-share { display: inline-block; border: 1.5px solid var(--ink-2); border-radius: 4px; padding: 0 4px; font-size: 12px; }

.chk { padding: 10px 14px; margin-top: 12px; font-size: 13px; }
.chk summary { cursor: pointer; font-weight: 700; color: var(--ink-2); }
.chk ul { margin: 8px 0 0 18px; padding: 0; line-height: 1.6; }
