:root {
  --ink: #111812;
  --paper: #f1efe5;
  --paper-deep: #dedbc9;
  --acid: #c9ff38;
  --orange: #ff5c35;
  --blue: #1f43ff;
  --line: rgba(17, 24, 18, 0.25);
  --mono: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
  --display: "Iowan Old Style", "Noto Serif TC", "Songti TC", serif;
  --sans: "Avenir Next Condensed", "Noto Sans TC", sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--ink); }
body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(90deg, transparent 49.85%, rgba(17,24,18,.07) 50%, transparent 50.15%),
    var(--paper);
  font-family: var(--sans);
  min-height: 100vh;
}
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }

.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 20;
  opacity: .18;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.92' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.25'/%3E%3C/svg%3E");
  mix-blend-mode: multiply;
}

.topbar {
  min-height: 68px;
  padding: 12px clamp(18px, 4vw, 64px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  color: var(--paper);
  background: var(--ink);
  border-bottom: 1px solid rgba(255,255,255,.15);
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: .06em;
  position: sticky;
  top: 0;
  z-index: 10;
}
.wordmark { display: flex; align-items: center; gap: 12px; text-decoration: none; }
.mark { color: var(--ink); background: var(--acid); padding: 8px 7px; font-weight: 800; }
.topbar-meta { display: flex; align-items: center; gap: 22px; }
.topbar-meta form { margin: 0; }
.text-button { border: 0; color: inherit; background: transparent; padding: 0; cursor: pointer; text-decoration: underline; }

main { width: min(1600px, 100%); margin: 0 auto; }
.hero {
  min-height: 360px;
  padding: clamp(52px, 8vw, 120px) clamp(20px, 6vw, 94px) 56px;
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(260px, .5fr);
  align-items: end;
  gap: 60px;
  border-bottom: 1px solid var(--ink);
  overflow: hidden;
}
.eyebrow, .section-number, .label, .metric-label, .progress-copy, .filters label > span {
  font: 700 11px/1.3 var(--mono);
  letter-spacing: .13em;
  text-transform: uppercase;
}
.eyebrow { margin: 0 0 16px; }
h1 {
  font: 500 clamp(54px, 9vw, 134px)/.8 var(--display);
  letter-spacing: -.055em;
  margin: 0;
}
h1 em { color: var(--blue); font-weight: 400; }
.hero-note { border-top: 8px solid var(--ink); padding-top: 18px; }
.hero-note .index { font: 700 58px/1 var(--mono); color: var(--orange); }
.hero-note p { font-size: 17px; line-height: 1.65; margin: 18px 0 0; }

.command-panel {
  display: grid;
  grid-template-columns: minmax(260px, .7fr) 1.3fr;
  background: var(--ink);
  color: var(--paper);
  border-bottom: 1px solid var(--ink);
}
.state-block { padding: 24px clamp(20px, 4vw, 56px); border-right: 1px solid rgba(255,255,255,.18); }
.state-line { display: flex; align-items: center; gap: 10px; margin: 8px 0; font-size: 24px; }
.state-block p { margin: 0; color: rgba(241,239,229,.65); font: 12px/1.5 var(--mono); }
.pulse { width: 11px; height: 11px; border-radius: 50%; background: var(--orange); box-shadow: 0 0 0 5px rgba(255,92,53,.15); }
.pulse.online { background: var(--acid); box-shadow: 0 0 0 5px rgba(201,255,56,.15); animation: pulse 2s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 10px rgba(201,255,56,0); } }
.command-actions { padding: 18px clamp(20px, 3vw, 42px); display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.action {
  appearance: none;
  min-height: 46px;
  padding: 12px 18px;
  border: 1px solid currentColor;
  color: inherit;
  background: transparent;
  font: 700 12px/1 var(--mono);
  letter-spacing: .04em;
  text-decoration: none;
  cursor: pointer;
  transition: transform .18s ease, background .18s ease, color .18s ease;
}
.action:hover:not(:disabled) { transform: translate(-2px, -2px); box-shadow: 3px 3px 0 var(--orange); }
.action.primary { background: var(--acid); border-color: var(--acid); color: var(--ink); }
.action.export { margin-left: auto; }
.action:disabled { opacity: .35; cursor: not-allowed; }
.wide { width: 100%; }

.metrics { display: grid; grid-template-columns: repeat(4, 1fr); border-bottom: 1px solid var(--ink); }
.metric { min-height: 190px; padding: 24px clamp(18px, 3vw, 42px); border-right: 1px solid var(--ink); display: flex; flex-direction: column; }
.metric:last-child { border-right: 0; }
.metric strong { margin-top: auto; font: 600 clamp(42px, 5vw, 76px)/.9 var(--display); letter-spacing: -.05em; }
.metric small { margin-top: 12px; font: 12px/1.4 var(--mono); }
.metric-found { background: var(--acid); }
.metric-eta { background: var(--blue); color: white; }

.progress-section { padding: 22px clamp(20px, 4vw, 64px) 28px; border-bottom: 1px solid var(--ink); }
.progress-copy { display: flex; justify-content: space-between; margin-bottom: 10px; }
.progress-track { height: 12px; border: 1px solid var(--ink); padding: 2px; }
.progress-track > div { width: 0; height: 100%; background: var(--orange); transition: width .6s cubic-bezier(.22,1,.36,1); }

.workspace-grid { display: grid; grid-template-columns: minmax(0, 1fr) 360px; }
.ledger-panel { min-width: 0; border-right: 1px solid var(--ink); }
.section-heading { padding: 42px clamp(20px, 4vw, 56px) 26px; display: flex; justify-content: space-between; align-items: end; gap: 28px; }
h2 { font: 500 clamp(30px, 4vw, 48px)/1 var(--display); letter-spacing: -.035em; margin: 8px 0 0; }
.filters { display: flex; gap: 12px; align-items: end; }
.filters label { display: grid; gap: 7px; }
.filters input, .filters select {
  min-height: 42px;
  border: 1px solid var(--ink);
  border-radius: 0;
  background: transparent;
  padding: 9px 12px;
  color: var(--ink);
}
.filters input { width: min(300px, 36vw); }
.table-wrap { overflow-x: auto; border-top: 1px solid var(--ink); border-bottom: 1px solid var(--ink); }
table { width: 100%; border-collapse: collapse; min-width: 880px; }
th { background: var(--paper-deep); font: 700 10px/1 var(--mono); letter-spacing: .1em; text-align: left; padding: 13px 16px; border-right: 1px solid var(--line); }
td { padding: 16px; border-top: 1px solid var(--line); border-right: 1px solid var(--line); vertical-align: top; font-size: 14px; }
th:last-child, td:last-child { border-right: 0; }
tbody tr:hover { background: rgba(201,255,56,.22); }
td strong, td span, td a { display: block; }
td small { display: block; margin-top: 5px; color: rgba(17,24,18,.55); font: 11px/1.4 var(--mono); }
td a { text-underline-offset: 3px; word-break: break-all; }
.muted { color: rgba(17,24,18,.45); }
.evidence-note { max-width: 280px; max-height: 3.8em; overflow: hidden; }
.empty { padding: 60px 20px; text-align: center; font-family: var(--mono); }
.status { display: inline-block; width: fit-content; padding: 7px 9px; background: var(--paper-deep); font: 700 10px/1 var(--mono); white-space: nowrap; }
.status-found { background: var(--acid); }
.status-processing { background: var(--blue); color: white; }
.status-blocked, .status-error { background: var(--orange); color: var(--ink); }
.pagination { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; font: 11px/1 var(--mono); }
.pagination button { border: 0; background: transparent; cursor: pointer; padding: 8px; }
.pagination button:disabled { opacity: .3; }

.side-panel { background: var(--paper-deep); }
.side-panel section { padding: 42px 28px; border-bottom: 1px solid var(--ink); }
.side-panel h2 { font-size: 34px; }
.side-panel p { line-height: 1.65; font-size: 14px; }
code { font-family: var(--mono); font-size: .85em; }
.file-drop { display: grid; gap: 8px; border: 1px dashed var(--ink); padding: 20px; margin: 24px 0 12px; cursor: pointer; }
.file-drop input { position: absolute; opacity: 0; pointer-events: none; }
.file-drop strong { font: 700 13px var(--mono); }
.file-drop span { color: rgba(17,24,18,.55); font-size: 12px; word-break: break-all; }
.activity-card ol { list-style: none; padding: 0; margin: 26px 0 0; }
.activity-card li { display: grid; grid-template-columns: 98px 1fr; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); font-size: 12px; line-height: 1.45; }
.activity-card time { font: 9px/1.4 var(--mono); color: rgba(17,24,18,.55); }
.activity-card li[data-level="error"], .activity-card li[data-level="warning"] { color: #b82c11; }

.toast { position: fixed; right: 20px; bottom: 20px; max-width: 460px; padding: 16px 20px; background: var(--ink); color: var(--paper); font: 12px/1.5 var(--mono); transform: translateY(120px); opacity: 0; z-index: 30; transition: .25s ease; }
.toast.visible { transform: translateY(0); opacity: 1; }
.toast[data-tone="error"] { background: var(--orange); color: var(--ink); }
.toast[data-tone="success"] { background: var(--acid); color: var(--ink); }

.login-body { background: var(--ink); color: var(--paper); }
.login-shell { min-height: 100vh; display: grid; grid-template-columns: 1.15fr .85fr; }
.login-poster { padding: clamp(40px, 8vw, 120px); display: flex; flex-direction: column; justify-content: center; position: relative; overflow: hidden; border-right: 1px solid rgba(255,255,255,.2); }
.login-poster::after { content: "@"; position: absolute; right: -6vw; bottom: -20vw; color: var(--acid); opacity: .95; font: 500 50vw/.7 var(--display); z-index: -1; }
.login-poster h1 { font-size: clamp(58px, 9vw, 130px); }
.login-poster h1 em { color: var(--acid); }
.login-poster > p:last-child { max-width: 480px; font-size: 17px; line-height: 1.7; }
.poster-index { position: absolute; top: 30px; left: 30px; font: 11px var(--mono); }
.login-form-wrap { display: grid; place-items: center; padding: 30px; background: var(--paper); color: var(--ink); }
.login-form { width: min(440px, 100%); }
.login-form h2 { margin-bottom: 48px; }
.login-form label { display: grid; gap: 9px; margin-bottom: 18px; font: 700 11px var(--mono); letter-spacing: .08em; }
.login-form input { width: 100%; min-height: 54px; border: 1px solid var(--ink); border-radius: 0; padding: 12px; background: transparent; }
.form-error { color: #b82c11; font: 12px var(--mono); }

@media (max-width: 1100px) {
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .metric:nth-child(2) { border-right: 0; }
  .metric:nth-child(-n+2) { border-bottom: 1px solid var(--ink); }
  .workspace-grid { grid-template-columns: 1fr; }
  .ledger-panel { border-right: 0; }
  .side-panel { display: grid; grid-template-columns: 1fr 1fr; border-top: 1px solid var(--ink); }
  .side-panel section { border-right: 1px solid var(--ink); }
}

@media (max-width: 760px) {
  .topbar-meta span:not(:last-of-type) { display: none; }
  .hero { grid-template-columns: 1fr; min-height: auto; gap: 38px; }
  .hero h1 { font-size: clamp(54px, 17vw, 90px); }
  .command-panel { grid-template-columns: 1fr; }
  .state-block { border-right: 0; border-bottom: 1px solid rgba(255,255,255,.18); }
  .command-actions { align-items: stretch; }
  .action { flex: 1 1 46%; text-align: center; }
  .action.export { margin-left: 0; }
  .metrics { grid-template-columns: 1fr 1fr; }
  .metric { min-height: 150px; }
  .metric strong { font-size: 42px; }
  .section-heading { align-items: stretch; flex-direction: column; }
  .filters { width: 100%; }
  .filters label { flex: 1; }
  .filters input { width: 100%; }
  .side-panel { grid-template-columns: 1fr; }
  .side-panel section { border-right: 0; }
  .login-shell { grid-template-columns: 1fr; }
  .login-poster { min-height: 54vh; border-right: 0; border-bottom: 1px solid rgba(255,255,255,.2); }
  .login-form-wrap { min-height: 46vh; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
