:root {
  --ink: #1c2824;
  --muted: #5e6b64;
  --green: #1f4d40;
  --green-2: #2f6f5e;
  --paper: #f3efe6;
  --card: #fffdf8;
  --line: #e3d9c6;
  --yellow: #ffe45c;
  --yellow-deep: #e2b400;
  --danger: #9d2c2c;
  --shadow: 0 18px 50px rgba(48, 38, 18, 0.12);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
  margin: 0;
  padding-bottom: 52px;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at top right, rgba(47, 111, 94, 0.08), transparent 28%),
    var(--paper);
  font-family: "Segoe UI", "Arial", sans-serif;
  font-size: 16px;
}

button, input, select { font: inherit; color: inherit; }

button { cursor: pointer; }

:focus-visible {
  outline: 3px solid var(--yellow-deep);
  outline-offset: 2px;
}

h1, h2, h3, p { margin-top: 0; }

.brand {
  margin: 0;
  color: var(--green);
  font-weight: 800;
  letter-spacing: 0;
}

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(640px, 100%);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 28px;
}

.login-card h1 {
  margin: 8px 0 8px;
  font-size: 28px;
}

.lead, .help-line { color: var(--muted); line-height: 1.5; }

form { display: grid; gap: 12px; }

label { display: grid; gap: 6px; font-weight: 700; }

input, select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.primary, .ghost, .danger, .preset, .pill {
  border-radius: 12px;
  border: 1px solid transparent;
  padding: 10px 14px;
}

.primary { background: var(--green); color: white; }
.primary:hover { background: var(--green-2); }

.ghost {
  background: transparent;
  border-color: var(--line);
}

.danger {
  background: #fff;
  color: var(--danger);
  border-color: #efc7c7;
}

.hint, .form-error { margin: 0; }

.hint {
  background: #f7f1df;
  border-radius: 12px;
  padding: 10px 12px;
  color: var(--ink);
}

.form-error { color: var(--danger); font-weight: 700; }

.device-list { display: grid; gap: 8px; }

.device-row { display: flex; gap: 8px; }

.device-row .primary { flex: 1; }

h2 { font-size: 18px; margin-bottom: 0; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 4;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 14px 20px;
  background: rgba(243, 239, 230, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(8px);
}

.today { margin: 2px 0 0; color: var(--muted); }

.pavilion-mark {
  display: inline-block;
  margin: 6px 0 0;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--green);
  color: #f7f3ea;
  font-weight: 800;
  font-size: 18px;
}

.pavilion-picker {
  display: grid;
  gap: 8px;
  margin: 4px 0 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #f7f3ea;
}

.pavilion-title, .group-label { margin: 0; font-weight: 800; }

.group-label { color: var(--muted); font-size: 14px; }

.pavilion-row { display: flex; flex-wrap: wrap; gap: 8px; }

.pavilion-choice {
  border: 2px solid var(--line);
  background: white;
  border-radius: 999px;
  padding: 8px 16px;
  font-weight: 800;
}

.pavilion-choice.selected {
  background: var(--green);
  border-color: var(--green);
  color: white;
}

.extend-box {
  display: grid;
  gap: 10px;
  padding: 12px;
  border-radius: 14px;
  background: #f7f3ea;
}

.extend-title { margin: 0; font-weight: 800; }

.sep-reason {
  display: block;
  margin-top: 4px;
  font-size: 14px;
}

.top-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-start;
  align-items: center;
}

.top-actions input { width: 180px; }

main { padding: 16px 20px 40px; }

.who {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  color: var(--muted);
}

.live { color: var(--green-2); font-weight: 700; }

.yesterday-banner {
  background: #efe7fb;
  border-color: #d5c6ee;
  font-weight: 800;
}

.banner {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  background: #e7f3ee;
  border: 1px solid #b7d8cc;
  border-radius: 14px;
  padding: 12px 14px;
  margin-bottom: 12px;
}

.help {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 14px;
  margin-bottom: 14px;
}

.help p { margin-bottom: 8px; line-height: 1.55; }

