:root {
  --navy: #1F4E78;
  --navy-dark: #163a58;
  --accent: #2E75B6;
  --section-bg: #D9E1F2;
  --note-bg: #FFF2A8;
  --note-fg: #7F6000;
  --warn-bg: #FF6B35;
  --warn-fg: #FFFFFF;
  --border: #BFBFBF;
  --bg: #F4F6F9;
  --text: #1c1c1c;
  --muted: #6b7280;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: Arial, "Segoe UI", Helvetica, sans-serif;
  color: var(--text);
  background: var(--bg);
}

.app-shell { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }

.topbar {
  background: var(--navy);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  flex-shrink: 0;
}
.brand-mark { font-size: 20px; font-weight: 700; letter-spacing: 0.5px; }
.brand-accent { color: #8ecbff; }
.brand-sub { margin-left: 12px; font-size: 13px; color: #cfe0f2; font-weight: 400; }
.topbar-meta { font-size: 12px; color: #cfe0f2; display: flex; align-items: center; gap: 8px; }
#version-badge {
  font-weight: 700;
  color: #14202e;
  background: #8ecbff;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11.5px;
  letter-spacing: 0.2px;
}

.body-row { display: flex; flex: 1; min-height: 0; }

.sidebar {
  width: 300px;
  background: var(--navy-dark);
  color: #e7edf5;
  flex-shrink: 0;
  padding: 16px 0;
  overflow-y: auto;
}
.nav-group { margin-bottom: 4px; }
.nav-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  background: none;
  border: none;
  color: #e7edf5;
  text-decoration: none;
  font-size: 14.5px;
  font-weight: 600;
  padding: 12px 18px;
  cursor: pointer;
  text-align: left;
}
.nav-toggle:hover { background: rgba(255,255,255,0.06); }
.nav-toggle-icon { width: 16px; display: inline-block; font-size: 12px; opacity: 0.8; }
.nav-toggle-icon-search {
  width: 13px; height: 13px;
  border: 2px solid #cfe0f2;
  border-radius: 50%;
  position: relative;
  margin-left: 1px;
}
.nav-toggle-icon-search::after {
  content: "";
  position: absolute;
  width: 2px; height: 7px;
  background: #cfe0f2;
  right: -5px; bottom: -5px;
  transform: rotate(-45deg);
  border-radius: 1px;
}
.nav-toggle-icon-history {
  width: 13px; height: 13px;
  border: 2px solid #cfe0f2;
  border-radius: 50%;
  position: relative;
  margin-left: 1px;
}
.nav-toggle-icon-history::after {
  content: "";
  position: absolute;
  width: 1px; height: 5px;
  background: #cfe0f2;
  left: 4px; top: 1px;
  transform-origin: bottom;
  transform: rotate(35deg);
}
.nav-toggle-flat { justify-content: flex-start; }
.nav-toggle-flat.active {
  background: rgba(255,255,255,0.1);
  color: #fff;
}
.nav-toggle-flat.active .nav-toggle-icon-search,
.nav-toggle-flat.active .nav-toggle-icon-history { border-color: #fff; }
.nav-toggle-flat.active .nav-toggle-icon-search::after,
.nav-toggle-flat.active .nav-toggle-icon-history::after { background: #fff; }
.badge-soon {
  margin-left: auto;
  font-size: 10px;
  font-weight: 600;
  background: #8a5a00;
  color: #ffe6b3;
  padding: 2px 6px;
  border-radius: 3px;
  white-space: nowrap;
}
.nav-submenu { list-style: none; margin: 0; padding: 0 0 8px 0; }
.nav-submenu li a {
  display: block;
  padding: 9px 18px 9px 42px;
  color: #c3d3e6;
  text-decoration: none;
  font-size: 13.5px;
  border-left: 3px solid transparent;
}
.nav-submenu li a:hover { background: rgba(255,255,255,0.06); color: #fff; }
.nav-submenu li a.active {
  background: rgba(255,255,255,0.1);
  color: #fff;
  border-left-color: #8ecbff;
  font-weight: 600;
}

.content {
  flex: 1;
  padding: 28px 36px 60px;
  overflow-y: auto;
  min-width: 0;
}
.loading { color: var(--muted); font-size: 14px; }

.page-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--navy);
  margin: 0 0 4px;
}
.page-subtitle { color: var(--muted); font-size: 13px; margin: 0 0 20px; }

.download-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 22px;
}
.download-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  padding: 8px 14px;
  border-radius: 5px;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 0;
}
.download-link:hover { background: var(--navy); }
.download-link-client {
  background: #b7791f;
}
.download-link-client:hover { background: #8a5a00; }

.sheet-block { margin-bottom: 34px; }
.sheet-heading {
  font-size: 16px;
  font-weight: 700;
  color: var(--navy);
  border-bottom: 2px solid var(--section-bg);
  padding-bottom: 6px;
  margin: 0 0 10px;
}
.sheet-meta { font-size: 12px; color: var(--muted); font-style: italic; margin: 2px 0; }

.note-box, .warn-box {
  border-radius: 5px;
  padding: 12px 14px;
  font-size: 13.5px;
  margin: 10px 0;
  line-height: 1.5;
}
.note-box { background: var(--note-bg); color: var(--note-fg); font-style: italic; }
.warn-box { background: var(--warn-bg); color: var(--warn-fg); font-weight: 600; }

.screenshot-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin: 14px 0;
}
.screenshot-frame {
  margin: 0;
  text-align: center;
  display: flex;
  flex-direction: column;
  width: 220px;
  flex: 0 0 220px;
}
.screenshot-frame img {
  width: 220px;
  height: 150px;
  border: 1px solid var(--border);
  border-radius: 4px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  object-fit: cover;
  object-position: top center;
  cursor: zoom-in;
  transition: box-shadow 0.15s, transform 0.15s;
  display: block;
}
.screenshot-frame img:hover {
  box-shadow: 0 3px 10px rgba(0,0,0,0.22);
  transform: translateY(-1px);
}
.screenshot-frame .screenshot-caption {
  font-size: 11px;
  color: var(--muted);
  margin-top: 6px;
  line-height: 1.35;
}

