:root {
  --navy: #0f2444;
  --navy-soft: #1a3766;
  --gold: #d3a44f;
  --paper: #f3f0ea;
  --desk: #e4ddd2;
  --card: #ffffff;
  --ink: #1c2430;
  --muted: #5d6b7c;
  --line: #ddd4c6;
  --ok: #1f7a4d;
  --danger: #8e2f2f;
  --shadow: 0 12px 32px rgba(15, 36, 68, 0.12);
  font-family: "Segoe UI", "Helvetica Neue", sans-serif;
  color: var(--ink);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--desk);
}

body {
  overscroll-behavior: none;
}

button, input {
  font: inherit;
}

button {
  cursor: pointer;
}

.shell {
  width: min(860px, 100%);
  min-height: 100dvh;
  margin: 0 auto;
  background: var(--paper);
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  padding: 10px 16px;
  background: white;
  color: var(--navy);
  border-bottom: 4px solid var(--gold);
  box-shadow: 0 1px 0 var(--navy);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand img {
  height: 42px;
  width: auto;
  display: block;
}

.brand-label {
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.03em;
  color: var(--navy);
  padding-left: 12px;
  border-left: 1px solid var(--line);
}

.hero-logo {
  width: min(260px, 72%);
  height: auto;
  display: block;
  margin-bottom: 4px;
}

.login-card .hero-logo {
  margin-inline: auto;
  margin-bottom: 8px;
}

.site-btn {
  margin-left: auto;
  border: 1px solid #c5d0de;
  background: #f4f7fb;
  color: var(--navy);
  border-radius: 999px;
  min-height: 40px;
  padding: 0 14px;
  font-weight: 700;
}

.site-btn:hover { background: #e7eef8; }

.status-pills {
  display: flex;
  gap: 8px;
  align-items: center;
}

.pill {
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.82rem;
  background: #e7f2ec;
  color: var(--ok);
  font-weight: 650;
}

.pill.is-off { background: #f8ecd4; color: #7a5b16; }

.pill.is-wait { background: var(--gold); color: var(--navy); font-weight: 650; }

.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 22px 18px 24px;
}

.screen[hidden] { display: none !important; }

.eyebrow {
  margin: 0;
  color: var(--gold);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.78rem;
}

h1 {
  margin: 0;
  font-size: clamp(1.7rem, 3vw, 2.3rem);
  line-height: 1.15;
  color: var(--navy);
}

.lead {
  margin: 0;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.45;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 16px;
}

.fields { display: flex; flex-direction: column; gap: 12px; }

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-weight: 650;
  color: var(--navy);
}

input[type="text"],
input[type="password"],
input[type="date"],
input[type="search"] {
  min-height: 52px;
  border-radius: 12px;
  border: 1px solid #cfc5b6;
  padding: 0 14px;
  background: white;
  color: var(--ink);
}

input:focus {
  outline: 3px solid rgba(211, 164, 79, 0.45);
  border-color: var(--gold);
}

.hint { margin: 0; color: var(--muted); font-size: 0.92rem; }

.actions {
  display: flex;
  gap: 10px;
  margin-top: auto;
}

.btn {
  appearance: none;
  border: 0;
  border-radius: 12px;
  min-height: 56px;
  padding: 0 16px;
  background: white;
  color: var(--navy);
  border: 1px solid #cfc5b6;
  font-weight: 700;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--navy);
  color: white;
  border-color: var(--navy);
}

.actions .btn-primary { flex: 1; }

select {
  min-height: 52px;
  border-radius: 12px;
  border: 1px solid #cfc5b6;
  padding: 0 14px;
  background: white;
  color: var(--ink);
}

.btn-gold {
  background: var(--gold);
  color: var(--navy);
  border-color: var(--gold);
}

.btn-danger {
  background: white;
  color: var(--danger);
  border-color: #e2c2c2;
}

.grow { flex: 1; min-height: 0; }

.guide-frame {
  background: white;
  border-radius: 16px;
  overflow: auto;
  box-shadow: var(--shadow);
  min-height: 0;
  flex: 1;
}

.guide-frame img {
  display: block;
  width: 100%;
  height: auto;
}

.pager {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--navy);
  font-weight: 700;
}

.statement {
  margin: 0;
  line-height: 1.45;
}

.pad-wrap {
  background: white;
  border-radius: 16px;
  border: 1px dashed #b7ad9e;
  overflow: hidden;
}

canvas#pad {
  width: 100%;
  height: 220px;
  touch-action: none;
  display: block;
  cursor: crosshair;
}

.msg {
  min-height: 1.2em;
  margin: 0;
  color: var(--danger);
  font-weight: 650;
}

.msg.is-ok { color: var(--ok); }

dialog {
  width: min(520px, calc(100% - 24px));
  border: 0;
  border-radius: 18px;
  padding: 18px;
  box-shadow: var(--shadow);
}

dialog::backdrop { background: rgba(15, 36, 68, 0.48); }

.site-list { display: flex; flex-direction: column; gap: 8px; margin: 12px 0; }

.site-choice {
  text-align: left;
  min-height: 58px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: white;
  padding: 0 14px;
  font-weight: 700;
  color: var(--navy);
}

.site-choice.is-current { border-color: var(--gold); background: #fbf6ec; }

.admin-shell { width: min(1200px, 100%); }

.tabs { display: flex; gap: 8px; padding: 16px 16px 0; }

.tab {
  min-height: 44px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--navy);
  padding: 0 14px;
  font-weight: 700;
}

.tab.is-on { background: var(--navy); color: white; }

.panel { padding: 16px; display: flex; flex-direction: column; gap: 14px; }

.panel[hidden] { display: none !important; }

.filters, .inline {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: end;
}

.filters label, .inline label { flex: 1; min-width: 160px; }

.table-wrap { overflow: auto; background: white; border-radius: 16px; border: 1px solid var(--line); }

table { width: 100%; border-collapse: collapse; }

th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }

th { color: var(--muted); font-size: 0.82rem; letter-spacing: 0.04em; text-transform: uppercase; }

tr.clickable { cursor: pointer; }

tr.clickable:hover { background: #faf7f2; }

.site-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  align-items: center;
  background: white;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px;
}

.site-row input { min-width: 0; }

.login-wrap {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card { width: min(440px, 100%); display: flex; flex-direction: column; gap: 14px; }

.detail-grid { display: grid; grid-template-columns: 160px 1fr; gap: 8px 12px; }

.detail-grid dt { color: var(--muted); }

.detail-grid dd { margin: 0; font-weight: 650; }

.sign-preview {
  width: min(420px, 100%);
  background: white;
  border: 1px solid var(--line);
  border-radius: 12px;
}

#detail { width: min(640px, calc(100% - 24px)); }

#detail .actions { flex-wrap: wrap; }

#delete-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#delete-box textarea {
  min-height: 88px;
  border-radius: 12px;
  border: 1px solid #cfc5b6;
  padding: 10px 14px;
  font: inherit;
  resize: vertical;
  color: var(--ink);
}

#delete-box textarea:focus {
  outline: 3px solid rgba(211, 164, 79, 0.45);
  border-color: var(--gold);
}

td.reason { max-width: 260px; white-space: normal; }

.top-actions { margin-left: auto; display: flex; gap: 8px; }

.top-actions .btn, .filters .btn, .inline .btn, .site-row .btn { min-height: 44px; }

@media print {
  body { background: white; }
  .topbar, .tabs, .panel, #login-view { display: none !important; }
  #detail { display: block; position: static; width: 100%; box-shadow: none; }
}
