/* SES案件DB 共通スタイル */
:root {
  --bg: #f5f7fa;
  --panel: #ffffff;
  --fg: #1f2933;
  --muted: #6b7684;
  --border: #d9dee5;
  --accent: #1f6fb2;
  --accent-weak: #e8f1fa;
  --danger: #c0392b;
  --danger-weak: #fdecea;
  --ok: #1e7e4a;
  --ok-weak: #e6f4ec;
  --warn: #8a6100;
  --warn-weak: #fff5d6;
  --mark: #fff1a8;
  --chip: #eef2f7;
  --header-h: 48px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--fg);
  font-family: "Yu Gothic UI", "Meiryo", "Hiragino Kaku Gothic ProN", sans-serif;
  font-size: 14px; line-height: 1.6;
}
body.bare { background: var(--panel); }
a { color: var(--accent); }
h1 { font-size: 20px; margin: 0 0 12px; }
h2 { font-size: 16px; margin: 20px 0 8px; }
code, .mono, pre.body, textarea.mono, input.mono {
  font-family: "BIZ UDGothic", "MS Gothic", Consolas, monospace;
}
.muted { color: var(--muted); }
.small { font-size: 12px; }
.hidden { display: none !important; }

/* ---- ヘッダー ---- */
.site-header {
  height: var(--header-h); display: flex; align-items: center; gap: 16px;
  padding: 0 16px; background: #1f2d3d; color: #fff;
}
.site-header a, .site-header summary { color: #fff; text-decoration: none; }
.brand { font-weight: bold; font-size: 16px; }
.main-nav { display: flex; gap: 16px; align-items: center; flex: 1; }
.dropdown { position: relative; }
.dropdown summary { cursor: pointer; list-style: none; }
.dropdown summary::-webkit-details-marker { display: none; }
.dropdown summary::after { content: " ▾"; }
.dropdown-menu {
  position: absolute; top: 30px; left: 0; z-index: 10; min-width: 180px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,.12); padding: 4px 0;
}
.dropdown-menu.right { left: auto; right: 0; }
.dropdown-menu a, .dropdown-menu button.link {
  display: block; width: 100%; padding: 8px 14px; color: var(--fg) !important;
  text-align: left; background: none; border: 0; font: inherit; cursor: pointer;
}
.dropdown-menu a:hover, .dropdown-menu button.link:hover { background: var(--accent-weak); }
.badge {
  display: inline-block; min-width: 18px; padding: 0 6px; border-radius: 9px;
  background: var(--danger); color: #fff; font-size: 11px; text-align: center;
}
.alert-band { background: var(--danger); color: #fff; padding: 6px 16px; }
.alert-band a { color: #fff; font-weight: bold; }

/* ---- メッセージ ---- */
.flash { margin: 8px 16px; padding: 8px 36px 8px 12px; border-radius: 6px; position: relative; }
.flash-success { background: var(--ok-weak); color: var(--ok); }
.flash-error { background: var(--danger-weak); color: var(--danger); }
.flash-warning { background: var(--warn-weak); color: var(--warn); }
.flash-close { position: absolute; right: 8px; top: 6px; border: 0; background: none; cursor: pointer; font-size: 16px; color: inherit; }
.field-error { color: var(--danger); font-size: 12px; margin-top: 2px; }

/* ---- フォーム・ボタン ---- */
input[type=text], input[type=password], input[type=number], input[type=email], select, textarea {
  font: inherit; padding: 5px 8px; border: 1px solid var(--border); border-radius: 4px; background: #fff;
}
input.num { width: 72px; }
textarea { width: 100%; }
.btn {
  display: inline-block; padding: 6px 14px; border: 1px solid var(--accent); border-radius: 4px;
  background: var(--accent); color: #fff; font: inherit; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn.secondary { background: #fff; color: var(--accent); }
.btn.danger { background: var(--danger); border-color: var(--danger); }
.btn.small { padding: 2px 10px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: default; }
button.link { background: none; border: 0; color: var(--accent); cursor: pointer; padding: 0; font: inherit; }

.page { padding: 16px; max-width: 1280px; margin: 0 auto; }
.search-row { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; margin: 0 0 10px; }
.search-row form { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; margin: 0; }
.search-row h2 { margin: 0; }
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 16px; margin-bottom: 16px; }
.form-grid { display: grid; grid-template-columns: 220px 1fr; gap: 10px 16px; align-items: start; }
.form-grid label.title { padding-top: 6px; font-weight: bold; }
.form-actions { margin-top: 16px; display: flex; gap: 8px; }
.req::after { content: " *"; color: var(--danger); }

/* ---- 表 ---- */
table.list { border-collapse: collapse; width: 100%; background: var(--panel); }
table.list th, table.list td { border: 1px solid var(--border); padding: 6px 8px; text-align: left; vertical-align: top; }
table.list th { background: #eef2f7; white-space: nowrap; }
table.list tr.inactive td { color: var(--muted); background: #f3f4f6; }
table.list tr.failed td { background: var(--danger-weak); }
td.num, th.num { text-align: right; white-space: nowrap; }
.score-plus { color: var(--ok); font-weight: bold; }
.score-minus { color: var(--danger); font-weight: bold; }
.truncate { max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- チップ ---- */
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip {
  display: inline-block; padding: 0 8px; border-radius: 10px; background: var(--chip);
  font-size: 12px; color: var(--fg); text-decoration: none; border: 0; cursor: pointer; line-height: 20px;
}
a.chip:hover { background: var(--accent-weak); }
.chip.selected { background: var(--accent); color: #fff; }
.chip.minus { background: #eceff3; color: var(--muted); }
.chip.more { background: none; color: var(--muted); cursor: default; }

/* ---- 2ペイン（S-02, S-04） ---- */
.search-bar { background: var(--panel); border-bottom: 1px solid var(--border); padding: 10px 16px; }
.search-bar .row { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; margin-bottom: 6px; }
.search-bar input[name=q] { width: 360px; max-width: 100%; }
.two-pane { display: flex; height: calc(100vh - var(--header-h) - var(--search-h, 96px)); }
.two-pane .list-pane {
  width: 440px; flex-shrink: 0; overflow-y: auto; padding: 10px; border-right: 1px solid var(--border);
}
.two-pane .detail-pane { flex: 1; min-width: 0; background: var(--panel); }
.two-pane iframe { width: 100%; height: 100%; border: 0; display: block; }
.result-count { margin: 0 0 8px; color: var(--muted); }

.card {
  display: block; background: var(--panel); border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 12px; margin-bottom: 8px; color: var(--fg); text-decoration: none; cursor: pointer;
}
.card:hover { border-color: var(--accent); }
.card.selected { border: 2px solid var(--accent); padding: 9px 11px; }
.card .card-title {
  font-weight: bold; margin-bottom: 4px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card .card-meta { display: flex; gap: 12px; align-items: center; margin-top: 6px; color: var(--muted); font-size: 12px; }
.card .price { color: var(--fg); font-weight: bold; margin-left: auto; }
.card .price.unknown { color: var(--muted); font-weight: normal; }
.card.borderline { background: var(--warn-weak); }

.pager { display: flex; gap: 4px; justify-content: center; margin: 12px 0; flex-wrap: wrap; }
.pager a, .pager span { padding: 2px 9px; border: 1px solid var(--border); border-radius: 4px; background: var(--panel); text-decoration: none; }
.pager span.current { background: var(--accent); color: #fff; border-color: var(--accent); }

.placeholder { color: var(--muted); padding: 40px; text-align: center; }

/* ---- 詳細（S-03, S-04-1） ---- */
.detail { padding: 16px 20px; }
.detail-head { display: flex; gap: 12px; align-items: flex-start; }
.detail-head h1 { flex: 1; margin-bottom: 6px; }
table.info { border-collapse: collapse; margin: 12px 0; width: 100%; }
table.info th { width: 110px; text-align: left; vertical-align: top; padding: 4px 8px 4px 0; color: var(--muted); font-weight: normal; }
table.info td { padding: 4px 0; white-space: pre-wrap; }
.history { margin: 8px 0; }
.history a { display: block; padding: 3px 6px; text-decoration: none; color: var(--fg); border-radius: 4px; }
.history a.current { background: var(--accent-weak); }
.history a:hover { background: #f0f3f7; }
.multi-note { background: var(--accent-weak); border-radius: 6px; padding: 8px 12px; margin: 8px 0; }
pre.body {
  white-space: pre-wrap; word-break: break-word; background: #fafbfc; border: 1px solid var(--border);
  border-radius: 6px; padding: 12px; font-size: 13px; line-height: 1.55; margin: 8px 0;
}
pre.body .segment { background: #fff8d0; display: block; }
mark { background: var(--mark); }
.admin-actions { border-top: 1px solid var(--border); margin-top: 16px; padding-top: 12px; }

/* ---- ログイン ---- */
.login-box { max-width: 360px; margin: 10vh auto; background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 28px; }
.login-box h1 { text-align: center; }
.login-box input { width: 100%; margin-bottom: 12px; }
.login-box .btn { width: 100%; }

/* ---- タブ ---- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 12px; }
.tabs a { padding: 6px 14px; text-decoration: none; border: 1px solid transparent; border-bottom: 0; border-radius: 6px 6px 0 0; }
.tabs a.active { border-color: var(--border); background: var(--panel); color: var(--fg); font-weight: bold; }

/* ---- スマホ ---- */
@media (max-width: 767px) {
  .two-pane { display: block; height: auto; }
  .two-pane .list-pane { width: auto; border-right: 0; overflow: visible; }
  .two-pane .detail-pane { display: none; }
  .search-bar input[name=q] { width: 100%; }
  .form-grid { grid-template-columns: 1fr; }
  .site-header { gap: 10px; }
}