.table-wrap {
  overflow: auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

table {
  width: 100%;
  min-width: 1100px;
  border-collapse: separate;
  border-spacing: 0;
}

th, td {
  padding: 12px;
  text-align: right;
  vertical-align: top;
  border-bottom: 2px solid #cfc3ab;
  border-left: 3px solid #cfc3ab;
}

th:last-child, td:last-child { border-left: 0; }

th {
  position: sticky;
  top: 0;
  z-index: 1;
  font-size: 15px;
  border-bottom-width: 3px;
}

.col-name { background: #fffdf8; width: 18%; }
.col-closure { background: #e7f3ee; width: 28%; }
.col-overnight { background: #f4eefb; width: 26%; }
.col-sep { background: #fff6d8; width: 18%; }
.col-cigs { background: #f7f1e6; width: 10%; }

.name-line {
  display: flex;
  align-items: center;
  gap: 8px;
}

.name-line strong { font-size: 18px; }

.row-actions, .chips, .dialog-actions, .presets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.row-actions { margin-top: 8px; }

.pill, .presets button, .linkish {
  background: #f6f1e6;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 14px;
}

.linkish { background: transparent; }

.danger-text { color: var(--danger); }

.chips {
  min-height: 28px;
  flex-direction: column;
  align-items: stretch;
}

.chip {
  position: relative;
  width: 100%;
  padding: 8px 10px 8px 28px;
  border-radius: 14px;
  border: 1px solid transparent;
}

.chip.closure {
  background: #e7f3ee;
  border-color: #b7d8cc;
}

.chip.overnight {
  background: #f3eafa;
  border-color: #dcc8ef;
}

.chip-date { font-weight: 800; }

.chip-date span {
  font-weight: 600;
  color: var(--muted);
}

.chip-text {
  display: block;
  width: 100%;
  margin-top: 2px;
  padding: 0;
  border: 0;
  background: transparent;
  text-align: right;
  cursor: pointer;
}

.chip-x {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
}

tr.separated td {
  background: var(--yellow);
  box-shadow: inset 0 0 0 1px rgba(196, 138, 0, 0.35);
}

tr.separated {
  box-shadow: inset -4px 0 0 var(--yellow-deep);
}

.sep strong { display: block; }

.sep-until, .sep-left {
  display: block;
  margin-top: 2px;
}

.cigs select {
  width: 76px;
  padding: 8px;
  text-align: center;
  font-weight: 800;
}

.muted, .empty { color: var(--muted); }

.empty { text-align: center; padding: 28px; }

.preview {
  margin: 0;
  min-height: 1.4em;
  padding: 10px 12px;
  border-radius: 12px;
  background: #f6f1e6;
  font-weight: 700;
}

.sep-preview { background: var(--yellow); }

dialog {
  width: min(460px, calc(100% - 24px));
  border: 0;
  border-radius: 20px;
  padding: 0;
  box-shadow: var(--shadow);
}

dialog.wide { width: min(720px, calc(100% - 24px)); }

dialog::backdrop { background: rgba(28, 40, 36, 0.45); }

dialog form { padding: 22px; }

dialog h3 { font-size: 22px; }

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
}

.check input { width: auto; }

.user-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.inline-pavilion { margin-top: 8px; }

.inline-pavilion select { margin-top: 4px; }

.user-list { display: grid; gap: 8px; padding: 0 22px 22px; }

.user-row {
  display: grid;
  grid-template-columns: 1.3fr 1fr auto auto auto;
  gap: 8px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
}

.user-row input[type="password"] { min-width: 0; }

.badge {
  display: inline-block;
  margin-inline-start: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #e7f3ee;
  font-size: 13px;
}

.toast {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  max-width: min(520px, calc(100% - 24px));
  padding: 12px 16px;
  border-radius: 14px;
  background: var(--ink);
  color: white;
  box-shadow: var(--shadow);
}

.copyright {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 6;
  margin: 0;
  padding: 10px 16px;
  text-align: center;
  background: var(--green);
  color: #f7f3ea;
  font-size: 14px;
  letter-spacing: 0.02em;
}

.print-only { display: none; }

@media (max-width: 800px) {
  .topbar, .user-grid, .user-row { display: grid; }
  .user-row { grid-template-columns: 1fr; }
  .top-actions input { width: 100%; }
}

@media print {
  .no-print, .copyright { display: none !important; }
  .print-only { display: block; margin: 0 0 12px; font-size: 20px; font-weight: 800; }
  body { background: white; }
  .table-wrap { box-shadow: none; overflow: visible; }
  table { min-width: 0; }
  tr.separated td {
    background: #ffe45c !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}
