:root {
  color-scheme: light;
  --bg: #f5f7f9;
  --panel: #ffffff;
  --panel-strong: #eef3f6;
  --ink: #1c252c;
  --muted: #5c6974;
  --line: #d7e0e7;
  --blue: #1f6feb;
  --blue-dark: #164ea6;
  --green: #237a57;
  --red: #ad3434;
  --yellow: #8a6100;
  --shadow: 0 16px 40px rgba(31, 47, 63, 0.11);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body.access-locked .app-shell {
  display: none;
}

body.live-internal .nav-button[data-view="admin"],
body.live-internal #resetDemo,
body.live-internal #saveLocal,
body.live-internal .staff-user-field,
body.live-internal .staff-pin-field {
  display: none;
}

body.live-admin .nav-button[data-view="admin"] {
  display: block;
}

body:not(.access-locked) .access-gate {
  display: none;
}

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

.access-gate-panel {
  width: min(100%, 520px);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 28px;
}

.access-gate-panel .brand-logo {
  margin-bottom: 18px;
}

.access-gate-panel p:last-child {
  margin: 14px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

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

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
}

.sidebar {
  background: #17212b;
  color: #f9fbfd;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.brand-block {
  display: flex;
  gap: 14px;
  align-items: center;
}

.brand-mark {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  background: #f7c948;
  color: #17212b;
  border-radius: 6px;
  font-weight: 800;
}

.brand-logo {
  width: 96px;
  height: 96px;
  display: block;
  object-fit: contain;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
}

.sidebar-logo {
  width: 52px;
  height: 52px;
  flex: 0 0 auto;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.2;
  text-transform: uppercase;
  letter-spacing: 0;
  font-weight: 700;
}

.sidebar .eyebrow {
  color: #aab6c1;
}

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

h1 {
  font-size: 22px;
}

h2 {
  font-size: 28px;
}

h3 {
  font-size: 20px;
}

.nav-stack {
  display: grid;
  gap: 8px;
}

.nav-button {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid transparent;
  background: transparent;
  color: #d9e2ec;
  border-radius: 6px;
  text-align: left;
  cursor: pointer;
}

.nav-button.active,
.nav-button:hover {
  background: #253241;
  border-color: #3a4b5d;
  color: #ffffff;
}

.status-panel {
  margin-top: auto;
  padding: 16px;
  background: #22303d;
  border: 1px solid #354657;
  border-radius: 8px;
  display: grid;
  gap: 6px;
}

.panel-label {
  margin: 0;
  color: #aab6c1;
  font-size: 12px;
  text-transform: uppercase;
  font-weight: 700;
}

.status-panel span {
  color: #ccd6df;
  font-size: 13px;
}

.main-panel {
  min-width: 0;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.topbar-actions,
.form-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.primary-button,
.secondary-button {
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 9px 14px;
  cursor: pointer;
  font-weight: 700;
}

.primary-button {
  background: var(--blue);
  color: #ffffff;
}

.primary-button:hover {
  background: var(--blue-dark);
}

.secondary-button {
  background: #ffffff;
  border-color: var(--line);
  color: var(--ink);
}

.secondary-button:hover {
  background: var(--panel-strong);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.content-grid {
  display: grid;
  gap: 18px;
}

.two-column {
  grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.7fr);
}

.admin-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.span-admin {
  grid-column: 1 / -1;
}

.work-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 20px;
  min-width: 0;
}

.section-heading {
  margin-bottom: 18px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

label {
  display: grid;
  gap: 7px;
  color: #34434f;
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--ink);
  padding: 10px 11px;
  min-height: 40px;
}

textarea {
  resize: vertical;
}

#configPackage {
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  line-height: 1.45;
  min-height: 150px;
}

select[multiple] {
  min-height: 112px;
}

.span-all {
  grid-column: 1 / -1;
}

.summary-panel {
  position: sticky;
  top: 24px;
  align-self: start;
}

.summary-list {
  display: grid;
  gap: 10px;
  margin: 0;
}

.summary-row {
  display: grid;
  grid-template-columns: minmax(120px, 0.8fr) minmax(0, 1fr);
  gap: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.summary-row dt {
  color: var(--muted);
  font-size: 13px;
}

.summary-row dd {
  margin: 0;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.notice {
  margin-top: 18px;
  border-left: 4px solid var(--blue);
  background: #eef5ff;
  padding: 12px;
  border-radius: 6px;
  color: #24415f;
  line-height: 1.45;
}

.notice.warning {
  border-left-color: var(--yellow);
  background: #fff8e6;
  color: #5f450b;
}

.notice.success {
  border-left-color: var(--green);
  background: #edf8f2;
  color: #1f513c;
}

.compact-notice {
  margin-top: 14px;
}

.field-map,
.staff-list,
.audit-log,
.checklist {
  display: grid;
  gap: 10px;
}

.map-row,
.staff-row,
.audit-row,
.check-row {
  border: 1px solid var(--line);
  background: #fbfcfd;
  border-radius: 6px;
  padding: 12px;
}

.map-row {
  display: grid;
  grid-template-columns: minmax(130px, 0.8fr) minmax(180px, 1fr);
  gap: 12px;
  align-items: center;
}

.map-row strong,
.staff-row strong {
  display: block;
  margin-bottom: 4px;
}

.hint {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.inline-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  gap: 10px;
  margin-top: 14px;
}

.checklist {
  list-style: none;
  padding: 0;
  margin: 0;
}

.check-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.check-icon {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-size: 13px;
  font-weight: 800;
  flex: 0 0 auto;
}

.check-icon.pass {
  background: #dff3e8;
  color: var(--green);
}

.check-icon.fail {
  background: #f8dddd;
  color: var(--red);
}

.audit-row {
  display: grid;
  gap: 4px;
}

.audit-meta {
  color: var(--muted);
  font-size: 12px;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }

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

  .summary-panel {
    position: static;
  }
}

@media (max-width: 640px) {
  .main-panel,
  .sidebar {
    padding: 18px;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

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

  h2 {
    font-size: 24px;
  }
}
