/* 东盟法律法规数据库 — public portal + internal workbench.
   Navy for brand/navigation, teal for actions/confirmed states, warm gold for notices, red only for errors. */
:root {
  --navy: #102d3d; --navy-2: #0b2634; --teal: #146c65; --teal-dark: #0d5852; --gold: #b7863a; --gold-bg: #fff6e3;
  --ink: #182b37; --muted: #5b6b74; --line: #d8e2df; --paper: #f5f7f6; --white: #fff;
  --ok-bg: #e5f3ef; --ok-ink: #155e52; --info-bg: #e8f0f8; --info-ink: #1f4b75; --warn-bg: #fdf1dc; --warn-ink: #7a4b00;
  --muted-bg: #eef1f2; --err-bg: #fbe9e7; --err-ink: #9c2b1f; --focus: #f2b134;
  --radius: 8px; --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 16px/1.7 var(--font); }
a { color: var(--teal); text-underline-offset: 2px; }
a:hover { color: var(--teal-dark); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
h1, h2, h3 { color: var(--navy); line-height: 1.35; }
h1 { font-size: 1.75rem; margin: .2em 0 .5em; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.08rem; }
.container { max-width: 1180px; margin: 0 auto; padding: 0 16px; }
.page { padding-top: 24px; padding-bottom: 48px; }
.narrow { max-width: 860px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: 8px; top: -60px; background: var(--white); color: var(--navy); padding: 8px 14px; border-radius: 6px; z-index: 100; }
.skip-link:focus { top: 8px; }
main:focus { outline: none; }
.small { font-size: .88rem; color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .85em; word-break: break-all; }

/* header / footer */
.topbar { background: var(--navy-2); color: #dfe9e7; font-size: .78rem; }
.topbar .container { display: flex; justify-content: space-between; gap: 12px; padding-top: 6px; padding-bottom: 6px; flex-wrap: wrap; }
.site-header { background: var(--white); border-bottom: 1px solid var(--line); }
.header-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 72px; flex-wrap: wrap; padding-top: 8px; padding-bottom: 8px; }
.brand { display: flex; gap: 12px; align-items: center; color: var(--navy); text-decoration: none; }
.brand strong { display: block; font-size: 1.05rem; letter-spacing: .03em; }
.brand small { display: block; font-size: .64rem; color: var(--muted); letter-spacing: .12em; }
.seal { width: 40px; height: 40px; border: 1.5px solid var(--gold); border-radius: 50%; display: grid; place-items: center; color: var(--teal); font-size: 1.15rem; flex: none; }
.main-nav { display: flex; gap: 4px 18px; flex-wrap: wrap; }
.main-nav a { color: var(--ink); text-decoration: none; padding: 6px 2px; border-bottom: 2px solid transparent; }
.main-nav a[aria-current="page"], .main-nav a:hover { color: var(--teal); border-bottom-color: var(--teal); }
.site-footer { background: var(--navy-2); color: #c9d4d5; font-size: .82rem; margin-top: 32px; }
.site-footer a { color: #e7efee; }
.footer-row { display: flex; justify-content: space-between; gap: 12px; padding-top: 22px; padding-bottom: 22px; flex-wrap: wrap; }

/* hero / home */
.hero { background: var(--navy); color: var(--white); padding: 52px 0 46px; }
.hero h1 { color: var(--white); font-size: 2.1rem; max-width: 760px; }
.hero .lead { color: #cbd8d9; max-width: 680px; }
.eyebrow { color: #e3c38a; letter-spacing: .14em; font-size: .78rem; text-transform: uppercase; margin: 0; }
.hero-search { display: flex; gap: 6px; background: var(--white); padding: 6px; border-radius: var(--radius); max-width: 760px; }
.hero-search input { flex: 1; min-width: 0; border: 0; font-size: 1rem; padding: 10px 12px; color: var(--ink); }
.hero-note { color: #a9bcbd; font-size: .8rem; margin-top: 12px; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); margin-top: -18px; position: relative; }
.stats div { padding: 16px 20px; border-right: 1px solid var(--line); }
.stats div:last-child { border-right: 0; }
.stats strong { display: block; font-size: 1.5rem; color: var(--navy); }
.stats span { font-size: .82rem; color: var(--muted); }
.section { padding: 28px 0 8px; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.section-head h2 { margin-bottom: 4px; }
.section-head p { margin: 0; color: var(--muted); font-size: .86rem; }
.country-grid { list-style: none; padding: 0; margin: 12px 0 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.country-card { display: flex; gap: 12px; align-items: center; background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; text-decoration: none; color: var(--ink); }
.country-card:hover { border-color: var(--teal); }
.country-card b { display: block; }
.country-card small { color: var(--muted); }
.country-code { font-weight: 700; color: var(--teal); border: 1px solid var(--line); border-radius: 6px; padding: 2px 6px; font-size: .8rem; }
.topic-list { list-style: none; display: flex; flex-wrap: wrap; gap: 8px; padding: 0; margin: 12px 0 0; }
.chip { display: inline-block; padding: 6px 14px; border: 1px solid #bcd4cf; background: var(--white); border-radius: 999px; text-decoration: none; color: var(--teal-dark); }
.chip:hover { background: var(--ok-bg); }
.two-col { display: grid; grid-template-columns: 1.7fr 1fr; gap: 20px; align-items: start; }

/* generic components */
.panel { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 16px; }
.panel > h2:first-child, .panel > h3:first-child { margin-top: 0; }
.plain { padding-left: 1.1em; }
.plain li { margin-bottom: .4em; }
.empty { background: #f9fbfa; border: 1px dashed #c3d1cd; border-radius: var(--radius); padding: 16px 18px; color: var(--muted); }
.notice { background: var(--gold-bg); border-left: 4px solid var(--gold); padding: 10px 14px; border-radius: 4px; color: #5b4521; font-size: .92rem; }
.flash { margin: 16px 0 0; padding: 12px 16px; border-radius: var(--radius); border: 1px solid; }
.flash-ok { background: var(--ok-bg); color: var(--ok-ink); border-color: #b5dacf; }
.flash-error { background: var(--err-bg); color: var(--err-ink); border-color: #efc2bb; }
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .8rem; font-weight: 600; border: 1px solid transparent; }
.badge-ok { background: var(--ok-bg); color: var(--ok-ink); border-color: #b5dacf; }
.badge-info { background: var(--info-bg); color: var(--info-ink); border-color: #bcd0e6; }
.badge-warn { background: var(--warn-bg); color: var(--warn-ink); border-color: #ecd09a; }
.badge-muted { background: var(--muted-bg); color: #46555d; border-color: #d4dbde; }
.badge-err { background: var(--err-bg); color: var(--err-ink); border-color: #efc2bb; }
.tag { display: inline-block; background: #f1f5f4; color: #3c5650; border-radius: 4px; padding: 0 8px; font-size: .78rem; margin: 2px 4px 2px 0; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 16px; border-radius: 6px; border: 1px solid var(--teal); background: var(--white); color: var(--teal); font: inherit; font-size: .92rem; cursor: pointer; text-decoration: none; min-height: 40px; }
.btn:hover { background: var(--ok-bg); color: var(--teal-dark); }
.btn-primary { background: var(--teal); color: var(--white); }
.btn-primary:hover { background: var(--teal-dark); color: var(--white); }
.btn-danger { border-color: var(--err-ink); color: var(--err-ink); }
.btn-danger:hover { background: var(--err-bg); color: var(--err-ink); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.btn-small { min-height: 32px; padding: 4px 10px; font-size: .85rem; }
.link-btn { background: none; border: 0; color: var(--teal); padding: 0; font: inherit; font-size: .85rem; cursor: pointer; text-decoration: underline; }
.breadcrumb { font-size: .88rem; color: var(--muted); }
.table { width: 100%; border-collapse: collapse; background: var(--white); font-size: .92rem; }
.table th, .table td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { color: var(--muted); font-weight: 600; font-size: .82rem; background: #f8faf9; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
.table-wrap .table { min-width: 640px; }

/* forms */
label { display: block; font-size: .86rem; font-weight: 600; color: #34464f; margin-bottom: 4px; }
input[type=text], input[type=search], input[type=date], input[type=password], input[type=number], select, textarea {
  width: 100%; font: inherit; font-size: .95rem; padding: 8px 10px; border: 1px solid #b7c6c2; border-radius: 6px; background: var(--white); color: var(--ink); min-height: 40px; }
textarea { min-height: 120px; line-height: 1.6; }
.field { margin-bottom: 14px; }
.hint { font-size: .82rem; color: var(--muted); margin: 4px 0 0; }
.check { display: flex; gap: 8px; align-items: center; }
.check label { margin: 0; font-weight: 400; }
.check input { width: 18px; height: 18px; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; margin: 0 0 14px; }
legend { font-weight: 600; color: var(--navy); padding: 0 6px; }

/* search */
.search-form { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.search-main { display: grid; grid-template-columns: 1fr auto; gap: 6px 10px; align-items: end; }
.search-main label { grid-column: 1 / -1; }
.filters { margin-top: 12px; }
.filters summary { cursor: pointer; color: var(--teal); font-weight: 600; min-height: 32px; }
.filter-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-top: 12px; }
.filter-actions { margin-top: 12px; display: flex; gap: 16px; align-items: center; }
.result-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 18px 0 8px; flex-wrap: wrap; }
.sort-form { display: flex; gap: 8px; align-items: center; }
.sort-form label { margin: 0; }
.sort-form select { width: auto; }
.result-card { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 18px; margin-bottom: 10px; }
.result-title { margin: 0 0 2px; font-size: 1.08rem; }
.result-title a { text-decoration: none; }
.original-title { margin: 0; color: var(--muted); font-size: .92rem; }
.meta { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: .84rem; color: var(--muted); margin: 6px 0; }
.badges { margin: 6px 0; }
.snippet { background: #f8faf9; border-left: 3px solid #b5dacf; padding: 6px 10px; font-size: .9rem; margin: 6px 0; }
.pagination { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 16px; }
.pagination a { min-width: 40px; min-height: 40px; display: grid; place-items: center; border: 1px solid var(--line); background: var(--white); border-radius: 6px; text-decoration: none; }
.pagination a.current { background: var(--teal); color: var(--white); border-color: var(--teal); }

/* law detail */
.law-head { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px; }
.law-head h1 { margin-top: 0; }
.facts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px 18px; margin: 14px 0; }
.facts dt { font-size: .78rem; color: var(--muted); }
.facts dd { margin: 0; font-weight: 600; }
.tabs { display: flex; gap: 2px; border-bottom: 2px solid var(--line); margin: 18px 0 16px; overflow-x: auto; }
.tabs a { padding: 10px 14px; text-decoration: none; color: var(--ink); border-bottom: 3px solid transparent; margin-bottom: -2px; white-space: nowrap; }
.tabs a[aria-current="page"] { color: var(--teal); border-bottom-color: var(--teal); font-weight: 600; }
.law-body.with-toc { display: grid; grid-template-columns: 240px 1fr; gap: 20px; align-items: start; }
.toc { position: sticky; top: 12px; background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; max-height: calc(100vh - 24px); overflow: auto; font-size: .88rem; }
.toc-title { font-size: .95rem; margin: 0 0 6px; }
.toc ol { list-style: none; padding: 0; margin: 0; }
.toc li { margin: 4px 0; }
.provision { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 18px; margin-bottom: 10px; scroll-margin-top: 12px; }
.provision h3 { margin: 0 0 8px; }
.provision-text { white-space: pre-wrap; }
.bi-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.col-label { font-size: .78rem; color: var(--muted); margin: 0 0 4px; text-transform: uppercase; letter-spacing: .06em; }
.evidence-card { border: 1px solid var(--line); border-radius: 6px; padding: 10px 14px; margin-bottom: 10px; }
.evidence-card p { margin: 4px 0; }
.citation { background: #f8faf9; padding: 10px 12px; border-radius: 6px; }

/* admin */
body.admin { background: #f1f4f3; }
.admin-header { background: var(--navy); color: var(--white); }
.admin-header .container { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 56px; flex-wrap: wrap; }
.admin-header a { color: var(--white); }
.admin-brand { font-weight: 700; text-decoration: none; }
.who { font-size: .85rem; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.who form { margin: 0; }
.who button { background: none; border: 1px solid #6f8b94; color: var(--white); border-radius: 6px; padding: 4px 10px; cursor: pointer; font: inherit; font-size: .85rem; }
.admin-shell { display: grid; grid-template-columns: 220px 1fr; gap: 20px; align-items: start; padding-top: 20px; padding-bottom: 40px; }
.admin-nav { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px; position: sticky; top: 12px; }
.admin-nav a { display: block; padding: 8px 10px; border-radius: 6px; color: var(--ink); text-decoration: none; }
.admin-nav a[aria-current="page"] { background: var(--ok-bg); color: var(--teal-dark); font-weight: 600; }
.admin-nav a:hover { background: #f1f5f4; }
.cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 18px; }
.count-card { display: block; background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; text-decoration: none; color: var(--ink); }
.count-card strong { display: block; font-size: 1.6rem; color: var(--navy); }
.count-card span { font-size: .85rem; color: var(--muted); }
.count-card.alert { border-color: #efc2bb; background: #fff8f6; }
.count-card:hover { border-color: var(--teal); }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.checklist { list-style: none; padding: 0; }
.checklist li { padding: 8px 0; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: 70px 1fr; gap: 10px; }
.check-ok { color: var(--ok-ink); font-weight: 700; }
.check-fail { color: var(--err-ink); font-weight: 700; }
.diff ins { background: #d6f0e6; text-decoration: none; }
.diff del { background: #fadcd7; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.actions select, .actions input[type=text] { width: auto; flex: 0 1 280px; }
.blocked-reason { font-size: .85rem; color: var(--warn-ink); background: var(--warn-bg); padding: 6px 10px; border-radius: 6px; }
.login-box { max-width: 460px; margin: 60px auto; }
pre.raw { white-space: pre-wrap; word-break: break-word; background: #f8faf9; padding: 10px; border-radius: 6px; font-size: .85rem; max-height: 320px; overflow: auto; }

@media (max-width: 960px) {
  .filter-grid { grid-template-columns: repeat(2, 1fr); }
  .country-grid, .cards { grid-template-columns: repeat(2, 1fr); }
  .two-col, .split, .admin-shell, .law-body.with-toc { grid-template-columns: 1fr; }
  .toc, .admin-nav { position: static; max-height: none; }
  .admin-nav { display: flex; flex-wrap: wrap; gap: 2px; }
  .facts { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 600px) {
  body { font-size: 15px; }
  .hero { padding: 36px 0 34px; }
  .hero h1 { font-size: 1.6rem; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stats div:nth-child(2) { border-right: 0; }
  .stats div:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .filter-grid, .bi-grid { grid-template-columns: 1fr; }
  .country-grid { grid-template-columns: 1fr 1fr; }
  .hero-search { flex-direction: column; }
}
@media print {
  .topbar, .site-header, .site-footer, .tabs, .toc, .link-btn, .btn, .skip-link, .admin-header, .admin-nav { display: none !important; }
  body { background: #fff; }
  .provision, .panel, .law-head { border: 0; padding: 0; }
  .law-body.with-toc { display: block; }
}

/* grid children must be allowed to shrink so wide tables scroll inside .table-wrap */
.admin-main, .law-section, .two-col > *, .split > * { min-width: 0; }

/* public portal additions */
mark { background: #fde9a8; color: inherit; padding: 0 1px; border-radius: 2px; }
.topic-grid { list-style: none; padding: 0; margin: 12px 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.topic-fieldset { margin-top: 12px; }
.topic-fieldset .topic-list { margin-top: 4px; gap: 4px 16px; }
.toc a[aria-current="location"] { font-weight: 700; color: var(--navy); text-decoration: none; border-left: 3px solid var(--teal); padding-left: 6px; margin-left: -9px; }
.notice.historical { margin-bottom: 12px; }
@media (max-width: 960px) { .topic-grid { grid-template-columns: repeat(2, 1fr); } }

/* AI search */
.citations { list-style: none; padding: 0; margin: 0; }
.citation-card h3 { margin-top: 0; }
.cite-no { color: var(--teal); }
.cite-facts { grid-template-columns: repeat(4, 1fr); }
.answer-text { line-height: 1.9; }
.cite-ref { font-size: .82em; vertical-align: super; text-decoration: none; padding: 0 1px; }
:target.citation-card { outline: 3px solid var(--focus); }
@media (max-width: 960px) { .cite-facts { grid-template-columns: repeat(2, 1fr); } }
