:root {
  --ink: #1c1915;
  --muted: #5c564c;
  --paper: #f3efe6;
  --card: #fffdf8;
  --line: #e2d9c8;
  --pine: #1f4d3a;
  --pine-dark: #16382a;
  --warn: #8a3b12;
  --ok: #1f4d3a;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", "Liberation Sans", sans-serif;
  color: var(--ink);
  background: var(--paper);
}
a { color: var(--pine); }
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 16px 28px;
  background: var(--pine-dark);
  color: #f6f3ec;
}
header a { color: #f6f3ec; text-decoration: none; }
header button { background: #f4efe4; color: var(--pine-dark); }
header button.quiet { background: transparent; color: #f6f3ec; border-color: transparent; }
.brand { font-weight: 700; letter-spacing: 0.04em; }
nav { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
nav form { margin: 0; }
main { max-width: 1400px; margin: 0 auto; padding: 28px 20px 64px; }
h1 { font-size: 28px; margin: 0 0 8px; }
h2 { font-size: 18px; margin: 28px 0 12px; }
.lead { color: var(--muted); margin-top: 0; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px;
}
.grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.grid.five { grid-template-columns: repeat(5, 1fr); }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; margin-bottom: 20px; }
.pair .card h2 { margin-top: 0; }
label.check { display: flex; align-items: center; gap: 8px; font-weight: 400; }
.sign-preview { max-width: 280px; max-height: 160px; display: block; }
.stat strong { display: block; font-size: 28px; }
.stat span { color: var(--muted); }
label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 4px; }
input, textarea, select, button {
  font: inherit;
}
input[type="text"], input[type="email"], input[type="password"], input[type="file"], textarea, select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}
textarea { min-height: 90px; }
button, .button {
  display: inline-block;
  background: var(--pine);
  color: white;
  border: 0;
  border-radius: 8px;
  padding: 10px 14px;
  text-decoration: none;
  cursor: pointer;
}
button.quiet, .button.quiet { background: transparent; color: var(--pine); border: 1px solid var(--line); }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.flash {
  background: #efe4c4;
  border: 1px solid #e0cf98;
  padding: 10px 12px;
  border-radius: 8px;
  margin-bottom: 16px;
}
table { width: 100%; border-collapse: collapse; background: var(--card); }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; font-size: 14px; }
th { color: var(--muted); font-weight: 600; }
.narrow { max-width: 460px; }
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.comment { white-space: pre-wrap; max-width: 280px; }
.clip { max-width: 180px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status { font-weight: 600; }
td.mails { max-width: 260px; }
td.mails details summary { cursor: pointer; }
td.mails .more { color: var(--muted); }
td.mails .mail-list { margin-top: 6px; line-height: 1.45; }
select.compact { width: auto; padding: 4px 8px; }
td form { margin: 0; }
td form + form { margin-top: 6px; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.name-cell { white-space: nowrap; }
button.twist {
  background: transparent;
  color: var(--ink);
  border: 0;
  padding: 0 6px 0 0;
  min-width: 0;
  font-size: 13px;
}
.fold td { background: #faf7f1; }
.reply-text { max-width: 220px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stats { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; margin: 16px 0; }
input.calendar { width: auto; }
button.quiet { background: transparent; color: var(--pine); border: 1px solid var(--line); }
@media (max-width: 800px) {
  header { flex-direction: column; align-items: stretch; padding: 12px 14px; gap: 10px; }
  nav { gap: 8px 14px; }
  main { padding: 16px 12px 48px; }
  h1 { font-size: 24px; }
  .grid, .grid.five, .stats { grid-template-columns: 1fr 1fr; }
  .pair { grid-template-columns: 1fr; }
  .stat strong { font-size: 22px; }
  .auth { padding: 12px; min-height: 100dvh; align-items: start; }
  .auth .card { width: 100%; }
  .narrow { max-width: none; }
  input.calendar { width: 100%; }
  .row > input, .row > select { flex: 1 1 140px; width: auto; min-width: 0; max-width: 100%; }
}
@media (max-width: 420px) {
  .grid, .grid.five, .stats { grid-template-columns: 1fr; }
}
button.cross {
  background: transparent;
  color: var(--warn);
  border: 0;
  padding: 0 4px;
  font-size: 18px;
  line-height: 1;
}
.pager { display: flex; gap: 6px; align-items: center; margin: 12px 0; }
.pager a, .pager span {
  min-width: 32px;
  text-align: center;
  padding: 6px 8px;
  border-radius: 8px;
}
.pager-current { background: var(--pine); color: white; }
.pager-off { color: var(--muted); }
dialog {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  padding: 18px;
}
