@font-face { font-family: Inter; src: url("../fonts/Inter-Regular.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: Inter; src: url("../fonts/Inter-SemiBold.woff2") format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: Inter; src: url("../fonts/Inter-Bold.woff2") format("woff2"); font-weight: 700; font-display: swap; }

:root {
  --primary: #c8260a;
  --navy: #0f3d14;
  --ink: #1f2e21;
  --muted: #5f665d;
  --line: #f1e0d3;
  --soft: #fdf2ea;
  --paper: #fffaf5;
  --ok: #1d6b2a;
  --display: 'Playfair Display', Georgia, serif;
  color-scheme: light;
}

* { box-sizing: border-box; margin: 0; }

/* Elements with their own display (savebar, buttons…) must still hide with the hidden attribute. */
[hidden] { display: none !important; }

body {
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font: 400 15px/1.55 Inter, Arial, sans-serif;
  padding-bottom: 96px;
}

a { color: var(--primary); }

.top {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  background: #fffaf5f2;
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}

.top-brand img { display: block; width: 104px; height: auto; }
.top-actions { display: flex; gap: 8px; }

.top-link {
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--navy);
  font: 600 13px Inter, Arial, sans-serif;
  text-decoration: none;
  cursor: pointer;
}

.page {
  width: min(880px, 100%);
  margin: 0 auto;
  padding: 24px 16px;
}

.loading { padding: 60px 0; text-align: center; color: var(--muted); }

h1, h2 { font-family: var(--display); color: var(--navy); line-height: 1.2; }
h1 { font-size: 30px; }
h2 { font-size: 24px; }
h3 { margin: 22px 0 10px; font-size: 13px; font-weight: 700; letter-spacing: .8px; text-transform: uppercase; color: #9a7b3c; }

.lead { margin-top: 8px; color: var(--muted); }
.sub { margin-top: 4px; color: var(--muted); font-size: 14px; }
.intro { margin-bottom: 20px; }

.card {
  margin-bottom: 18px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: #fff;
}

.card.narrow { width: min(460px, 100%); margin: 24px auto; }

.form { display: flex; flex-direction: column; gap: 14px; margin-top: 18px; }

.form label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--navy); }
.form small { font-weight: 400; color: var(--muted); }

.form input {
  height: 46px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
  color: var(--navy);
  font: 400 16px Inter, Arial, sans-serif;
}

input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px #c8260a1f; background: #fff; }

.msg { padding: 10px 12px; border-radius: 10px; background: #fdecea; color: #a3200a; font-size: 14px; }
.msg[data-kind="ok"] { background: #e9f5ea; color: var(--ok); }

.hint { margin-top: 16px; text-align: center; font-size: 14px; color: var(--muted); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--navy);
  font: 700 14px Inter, Arial, sans-serif;
  cursor: pointer;
}

.btn.primary { border-color: var(--primary); background: var(--primary); color: #fff; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.small { min-height: 34px; padding: 0 12px; font-size: 13px; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }

.guide { margin-top: 16px; padding: 14px 16px; border-radius: 14px; background: var(--soft); font-size: 14px; }
.guide summary { font-weight: 700; color: var(--navy); cursor: pointer; }
.guide ol { margin-top: 10px; padding-left: 20px; display: grid; gap: 8px; }
code { padding: 1px 5px; border-radius: 6px; background: #fff; font-size: 13px; }

.test-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin-bottom: 18px;
  padding: 12px 16px;
  border: 1px dashed #e0a43a;
  border-radius: 14px;
  background: #fff8e6;
  color: #6b4a00;
  font-size: 14px;
}

/* Giá */
.prices { display: grid; gap: 10px; }

.price-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 4px 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--paper);
}

.price-row.is-changed { border-color: #f0b8a8; background: #fff3ee; }
.price-name { font-weight: 600; color: var(--navy); }
.price-box { display: inline-flex; align-items: center; gap: 6px; }

.price-input {
  width: 96px;
  height: 44px;
  padding: 0 10px;
  border: 1px solid #ecd3cc;
  border-radius: 12px;
  background: #fff;
  color: var(--primary);
  font: 700 18px Inter, Arial, sans-serif;
  text-align: right;
}

.price-input[aria-invalid="true"] { border-color: var(--primary); background: #fdecea; }
.price-unit { font-weight: 700; color: var(--primary); }
.price-was { grid-column: 1 / -1; font-size: 12.5px; color: var(--muted); }
.price-row.is-changed .price-was { color: var(--primary); font-weight: 600; }

/* Ảnh */
.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.tiles.tall { margin-top: 14px; grid-template-columns: repeat(5, minmax(0, 1fr)); }
.tiles.four { margin-top: 12px; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.tiles.agent { margin-top: 14px; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.tiles.agent .tile-img { aspect-ratio: 1; }
/* Avatar preview: round, like on the website */
.tiles.agent .tile:last-child .tile-img { padding: 14px; background: var(--soft); }
.tiles.agent .tile:last-child .tile-img img { border-radius: 50%; }

.tile {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  background: #fff;
  transition: opacity .2s;
}

.tile.is-changed { border-color: var(--primary); box-shadow: 0 0 0 2px #c8260a26; }
.tile.is-busy { opacity: .5; pointer-events: none; }
.tile-img { aspect-ratio: 3 / 2; background: var(--soft); }
.tiles.tall .tile-img { aspect-ratio: 3 / 4; }
.tile-img img { display: block; width: 100%; height: 100%; object-fit: cover; }

.tile figcaption { display: flex; flex-direction: column; gap: 2px; padding: 10px 10px 4px; font-size: 13px; line-height: 1.35; }
.tile figcaption b { color: var(--navy); }
.tile figcaption small { color: var(--muted); font-size: 11.5px; }
.tile figcaption .tile-new { color: var(--primary); font-weight: 700; }
.tile-actions { display: flex; flex-wrap: wrap; gap: 4px; padding: 6px 10px 10px; margin-top: auto; }

.settings summary { font-family: var(--display); font-size: 20px; font-weight: 700; color: var(--navy); cursor: pointer; }

/* Thanh lưu */
.savebar {
  position: fixed;
  inset: auto 0 0;
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px max(16px, calc((100vw - 880px) / 2 + 16px)) calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: #fffffff5;
  backdrop-filter: blur(8px);
  box-shadow: 0 -10px 30px #0f3d140d;
}

.savebar-text { font-size: 14px; font-weight: 600; color: var(--muted); }
.savebar-text[data-kind="pending"] { color: var(--primary); }
.savebar-text[data-kind="ok"] { color: var(--ok); }
.savebar-text[data-kind="error"] { color: #a3200a; }
.savebar-actions { display: flex; gap: 8px; flex: none; }

@media (max-width: 720px) {
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tiles.tall { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tiles.four, .tiles.agent { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .card { padding: 18px 16px; border-radius: 18px; }
  h1 { font-size: 26px; }
}

@media (max-width: 420px) {
  .savebar { flex-direction: column; align-items: stretch; gap: 8px; }
  .savebar-actions .btn { flex: 1; }
  .savebar-text { text-align: center; }
}
