:root{
  --bg: #f8fafc;
  --panel: #ffffff;
  --ink: #0f172a;
  --muted: #475569;
  --line: #e2e8f0;
  --accent: #1d4ed8;
  --accent-weak: #dbeafe;
  --danger: #b91c1c;
  --shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
  --radius: 14px;
  --font-sans: "Noto Sans SC", Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, "Apple Color Emoji", "Segoe UI Emoji";
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

html, body{
  height: 100%;
}

*, *::before, *::after{
  box-sizing: border-box;
}

body{
  font-family: var(--font-sans);
  color: var(--ink);
  background: var(--bg);
  text-rendering: geometricPrecision;
  margin: 0;
}

a{
  color: inherit;
  text-decoration: none;
}

a:focus, button:focus{
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

img{
  max-width: 100%;
  height: auto;
}

.container{
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 16px;
}

.topbar{
  background: rgba(248, 250, 252, 0.75);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.topbar-inner{
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: space-between;
  padding: 12px 0;
  position: relative;
}

.brand{
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 220px;
}

.brand-title{
  font-weight: 800;
  letter-spacing: 0.02em;
  line-height: 1.1;
}

.brand-subtitle{
  margin-top: 2px;
  font-size: 12px;
  color: var(--muted);
}

.nav{
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.nav a{
  padding: 8px 10px;
  border-radius: 999px;
  border: 1px solid transparent;
  color: var(--muted);
  font-weight: 600;
  font-size: 14px;
}

.nav a.is-active{
  color: var(--ink);
  border-color: var(--line);
  background: #fff;
}

.nav-actions{
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-toggle{
  display: none;
}

@media (max-width: 920px){
  .topbar-inner{
    flex-wrap: wrap;
  }

  .brand{
    min-width: 0;
    flex: 1 1 auto;
    order: 1;
  }

  .nav-actions{
    order: 2;
  }

  .nav-toggle{
    display: inline-flex;
  }

  .nav{
    display: none;
    position: static;
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    padding: 10px;
    border-radius: 16px;
    border: 1px solid var(--line);
    background: #fff;
    box-shadow: var(--shadow);
    width: 100%;
    margin-top: 10px;
    order: 3;
  }

  .nav.is-open{
    display: flex;
  }

  .nav a{
    width: 100%;
    padding: 10px 12px;
  }

  .btn-icon{
    width: 44px;
    height: 44px;
  }
}

@media (max-width: 420px){
  .container{
    padding: 0 12px;
  }

  .topbar-inner{
    padding: 10px 0;
  }

  .page-title{
    font-size: 24px;
  }

  .page-meta{
    font-size: 13px;
  }

  .card{
    padding: 12px 12px;
  }
}

.btn{
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  min-height: 40px;
  touch-action: manipulation;
}

.btn:hover{
  border-color: #cbd5e1;
}

.btn-primary{
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover{
  filter: brightness(0.95);
}

.btn-ghost{
  border-color: transparent;
  background: transparent;
  color: var(--muted);
}

.btn-ghost:hover{
  background: rgba(148, 163, 184, 0.12);
  color: var(--ink);
}

.btn-icon{
  width: 40px;
  height: 40px;
  justify-content: center;
  padding: 0;
}

.layout{
  padding: 18px 0 48px;
}

.page-title{
  font-size: 28px;
  font-weight: 900;
  letter-spacing: 0.01em;
}

.page-meta{
  margin-top: 6px;
  font-size: 14px;
  color: var(--muted);
}

.grid{
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

@media (min-width: 920px){
  .grid-2{
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .grid-3{
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.card{
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.04);
  padding: 14px 14px;
}

.avoid-break{
  break-inside: avoid;
  page-break-inside: avoid;
}

.card-title{
  font-weight: 800;
  font-size: 16px;
  letter-spacing: 0.01em;
  margin-bottom: 8px;
}

.muted{
  color: var(--muted);
}

.codeblock{
  font-family: var(--font-mono);
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-word;
  background: #0b1220;
  color: #e2e8f0;
  border-radius: 12px;
  padding: 12px;
  border: 1px solid rgba(226, 232, 240, 0.12);
}

.code-inline{
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 1px 8px;
  border-radius: 999px;
  background: rgba(226, 232, 240, 0.5);
  border: 1px solid var(--line);
  color: #0b1220;
}

.table{
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.table-scroll{
  position: relative;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table-scroll::before,
.table-scroll::after{
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: 26px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 160ms ease;
}

.table-scroll::before{
  left: 0;
  background: linear-gradient(to right, var(--panel), rgba(255, 255, 255, 0));
}

.table-scroll::after{
  right: 0;
  background: linear-gradient(to left, var(--panel), rgba(255, 255, 255, 0));
}

.table-scroll .table{
  width: max-content;
  min-width: 100%;
}

@media (max-width: 720px){
  .table-scroll::before,
  .table-scroll::after{
    opacity: 1;
  }
}

.table th, .table td{
  border-bottom: 1px solid var(--line);
  padding: 10px 8px;
  vertical-align: top;
}

.table th{
  text-align: left;
  font-weight: 800;
  color: #0b1220;
  background: rgba(226, 232, 240, 0.25);
}

.badge{
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 12px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
}

.badge-accent{
  border-color: rgba(29, 78, 216, 0.25);
  background: var(--accent-weak);
  color: #1e3a8a;
}

.no-print{
  display: block;
}

.appendix-overlay{
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
  backdrop-filter: blur(2px);
  z-index: 60;
}

.appendix-drawer{
  position: fixed;
  top: 0;
  right: 0;
  height: 100dvh;
  width: min(560px, 92vw);
  background: #fff;
  border-left: 1px solid var(--line);
  box-shadow: var(--shadow);
  z-index: 70;
  transform: translateX(105%);
  transition: transform 180ms ease;
  display: flex;
  flex-direction: column;
}

.appendix-drawer.is-open{
  transform: translateX(0);
}

.appendix-head{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 14px;
  border-bottom: 1px solid var(--line);
}

.appendix-title{
  font-weight: 900;
  letter-spacing: 0.01em;
}

.appendix-controls{
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 8px;
  align-items: center;
}

.appendix-search{
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 14px;
}

.appendix-tabs{
  display: flex;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
}

.tab{
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-weight: 800;
  font-size: 12px;
  color: var(--muted);
  background: #fff;
  cursor: pointer;
}

.tab.is-active{
  color: var(--ink);
  border-color: rgba(29, 78, 216, 0.25);
  background: var(--accent-weak);
}

.appendix-body{
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  padding: 12px 14px 16px;
  overflow: hidden;
  flex: 1 1 auto;
}

@media (min-width: 780px){
  .appendix-body{
    grid-template-columns: 210px 1fr;
  }
}

.appendix-list{
  list-style: none;
  padding: 0;
  margin: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.appendix-list button{
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  padding: 10px 10px;
  cursor: pointer;
  border-bottom: 1px solid var(--line);
}

.appendix-list button:hover{
  background: rgba(148, 163, 184, 0.12);
}

.appendix-list button.is-active{
  background: var(--accent-weak);
}

.appendix-detail{
  overflow: auto;
}

.appendix-kv{
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  margin-bottom: 10px;
}

.appendix-kv div{
  font-size: 12px;
  color: var(--muted);
}

.appendix-actions{
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 8px 0 10px;
}

.lightbox{
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.75);
  z-index: 90;
  padding: 18px;
}

.lightbox.is-open{
  display: flex;
}

.lightbox img{
  max-width: min(1200px, 92vw);
  max-height: 90vh;
  border-radius: 14px;
  background: #fff;
  box-shadow: var(--shadow);
}

.img-grid{
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

@media (min-width: 780px){
  .img-grid{
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.img-grid > img{
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 3;
  object-fit: contain;
  object-position: center;
  padding: 6px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #fff;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.08);
  cursor: zoom-in;
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.img-grid > img:hover{
  transform: translateY(-1px);
  box-shadow: 0 14px 34px rgba(15, 23, 42, 0.12);
  border-color: rgba(203, 213, 225, 0.9);
}

.img-grid .thumb{
  position: relative;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #fff;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.08);
  overflow: hidden;
  cursor: zoom-in;
  aspect-ratio: 4 / 3;
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.img-grid .thumb:hover{
  transform: translateY(-1px);
  box-shadow: 0 14px 34px rgba(15, 23, 42, 0.12);
  border-color: rgba(203, 213, 225, 0.9);
}

.img-grid .thumb.is-portrait{
  aspect-ratio: 3 / 4;
}

.img-grid .thumb.is-wide{
  aspect-ratio: 16 / 9;
}

.thumb-bg{
  position: absolute;
  inset: -22px;
  background-size: cover;
  background-position: center;
  filter: blur(18px);
  transform: scale(1.1);
  opacity: 0.6;
  pointer-events: none;
}

.thumb:not(.thumb--blur) .thumb-bg{
  display: none;
}

.img-grid .thumb img{
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  padding: 8px;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  cursor: zoom-in;
}

.screen-only{
  display: block;
}

.print-only{
  display: none;
}

.chart-wrap{
  position: relative;
  width: 100%;
  height: 260px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  overflow: hidden;
}

.chart-wrap canvas{
  width: 100% !important;
  height: 100% !important;
}

.pending{
  border: 1px dashed #cbd5e1;
  border-radius: 12px;
  padding: 12px;
  color: var(--muted);
  background: rgba(226, 232, 240, 0.25);
  font-weight: 600;
}

details.details{
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  background: rgba(226, 232, 240, 0.18);
}

details.details summary{
  cursor: pointer;
  font-weight: 800;
}

details.details[open] summary{
  margin-bottom: 8px;
}
