:root {
  --ink: #1c241f;
  --muted: #6d756f;
  --line: #e4dfd4;
  --paper: #f4f1ea;
  --card: #fff;
  --green: #1c3a30;
  --green-2: #2a4d40;
  --good: #1d6b45;
  --good-bg: #e7f3ec;
  --bad: #8d2f2a;
  --bad-bg: #f8e8e6;
  --wait: #8a5a12;
  --wait-bg: #f8f0dc;
  --side: #172822;
  --side-text: #d7e4dc;
  --radius: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font: 14px/1.45 "Segoe UI", sans-serif;
}

button, input, select { font: inherit; color: inherit; }

button { cursor: pointer; }

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 2px;
}

.shell {
  display: flex;
  min-height: 100vh;
}

aside {
  width: 220px;
  flex-shrink: 0;
  background: var(--side);
  color: var(--side-text);
  padding: 20px 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px 18px;
}

.mark {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: #f4f1ea;
  color: var(--green);
  display: grid;
  place-items: center;
  font-weight: 700;
}

.brand strong { display: block; color: #fff; font-size: 15px; }
.brand span { color: #a9bdb3; font-size: 12px; }

nav button {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  color: var(--side-text);
  border: 0;
  border-radius: 8px;
  padding: 9px 10px;
  margin-bottom: 2px;
}

nav button:hover { background: #22362f; }
nav button.on { background: var(--green-2); color: #fff; }

.workspace {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

header {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 60px;
  padding: 10px 24px;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}

header select,
.school-name {
  min-width: 180px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
}

.school-name { color: var(--ink); }

.spacer { flex: 1; }

.user { text-align: right; }
.user strong { display: block; font-weight: 600; }
.user span { color: var(--muted); font-size: 12px; }

.content {
  padding: 8px 24px 48px;
  max-width: 1120px;
}

h1 {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 18px 0 12px;
}

h2 {
  font-size: 15px;
  font-weight: 600;
  margin: 22px 0 8px;
}

.lead, .muted { color: var(--muted); }
.lead { margin: 0 0 14px; }

.nums {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(148px, 1fr));
  gap: 10px;
  margin-bottom: 8px;
}

.num {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px 12px;
}

.num b {
  display: block;
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

.num span { color: var(--muted); font-size: 13px; }
.num.warn b { color: var(--bad); }

form.form {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 6px 16px 16px;
  margin-bottom: 16px;
}

.form, .stack {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 12px;
  max-width: 680px;
}

.wide { grid-column: 1 / -1; }

label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin: 10px 0 4px;
}

[hidden] { display: none !important; }

input, select {
  width: 100%;
  border: 1px solid #d9d3c7;
  background: #fff;
  color: var(--ink);
  font-size: 16px;
  border-radius: 8px;
  padding: 9px 10px;
}

input::placeholder { color: #8b938c; opacity: 1; }

.filebox {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  border: 1px dashed #d9d3c7;
  background: #faf8f4;
  border-radius: 8px;
  padding: 6px 10px;
}

.filebox input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.filebtn {
  background: #e7efe9;
  color: var(--green);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 14px;
}

.filename {
  color: var(--muted);
  font-size: 14px;
}

.face-block,
.card-block { margin-top: 10px; }

.card-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin: 0 0 8px;
}

.card-row input { margin: 0; }

.card-add { margin-top: 4px; }

.face-label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 6px;
}

.face-stage {
  display: block;
  width: min(280px, 100%);
  height: auto;
  aspect-ratio: 1;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #eef2ef;
  cursor: grab;
  touch-action: none;
}

.face-stage:active { cursor: grabbing; }

.face-hint,
.face-note { margin: 6px 0 0; font-size: 13px; }

.face-zoom-label {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 10px 0 8px;
  color: var(--ink);
  font-size: 14px;
}

.face-zoom-label input { width: min(220px, 100%); }

.facepick {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.facepick .filebox { flex: 1; min-width: 180px; }

header select { width: 220px; }

.tools input,
.tools select {
  width: auto;
  min-width: 160px;
}

button.primary,
form button,
.tools > button,
td button:not(.ghost):not(.danger) {
  background: var(--green);
  color: #fff;
  border: 0;
  border-radius: 8px;
  padding: 9px 14px;
}

button.ghost,
button.danger {
  background: #fff;
  color: var(--ink);
  border: 1px solid #d5d0c6;
  border-radius: 8px;
  padding: 6px 10px;
}

button.danger { color: var(--bad); }

button.ghost:hover,
button.danger:hover { background: #faf8f4; }

.tools {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin: 0 0 14px;
}

.sheet {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: auto;
  margin: 0 0 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: transparent;
}

th, td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid #f0ece4;
  vertical-align: middle;
}

tr:last-child td { border-bottom: 0; }

th {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  background: #faf8f4;
}

tbody tr:hover td { background: #fcfbf8; }

.actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

td select { min-width: 110px; }

.modal-back {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(23, 40, 34, 0.45);
}

form.modal {
  width: min(420px, 100%);
  margin: 0;
  padding: 8px 20px 20px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

form.person-modal {
  width: min(460px, 100%);
  max-height: calc(100vh - 40px);
  overflow: auto;
}

form.person-modal .modal-error { margin: 8px 0 0; }
form.person-modal .modal-error:empty { display: none; }

.modal-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

#door-error { margin: 8px 0 0; min-height: 0; }
#door-error:empty { display: none; }

.pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: #f1eee7;
  color: var(--ink);
  font-size: 12px;
}

.pill.good { background: var(--good-bg); color: var(--good); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill.wait { background: var(--wait-bg); color: var(--wait); }

.person {
  display: flex;
  align-items: center;
  gap: 10px;
}

.face, .avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.avatar {
  display: grid;
  place-items: center;
  background: #e7efe9;
  color: var(--green);
  font-weight: 600;
}

#note:empty { display: none; }

#note p {
  margin: 14px 0 0;
  padding: 10px 12px;
  border-radius: 10px;
}

#note p.ok { background: var(--good-bg); color: var(--good); }
#note p.err { background: var(--bad-bg); color: var(--bad); }

.err { color: var(--bad); }
.ok { color: var(--good); }

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login {
  width: min(400px, 100%);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 28px 28px 22px;
}

.login h1 {
  margin: 14px 0 4px;
  font-size: 28px;
}

.login .hint {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #faf8f4;
}

@media (max-width: 800px) {
  .shell { display: block; }
  aside { width: auto; padding: 12px; }
  .brand { padding-bottom: 10px; }
  nav { display: flex; gap: 4px; overflow: auto; }
  nav button { width: auto; white-space: nowrap; }
  .form, .stack { grid-template-columns: 1fr; }
  header { flex-wrap: wrap; }
  .user { text-align: left; }
}
