/* Hệ thống DNS MORA — token theo bộ nhận diện MORA (mora.vn/brand/static/site.css): xanh #0077B2, navy #0B1220,
   chữ Plus Jakarta Sans, wordmark MORA Tech. Phông nhúng trong ảnh (không gọi dịch vụ ngoài, hợp CSP). */
@font-face { font-family: "Plus Jakarta Sans"; src: url("/static/fonts/PlusJakartaSans-Var.woff2") format("woff2"); font-weight: 200 800; font-display: swap; }
@font-face { font-family: "MORA Tech"; src: url("/static/fonts/MoraTech-Regular.woff2") format("woff2"); font-weight: 400; font-display: swap; }

:root {
  --blue: #0077B2; --blue2: #00669A; --blue3: #005681; --blue-soft: #E6F2F8; --navy: #0B1220;
  --ink: #1F2328; --ink2: #3B4252; --mute: #5B6478; --line: #E3E8EF; --line2: #D5DCE6;
  --bg: #F6F8FC; --surface: #FFFFFF; --surface2: #F1F4F9; --hover: #EEF3F9; --top: #FFFFFF;
  --ok: #047857; --ok-soft: #E3F4EC; --warn: #B45309; --warn-soft: #FDF1E1; --err: #C8102E; --err-soft: #FCE8EC;
  --shadow: 0 1px 2px rgba(16,24,40,.06), 0 4px 16px rgba(16,24,40,.06);
  --radius: 12px; --radius-sm: 8px;
  --font: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --blue: #3AA6DC; --blue2: #62B8E4; --blue3: #8CCBEC; --blue-soft: #11304A;
    --ink: #E6EBF3; --ink2: #C3CBD8; --mute: #98A3B8; --line: #243150; --line2: #2E3C5E;
    --bg: #0B1220; --surface: #121B2C; --surface2: #18233A; --hover: #1C2942; --top: #0B1220;
    --ok: #34D399; --ok-soft: #0E3328; --warn: #F5B35C; --warn-soft: #3A2A12; --err: #F37A8E; --err-soft: #3D1620;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 6px 20px rgba(0,0,0,.35);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100vh; display: flex; flex-direction: column; font: 15px/1.55 var(--font); color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 24px; line-height: 1.25; margin: 0 0 8px; letter-spacing: -.015em; font-weight: 700; text-wrap: balance; }
h2 { font-size: 17px; margin: 0 0 10px; font-weight: 700; }
h3 { font-size: 15px; margin: 0 0 8px; font-weight: 700; }
p { margin: 0 0 10px; }
code, .mono { font-family: var(--mono); font-size: .92em; }
code { background: var(--surface2); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; }
.break { word-break: break-all; }
.small { font-size: 13px; }
.mute { color: var(--mute); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.row.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.inline { display: inline; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

.wrap { width: 100%; max-width: 1080px; margin: 0 auto; padding: 0 20px; }
.page { flex: 1; padding-top: 28px; padding-bottom: 48px; display: flex; flex-direction: column; gap: 20px; }

/* Thanh trên cùng */
header.top { background: var(--top); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.bar { display: flex; align-items: center; gap: 16px; height: 60px; }
.logo { display: inline-flex; align-items: center; gap: 10px; text-decoration: none !important; }
.logo img { height: 28px; width: auto; display: block; }
.logo .prod { font: 700 13px/1 var(--font); letter-spacing: .08em; color: var(--blue); border-left: 1px solid var(--line2); padding-left: 10px; }
.nav { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.nav > a:not(.btn) { color: var(--ink); padding: 7px 10px; border-radius: 8px; font-size: 14px; font-weight: 500; }
.nav > a:not(.btn):hover { background: var(--hover); text-decoration: none; }
.user { position: relative; }
.user summary { list-style: none; cursor: pointer; border-radius: 50%; }
.user summary::-webkit-details-marker { display: none; }
.avatar { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: linear-gradient(135deg, var(--navy), var(--blue3)); color: #fff; font: 700 13px/1 var(--font); }
.umenu { position: absolute; right: 0; top: 44px; min-width: 240px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 6px; z-index: 20; }
.umenu a, .menu-btn { display: block; width: 100%; text-align: left; padding: 8px 10px; border-radius: 6px; color: var(--ink); background: none; border: 0; font: inherit; font-size: 14px; cursor: pointer; }
.umenu a:hover, .menu-btn:hover { background: var(--hover); text-decoration: none; }
.menu-btn.out { color: var(--err); }
.uhead { padding: 6px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 6px; display: flex; flex-direction: column; }
.uhead span { font-size: 12px; color: var(--mute); word-break: break-all; }

/* Nút, ô nhập */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; font: 600 14px/1.2 var(--font); padding: 10px 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--blue); background: var(--blue); color: #fff; cursor: pointer; white-space: nowrap; text-decoration: none !important; }
.btn:hover { background: var(--blue2); border-color: var(--blue2); }
.btn img { filter: brightness(0) invert(1); border-radius: 4px; }
.btn.ghost { background: var(--surface); color: var(--ink); border-color: var(--line2); }
.btn.ghost:hover { background: var(--hover); }
.btn.sm { padding: 6px 11px; font-size: 13px; }
.btn.danger { color: var(--err); }
.btn.danger-solid { background: var(--err); border-color: var(--err); color: #fff; }
input, select, textarea { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line2); border-radius: var(--radius-sm); padding: 8px 10px; width: 100%; min-width: 0; }
textarea { resize: vertical; font-family: var(--mono); font-size: 13px; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--blue) 35%, transparent); border-color: var(--blue); }
label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 600; color: var(--ink2); }
.hint { font-weight: 400; color: var(--mute); font-size: 12px; }

.pill { display: inline-flex; align-items: center; font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 999px; background: var(--surface2); color: var(--ink2); white-space: nowrap; }
.st-active { background: var(--ok-soft); color: var(--ok); }
.st-pending { background: var(--warn-soft); color: var(--warn); }
.st-external { background: var(--blue-soft); color: var(--blue); }
.st-suspended { background: var(--err-soft); color: var(--err); }
.tag { display: inline-block; font: 700 11px/1 var(--mono); padding: 4px 6px; border-radius: 5px; background: var(--blue-soft); color: var(--blue); }
.alert { padding: 10px 12px; border-radius: var(--radius-sm); background: var(--blue-soft); font-size: 14px; margin: 0; }
.alert.ok { background: var(--ok-soft); color: var(--ok); }
.alert.err { background: var(--err-soft); color: var(--err); }
.alert.warn { background: var(--warn-soft); color: var(--warn); }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.panel.narrow { max-width: 560px; margin: 24px auto; width: 100%; }
.head-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.head-row h1, .head-row h2 { margin: 0; }
.crumbs { color: var(--mute); }
.zone-title { font-family: var(--mono); font-size: 22px; word-break: break-all; }
.meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; color: var(--mute); margin: 4px 0 0; }

/* Trang chủ */
.hero { padding: 28px 0 8px; max-width: 720px; }
.eyebrow { font: 700 12px/1 var(--font); letter-spacing: .12em; text-transform: uppercase; color: var(--blue); margin-bottom: 12px; }
.hero h1 { font-size: clamp(26px, 4vw, 38px); }
.lead { font-size: 17px; color: var(--mute); }
.cards3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }

