:root {
  --ink: #17212b;
  --muted: #5f6c76;
  --line: #d9e1e8;
  --panel: #ffffff;
  --bg: #f4f7fb;
  --brand: #12324a;
  --accent: #0f766e;
  --danger: #b42318;
  --plate: #ffd82e;
  --plate-border: #111111;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
  line-height: 1.45;
}

a { color: inherit; }

.page,
.admin-shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0;
}

.hero {
  padding: 24px 0 18px;
}

.hero.compact { padding-bottom: 8px; }

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0;
}

h1, h2 {
  margin: 0 0 12px;
  line-height: 1.15;
  letter-spacing: 0;
}

h1 { font-size: clamp(2rem, 5vw, 4.2rem); }
h2 { font-size: 1.35rem; }
p { color: var(--muted); }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 22px;
  box-shadow: 0 10px 30px rgba(18, 50, 74, 0.06);
}

.form-panel,
.login-panel {
  max-width: 560px;
}

label {
  display: block;
  margin: 16px 0 7px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-height: 46px;
  border: 1px solid #b9c5cf;
  border-radius: 6px;
  padding: 10px 12px;
  color: var(--ink);
  background: #fff;
  font: inherit;
}

textarea {
  min-height: 110px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.plate-input,
.plate-display,
.mini-plate {
  background: var(--plate);
  color: #111;
  border: 2px solid var(--plate-border);
  border-radius: 6px;
  font-family: Arial, Helvetica, sans-serif;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.22);
}

.plate-input {
  min-height: 68px;
  text-align: center;
  font-size: 2rem;
}

.plate-display {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 220px;
  min-height: 72px;
  padding: 10px 24px;
  font-size: 2.1rem;
}

.mini-plate {
  display: inline-flex;
  min-width: 96px;
  justify-content: center;
  padding: 5px 8px;
  white-space: nowrap;
}

button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 14px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

.primary {
  margin-top: 20px;
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
}

.secondary {
  background: #eef3f7;
}

.danger {
  border-color: #f2b8b5;
  background: #fff3f2;
  color: var(--danger);
}

.notice {
  max-width: 720px;
  margin: 12px 0 18px;
  border: 1px solid #c7d6e2;
  border-radius: 8px;
  padding: 12px 14px;
  background: #eef6ff;
  color: #17324d;
}

.notice.success {
  border-color: #a4d7ba;
  background: #edfff4;
  color: #14532d;
}

.notice.error {
  border-color: #f2b8b5;
  background: #fff3f2;
  color: var(--danger);
}

.confirm-panel dl,
.vehicle-card dl,
.tv-card dl {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 7px 14px;
  margin: 20px 0 0;
}

dt {
  color: var(--muted);
  font-weight: 700;
}

dd { margin: 0; }

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 18px;
}

.admin-header,
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.admin-grid {
  display: grid;
  grid-template-columns: minmax(260px, 330px) 1fr;
  gap: 18px;
  align-items: start;
}

.wide { min-width: 0; }

.inline-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: end;
}

.inline-form .primary { margin: 0; }

.tenant-list,
.visitor-list {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.list-row,
.visitor-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1160px;
}

th, td {
  border-bottom: 1px solid var(--line);
  padding: 10px;
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 0.82rem;
  text-transform: uppercase;
}

.table-actions {
  display: flex;
  gap: 8px;
}

.table-actions form { margin: 0; }

.admin-photo-thumb {
  display: block;
  width: 54px;
  height: 40px;
  border-radius: 6px;
  object-fit: cover;
  background: #e9eef3;
}

.kiosk-page {
  background: #e9eef3;
}

.kiosk-shell {
  min-height: 100vh;
  display: grid;
  align-items: center;
  padding: 22px 28px;
}

.kiosk-form {
  width: min(960px, 100%);
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(220px, 0.7fr) minmax(520px, 1.3fr);
  gap: 28px;
  align-items: center;
}

.kiosk-title h1 {
  max-width: 8ch;
  margin-bottom: 0;
  font-size: clamp(2.7rem, 6.3vw, 4.8rem);
}

.kiosk-workspace {
  min-width: 0;
}

.kiosk-workspace .notice {
  max-width: none;
  margin: 0 0 10px;
  padding: 10px 12px;
}

.kiosk-entry-form {
  max-width: none;
  padding: 16px;
}

.kiosk-entry-form label,
.tenant-picker legend {
  display: block;
  margin: 0 0 6px;
  color: #1b2834;
  font-size: 0.92rem;
  font-weight: 800;
}

.kiosk-field {
  margin-bottom: 10px;
}

