/* Valley 336 dataroom. White and slate surfaces, restrained blue/teal accents.
   Chinese-first typography: a system Chinese stack with generous line height, and tabular
   figures for the hashes, byte counts and dates that fill the tables. */

:root {
  --slate-900: #0f172a;
  --slate-700: #334155;
  --slate-600: #475569;
  --slate-500: #64748b;
  --slate-400: #94a3b8;
  --slate-300: #cbd5e1;
  --slate-200: #e2e8f0;
  --slate-100: #f1f5f9;
  --slate-50:  #f8fafc;
  --blue:      #1d4ed8;
  --blue-soft: #eff6ff;
  --teal:      #0f766e;
  --teal-soft: #f0fdfa;
  --amber:     #b45309;
  --amber-soft:#fffbeb;
  --red:       #b91c1c;
  --red-soft:  #fef2f2;
  --radius: 6px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 1px 3px rgba(15, 23, 42, .04);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--slate-100);
  color: var(--slate-900);
  font-family: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", "Noto Sans CJK SC",
               "Source Han Sans SC", "Segoe UI", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.75;
  letter-spacing: .01em;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { line-height: 1.4; margin: 0 0 .6rem; font-weight: 600; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .8rem; }

/* --- top bar ------------------------------------------------------------------------------ */

.topbar {
  background: #fff;
  border-bottom: 1px solid var(--slate-200);
  position: sticky; top: 0; z-index: 20;
}
.topbar-inner {
  max-width: 1400px; margin: 0 auto; padding: .5rem 1.25rem;
  display: flex; align-items: center; gap: 1.25rem; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: .5rem; color: var(--slate-900); }
.brand:hover { text-decoration: none; }
.brand-mark {
  background: var(--slate-900); color: #fff; font-weight: 700; font-size: .75rem;
  padding: .15rem .4rem; border-radius: 4px; letter-spacing: .04em;
}
.brand-name { font-weight: 600; font-size: .95rem; }

.mainnav { display: flex; gap: .15rem; flex-wrap: wrap; flex: 1 1 auto; }
.mainnav a {
  color: var(--slate-600); padding: .3rem .6rem; border-radius: var(--radius);
  font-size: .9rem; white-space: nowrap;
}
.mainnav a:hover { background: var(--slate-100); text-decoration: none; }
.mainnav a.is-active { background: var(--blue-soft); color: var(--blue); font-weight: 600; }

.viewer { display: flex; align-items: center; gap: .6rem; font-size: .85rem; color: var(--slate-500); }
.viewer-name { color: var(--slate-900); font-weight: 600; }
.logout-form { margin: 0; }
.linkbutton {
  background: none; border: none; color: var(--blue); cursor: pointer;
  font: inherit; padding: 0;
}
.linkbutton:hover { text-decoration: underline; }

/* --- layout -------------------------------------------------------------------------------- */

.page { max-width: 1400px; margin: 0 auto; padding: 1.5rem 1.25rem 3rem; }
.pagehead { margin-bottom: 1.25rem; }
.pagehead .sub { color: var(--slate-500); font-size: .9rem; margin: 0; }

.card {
  background: #fff; border: 1px solid var(--slate-200); border-radius: var(--radius);
  padding: 1rem 1.15rem; box-shadow: var(--shadow); margin-bottom: 1.15rem;
}
.card > h2 { border-bottom: 1px solid var(--slate-200); padding-bottom: .5rem; margin-bottom: .8rem; }
.card-note { color: var(--slate-500); font-size: .85rem; }

.grid { display: grid; gap: 1.15rem; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }

.stat { background: #fff; border: 1px solid var(--slate-200); border-radius: var(--radius); padding: .85rem 1rem; }
.stat .value { font-size: 1.6rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.stat .label { color: var(--slate-500); font-size: .85rem; }

/* --- tables -------------------------------------------------------------------------------- */

.tablewrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.data {
  width: 100%; border-collapse: collapse; font-size: .875rem;
  font-variant-numeric: tabular-nums;
}
table.data th, table.data td {
  text-align: left; padding: .5rem .6rem; border-bottom: 1px solid var(--slate-200);
  vertical-align: top;
}
table.data thead th {
  background: var(--slate-50); color: var(--slate-600); font-weight: 600;
  border-bottom: 1px solid var(--slate-300); position: sticky; top: 0; white-space: nowrap;
}
table.data tbody tr:hover { background: var(--slate-50); }
table.data td.num { text-align: right; white-space: nowrap; }
table.data td.mono, .mono {
  font-family: ui-monospace, "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: .8rem;
}
.muted { color: var(--slate-500); }
.nowrap { white-space: nowrap; }

/* --- badges -------------------------------------------------------------------------------- */

.badge {
  display: inline-block; padding: .05rem .4rem; border-radius: 4px; font-size: .75rem;
  border: 1px solid transparent; white-space: nowrap; line-height: 1.6;
}
.badge-fact      { background: var(--teal-soft); color: var(--teal); border-color: #99f6e4; }
.badge-study     { background: var(--blue-soft); color: var(--blue); border-color: #bfdbfe; }
.badge-hold      { background: var(--amber-soft); color: var(--amber); border-color: #fde68a; }
.badge-reference { background: var(--slate-100); color: var(--slate-600); border-color: var(--slate-300); }
.badge-internal  { background: var(--slate-100); color: var(--slate-600); border-color: var(--slate-300); }
.badge-published { background: var(--teal-soft); color: var(--teal); border-color: #99f6e4; }
.badge-neutral   { background: var(--slate-100); color: var(--slate-600); border-color: var(--slate-200); }
.badge-warn      { background: var(--red-soft); color: var(--red); border-color: #fecaca; }

/* --- forms --------------------------------------------------------------------------------- */

.filters { display: flex; flex-wrap: wrap; gap: .6rem; align-items: flex-end; }
.field { display: flex; flex-direction: column; gap: .2rem; }
.field label { font-size: .78rem; color: var(--slate-500); }
input[type=text], input[type=search], input[type=password], input[type=date], select {
  font: inherit; font-size: .875rem; padding: .35rem .5rem; border: 1px solid var(--slate-300);
  border-radius: var(--radius); background: #fff; color: var(--slate-900); min-width: 9rem;
}
input:focus, select:focus { outline: 2px solid #bfdbfe; outline-offset: 1px; border-color: var(--blue); }

.btn {
  display: inline-block; font: inherit; font-size: .875rem; padding: .35rem .8rem;
  border-radius: var(--radius); border: 1px solid var(--slate-300); background: #fff;
  color: var(--slate-700); cursor: pointer; text-decoration: none;
}
.btn:hover { background: var(--slate-50); text-decoration: none; }
.btn-primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn-primary:hover { background: #1e40af; }
.btn-disabled { background: var(--slate-100); color: var(--slate-400); cursor: not-allowed; border-style: dashed; }

/* --- messages and notes --------------------------------------------------------------------- */

.messages { margin-bottom: 1rem; }
.msg { padding: .5rem .8rem; border-radius: var(--radius); margin-bottom: .4rem; font-size: .9rem; }
.msg-error { background: var(--red-soft); color: var(--red); border: 1px solid #fecaca; }
.msg-success { background: var(--teal-soft); color: var(--teal); border: 1px solid #99f6e4; }
.msg-info, .msg-warning { background: var(--amber-soft); color: var(--amber); border: 1px solid #fde68a; }

.note {
  background: var(--slate-50); border-left: 3px solid var(--slate-300);
  padding: .55rem .8rem; font-size: .85rem; color: var(--slate-600); border-radius: 0 4px 4px 0;
  margin-bottom: .8rem;
}
.note-teal { border-left-color: var(--teal); background: var(--teal-soft); color: #115e59; }
.note-amber { border-left-color: var(--amber); background: var(--amber-soft); color: #92400e; }

/* --- states panel --------------------------------------------------------------------------- */

.states { display: grid; gap: .7rem; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.state-card {
  border: 1px solid var(--slate-200); border-radius: var(--radius); padding: .7rem .8rem;
  background: var(--slate-50);
}
.state-card h3 { font-size: .9rem; margin-bottom: .3rem; color: var(--slate-700); }
.state-card p { font-size: .82rem; color: var(--slate-600); margin: 0; }

/* --- login ---------------------------------------------------------------------------------- */

body.login { background: var(--slate-100); display: flex; min-height: 100vh; align-items: center; }
.loginbox {
  max-width: 400px; margin: 0 auto; background: #fff; border: 1px solid var(--slate-200);
  border-radius: 8px; padding: 1.75rem; box-shadow: var(--shadow); width: 100%;
}
.loginbox h1 { font-size: 1.15rem; }
.loginbox .field { margin-bottom: .8rem; }
.loginbox input { width: 100%; }
.loginbox .btn { width: 100%; text-align: center; padding: .45rem; }
.loginbox .foot { font-size: .78rem; color: var(--slate-500); margin-top: 1rem; }

/* --- preview -------------------------------------------------------------------------------- */

.previewframe {
  width: 100%; height: 76vh; min-height: 420px; border: 1px solid var(--slate-300);
  border-radius: var(--radius); background: var(--slate-50);
}
.previewimage {
  max-width: 100%; height: auto; border: 1px solid var(--slate-300); border-radius: var(--radius);
  background: #fff;
}
pre.textpreview {
  background: var(--slate-50); border: 1px solid var(--slate-200); border-radius: var(--radius);
  padding: .8rem; overflow: auto; max-height: 70vh; font-size: .82rem; line-height: 1.6;
  font-family: ui-monospace, Consolas, monospace; white-space: pre-wrap; word-break: break-word;
}

/* Rendered internal Markdown guides. Constrained line length keeps Chinese body text readable;
   tables inherit the data-table look so a deliverable list is scannable. */
.prose { max-width: 62rem; }
.prose h1 { font-size: 1.35rem; margin-top: 1.4rem; }
.prose h2 { font-size: 1.1rem; margin-top: 1.3rem; padding-bottom: .3rem; border-bottom: 1px solid var(--slate-200); }
.prose h3 { font-size: .98rem; margin-top: 1.1rem; }
.prose p, .prose li { line-height: 1.85; }
.prose ul, .prose ol { padding-left: 1.4rem; }
.prose li { margin-bottom: .2rem; }
.prose code {
  font-family: ui-monospace, Consolas, monospace; font-size: .85em;
  background: var(--slate-100); padding: .05rem .3rem; border-radius: 3px;
}
.prose pre {
  background: var(--slate-50); border: 1px solid var(--slate-200); border-radius: var(--radius);
  padding: .7rem; overflow-x: auto; font-size: .82rem;
}
.prose pre code { background: none; padding: 0; }
.prose blockquote {
  margin: .8rem 0; padding: .4rem .9rem; border-left: 3px solid var(--slate-300);
  background: var(--slate-50); color: var(--slate-600);
}
.prose table {
  width: 100%; border-collapse: collapse; font-size: .875rem; margin: .8rem 0;
  display: block; overflow-x: auto;
}
.prose th, .prose td {
  border: 1px solid var(--slate-200); padding: .4rem .55rem; text-align: left; vertical-align: top;
}
.prose th { background: var(--slate-50); font-weight: 600; }
.prose hr { border: none; border-top: 1px solid var(--slate-200); margin: 1.2rem 0; }
.prose img { max-width: 100%; height: auto; }

.gallery { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.tile { background: #fff; border: 1px solid var(--slate-200); border-radius: var(--radius); overflow: hidden; }
.tile img { width: 100%; height: 180px; object-fit: cover; display: block; background: var(--slate-100); }
.tile .tilebody { padding: .6rem .7rem; }
.tile .tilebody h3 { font-size: .9rem; margin-bottom: .2rem; }
.tile .tilebody p { font-size: .78rem; color: var(--slate-500); margin: 0; }

/* --- pagination ----------------------------------------------------------------------------- */

.pagination { display: flex; gap: .3rem; align-items: center; margin-top: 1rem; font-size: .85rem; flex-wrap: wrap; }
.pagination a, .pagination span {
  padding: .25rem .55rem; border: 1px solid var(--slate-300); border-radius: 4px; background: #fff;
}
.pagination .current { background: var(--blue); border-color: var(--blue); color: #fff; }

.dwell {
  position: fixed; right: 1rem; bottom: 1rem; background: #fff; border: 1px solid var(--slate-300);
  border-radius: var(--radius); padding: .4rem .7rem; font-size: .78rem; color: var(--slate-600);
  box-shadow: var(--shadow); font-variant-numeric: tabular-nums;
}

.sitefoot {
  border-top: 1px solid var(--slate-200); background: #fff; color: var(--slate-500);
  font-size: .8rem; padding: .9rem 1.25rem; text-align: center;
}
.sitefoot p { margin: 0; max-width: 1400px; margin: 0 auto; }

.breadcrumb { font-size: .82rem; color: var(--slate-500); margin-bottom: .5rem; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: .25rem .9rem; font-size: .875rem; }
.kv dt { color: var(--slate-500); }
.kv dd { margin: 0; }

.actionbar { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin: .6rem 0; }

/* --- responsive ------------------------------------------------------------------------------ */

@media (max-width: 900px) {
  .topbar-inner { padding: .5rem .75rem; gap: .6rem; }
  .brand-name { display: none; }
  .mainnav { order: 3; width: 100%; overflow-x: auto; padding-bottom: .2rem; }
  .mainnav a { font-size: .85rem; padding: .25rem .5rem; }
  .viewer-org { display: none; }
  .page { padding: 1rem .75rem 2.5rem; }
  .card { padding: .85rem; }
  table.data { font-size: .8rem; }
  table.data th, table.data td { padding: .4rem .45rem; }
  .previewframe { height: 60vh; }
  .filters .field { flex: 1 1 45%; }
  input[type=text], input[type=search], select { min-width: 0; width: 100%; }
}

@media (max-width: 560px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .stat .value { font-size: 1.3rem; }
  .gallery { grid-template-columns: 1fr; }
}