/* Danh sách zone */
.zone-list { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.zone-card { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; color: var(--ink); box-shadow: var(--shadow); }
.zone-card:hover { border-color: var(--blue); text-decoration: none; }
.zname { font: 600 16px/1.3 var(--mono); word-break: break-all; }
.empty p:last-child { margin: 0; }

/* Hướng dẫn */
.guide p:last-child { margin-bottom: 0; }
.ways { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; margin-bottom: 12px; }
.way { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px; background: var(--surface2); }
.steps { padding-left: 20px; margin: 0 0 8px; }
.codes { list-style: none; padding: 0; margin: 0 0 10px; display: flex; flex-direction: column; gap: 6px; }
.codes code { font-size: 14px; padding: 4px 8px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 12px; margin: 0; align-items: baseline; }
.kv dt { font-size: 13px; color: var(--mute); }
.kv dd { margin: 0; min-width: 0; }

/* Bảng bản ghi */
.records { display: flex; flex-direction: column; gap: 12px; }
table.rec { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.rec th { text-align: left; font-size: 12px; font-weight: 700; color: var(--mute); text-transform: uppercase; letter-spacing: .04em; padding: 10px 12px; background: var(--surface2); border-bottom: 1px solid var(--line); }
.rec td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; font-size: 14px; }
.rec tr:last-child td { border-bottom: 0; }
.rec td.c-val { word-break: break-all; max-width: 460px; }
.rec td.c-name { word-break: break-all; font-weight: 600; }
.rec td.act { text-align: right; white-space: nowrap; }
.rec td.act > * { vertical-align: top; }
details.edit { display: inline-block; text-align: left; }
details.edit > summary { list-style: none; }
details.edit > summary::-webkit-details-marker { display: none; }
details.edit[open] { display: block; margin-bottom: 8px; }
details.edit[open] > form { margin-top: 10px; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface2); white-space: normal; min-width: min(560px, 80vw); }
.fgrid { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 10px 12px; margin-bottom: 12px; }
.fgrid .wide { grid-column: 1 / -1; }
.audit { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.filters { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.filters label { flex: 1; min-width: 180px; }
.pager { margin-top: 4px; }

footer.foot { border-top: 1px solid var(--line); color: var(--mute); font-size: 12px; padding: 16px 0 24px; }

/* Điện thoại: bảng thành thẻ */
@media (max-width: 720px) {
  .wrap { padding: 0 16px; }
  .bar { height: 56px; gap: 10px; }
  .logo img { height: 24px; }
  .nav > a:not(.btn) { padding: 6px 7px; font-size: 13px; }
  .page { padding-top: 20px; }
  h1 { font-size: 21px; }
  .fgrid { grid-template-columns: 1fr 1fr; }
  .fgrid label:first-child { grid-column: 1 / -1; }
  /* mỗi bản ghi một thẻ gọn: loại · tên · TTL / giá trị / thao tác */
  table.rec, .rec tbody { display: block; width: 100%; border: 0; background: transparent; }
  .rec thead { display: none; }
  .rec tr { display: grid; grid-template-columns: auto 1fr auto; grid-template-areas: "type name ttl" "val val val" "act act act";
    gap: 4px 8px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 8px; padding: 10px 12px; }
  .rec td { border: 0; padding: 0; }
  .rec td.c-type { grid-area: type; }
  .rec td.c-name { grid-area: name; }
  .rec td.c-ttl { grid-area: ttl; font-size: 12px; color: var(--mute); }
  .rec td.c-val { grid-area: val; max-width: none; font-size: 13px; color: var(--ink2); }
  .rec td.act { grid-area: act; text-align: left; white-space: normal; }
  .rec.admin tr { grid-template-columns: 1fr auto; grid-template-areas: none; }
  .rec.admin td { grid-column: 1 / -1; }
  details.edit[open] { width: 100%; }
  details.edit[open] > form { min-width: 0; }
}