.kiosk-camera {
  position: fixed;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

.kiosk-camera video {
  width: 1px;
  height: 1px;
  object-fit: cover;
  transform: scaleX(-1);
}

.kiosk-camera span {
  display: none;
}

.kiosk-camera canvas {
  display: none;
}

.kiosk-entry-form input {
  min-height: 48px;
  font-size: 1.08rem;
}

.kiosk-entry-form .plate-input {
  min-height: 76px;
  font-size: clamp(2rem, 5vw, 3rem);
}

.tenant-picker {
  margin: 0;
  padding: 0;
  border: 0;
}

.tenant-buttons {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
  max-height: 150px;
  overflow-y: auto;
  padding: 1px;
}

.tenant-choice {
  justify-content: flex-start;
  min-height: 46px;
  width: 100%;
  padding: 8px 10px;
  border-color: #c4d0da;
  background: #f7fafc;
  color: #18232d;
  font-size: 0.95rem;
  line-height: 1.15;
  text-align: left;
  overflow-wrap: anywhere;
}

.tenant-choice.selected {
  border-color: var(--brand);
  background: #dcecf7;
  box-shadow: inset 0 0 0 2px var(--brand);
}

.tenant-picker.needs-choice {
  border-radius: 8px;
  outline: 3px solid rgba(180, 35, 24, 0.25);
  outline-offset: 5px;
}

.kiosk-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(130px, 0.42fr);
  gap: 10px;
  margin-top: 12px;
}

.kiosk-submit,
.kiosk-secondary-action {
  width: 100%;
  min-height: 52px;
  margin-top: 0;
  font-size: 1.08rem;
}

.kiosk-keyboard {
  position: fixed;
  right: 14px;
  bottom: 14px;
  left: 14px;
  z-index: 15;
  display: none;
  max-width: 980px;
  margin: 0 auto;
  border: 1px solid #b8c7d3;
  border-radius: 8px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 16px 42px rgba(18, 50, 74, 0.22);
}

.kiosk-keyboard.active {
  display: block;
}

.keyboard-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.keyboard-topline strong {
  font-size: 0.92rem;
}

.keyboard-control {
  min-height: 34px;
  padding: 6px 14px;
  background: #e9f1f7;
}

.keyboard-keys {
  display: grid;
  gap: 6px;
}

.keyboard-row {
  display: flex;
  justify-content: center;
  gap: 6px;
}

.keyboard-key {
  flex: 1 1 0;
  min-width: 0;
  min-height: 42px;
  padding: 6px 8px;
  border-color: #b9c8d4;
  background: #f7fafc;
  color: #111d27;
  font-size: 1.05rem;
  line-height: 1;
}

.plate-layout .keyboard-key {
  font-weight: 800;
}

.keyboard-key.key-space {
  flex-grow: 4;
}

.keyboard-key.key-clear,
.keyboard-key.key-done,
.keyboard-key.key-backspace,
.keyboard-key.key-shift {
  flex-grow: 1.7;
  background: #e9f1f7;
  font-size: 0.92rem;
}

.keyboard-key.key-done {
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
}

.screensaver {
  position: fixed;
  inset: 0;
  display: none;
  align-content: center;
  padding: 6vw;
  background: #102535;
  color: #fff;
  z-index: 20;
}

.screensaver.active {
  display: grid;
}

.screensaver h2 {
  font-size: clamp(2rem, 6vw, 5rem);
}

.screensaver-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 18px;
}

.screensaver-grid div {
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  padding: 18px;
  background: rgba(255, 255, 255, 0.08);
}

.screensaver-grid span,
.screensaver-grid em {
  display: block;
  color: #d6e6f2;
  font-style: normal;
}

.tv-page {
  background: #081720;
  color: #fff;
}

.tv-board {
  min-height: 100vh;
  padding: 4vw;
}

.tv-board header {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: start;
}

.tv-board h1 {
  font-size: clamp(2.4rem, 6vw, 5.5rem);
}

#clock {
  font-size: clamp(1.5rem, 4vw, 3rem);
  font-weight: 800;
}

.tv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 22px;
  margin-top: 28px;
}

.tv-card {
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  padding: 22px;
  background: rgba(255, 255, 255, 0.08);
}

.tv-card.new {
  animation: arrival 1.6s ease-in-out;
}

.tv-card h2 {
  margin-top: 18px;
  font-size: 2rem;
}

.tv-card p,
.empty-tv {
  color: #d8e5ee;
}

@keyframes arrival {
  0% { outline: 0 solid rgba(255, 216, 46, 0.9); transform: scale(1); }
  35% { outline: 10px solid rgba(255, 216, 46, 0.25); transform: scale(1.02); }
  100% { outline: 0 solid rgba(255, 216, 46, 0); transform: scale(1); }
}

.quiet {
  min-height: 20px;
  color: var(--muted);
  margin-top: 8px;
}