/* --- Screenshot lightbox --- */
.lightbox-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 14, 20, 0.82);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  z-index: 1000;
}
.lightbox-overlay.hidden { display: none; }
.lightbox-overlay img {
  max-width: 92vw;
  max-height: 88vh;
  border-radius: 5px;
  box-shadow: 0 6px 28px rgba(0,0,0,0.5);
  cursor: default;
}
.lightbox-close {
  position: absolute;
  top: 16px;
  right: 22px;
  background: none;
  border: none;
  color: #fff;
  font-size: 30px;
  line-height: 1;
  cursor: pointer;
  padding: 6px 10px;
  opacity: 0.85;
}
.lightbox-close:hover { opacity: 1; }
.lightbox-hint {
  position: absolute;
  bottom: 18px;
  left: 0;
  right: 0;
  text-align: center;
  color: #cfd6de;
  font-size: 12px;
}

table.tr-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin-top: 6px;
}
table.tr-table th {
  background: var(--navy);
  color: #fff;
  text-align: left;
  padding: 8px 10px;
  border: 1px solid var(--border);
  font-size: 12.5px;
}
table.tr-table td {
  border: 1px solid var(--border);
  padding: 7px 10px;
  vertical-align: top;
  white-space: pre-wrap;
}
table.tr-table td.ref-col { width: 70px; white-space: normal; color: var(--muted); font-size: 11.5px; }
table.tr-table tr.section-row td { background: var(--section-bg); font-weight: 700; }
table.tr-table tr:nth-child(even):not(.section-row) td { background: #fafbfd; }

.under-construction {
  border: 2px dashed var(--border);
  border-radius: 8px;
  padding: 50px 20px;
  text-align: center;
  color: var(--muted);
  margin-top: 40px;
}
.under-construction .uc-icon { font-size: 40px; margin-bottom: 12px; }

/* --- Search page --- */
.search-box-wrap { margin-bottom: 22px; }
.search-input {
  width: 100%;
  max-width: 520px;
  padding: 11px 14px;
  font-size: 15px;
  border: 1px solid var(--border);
  border-radius: 6px;
}
.search-hint { font-size: 12px; color: var(--muted); margin-top: 6px; }
.search-stats { font-size: 13px; color: var(--muted); margin: 14px 0 8px; }

.result-card {
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 14px;
  overflow: hidden;
  background: #fff;
}
.result-card-header {
  background: #eef2f7;
  padding: 8px 14px;
  font-size: 12.5px;
  color: var(--navy);
  font-weight: 700;
  display: flex;
  justify-content: space-between;
  gap: 10px;
}
.result-card-header a { color: var(--navy); text-decoration: none; }
.result-card-header a:hover { text-decoration: underline; }
.result-card-sheet { color: var(--muted); font-weight: 400; }
.result-row { display: grid; grid-template-columns: 90px 1fr; gap: 0; border-top: 1px solid #eee; }
.result-row:first-of-type { border-top: none; }
.result-label {
  background: #f7f8fa;
  padding: 8px 10px;
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
  border-right: 1px solid #eee;
}
.result-value { padding: 8px 12px; font-size: 13px; white-space: pre-wrap; }
mark { background: #fff1a6; padding: 0 1px; border-radius: 2px; }

@media (max-width: 860px) {
  .sidebar { width: 220px; }
  .content { padding: 20px; }
  .result-row { grid-template-columns: 70px 1fr; }
}
