:root {
  --navy: #18365f;
  --blue: #275b95;
  --pale: #e9f1fb;
  --gold: #b98a31;
  --ink: #17243a;
  --muted: #65738a;
  --line: #ccd8e8;
  --danger: #963c42;
  --ok: #286d4b;
  --paper: #fffdf8;
}
* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  min-height: 100%;
  font-family: "Yu Gothic UI", "Yu Gothic", system-ui, sans-serif;
  color: var(--ink);
  background: #f3f6fa;
}
a {
  color: #1e568e;
}
.site-header {
  height: 86px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 22px;
  background: white;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  text-decoration: none;
  color: var(--navy);
  font-size: 1.28rem;
  font-weight: 700;
}
.brand img {
  width: 118px;
  height: 68px;
  object-fit: contain;
}
.site-nav {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.site-nav a {
  padding: 9px 12px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--navy);
}
.site-nav a:hover {
  background: var(--pale);
}
.login-shell,
.setup-shell {
  max-width: 760px;
  margin: 36px auto;
  padding: 0 18px;
}
.login-card,
.setup-card,
.panel {
  background: white;
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 8px 28px rgba(20, 45, 80, 0.08);
}
.login-card,
.setup-card {
  padding: 28px;
}
.hero-logo {
  display: block;
  max-width: 400px;
  width: 100%;
  max-height: 260px;
  object-fit: contain;
  margin: 0 auto 18px;
}
.field {
  margin: 15px 0;
}
.field label {
  display: block;
  font-weight: 700;
  margin-bottom: 6px;
}
.field input,
.field select,
.field textarea,
.search-form input {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid #aebed4;
  border-radius: 8px;
  background: white;
  font: inherit;
}
.help {
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.65;
}
.error,
.notice,
.success {
  padding: 12px 14px;
  border-radius: 9px;
  margin: 14px 0;
}
.error {
  background: #fdecee;
  color: #842f39;
  border: 1px solid #e9b7bd;
}
.notice {
  background: #fff7df;
  border: 1px solid #ebd291;
  color: #6d531f;
}
.success {
  background: #e8f6ee;
  border: 1px solid #acd6bd;
  color: #205d3f;
}
.button,
button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  border: 1px solid var(--blue);
  border-radius: 8px;
  background: var(--blue);
  color: white;
  text-decoration: none;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.button.secondary,
button.secondary {
  background: white;
  color: var(--blue);
}
.button.danger,
button.danger {
  background: var(--danger);
  border-color: var(--danger);
}
.button-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 18px;
}
.secret-box {
  white-space: pre-wrap;
  word-break: break-all;
  padding: 14px;
  border: 1px dashed var(--gold);
  border-radius: 8px;
  background: #fffaf0;
  font-family: ui-monospace, monospace;
}
.db-layout {
  display: grid;
  grid-template-columns: 280px minmax(280px, 390px) minmax(450px, 1fr);
  min-height: calc(100vh - 86px);
}
.tree-pane,
.list-pane,
.detail-pane {
  min-width: 0;
  border-right: 1px solid var(--line);
  background: white;
}
.tree-pane {
  background: var(--navy);
  color: white;
  padding: 14px;
  overflow: auto;
}
.tree-pane a {
  color: #edf5ff;
  text-decoration: none;
}
.tree-pane ul {
  list-style: none;
  padding-left: 17px;
  margin: 6px 0;
}
.tree-pane li {
  margin: 5px 0;
}
.tree-pane .selected > a {
  font-weight: 700;
  color: #ffe0a6;
}
.list-pane {
  padding: 14px;
  overflow: auto;
}
.search-form {
  display: flex;
  gap: 8px;
  margin-bottom: 13px;
}
.search-form button {
  flex: 0 0 auto;
}
.item-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.item-list a {
  display: block;
  padding: 10px 9px;
  border-bottom: 1px solid #e5ebf3;
  text-decoration: none;
  color: var(--ink);
}
.item-list a:hover,
.item-list .selected a {
  background: var(--pale);
}
.item-meta {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  margin-top: 4px;
}
.detail-pane {
  padding: 18px 22px;
  overflow: auto;
}
.detail-toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.detail-toolbar button {
  padding: 7px 11px;
  font-size: 0.9rem;
}
.record-body {
  white-space: pre-wrap;
  line-height: 1.95;
  font-family: "Yu Mincho", "Hiragino Mincho ProN", serif;
  font-size: 1.08rem;
  max-width: 1100px;
}
.record-body.page-mode {
  background: var(--paper);
  border: 1px solid #e5d8bb;
  padding: 42px clamp(22px, 7vw, 90px);
  max-width: 940px;
  margin: auto;
  box-shadow: 0 6px 24px rgba(61, 45, 20, 0.08);
}
.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin: 20px 0;
}
.image-grid img {
  width: 100%;
  max-height: 520px;
  object-fit: contain;
  background: #f4f6f9;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.empty {
  padding: 40px 12px;
  text-align: center;
  color: var(--muted);
}
.content-wrap {
  max-width: 1320px;
  margin: 22px auto;
  padding: 0 18px;
}
.panel {
  padding: 22px;
  margin-bottom: 18px;
}
.stats {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
}
.stat {
  padding: 12px 16px;
  background: var(--pale);
  border-radius: 9px;
}
.table-wrap {
  overflow: auto;
}
.data-table {
  border-collapse: collapse;
  width: 100%;
  background: white;
}
.data-table th,
.data-table td {
  padding: 9px 11px;
  border: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}
.data-table th {
  background: var(--navy);
  color: white;
  position: sticky;
  top: 85px;
}
.data-table[data-sortable] th {
  cursor: pointer;
}
.data-table[data-sortable] th[data-order="asc"]::after {
  content: " ▲";
}
.data-table[data-sortable] th[data-order="desc"]::after {
  content: " ▼";
}
.data-table td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.good-row {
  background: #eef9f2;
}
.toggle-check {
  display: flex;
  gap: 8px;
  align-items: center;
}
.toggle-check input {
  width: auto;
}
.footer-note {
  color: var(--muted);
  font-size: 0.9rem;
  margin-top: 18px;
}
.hidden {
  display: none !important;
}
@media (max-width: 1050px) {
  .db-layout {
    grid-template-columns: 230px 330px 1fr;
  }
  .site-header {
    height: auto;
    position: static;
  }
  .data-table th {
    top: 0;
  }
}
@media (max-width: 760px) {
  .site-header {
    display: block;
    padding: 8px 12px;
  }
  .brand {
    justify-content: center;
  }
  .site-nav {
    justify-content: center;
  }
  .db-layout {
    display: block;
  }
  .tree-pane,
  .list-pane,
  .detail-pane {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .tree-pane {
    max-height: 330px;
  }
  .list-pane {
    max-height: 420px;
  }
  .detail-pane {
    padding: 15px;
  }
  .record-body.page-mode {
    padding: 25px 18px;
  }
  .button-row {
    display: grid;
  }
  .button-row > * {
    width: 100%;
  }
}