@media (max-width: 800px) {
  .page,
  .admin-shell {
    width: min(100% - 20px, 1120px);
    padding: 18px 0;
  }

  .panel { padding: 16px; }

  .admin-grid {
    grid-template-columns: 1fr;
  }

  .admin-header,
  .section-head,
  .list-row,
  .visitor-row,
  .tv-board header {
    align-items: stretch;
    flex-direction: column;
  }

  .inline-form {
    grid-template-columns: 1fr;
  }

  .plate-input {
    font-size: 1.6rem;
  }

  .plate-display {
    width: 100%;
    min-width: 0;
    font-size: 1.75rem;
  }

  .table-actions {
    flex-direction: column;
  }
}

@media (orientation: landscape) and (max-width: 1100px) and (max-height: 700px) {
  body.kiosk-page {
    overflow: hidden;
  }

  .kiosk-shell {
    height: 100vh;
    min-height: 0;
    padding: 14px 18px;
  }

  .kiosk-form {
    grid-template-columns: minmax(190px, 0.55fr) minmax(540px, 1.45fr);
    gap: 22px;
    width: min(980px, 100%);
  }

  .kiosk-title h1 {
    font-size: clamp(2.5rem, 5.2vw, 3.9rem);
  }

  .kiosk-title .eyebrow {
    margin-bottom: 6px;
  }

  .kiosk-entry-form {
    padding: 14px;
  }

  .kiosk-entry-form .plate-input {
    min-height: 68px;
    font-size: 2.55rem;
  }

  .kiosk-entry-form input {
    min-height: 44px;
  }

  .tenant-buttons {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 7px;
    max-height: 96px;
  }

  .tenant-choice {
    min-height: 42px;
    padding: 7px 9px;
    font-size: 0.88rem;
  }

  .kiosk-actions {
    margin-top: 10px;
  }

  .kiosk-submit,
  .kiosk-secondary-action {
    min-height: 48px;
  }

  body.keyboard-open .kiosk-shell {
    align-items: start;
    padding: 8px 12px 174px;
    overflow-y: auto;
  }

  body.keyboard-open .kiosk-form {
    display: block;
    width: min(620px, 100%);
  }

  body.keyboard-open .kiosk-title {
    display: none;
  }

  body.keyboard-open .kiosk-entry-form {
    padding: 10px;
  }

  body.keyboard-open .kiosk-field {
    margin-bottom: 6px;
  }

  body.keyboard-open .kiosk-entry-form label,
  body.keyboard-open .tenant-picker legend {
    margin-bottom: 4px;
    font-size: 0.78rem;
  }

  body.keyboard-open .kiosk-entry-form .plate-input {
    min-height: 50px;
    font-size: 1.9rem;
  }

  body.keyboard-open .kiosk-entry-form input {
    min-height: 36px;
    font-size: 0.94rem;
  }

  body.keyboard-open .tenant-buttons {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    max-height: 45px;
    gap: 5px;
  }

  body.keyboard-open .tenant-choice {
    min-height: 34px;
    padding: 5px 7px;
    font-size: 0.76rem;
  }

  body.keyboard-open .kiosk-actions {
    margin-top: 7px;
  }

  body.keyboard-open .kiosk-submit,
  body.keyboard-open .kiosk-secondary-action {
    min-height: 38px;
    font-size: 0.9rem;
  }

  .kiosk-keyboard {
    right: 6px;
    bottom: 0;
    left: 6px;
    max-width: none;
    border-radius: 8px 8px 0 0;
    padding: 6px;
  }

  .keyboard-topline {
    display: none;
  }

  .keyboard-key {
    min-height: 27px;
    padding: 3px 5px;
    font-size: 0.8rem;
  }

  .keyboard-row {
    gap: 4px;
  }

  .keyboard-keys {
    gap: 4px;
  }

  .keyboard-key.key-clear,
  .keyboard-key.key-done,
  .keyboard-key.key-backspace,
  .keyboard-key.key-shift {
    font-size: 0.72rem;
  }

  .confirm-panel {
    padding: 16px;
  }

  .confirm-panel dl {
    grid-template-columns: 90px 1fr;
    gap: 5px 12px;
    margin-top: 12px;
  }

  .confirm-panel .plate-display {
    min-height: 62px;
    font-size: 1.9rem;
  }
}

@media (max-width: 760px), (orientation: portrait) {
  .kiosk-shell {
    align-items: start;
    padding: 16px;
    overflow: auto;
  }

  .kiosk-form {
    display: block;
  }

  .kiosk-title {
    margin-bottom: 14px;
  }

  .kiosk-title h1 {
    max-width: none;
    font-size: 2.4rem;
  }

  .tenant-buttons {
    grid-template-columns: 1fr 1fr;
  }

  .kiosk-actions {
    grid-template-columns: 1fr;
  }

  body.keyboard-open .kiosk-shell {
    padding-bottom: 250px;
  }

  .kiosk-keyboard {
    right: 8px;
    bottom: 8px;
    left: 8px;
  }

  .keyboard-key {
    min-height: 38px;
    padding: 5px;
    font-size: 0.92rem;
  }
}
