:root {
  --bg: #f5f6f8; --panel: #fff; --text: #1d2430; --muted: #6b7280;
  --line: #e3e6ea; --accent: #1f5eff; --accent-dark: #164ad0;
  --red: #c0392b; --green: #1a7f4b;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}
header { background: var(--panel); border-bottom: 1px solid var(--line); }
nav { display: flex; align-items: center; gap: 18px; max-width: 1200px;
      margin: 0 auto; padding: 10px 20px; flex-wrap: wrap; }
nav a { color: var(--text); text-decoration: none; }
nav a:hover { color: var(--accent); }
nav .brand { font-weight: 700; margin-right: 8px; }
nav .sep { width: 1px; height: 18px; background: var(--line); }
nav .spacer { flex: 1; }
nav .who { color: var(--muted); }
main { max-width: 1200px; margin: 28px auto; padding: 0 20px; }
main.full { max-width: none; margin: 20px 0; padding: 0 14px; }
main.full .wide { max-width: none; }
h1 { font-size: 22px; margin: 0 0 16px; }
h2 { font-size: 17px; margin: 24px 0 10px; }
a { color: var(--accent); }
.mono { font-family: ui-monospace, 'SF Mono', Consolas, monospace; font-size: 13.5px; }
.hint { color: var(--muted); font-size: 13.5px; }
.error { color: var(--red); background: #fdeceb; border: 1px solid #f5c9c4;
         padding: 8px 12px; border-radius: 8px; }
.notice { color: var(--green); background: #e8f6ee; border: 1px solid #bfe5cf;
          padding: 8px 12px; border-radius: 8px; }
.muted { opacity: .5; }
.pass-banner { background: #fff4de; border-bottom: 1px solid #f0ddb4; color: #7a5b12;
               text-align: center; padding: 8px 20px; font-size: 14px; }
.badge { font-size: 11.5px; background: #e7edff; color: var(--accent-dark);
         border-radius: 6px; padding: 1px 7px; }
.badge.red { background: #fdeceb; color: var(--red); }

button, .btn {
  background: var(--accent); color: #fff; border: 0; border-radius: 8px;
  padding: 8px 16px; font-size: 14.5px; cursor: pointer; text-decoration: none;
  display: inline-block;
}
button:hover, .btn:hover { background: var(--accent-dark); color: #fff; }
button.secondary, .btn.secondary { background: #eceff3; color: var(--text); }
button.secondary:hover, .btn.secondary:hover { background: #dfe3e9; }
input, textarea, select {
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px;
  font: inherit; background: #fff; color: var(--text); width: 100%;
}
input:focus, textarea:focus, select:focus {
  outline: 2px solid #c8d7ff; border-color: var(--accent);
}

.login-box { max-width: 360px; margin: 10vh auto; background: var(--panel);
             border: 1px solid var(--line); border-radius: 14px; padding: 28px; }
.login-box h1 { text-align: center; }
.login-box label { display: block; margin: 12px 0; color: var(--muted); font-size: 13.5px; }
.login-box button { width: 100%; margin-top: 14px; }

.search-page { max-width: 960px; margin: 6vh auto 0; }
.search-form { display: flex; gap: 10px; }
.search-form input { font-size: 16px; padding: 11px 14px; }
.search-page .hint { margin-top: 10px; }
table.results { width: 100%; margin-top: 18px; border-collapse: collapse;
                background: var(--panel); border: 1px solid var(--line); border-radius: 10px; }
table.results td { padding: 10px 14px; border-bottom: 1px solid var(--line); }
table.results tr:last-child td { border-bottom: 0; }

.card { max-width: 760px; background: var(--panel); border: 1px solid var(--line);
        border-radius: 14px; padding: 24px 28px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
table.props { width: 100%; border-collapse: collapse; margin-top: 8px; }
table.props th { text-align: left; color: var(--muted); font-weight: 500; width: 280px;
                 vertical-align: top; padding: 7px 12px 7px 0; }
table.props td { padding: 7px 0; white-space: pre-wrap; }
table.props tr { border-bottom: 1px solid var(--line); }

.edit-form .field { margin: 12px 0; }
.edit-form .flabel { display: block; color: var(--muted); font-size: 13px; margin-bottom: 3px; }
.edit-form .field .hint { display: block; margin-top: 3px; }
.edit-form .field .chk { margin-top: 4px; }
.edit-form input[type=date] { width: auto; }
.subject-autocomplete { position: relative; }
.subject-suggestions {
  position: absolute; z-index: 10; top: calc(100% + 3px); left: 0; right: 0;
  max-height: 240px; overflow-y: auto; background: var(--panel);
  border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 8px 22px rgba(29, 36, 48, .14);
}
.subject-suggestions[hidden] { display: none; }
button.subject-option {
  display: block; width: 100%; padding: 7px 10px; border-radius: 0;
  border-bottom: 1px solid var(--line); background: var(--panel); color: var(--text);
  text-align: left; white-space: normal; line-height: 1.35;
}
button.subject-option:last-child { border-bottom: 0; }
button.subject-option:hover, button.subject-option.active {
  background: #f1f3f6; color: var(--text);
}
.real-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.real-row select { width: auto; }
.real-block input[type=text] { min-width: 320px; }
.result-card { margin-top: 16px; max-width: 640px; }
.result-card h2 { margin: 0; font-size: 17px; }
.result-card table.props th { width: 240px; font-size: 13.5px; }
.result-card table.props td { font-size: 13.5px; }
.form-actions { margin-top: 18px; display: flex; gap: 10px; }

.wide { max-width: 1200px; }
.admin-head { display: flex; align-items: center; justify-content: space-between;
              flex-wrap: wrap; gap: 12px; }
.admin-tools { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.inline { display: inline-flex; gap: 8px; align-items: center; }
.inline input { width: auto; }
.chk { display: inline-flex; gap: 5px; align-items: center; white-space: nowrap;
       color: var(--muted); font-size: 13.5px; }
.chk input { width: auto; }
.table-wrap { overflow-x: auto; margin-top: 14px; border: 1px solid var(--line);
              max-height: 75vh; overflow-y: auto; }
.table-wrap table.grid { margin-top: 0; border: 0; }
td.clip { max-width: 220px; white-space: nowrap; overflow: hidden;
          text-overflow: ellipsis; }
.filters { margin-top: 12px; flex-wrap: wrap; }
.filters select, .filters input { width: auto; }
.filter-prefix { display: inline-flex; gap: 5px; align-items: center;
                 white-space: nowrap; color: var(--muted); }
.pager { display: flex; gap: 16px; align-items: center; }
table.grid { width: 100%; border-collapse: collapse; background: var(--panel);
             border: 1px solid var(--line); margin-top: 14px; font-size: 14px; }
table.grid th { text-align: left; padding: 8px 10px; background: #eef0f4;
                border-bottom: 1px solid var(--line); position: sticky; top: 0; }
table.grid td { padding: 7px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.reorderable-table th[draggable="true"] { cursor: grab; user-select: none; }
.reorderable-table th[draggable="true"]:active { cursor: grabbing; }
.reorderable-table th.dragging { opacity: .45; }
.reorderable-table th.drop-before { box-shadow: inset 3px 0 0 var(--accent); }
.reorderable-table th.drop-after { box-shadow: inset -3px 0 0 var(--accent); }
.column-order-hint { margin-bottom: 0; }
.details div { margin-bottom: 3px; }
.details s { color: var(--muted); }
.log-filter select { width: auto; }
.tabs { display: flex; gap: 4px; margin: 14px 0 6px; }
.tabs a { padding: 6px 16px; border: 1px solid var(--line); border-radius: 8px 8px 0 0;
          text-decoration: none; color: var(--muted); background: #eceff3; }
.tabs a.active { background: var(--panel); color: var(--text); font-weight: 600;
                 border-bottom-color: var(--panel); }
.tabs a.tab-red.active { color: var(--red); }
tr.row-red td { background: #fdf0ef; }
.btn-small { padding: 3px 10px; font-size: 12.5px; }
.susp-table { margin-bottom: 20px; }
.actions form { margin-right: 6px; }
.actions button { padding: 4px 10px; font-size: 13px; }
